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 "effectstack/effectstackview2.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #include "jogaction.h"
45 #include "jogshuttleconfig.h"
47 #include "clipproperties.h"
49 #include "commands/editclipcommand.h"
50 #include "titlewidget.h"
51 #include "markerdialog.h"
53 #include "interfaces.h"
54 #include "config-kdenlive.h"
55 #include "cliptranscode.h"
56 #include "ui_templateclip_ui.h"
57 #include "scopes/scopemanager.h"
58 #include "scopes/colorscopes/vectorscope.h"
59 #include "scopes/colorscopes/waveform.h"
60 #include "scopes/colorscopes/rgbparade.h"
61 #include "scopes/colorscopes/histogram.h"
62 #include "scopes/audioscopes/audiosignal.h"
63 #include "scopes/audioscopes/audiospectrum.h"
64 #include "scopes/audioscopes/spectrogram.h"
65 #include "archivewidget.h"
66 #include "databackup/backupwidget.h"
67 #include "utils/resourcewidget.h"
70 #include <KApplication>
74 #include <KActionCollection>
75 #include <KActionCategory>
76 #include <KStandardAction>
77 #include <KShortcutsDialog>
78 #include <KFileDialog>
79 #include <KMessageBox>
81 #include <KIO/NetAccess>
84 #include <KConfigDialog>
85 #include <KXMLGUIFactory>
87 #include <kstandarddirs.h>
88 #include <KUrlRequesterDialog>
89 #include <KTemporaryFile>
91 #include <KActionMenu>
93 #include <ktogglefullscreenaction.h>
95 #include <KNotification>
96 #include <KNotifyConfigWidget>
97 #if KDE_IS_VERSION(4,3,80)
98 #include <knewstuff3/downloaddialog.h>
99 #include <knewstuff3/knewstuffaction.h>
101 #include <knewstuff2/engine.h>
102 #include <knewstuff2/ui/knewstuffaction.h>
106 #include <KColorScheme>
107 #include <KProgressDialog>
109 #include <QTextStream>
113 #include <QInputDialog>
114 #include <QDesktopWidget>
120 // Uncomment for deeper debugging
121 //#define DEBUG_MAINW
127 static const char version[] = VERSION;
129 static const int ID_TIMELINE_POS = 0;
135 Q_DECLARE_METATYPE(QVector<int16_t>)
138 EffectsList MainWindow::videoEffects;
139 EffectsList MainWindow::audioEffects;
140 EffectsList MainWindow::customEffects;
141 EffectsList MainWindow::transitions;
143 QMap <QString,QImage> MainWindow::m_lumacache;
145 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
146 KXmlGuiWindow(parent),
147 m_activeDocument(NULL),
148 m_activeTimeline(NULL),
153 m_projectMonitor(NULL),
155 m_renderWidget(NULL),
156 #ifdef USE_JOGSHUTTLE
160 m_findActivated(false),
164 qRegisterMetaType<QVector<int16_t> > ();
165 qRegisterMetaType<stringMap> ("stringMap");
166 qRegisterMetaType<audioByteArray> ("audioByteArray");
169 QLocale systemLocale = QLocale();
170 setlocale(LC_NUMERIC, NULL);
171 char *separator = localeconv()->decimal_point;
172 if (separator != systemLocale.decimalPoint()) {
173 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
174 // HACK: There is a locale conflict, so set locale to C
175 // Make sure to override exported values or it won't work
176 setenv("LANG", "C", 1);
177 setlocale(LC_NUMERIC, "C");
178 systemLocale = QLocale::c();
181 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
182 QLocale::setDefault(systemLocale);
184 // Create DBus interface
185 new MainWindowAdaptor(this);
186 QDBusConnection dbus = QDBusConnection::sessionBus();
187 dbus.registerObject("/MainWindow", this);
189 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
190 setFont(KGlobalSettings::toolBarFont());
191 parseProfiles(MltPath);
192 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
193 m_commandStack = new QUndoGroup;
194 setDockNestingEnabled(true);
195 m_timelineArea = new KTabWidget(this);
196 m_timelineArea->setTabReorderingEnabled(true);
197 m_timelineArea->setTabBarHidden(true);
198 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
199 m_timelineArea->setMinimumHeight(200);
201 QToolButton *closeTabButton = new QToolButton;
202 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
203 closeTabButton->setIcon(KIcon("tab-close"));
204 closeTabButton->adjustSize();
205 closeTabButton->setToolTip(i18n("Close the current tab"));
206 m_timelineArea->setCornerWidget(closeTabButton);
207 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
209 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
210 m_findTimer.setSingleShot(true);
212 // FIXME: the next call returns a newly allocated object, which leaks
213 initEffects::parseEffectFiles();
214 //initEffects::parseCustomEffectsFile();
216 m_monitorManager = new MonitorManager();
218 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
219 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
224 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
225 m_projectListDock->setObjectName("project_tree");
226 m_projectList = new ProjectList();
227 m_projectListDock->setWidget(m_projectList);
228 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
230 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
231 m_clipMonitorDock->setObjectName("clip_monitor");
232 m_clipMonitor = new Monitor(Kdenlive::clipMonitor, m_monitorManager, QString(), m_timelineArea);
233 m_clipMonitorDock->setWidget(m_clipMonitor);
235 // Connect the project list
236 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
237 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(slotActivateMonitor()));
238 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
239 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
240 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
241 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
242 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
243 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
244 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
245 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
246 connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
248 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
249 m_projectMonitorDock->setObjectName("project_monitor");
250 m_projectMonitor = new Monitor(Kdenlive::projectMonitor, m_monitorManager, QString());
251 m_projectMonitorDock->setWidget(m_projectMonitor);
254 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
255 m_recMonitorDock->setObjectName("record_monitor");
256 m_recMonitor = new RecMonitor(Kdenlive::recordMonitor, m_monitorManager);
257 m_recMonitorDock->setWidget(m_recMonitor);
258 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
259 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
260 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
262 #endif /* ! Q_WS_MAC */
263 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
265 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
266 m_notesDock->setObjectName("notes_widget");
267 m_notesWidget = new NotesWidget();
268 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
269 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
271 m_notesWidget->setTabChangesFocus(true);
272 #if KDE_IS_VERSION(4,4,0)
273 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
275 m_notesDock->setWidget(m_notesWidget);
276 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
278 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
279 m_effectStackDock->setObjectName("effect_stack");
280 m_effectStack = new EffectStackView2(m_projectMonitor);
281 m_effectStackDock->setWidget(m_effectStack);
282 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
283 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&)));
285 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
286 m_transitionConfigDock->setObjectName("transition");
287 m_transitionConfig = new TransitionSettings(m_projectMonitor);
288 m_transitionConfigDock->setWidget(m_transitionConfig);
289 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
291 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
292 m_effectListDock->setObjectName("effect_list");
293 m_effectList = new EffectsListView();
294 m_effectListDock->setWidget(m_effectList);
295 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
297 m_scopeManager = new ScopeManager(m_monitorManager);
298 m_vectorscope = new Vectorscope();
299 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
300 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
301 m_vectorscopeDock->setWidget(m_vectorscope);
302 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
303 m_scopeManager->addScope(m_vectorscope, m_vectorscopeDock);
305 m_waveform = new Waveform();
306 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
307 m_waveformDock->setObjectName(m_waveform->widgetName());
308 m_waveformDock->setWidget(m_waveform);
309 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
310 m_scopeManager->addScope(m_waveform, m_waveformDock);
312 m_RGBParade = new RGBParade();
313 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
314 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
315 m_RGBParadeDock->setWidget(m_RGBParade);
316 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
317 m_scopeManager->addScope(m_RGBParade, m_RGBParadeDock);
319 m_histogram = new Histogram();
320 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
321 m_histogramDock->setObjectName(m_histogram->widgetName());
322 m_histogramDock->setWidget(m_histogram);
323 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
324 m_scopeManager->addScope(m_histogram, m_histogramDock);
326 m_audiosignal = new AudioSignal;
327 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
328 m_audiosignalDock->setObjectName("audiosignal");
329 m_audiosignalDock->setWidget(m_audiosignal);
330 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
331 m_scopeManager->addScope(m_audiosignal, m_audiosignalDock);
333 m_audioSpectrum = new AudioSpectrum();
334 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
335 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
336 m_audioSpectrumDock->setWidget(m_audioSpectrum);
337 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
338 m_scopeManager->addScope(m_audioSpectrum, m_audioSpectrumDock);
340 m_spectrogram = new Spectrogram();
341 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
342 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
343 m_spectrogramDock->setWidget(m_spectrogram);
344 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
345 m_scopeManager->addScope(m_spectrogram, m_spectrogramDock);
347 // Add monitors here to keep them at the right of the window
348 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
349 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
351 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
354 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
355 m_undoViewDock->setObjectName("undo_history");
356 m_undoView = new QUndoView();
357 m_undoView->setCleanIcon(KIcon("edit-clear"));
358 m_undoView->setEmptyLabel(i18n("Clean"));
359 m_undoViewDock->setWidget(m_undoView);
360 m_undoView->setGroup(m_commandStack);
361 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
365 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
368 // Close non-general docks for the initial layout
369 // only show important ones
370 m_histogramDock->close();
371 m_RGBParadeDock->close();
372 m_waveformDock->close();
373 m_vectorscopeDock->close();
375 m_audioSpectrumDock->close();
376 m_spectrogramDock->close();
377 m_audiosignalDock->close();
379 m_undoViewDock->close();
383 /// Tabify Widgets ///
384 tabifyDockWidget(m_effectListDock, m_effectStackDock);
385 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
386 tabifyDockWidget(m_projectListDock, m_notesDock);
388 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
390 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
392 setCentralWidget(m_timelineArea);
394 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
396 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
397 m_fileRevert->setEnabled(false);
399 // Prepare layout actions
400 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
401 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
402 for (int i = 1; i < 5; i++) {
403 KAction *load = new KAction(KIcon(), i18n("Layout %1", i), this);
404 load->setData('_' + QString::number(i));
405 layoutActions->addAction("load_layout" + QString::number(i), load);
406 m_loadLayout->addAction(load);
407 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1", i), this);
408 save->setData('_' + QString::number(i));
409 layoutActions->addAction("save_layout" + QString::number(i), save);
411 // Required to enable user to add the load layout action to toolbar
412 layoutActions->addAction("load_layouts", m_loadLayout);
413 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
416 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
417 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
418 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
419 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
420 m_stopmotion_actions->addAction("stopmotion_capture", action);
421 action = new KAction(i18n("Switch live / captured frame"), this);
422 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
423 m_stopmotion_actions->addAction("stopmotion_switch", action);
424 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
425 action->setCheckable(true);
426 action->setChecked(false);
427 m_stopmotion_actions->addAction("stopmotion_overlay", action);
429 // Build effects menu
430 m_effectsMenu = new QMenu(i18n("Add Effect"));
431 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
432 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
433 m_effectsActionCollection->readSettings();
435 // Populate View menu with show / hide actions for dock widgets
436 KActionCategory *guiActions = new KActionCategory(i18n("Interface"), actionCollection());
440 // Find QDockWidget tab bars and show / hide widget title bars on right click
441 QList <QTabBar *> tabs = findChildren<QTabBar *>();
442 for (int i = 0; i < tabs.count(); i++) {
443 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
444 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
447 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
448 guiFactory()->addClient(sp);*/
449 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
450 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
453 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
455 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
458 // Load layout names from config file
465 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
466 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
468 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
469 clipInTimeline->setIcon(KIcon("go-jump"));
470 QHash<QString,QMenu*> menus;
471 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
472 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
473 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
474 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
475 menus.insert("inTimelineMenu",clipInTimeline);
476 m_projectList->setupGeneratorMenu(menus);
478 // build themes menus
479 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
480 QActionGroup *themegroup = new QActionGroup(this);
481 themegroup->setExclusive(true);
482 action = new KAction(i18n("Default"), this);
483 action->setCheckable(true);
484 themegroup->addAction(action);
485 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
487 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
489 for (int i = 0; i < schemeFiles.size(); ++i) {
491 const QString filename = schemeFiles.at(i);
492 const QFileInfo info(filename);
495 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
496 QIcon icon = createSchemePreviewIcon(config);
497 KConfigGroup group(config, "General");
498 const QString name = group.readEntry("Name", info.baseName());
499 action = new KAction(name, this);
500 action->setData(filename);
501 action->setIcon(icon);
502 action->setCheckable(true);
503 themegroup->addAction(action);
504 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
507 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
508 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
509 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
512 action = new QAction(fi.fileName(), this);
513 action->setData(*it);
514 action->setCheckable(true);
515 themegroup->addAction(action);
516 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
518 themesMenu->addActions(themegroup->actions());
519 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
521 // Setup and fill effects and transitions menus.
524 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
525 m->addActions(m_effectsMenu->actions());
528 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
529 for (int i = 0; i < transitions.count(); ++i)
530 m_transitionsMenu->addAction(m_transitions[i]);
532 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
533 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
534 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
536 m_timelineContextMenu = new QMenu(this);
537 m_timelineContextClipMenu = new QMenu(this);
538 m_timelineContextTransitionMenu = new QMenu(this);
540 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
541 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
542 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
544 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
545 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
546 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
547 m_timelineContextClipMenu->addSeparator();
548 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
549 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
550 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
551 m_timelineContextClipMenu->addAction(actionCollection()->action("set_audio_align_ref"));
552 m_timelineContextClipMenu->addAction(actionCollection()->action("align_audio"));
553 m_timelineContextClipMenu->addSeparator();
554 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
555 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
556 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
557 m_timelineContextClipMenu->addSeparator();
559 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
560 m_timelineContextClipMenu->addMenu(markersMenu);
561 m_timelineContextClipMenu->addSeparator();
562 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
563 m_timelineContextClipMenu->addMenu(m_effectsMenu);
565 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
566 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
568 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
570 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
571 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
572 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
573 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
575 slotConnectMonitors();
577 // Open or create a file. Command line argument passed in Url has
578 // precedence, then "openlastproject", then just a plain empty file.
579 // If opening Url fails, openlastproject will _not_ be used.
580 if (!Url.isEmpty()) {
581 // delay loading so that the window shows up
583 QTimer::singleShot(500, this, SLOT(openFile()));
584 } else if (KdenliveSettings::openlastproject()) {
585 QTimer::singleShot(500, this, SLOT(openLastFile()));
586 } else { //if (m_timelineArea->count() == 0) {
590 if (!clipsToLoad.isEmpty() && m_activeDocument) {
591 QStringList list = clipsToLoad.split(',');
593 foreach(const QString &path, list) {
594 kDebug() << QDir::current().absoluteFilePath(path);
595 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
597 m_projectList->slotAddClip(urls);
600 #ifdef USE_JOGSHUTTLE
601 activateShuttleDevice();
603 m_projectListDock->raise();
605 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
606 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
608 QMap <QString, KAction *> viewActions;
609 KAction *showTimeline = new KAction(i18n("Timeline"), this);
610 showTimeline->setCheckable(true);
611 showTimeline->setChecked(true);
612 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
613 viewActions.insert(showTimeline->text(), showTimeline);
615 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
616 for (int i = 0; i < docks.count(); i++) {
617 QDockWidget* dock = docks.at(i);
618 KAction* dockInformations = new KAction(this);
619 dockInformations->setText(dock->windowTitle());
620 dockInformations->setCheckable(true);
621 dockInformations->setChecked(!dock->isHidden());
622 connect(dockInformations,SIGNAL(toggled(bool)), dock, SLOT(setVisible(bool)));
623 viewActions.insert(dockInformations->text(), dockInformations);
627 KMenu *viewMenu = static_cast<KMenu*>(factory()->container("dockwindows", this));
628 //const QList<QAction *> viewActions = createPopupMenu()->actions();
629 QMap<QString, KAction *>::const_iterator i = viewActions.constBegin();
630 while (i != viewActions.constEnd()) {
631 viewMenu->addAction(guiActions->addAction(i.key(), i.value()));
635 // Populate encoding profiles
636 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
637 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
638 KConfigGroup group(&conf, "proxy");
639 QMap< QString, QString > values = group.entryMap();
640 QMapIterator<QString, QString> i(values);
643 QString data = i.value();
644 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
645 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
648 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
649 KConfigGroup group(&conf, "video4linux");
650 QMap< QString, QString > values = group.entryMap();
651 QMapIterator<QString, QString> i(values);
654 QString data = i.value();
655 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
656 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
659 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
660 KConfigGroup group(&conf, "decklink");
661 QMap< QString, QString > values = group.entryMap();
662 QMapIterator<QString, QString> i(values);
665 QString data = i.value();
666 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
667 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
671 connect (KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(slotChangePalette()));
674 MainWindow::~MainWindow()
679 m_effectStack->slotClipItemSelected(NULL);
680 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
682 if (m_projectMonitor) m_projectMonitor->stop();
683 if (m_clipMonitor) m_clipMonitor->stop();
685 delete m_activeTimeline;
686 delete m_effectStack;
687 delete m_transitionConfig;
688 delete m_activeDocument;
689 delete m_projectMonitor;
690 delete m_clipMonitor;
691 delete m_shortcutRemoveFocus;
692 delete[] m_transitions;
693 delete m_monitorManager;
694 delete m_scopeManager;
695 Mlt::Factory::close();
699 bool MainWindow::queryClose()
701 if (m_renderWidget) {
702 int waitingJobs = m_renderWidget->waitingJobsCount();
703 if (waitingJobs > 0) {
704 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")))) {
705 case KMessageBox::Yes :
706 // create script with waiting jobs and start it
707 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
709 case KMessageBox::No :
710 // Don't do anything, jobs will be deleted
718 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
719 // warn the user to save if document is modified and we have clips in our project list
720 if (m_activeDocument && m_activeDocument->isModified() &&
721 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
722 !m_projectList->documentClipList().isEmpty())) {
726 if (m_activeDocument->url().fileName().isEmpty())
727 message = i18n("Save changes to document?");
729 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?", m_activeDocument->url().fileName());
730 switch (KMessageBox::warningYesNoCancel(this, message)) {
731 case KMessageBox::Yes :
732 // save document here. If saving fails, return false;
734 case KMessageBox::No :
735 // User does not want to save the changes, clear recovery files
736 m_activeDocument->m_autosave->resize(0);
745 void MainWindow::loadPlugins()
747 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
748 populateMenus(plugin);
751 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
753 filters << "libkdenlive*";
754 foreach(const QString & folder, directories) {
755 kDebug() << "Parsing plugin folder: " << folder;
756 QDir pluginsDir(folder);
757 foreach(const QString & fileName,
758 pluginsDir.entryList(filters, QDir::Files)) {
760 * Avoid loading the same plugin twice when there is more than one
763 if (!m_pluginFileNames.contains(fileName)) {
764 kDebug() << "Found plugin: " << fileName;
765 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
766 QObject *plugin = loader.instance();
768 populateMenus(plugin);
769 m_pluginFileNames += fileName;
771 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
777 void MainWindow::populateMenus(QObject *plugin)
779 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
780 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
782 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
786 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
787 QMenu *menu, const char *member,
788 QActionGroup *actionGroup)
790 kDebug() << "// ADD to MENU" << texts;
791 foreach(const QString & text, texts) {
792 QAction *action = new QAction(text, plugin);
793 action->setData(text);
794 connect(action, SIGNAL(triggered()), this, member);
795 menu->addAction(action);
798 action->setCheckable(true);
799 actionGroup->addAction(action);
804 void MainWindow::aboutPlugins()
806 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
811 void MainWindow::generateClip()
813 QAction *action = qobject_cast<QAction *>(sender());
814 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
816 KUrl clipUrl = iGenerator->generatedClip(KdenliveSettings::rendererpath(), action->data().toString(), m_activeDocument->projectFolder(),
817 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
818 if (!clipUrl.isEmpty()) {
819 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
823 void MainWindow::saveProperties(KConfigGroup &config)
825 // save properties here,used by session management
827 KMainWindow::saveProperties(config);
831 void MainWindow::readProperties(const KConfigGroup &config)
833 // read properties here,used by session management
834 KMainWindow::readProperties(config);
835 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
836 openFile(KUrl(Lastproject));
839 void MainWindow::slotReloadEffects()
841 initEffects::parseCustomEffectsFile();
842 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
845 #ifdef USE_JOGSHUTTLE
846 void MainWindow::activateShuttleDevice()
852 if (KdenliveSettings::enableshuttle() == false) return;
854 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
855 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
857 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
858 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
859 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
860 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
861 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
863 #endif /* USE_JOGSHUTTLE */
865 void MainWindow::slotDoAction(const QString& action_name)
867 QAction* action = actionCollection()->action(action_name);
869 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
875 void MainWindow::configureNotifications()
877 KNotifyConfigWidget::configure(this);
880 void MainWindow::slotFullScreen()
882 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
885 void MainWindow::slotAddEffect(const QDomElement effect)
887 if (!m_activeDocument) return;
888 if (effect.isNull()) {
889 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
892 QDomElement effectToAdd = effect.cloneNode().toElement();
894 int ix = m_effectStack->isTrackMode(&ok);
895 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
896 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
899 void MainWindow::slotUpdateClip(const QString &id)
901 if (!m_activeDocument) return;
902 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
904 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
905 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
906 Mlt::Producer *monitorProducer = clip->getCloneProducer();
907 m_clipMonitor->updateClipProducer(monitorProducer);
909 clip->cleanupProducers();
912 void MainWindow::slotConnectMonitors()
914 m_projectList->setRenderer(m_projectMonitor->render);
915 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
916 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
917 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
918 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
919 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
921 kDebug()<<" - - - - - -\n CONNECTED REPLY";
922 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)));
924 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
926 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
928 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
930 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
931 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
933 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
935 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
936 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
939 void MainWindow::slotAdjustClipMonitor()
941 m_clipMonitorDock->updateGeometry();
942 m_clipMonitorDock->adjustSize();
943 m_clipMonitor->resetSize();
946 void MainWindow::slotAdjustProjectMonitor()
948 m_projectMonitorDock->updateGeometry();
949 m_projectMonitorDock->adjustSize();
950 m_projectMonitor->resetSize();
954 class NameGrabbingKActionCollection {
956 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
957 : m_collection(collection), m_action_names(action_names) {
958 m_action_names.clear();
960 KAction* addAction(const QString& action_name) {
961 m_action_names << action_name;
962 return m_collection->addAction(action_name);
964 void addAction(const QString& action_name, QAction* action) {
965 m_action_names << action_name;
966 m_collection->addAction(action_name, action);
968 operator KActionCollection*() { return m_collection; }
969 const QStringList& actionNames() const { return m_action_names; }
971 KActionCollection* m_collection;
972 QStringList& m_action_names;
975 void MainWindow::setupActions()
978 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
979 m_timecodeFormat = new KComboBox(this);
980 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
981 m_timecodeFormat->addItem(i18n("Frames"));
982 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
983 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
985 m_statusProgressBar = new QProgressBar(this);
986 m_statusProgressBar->setMinimum(0);
987 m_statusProgressBar->setMaximum(100);
988 m_statusProgressBar->setMaximumWidth(150);
989 m_statusProgressBar->setVisible(false);
991 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
992 toolbar->setMovable(false);
994 setStatusBarStyleSheet(palette());
995 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
997 //create edit mode buttons
998 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
999 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
1000 toolbar->addAction(m_normalEditTool);
1001 m_normalEditTool->setCheckable(true);
1002 m_normalEditTool->setChecked(true);
1004 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
1005 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
1006 toolbar->addAction(m_overwriteEditTool);
1007 m_overwriteEditTool->setCheckable(true);
1008 m_overwriteEditTool->setChecked(false);
1010 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
1011 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
1012 toolbar->addAction(m_insertEditTool);
1013 m_insertEditTool->setCheckable(true);
1014 m_insertEditTool->setChecked(false);
1015 // not implemented yet
1016 m_insertEditTool->setEnabled(false);
1018 QActionGroup *editGroup = new QActionGroup(this);
1019 editGroup->addAction(m_normalEditTool);
1020 editGroup->addAction(m_overwriteEditTool);
1021 editGroup->addAction(m_insertEditTool);
1022 editGroup->setExclusive(true);
1023 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
1024 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1026 toolbar->addSeparator();
1028 // create tools buttons
1029 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1030 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1031 toolbar->addAction(m_buttonSelectTool);
1032 m_buttonSelectTool->setCheckable(true);
1033 m_buttonSelectTool->setChecked(true);
1035 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1036 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1037 toolbar->addAction(m_buttonRazorTool);
1038 m_buttonRazorTool->setCheckable(true);
1039 m_buttonRazorTool->setChecked(false);
1041 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1042 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1043 toolbar->addAction(m_buttonSpacerTool);
1044 m_buttonSpacerTool->setCheckable(true);
1045 m_buttonSpacerTool->setChecked(false);
1047 QActionGroup *toolGroup = new QActionGroup(this);
1048 toolGroup->addAction(m_buttonSelectTool);
1049 toolGroup->addAction(m_buttonRazorTool);
1050 toolGroup->addAction(m_buttonSpacerTool);
1051 toolGroup->setExclusive(true);
1052 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1054 QWidget * actionWidget;
1055 int max = toolbar->iconSizeDefault() + 2;
1056 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1057 actionWidget->setMaximumWidth(max);
1058 actionWidget->setMaximumHeight(max - 4);
1060 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1061 actionWidget->setMaximumWidth(max);
1062 actionWidget->setMaximumHeight(max - 4);
1064 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1065 actionWidget->setMaximumWidth(max);
1066 actionWidget->setMaximumHeight(max - 4);
1068 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1069 actionWidget->setMaximumWidth(max);
1070 actionWidget->setMaximumHeight(max - 4);
1072 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1073 actionWidget->setMaximumWidth(max);
1074 actionWidget->setMaximumHeight(max - 4);
1076 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1077 actionWidget->setMaximumWidth(max);
1078 actionWidget->setMaximumHeight(max - 4);
1080 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1082 toolbar->addSeparator();
1083 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1084 toolbar->addAction(m_buttonFitZoom);
1085 m_buttonFitZoom->setCheckable(false);
1087 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1088 toolbar->addAction(m_zoomOut);
1089 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1091 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1092 m_zoomSlider->setMaximum(13);
1093 m_zoomSlider->setPageStep(1);
1094 m_zoomSlider->setInvertedAppearance(true);
1096 m_zoomSlider->setMaximumWidth(150);
1097 m_zoomSlider->setMinimumWidth(100);
1098 toolbar->addWidget(m_zoomSlider);
1100 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1101 toolbar->addAction(m_zoomIn);
1102 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1104 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1105 actionWidget->setMaximumWidth(max);
1106 actionWidget->setMaximumHeight(max - 4);
1107 actionWidget->setStyleSheet(styleBorderless);
1109 actionWidget = toolbar->widgetForAction(m_zoomIn);
1110 actionWidget->setMaximumWidth(max);
1111 actionWidget->setMaximumHeight(max - 4);
1112 actionWidget->setStyleSheet(styleBorderless);
1114 actionWidget = toolbar->widgetForAction(m_zoomOut);
1115 actionWidget->setMaximumWidth(max);
1116 actionWidget->setMaximumHeight(max - 4);
1117 actionWidget->setStyleSheet(styleBorderless);
1119 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1120 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1121 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1122 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1123 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1125 toolbar->addSeparator();
1127 //create automatic audio split button
1128 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1129 toolbar->addAction(m_buttonAutomaticSplitAudio);
1130 m_buttonAutomaticSplitAudio->setCheckable(true);
1131 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1132 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1134 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1135 toolbar->addAction(m_buttonVideoThumbs);
1136 m_buttonVideoThumbs->setCheckable(true);
1137 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1138 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1140 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1141 toolbar->addAction(m_buttonAudioThumbs);
1142 m_buttonAudioThumbs->setCheckable(true);
1143 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1144 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1146 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1147 toolbar->addAction(m_buttonShowMarkers);
1148 m_buttonShowMarkers->setCheckable(true);
1149 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1150 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1152 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1153 toolbar->addAction(m_buttonSnap);
1154 m_buttonSnap->setCheckable(true);
1155 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1156 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1158 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1159 actionWidget->setMaximumWidth(max);
1160 actionWidget->setMaximumHeight(max - 4);
1162 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1163 actionWidget->setMaximumWidth(max);
1164 actionWidget->setMaximumHeight(max - 4);
1166 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1167 actionWidget->setMaximumWidth(max);
1168 actionWidget->setMaximumHeight(max - 4);
1170 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1171 actionWidget->setMaximumWidth(max);
1172 actionWidget->setMaximumHeight(max - 4);
1174 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1175 actionWidget->setMaximumWidth(max);
1176 actionWidget->setMaximumHeight(max - 4);
1178 m_messageLabel = new StatusBarMessageLabel(this);
1179 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1181 statusBar()->addWidget(m_messageLabel, 10);
1182 statusBar()->addWidget(m_statusProgressBar, 0);
1183 statusBar()->addPermanentWidget(toolbar);
1184 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1185 statusBar()->addPermanentWidget(m_timecodeFormat);
1186 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1188 collection.addAction("normal_mode", m_normalEditTool);
1189 collection.addAction("overwrite_mode", m_overwriteEditTool);
1190 collection.addAction("insert_mode", m_insertEditTool);
1191 collection.addAction("select_tool", m_buttonSelectTool);
1192 collection.addAction("razor_tool", m_buttonRazorTool);
1193 collection.addAction("spacer_tool", m_buttonSpacerTool);
1195 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1196 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1197 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1198 collection.addAction("show_markers", m_buttonShowMarkers);
1199 collection.addAction("snap", m_buttonSnap);
1200 collection.addAction("zoom_fit", m_buttonFitZoom);
1201 collection.addAction("zoom_in", m_zoomIn);
1202 collection.addAction("zoom_out", m_zoomOut);
1204 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1205 collection.addAction("project_find", m_projectSearch);
1206 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1207 m_projectSearch->setShortcut(Qt::Key_Slash);
1209 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1210 collection.addAction("project_find_next", m_projectSearchNext);
1211 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1212 m_projectSearchNext->setShortcut(Qt::Key_F3);
1213 m_projectSearchNext->setEnabled(false);
1215 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1216 collection.addAction("manage_profiles", profilesAction);
1217 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1219 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1220 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1221 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1222 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1224 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1225 collection.addAction("run_wizard", wizAction);
1226 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1228 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1229 collection.addAction("project_settings", projectAction);
1230 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1232 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1233 collection.addAction("open_backup", backupAction);
1234 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1236 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1237 collection.addAction("project_render", projectRender);
1238 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1239 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1241 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1242 collection.addAction("project_clean", projectClean);
1243 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1245 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1246 collection.addAction("project_adjust_profile", projectAdjust);
1247 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1249 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1250 KShortcut playShortcut;
1251 playShortcut.setPrimary(Qt::Key_Space);
1252 playShortcut.setAlternate(Qt::Key_K);
1253 monitorPlay->setShortcut(playShortcut);
1254 collection.addAction("monitor_play", monitorPlay);
1255 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1257 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1258 collection.addAction("monitor_pause", monitorPause);
1259 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1261 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1262 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1263 collection.addAction("monitor_play_zone", m_playZone);
1264 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1266 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1267 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1268 collection.addAction("monitor_loop_zone", m_loopZone);
1269 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1271 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1272 m_loopClip->setEnabled(false);
1273 collection.addAction("monitor_loop_clip", m_loopClip);
1274 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1276 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1277 collection.addAction("dvd_wizard", dvdWizard);
1278 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1280 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1281 collection.addAction("transcode_clip", transcodeClip);
1282 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1284 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1285 collection.addAction("archive_project", archiveProject);
1286 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1289 KAction *markIn = collection.addAction("mark_in");
1290 markIn->setText(i18n("Set Zone In"));
1291 markIn->setShortcut(Qt::Key_I);
1292 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1294 KAction *markOut = collection.addAction("mark_out");
1295 markOut->setText(i18n("Set Zone Out"));
1296 markOut->setShortcut(Qt::Key_O);
1297 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1299 KAction *switchMon = collection.addAction("switch_monitor");
1300 switchMon->setText(i18n("Switch monitor"));
1301 switchMon->setShortcut(Qt::Key_T);
1302 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1304 KAction *fullMon = collection.addAction("monitor_fullscreen");
1305 fullMon->setText(i18n("Switch monitor fullscreen"));
1306 fullMon->setIcon(KIcon("view-fullscreen"));
1307 connect(fullMon, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotSwitchFullscreen()));
1309 KAction *insertTree = collection.addAction("insert_project_tree");
1310 insertTree->setText(i18n("Insert zone in project tree"));
1311 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1312 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1314 KAction *insertTimeline = collection.addAction("insert_timeline");
1315 insertTimeline->setText(i18n("Insert zone in timeline"));
1316 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1317 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1319 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1320 collection.addAction("resize_timeline_clip_start", resizeStart);
1321 resizeStart->setShortcut(Qt::Key_1);
1322 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1324 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1325 collection.addAction("resize_timeline_clip_end", resizeEnd);
1326 resizeEnd->setShortcut(Qt::Key_2);
1327 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1329 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1330 monitorSeekBackward->setShortcut(Qt::Key_J);
1331 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1332 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1334 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1335 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1336 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1337 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1339 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1340 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1341 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1342 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1344 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1345 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1346 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1347 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1349 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1350 monitorSeekForward->setShortcut(Qt::Key_L);
1351 collection.addAction("monitor_seek_forward", monitorSeekForward);
1352 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1354 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1355 clipStart->setShortcut(Qt::Key_Home);
1356 collection.addAction("seek_clip_start", clipStart);
1357 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1359 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1360 clipEnd->setShortcut(Qt::Key_End);
1361 collection.addAction("seek_clip_end", clipEnd);
1362 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1364 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1365 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1366 collection.addAction("seek_zone_start", zoneStart);
1367 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1369 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1370 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1371 collection.addAction("seek_zone_end", zoneEnd);
1372 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1374 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1375 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1376 collection.addAction("seek_start", projectStart);
1377 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1379 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1380 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1381 collection.addAction("seek_end", projectEnd);
1382 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1384 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1385 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1386 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1387 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1389 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1390 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1391 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1392 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1394 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1395 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1396 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1397 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1399 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1400 deleteItem->setShortcut(Qt::Key_Delete);
1401 collection.addAction("delete_timeline_clip", deleteItem);
1402 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1404 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1405 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1406 editTimelineClipSpeed->setData("change_speed");
1407 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1409 KAction *stickTransition = collection.addAction("auto_transition");
1410 stickTransition->setData(QString("auto"));
1411 stickTransition->setCheckable(true);
1412 stickTransition->setEnabled(false);
1413 stickTransition->setText(i18n("Automatic Transition"));
1414 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1416 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1417 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1418 collection.addAction("group_clip", groupClip);
1419 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1421 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1422 collection.addAction("ungroup_clip", ungroupClip);
1423 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1424 ungroupClip->setData("ungroup_clip");
1425 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1427 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1428 collection.addAction("edit_item_duration", editItemDuration);
1429 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1431 KAction* saveTimelineClip = new KAction(KIcon("document-save"), i18n("Save clip"), this);
1432 collection.addAction("save_timeline_clip", saveTimelineClip);
1433 connect(saveTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSaveTimelineClip()));
1435 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1436 collection.addAction("clip_in_project_tree", clipInProjectTree);
1437 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1439 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1440 collection.addAction("clip_to_project_tree", clipToProjectTree);
1441 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1443 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1444 insertOvertwrite->setShortcut(Qt::Key_V);
1445 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1446 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1448 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1449 selectTimelineClip->setShortcut(Qt::Key_Plus);
1450 collection.addAction("select_timeline_clip", selectTimelineClip);
1451 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1453 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1454 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1455 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1456 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1458 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1459 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1460 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1461 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1463 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1464 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1465 collection.addAction("select_timeline_transition", selectTimelineTransition);
1466 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1468 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1469 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1470 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1471 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1473 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1474 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1475 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1476 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1478 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1479 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1480 collection.addAction("cut_timeline_clip", cutTimelineClip);
1481 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1483 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1484 collection.addAction("add_clip_marker", addClipMarker);
1485 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1487 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1488 collection.addAction("delete_clip_marker", deleteClipMarker);
1489 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1491 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1492 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1493 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1495 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1496 editClipMarker->setData(QString("edit_marker"));
1497 collection.addAction("edit_clip_marker", editClipMarker);
1498 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1500 KAction* addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1501 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1502 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1503 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1505 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1506 collection.addAction("split_audio", splitAudio);
1507 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1509 KAction* setAudioAlignReference = new KAction(i18n("Set Audio Reference"), this);
1510 collection.addAction("set_audio_align_ref", setAudioAlignReference);
1511 connect(setAudioAlignReference, SIGNAL(triggered()), this, SLOT(slotSetAudioAlignReference()));
1513 KAction* alignAudio = new KAction(i18n("Align Audio to Reference"), this);
1514 collection.addAction("align_audio", alignAudio);
1515 connect(alignAudio, SIGNAL(triggered()), this, SLOT(slotAlignAudio()));
1517 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1518 collection.addAction("clip_audio_only", audioOnly);
1519 audioOnly->setData("clip_audio_only");
1520 audioOnly->setCheckable(true);
1522 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1523 collection.addAction("clip_video_only", videoOnly);
1524 videoOnly->setData("clip_video_only");
1525 videoOnly->setCheckable(true);
1527 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1528 collection.addAction("clip_audio_and_video", audioAndVideo);
1529 audioAndVideo->setData("clip_audio_and_video");
1530 audioAndVideo->setCheckable(true);
1532 m_clipTypeGroup = new QActionGroup(this);
1533 m_clipTypeGroup->addAction(audioOnly);
1534 m_clipTypeGroup->addAction(videoOnly);
1535 m_clipTypeGroup->addAction(audioAndVideo);
1536 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1537 m_clipTypeGroup->setEnabled(false);
1539 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1540 collection.addAction("insert_space", insertSpace);
1541 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1543 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1544 collection.addAction("delete_space", removeSpace);
1545 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1547 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1548 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1550 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1551 m_tracksActionCollection->addAction("insert_track", insertTrack);
1552 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1554 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1555 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1556 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1558 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1559 m_tracksActionCollection->addAction("config_tracks", configTracks);
1560 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1562 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1563 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1564 m_tracksActionCollection->addAction("select_track", selectTrack);
1566 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1567 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1568 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1570 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1571 collection.addAction("add_guide", addGuide);
1572 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1574 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1575 collection.addAction("delete_guide", delGuide);
1576 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1578 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1579 collection.addAction("edit_guide", editGuide);
1580 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1582 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1583 collection.addAction("delete_all_guides", delAllGuides);
1584 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1586 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1587 collection.addAction("paste_effects", pasteEffects);
1588 pasteEffects->setData("paste_effects");
1589 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1591 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1592 collection.addAction("show_titlebars", showTitleBar);
1593 showTitleBar->setCheckable(true);
1594 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1595 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1596 slotShowTitleBars(KdenliveSettings::showtitlebars());
1598 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1599 KStandardAction::quit(this, SLOT(close()), collection);
1600 KStandardAction::open(this, SLOT(openFile()), collection);
1601 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1602 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1603 KStandardAction::openNew(this, SLOT(newFile()), collection);
1604 // TODO: make the following connection to slotEditKeys work
1605 //KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1606 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1607 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1608 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1609 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1610 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1612 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1613 undo->setEnabled(false);
1614 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1616 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1617 redo->setEnabled(false);
1618 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1621 //TODO: Add status tooltip to actions ?
1622 connect(collection, SIGNAL(actionHovered(QAction*)),
1623 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1626 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1627 collection.addAction("add_clip", addClip);
1628 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1630 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1631 collection.addAction("add_color_clip", addColorClip);
1632 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1634 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1635 collection.addAction("add_slide_clip", addSlideClip);
1636 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1638 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1639 collection.addAction("add_text_clip", addTitleClip);
1640 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1642 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1643 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1644 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1646 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1647 collection.addAction("add_folder", addFolderButton);
1648 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1650 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1651 collection.addAction("download_resource", downloadResources);
1652 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1654 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1655 collection.addAction("clip_properties", clipProperties);
1656 clipProperties->setData("clip_properties");
1657 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1658 clipProperties->setEnabled(false);
1660 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1661 collection.addAction("edit_clip", openClip);
1662 openClip->setData("edit_clip");
1663 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1664 openClip->setEnabled(false);
1666 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1667 collection.addAction("delete_clip", deleteClip);
1668 deleteClip->setData("delete_clip");
1669 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1670 deleteClip->setEnabled(false);
1672 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1673 collection.addAction("reload_clip", reloadClip);
1674 reloadClip->setData("reload_clip");
1675 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1676 reloadClip->setEnabled(false);
1678 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1679 collection.addAction("proxy_clip", proxyClip);
1680 proxyClip->setData("proxy_clip");
1681 proxyClip->setCheckable(true);
1682 proxyClip->setChecked(false);
1683 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1685 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1686 collection.addAction("stopmotion", stopMotion);
1687 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1689 QMenu *addClips = new QMenu();
1690 addClips->addAction(addClip);
1691 addClips->addAction(addColorClip);
1692 addClips->addAction(addSlideClip);
1693 addClips->addAction(addTitleClip);
1694 addClips->addAction(addTitleTemplateClip);
1695 addClips->addAction(addFolderButton);
1696 addClips->addAction(downloadResources);
1698 addClips->addAction(reloadClip);
1699 addClips->addAction(proxyClip);
1700 addClips->addAction(clipProperties);
1701 addClips->addAction(openClip);
1702 addClips->addAction(deleteClip);
1703 m_projectList->setupMenu(addClips, addClip);
1705 // Setup effects and transitions actions.
1706 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1707 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1708 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1709 m_transitions = new KAction*[transitions.count()];
1710 for (int i = 0; i < transitions.count(); i++) {
1711 QStringList effectInfo = transitions.effectIdInfo(i);
1712 m_transitions[i] = new KAction(effectInfo.at(0), this);
1713 m_transitions[i]->setData(effectInfo);
1714 m_transitions[i]->setIconVisibleInMenu(false);
1715 QString id = effectInfo.at(2);
1716 if (id.isEmpty()) id = effectInfo.at(1);
1717 transitionActions->addAction("transition_" + id, m_transitions[i]);
1719 //m_effectsActionCollection->readSettings();
1723 void MainWindow::slotDisplayActionMessage(QAction *a)
1725 statusBar()->showMessage(a->data().toString(), 3000);
1728 void MainWindow::setStatusBarStyleSheet(const QPalette &p)
1730 KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
1731 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
1732 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
1733 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
1734 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
1735 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: %3;border-style: inset; border:1px solid %3;border-radius: 3px;} QToolButton:checked { background-color: %1; border-style: inset; border:1px solid %2;border-radius: 3px;}").arg(buttonBg.name()).arg(buttonBord.name()).arg(buttonBord2.name());
1736 statusBar()->setStyleSheet(style1);
1739 void MainWindow::loadLayouts()
1741 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1742 if (m_loadLayout == NULL || saveLayout == NULL) return;
1743 KSharedConfigPtr config = KGlobal::config();
1744 KConfigGroup layoutGroup(config, "Layouts");
1745 QStringList entries = layoutGroup.keyList();
1746 QList<QAction *> loadActions = m_loadLayout->actions();
1747 QList<QAction *> saveActions = saveLayout->actions();
1748 for (int i = 1; i < 5; i++) {
1749 // Rename the layouts actions
1750 foreach(const QString & key, entries) {
1751 if (key.endsWith(QString("_%1").arg(i))) {
1752 // Found previously saved layout
1753 QString layoutName = key.section('_', 0, -2);
1754 for (int j = 0; j < loadActions.count(); j++) {
1755 if (loadActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
1756 loadActions[j]->setText(layoutName);
1757 loadActions[j]->setData(key);
1761 for (int j = 0; j < saveActions.count(); j++) {
1762 if (saveActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
1763 saveActions[j]->setText(i18n("Save as %1", layoutName));
1764 saveActions[j]->setData(key);
1773 void MainWindow::slotLoadLayout(QAction *action)
1775 if (!action) return;
1776 QString layoutId = action->data().toString();
1777 if (layoutId.isEmpty()) return;
1778 KSharedConfigPtr config = KGlobal::config();
1779 KConfigGroup layouts(config, "Layouts");
1780 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1781 restoreState(state);
1784 void MainWindow::slotSaveLayout(QAction *action)
1786 QString originallayoutName = action->data().toString();
1787 int layoutId = originallayoutName.section('_', -1).toInt();
1789 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1790 if (layoutName.isEmpty()) return;
1791 KSharedConfigPtr config = KGlobal::config();
1792 KConfigGroup layouts(config, "Layouts");
1793 layouts.deleteEntry(originallayoutName);
1795 QByteArray st = saveState();
1796 layoutName.append('_' + QString::number(layoutId));
1797 layouts.writeEntry(layoutName, st.toBase64());
1801 void MainWindow::saveOptions()
1803 KdenliveSettings::self()->writeConfig();
1804 KSharedConfigPtr config = KGlobal::config();
1805 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1806 KConfigGroup treecolumns(config, "Project Tree");
1807 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1811 void MainWindow::readOptions()
1813 KSharedConfigPtr config = KGlobal::config();
1814 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1815 KConfigGroup initialGroup(config, "version");
1816 bool upgrade = false;
1817 if (initialGroup.exists()) {
1818 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1822 if (initialGroup.readEntry("version") == "0.7") {
1823 //Add new settings from 0.7.1
1824 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1825 QString path = QDir::homePath() + "/kdenlive";
1826 if (KStandardDirs::makeDir(path) == false) {
1827 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1828 } else KdenliveSettings::setDefaultprojectfolder(path);
1833 if (KdenliveSettings::ffmpegpath().isEmpty() || KdenliveSettings::ffplaypath().isEmpty()) upgrade = true;
1834 if (!initialGroup.exists() || upgrade) {
1835 // this is our first run, show Wizard
1836 QPointer<Wizard> w = new Wizard(upgrade, this);
1837 if (w->exec() == QDialog::Accepted && w->isOk()) {
1838 w->adjustSettings();
1839 initialGroup.writeEntry("version", version);
1846 KConfigGroup treecolumns(config, "Project Tree");
1847 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1848 if (!state.isEmpty())
1849 m_projectList->setHeaderInfo(state);
1852 void MainWindow::slotRunWizard()
1854 QPointer<Wizard> w = new Wizard(false, this);
1855 if (w->exec() == QDialog::Accepted && w->isOk()) {
1856 w->adjustSettings();
1861 void MainWindow::newFile(bool showProjectSettings, bool force)
1863 if (!m_timelineArea->isEnabled() && !force)
1865 m_fileRevert->setEnabled(false);
1866 QString profileName = KdenliveSettings::default_profile();
1867 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1868 QMap <QString, QString> documentProperties;
1869 QMap <QString, QString> documentMetadata;
1870 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1871 if (!showProjectSettings) {
1872 if (!KdenliveSettings::activatetabs())
1873 if (!closeCurrentDocument())
1876 QPointer<ProjectSettings> w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1877 if (w->exec() != QDialog::Accepted) {
1881 if (!KdenliveSettings::activatetabs())
1882 if (!closeCurrentDocument()) {
1886 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1887 slotSwitchVideoThumbs();
1888 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1889 slotSwitchAudioThumbs();
1890 profileName = w->selectedProfile();
1891 projectFolder = w->selectedFolder();
1892 projectTracks = w->tracks();
1893 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1894 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1895 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1896 documentProperties.insert("proxyparams", w->proxyParams());
1897 documentProperties.insert("proxyextension", w->proxyExtension());
1898 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1899 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1900 documentMetadata = w->metadata();
1903 m_timelineArea->setEnabled(true);
1904 m_projectList->setEnabled(true);
1906 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1907 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1909 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
1910 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1913 //m_timelineArea->setEnabled(false);
1914 //m_projectList->setEnabled(false);
1918 if (m_timelineArea->count() == 1) {
1919 connectDocumentInfo(doc);
1920 connectDocument(trackView, doc);
1922 m_timelineArea->setTabBarHidden(false);
1923 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
1924 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1927 void MainWindow::activateDocument()
1929 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1930 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1931 KdenliveDoc *currentDoc = currentTab->document();
1932 connectDocumentInfo(currentDoc);
1933 connectDocument(currentTab, currentDoc);
1936 bool MainWindow::closeCurrentDocument(bool saveChanges)
1938 QWidget *w = m_timelineArea->currentWidget();
1939 if (!w) return true;
1940 // closing current document
1941 int ix = m_timelineArea->currentIndex() + 1;
1942 if (ix == m_timelineArea->count()) ix = 0;
1943 m_timelineArea->setCurrentIndex(ix);
1944 TrackView *tabToClose = (TrackView *) w;
1945 KdenliveDoc *docToClose = tabToClose->document();
1946 if (docToClose && docToClose->isModified() && saveChanges) {
1948 if (m_activeDocument->url().fileName().isEmpty())
1949 message = i18n("Save changes to document?");
1951 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?", m_activeDocument->url().fileName());
1952 switch (KMessageBox::warningYesNoCancel(this, message)) {
1953 case KMessageBox::Yes :
1954 // save document here. If saving fails, return false;
1955 if (saveFile() == false) return false;
1957 case KMessageBox::Cancel :
1964 m_clipMonitor->slotSetClipProducer(NULL);
1965 m_projectList->slotResetProjectList();
1966 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1967 if (m_timelineArea->count() == 1) {
1968 m_timelineArea->setTabBarHidden(true);
1969 m_closeAction->setEnabled(false);
1971 if (docToClose == m_activeDocument) {
1972 delete m_activeDocument;
1973 m_activeDocument = NULL;
1974 m_effectStack->clear();
1975 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1979 if (w == m_activeTimeline) {
1980 delete m_activeTimeline;
1981 m_activeTimeline = NULL;
1988 bool MainWindow::saveFileAs(const QString &outputFileName)
1990 QString currentSceneList;
1991 m_monitorManager->stopActiveMonitor();
1993 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1996 // Save timeline thumbnails
1997 m_activeTimeline->projectView()->saveThumbnails();
1998 m_activeDocument->setUrl(KUrl(outputFileName));
1999 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
2000 if (m_activeDocument->m_autosave == NULL) {
2001 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
2002 } else m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
2003 setCaption(m_activeDocument->description());
2004 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2005 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
2006 m_activeDocument->setModified(false);
2007 m_fileOpenRecent->addUrl(KUrl(outputFileName));
2008 m_fileRevert->setEnabled(true);
2009 m_undoView->stack()->setClean();
2013 bool MainWindow::saveFileAs()
2015 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
2016 if (outputFile.isEmpty()) {
2019 if (QFile::exists(outputFile)) {
2020 // Show the file dialog again if the user does not want to overwrite the file
2021 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
2022 return saveFileAs();
2024 return saveFileAs(outputFile);
2027 bool MainWindow::saveFile()
2029 if (!m_activeDocument) return true;
2030 if (m_activeDocument->url().isEmpty()) {
2031 return saveFileAs();
2033 bool result = saveFileAs(m_activeDocument->url().path());
2034 m_activeDocument->m_autosave->resize(0);
2039 void MainWindow::openFile()
2041 if (!m_startUrl.isEmpty()) {
2042 openFile(m_startUrl);
2043 m_startUrl = KUrl();
2046 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2047 if (url.isEmpty()) return;
2048 m_fileOpenRecent->addUrl(url);
2052 void MainWindow::openLastFile()
2054 KSharedConfigPtr config = KGlobal::config();
2055 KUrl::List urls = m_fileOpenRecent->urls();
2056 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2057 if (urls.isEmpty()) newFile(false);
2058 else openFile(urls.last());
2061 void MainWindow::openFile(const KUrl &url)
2063 // Make sure the url is a Kdenlive project file
2064 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2065 if (mime.data()->is("application/x-compressed-tar")) {
2066 // Opening a compressed project file, we need to process it
2067 kDebug()<<"Opening archive, processing";
2068 QPointer<ArchiveWidget> ar = new ArchiveWidget(url);
2069 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2073 if (!url.fileName().endsWith(".kdenlive")) {
2074 // This is not a Kdenlive project file, abort loading
2075 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2079 // Check if the document is already opened
2080 const int ct = m_timelineArea->count();
2081 bool isOpened = false;
2083 for (i = 0; i < ct; i++) {
2084 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2085 KdenliveDoc *doc = tab->document();
2086 if (doc->url() == url) {
2092 m_timelineArea->setCurrentIndex(i);
2096 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2098 // Check for backup file
2099 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2100 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2101 if (!staleFiles.isEmpty()) {
2102 if (KMessageBox::questionYesNo(this,
2103 i18n("Auto-saved files exist. Do you want to recover them now?"),
2104 i18n("File Recovery"),
2105 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2106 recoverFiles(staleFiles, url);
2109 // remove the stale files
2110 foreach(KAutoSaveFile * stale, staleFiles) {
2111 stale->open(QIODevice::ReadWrite);
2116 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2117 m_messageLabel->repaint();
2118 doOpenFile(url, NULL);
2121 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2123 if (!m_timelineArea->isEnabled()) return;
2124 m_fileRevert->setEnabled(true);
2126 // Recreate stopmotion widget on document change
2128 delete m_stopmotion;
2129 m_stopmotion = NULL;
2133 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2134 progressDialog.setAllowCancel(false);
2135 progressDialog.progressBar()->setMaximum(4);
2136 progressDialog.show();
2137 progressDialog.progressBar()->setValue(0);
2138 qApp->processEvents();
2141 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);
2143 progressDialog.progressBar()->setValue(1);
2144 progressDialog.progressBar()->setMaximum(4);
2145 progressDialog.setLabelText(i18n("Loading project"));
2146 qApp->processEvents();
2148 if (stale == NULL) {
2149 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2150 stale = new KAutoSaveFile(KUrl(hash), doc);
2151 doc->m_autosave = stale;
2153 doc->m_autosave = stale;
2154 doc->setUrl(url);//stale->managedFile());
2155 doc->setModified(true);
2156 stale->setParent(doc);
2158 connectDocumentInfo(doc);
2160 progressDialog.progressBar()->setValue(2);
2161 qApp->processEvents();
2164 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2165 connectDocument(trackView, doc);
2166 progressDialog.progressBar()->setValue(3);
2167 qApp->processEvents();
2169 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2171 m_timelineArea->setEnabled(false);
2172 m_projectList->setEnabled(false);
2173 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2174 slotGotProgressInfo(QString(), -1);
2175 newFile(false, true);
2178 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2179 trackView->setDuration(trackView->duration());
2180 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2182 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2183 slotGotProgressInfo(QString(), -1);
2184 m_projectMonitor->adjustRulerSize(trackView->duration());
2185 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2186 progressDialog.progressBar()->setValue(4);
2187 if (openBackup) slotOpenBackupDialog(url);
2190 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl)
2192 foreach(KAutoSaveFile * stale, staleFiles) {
2193 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2194 // show an error message; we could not steal the lockfile
2195 // maybe another application got to the file before us?
2199 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2200 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2201 if (!stale->fileName().endsWith(".lock")) doOpenFile(originUrl, stale);
2202 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2206 void MainWindow::parseProfiles(const QString &mltPath)
2208 //KdenliveSettings::setDefaulttmpfolder();
2209 if (!mltPath.isEmpty()) {
2210 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2211 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2214 if (KdenliveSettings::mltpath().isEmpty())
2215 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2217 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2218 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2219 if (!QFile::exists(meltPath))
2220 meltPath = KStandardDirs::findExe("melt");
2221 KdenliveSettings::setRendererpath(meltPath);
2224 if (KdenliveSettings::rendererpath().isEmpty()) {
2225 // Cannot find the MLT melt renderer, ask for location
2226 QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2227 if (getUrl->exec() == QDialog::Rejected) {
2231 KUrl rendererPath = getUrl->selectedUrl();
2233 if (rendererPath.isEmpty()) ::exit(0);
2234 KdenliveSettings::setRendererpath(rendererPath.path());
2237 QStringList profilesFilter;
2238 profilesFilter << "*";
2239 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2240 if (profilesList.isEmpty()) {
2241 // Cannot find MLT path, try finding melt
2242 QString profilePath = KdenliveSettings::rendererpath();
2243 if (!profilePath.isEmpty()) {
2244 profilePath = profilePath.section('/', 0, -3);
2245 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2246 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2248 if (profilesList.isEmpty()) {
2249 // Cannot find the MLT profiles, ask for location
2250 QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2251 getUrl->fileDialog()->setMode(KFile::Directory);
2252 if (getUrl->exec() == QDialog::Rejected) {
2256 KUrl mltPath = getUrl->selectedUrl();
2258 if (mltPath.isEmpty()) ::exit(0);
2259 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2260 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2264 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2266 // Parse again MLT profiles to build a list of available video formats
2267 if (profilesList.isEmpty()) parseProfiles();
2271 void MainWindow::slotEditProfiles()
2273 ProfilesDialog *w = new ProfilesDialog;
2274 if (w->exec() == QDialog::Accepted) {
2275 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2276 if (d) d->checkProfile();
2281 void MainWindow::slotDetectAudioDriver()
2283 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2284 leading to no audio output, see bug #934 */
2286 //decide which audio driver is really best, in some cases SDL is wrong
2287 if (KdenliveSettings::audiodrivername().isEmpty()) {
2289 KProcess readProcess;
2290 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2291 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2292 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2293 readProcess.setProgram("pactl", QStringList() << "stat");
2294 readProcess.execute(2000); // Kill it after 2 seconds
2296 QString result = QString(readProcess.readAllStandardOutput());
2297 kDebug() << "// / / / / / READING PACTL: ";
2299 if (!result.isEmpty()) {
2301 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2305 KdenliveSettings::setAutoaudiodrivername(driver);
2309 void MainWindow::slotEditProjectSettings()
2311 QPoint p = m_activeDocument->getTracksCount();
2312 QPointer<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);
2313 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2315 if (w->exec() == QDialog::Accepted) {
2316 QString profile = w->selectedProfile();
2317 m_activeDocument->setProjectFolder(w->selectedFolder());
2319 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2321 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2322 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2323 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2324 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2325 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2326 m_activeDocument->setModified();
2327 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2328 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) {
2329 //TODO: rebuild all proxies
2330 //m_projectList->rebuildProxies();
2333 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2334 m_activeDocument->setModified();
2335 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2337 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2338 m_activeDocument->setModified();
2339 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2341 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2342 m_activeDocument->setModified();
2343 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2345 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2346 m_activeDocument->setModified();
2347 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2349 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2350 m_activeDocument->setModified();
2351 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2353 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2354 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2355 m_activeDocument->setModified();
2356 slotUpdateProxySettings();
2358 m_activeDocument->setMetadata(w->metadata());
2363 void MainWindow::slotDisableProxies()
2365 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2366 m_activeDocument->setModified();
2367 slotUpdateProxySettings();
2370 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2372 // Recreate the stopmotion widget if profile changes
2374 delete m_stopmotion;
2375 m_stopmotion = NULL;
2378 // Deselect current effect / transition
2379 m_effectStack->slotClipItemSelected(NULL);
2380 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2381 m_clipMonitor->slotSetClipProducer(NULL);
2382 bool updateFps = m_activeDocument->setProfilePath(profile);
2383 KdenliveSettings::setCurrent_profile(profile);
2384 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2385 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2387 m_activeDocument->clipManager()->clearUnusedProducers();
2388 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2389 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2390 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2391 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2392 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2393 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2394 if (updateFps) m_activeTimeline->updateProjectFps();
2395 m_activeDocument->clipManager()->clearCache();
2396 m_activeTimeline->updateProfile();
2397 m_activeDocument->setModified(true);
2398 m_commandStack->activeStack()->clear();
2399 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2400 slotUpdateMousePosition(0);
2401 // We need to desactivate & reactivate monitors to get a refresh
2402 //m_monitorManager->switchMonitors();
2406 void MainWindow::slotRenderProject()
2408 if (!m_renderWidget) {
2409 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2410 MltVideoProfile profile;
2411 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2412 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2413 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2414 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2415 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2416 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2417 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2418 if (m_activeDocument) {
2419 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2420 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2421 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2422 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2425 slotCheckRenderStatus();
2426 m_renderWidget->show();
2427 m_renderWidget->showNormal();
2429 // What are the following lines supposed to do?
2430 //m_activeTimeline->tracksNumber();
2431 //m_renderWidget->enableAudio(false);
2432 //m_renderWidget->export_audio;
2435 void MainWindow::slotCheckRenderStatus()
2437 // Make sure there are no missing clips
2439 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2442 void MainWindow::setRenderingProgress(const QString &url, int progress)
2445 m_renderWidget->setRenderJob(url, progress);
2448 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2451 m_renderWidget->setRenderStatus(url, status, error);
2454 void MainWindow::slotCleanProject()
2456 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2457 m_projectList->cleanup();
2460 void MainWindow::slotUpdateMousePosition(int pos)
2462 if (m_activeDocument)
2463 switch (m_timecodeFormat->currentIndex()) {
2465 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2468 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2472 void MainWindow::slotUpdateDocumentState(bool modified)
2474 if (!m_activeDocument) return;
2475 setCaption(m_activeDocument->description(), modified);
2476 m_saveAction->setEnabled(modified);
2478 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2479 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2481 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2482 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2486 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2488 if (m_activeDocument) {
2489 if (m_activeDocument == doc) return;
2490 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2492 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2495 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2497 //m_projectMonitor->stop();
2498 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2499 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2500 if (m_activeDocument) {
2501 if (m_activeDocument == doc) return;
2502 if (m_activeTimeline) {
2503 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2504 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2505 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2506 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2507 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2508 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2509 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2511 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2513 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2514 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2515 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2516 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2517 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2518 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2519 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
2520 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2521 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2522 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2523 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2524 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2525 disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2527 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
2528 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2529 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2530 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2531 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2532 disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2533 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, QList <int>, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, QList <int>, bool)));
2534 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, QList<int>, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, QList <int>, int)));
2535 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2536 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2537 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2538 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2539 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2540 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2541 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2542 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2543 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2544 m_effectStack->clear();
2546 //m_activeDocument->setRenderer(NULL);
2547 m_clipMonitor->stop();
2549 KdenliveSettings::setCurrent_profile(doc->profilePath());
2550 KdenliveSettings::setProject_fps(doc->fps());
2551 m_monitorManager->resetProfiles(doc->timecode());
2552 m_clipMonitorDock->raise();
2553 m_projectList->setDocument(doc);
2554 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2555 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2556 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2558 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2559 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2561 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2562 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2563 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2564 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2565 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2566 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2567 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2568 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2569 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2570 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2572 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2573 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2574 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2575 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2576 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2578 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2579 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2580 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2582 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2584 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2585 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotTrackSelected(int, TrackInfo)));
2587 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
2588 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2589 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2590 m_zoomSlider->setValue(doc->zoom().x());
2591 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2592 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2593 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2594 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2596 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2597 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2599 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2601 connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2603 // Effect stack signals
2604 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2605 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2606 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2607 connect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2608 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, QList <int>, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, QList <int>, bool)));
2609 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, QList <int>, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, QList <int>, int)));
2610 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2611 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(seekCursorPos(int)));
2612 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2613 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2615 // Transition config signals
2616 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2617 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(seekCursorPos(int)));
2619 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2620 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2621 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2622 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2623 m_activeTimeline = trackView;
2624 if (m_renderWidget) {
2625 slotCheckRenderStatus();
2626 m_renderWidget->setProfile(doc->mltProfile());
2627 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2628 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2629 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2631 //doc->setRenderer(m_projectMonitor->render);
2632 m_commandStack->setActiveStack(doc->commandStack());
2633 KdenliveSettings::setProject_display_ratio(doc->dar());
2634 //doc->clipManager()->checkAudioThumbs();
2636 //m_overView->setScene(trackView->projectScene());
2637 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2638 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2640 setCaption(doc->description(), doc->isModified());
2641 m_saveAction->setEnabled(doc->isModified());
2642 m_normalEditTool->setChecked(true);
2643 m_activeDocument = doc;
2644 m_activeTimeline->updateProjectFps();
2645 m_activeDocument->checkProjectClips();
2647 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2649 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2650 slotUpdateMousePosition(0);
2651 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
2652 // set tool to select tool
2653 m_buttonSelectTool->setChecked(true);
2656 void MainWindow::slotZoneMoved(int start, int end)
2658 m_activeDocument->setZone(start, end);
2659 m_projectMonitor->slotZoneMoved(start, end);
2662 void MainWindow::slotGuidesUpdated()
2665 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2668 void MainWindow::slotEditKeys()
2670 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2671 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2672 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2673 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2677 void MainWindow::slotPreferences(int page, int option)
2680 * An instance of your dialog could be already created and could be
2681 * cached, in which case you want to display the cached dialog
2682 * instead of creating another one
2684 if (m_stopmotion) m_stopmotion->slotLive(false);
2685 if (KConfigDialog::showDialog("settings")) {
2686 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2687 if (page != -1) d->showPage(page, option);
2691 // KConfigDialog didn't find an instance of this dialog, so lets
2694 // Get the mappable actions in localized form
2695 QMap<QString, QString> actions;
2696 KActionCollection* collection = actionCollection();
2697 foreach (const QString& action_name, m_action_names) {
2698 actions[collection->action(action_name)->text()] = action_name;
2701 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2702 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2703 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2705 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2708 if (page != -1) dialog->showPage(page, option);
2711 void MainWindow::slotUpdateCaptureFolder()
2715 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2716 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2720 void MainWindow::updateConfiguration()
2722 //TODO: we should apply settings to all projects, not only the current one
2723 if (m_activeTimeline) {
2724 m_activeTimeline->refresh();
2725 m_activeTimeline->projectView()->checkAutoScroll();
2726 m_activeTimeline->checkTrackHeight();
2727 if (m_activeDocument)
2728 m_activeDocument->clipManager()->checkAudioThumbs();
2730 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2731 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2732 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2733 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2735 // Update list of transcoding profiles
2738 #ifdef USE_JOGSHUTTLE
2739 activateShuttleDevice();
2744 void MainWindow::slotSwitchSplitAudio()
2746 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2747 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2750 void MainWindow::slotSwitchVideoThumbs()
2752 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2753 if (m_activeTimeline)
2754 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2755 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2758 void MainWindow::slotSwitchAudioThumbs()
2760 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2761 if (m_activeTimeline) {
2762 m_activeTimeline->refresh();
2763 m_activeTimeline->projectView()->checkAutoScroll();
2764 if (m_activeDocument)
2765 m_activeDocument->clipManager()->checkAudioThumbs();
2767 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2770 void MainWindow::slotSwitchMarkersComments()
2772 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2773 if (m_activeTimeline)
2774 m_activeTimeline->refresh();
2775 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2778 void MainWindow::slotSwitchSnap()
2780 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2781 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2785 void MainWindow::slotDeleteItem()
2787 if (QApplication::focusWidget() &&
2788 QApplication::focusWidget()->parentWidget() &&
2789 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2790 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2791 m_projectList->slotRemoveClip();
2794 QWidget *widget = QApplication::focusWidget();
2796 if (widget == m_effectStackDock) {
2797 m_effectStack->deleteCurrentEffect();
2800 widget = widget->parentWidget();
2803 // effect stack has no focus
2804 if (m_activeTimeline)
2805 m_activeTimeline->projectView()->deleteSelectedClips();
2809 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2811 if (m_clipMonitor->isActive())
2812 m_clipMonitor->checkOverlay();
2813 m_clipMonitor->updateMarkers(clip);
2816 void MainWindow::slotAddClipMarker()
2818 DocClipBase *clip = NULL;
2820 if (m_projectMonitor->isActive()) {
2821 if (m_activeTimeline) {
2822 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2824 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2825 clip = item->baseClip();
2829 clip = m_clipMonitor->activeClip();
2830 pos = m_clipMonitor->position();
2833 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2836 QString id = clip->getId();
2837 CommentedTime marker(pos, i18n("Marker"));
2838 QPointer<MarkerDialog> d = new MarkerDialog(clip, marker,
2839 m_activeDocument->timecode(), i18n("Add Marker"), this);
2840 if (d->exec() == QDialog::Accepted)
2841 m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker().time(), d->newMarker().comment());
2845 void MainWindow::slotDeleteClipMarker()
2847 DocClipBase *clip = NULL;
2849 if (m_projectMonitor->isActive()) {
2850 if (m_activeTimeline) {
2851 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2853 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2854 clip = item->baseClip();
2858 clip = m_clipMonitor->activeClip();
2859 pos = m_clipMonitor->position();
2862 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2866 QString id = clip->getId();
2867 QString comment = clip->markerComment(pos);
2868 if (comment.isEmpty()) {
2869 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2872 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2875 void MainWindow::slotDeleteAllClipMarkers()
2877 DocClipBase *clip = NULL;
2878 if (m_projectMonitor->isActive()) {
2879 if (m_activeTimeline) {
2880 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2882 clip = item->baseClip();
2886 clip = m_clipMonitor->activeClip();
2889 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2892 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2895 void MainWindow::slotEditClipMarker()
2897 DocClipBase *clip = NULL;
2899 if (m_projectMonitor->isActive()) {
2900 if (m_activeTimeline) {
2901 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2903 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2904 clip = item->baseClip();
2908 clip = m_clipMonitor->activeClip();
2909 pos = m_clipMonitor->position();
2912 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2916 QString id = clip->getId();
2917 QString oldcomment = clip->markerComment(pos);
2918 if (oldcomment.isEmpty()) {
2919 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2923 CommentedTime marker(pos, oldcomment);
2924 QPointer<MarkerDialog> d = new MarkerDialog(clip, marker,
2925 m_activeDocument->timecode(), i18n("Edit Marker"), this);
2926 if (d->exec() == QDialog::Accepted) {
2927 m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker().time(), d->newMarker().comment());
2928 if (d->newMarker().time() != pos) {
2929 // remove old marker
2930 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2936 void MainWindow::slotAddMarkerGuideQuickly()
2938 if (!m_activeTimeline || !m_activeDocument)
2941 if (m_clipMonitor->isActive()) {
2942 DocClipBase *clip = m_clipMonitor->activeClip();
2943 GenTime pos = m_clipMonitor->position();
2946 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2950 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2952 m_activeTimeline->projectView()->slotAddGuide(false);
2956 void MainWindow::slotAddGuide()
2958 if (m_activeTimeline)
2959 m_activeTimeline->projectView()->slotAddGuide();
2962 void MainWindow::slotInsertSpace()
2964 if (m_activeTimeline)
2965 m_activeTimeline->projectView()->slotInsertSpace();
2968 void MainWindow::slotRemoveSpace()
2970 if (m_activeTimeline)
2971 m_activeTimeline->projectView()->slotRemoveSpace();
2974 void MainWindow::slotInsertTrack(int ix)
2976 m_projectMonitor->slotActivateMonitor();
2977 if (m_activeTimeline) {
2978 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2979 m_activeTimeline->projectView()->slotInsertTrack(ix);
2981 if (m_activeDocument)
2982 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2985 void MainWindow::slotDeleteTrack(int ix)
2987 m_projectMonitor->slotActivateMonitor();
2988 if (m_activeTimeline) {
2989 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2990 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2992 if (m_activeDocument)
2993 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2996 void MainWindow::slotConfigTrack(int ix)
2998 m_projectMonitor->slotActivateMonitor();
2999 if (m_activeTimeline)
3000 m_activeTimeline->projectView()->slotConfigTracks(ix);
3001 if (m_activeDocument)
3002 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3005 void MainWindow::slotSelectTrack()
3007 m_projectMonitor->slotActivateMonitor();
3008 if (m_activeTimeline) {
3009 m_activeTimeline->projectView()->slotSelectClipsInTrack();
3013 void MainWindow::slotSelectAllTracks()
3015 m_projectMonitor->slotActivateMonitor();
3016 if (m_activeTimeline)
3017 m_activeTimeline->projectView()->slotSelectAllClips();
3020 void MainWindow::slotEditGuide()
3022 if (m_activeTimeline)
3023 m_activeTimeline->projectView()->slotEditGuide();
3026 void MainWindow::slotDeleteGuide()
3028 if (m_activeTimeline)
3029 m_activeTimeline->projectView()->slotDeleteGuide();
3032 void MainWindow::slotDeleteAllGuides()
3034 if (m_activeTimeline)
3035 m_activeTimeline->projectView()->slotDeleteAllGuides();
3038 void MainWindow::slotCutTimelineClip()
3040 if (m_activeTimeline)
3041 m_activeTimeline->projectView()->cutSelectedClips();
3044 void MainWindow::slotInsertClipOverwrite()
3046 if (m_activeTimeline) {
3047 QStringList data = m_clipMonitor->getZoneInfo();
3048 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
3052 void MainWindow::slotSelectTimelineClip()
3054 if (m_activeTimeline)
3055 m_activeTimeline->projectView()->selectClip(true);
3058 void MainWindow::slotSelectTimelineTransition()
3060 if (m_activeTimeline)
3061 m_activeTimeline->projectView()->selectTransition(true);
3064 void MainWindow::slotDeselectTimelineClip()
3066 if (m_activeTimeline)
3067 m_activeTimeline->projectView()->selectClip(false, true);
3070 void MainWindow::slotDeselectTimelineTransition()
3072 if (m_activeTimeline)
3073 m_activeTimeline->projectView()->selectTransition(false, true);
3076 void MainWindow::slotSelectAddTimelineClip()
3078 if (m_activeTimeline)
3079 m_activeTimeline->projectView()->selectClip(true, true);
3082 void MainWindow::slotSelectAddTimelineTransition()
3084 if (m_activeTimeline)
3085 m_activeTimeline->projectView()->selectTransition(true, true);
3088 void MainWindow::slotGroupClips()
3090 if (m_activeTimeline)
3091 m_activeTimeline->projectView()->groupClips();
3094 void MainWindow::slotUnGroupClips()
3096 if (m_activeTimeline)
3097 m_activeTimeline->projectView()->groupClips(false);
3100 void MainWindow::slotEditItemDuration()
3102 if (m_activeTimeline)
3103 m_activeTimeline->projectView()->editItemDuration();
3106 void MainWindow::slotAddProjectClip(KUrl url, stringMap data)
3108 if (m_activeDocument) {
3109 m_activeDocument->slotAddClipFile(url, data);
3113 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3115 if (m_activeDocument)
3116 m_activeDocument->slotAddClipList(urls);
3119 void MainWindow::slotAddTransition(QAction *result)
3121 if (!result) return;
3122 QStringList info = result->data().toStringList();
3123 if (info.isEmpty()) return;
3124 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3125 if (m_activeTimeline && !transition.isNull()) {
3126 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3130 void MainWindow::slotAddVideoEffect(QAction *result)
3132 if (!result) return;
3133 const int EFFECT_VIDEO = 1;
3134 const int EFFECT_AUDIO = 2;
3135 QStringList info = result->data().toStringList();
3137 if (info.isEmpty() || info.size() < 3) return;
3138 QDomElement effect ;
3139 if (info.last() == QString::number((int) EFFECT_VIDEO))
3140 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3141 else if (info.last() == QString::number((int) EFFECT_AUDIO))
3142 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3144 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3145 if (!effect.isNull()) slotAddEffect(effect);
3146 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2", info.at(0), info.at(1)), ErrorMessage);
3150 void MainWindow::slotZoomIn()
3152 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3153 slotShowZoomSliderToolTip();
3156 void MainWindow::slotZoomOut()
3158 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3159 slotShowZoomSliderToolTip();
3162 void MainWindow::slotFitZoom()
3164 if (m_activeTimeline)
3165 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3168 void MainWindow::slotSetZoom(int value)
3170 value = qMax(m_zoomSlider->minimum(), value);
3171 value = qMin(m_zoomSlider->maximum(), value);
3173 if (m_activeTimeline)
3174 m_activeTimeline->slotChangeZoom(value);
3176 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3177 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3178 slotUpdateZoomSliderToolTip(value);
3180 m_zoomSlider->blockSignals(true);
3181 m_zoomSlider->setValue(value);
3182 m_zoomSlider->blockSignals(false);
3185 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3187 if (zoomlevel != -1)
3188 slotUpdateZoomSliderToolTip(zoomlevel);
3190 QPoint global = m_zoomSlider->rect().topLeft();
3191 global.ry() += m_zoomSlider->height() / 2;
3192 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3193 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3196 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3198 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3201 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3203 m_statusProgressBar->setValue(progress);
3204 if (progress >= 0) {
3205 if (!message.isEmpty())
3206 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3207 m_statusProgressBar->setVisible(true);
3208 } else if (progress == -2) {
3209 if (!message.isEmpty())
3210 m_messageLabel->setMessage(message, ErrorMessage);
3211 m_statusProgressBar->setVisible(false);
3213 m_messageLabel->setMessage(QString(), DefaultMessage);
3214 m_statusProgressBar->setVisible(false);
3218 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3220 if (clip->clipType() == TEXT) {
3221 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3222 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3223 // template text clip
3225 // Get the list of existing templates
3227 filter << "*.kdenlivetitle";
3228 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3230 QDialog *dia = new QDialog(this);
3231 Ui::TemplateClip_UI dia_ui;
3232 dia_ui.setupUi(dia);
3234 const QString templatePath = clip->getProperty("resource");
3235 for (int i = 0; i < templateFiles.size(); ++i) {
3236 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3237 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3239 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3240 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3241 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3242 //warning: setting base directory doesn't work??
3243 KUrl startDir(titlepath);
3244 dia_ui.template_list->fileDialog()->setUrl(startDir);
3245 dia_ui.description->setText(clip->getProperty("description"));
3246 if (dia->exec() == QDialog::Accepted) {
3247 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3248 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3250 QMap <QString, QString> newprops;
3252 if (KUrl(textTemplate).path() != templatePath) {
3253 // The template was changed
3254 newprops.insert("resource", textTemplate);
3257 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3258 newprops.insert("description", dia_ui.description->toPlainText());
3261 QString newtemplate = newprops.value("xmltemplate");
3262 if (newtemplate.isEmpty()) newtemplate = templatePath;
3264 // template modified we need to update xmldata
3265 QString description = newprops.value("description");
3266 if (description.isEmpty()) description = clip->getProperty("description");
3267 else newprops.insert("templatetext", description);
3268 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3269 if (!newprops.isEmpty()) {
3270 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3271 m_activeDocument->commandStack()->push(command);
3277 QString path = clip->getProperty("resource");
3278 QPointer<TitleWidget> dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3280 doc.setContent(clip->getProperty("xmldata"));
3281 dia_ui->setXml(doc);
3282 if (dia_ui->exec() == QDialog::Accepted) {
3283 QMap <QString, QString> newprops;
3284 newprops.insert("xmldata", dia_ui->xml().toString());
3285 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3286 // duration changed, we need to update duration
3287 newprops.insert("out", QString::number(dia_ui->outPoint()));
3288 int currentLength = QString(clip->producerProperty("length")).toInt();
3289 if (currentLength <= dia_ui->outPoint())
3290 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3291 else newprops.insert("length", clip->producerProperty("length"));
3293 if (!path.isEmpty()) {
3294 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3295 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) {
3296 // save to external file
3297 dia_ui->saveTitle(path);
3298 } else newprops.insert("resource", QString());
3300 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3301 m_activeDocument->commandStack()->push(command);
3302 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3303 m_activeDocument->setModified(true);
3307 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3311 // any type of clip but a title
3312 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3313 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3314 connect(m_activeTimeline->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), dia, SLOT(slotFillMarkersList(DocClipBase *)));
3315 connect(dia, SIGNAL(loadMarkers(const QString &)), m_activeTimeline->projectView(), SLOT(slotLoadClipMarkers(const QString &)));
3316 connect(dia, SIGNAL(saveMarkers(const QString &)), m_activeTimeline->projectView(), SLOT(slotSaveClipMarkers(const QString &)));
3317 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3318 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)));
3323 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3325 if (newprops.isEmpty()) return;
3326 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3327 m_activeDocument->commandStack()->push(command);
3328 m_activeDocument->setModified();
3331 // update clip occurences in timeline
3332 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3337 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3339 QPointer<ClipProperties> dia = new ClipProperties(cliplist,
3340 m_activeDocument->timecode(), commonproperties, this);
3341 if (dia->exec() == QDialog::Accepted) {
3342 QUndoCommand *command = new QUndoCommand();
3343 command->setText(i18n("Edit clips"));
3344 QMap <QString, QString> newImageProps = dia->properties();
3345 // Transparency setting applies only for images
3346 QMap <QString, QString> newProps = newImageProps;
3347 newProps.remove("transparency");
3349 for (int i = 0; i < cliplist.count(); i++) {
3350 DocClipBase *clip = cliplist.at(i);
3351 if (clip->clipType() == IMAGE)
3352 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3354 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3356 m_activeDocument->commandStack()->push(command);
3357 for (int i = 0; i < cliplist.count(); i++)
3358 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia->needsTimelineReload());
3363 void MainWindow::customEvent(QEvent* e)
3365 if (e->type() == QEvent::User)
3366 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3369 void MainWindow::slotTimelineClipSelected(ClipItem* item, bool raise)
3371 if (item != m_mainClip) {
3372 if (m_mainClip) m_mainClip->setMainSelectedClip(false);
3373 if (item) item->setMainSelectedClip(true);
3376 m_effectStack->slotClipItemSelected(item);
3377 m_projectMonitor->slotSetSelectedClip(item);
3379 m_effectStack->raiseWindow(m_effectStackDock);
3382 void MainWindow::slotTrackSelected(int index, TrackInfo info, bool raise)
3384 m_effectStack->slotTrackItemSelected(index, info);
3386 m_effectStack->raiseWindow(m_effectStackDock);
3389 void MainWindow::slotActivateTransitionView(Transition *t)
3392 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3395 void MainWindow::slotSnapRewind()
3397 if (m_projectMonitor->isActive()) {
3398 if (m_activeTimeline)
3399 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3401 m_clipMonitor->slotSeekToPreviousSnap();
3405 void MainWindow::slotSnapForward()
3407 if (m_projectMonitor->isActive()) {
3408 if (m_activeTimeline)
3409 m_activeTimeline->projectView()->slotSeekToNextSnap();
3411 m_clipMonitor->slotSeekToNextSnap();
3415 void MainWindow::slotClipStart()
3417 if (m_projectMonitor->isActive()) {
3418 if (m_activeTimeline)
3419 m_activeTimeline->projectView()->clipStart();
3423 void MainWindow::slotClipEnd()
3425 if (m_projectMonitor->isActive()) {
3426 if (m_activeTimeline)
3427 m_activeTimeline->projectView()->clipEnd();
3431 void MainWindow::slotZoneStart()
3433 if (m_projectMonitor->isActive())
3434 m_projectMonitor->slotZoneStart();
3436 m_clipMonitor->slotZoneStart();
3439 void MainWindow::slotZoneEnd()
3441 if (m_projectMonitor->isActive())
3442 m_projectMonitor->slotZoneEnd();
3444 m_clipMonitor->slotZoneEnd();
3447 void MainWindow::slotChangeTool(QAction * action)
3449 if (action == m_buttonSelectTool)
3450 slotSetTool(SELECTTOOL);
3451 else if (action == m_buttonRazorTool)
3452 slotSetTool(RAZORTOOL);
3453 else if (action == m_buttonSpacerTool)
3454 slotSetTool(SPACERTOOL);
3457 void MainWindow::slotChangeEdit(QAction * action)
3459 if (!m_activeTimeline)
3462 if (action == m_overwriteEditTool)
3463 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3464 else if (action == m_insertEditTool)
3465 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3467 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3470 void MainWindow::slotSetTool(PROJECTTOOL tool)
3472 if (m_activeDocument && m_activeTimeline) {
3473 //m_activeDocument->setTool(tool);
3477 message = i18n("Ctrl + click to use spacer on current track only");
3480 message = i18n("Click on a clip to cut it");
3483 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3486 m_messageLabel->setMessage(message, InformationMessage);
3487 m_activeTimeline->projectView()->setTool(tool);
3491 void MainWindow::slotCopy()
3493 if (m_activeDocument && m_activeTimeline)
3494 m_activeTimeline->projectView()->copyClip();
3497 void MainWindow::slotPaste()
3499 if (m_activeDocument && m_activeTimeline)
3500 m_activeTimeline->projectView()->pasteClip();
3503 void MainWindow::slotPasteEffects()
3505 if (m_activeDocument && m_activeTimeline)
3506 m_activeTimeline->projectView()->pasteClipEffects();
3509 void MainWindow::slotFind()
3511 if (!m_activeDocument || !m_activeTimeline) return;
3512 m_projectSearch->setEnabled(false);
3513 m_findActivated = true;
3514 m_findString.clear();
3515 m_activeTimeline->projectView()->initSearchStrings();
3516 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3517 m_findTimer.start(5000);
3518 qApp->installEventFilter(this);
3521 void MainWindow::slotFindNext()
3523 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3524 statusBar()->showMessage(i18n("Found: %1", m_findString));
3526 statusBar()->showMessage(i18n("Reached end of project"));
3527 m_findTimer.start(4000);
3530 void MainWindow::findAhead()
3532 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3533 m_projectSearchNext->setEnabled(true);
3534 statusBar()->showMessage(i18n("Found: %1", m_findString));
3536 m_projectSearchNext->setEnabled(false);
3537 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3541 void MainWindow::findTimeout()
3543 m_projectSearchNext->setEnabled(false);
3544 m_findActivated = false;
3545 m_findString.clear();
3546 statusBar()->showMessage(i18n("Find stopped"), 3000);
3547 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3548 m_projectSearch->setEnabled(true);
3549 removeEventFilter(this);
3552 void MainWindow::slotClipInTimeline(const QString &clipId)
3554 if (m_activeTimeline && m_activeDocument) {
3555 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3557 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3558 inTimelineMenu->clear();
3560 QList <QAction *> actionList;
3562 for (int i = 0; i < matching.count(); ++i) {
3563 QString track = QString::number(matching.at(i).track);
3564 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3566 QAction *a = new QAction(track + ": " + start, this);
3567 a->setData(QStringList() << track << start);
3568 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3569 while (j < actionList.count()) {
3570 if (actionList.at(j)->text() > a->text()) break;
3573 actionList.insert(j, a);
3575 inTimelineMenu->addActions(actionList);
3577 if (matching.empty())
3578 inTimelineMenu->setEnabled(false);
3580 inTimelineMenu->setEnabled(true);
3584 void MainWindow::slotClipInProjectTree()
3586 if (m_activeTimeline) {
3587 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3588 if (clipIds.isEmpty())
3590 m_projectListDock->raise();
3591 for (int i = 0; i < clipIds.count(); i++)
3592 m_projectList->selectItemById(clipIds.at(i));
3593 if (m_projectMonitor->isActive())
3594 slotSwitchMonitors();
3598 /*void MainWindow::slotClipToProjectTree()
3600 if (m_activeTimeline) {
3601 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3602 if (clips.isEmpty()) return;
3603 for (int i = 0; i < clips.count(); i++) {
3604 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3606 //m_projectList->selectItemById(clipIds.at(i));
3610 void MainWindow::slotSelectClipInTimeline()
3612 if (m_activeTimeline) {
3613 QAction *action = qobject_cast<QAction *>(sender());
3614 QStringList data = action->data().toStringList();
3615 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3619 void MainWindow::keyPressEvent(QKeyEvent *ke)
3621 if (m_findActivated) {
3622 if (ke->key() == Qt::Key_Backspace) {
3623 m_findString = m_findString.left(m_findString.length() - 1);
3625 if (!m_findString.isEmpty())
3630 m_findTimer.start(4000);
3633 } else if (ke->key() == Qt::Key_Escape) {
3637 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3638 m_findString += ke->text();
3642 m_findTimer.start(4000);
3647 KXmlGuiWindow::keyPressEvent(ke);
3652 /** Gets called when the window gets hidden */
3653 void MainWindow::hideEvent(QHideEvent */*event*/)
3655 if (isMinimized() && m_monitorManager)
3656 m_monitorManager->stopActiveMonitor();
3659 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3661 if (m_findActivated) {
3662 if (event->type() == QEvent::ShortcutOverride) {
3663 QKeyEvent* ke = (QKeyEvent*) event;
3664 if (ke->text().trimmed().isEmpty()) return false;
3671 // pass the event on to the parent class
3672 return QMainWindow::eventFilter(obj, event);
3677 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3679 KDialog *dialog = new KDialog(this);
3680 dialog->setCaption("Save clip zone");
3681 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3683 QWidget *widget = new QWidget(dialog);
3684 dialog->setMainWidget(widget);
3686 QVBoxLayout *vbox = new QVBoxLayout(widget);
3687 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3688 if (path.isEmpty()) {
3689 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3690 if (baseClip == NULL) tmppath.append("untitled.mlt");
3692 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + '-' + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3694 path = KUrl(tmppath);
3696 KUrlRequester *url = new KUrlRequester(path, this);
3697 url->setFilter("video/mlt-playlist");
3698 QLabel *label2 = new QLabel(i18n("Description:"), this);
3699 KLineEdit *edit = new KLineEdit(this);
3700 vbox->addWidget(label1);
3701 vbox->addWidget(url);
3702 vbox->addWidget(label2);
3703 vbox->addWidget(edit);
3704 if (dialog->exec() == QDialog::Accepted) {
3705 if (QFile::exists(url->url().path())) {
3706 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3707 slotSaveZone(render, zone, baseClip, url->url());
3711 if (baseClip && !baseClip->fileURL().isEmpty()) {
3712 // create zone from clip url, so that we don't have problems with proxy clips
3714 #if QT_VERSION >= 0x040600
3715 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3716 env.remove("MLT_PROFILE");
3717 p.setProcessEnvironment(env);
3719 QStringList env = QProcess::systemEnvironment();
3720 env << "MLT_PROFILE='\0'";
3721 p.setEnvironment(env);
3723 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3724 if (!p.waitForStarted(3000)) {
3725 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3727 else if (!p.waitForFinished(5000)) {
3728 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3731 else render->saveZone(url->url(), edit->text(), zone);
3736 void MainWindow::slotSetInPoint()
3738 if (m_clipMonitor->isActive()) {
3739 m_clipMonitor->slotSetZoneStart();
3741 m_projectMonitor->slotSetZoneStart();
3745 void MainWindow::slotSetOutPoint()
3747 if (m_clipMonitor->isActive()) {
3748 m_clipMonitor->slotSetZoneEnd();
3750 m_projectMonitor->slotSetZoneEnd();
3754 void MainWindow::slotResizeItemStart()
3756 if (m_activeTimeline)
3757 m_activeTimeline->projectView()->setInPoint();
3760 void MainWindow::slotResizeItemEnd()
3762 if (m_activeTimeline)
3763 m_activeTimeline->projectView()->setOutPoint();
3766 int MainWindow::getNewStuff(const QString &configFile)
3768 KNS3::Entry::List entries;
3769 #if KDE_IS_VERSION(4,3,80)
3770 QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
3772 if (dialog) entries = dialog->changedEntries();
3773 foreach(const KNS3::Entry & entry, entries) {
3774 if (entry.status() == KNS3::Entry::Installed)
3775 kDebug() << "// Installed files: " << entry.installedFiles();
3779 KNS::Engine engine(0);
3780 if (engine.init(configFile))
3781 entries = engine.downloadDialogModal(this);
3782 foreach(KNS::Entry * entry, entries) {
3783 if (entry->status() == KNS::Entry::Installed)
3784 kDebug() << "// Installed files: " << entry->installedFiles();
3787 return entries.size();
3790 void MainWindow::slotGetNewTitleStuff()
3792 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3793 TitleWidget::refreshTitleTemplates();
3796 void MainWindow::slotGetNewLumaStuff()
3798 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3799 initEffects::refreshLumas();
3800 m_activeTimeline->projectView()->reloadTransitionLumas();
3804 void MainWindow::slotGetNewRenderStuff()
3806 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3808 m_renderWidget->reloadProfiles();
3811 void MainWindow::slotGetNewMltProfileStuff()
3813 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3814 // update the list of profiles in settings dialog
3815 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3821 void MainWindow::slotAutoTransition()
3823 if (m_activeTimeline)
3824 m_activeTimeline->projectView()->autoTransition();
3827 void MainWindow::slotSplitAudio()
3829 if (m_activeTimeline)
3830 m_activeTimeline->projectView()->splitAudio();
3833 void MainWindow::slotSetAudioAlignReference()
3835 if (m_activeTimeline) {
3836 m_activeTimeline->projectView()->setAudioAlignReference();
3840 void MainWindow::slotAlignAudio()
3842 if (m_activeTimeline) {
3843 m_activeTimeline->projectView()->alignAudio();
3847 void MainWindow::slotUpdateClipType(QAction *action)
3849 if (m_activeTimeline) {
3850 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3851 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3852 else m_activeTimeline->projectView()->setAudioAndVideo();
3856 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3858 // We must stop the monitors since we create a new on in the dvd wizard
3859 m_clipMonitor->stop();
3860 m_projectMonitor->stop();
3861 QPointer<DvdWizard> w = new DvdWizard(url, profile, this);
3863 m_projectMonitor->start();
3867 void MainWindow::slotShowTimeline(bool show)
3869 if (show == false) {
3870 m_timelineState = saveState();
3871 centralWidget()->setHidden(true);
3873 centralWidget()->setHidden(false);
3874 restoreState(m_timelineState);
3878 void MainWindow::slotMaximizeCurrent(bool)
3880 //TODO: is there a way to maximize current widget?
3882 m_timelineState = saveState();
3883 QWidget *par = focusWidget()->parentWidget();
3884 while (par->parentWidget() && par->parentWidget() != this)
3885 par = par->parentWidget();
3886 kDebug() << "CURRENT WIDGET: " << par->objectName();
3889 void MainWindow::loadStabilize()
3891 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3894 Mlt::Profile profile;
3895 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3896 QAction *action=stabMenu->addAction("Videostab (vstab)");
3897 action->setData("videostab");
3898 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3900 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3901 QAction *action=stabMenu->addAction("Videostab (transcode)");
3902 action->setData("videostab2");
3903 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3910 void MainWindow::loadTranscoders()
3912 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3915 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
3916 extractAudioMenu->clear();
3918 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3919 KConfigGroup transConfig(config, "Transcoding");
3921 QMap< QString, QString > profiles = transConfig.entryMap();
3922 QMapIterator<QString, QString> i(profiles);
3923 while (i.hasNext()) {
3925 QStringList data = i.value().split(';');
3927 // separate audio transcoding in a separate menu
3928 if (data.count() > 2 && data.at(2) == "audio") {
3929 a = extractAudioMenu->addAction(i.key());
3932 a = transMenu->addAction(i.key());
3935 if (data.count() > 1) a->setToolTip(data.at(1));
3936 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3940 void MainWindow::slotStabilize()
3942 QString condition,filtername;
3945 // Stablize selected clips
3946 QAction *action = qobject_cast<QAction *>(sender());
3948 filtername=action->data().toString();
3950 m_projectList->startClipFilterJob(filtername, condition);
3952 if (ids.isEmpty()) {
3953 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3956 QString destination;
3957 ProjectItem *item = m_projectList->getClipById(ids.at(0));
3958 if (ids.count() == 1) {
3961 ClipStabilize *d = new ClipStabilize(destination, ids.count(), filtername);
3962 //connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3963 if (d->exec() == QDialog::Accepted) {
3964 m_projectList->slotStabilizeClipJob(ids, d->autoAddClip(), d->params(), d->desc());
3969 void MainWindow::slotTranscode(KUrl::List urls)
3974 if (urls.isEmpty()) {
3975 QAction *action = qobject_cast<QAction *>(sender());
3976 QStringList data = action->data().toStringList();
3977 params = data.at(0);
3978 if (data.count() > 1) desc = data.at(1);
3979 if (data.count() > 3) condition = data.at(3);
3980 m_projectList->slotTranscodeClipJob(condition, params, desc);
3983 if (urls.isEmpty()) {
3984 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3987 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3988 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3992 void MainWindow::slotTranscodeClip()
3994 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3995 if (urls.isEmpty()) return;
3996 slotTranscode(urls);
3999 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
4001 if (m_activeDocument == NULL) return;
4002 QMapIterator<QString, QString> i(props);
4003 while (i.hasNext()) {
4005 m_activeDocument->setDocumentProperty(i.key(), i.value());
4007 m_activeDocument->setModified(true);
4011 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
4013 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
4015 QString playlistPath;
4018 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
4019 QString path = m_renderWidget->getFreeScriptName();
4020 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
4021 if (!ok || scriptPath.isEmpty()) return;
4022 scriptPath.prepend(scriptsFolder);
4023 QFile f(scriptPath);
4025 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
4028 playlistPath = scriptPath + ".mlt";
4030 KTemporaryFile temp;
4031 temp.setAutoRemove(false);
4032 temp.setSuffix(".mlt");
4034 playlistPath = temp.fileName();
4036 QString playlistContent = m_projectMonitor->sceneList();
4037 if (!chapterFile.isEmpty()) {
4040 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
4042 in = m_activeTimeline->inPoint();
4043 out = m_activeTimeline->outPoint();
4046 QDomElement chapters = doc.createElement("chapters");
4047 chapters.setAttribute("fps", m_activeDocument->fps());
4048 doc.appendChild(chapters);
4050 QDomElement guidesxml = m_activeDocument->guidesXml();
4051 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
4052 for (int i = 0; i < nodes.count(); i++) {
4053 QDomElement e = nodes.item(i).toElement();
4055 QString comment = e.attribute("comment");
4056 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
4057 if (time >= in && time < out) {
4058 if (zoneOnly) time = time - in;
4059 QDomElement chapter = doc.createElement("chapter");
4060 chapters.appendChild(chapter);
4061 chapter.setAttribute("title", comment);
4062 chapter.setAttribute("time", time);
4066 if (chapters.childNodes().count() > 0) {
4067 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
4068 // Always insert a guide in pos 0
4069 QDomElement chapter = doc.createElement("chapter");
4070 chapters.insertBefore(chapter, QDomNode());
4071 chapter.setAttribute("title", i18n("Start"));
4072 chapter.setAttribute("time", "0");
4074 // save chapters file
4075 QFile file(chapterFile);
4076 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4077 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4079 file.write(doc.toString().toUtf8());
4080 if (file.error() != QFile::NoError) {
4081 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4088 if (m_renderWidget->automaticAudioExport()) {
4089 exportAudio = m_activeTimeline->checkProjectAudio();
4090 } else exportAudio = m_renderWidget->selectedAudioExport();
4092 // Set playlist audio volume to 100%
4094 doc.setContent(playlistContent);
4095 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4096 if (!tractor.isNull()) {
4097 QDomNodeList props = tractor.elementsByTagName("property");
4098 for (int i = 0; i < props.count(); i++) {
4099 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4100 props.at(i).firstChild().setNodeValue("1");
4106 // Do we want proxy rendering
4107 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4108 QString root = doc.documentElement().attribute("root");
4110 // replace proxy clips with originals
4111 QMap <QString, QString> proxies = m_projectList->getProxies();
4113 QDomNodeList producers = doc.elementsByTagName("producer");
4114 QString producerResource;
4116 for (uint n = 0; n < producers.length(); n++) {
4117 QDomElement e = producers.item(n).toElement();
4118 producerResource = EffectsList::property(e, "resource");
4119 if (producerResource.isEmpty()) continue;
4120 if (!producerResource.startsWith('/')) {
4121 producerResource.prepend(root + '/');
4123 if (producerResource.contains('?')) {
4124 // slowmotion producer
4125 suffix = '?' + producerResource.section('?', 1);
4126 producerResource = producerResource.section('?', 0, 0);
4128 else suffix.clear();
4129 if (!producerResource.isEmpty()) {
4130 if (proxies.contains(producerResource)) {
4131 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4132 // We need to delete the "aspect_ratio" property because proxy clips
4133 // sometimes have different ratio than original clips
4134 EffectsList::removeProperty(e, "aspect_ratio");
4135 EffectsList::removeMetaProperties(e);
4140 /*QMapIterator<QString, QString> i(proxies);
4141 while (i.hasNext()) {
4143 // Replace all keys with their values (proxy path with original path)
4144 QString key = i.key();
4145 playlistContent.replace(key, i.value());
4146 if (!root.isEmpty() && key.startsWith(root)) {
4147 // in case the resource path in MLT playlist is relative
4148 key.remove(0, root.count() + 1);
4149 playlistContent.replace(key, i.value());
4153 playlistContent = doc.toString();
4155 // Do save scenelist
4156 QFile file(playlistPath);
4157 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4158 m_messageLabel->setMessage(i18n("Cannot write to file %1", playlistPath), ErrorMessage);
4161 file.write(playlistContent.toUtf8());
4162 if (file.error() != QFile::NoError) {
4163 m_messageLabel->setMessage(i18n("Cannot write to file %1", playlistPath), ErrorMessage);
4168 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4171 void MainWindow::slotUpdateTimecodeFormat(int ix)
4173 KdenliveSettings::setFrametimecode(ix == 1);
4174 m_clipMonitor->updateTimecodeFormat();
4175 m_projectMonitor->updateTimecodeFormat();
4176 m_transitionConfig->updateTimecodeFormat();
4177 m_effectStack->updateTimecodeFormat();
4178 //m_activeTimeline->projectView()->clearSelection();
4179 m_activeTimeline->updateRuler();
4182 void MainWindow::slotRemoveFocus()
4184 statusBar()->setFocus();
4185 statusBar()->clearFocus();
4188 void MainWindow::slotRevert()
4190 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;
4191 KUrl url = m_activeDocument->url();
4192 if (closeCurrentDocument(false))
4193 doOpenFile(url, NULL);
4197 void MainWindow::slotShutdown()
4199 if (m_activeDocument) m_activeDocument->setModified(false);
4201 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4202 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4203 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4204 smserver.call("logout", 1, 2, 2);
4205 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4206 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4207 smserver.call("Shutdown");
4211 void MainWindow::slotUpdateTrackInfo()
4213 if (m_activeDocument)
4214 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4217 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4219 // Load the theme file
4221 if (action == NULL) theme = themename;
4222 else theme = action->data().toString();
4223 KdenliveSettings::setColortheme(theme);
4224 // Make palette for all widgets.
4225 QPalette plt = kapp->palette();
4226 if (theme.isEmpty()) {
4227 plt = QApplication::desktop()->palette();
4229 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4231 #if KDE_IS_VERSION(4,6,3)
4232 plt = KGlobalSettings::createNewApplicationPalette(config);
4234 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4235 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4236 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4237 QPalette::Disabled };
4238 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4239 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4241 for ( int i = 0; i < 3 ; i++ ) {
4242 QPalette::ColorGroup state = states[i];
4243 KColorScheme schemeView(state, KColorScheme::View, config);
4244 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4245 KColorScheme schemeButton(state, KColorScheme::Button, config);
4246 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4248 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4249 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4250 plt.setBrush( state, QPalette::Base, schemeView.background() );
4251 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4252 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4253 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4254 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4255 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4256 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4257 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4259 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4260 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4261 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4262 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4263 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4265 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4266 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4267 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4272 kapp->setPalette(plt);
4273 slotChangePalette();
4274 const QObjectList children = statusBar()->children();
4276 foreach(QObject * child, children) {
4277 if (child->isWidgetType())
4278 ((QWidget*)child)->setPalette(plt);
4279 const QObjectList subchildren = child->children();
4280 foreach(QObject * subchild, subchildren) {
4281 if (subchild->isWidgetType())
4282 ((QWidget*)subchild)->setPalette(plt);
4288 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4290 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4291 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4292 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4293 const QSize bitsSize(24, 2);
4294 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4295 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4297 QPixmap pixmap(23, 16);
4298 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4300 KConfigGroup group(config, "WM");
4301 QPainter p(&pixmap);
4302 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4303 p.fillRect(1, 1, 7, 7, windowScheme.background());
4304 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4306 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4307 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4308 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4310 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4311 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4313 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4314 p.fillRect(1, 8, 7, 7, viewScheme.background());
4315 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4317 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4318 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4319 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4321 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4322 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4328 void MainWindow::slotSwitchMonitors()
4330 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4331 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4332 else m_projectList->focusTree();
4335 void MainWindow::slotInsertZoneToTree()
4337 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4338 QStringList info = m_clipMonitor->getZoneInfo();
4339 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4342 void MainWindow::slotInsertZoneToTimeline()
4344 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4345 QStringList info = m_clipMonitor->getZoneInfo();
4346 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4350 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4352 if (m_activeDocument && m_activeTimeline) {
4353 if (!ids.isEmpty()) {
4354 for (int i = 0; i < ids.size(); ++i) {
4355 m_activeTimeline->slotDeleteClip(ids.at(i));
4357 m_activeDocument->clipManager()->slotDeleteClips(ids);
4359 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4360 m_activeDocument->setModified(true);
4364 void MainWindow::slotShowTitleBars(bool show)
4366 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4367 for (int i = 0; i < docks.count(); i++) {
4368 QDockWidget* dock = docks.at(i);
4370 dock->setTitleBarWidget(0);
4372 if (!dock->isFloating()) {
4373 dock->setTitleBarWidget(new QWidget);
4377 KdenliveSettings::setShowtitlebars(show);
4380 void MainWindow::slotSwitchTitles()
4382 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4385 QString MainWindow::getMimeType(bool open)
4387 QString mimetype = "application/x-kdenlive";
4388 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4390 mimetype = "*.kdenlive";
4391 if (open) mimetype.append(" *.tar.gz");
4393 else if (open) mimetype.append(" application/x-compressed-tar");
4397 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4400 m_projectMonitor->render->sendFrameForAnalysis = true;
4403 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4404 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4411 qDebug() << "Any scope accepting new frames? " << request;
4414 m_projectMonitor->render->sendFrameForAnalysis = false;
4419 void MainWindow::slotOpenStopmotion()
4421 if (m_stopmotion == NULL) {
4422 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4423 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4424 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4425 // Check if we need the renderer to send a new frame for update
4426 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4427 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4428 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4431 m_stopmotion->show();
4434 void MainWindow::slotDeleteClip(const QString &id)
4436 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4437 for (int i = 0; i < list.size(); ++i) {
4438 list.at(i)->disableClipId(id);
4440 m_projectList->slotDeleteClip(id);
4443 void MainWindow::slotUpdateProxySettings()
4445 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4446 if (KdenliveSettings::enableproxy())
4447 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4448 m_projectList->updateProxyConfig();
4451 void MainWindow::slotInsertNotesTimecode()
4453 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4454 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4455 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4458 void MainWindow::slotArchiveProject()
4460 QList <DocClipBase*> list = m_projectList->documentClipList();
4461 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4462 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4467 void MainWindow::slotOpenBackupDialog(const KUrl url)
4472 kDebug()<<"// BACKUP URL: "<<url.path();
4473 if (!url.isEmpty()) {
4474 // we could not open the project file, guess where the backups are
4475 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4479 projectFolder = m_activeDocument->projectFolder();
4480 projectFile = m_activeDocument->url();
4481 projectId = m_activeDocument->getDocumentProperty("documentid");
4484 QPointer<BackupWidget> dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4485 if (dia->exec() == QDialog::Accepted) {
4486 QString requestedBackup = dia->selectedFile();
4487 m_activeDocument->backupLastSavedVersion(projectFile.path());
4488 closeCurrentDocument(false);
4489 doOpenFile(KUrl(requestedBackup), NULL);
4490 m_activeDocument->setUrl(projectFile);
4491 m_activeDocument->setModified(true);
4492 setCaption(m_activeDocument->description());
4497 void MainWindow::slotElapsedTime()
4499 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4503 void MainWindow::slotDownloadResources()
4505 QString currentFolder;
4506 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4507 else currentFolder = KdenliveSettings::defaultprojectfolder();
4508 ResourceWidget *d = new ResourceWidget(currentFolder);
4509 connect(d, SIGNAL(addClip(KUrl,stringMap)), this, SLOT(slotAddProjectClip(KUrl,stringMap)));
4513 void MainWindow::slotChangePalette()
4515 QPalette plt = QApplication::palette();
4516 if (m_effectStack) m_effectStack->updatePalette();
4517 if (m_projectList) m_projectList->updatePalette();
4518 if (m_effectList) m_effectList->updatePalette();
4520 if (m_clipMonitor) m_clipMonitor->setPalette(plt);
4521 if (m_projectMonitor) m_projectMonitor->setPalette(plt);
4523 setStatusBarStyleSheet(plt);
4524 if (m_activeTimeline) {
4525 m_activeTimeline->updatePalette();
4529 void MainWindow::slotSaveTimelineClip()
4531 if (m_activeTimeline && m_projectMonitor->render) {
4532 ClipItem *clip = m_activeTimeline->projectView()->getActiveClipUnderCursor(true);
4534 m_messageLabel->setMessage(i18n("Select a clip to save"), InformationMessage);
4537 KUrl url = KFileDialog::getSaveUrl(m_activeDocument->projectFolder(), "video/mlt-playlist");
4538 if (!url.isEmpty()) m_projectMonitor->render->saveClip(m_activeDocument->tracksCount() - clip->track(), clip->startPos(), url);
4543 #include "mainwindow.moc"