1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "effectstack/effectstackview2.h"
40 #include "transitionsettings.h"
41 #include "renderwidget.h"
44 #include "jogshuttle.h"
45 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
48 #include "clipproperties.h"
50 #include "commands/editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "config-kdenlive.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "scopes/scopemanager.h"
59 #include "scopes/colorscopes/vectorscope.h"
60 #include "scopes/colorscopes/waveform.h"
61 #include "scopes/colorscopes/rgbparade.h"
62 #include "scopes/colorscopes/histogram.h"
63 #include "scopes/audioscopes/audiosignal.h"
64 #include "scopes/audioscopes/audiospectrum.h"
65 #include "scopes/audioscopes/spectrogram.h"
66 #include "archivewidget.h"
67 #include "databackup/backupwidget.h"
68 #include "utils/resourcewidget.h"
71 #include <KApplication>
75 #include <KActionCollection>
76 #include <KActionCategory>
77 #include <KStandardAction>
78 #include <KShortcutsDialog>
79 #include <KFileDialog>
80 #include <KMessageBox>
82 #include <KIO/NetAccess>
85 #include <KConfigDialog>
86 #include <KXMLGUIFactory>
88 #include <kstandarddirs.h>
89 #include <KUrlRequesterDialog>
90 #include <KTemporaryFile>
92 #include <KActionMenu>
94 #include <ktogglefullscreenaction.h>
96 #include <KNotification>
97 #include <KNotifyConfigWidget>
98 #if KDE_IS_VERSION(4,3,80)
99 #include <knewstuff3/downloaddialog.h>
100 #include <knewstuff3/knewstuffaction.h>
102 #include <knewstuff2/engine.h>
103 #include <knewstuff2/ui/knewstuffaction.h>
107 #include <KColorScheme>
108 #include <KProgressDialog>
110 #include <QTextStream>
114 #include <QInputDialog>
115 #include <QDesktopWidget>
121 // Uncomment for deeper debugging
122 //#define DEBUG_MAINW
128 static const char version[] = VERSION;
130 static const int ID_TIMELINE_POS = 0;
136 Q_DECLARE_METATYPE(QVector<int16_t>)
139 EffectsList MainWindow::videoEffects;
140 EffectsList MainWindow::audioEffects;
141 EffectsList MainWindow::customEffects;
142 EffectsList MainWindow::transitions;
144 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
145 KXmlGuiWindow(parent),
146 m_activeDocument(NULL),
147 m_activeTimeline(NULL),
149 m_renderWidget(NULL),
150 #ifdef USE_JOGSHUTTLE
154 m_findActivated(false),
157 qRegisterMetaType<QVector<int16_t> > ();
158 qRegisterMetaType<stringMap> ("stringMap");
159 qRegisterMetaType<audioByteArray> ("audioByteArray");
162 QLocale systemLocale = QLocale();
163 setlocale(LC_NUMERIC, NULL);
164 char *separator = localeconv()->decimal_point;
165 if (separator != systemLocale.decimalPoint()) {
166 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
167 // HACK: There is a locale conflict, so set locale to at least have correct decimal point
168 if (strncmp(separator, ".", 1) == 0) systemLocale = QLocale::c();
169 else if (strncmp(separator, ",", 1) == 0) systemLocale = QLocale("fr_FR.UTF-8");
172 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
173 QLocale::setDefault(systemLocale);
175 // Create DBus interface
176 new MainWindowAdaptor(this);
177 QDBusConnection dbus = QDBusConnection::sessionBus();
178 dbus.registerObject("/MainWindow", this);
180 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
181 setFont(KGlobalSettings::toolBarFont());
182 parseProfiles(MltPath);
183 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
184 m_commandStack = new QUndoGroup;
185 setDockNestingEnabled(true);
186 m_timelineArea = new KTabWidget(this);
187 m_timelineArea->setTabReorderingEnabled(true);
188 m_timelineArea->setTabBarHidden(true);
189 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
190 m_timelineArea->setMinimumHeight(200);
192 QToolButton *closeTabButton = new QToolButton;
193 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
194 closeTabButton->setIcon(KIcon("tab-close"));
195 closeTabButton->adjustSize();
196 closeTabButton->setToolTip(i18n("Close the current tab"));
197 m_timelineArea->setCornerWidget(closeTabButton);
198 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
200 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
201 m_findTimer.setSingleShot(true);
203 // FIXME: the next call returns a newly allocated object, which leaks
204 initEffects::parseEffectFiles();
205 //initEffects::parseCustomEffectsFile();
207 m_monitorManager = new MonitorManager();
209 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
210 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
215 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
216 m_projectListDock->setObjectName("project_tree");
217 m_projectList = new ProjectList();
218 m_projectListDock->setWidget(m_projectList);
219 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
221 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
222 m_clipMonitorDock->setObjectName("clip_monitor");
223 m_clipMonitor = new Monitor(Kdenlive::clipMonitor, m_monitorManager, QString(), m_timelineArea);
224 m_clipMonitorDock->setWidget(m_clipMonitor);
226 // Connect the project list
227 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
228 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(slotActivateMonitor()));
229 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
230 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
231 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
232 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
233 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
234 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
235 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
236 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
237 connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
239 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
240 m_projectMonitorDock->setObjectName("project_monitor");
241 m_projectMonitor = new Monitor(Kdenlive::projectMonitor, m_monitorManager, QString());
242 m_projectMonitorDock->setWidget(m_projectMonitor);
245 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
246 m_recMonitorDock->setObjectName("record_monitor");
247 m_recMonitor = new RecMonitor(Kdenlive::recordMonitor, m_monitorManager);
248 m_recMonitorDock->setWidget(m_recMonitor);
249 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
250 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
251 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
253 #endif /* ! Q_WS_MAC */
254 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
256 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
257 m_notesDock->setObjectName("notes_widget");
258 m_notesWidget = new NotesWidget();
259 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
260 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
262 m_notesWidget->setTabChangesFocus(true);
263 #if KDE_IS_VERSION(4,4,0)
264 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
266 m_notesDock->setWidget(m_notesWidget);
267 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
269 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
270 m_effectStackDock->setObjectName("effect_stack");
271 m_effectStack = new EffectStackView2(m_projectMonitor);
272 m_effectStackDock->setWidget(m_effectStack);
273 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
274 connect(m_effectStack, SIGNAL(startFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&)), m_projectList, SLOT(slotStartFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&)));
276 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
277 m_transitionConfigDock->setObjectName("transition");
278 m_transitionConfig = new TransitionSettings(m_projectMonitor);
279 m_transitionConfigDock->setWidget(m_transitionConfig);
280 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
282 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
283 m_effectListDock->setObjectName("effect_list");
284 m_effectList = new EffectsListView();
285 m_effectListDock->setWidget(m_effectList);
286 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
288 m_scopeManager = new ScopeManager(m_monitorManager);
289 m_vectorscope = new Vectorscope();
290 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
291 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
292 m_vectorscopeDock->setWidget(m_vectorscope);
293 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
294 m_scopeManager->addScope(m_vectorscope, m_vectorscopeDock);
296 m_waveform = new Waveform();
297 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
298 m_waveformDock->setObjectName(m_waveform->widgetName());
299 m_waveformDock->setWidget(m_waveform);
300 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
301 m_scopeManager->addScope(m_waveform, m_waveformDock);
303 m_RGBParade = new RGBParade();
304 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
305 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
306 m_RGBParadeDock->setWidget(m_RGBParade);
307 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
308 m_scopeManager->addScope(m_RGBParade, m_RGBParadeDock);
310 m_histogram = new Histogram();
311 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
312 m_histogramDock->setObjectName(m_histogram->widgetName());
313 m_histogramDock->setWidget(m_histogram);
314 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
315 m_scopeManager->addScope(m_histogram, m_histogramDock);
317 m_audiosignal = new AudioSignal;
318 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
319 m_audiosignalDock->setObjectName("audiosignal");
320 m_audiosignalDock->setWidget(m_audiosignal);
321 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
322 m_scopeManager->addScope(m_audiosignal, m_audiosignalDock);
324 m_audioSpectrum = new AudioSpectrum();
325 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
326 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
327 m_audioSpectrumDock->setWidget(m_audioSpectrum);
328 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
329 m_scopeManager->addScope(m_audioSpectrum, m_audioSpectrumDock);
331 m_spectrogram = new Spectrogram();
332 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
333 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
334 m_spectrogramDock->setWidget(m_spectrogram);
335 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
336 m_scopeManager->addScope(m_spectrogram, m_spectrogramDock);
338 // Add monitors here to keep them at the right of the window
339 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
340 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
342 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
345 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
346 m_undoViewDock->setObjectName("undo_history");
347 m_undoView = new QUndoView();
348 m_undoView->setCleanIcon(KIcon("edit-clear"));
349 m_undoView->setEmptyLabel(i18n("Clean"));
350 m_undoViewDock->setWidget(m_undoView);
351 m_undoView->setGroup(m_commandStack);
352 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
356 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
359 // Close non-general docks for the initial layout
360 // only show important ones
361 m_histogramDock->close();
362 m_RGBParadeDock->close();
363 m_waveformDock->close();
364 m_vectorscopeDock->close();
366 m_audioSpectrumDock->close();
367 m_spectrogramDock->close();
368 m_audiosignalDock->close();
370 m_undoViewDock->close();
374 /// Tabify Widgets ///
375 tabifyDockWidget(m_effectListDock, m_effectStackDock);
376 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
377 tabifyDockWidget(m_projectListDock, m_notesDock);
379 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
381 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
387 setCentralWidget(m_timelineArea);
390 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
392 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
393 m_fileRevert->setEnabled(false);
395 // Prepare layout actions
396 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
397 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
398 for (int i = 1; i < 5; i++) {
399 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
400 load->setData("_" + QString::number(i));
401 layoutActions->addAction("load_layout" + QString::number(i), load);
402 m_loadLayout->addAction(load);
403 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
404 save->setData("_" + QString::number(i));
405 layoutActions->addAction("save_layout" + QString::number(i), save);
407 layoutActions->addAction("load_layouts", m_loadLayout);
408 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
411 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
412 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
413 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
414 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
415 m_stopmotion_actions->addAction("stopmotion_capture", action);
416 action = new KAction(i18n("Switch live / captured frame"), this);
417 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
418 m_stopmotion_actions->addAction("stopmotion_switch", action);
419 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
420 action->setCheckable(true);
421 action->setChecked(false);
422 m_stopmotion_actions->addAction("stopmotion_overlay", action);
424 // Build effects menu
425 m_effectsMenu = new QMenu(i18n("Add Effect"));
426 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
427 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
428 m_effectsActionCollection->readSettings();
432 // Find QDockWidget tab bars and show / hide widget title bars on right click
433 QList <QTabBar *> tabs = findChildren<QTabBar *>();
434 for (int i = 0; i < tabs.count(); i++) {
435 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
436 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
439 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
440 guiFactory()->addClient(sp);*/
441 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
442 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
445 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
447 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
450 // Load layout names from config file
457 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
458 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
460 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
461 clipInTimeline->setIcon(KIcon("go-jump"));
462 QHash<QString,QMenu*> menus;
463 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
464 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
465 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
466 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
467 menus.insert("inTimelineMenu",clipInTimeline);
468 m_projectList->setupGeneratorMenu(menus);
470 // build themes menus
471 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
472 QActionGroup *themegroup = new QActionGroup(this);
473 themegroup->setExclusive(true);
474 action = new KAction(i18n("Default"), this);
475 action->setCheckable(true);
476 themegroup->addAction(action);
477 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
479 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
481 for (int i = 0; i < schemeFiles.size(); ++i) {
483 const QString filename = schemeFiles.at(i);
484 const QFileInfo info(filename);
487 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
488 QIcon icon = createSchemePreviewIcon(config);
489 KConfigGroup group(config, "General");
490 const QString name = group.readEntry("Name", info.baseName());
491 action = new KAction(name, this);
492 action->setData(filename);
493 action->setIcon(icon);
494 action->setCheckable(true);
495 themegroup->addAction(action);
496 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
499 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
500 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
501 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
504 action = new QAction(fi.fileName(), this);
505 action->setData(*it);
506 action->setCheckable(true);
507 themegroup->addAction(action);
508 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
510 themesMenu->addActions(themegroup->actions());
511 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
513 // Setup and fill effects and transitions menus.
516 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
517 m->addActions(m_effectsMenu->actions());
520 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
521 for (int i = 0; i < transitions.count(); ++i)
522 m_transitionsMenu->addAction(m_transitions[i]);
524 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
525 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
526 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
528 m_effectStack->setMenu(m_effectsMenu);
530 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
531 const QList<QAction *> viewActions = createPopupMenu()->actions();
532 viewMenu->insertActions(NULL, viewActions);
534 m_timelineContextMenu = new QMenu(this);
535 m_timelineContextClipMenu = new QMenu(this);
536 m_timelineContextTransitionMenu = new QMenu(this);
538 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
539 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
540 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
542 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
543 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
544 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
545 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
546 m_timelineContextClipMenu->addSeparator();
547 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
548 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
549 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
550 m_timelineContextClipMenu->addSeparator();
551 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
552 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
553 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
554 m_timelineContextClipMenu->addSeparator();
556 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
557 m_timelineContextClipMenu->addMenu(markersMenu);
558 m_timelineContextClipMenu->addSeparator();
559 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
560 m_timelineContextClipMenu->addMenu(m_effectsMenu);
562 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
563 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
564 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
566 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
568 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
569 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
570 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
571 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
573 slotConnectMonitors();
575 // Open or create a file. Command line argument passed in Url has
576 // precedence, then "openlastproject", then just a plain empty file.
577 // If opening Url fails, openlastproject will _not_ be used.
578 if (!Url.isEmpty()) {
579 // delay loading so that the window shows up
581 QTimer::singleShot(500, this, SLOT(openFile()));
582 } else if (KdenliveSettings::openlastproject()) {
583 QTimer::singleShot(500, this, SLOT(openLastFile()));
584 } else { //if (m_timelineArea->count() == 0) {
588 if (!clipsToLoad.isEmpty() && m_activeDocument) {
589 QStringList list = clipsToLoad.split(',');
591 foreach(QString path, list) {
592 kDebug() << QDir::current().absoluteFilePath(path);
593 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
595 m_projectList->slotAddClip(urls);
598 #ifdef USE_JOGSHUTTLE
599 activateShuttleDevice();
601 m_projectListDock->raise();
603 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
604 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
606 // Populate encoding profiles
607 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
608 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
609 KConfigGroup group(&conf, "proxy");
610 QMap< QString, QString > values = group.entryMap();
611 QMapIterator<QString, QString> i(values);
614 QString data = i.value();
615 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
616 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
619 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
620 KConfigGroup group(&conf, "video4linux");
621 QMap< QString, QString > values = group.entryMap();
622 QMapIterator<QString, QString> i(values);
625 QString data = i.value();
626 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
627 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
630 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
631 KConfigGroup group(&conf, "decklink");
632 QMap< QString, QString > values = group.entryMap();
633 QMapIterator<QString, QString> i(values);
636 QString data = i.value();
637 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
638 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
643 MainWindow::~MainWindow()
648 m_effectStack->slotClipItemSelected(NULL, 0);
649 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
651 if (m_projectMonitor) m_projectMonitor->stop();
652 if (m_clipMonitor) m_clipMonitor->stop();
654 delete m_activeTimeline;
655 delete m_effectStack;
656 delete m_transitionConfig;
657 delete m_activeDocument;
658 delete m_projectMonitor;
659 delete m_clipMonitor;
660 delete m_shortcutRemoveFocus;
661 delete[] m_transitions;
662 delete m_monitorManager;
663 delete m_scopeManager;
664 Mlt::Factory::close();
668 bool MainWindow::queryClose()
670 if (m_renderWidget) {
671 int waitingJobs = m_renderWidget->waitingJobsCount();
672 if (waitingJobs > 0) {
673 switch (KMessageBox::warningYesNoCancel(this, i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?", "You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
674 case KMessageBox::Yes :
675 // create script with waiting jobs and start it
676 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
678 case KMessageBox::No :
679 // Don't do anything, jobs will be deleted
687 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
688 // warn the user to save if document is modified and we have clips in our project list
689 if (m_activeDocument && m_activeDocument->isModified() &&
690 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
691 !m_projectList->documentClipList().isEmpty())) {
695 if (m_activeDocument->url().fileName().isEmpty())
696 message = i18n("Save changes to document?");
698 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
699 switch (KMessageBox::warningYesNoCancel(this, message)) {
700 case KMessageBox::Yes :
701 // save document here. If saving fails, return false;
703 case KMessageBox::No :
704 // User does not want to save the changes, clear recovery files
705 m_activeDocument->m_autosave->resize(0);
714 void MainWindow::loadPlugins()
716 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
717 populateMenus(plugin);
720 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
722 filters << "libkdenlive*";
723 foreach(const QString & folder, directories) {
724 kDebug() << "Parsing plugin folder: " << folder;
725 QDir pluginsDir(folder);
726 foreach(const QString & fileName,
727 pluginsDir.entryList(filters, QDir::Files)) {
729 * Avoid loading the same plugin twice when there is more than one
732 if (!m_pluginFileNames.contains(fileName)) {
733 kDebug() << "Found plugin: " << fileName;
734 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
735 QObject *plugin = loader.instance();
737 populateMenus(plugin);
738 m_pluginFileNames += fileName;
740 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
746 void MainWindow::populateMenus(QObject *plugin)
748 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
749 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
751 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
755 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
756 QMenu *menu, const char *member,
757 QActionGroup *actionGroup)
759 kDebug() << "// ADD to MENU" << texts;
760 foreach(const QString & text, texts) {
761 QAction *action = new QAction(text, plugin);
762 action->setData(text);
763 connect(action, SIGNAL(triggered()), this, member);
764 menu->addAction(action);
767 action->setCheckable(true);
768 actionGroup->addAction(action);
773 void MainWindow::aboutPlugins()
775 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
780 void MainWindow::generateClip()
782 QAction *action = qobject_cast<QAction *>(sender());
783 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
785 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
786 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
787 if (!clipUrl.isEmpty()) {
788 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
792 void MainWindow::saveProperties(KConfigGroup &config)
794 // save properties here,used by session management
796 KMainWindow::saveProperties(config);
800 void MainWindow::readProperties(const KConfigGroup &config)
802 // read properties here,used by session management
803 KMainWindow::readProperties(config);
804 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
805 openFile(KUrl(Lastproject));
808 void MainWindow::slotReloadEffects()
810 initEffects::parseCustomEffectsFile();
811 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
814 #ifdef USE_JOGSHUTTLE
815 void MainWindow::activateShuttleDevice()
821 if (KdenliveSettings::enableshuttle() == false) return;
823 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
824 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
826 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
827 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
828 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
829 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
830 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
832 #endif /* USE_JOGSHUTTLE */
834 void MainWindow::slotDoAction(const QString& action_name)
836 QAction* action = actionCollection()->action(action_name);
838 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
844 void MainWindow::configureNotifications()
846 KNotifyConfigWidget::configure(this);
849 void MainWindow::slotFullScreen()
851 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
854 void MainWindow::slotAddEffect(const QDomElement effect)
856 if (!m_activeDocument) return;
857 if (effect.isNull()) {
858 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
861 QDomElement effectToAdd = effect.cloneNode().toElement();
863 int ix = m_effectStack->isTrackMode(&ok);
864 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
865 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
868 void MainWindow::slotUpdateClip(const QString &id)
870 if (!m_activeDocument) return;
871 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
873 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
874 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
875 Mlt::Producer *monitorProducer = clip->getCloneProducer();
876 m_clipMonitor->updateClipProducer(monitorProducer);
878 clip->cleanupProducers();
881 void MainWindow::slotConnectMonitors()
883 m_projectList->setRenderer(m_projectMonitor->render);
884 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
885 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
886 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
887 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
888 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
889 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)));
891 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
893 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
895 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
897 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
898 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
900 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
902 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
903 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
906 void MainWindow::slotAdjustClipMonitor()
908 m_clipMonitorDock->updateGeometry();
909 m_clipMonitorDock->adjustSize();
910 m_clipMonitor->resetSize();
913 void MainWindow::slotAdjustProjectMonitor()
915 m_projectMonitorDock->updateGeometry();
916 m_projectMonitorDock->adjustSize();
917 m_projectMonitor->resetSize();
921 class NameGrabbingKActionCollection {
923 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
924 : m_collection(collection), m_action_names(action_names) {
925 m_action_names.clear();
927 KAction* addAction(const QString& action_name) {
928 m_action_names << action_name;
929 return m_collection->addAction(action_name);
931 void addAction(const QString& action_name, QAction* action) {
932 m_action_names << action_name;
933 m_collection->addAction(action_name, action);
935 operator KActionCollection*() { return m_collection; }
936 const QStringList& actionNames() const { return m_action_names; }
938 KActionCollection* m_collection;
939 QStringList& m_action_names;
942 void MainWindow::setupActions()
945 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
946 m_timecodeFormat = new KComboBox(this);
947 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
948 m_timecodeFormat->addItem(i18n("Frames"));
949 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
950 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
952 m_statusProgressBar = new QProgressBar(this);
953 m_statusProgressBar->setMinimum(0);
954 m_statusProgressBar->setMaximum(100);
955 m_statusProgressBar->setMaximumWidth(150);
956 m_statusProgressBar->setVisible(false);
958 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
959 toolbar->setMovable(false);
960 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
961 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
962 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
963 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
964 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
965 QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
966 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
968 //create edit mode buttons
969 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
970 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
971 toolbar->addAction(m_normalEditTool);
972 m_normalEditTool->setCheckable(true);
973 m_normalEditTool->setChecked(true);
975 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
976 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
977 toolbar->addAction(m_overwriteEditTool);
978 m_overwriteEditTool->setCheckable(true);
979 m_overwriteEditTool->setChecked(false);
981 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
982 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
983 toolbar->addAction(m_insertEditTool);
984 m_insertEditTool->setCheckable(true);
985 m_insertEditTool->setChecked(false);
986 // not implemented yet
987 m_insertEditTool->setEnabled(false);
989 QActionGroup *editGroup = new QActionGroup(this);
990 editGroup->addAction(m_normalEditTool);
991 editGroup->addAction(m_overwriteEditTool);
992 editGroup->addAction(m_insertEditTool);
993 editGroup->setExclusive(true);
994 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
995 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
997 toolbar->addSeparator();
999 // create tools buttons
1000 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1001 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1002 toolbar->addAction(m_buttonSelectTool);
1003 m_buttonSelectTool->setCheckable(true);
1004 m_buttonSelectTool->setChecked(true);
1006 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1007 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1008 toolbar->addAction(m_buttonRazorTool);
1009 m_buttonRazorTool->setCheckable(true);
1010 m_buttonRazorTool->setChecked(false);
1012 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1013 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1014 toolbar->addAction(m_buttonSpacerTool);
1015 m_buttonSpacerTool->setCheckable(true);
1016 m_buttonSpacerTool->setChecked(false);
1018 QActionGroup *toolGroup = new QActionGroup(this);
1019 toolGroup->addAction(m_buttonSelectTool);
1020 toolGroup->addAction(m_buttonRazorTool);
1021 toolGroup->addAction(m_buttonSpacerTool);
1022 toolGroup->setExclusive(true);
1023 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1025 QWidget * actionWidget;
1026 int max = toolbar->iconSizeDefault() + 2;
1027 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1028 actionWidget->setMaximumWidth(max);
1029 actionWidget->setMaximumHeight(max - 4);
1031 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1032 actionWidget->setMaximumWidth(max);
1033 actionWidget->setMaximumHeight(max - 4);
1035 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1036 actionWidget->setMaximumWidth(max);
1037 actionWidget->setMaximumHeight(max - 4);
1039 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1040 actionWidget->setMaximumWidth(max);
1041 actionWidget->setMaximumHeight(max - 4);
1043 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1044 actionWidget->setMaximumWidth(max);
1045 actionWidget->setMaximumHeight(max - 4);
1047 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1048 actionWidget->setMaximumWidth(max);
1049 actionWidget->setMaximumHeight(max - 4);
1051 toolbar->setStyleSheet(style1);
1052 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1054 toolbar->addSeparator();
1055 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1056 toolbar->addAction(m_buttonFitZoom);
1057 m_buttonFitZoom->setCheckable(false);
1059 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1060 toolbar->addAction(m_zoomOut);
1061 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1063 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1064 m_zoomSlider->setMaximum(13);
1065 m_zoomSlider->setPageStep(1);
1066 m_zoomSlider->setInvertedAppearance(true);
1068 m_zoomSlider->setMaximumWidth(150);
1069 m_zoomSlider->setMinimumWidth(100);
1070 toolbar->addWidget(m_zoomSlider);
1072 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1073 toolbar->addAction(m_zoomIn);
1074 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1076 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1077 actionWidget->setMaximumWidth(max);
1078 actionWidget->setMaximumHeight(max - 4);
1079 actionWidget->setStyleSheet(styleBorderless);
1081 actionWidget = toolbar->widgetForAction(m_zoomIn);
1082 actionWidget->setMaximumWidth(max);
1083 actionWidget->setMaximumHeight(max - 4);
1084 actionWidget->setStyleSheet(styleBorderless);
1086 actionWidget = toolbar->widgetForAction(m_zoomOut);
1087 actionWidget->setMaximumWidth(max);
1088 actionWidget->setMaximumHeight(max - 4);
1089 actionWidget->setStyleSheet(styleBorderless);
1091 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1092 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1093 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1094 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1095 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1097 toolbar->addSeparator();
1099 //create automatic audio split button
1100 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1101 toolbar->addAction(m_buttonAutomaticSplitAudio);
1102 m_buttonAutomaticSplitAudio->setCheckable(true);
1103 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1104 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1106 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1107 toolbar->addAction(m_buttonVideoThumbs);
1108 m_buttonVideoThumbs->setCheckable(true);
1109 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1110 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1112 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1113 toolbar->addAction(m_buttonAudioThumbs);
1114 m_buttonAudioThumbs->setCheckable(true);
1115 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1116 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1118 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1119 toolbar->addAction(m_buttonShowMarkers);
1120 m_buttonShowMarkers->setCheckable(true);
1121 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1122 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1124 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1125 toolbar->addAction(m_buttonSnap);
1126 m_buttonSnap->setCheckable(true);
1127 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1128 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1130 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1131 actionWidget->setMaximumWidth(max);
1132 actionWidget->setMaximumHeight(max - 4);
1134 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1135 actionWidget->setMaximumWidth(max);
1136 actionWidget->setMaximumHeight(max - 4);
1138 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1139 actionWidget->setMaximumWidth(max);
1140 actionWidget->setMaximumHeight(max - 4);
1142 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1143 actionWidget->setMaximumWidth(max);
1144 actionWidget->setMaximumHeight(max - 4);
1146 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1147 actionWidget->setMaximumWidth(max);
1148 actionWidget->setMaximumHeight(max - 4);
1150 m_messageLabel = new StatusBarMessageLabel(this);
1151 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1153 statusBar()->addWidget(m_messageLabel, 10);
1154 statusBar()->addWidget(m_statusProgressBar, 0);
1155 statusBar()->addPermanentWidget(toolbar);
1156 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1157 statusBar()->addPermanentWidget(m_timecodeFormat);
1158 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1160 collection.addAction("normal_mode", m_normalEditTool);
1161 collection.addAction("overwrite_mode", m_overwriteEditTool);
1162 collection.addAction("insert_mode", m_insertEditTool);
1163 collection.addAction("select_tool", m_buttonSelectTool);
1164 collection.addAction("razor_tool", m_buttonRazorTool);
1165 collection.addAction("spacer_tool", m_buttonSpacerTool);
1167 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1168 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1169 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1170 collection.addAction("show_markers", m_buttonShowMarkers);
1171 collection.addAction("snap", m_buttonSnap);
1172 collection.addAction("zoom_fit", m_buttonFitZoom);
1173 collection.addAction("zoom_in", m_zoomIn);
1174 collection.addAction("zoom_out", m_zoomOut);
1176 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1177 collection.addAction("project_find", m_projectSearch);
1178 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1179 m_projectSearch->setShortcut(Qt::Key_Slash);
1181 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1182 collection.addAction("project_find_next", m_projectSearchNext);
1183 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1184 m_projectSearchNext->setShortcut(Qt::Key_F3);
1185 m_projectSearchNext->setEnabled(false);
1187 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1188 collection.addAction("manage_profiles", profilesAction);
1189 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1191 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1192 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1193 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1194 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1196 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1197 collection.addAction("run_wizard", wizAction);
1198 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1200 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1201 collection.addAction("project_settings", projectAction);
1202 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1204 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1205 collection.addAction("open_backup", backupAction);
1206 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1208 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1209 collection.addAction("project_render", projectRender);
1210 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1211 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1213 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1214 collection.addAction("project_clean", projectClean);
1215 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1217 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1218 collection.addAction("project_adjust_profile", projectAdjust);
1219 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1221 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1222 KShortcut playShortcut;
1223 playShortcut.setPrimary(Qt::Key_Space);
1224 playShortcut.setAlternate(Qt::Key_K);
1225 monitorPlay->setShortcut(playShortcut);
1226 collection.addAction("monitor_play", monitorPlay);
1227 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1229 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1230 collection.addAction("monitor_pause", monitorPause);
1231 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1233 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1234 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1235 collection.addAction("monitor_play_zone", m_playZone);
1236 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1238 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1239 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1240 collection.addAction("monitor_loop_zone", m_loopZone);
1241 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1243 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1244 m_loopClip->setEnabled(false);
1245 collection.addAction("monitor_loop_clip", m_loopClip);
1246 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1248 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1249 collection.addAction("dvd_wizard", dvdWizard);
1250 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1252 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1253 collection.addAction("transcode_clip", transcodeClip);
1254 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1256 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1257 collection.addAction("archive_project", archiveProject);
1258 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1261 KAction *markIn = collection.addAction("mark_in");
1262 markIn->setText(i18n("Set Zone In"));
1263 markIn->setShortcut(Qt::Key_I);
1264 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1266 KAction *markOut = collection.addAction("mark_out");
1267 markOut->setText(i18n("Set Zone Out"));
1268 markOut->setShortcut(Qt::Key_O);
1269 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1271 KAction *switchMon = collection.addAction("switch_monitor");
1272 switchMon->setText(i18n("Switch monitor"));
1273 switchMon->setShortcut(Qt::Key_T);
1274 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1276 KAction *fullMon = collection.addAction("monitor_fullscreen");
1277 fullMon->setText(i18n("Switch monitor fullscreen"));
1278 fullMon->setIcon(KIcon("view-fullscreen"));
1279 connect(fullMon, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotSwitchFullscreen()));
1281 KAction *insertTree = collection.addAction("insert_project_tree");
1282 insertTree->setText(i18n("Insert zone in project tree"));
1283 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1284 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1286 KAction *insertTimeline = collection.addAction("insert_timeline");
1287 insertTimeline->setText(i18n("Insert zone in timeline"));
1288 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1289 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1291 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1292 collection.addAction("resize_timeline_clip_start", resizeStart);
1293 resizeStart->setShortcut(Qt::Key_1);
1294 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1296 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1297 collection.addAction("resize_timeline_clip_end", resizeEnd);
1298 resizeEnd->setShortcut(Qt::Key_2);
1299 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1301 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1302 monitorSeekBackward->setShortcut(Qt::Key_J);
1303 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1304 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1306 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1307 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1308 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1309 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1311 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1312 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1313 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1314 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1316 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1317 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1318 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1319 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1321 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1322 monitorSeekForward->setShortcut(Qt::Key_L);
1323 collection.addAction("monitor_seek_forward", monitorSeekForward);
1324 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1326 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1327 clipStart->setShortcut(Qt::Key_Home);
1328 collection.addAction("seek_clip_start", clipStart);
1329 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1331 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1332 clipEnd->setShortcut(Qt::Key_End);
1333 collection.addAction("seek_clip_end", clipEnd);
1334 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1336 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1337 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1338 collection.addAction("seek_zone_start", zoneStart);
1339 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1341 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1342 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1343 collection.addAction("seek_zone_end", zoneEnd);
1344 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1346 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1347 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1348 collection.addAction("seek_start", projectStart);
1349 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1351 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1352 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1353 collection.addAction("seek_end", projectEnd);
1354 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1356 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1357 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1358 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1359 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1361 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1362 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1363 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1364 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1366 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1367 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1368 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1369 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1371 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1372 deleteItem->setShortcut(Qt::Key_Delete);
1373 collection.addAction("delete_timeline_clip", deleteItem);
1374 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1376 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1377 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1378 editTimelineClipSpeed->setData("change_speed");
1379 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1381 KAction *stickTransition = collection.addAction("auto_transition");
1382 stickTransition->setData(QString("auto"));
1383 stickTransition->setCheckable(true);
1384 stickTransition->setEnabled(false);
1385 stickTransition->setText(i18n("Automatic Transition"));
1386 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1388 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1389 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1390 collection.addAction("group_clip", groupClip);
1391 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1393 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1394 collection.addAction("ungroup_clip", ungroupClip);
1395 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1396 ungroupClip->setData("ungroup_clip");
1397 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1399 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1400 collection.addAction("edit_item_duration", editItemDuration);
1401 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1403 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1404 collection.addAction("clip_in_project_tree", clipInProjectTree);
1405 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1407 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1408 collection.addAction("clip_to_project_tree", clipToProjectTree);
1409 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1411 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1412 insertOvertwrite->setShortcut(Qt::Key_V);
1413 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1414 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1416 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1417 selectTimelineClip->setShortcut(Qt::Key_Plus);
1418 collection.addAction("select_timeline_clip", selectTimelineClip);
1419 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1421 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1422 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1423 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1424 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1426 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1427 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1428 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1429 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1431 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1432 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1433 collection.addAction("select_timeline_transition", selectTimelineTransition);
1434 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1436 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1437 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1438 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1439 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1441 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1442 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1443 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1444 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1446 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1447 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1448 collection.addAction("cut_timeline_clip", cutTimelineClip);
1449 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1451 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1452 collection.addAction("add_clip_marker", addClipMarker);
1453 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1455 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1456 collection.addAction("delete_clip_marker", deleteClipMarker);
1457 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1459 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1460 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1461 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1463 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1464 editClipMarker->setData(QString("edit_marker"));
1465 collection.addAction("edit_clip_marker", editClipMarker);
1466 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1468 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1469 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1470 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1471 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1473 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1474 collection.addAction("split_audio", splitAudio);
1475 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1477 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1478 collection.addAction("clip_audio_only", audioOnly);
1479 audioOnly->setData("clip_audio_only");
1480 audioOnly->setCheckable(true);
1482 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1483 collection.addAction("clip_video_only", videoOnly);
1484 videoOnly->setData("clip_video_only");
1485 videoOnly->setCheckable(true);
1487 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1488 collection.addAction("clip_audio_and_video", audioAndVideo);
1489 audioAndVideo->setData("clip_audio_and_video");
1490 audioAndVideo->setCheckable(true);
1492 m_clipTypeGroup = new QActionGroup(this);
1493 m_clipTypeGroup->addAction(audioOnly);
1494 m_clipTypeGroup->addAction(videoOnly);
1495 m_clipTypeGroup->addAction(audioAndVideo);
1496 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1497 m_clipTypeGroup->setEnabled(false);
1499 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1500 collection.addAction("insert_space", insertSpace);
1501 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1503 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1504 collection.addAction("delete_space", removeSpace);
1505 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1507 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1508 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1510 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1511 m_tracksActionCollection->addAction("insert_track", insertTrack);
1512 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1514 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1515 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1516 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1518 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1519 m_tracksActionCollection->addAction("config_tracks", configTracks);
1520 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1522 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1523 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1524 m_tracksActionCollection->addAction("select_track", selectTrack);
1526 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1527 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1528 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1530 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1531 collection.addAction("add_guide", addGuide);
1532 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1534 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1535 collection.addAction("delete_guide", delGuide);
1536 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1538 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1539 collection.addAction("edit_guide", editGuide);
1540 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1542 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1543 collection.addAction("delete_all_guides", delAllGuides);
1544 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1546 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1547 collection.addAction("paste_effects", pasteEffects);
1548 pasteEffects->setData("paste_effects");
1549 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1551 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1552 collection.addAction("show_timeline", showTimeline);
1553 showTimeline->setCheckable(true);
1554 showTimeline->setChecked(true);
1555 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1557 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1558 collection.addAction("show_titlebars", showTitleBar);
1559 showTitleBar->setCheckable(true);
1560 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1561 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1562 slotShowTitleBars(KdenliveSettings::showtitlebars());
1564 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1565 KStandardAction::quit(this, SLOT(close()), collection);
1566 KStandardAction::open(this, SLOT(openFile()), collection);
1567 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1568 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1569 KStandardAction::openNew(this, SLOT(newFile()), collection);
1570 // TODO: make the following connection to slotEditKeys work
1571 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1572 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1573 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1574 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1575 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1576 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1578 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1579 undo->setEnabled(false);
1580 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1582 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1583 redo->setEnabled(false);
1584 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1587 //TODO: Add status tooltip to actions ?
1588 connect(collection, SIGNAL(actionHovered(QAction*)),
1589 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1592 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1593 collection.addAction("add_clip", addClip);
1594 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1596 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1597 collection.addAction("add_color_clip", addColorClip);
1598 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1600 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1601 collection.addAction("add_slide_clip", addSlideClip);
1602 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1604 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1605 collection.addAction("add_text_clip", addTitleClip);
1606 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1608 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1609 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1610 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1612 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1613 collection.addAction("add_folder", addFolderButton);
1614 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1616 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1617 collection.addAction("download_resource", downloadResources);
1618 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1620 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1621 collection.addAction("clip_properties", clipProperties);
1622 clipProperties->setData("clip_properties");
1623 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1624 clipProperties->setEnabled(false);
1626 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1627 collection.addAction("edit_clip", openClip);
1628 openClip->setData("edit_clip");
1629 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1630 openClip->setEnabled(false);
1632 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1633 collection.addAction("delete_clip", deleteClip);
1634 deleteClip->setData("delete_clip");
1635 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1636 deleteClip->setEnabled(false);
1638 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1639 collection.addAction("reload_clip", reloadClip);
1640 reloadClip->setData("reload_clip");
1641 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1642 reloadClip->setEnabled(false);
1644 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1645 collection.addAction("proxy_clip", proxyClip);
1646 proxyClip->setData("proxy_clip");
1647 proxyClip->setCheckable(true);
1648 proxyClip->setChecked(false);
1649 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1651 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1652 collection.addAction("stopmotion", stopMotion);
1653 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1655 QMenu *addClips = new QMenu();
1656 addClips->addAction(addClip);
1657 addClips->addAction(addColorClip);
1658 addClips->addAction(addSlideClip);
1659 addClips->addAction(addTitleClip);
1660 addClips->addAction(addTitleTemplateClip);
1661 addClips->addAction(addFolderButton);
1662 addClips->addAction(downloadResources);
1664 addClips->addAction(reloadClip);
1665 addClips->addAction(proxyClip);
1666 addClips->addAction(clipProperties);
1667 addClips->addAction(openClip);
1668 addClips->addAction(deleteClip);
1669 m_projectList->setupMenu(addClips, addClip);
1671 // Setup effects and transitions actions.
1672 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1673 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1674 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1675 m_transitions = new KAction*[transitions.count()];
1676 for (int i = 0; i < transitions.count(); i++) {
1677 QStringList effectInfo = transitions.effectIdInfo(i);
1678 m_transitions[i] = new KAction(effectInfo.at(0), this);
1679 m_transitions[i]->setData(effectInfo);
1680 m_transitions[i]->setIconVisibleInMenu(false);
1681 QString id = effectInfo.at(2);
1682 if (id.isEmpty()) id = effectInfo.at(1);
1683 transitionActions->addAction("transition_" + id, m_transitions[i]);
1685 //m_effectsActionCollection->readSettings();
1689 void MainWindow::slotDisplayActionMessage(QAction *a)
1691 statusBar()->showMessage(a->data().toString(), 3000);
1694 void MainWindow::loadLayouts()
1696 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1697 if (m_loadLayout == NULL || saveLayout == NULL) return;
1698 KSharedConfigPtr config = KGlobal::config();
1699 KConfigGroup layoutGroup(config, "Layouts");
1700 QStringList entries = layoutGroup.keyList();
1701 QList<QAction *> loadActions = m_loadLayout->actions();
1702 QList<QAction *> saveActions = saveLayout->actions();
1703 for (int i = 1; i < 5; i++) {
1704 // Rename the layouts actions
1705 foreach(const QString & key, entries) {
1706 if (key.endsWith(QString("_%1").arg(i))) {
1707 // Found previously saved layout
1708 QString layoutName = key.section("_", 0, -2);
1709 for (int j = 0; j < loadActions.count(); j++) {
1710 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1711 loadActions[j]->setText(layoutName);
1712 loadActions[j]->setData(key);
1716 for (int j = 0; j < saveActions.count(); j++) {
1717 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1718 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1719 saveActions[j]->setData(key);
1728 void MainWindow::slotLoadLayout(QAction *action)
1730 if (!action) return;
1731 QString layoutId = action->data().toString();
1732 if (layoutId.isEmpty()) return;
1733 KSharedConfigPtr config = KGlobal::config();
1734 KConfigGroup layouts(config, "Layouts");
1735 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1736 restoreState(state);
1739 void MainWindow::slotSaveLayout(QAction *action)
1741 QString originallayoutName = action->data().toString();
1742 int layoutId = originallayoutName.section('_', -1).toInt();
1744 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1745 if (layoutName.isEmpty()) return;
1746 KSharedConfigPtr config = KGlobal::config();
1747 KConfigGroup layouts(config, "Layouts");
1748 layouts.deleteEntry(originallayoutName);
1750 QByteArray st = saveState();
1751 layoutName.append("_" + QString::number(layoutId));
1752 layouts.writeEntry(layoutName, st.toBase64());
1756 void MainWindow::saveOptions()
1758 KdenliveSettings::self()->writeConfig();
1759 KSharedConfigPtr config = KGlobal::config();
1760 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1761 KConfigGroup treecolumns(config, "Project Tree");
1762 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1766 void MainWindow::readOptions()
1768 KSharedConfigPtr config = KGlobal::config();
1769 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1770 KConfigGroup initialGroup(config, "version");
1771 bool upgrade = false;
1772 if (initialGroup.exists()) {
1773 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1777 if (initialGroup.readEntry("version") == "0.7") {
1778 //Add new settings from 0.7.1
1779 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1780 QString path = QDir::homePath() + "/kdenlive";
1781 if (KStandardDirs::makeDir(path) == false) {
1782 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1783 } else KdenliveSettings::setDefaultprojectfolder(path);
1789 if (!initialGroup.exists() || upgrade) {
1790 // this is our first run, show Wizard
1791 Wizard *w = new Wizard(upgrade, this);
1792 if (w->exec() == QDialog::Accepted && w->isOk()) {
1793 w->adjustSettings();
1794 initialGroup.writeEntry("version", version);
1800 KConfigGroup treecolumns(config, "Project Tree");
1801 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1802 if (!state.isEmpty())
1803 m_projectList->setHeaderInfo(state);
1806 void MainWindow::slotRunWizard()
1808 Wizard *w = new Wizard(false, this);
1809 if (w->exec() == QDialog::Accepted && w->isOk()) {
1810 w->adjustSettings();
1815 void MainWindow::newFile(bool showProjectSettings, bool force)
1817 if (!m_timelineArea->isEnabled() && !force)
1819 m_fileRevert->setEnabled(false);
1820 QString profileName = KdenliveSettings::default_profile();
1821 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1822 QMap <QString, QString> documentProperties;
1823 QMap <QString, QString> documentMetadata;
1824 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1825 if (!showProjectSettings) {
1826 if (!KdenliveSettings::activatetabs())
1827 if (!closeCurrentDocument())
1830 ProjectSettings *w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1831 if (w->exec() != QDialog::Accepted)
1833 if (!KdenliveSettings::activatetabs())
1834 if (!closeCurrentDocument())
1836 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1837 slotSwitchVideoThumbs();
1838 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1839 slotSwitchAudioThumbs();
1840 profileName = w->selectedProfile();
1841 projectFolder = w->selectedFolder();
1842 projectTracks = w->tracks();
1843 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1844 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1845 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1846 documentProperties.insert("proxyparams", w->proxyParams());
1847 documentProperties.insert("proxyextension", w->proxyExtension());
1848 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1849 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1850 documentMetadata = w->metadata();
1853 m_timelineArea->setEnabled(true);
1854 m_projectList->setEnabled(true);
1856 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1857 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1859 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
1860 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1863 //m_timelineArea->setEnabled(false);
1864 //m_projectList->setEnabled(false);
1868 if (m_timelineArea->count() == 1) {
1869 connectDocumentInfo(doc);
1870 connectDocument(trackView, doc);
1872 m_timelineArea->setTabBarHidden(false);
1873 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
1874 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1877 void MainWindow::activateDocument()
1879 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1880 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1881 KdenliveDoc *currentDoc = currentTab->document();
1882 connectDocumentInfo(currentDoc);
1883 connectDocument(currentTab, currentDoc);
1886 bool MainWindow::closeCurrentDocument(bool saveChanges)
1888 QWidget *w = m_timelineArea->currentWidget();
1889 if (!w) return true;
1890 // closing current document
1891 int ix = m_timelineArea->currentIndex() + 1;
1892 if (ix == m_timelineArea->count()) ix = 0;
1893 m_timelineArea->setCurrentIndex(ix);
1894 TrackView *tabToClose = (TrackView *) w;
1895 KdenliveDoc *docToClose = tabToClose->document();
1896 if (docToClose && docToClose->isModified() && saveChanges) {
1898 if (m_activeDocument->url().fileName().isEmpty())
1899 message = i18n("Save changes to document?");
1901 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1902 switch (KMessageBox::warningYesNoCancel(this, message)) {
1903 case KMessageBox::Yes :
1904 // save document here. If saving fails, return false;
1905 if (saveFile() == false) return false;
1907 case KMessageBox::Cancel :
1914 m_clipMonitor->slotSetClipProducer(NULL);
1915 m_projectList->slotResetProjectList();
1916 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1917 if (m_timelineArea->count() == 1) {
1918 m_timelineArea->setTabBarHidden(true);
1919 m_closeAction->setEnabled(false);
1921 if (docToClose == m_activeDocument) {
1922 delete m_activeDocument;
1923 m_activeDocument = NULL;
1924 m_effectStack->clear();
1925 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1929 if (w == m_activeTimeline) {
1930 delete m_activeTimeline;
1931 m_activeTimeline = NULL;
1938 bool MainWindow::saveFileAs(const QString &outputFileName)
1940 QString currentSceneList;
1941 m_monitorManager->stopActiveMonitor();
1943 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1946 // Save timeline thumbnails
1947 m_activeTimeline->projectView()->saveThumbnails();
1948 m_activeDocument->setUrl(KUrl(outputFileName));
1949 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
1950 if (m_activeDocument->m_autosave == NULL) {
1951 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
1952 } else m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
1953 setCaption(m_activeDocument->description());
1954 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1955 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1956 m_activeDocument->setModified(false);
1957 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1958 m_fileRevert->setEnabled(true);
1959 m_undoView->stack()->setClean();
1963 bool MainWindow::saveFileAs()
1965 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1966 if (outputFile.isEmpty()) {
1969 if (QFile::exists(outputFile)) {
1970 // Show the file dialog again if the user does not want to overwrite the file
1971 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1972 return saveFileAs();
1974 return saveFileAs(outputFile);
1977 bool MainWindow::saveFile()
1979 if (!m_activeDocument) return true;
1980 if (m_activeDocument->url().isEmpty()) {
1981 return saveFileAs();
1983 bool result = saveFileAs(m_activeDocument->url().path());
1984 m_activeDocument->m_autosave->resize(0);
1989 void MainWindow::openFile()
1991 if (!m_startUrl.isEmpty()) {
1992 openFile(m_startUrl);
1993 m_startUrl = KUrl();
1996 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1997 if (url.isEmpty()) return;
1998 m_fileOpenRecent->addUrl(url);
2002 void MainWindow::openLastFile()
2004 KSharedConfigPtr config = KGlobal::config();
2005 KUrl::List urls = m_fileOpenRecent->urls();
2006 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2007 if (urls.isEmpty()) newFile(false);
2008 else openFile(urls.last());
2011 void MainWindow::openFile(const KUrl &url)
2013 // Make sure the url is a Kdenlive project file
2014 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2015 if (mime.data()->is("application/x-compressed-tar")) {
2016 // Opening a compressed project file, we need to process it
2017 kDebug()<<"Opening archive, processing";
2018 ArchiveWidget *ar = new ArchiveWidget(url);
2019 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2023 if (!url.fileName().endsWith(".kdenlive")) {
2024 // This is not a Kdenlive project file, abort loading
2025 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2029 // Check if the document is already opened
2030 const int ct = m_timelineArea->count();
2031 bool isOpened = false;
2033 for (i = 0; i < ct; i++) {
2034 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2035 KdenliveDoc *doc = tab->document();
2036 if (doc->url() == url) {
2042 m_timelineArea->setCurrentIndex(i);
2046 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2048 // Check for backup file
2049 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2050 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2051 if (!staleFiles.isEmpty()) {
2052 if (KMessageBox::questionYesNo(this,
2053 i18n("Auto-saved files exist. Do you want to recover them now?"),
2054 i18n("File Recovery"),
2055 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2056 recoverFiles(staleFiles, url);
2059 // remove the stale files
2060 foreach(KAutoSaveFile * stale, staleFiles) {
2061 stale->open(QIODevice::ReadWrite);
2066 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2067 m_messageLabel->repaint();
2068 doOpenFile(url, NULL);
2071 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2073 if (!m_timelineArea->isEnabled()) return;
2074 m_fileRevert->setEnabled(true);
2076 // Recreate stopmotion widget on document change
2078 delete m_stopmotion;
2079 m_stopmotion = NULL;
2083 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2084 progressDialog.setAllowCancel(false);
2085 progressDialog.progressBar()->setMaximum(4);
2086 progressDialog.show();
2087 progressDialog.progressBar()->setValue(0);
2088 qApp->processEvents();
2091 KdenliveDoc *doc = new KdenliveDoc(stale ? KUrl(stale->fileName()) : url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
2093 progressDialog.progressBar()->setValue(1);
2094 progressDialog.progressBar()->setMaximum(4);
2095 progressDialog.setLabelText(i18n("Loading project"));
2096 qApp->processEvents();
2098 if (stale == NULL) {
2099 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2100 stale = new KAutoSaveFile(KUrl(hash), doc);
2101 doc->m_autosave = stale;
2103 doc->m_autosave = stale;
2104 doc->setUrl(url);//stale->managedFile());
2105 doc->setModified(true);
2106 stale->setParent(doc);
2108 connectDocumentInfo(doc);
2110 progressDialog.progressBar()->setValue(2);
2111 qApp->processEvents();
2114 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2115 connectDocument(trackView, doc);
2116 progressDialog.progressBar()->setValue(3);
2117 qApp->processEvents();
2119 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2121 m_timelineArea->setEnabled(false);
2122 m_projectList->setEnabled(false);
2123 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2124 slotGotProgressInfo(QString(), -1);
2125 newFile(false, true);
2128 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2129 trackView->setDuration(trackView->duration());
2130 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2132 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2133 slotGotProgressInfo(QString(), -1);
2134 m_projectMonitor->adjustRulerSize(trackView->duration());
2135 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2136 progressDialog.progressBar()->setValue(4);
2137 if (openBackup) slotOpenBackupDialog(url);
2140 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl)
2142 foreach(KAutoSaveFile * stale, staleFiles) {
2143 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2144 // show an error message; we could not steal the lockfile
2145 // maybe another application got to the file before us?
2149 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2150 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2151 if (!stale->fileName().endsWith(".lock")) doOpenFile(originUrl, stale);
2152 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2156 void MainWindow::parseProfiles(const QString &mltPath)
2158 //KdenliveSettings::setDefaulttmpfolder();
2159 if (!mltPath.isEmpty()) {
2160 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2161 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2164 if (KdenliveSettings::mltpath().isEmpty())
2165 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2167 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2168 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2169 if (!QFile::exists(meltPath))
2170 meltPath = KStandardDirs::findExe("melt");
2171 KdenliveSettings::setRendererpath(meltPath);
2174 if (KdenliveSettings::rendererpath().isEmpty()) {
2175 // Cannot find the MLT melt renderer, ask for location
2176 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2177 if (getUrl->exec() == QDialog::Rejected) {
2180 KUrl rendererPath = getUrl->selectedUrl();
2182 if (rendererPath.isEmpty()) ::exit(0);
2183 KdenliveSettings::setRendererpath(rendererPath.path());
2186 QStringList profilesFilter;
2187 profilesFilter << "*";
2188 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2189 if (profilesList.isEmpty()) {
2190 // Cannot find MLT path, try finding melt
2191 QString profilePath = KdenliveSettings::rendererpath();
2192 if (!profilePath.isEmpty()) {
2193 profilePath = profilePath.section('/', 0, -3);
2194 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2195 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2197 if (profilesList.isEmpty()) {
2198 // Cannot find the MLT profiles, ask for location
2199 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2200 getUrl->fileDialog()->setMode(KFile::Directory);
2201 if (getUrl->exec() == QDialog::Rejected) {
2204 KUrl mltPath = getUrl->selectedUrl();
2206 if (mltPath.isEmpty()) ::exit(0);
2207 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2208 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2212 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2214 // Parse again MLT profiles to build a list of available video formats
2215 if (profilesList.isEmpty()) parseProfiles();
2219 void MainWindow::slotEditProfiles()
2221 ProfilesDialog *w = new ProfilesDialog;
2222 if (w->exec() == QDialog::Accepted) {
2223 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2224 if (d) d->checkProfile();
2229 void MainWindow::slotDetectAudioDriver()
2231 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2232 leading to no audio output, see bug #934 */
2234 //decide which audio driver is really best, in some cases SDL is wrong
2235 if (KdenliveSettings::audiodrivername().isEmpty()) {
2237 KProcess readProcess;
2238 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2239 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2240 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2241 readProcess.setProgram("pactl", QStringList() << "stat");
2242 readProcess.execute(2000); // Kill it after 2 seconds
2244 QString result = QString(readProcess.readAllStandardOutput());
2245 kDebug() << "// / / / / / READING PACTL: ";
2247 if (!result.isEmpty()) {
2249 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2253 KdenliveSettings::setAutoaudiodrivername(driver);
2257 void MainWindow::slotEditProjectSettings()
2259 QPoint p = m_activeDocument->getTracksCount();
2260 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeDocument->metadata(), m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2261 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2263 if (w->exec() == QDialog::Accepted) {
2264 QString profile = w->selectedProfile();
2265 m_activeDocument->setProjectFolder(w->selectedFolder());
2267 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2269 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2270 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2271 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2272 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2273 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2274 m_activeDocument->setModified();
2275 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2276 if (m_activeDocument->clipManager()->clipsCount() > 0 && KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) == KMessageBox::Yes) {
2277 //TODO: rebuild all proxies
2278 //m_projectList->rebuildProxies();
2281 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2282 m_activeDocument->setModified();
2283 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2285 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2286 m_activeDocument->setModified();
2287 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2289 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2290 m_activeDocument->setModified();
2291 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2293 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2294 m_activeDocument->setModified();
2295 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2297 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2298 m_activeDocument->setModified();
2299 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2301 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2302 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2303 m_activeDocument->setModified();
2304 slotUpdateProxySettings();
2306 m_activeDocument->setMetadata(w->metadata());
2311 void MainWindow::slotDisableProxies()
2313 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2314 m_activeDocument->setModified();
2315 slotUpdateProxySettings();
2318 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2320 // Recreate the stopmotion widget if profile changes
2322 delete m_stopmotion;
2323 m_stopmotion = NULL;
2326 // Deselect current effect / transition
2327 m_effectStack->slotClipItemSelected(NULL, 0);
2328 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2329 m_clipMonitor->slotSetClipProducer(NULL);
2330 bool updateFps = m_activeDocument->setProfilePath(profile);
2331 KdenliveSettings::setCurrent_profile(profile);
2332 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2333 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2335 m_activeDocument->clipManager()->clearUnusedProducers();
2336 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2337 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2338 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2339 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2340 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2341 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2342 if (updateFps) m_activeTimeline->updateProjectFps();
2343 m_activeDocument->clipManager()->clearCache();
2344 m_activeTimeline->updateProfile();
2345 m_activeDocument->setModified(true);
2346 m_commandStack->activeStack()->clear();
2347 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2348 slotUpdateMousePosition(0);
2349 // We need to desactivate & reactivate monitors to get a refresh
2350 //m_monitorManager->switchMonitors();
2354 void MainWindow::slotRenderProject()
2356 if (!m_renderWidget) {
2357 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2358 MltVideoProfile profile;
2359 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2360 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2361 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2362 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2363 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2364 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2365 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2366 if (m_activeDocument) {
2367 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2368 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2369 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2370 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2373 slotCheckRenderStatus();
2374 m_renderWidget->show();
2375 m_renderWidget->showNormal();
2377 // What are the following lines supposed to do?
2378 //m_activeTimeline->tracksNumber();
2379 //m_renderWidget->enableAudio(false);
2380 //m_renderWidget->export_audio;
2383 void MainWindow::slotCheckRenderStatus()
2385 // Make sure there are no missing clips
2387 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2390 void MainWindow::setRenderingProgress(const QString &url, int progress)
2393 m_renderWidget->setRenderJob(url, progress);
2396 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2399 m_renderWidget->setRenderStatus(url, status, error);
2402 void MainWindow::slotCleanProject()
2404 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2405 m_projectList->cleanup();
2408 void MainWindow::slotUpdateMousePosition(int pos)
2410 if (m_activeDocument)
2411 switch (m_timecodeFormat->currentIndex()) {
2413 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2416 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2420 void MainWindow::slotUpdateDocumentState(bool modified)
2422 if (!m_activeDocument) return;
2423 setCaption(m_activeDocument->description(), modified);
2424 m_saveAction->setEnabled(modified);
2426 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2427 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2429 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2430 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2434 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2436 if (m_activeDocument) {
2437 if (m_activeDocument == doc) return;
2438 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2440 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2443 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2445 //m_projectMonitor->stop();
2446 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2447 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2448 if (m_activeDocument) {
2449 if (m_activeDocument == doc) return;
2450 if (m_activeTimeline) {
2451 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2452 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2453 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2454 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2455 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2456 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2457 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2459 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2461 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2462 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2463 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2464 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2465 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2466 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2467 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2468 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2469 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2470 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2471 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2472 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2473 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2474 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2475 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2476 disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2478 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
2479 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2480 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2481 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2482 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2483 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2484 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2485 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2486 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2487 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2488 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2489 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2490 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2491 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2492 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2493 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2494 m_effectStack->clear();
2496 //m_activeDocument->setRenderer(NULL);
2497 m_clipMonitor->stop();
2499 KdenliveSettings::setCurrent_profile(doc->profilePath());
2500 KdenliveSettings::setProject_fps(doc->fps());
2501 m_monitorManager->resetProfiles(doc->timecode());
2502 m_clipMonitorDock->raise();
2503 m_projectList->setDocument(doc);
2504 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2505 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2506 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2508 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2509 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2511 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2512 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2513 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2514 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2515 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2516 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2517 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2518 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2519 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2520 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2521 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2523 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2524 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2525 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2526 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2527 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2529 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2530 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2531 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2533 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2535 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2536 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2537 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2538 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2540 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2541 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2542 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2543 m_zoomSlider->setValue(doc->zoom().x());
2544 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2545 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2546 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2547 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2549 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2550 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2552 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2553 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2555 connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2557 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2558 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2559 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2560 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2561 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2562 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2563 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2564 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2565 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2566 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2567 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2569 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2570 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2571 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2572 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2573 m_activeTimeline = trackView;
2574 if (m_renderWidget) {
2575 slotCheckRenderStatus();
2576 m_renderWidget->setProfile(doc->mltProfile());
2577 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2578 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2579 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2581 //doc->setRenderer(m_projectMonitor->render);
2582 m_commandStack->setActiveStack(doc->commandStack());
2583 KdenliveSettings::setProject_display_ratio(doc->dar());
2584 //doc->clipManager()->checkAudioThumbs();
2586 //m_overView->setScene(trackView->projectScene());
2587 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2588 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2590 setCaption(doc->description(), doc->isModified());
2591 m_saveAction->setEnabled(doc->isModified());
2592 m_normalEditTool->setChecked(true);
2593 m_activeDocument = doc;
2594 m_activeTimeline->updateProjectFps();
2595 m_activeDocument->checkProjectClips();
2597 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2599 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2600 slotUpdateMousePosition(0);
2601 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
2602 // set tool to select tool
2603 m_buttonSelectTool->setChecked(true);
2606 void MainWindow::slotZoneMoved(int start, int end)
2608 m_activeDocument->setZone(start, end);
2609 m_projectMonitor->slotZoneMoved(start, end);
2612 void MainWindow::slotGuidesUpdated()
2615 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2618 void MainWindow::slotEditKeys()
2620 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2621 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2622 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2623 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2627 void MainWindow::slotPreferences(int page, int option)
2630 * An instance of your dialog could be already created and could be
2631 * cached, in which case you want to display the cached dialog
2632 * instead of creating another one
2634 if (m_stopmotion) m_stopmotion->slotLive(false);
2635 if (KConfigDialog::showDialog("settings")) {
2636 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2637 if (page != -1) d->showPage(page, option);
2641 // KConfigDialog didn't find an instance of this dialog, so lets
2644 // Get the mappable actions in localized form
2645 QMap<QString, QString> actions;
2646 KActionCollection* collection = actionCollection();
2647 foreach (const QString& action_name, m_action_names) {
2648 actions[collection->action(action_name)->text()] = action_name;
2651 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2652 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2653 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2655 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2658 if (page != -1) dialog->showPage(page, option);
2661 void MainWindow::slotUpdateCaptureFolder()
2665 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2666 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2670 void MainWindow::updateConfiguration()
2672 //TODO: we should apply settings to all projects, not only the current one
2673 if (m_activeTimeline) {
2674 m_activeTimeline->refresh();
2675 m_activeTimeline->projectView()->checkAutoScroll();
2676 m_activeTimeline->checkTrackHeight();
2677 if (m_activeDocument)
2678 m_activeDocument->clipManager()->checkAudioThumbs();
2680 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2681 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2682 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2683 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2685 // Update list of transcoding profiles
2688 #ifdef USE_JOGSHUTTLE
2689 activateShuttleDevice();
2694 void MainWindow::slotSwitchSplitAudio()
2696 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2697 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2700 void MainWindow::slotSwitchVideoThumbs()
2702 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2703 if (m_activeTimeline)
2704 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2705 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2708 void MainWindow::slotSwitchAudioThumbs()
2710 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2711 if (m_activeTimeline) {
2712 m_activeTimeline->refresh();
2713 m_activeTimeline->projectView()->checkAutoScroll();
2714 if (m_activeDocument)
2715 m_activeDocument->clipManager()->checkAudioThumbs();
2717 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2720 void MainWindow::slotSwitchMarkersComments()
2722 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2723 if (m_activeTimeline)
2724 m_activeTimeline->refresh();
2725 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2728 void MainWindow::slotSwitchSnap()
2730 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2731 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2735 void MainWindow::slotDeleteItem()
2737 if (QApplication::focusWidget() &&
2738 QApplication::focusWidget()->parentWidget() &&
2739 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2740 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2741 m_projectList->slotRemoveClip();
2744 QWidget *widget = QApplication::focusWidget();
2746 if (widget == m_effectStackDock) {
2747 m_effectStack->slotItemDel();
2750 widget = widget->parentWidget();
2753 // effect stack has no focus
2754 if (m_activeTimeline)
2755 m_activeTimeline->projectView()->deleteSelectedClips();
2759 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2761 if (m_clipMonitor->isActive())
2762 m_clipMonitor->checkOverlay();
2763 m_clipMonitor->updateMarkers(clip);
2766 void MainWindow::slotAddClipMarker()
2768 DocClipBase *clip = NULL;
2770 if (m_projectMonitor->isActive()) {
2771 if (m_activeTimeline) {
2772 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2774 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2775 clip = item->baseClip();
2779 clip = m_clipMonitor->activeClip();
2780 pos = m_clipMonitor->position();
2783 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2786 QString id = clip->getId();
2787 CommentedTime marker(pos, i18n("Marker"));
2788 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2789 if (d.exec() == QDialog::Accepted)
2790 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2793 void MainWindow::slotDeleteClipMarker()
2795 DocClipBase *clip = NULL;
2797 if (m_projectMonitor->isActive()) {
2798 if (m_activeTimeline) {
2799 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2801 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2802 clip = item->baseClip();
2806 clip = m_clipMonitor->activeClip();
2807 pos = m_clipMonitor->position();
2810 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2814 QString id = clip->getId();
2815 QString comment = clip->markerComment(pos);
2816 if (comment.isEmpty()) {
2817 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2820 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2823 void MainWindow::slotDeleteAllClipMarkers()
2825 DocClipBase *clip = NULL;
2826 if (m_projectMonitor->isActive()) {
2827 if (m_activeTimeline) {
2828 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2830 clip = item->baseClip();
2834 clip = m_clipMonitor->activeClip();
2837 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2840 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2843 void MainWindow::slotEditClipMarker()
2845 DocClipBase *clip = NULL;
2847 if (m_projectMonitor->isActive()) {
2848 if (m_activeTimeline) {
2849 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2851 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2852 clip = item->baseClip();
2856 clip = m_clipMonitor->activeClip();
2857 pos = m_clipMonitor->position();
2860 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2864 QString id = clip->getId();
2865 QString oldcomment = clip->markerComment(pos);
2866 if (oldcomment.isEmpty()) {
2867 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2871 CommentedTime marker(pos, oldcomment);
2872 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2873 if (d.exec() == QDialog::Accepted) {
2874 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2875 if (d.newMarker().time() != pos) {
2876 // remove old marker
2877 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2882 void MainWindow::slotAddMarkerGuideQuickly()
2884 if (!m_activeTimeline || !m_activeDocument)
2887 if (m_clipMonitor->isActive()) {
2888 DocClipBase *clip = m_clipMonitor->activeClip();
2889 GenTime pos = m_clipMonitor->position();
2892 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2896 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2898 m_activeTimeline->projectView()->slotAddGuide(false);
2902 void MainWindow::slotAddGuide()
2904 if (m_activeTimeline)
2905 m_activeTimeline->projectView()->slotAddGuide();
2908 void MainWindow::slotInsertSpace()
2910 if (m_activeTimeline)
2911 m_activeTimeline->projectView()->slotInsertSpace();
2914 void MainWindow::slotRemoveSpace()
2916 if (m_activeTimeline)
2917 m_activeTimeline->projectView()->slotRemoveSpace();
2920 void MainWindow::slotInsertTrack(int ix)
2922 m_projectMonitor->slotActivateMonitor();
2923 if (m_activeTimeline) {
2924 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2925 m_activeTimeline->projectView()->slotInsertTrack(ix);
2927 if (m_activeDocument)
2928 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2931 void MainWindow::slotDeleteTrack(int ix)
2933 m_projectMonitor->slotActivateMonitor();
2934 if (m_activeTimeline) {
2935 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2936 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2938 if (m_activeDocument)
2939 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2942 void MainWindow::slotConfigTrack(int ix)
2944 m_projectMonitor->slotActivateMonitor();
2945 if (m_activeTimeline)
2946 m_activeTimeline->projectView()->slotConfigTracks(ix);
2947 if (m_activeDocument)
2948 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2951 void MainWindow::slotSelectTrack()
2953 m_projectMonitor->slotActivateMonitor();
2954 if (m_activeTimeline) {
2955 m_activeTimeline->projectView()->slotSelectClipsInTrack();
2959 void MainWindow::slotSelectAllTracks()
2961 m_projectMonitor->slotActivateMonitor();
2962 if (m_activeTimeline)
2963 m_activeTimeline->projectView()->slotSelectAllClips();
2966 void MainWindow::slotEditGuide()
2968 if (m_activeTimeline)
2969 m_activeTimeline->projectView()->slotEditGuide();
2972 void MainWindow::slotDeleteGuide()
2974 if (m_activeTimeline)
2975 m_activeTimeline->projectView()->slotDeleteGuide();
2978 void MainWindow::slotDeleteAllGuides()
2980 if (m_activeTimeline)
2981 m_activeTimeline->projectView()->slotDeleteAllGuides();
2984 void MainWindow::slotCutTimelineClip()
2986 if (m_activeTimeline)
2987 m_activeTimeline->projectView()->cutSelectedClips();
2990 void MainWindow::slotInsertClipOverwrite()
2992 if (m_activeTimeline) {
2993 QStringList data = m_clipMonitor->getZoneInfo();
2994 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2998 void MainWindow::slotSelectTimelineClip()
3000 if (m_activeTimeline)
3001 m_activeTimeline->projectView()->selectClip(true);
3004 void MainWindow::slotSelectTimelineTransition()
3006 if (m_activeTimeline)
3007 m_activeTimeline->projectView()->selectTransition(true);
3010 void MainWindow::slotDeselectTimelineClip()
3012 if (m_activeTimeline)
3013 m_activeTimeline->projectView()->selectClip(false, true);
3016 void MainWindow::slotDeselectTimelineTransition()
3018 if (m_activeTimeline)
3019 m_activeTimeline->projectView()->selectTransition(false, true);
3022 void MainWindow::slotSelectAddTimelineClip()
3024 if (m_activeTimeline)
3025 m_activeTimeline->projectView()->selectClip(true, true);
3028 void MainWindow::slotSelectAddTimelineTransition()
3030 if (m_activeTimeline)
3031 m_activeTimeline->projectView()->selectTransition(true, true);
3034 void MainWindow::slotGroupClips()
3036 if (m_activeTimeline)
3037 m_activeTimeline->projectView()->groupClips();
3040 void MainWindow::slotUnGroupClips()
3042 if (m_activeTimeline)
3043 m_activeTimeline->projectView()->groupClips(false);
3046 void MainWindow::slotEditItemDuration()
3048 if (m_activeTimeline)
3049 m_activeTimeline->projectView()->editItemDuration();
3052 void MainWindow::slotAddProjectClip(KUrl url, const QString &comment)
3054 if (m_activeDocument)
3055 m_activeDocument->slotAddClipFile(url, QString(), QString(), comment);
3058 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3060 if (m_activeDocument)
3061 m_activeDocument->slotAddClipList(urls, QString());
3064 void MainWindow::slotAddTransition(QAction *result)
3066 if (!result) return;
3067 QStringList info = result->data().toStringList();
3068 if (info.isEmpty()) return;
3069 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3070 if (m_activeTimeline && !transition.isNull()) {
3071 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3075 void MainWindow::slotAddVideoEffect(QAction *result)
3077 if (!result) return;
3078 const int EFFECT_VIDEO = 1;
3079 const int EFFECT_AUDIO = 2;
3080 QStringList info = result->data().toStringList();
3082 if (info.isEmpty() || info.size() < 3) return;
3083 QDomElement effect ;
3084 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3085 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3086 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3087 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3089 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3090 if (!effect.isNull()) slotAddEffect(effect);
3091 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3095 void MainWindow::slotZoomIn()
3097 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3098 slotShowZoomSliderToolTip();
3101 void MainWindow::slotZoomOut()
3103 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3104 slotShowZoomSliderToolTip();
3107 void MainWindow::slotFitZoom()
3109 if (m_activeTimeline)
3110 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3113 void MainWindow::slotSetZoom(int value)
3115 value = qMax(m_zoomSlider->minimum(), value);
3116 value = qMin(m_zoomSlider->maximum(), value);
3118 if (m_activeTimeline)
3119 m_activeTimeline->slotChangeZoom(value);
3121 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3122 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3123 slotUpdateZoomSliderToolTip(value);
3125 m_zoomSlider->blockSignals(true);
3126 m_zoomSlider->setValue(value);
3127 m_zoomSlider->blockSignals(false);
3130 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3132 if (zoomlevel != -1)
3133 slotUpdateZoomSliderToolTip(zoomlevel);
3135 QPoint global = m_zoomSlider->rect().topLeft();
3136 global.ry() += m_zoomSlider->height() / 2;
3137 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3138 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3141 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3143 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3146 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3148 m_statusProgressBar->setValue(progress);
3149 if (progress >= 0) {
3150 if (!message.isEmpty())
3151 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3152 m_statusProgressBar->setVisible(true);
3153 } else if (progress == -2) {
3154 if (!message.isEmpty())
3155 m_messageLabel->setMessage(message, ErrorMessage);
3156 m_statusProgressBar->setVisible(false);
3158 m_messageLabel->setMessage(QString(), DefaultMessage);
3159 m_statusProgressBar->setVisible(false);
3163 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3165 if (clip->clipType() == TEXT) {
3166 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3167 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3168 // template text clip
3170 // Get the list of existing templates
3172 filter << "*.kdenlivetitle";
3173 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3175 QDialog *dia = new QDialog(this);
3176 Ui::TemplateClip_UI dia_ui;
3177 dia_ui.setupUi(dia);
3179 const QString templatePath = clip->getProperty("resource");
3180 for (int i = 0; i < templateFiles.size(); ++i) {
3181 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3182 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3184 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3185 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3186 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3187 //warning: setting base directory doesn't work??
3188 KUrl startDir(titlepath);
3189 dia_ui.template_list->fileDialog()->setUrl(startDir);
3190 dia_ui.description->setText(clip->getProperty("description"));
3191 if (dia->exec() == QDialog::Accepted) {
3192 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3193 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3195 QMap <QString, QString> newprops;
3197 if (KUrl(textTemplate).path() != templatePath) {
3198 // The template was changed
3199 newprops.insert("resource", textTemplate);
3202 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3203 newprops.insert("description", dia_ui.description->toPlainText());
3206 QString newtemplate = newprops.value("xmltemplate");
3207 if (newtemplate.isEmpty()) newtemplate = templatePath;
3209 // template modified we need to update xmldata
3210 QString description = newprops.value("description");
3211 if (description.isEmpty()) description = clip->getProperty("description");
3212 else newprops.insert("templatetext", description);
3213 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3214 if (!newprops.isEmpty()) {
3215 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3216 m_activeDocument->commandStack()->push(command);
3222 QString path = clip->getProperty("resource");
3223 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3225 doc.setContent(clip->getProperty("xmldata"));
3226 dia_ui->setXml(doc);
3227 if (dia_ui->exec() == QDialog::Accepted) {
3228 QMap <QString, QString> newprops;
3229 newprops.insert("xmldata", dia_ui->xml().toString());
3230 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3231 // duration changed, we need to update duration
3232 newprops.insert("out", QString::number(dia_ui->outPoint()));
3233 int currentLength = QString(clip->producerProperty("length")).toInt();
3234 if (currentLength <= dia_ui->outPoint())
3235 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3236 else newprops.insert("length", clip->producerProperty("length"));
3238 if (!path.isEmpty()) {
3239 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3240 if (KMessageBox::questionYesNo(this, i18n("You are editing an external title clip (%1). Do you want to save your changes to the title file or save the changes for this project only?", path), i18n("Save Title"), KGuiItem(i18n("Save to title file")), KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
3241 // save to external file
3242 dia_ui->saveTitle(path);
3243 } else newprops.insert("resource", QString());
3245 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3246 m_activeDocument->commandStack()->push(command);
3247 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3248 m_activeDocument->setModified(true);
3252 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3256 // any type of clip but a title
3257 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3258 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3259 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3260 connect(dia, SIGNAL(applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)), this, SLOT(slotApplyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)));
3265 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3267 if (newprops.isEmpty()) return;
3268 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3269 m_activeDocument->commandStack()->push(command);
3270 m_activeDocument->setModified();
3273 // update clip occurences in timeline
3274 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3279 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3281 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3282 if (dia.exec() == QDialog::Accepted) {
3283 QUndoCommand *command = new QUndoCommand();
3284 command->setText(i18n("Edit clips"));
3285 QMap <QString, QString> newImageProps = dia.properties();
3286 // Transparency setting applies only for images
3287 QMap <QString, QString> newProps = newImageProps;
3288 newProps.remove("transparency");
3290 for (int i = 0; i < cliplist.count(); i++) {
3291 DocClipBase *clip = cliplist.at(i);
3292 if (clip->clipType() == IMAGE)
3293 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3295 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3297 m_activeDocument->commandStack()->push(command);
3298 for (int i = 0; i < cliplist.count(); i++)
3299 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3303 void MainWindow::customEvent(QEvent* e)
3305 if (e->type() == QEvent::User)
3306 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3308 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3314 m_effectStack->raiseWindow(m_effectStackDock);
3317 void MainWindow::slotActivateTransitionView(Transition *t)
3320 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3323 void MainWindow::slotSnapRewind()
3325 if (m_projectMonitor->isActive()) {
3326 if (m_activeTimeline)
3327 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3329 m_clipMonitor->slotSeekToPreviousSnap();
3333 void MainWindow::slotSnapForward()
3335 if (m_projectMonitor->isActive()) {
3336 if (m_activeTimeline)
3337 m_activeTimeline->projectView()->slotSeekToNextSnap();
3339 m_clipMonitor->slotSeekToNextSnap();
3343 void MainWindow::slotClipStart()
3345 if (m_projectMonitor->isActive()) {
3346 if (m_activeTimeline)
3347 m_activeTimeline->projectView()->clipStart();
3351 void MainWindow::slotClipEnd()
3353 if (m_projectMonitor->isActive()) {
3354 if (m_activeTimeline)
3355 m_activeTimeline->projectView()->clipEnd();
3359 void MainWindow::slotZoneStart()
3361 if (m_projectMonitor->isActive())
3362 m_projectMonitor->slotZoneStart();
3364 m_clipMonitor->slotZoneStart();
3367 void MainWindow::slotZoneEnd()
3369 if (m_projectMonitor->isActive())
3370 m_projectMonitor->slotZoneEnd();
3372 m_clipMonitor->slotZoneEnd();
3375 void MainWindow::slotChangeTool(QAction * action)
3377 if (action == m_buttonSelectTool)
3378 slotSetTool(SELECTTOOL);
3379 else if (action == m_buttonRazorTool)
3380 slotSetTool(RAZORTOOL);
3381 else if (action == m_buttonSpacerTool)
3382 slotSetTool(SPACERTOOL);
3385 void MainWindow::slotChangeEdit(QAction * action)
3387 if (!m_activeTimeline)
3390 if (action == m_overwriteEditTool)
3391 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3392 else if (action == m_insertEditTool)
3393 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3395 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3398 void MainWindow::slotSetTool(PROJECTTOOL tool)
3400 if (m_activeDocument && m_activeTimeline) {
3401 //m_activeDocument->setTool(tool);
3405 message = i18n("Ctrl + click to use spacer on current track only");
3408 message = i18n("Click on a clip to cut it");
3411 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3414 m_messageLabel->setMessage(message, InformationMessage);
3415 m_activeTimeline->projectView()->setTool(tool);
3419 void MainWindow::slotCopy()
3421 if (m_activeDocument && m_activeTimeline)
3422 m_activeTimeline->projectView()->copyClip();
3425 void MainWindow::slotPaste()
3427 if (m_activeDocument && m_activeTimeline)
3428 m_activeTimeline->projectView()->pasteClip();
3431 void MainWindow::slotPasteEffects()
3433 if (m_activeDocument && m_activeTimeline)
3434 m_activeTimeline->projectView()->pasteClipEffects();
3437 void MainWindow::slotFind()
3439 if (!m_activeDocument || !m_activeTimeline) return;
3440 m_projectSearch->setEnabled(false);
3441 m_findActivated = true;
3442 m_findString.clear();
3443 m_activeTimeline->projectView()->initSearchStrings();
3444 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3445 m_findTimer.start(5000);
3446 qApp->installEventFilter(this);
3449 void MainWindow::slotFindNext()
3451 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3452 statusBar()->showMessage(i18n("Found: %1", m_findString));
3454 statusBar()->showMessage(i18n("Reached end of project"));
3455 m_findTimer.start(4000);
3458 void MainWindow::findAhead()
3460 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3461 m_projectSearchNext->setEnabled(true);
3462 statusBar()->showMessage(i18n("Found: %1", m_findString));
3464 m_projectSearchNext->setEnabled(false);
3465 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3469 void MainWindow::findTimeout()
3471 m_projectSearchNext->setEnabled(false);
3472 m_findActivated = false;
3473 m_findString.clear();
3474 statusBar()->showMessage(i18n("Find stopped"), 3000);
3475 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3476 m_projectSearch->setEnabled(true);
3477 removeEventFilter(this);
3480 void MainWindow::slotClipInTimeline(const QString &clipId)
3482 if (m_activeTimeline && m_activeDocument) {
3483 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3485 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3486 inTimelineMenu->clear();
3488 QList <QAction *> actionList;
3490 for (int i = 0; i < matching.count(); ++i) {
3491 QString track = QString::number(matching.at(i).track);
3492 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3494 QAction *a = new QAction(track + ": " + start, this);
3495 a->setData(QStringList() << track << start);
3496 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3497 while (j < actionList.count()) {
3498 if (actionList.at(j)->text() > a->text()) break;
3501 actionList.insert(j, a);
3503 inTimelineMenu->addActions(actionList);
3505 if (matching.empty())
3506 inTimelineMenu->setEnabled(false);
3508 inTimelineMenu->setEnabled(true);
3512 void MainWindow::slotClipInProjectTree()
3514 if (m_activeTimeline) {
3515 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3516 if (clipIds.isEmpty())
3518 m_projectListDock->raise();
3519 for (int i = 0; i < clipIds.count(); i++)
3520 m_projectList->selectItemById(clipIds.at(i));
3521 if (m_projectMonitor->isActive())
3522 slotSwitchMonitors();
3526 /*void MainWindow::slotClipToProjectTree()
3528 if (m_activeTimeline) {
3529 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3530 if (clips.isEmpty()) return;
3531 for (int i = 0; i < clips.count(); i++) {
3532 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3534 //m_projectList->selectItemById(clipIds.at(i));
3538 void MainWindow::slotSelectClipInTimeline()
3540 if (m_activeTimeline) {
3541 QAction *action = qobject_cast<QAction *>(sender());
3542 QStringList data = action->data().toStringList();
3543 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3547 void MainWindow::keyPressEvent(QKeyEvent *ke)
3549 if (m_findActivated) {
3550 if (ke->key() == Qt::Key_Backspace) {
3551 m_findString = m_findString.left(m_findString.length() - 1);
3553 if (!m_findString.isEmpty())
3558 m_findTimer.start(4000);
3561 } else if (ke->key() == Qt::Key_Escape) {
3565 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3566 m_findString += ke->text();
3570 m_findTimer.start(4000);
3575 KXmlGuiWindow::keyPressEvent(ke);
3580 /** Gets called when the window gets hidden */
3581 void MainWindow::hideEvent(QHideEvent */*event*/)
3583 if (isMinimized() && m_monitorManager)
3584 m_monitorManager->stopActiveMonitor();
3587 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3589 if (m_findActivated) {
3590 if (event->type() == QEvent::ShortcutOverride) {
3591 QKeyEvent* ke = (QKeyEvent*) event;
3592 if (ke->text().trimmed().isEmpty()) return false;
3599 // pass the event on to the parent class
3600 return QMainWindow::eventFilter(obj, event);
3605 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3607 KDialog *dialog = new KDialog(this);
3608 dialog->setCaption("Save clip zone");
3609 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3611 QWidget *widget = new QWidget(dialog);
3612 dialog->setMainWidget(widget);
3614 QVBoxLayout *vbox = new QVBoxLayout(widget);
3615 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3616 if (path.isEmpty()) {
3617 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3618 if (baseClip == NULL) tmppath.append("untitled.mlt");
3620 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3622 path = KUrl(tmppath);
3624 KUrlRequester *url = new KUrlRequester(path, this);
3625 url->setFilter("video/mlt-playlist");
3626 QLabel *label2 = new QLabel(i18n("Description:"), this);
3627 KLineEdit *edit = new KLineEdit(this);
3628 vbox->addWidget(label1);
3629 vbox->addWidget(url);
3630 vbox->addWidget(label2);
3631 vbox->addWidget(edit);
3632 if (dialog->exec() == QDialog::Accepted) {
3633 if (QFile::exists(url->url().path())) {
3634 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3635 slotSaveZone(render, zone, baseClip, url->url());
3639 if (baseClip && !baseClip->fileURL().isEmpty()) {
3640 // create zone from clip url, so that we don't have problems with proxy clips
3642 #if QT_VERSION >= 0x040600
3643 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3644 env.remove("MLT_PROFILE");
3645 p.setProcessEnvironment(env);
3647 QStringList env = QProcess::systemEnvironment();
3648 env << "MLT_PROFILE='\0'";
3649 p.setEnvironment(env);
3651 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3652 if (!p.waitForStarted(3000)) {
3653 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3655 else if (!p.waitForFinished(5000)) {
3656 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3659 else render->saveZone(url->url(), edit->text(), zone);
3664 void MainWindow::slotSetInPoint()
3666 if (m_clipMonitor->isActive()) {
3667 m_clipMonitor->slotSetZoneStart();
3669 m_projectMonitor->slotSetZoneStart();
3673 void MainWindow::slotSetOutPoint()
3675 if (m_clipMonitor->isActive()) {
3676 m_clipMonitor->slotSetZoneEnd();
3678 m_projectMonitor->slotSetZoneEnd();
3682 void MainWindow::slotResizeItemStart()
3684 if (m_activeTimeline)
3685 m_activeTimeline->projectView()->setInPoint();
3688 void MainWindow::slotResizeItemEnd()
3690 if (m_activeTimeline)
3691 m_activeTimeline->projectView()->setOutPoint();
3694 int MainWindow::getNewStuff(const QString &configFile)
3696 KNS3::Entry::List entries;
3697 #if KDE_IS_VERSION(4,3,80)
3698 KNS3::DownloadDialog dialog(configFile);
3700 entries = dialog.changedEntries();
3701 foreach(const KNS3::Entry & entry, entries) {
3702 if (entry.status() == KNS3::Entry::Installed)
3703 kDebug() << "// Installed files: " << entry.installedFiles();
3706 KNS::Engine engine(0);
3707 if (engine.init(configFile))
3708 entries = engine.downloadDialogModal(this);
3709 foreach(KNS::Entry * entry, entries) {
3710 if (entry->status() == KNS::Entry::Installed)
3711 kDebug() << "// Installed files: " << entry->installedFiles();
3714 return entries.size();
3717 void MainWindow::slotGetNewTitleStuff()
3719 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3720 TitleWidget::refreshTitleTemplates();
3723 void MainWindow::slotGetNewLumaStuff()
3725 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3726 initEffects::refreshLumas();
3727 m_activeTimeline->projectView()->reloadTransitionLumas();
3731 void MainWindow::slotGetNewRenderStuff()
3733 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3735 m_renderWidget->reloadProfiles();
3738 void MainWindow::slotGetNewMltProfileStuff()
3740 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3741 // update the list of profiles in settings dialog
3742 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3748 void MainWindow::slotAutoTransition()
3750 if (m_activeTimeline)
3751 m_activeTimeline->projectView()->autoTransition();
3754 void MainWindow::slotSplitAudio()
3756 if (m_activeTimeline)
3757 m_activeTimeline->projectView()->splitAudio();
3760 void MainWindow::slotUpdateClipType(QAction *action)
3762 if (m_activeTimeline) {
3763 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3764 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3765 else m_activeTimeline->projectView()->setAudioAndVideo();
3769 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3771 // We must stop the monitors since we create a new on in the dvd wizard
3772 m_clipMonitor->stop();
3773 m_projectMonitor->stop();
3774 DvdWizard w(url, profile, this);
3776 m_projectMonitor->start();
3779 void MainWindow::slotShowTimeline(bool show)
3781 if (show == false) {
3782 m_timelineState = saveState();
3783 centralWidget()->setHidden(true);
3785 centralWidget()->setHidden(false);
3786 restoreState(m_timelineState);
3790 void MainWindow::slotMaximizeCurrent(bool)
3792 //TODO: is there a way to maximize current widget?
3794 m_timelineState = saveState();
3795 QWidget *par = focusWidget()->parentWidget();
3796 while (par->parentWidget() && par->parentWidget() != this)
3797 par = par->parentWidget();
3798 kDebug() << "CURRENT WIDGET: " << par->objectName();
3801 void MainWindow::loadStabilize()
3803 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3806 Mlt::Profile profile;
3807 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3808 QAction *action=stabMenu->addAction("Videostab (vstab)");
3809 action->setData("videostab");
3810 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3812 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3813 QAction *action=stabMenu->addAction("Videostab (transcode)");
3814 action->setData("videostab2");
3815 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3822 void MainWindow::loadTranscoders()
3824 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3827 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
3828 extractAudioMenu->clear();
3830 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3831 KConfigGroup transConfig(config, "Transcoding");
3833 QMap< QString, QString > profiles = transConfig.entryMap();
3834 QMapIterator<QString, QString> i(profiles);
3835 while (i.hasNext()) {
3837 QStringList data = i.value().split(";");
3839 // separate audio transcoding in a separate menu
3840 if (data.count() > 2 && data.at(2) == "audio") {
3841 a = extractAudioMenu->addAction(i.key());
3844 a = transMenu->addAction(i.key());
3847 if (data.count() > 1) a->setToolTip(data.at(1));
3848 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3852 void MainWindow::slotStabilize()
3854 QString condition,filtername;
3857 // Stablize selected clips
3858 QAction *action = qobject_cast<QAction *>(sender());
3860 filtername=action->data().toString();
3862 m_projectList->startClipFilterJob(filtername, condition);
3864 if (ids.isEmpty()) {
3865 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3868 QString destination;
3869 ProjectItem *item = m_projectList->getClipById(ids.at(0));
3870 if (ids.count() == 1) {
3873 ClipStabilize *d = new ClipStabilize(destination, ids.count(), filtername);
3874 //connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3875 if (d->exec() == QDialog::Accepted) {
3876 m_projectList->slotStabilizeClipJob(ids, d->autoAddClip(), d->params(), d->desc());
3881 void MainWindow::slotTranscode(KUrl::List urls)
3886 if (urls.isEmpty()) {
3887 QAction *action = qobject_cast<QAction *>(sender());
3888 QStringList data = action->data().toStringList();
3889 params = data.at(0);
3890 if (data.count() > 1) desc = data.at(1);
3891 if (data.count() > 3) condition = data.at(3);
3892 m_projectList->slotTranscodeClipJob(condition, params, desc);
3895 if (urls.isEmpty()) {
3896 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3899 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3900 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3904 void MainWindow::slotTranscodeClip()
3906 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3907 if (urls.isEmpty()) return;
3908 slotTranscode(urls);
3911 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3913 if (m_activeDocument == NULL) return;
3914 QMapIterator<QString, QString> i(props);
3915 while (i.hasNext()) {
3917 m_activeDocument->setDocumentProperty(i.key(), i.value());
3919 m_activeDocument->setModified(true);
3923 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3925 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3927 QString playlistPath;
3930 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3931 QString path = m_renderWidget->getFreeScriptName();
3932 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3933 if (!ok || scriptPath.isEmpty()) return;
3934 scriptPath.prepend(scriptsFolder);
3935 QFile f(scriptPath);
3937 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3940 playlistPath = scriptPath + ".mlt";
3942 KTemporaryFile temp;
3943 temp.setAutoRemove(false);
3944 temp.setSuffix(".mlt");
3946 playlistPath = temp.fileName();
3948 QString playlistContent = m_projectMonitor->sceneList();
3949 if (!chapterFile.isEmpty()) {
3952 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3954 in = m_activeTimeline->inPoint();
3955 out = m_activeTimeline->outPoint();
3958 QDomElement chapters = doc.createElement("chapters");
3959 chapters.setAttribute("fps", m_activeDocument->fps());
3960 doc.appendChild(chapters);
3962 QDomElement guidesxml = m_activeDocument->guidesXml();
3963 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3964 for (int i = 0; i < nodes.count(); i++) {
3965 QDomElement e = nodes.item(i).toElement();
3967 QString comment = e.attribute("comment");
3968 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3969 if (time >= in && time < out) {
3970 if (zoneOnly) time = time - in;
3971 QDomElement chapter = doc.createElement("chapter");
3972 chapters.appendChild(chapter);
3973 chapter.setAttribute("title", comment);
3974 chapter.setAttribute("time", time);
3978 if (chapters.childNodes().count() > 0) {
3979 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3980 // Always insert a guide in pos 0
3981 QDomElement chapter = doc.createElement("chapter");
3982 chapters.insertBefore(chapter, QDomNode());
3983 chapter.setAttribute("title", i18n("Start"));
3984 chapter.setAttribute("time", "0");
3986 // save chapters file
3987 QFile file(chapterFile);
3988 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3989 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3991 file.write(doc.toString().toUtf8());
3992 if (file.error() != QFile::NoError) {
3993 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4000 if (m_renderWidget->automaticAudioExport()) {
4001 exportAudio = m_activeTimeline->checkProjectAudio();
4002 } else exportAudio = m_renderWidget->selectedAudioExport();
4004 // Set playlist audio volume to 100%
4006 doc.setContent(playlistContent);
4007 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4008 if (!tractor.isNull()) {
4009 QDomNodeList props = tractor.elementsByTagName("property");
4010 for (int i = 0; i < props.count(); i++) {
4011 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4012 props.at(i).firstChild().setNodeValue("1");
4018 // Do we want proxy rendering
4019 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4020 QString root = doc.documentElement().attribute("root");
4022 // replace proxy clips with originals
4023 QMap <QString, QString> proxies = m_projectList->getProxies();
4025 QDomNodeList producers = doc.elementsByTagName("producer");
4026 QString producerResource;
4028 for (uint n = 0; n < producers.length(); n++) {
4029 QDomElement e = producers.item(n).toElement();
4030 producerResource = EffectsList::property(e, "resource");
4031 if (producerResource.isEmpty()) continue;
4032 if (!producerResource.startsWith("/")) {
4033 producerResource.prepend(root + "/");
4035 if (producerResource.contains('?')) {
4036 // slowmotion producer
4037 suffix = "?" + producerResource.section('?', 1);
4038 producerResource = producerResource.section('?', 0, 0);
4040 else suffix.clear();
4041 if (!producerResource.isEmpty()) {
4042 if (proxies.contains(producerResource)) {
4043 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4044 // We need to delete the "aspect_ratio" property because proxy clips
4045 // sometimes have different ratio than original clips
4046 EffectsList::removeProperty(e, "aspect_ratio");
4047 EffectsList::removeMetaProperties(e);
4052 /*QMapIterator<QString, QString> i(proxies);
4053 while (i.hasNext()) {
4055 // Replace all keys with their values (proxy path with original path)
4056 QString key = i.key();
4057 playlistContent.replace(key, i.value());
4058 if (!root.isEmpty() && key.startsWith(root)) {
4059 // in case the resource path in MLT playlist is relative
4060 key.remove(0, root.count() + 1);
4061 playlistContent.replace(key, i.value());
4065 playlistContent = doc.toString();
4067 // Do save scenelist
4068 QFile file(playlistPath);
4069 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4070 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4073 file.write(playlistContent.toUtf8());
4074 if (file.error() != QFile::NoError) {
4075 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4080 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4083 void MainWindow::slotUpdateTimecodeFormat(int ix)
4085 KdenliveSettings::setFrametimecode(ix == 1);
4086 m_clipMonitor->updateTimecodeFormat();
4087 m_projectMonitor->updateTimecodeFormat();
4088 m_transitionConfig->updateTimecodeFormat();
4089 m_effectStack->updateTimecodeFormat();
4090 //m_activeTimeline->projectView()->clearSelection();
4091 m_activeTimeline->updateRuler();
4094 void MainWindow::slotRemoveFocus()
4096 statusBar()->setFocus();
4097 statusBar()->clearFocus();
4100 void MainWindow::slotRevert()
4102 if (KMessageBox::warningContinueCancel(this, i18n("This will delete all changes made since you last saved your project. Are you sure you want to continue?"), i18n("Revert to last saved version")) == KMessageBox::Cancel) return;
4103 KUrl url = m_activeDocument->url();
4104 if (closeCurrentDocument(false))
4105 doOpenFile(url, NULL);
4109 void MainWindow::slotShutdown()
4111 if (m_activeDocument) m_activeDocument->setModified(false);
4113 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4114 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4115 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4116 smserver.call("logout", 1, 2, 2);
4117 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4118 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4119 smserver.call("Shutdown");
4123 void MainWindow::slotUpdateTrackInfo()
4125 if (m_activeDocument)
4126 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4129 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4131 // Load the theme file
4133 if (action == NULL) theme = themename;
4134 else theme = action->data().toString();
4135 KdenliveSettings::setColortheme(theme);
4136 // Make palette for all widgets.
4137 QPalette plt = kapp->palette();
4138 if (theme.isEmpty()) {
4139 plt = QApplication::desktop()->palette();
4141 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4143 #if KDE_IS_VERSION(4,6,3)
4144 plt = KGlobalSettings::createNewApplicationPalette(config);
4146 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4147 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4148 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4149 QPalette::Disabled };
4150 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4151 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4153 for ( int i = 0; i < 3 ; i++ ) {
4154 QPalette::ColorGroup state = states[i];
4155 KColorScheme schemeView(state, KColorScheme::View, config);
4156 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4157 KColorScheme schemeButton(state, KColorScheme::Button, config);
4158 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4160 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4161 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4162 plt.setBrush( state, QPalette::Base, schemeView.background() );
4163 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4164 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4165 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4166 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4167 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4168 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4169 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4171 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4172 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4173 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4174 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4175 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4177 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4178 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4179 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4184 kapp->setPalette(plt);
4185 const QObjectList children = statusBar()->children();
4187 foreach(QObject * child, children) {
4188 if (child->isWidgetType())
4189 ((QWidget*)child)->setPalette(plt);
4190 const QObjectList subchildren = child->children();
4191 foreach(QObject * subchild, subchildren) {
4192 if (subchild->isWidgetType())
4193 ((QWidget*)subchild)->setPalette(plt);
4196 if (m_activeTimeline) {
4197 m_activeTimeline->projectView()->updatePalette();
4202 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4204 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4205 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4206 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4207 const QSize bitsSize(24, 2);
4208 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4209 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4211 QPixmap pixmap(23, 16);
4212 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4214 KConfigGroup group(config, "WM");
4215 QPainter p(&pixmap);
4216 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4217 p.fillRect(1, 1, 7, 7, windowScheme.background());
4218 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4220 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4221 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4222 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4224 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4225 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4227 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4228 p.fillRect(1, 8, 7, 7, viewScheme.background());
4229 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4231 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4232 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4233 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4235 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4236 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4242 void MainWindow::slotSwitchMonitors()
4244 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4245 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4246 else m_projectList->focusTree();
4249 void MainWindow::slotInsertZoneToTree()
4251 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4252 QStringList info = m_clipMonitor->getZoneInfo();
4253 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4256 void MainWindow::slotInsertZoneToTimeline()
4258 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4259 QStringList info = m_clipMonitor->getZoneInfo();
4260 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4264 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4266 if (m_activeDocument && m_activeTimeline) {
4267 if (!ids.isEmpty()) {
4268 for (int i = 0; i < ids.size(); ++i) {
4269 m_activeTimeline->slotDeleteClip(ids.at(i));
4271 m_activeDocument->clipManager()->slotDeleteClips(ids);
4273 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4274 m_activeDocument->setModified(true);
4278 void MainWindow::slotShowTitleBars(bool show)
4280 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4281 for (int i = 0; i < docks.count(); i++) {
4282 QDockWidget* dock = docks.at(i);
4284 dock->setTitleBarWidget(0);
4286 if (!dock->isFloating()) {
4287 dock->setTitleBarWidget(new QWidget);
4291 KdenliveSettings::setShowtitlebars(show);
4294 void MainWindow::slotSwitchTitles()
4296 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4299 QString MainWindow::getMimeType(bool open)
4301 QString mimetype = "application/x-kdenlive";
4302 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4304 mimetype = "*.kdenlive";
4305 if (open) mimetype.append(" *.tar.gz");
4307 else if (open) mimetype.append(" application/x-compressed-tar");
4311 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4314 m_projectMonitor->render->sendFrameForAnalysis = true;
4317 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4318 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4325 qDebug() << "Any scope accepting new frames? " << request;
4328 m_projectMonitor->render->sendFrameForAnalysis = false;
4333 void MainWindow::slotOpenStopmotion()
4335 if (m_stopmotion == NULL) {
4336 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4337 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4338 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4339 // Check if we need the renderer to send a new frame for update
4340 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4341 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4342 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4345 m_stopmotion->show();
4348 void MainWindow::slotDeleteClip(const QString &id)
4350 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4351 for (int i = 0; i < list.size(); ++i) {
4352 list.at(i)->disableClipId(id);
4354 m_projectList->slotDeleteClip(id);
4357 void MainWindow::slotUpdateProxySettings()
4359 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4360 if (KdenliveSettings::enableproxy())
4361 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4362 m_projectList->updateProxyConfig();
4365 void MainWindow::slotInsertNotesTimecode()
4367 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4368 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4369 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4372 void MainWindow::slotArchiveProject()
4374 QList <DocClipBase*> list = m_projectList->documentClipList();
4375 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4376 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4381 void MainWindow::slotOpenBackupDialog(const KUrl url)
4386 kDebug()<<"// BACKUP URL: "<<url.path();
4387 if (!url.isEmpty()) {
4388 // we could not open the project file, guess where the backups are
4389 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4393 projectFolder = m_activeDocument->projectFolder();
4394 projectFile = m_activeDocument->url();
4395 projectId = m_activeDocument->getDocumentProperty("documentid");
4398 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4399 if (dia->exec() == QDialog::Accepted) {
4400 QString requestedBackup = dia->selectedFile();
4401 m_activeDocument->backupLastSavedVersion(projectFile.path());
4402 closeCurrentDocument(false);
4403 doOpenFile(KUrl(requestedBackup), NULL);
4404 m_activeDocument->setUrl(projectFile);
4405 m_activeDocument->setModified(true);
4406 setCaption(m_activeDocument->description());
4411 void MainWindow::slotElapsedTime()
4413 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4417 void MainWindow::slotDownloadResources()
4419 QString currentFolder;
4420 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4421 else currentFolder = KdenliveSettings::defaultprojectfolder();
4422 ResourceWidget *d = new ResourceWidget(currentFolder);
4423 connect(d, SIGNAL(addClip(KUrl, const QString &)), this, SLOT(slotAddProjectClip(KUrl, const QString &)));
4427 #include "mainwindow.moc"