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),
163 qRegisterMetaType<QVector<int16_t> > ();
164 qRegisterMetaType<stringMap> ("stringMap");
165 qRegisterMetaType<audioByteArray> ("audioByteArray");
168 QLocale systemLocale = QLocale();
169 setlocale(LC_NUMERIC, NULL);
170 char *separator = localeconv()->decimal_point;
171 if (separator != systemLocale.decimalPoint()) {
172 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
173 // HACK: There is a locale conflict, so set locale to at least have correct decimal point
174 if (strncmp(separator, ".", 1) == 0) systemLocale = QLocale::c();
175 else if (strncmp(separator, ",", 1) == 0) systemLocale = QLocale("fr_FR.UTF-8");
178 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
179 QLocale::setDefault(systemLocale);
181 // Create DBus interface
182 new MainWindowAdaptor(this);
183 QDBusConnection dbus = QDBusConnection::sessionBus();
184 dbus.registerObject("/MainWindow", this);
186 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
187 setFont(KGlobalSettings::toolBarFont());
188 parseProfiles(MltPath);
189 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
190 m_commandStack = new QUndoGroup;
191 setDockNestingEnabled(true);
192 m_timelineArea = new KTabWidget(this);
193 m_timelineArea->setTabReorderingEnabled(true);
194 m_timelineArea->setTabBarHidden(true);
195 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
196 m_timelineArea->setMinimumHeight(200);
198 QToolButton *closeTabButton = new QToolButton;
199 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
200 closeTabButton->setIcon(KIcon("tab-close"));
201 closeTabButton->adjustSize();
202 closeTabButton->setToolTip(i18n("Close the current tab"));
203 m_timelineArea->setCornerWidget(closeTabButton);
204 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
206 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
207 m_findTimer.setSingleShot(true);
209 // FIXME: the next call returns a newly allocated object, which leaks
210 initEffects::parseEffectFiles();
211 //initEffects::parseCustomEffectsFile();
213 m_monitorManager = new MonitorManager();
215 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
216 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
221 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
222 m_projectListDock->setObjectName("project_tree");
223 m_projectList = new ProjectList();
224 m_projectListDock->setWidget(m_projectList);
225 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
227 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
228 m_clipMonitorDock->setObjectName("clip_monitor");
229 m_clipMonitor = new Monitor(Kdenlive::clipMonitor, m_monitorManager, QString(), m_timelineArea);
230 m_clipMonitorDock->setWidget(m_clipMonitor);
232 // Connect the project list
233 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
234 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(slotActivateMonitor()));
235 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
236 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
237 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
238 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
239 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
240 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
241 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
242 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
243 connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
245 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
246 m_projectMonitorDock->setObjectName("project_monitor");
247 m_projectMonitor = new Monitor(Kdenlive::projectMonitor, m_monitorManager, QString());
248 m_projectMonitorDock->setWidget(m_projectMonitor);
251 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
252 m_recMonitorDock->setObjectName("record_monitor");
253 m_recMonitor = new RecMonitor(Kdenlive::recordMonitor, m_monitorManager);
254 m_recMonitorDock->setWidget(m_recMonitor);
255 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
256 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
257 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
259 #endif /* ! Q_WS_MAC */
260 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
262 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
263 m_notesDock->setObjectName("notes_widget");
264 m_notesWidget = new NotesWidget();
265 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
266 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
268 m_notesWidget->setTabChangesFocus(true);
269 #if KDE_IS_VERSION(4,4,0)
270 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
272 m_notesDock->setWidget(m_notesWidget);
273 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
275 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
276 m_effectStackDock->setObjectName("effect_stack");
277 m_effectStack = new EffectStackView2(m_projectMonitor);
278 m_effectStackDock->setWidget(m_effectStack);
279 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
280 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&)));
282 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
283 m_transitionConfigDock->setObjectName("transition");
284 m_transitionConfig = new TransitionSettings(m_projectMonitor);
285 m_transitionConfigDock->setWidget(m_transitionConfig);
286 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
288 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
289 m_effectListDock->setObjectName("effect_list");
290 m_effectList = new EffectsListView();
291 m_effectListDock->setWidget(m_effectList);
292 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
294 m_scopeManager = new ScopeManager(m_monitorManager);
295 m_vectorscope = new Vectorscope();
296 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
297 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
298 m_vectorscopeDock->setWidget(m_vectorscope);
299 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
300 m_scopeManager->addScope(m_vectorscope, m_vectorscopeDock);
302 m_waveform = new Waveform();
303 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
304 m_waveformDock->setObjectName(m_waveform->widgetName());
305 m_waveformDock->setWidget(m_waveform);
306 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
307 m_scopeManager->addScope(m_waveform, m_waveformDock);
309 m_RGBParade = new RGBParade();
310 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
311 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
312 m_RGBParadeDock->setWidget(m_RGBParade);
313 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
314 m_scopeManager->addScope(m_RGBParade, m_RGBParadeDock);
316 m_histogram = new Histogram();
317 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
318 m_histogramDock->setObjectName(m_histogram->widgetName());
319 m_histogramDock->setWidget(m_histogram);
320 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
321 m_scopeManager->addScope(m_histogram, m_histogramDock);
323 m_audiosignal = new AudioSignal;
324 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
325 m_audiosignalDock->setObjectName("audiosignal");
326 m_audiosignalDock->setWidget(m_audiosignal);
327 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
328 m_scopeManager->addScope(m_audiosignal, m_audiosignalDock);
330 m_audioSpectrum = new AudioSpectrum();
331 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
332 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
333 m_audioSpectrumDock->setWidget(m_audioSpectrum);
334 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
335 m_scopeManager->addScope(m_audioSpectrum, m_audioSpectrumDock);
337 m_spectrogram = new Spectrogram();
338 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
339 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
340 m_spectrogramDock->setWidget(m_spectrogram);
341 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
342 m_scopeManager->addScope(m_spectrogram, m_spectrogramDock);
344 // Add monitors here to keep them at the right of the window
345 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
346 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
348 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
351 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
352 m_undoViewDock->setObjectName("undo_history");
353 m_undoView = new QUndoView();
354 m_undoView->setCleanIcon(KIcon("edit-clear"));
355 m_undoView->setEmptyLabel(i18n("Clean"));
356 m_undoViewDock->setWidget(m_undoView);
357 m_undoView->setGroup(m_commandStack);
358 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
362 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
365 // Close non-general docks for the initial layout
366 // only show important ones
367 m_histogramDock->close();
368 m_RGBParadeDock->close();
369 m_waveformDock->close();
370 m_vectorscopeDock->close();
372 m_audioSpectrumDock->close();
373 m_spectrogramDock->close();
374 m_audiosignalDock->close();
376 m_undoViewDock->close();
380 /// Tabify Widgets ///
381 tabifyDockWidget(m_effectListDock, m_effectStackDock);
382 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
383 tabifyDockWidget(m_projectListDock, m_notesDock);
385 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
387 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
389 setCentralWidget(m_timelineArea);
391 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
393 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
394 m_fileRevert->setEnabled(false);
396 // Prepare layout actions
397 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
398 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
399 for (int i = 1; i < 5; i++) {
400 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
401 load->setData("_" + QString::number(i));
402 layoutActions->addAction("load_layout" + QString::number(i), load);
403 m_loadLayout->addAction(load);
404 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
405 save->setData("_" + QString::number(i));
406 layoutActions->addAction("save_layout" + QString::number(i), save);
408 layoutActions->addAction("load_layouts", m_loadLayout);
409 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
412 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
413 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
414 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
415 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
416 m_stopmotion_actions->addAction("stopmotion_capture", action);
417 action = new KAction(i18n("Switch live / captured frame"), this);
418 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
419 m_stopmotion_actions->addAction("stopmotion_switch", action);
420 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
421 action->setCheckable(true);
422 action->setChecked(false);
423 m_stopmotion_actions->addAction("stopmotion_overlay", action);
425 // Build effects menu
426 m_effectsMenu = new QMenu(i18n("Add Effect"));
427 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
428 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
429 m_effectsActionCollection->readSettings();
433 // Find QDockWidget tab bars and show / hide widget title bars on right click
434 QList <QTabBar *> tabs = findChildren<QTabBar *>();
435 for (int i = 0; i < tabs.count(); i++) {
436 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
437 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
440 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
441 guiFactory()->addClient(sp);*/
442 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
443 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
446 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
448 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
451 // Load layout names from config file
458 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
459 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
461 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
462 clipInTimeline->setIcon(KIcon("go-jump"));
463 QHash<QString,QMenu*> menus;
464 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
465 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
466 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
467 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
468 menus.insert("inTimelineMenu",clipInTimeline);
469 m_projectList->setupGeneratorMenu(menus);
471 // build themes menus
472 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
473 QActionGroup *themegroup = new QActionGroup(this);
474 themegroup->setExclusive(true);
475 action = new KAction(i18n("Default"), this);
476 action->setCheckable(true);
477 themegroup->addAction(action);
478 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
480 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
482 for (int i = 0; i < schemeFiles.size(); ++i) {
484 const QString filename = schemeFiles.at(i);
485 const QFileInfo info(filename);
488 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
489 QIcon icon = createSchemePreviewIcon(config);
490 KConfigGroup group(config, "General");
491 const QString name = group.readEntry("Name", info.baseName());
492 action = new KAction(name, this);
493 action->setData(filename);
494 action->setIcon(icon);
495 action->setCheckable(true);
496 themegroup->addAction(action);
497 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
500 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
501 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
502 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
505 action = new QAction(fi.fileName(), this);
506 action->setData(*it);
507 action->setCheckable(true);
508 themegroup->addAction(action);
509 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
511 themesMenu->addActions(themegroup->actions());
512 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
514 // Setup and fill effects and transitions menus.
517 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
518 m->addActions(m_effectsMenu->actions());
521 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
522 for (int i = 0; i < transitions.count(); ++i)
523 m_transitionsMenu->addAction(m_transitions[i]);
525 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
526 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
527 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
529 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
530 const QList<QAction *> viewActions = createPopupMenu()->actions();
531 viewMenu->insertActions(NULL, viewActions);
533 m_timelineContextMenu = new QMenu(this);
534 m_timelineContextClipMenu = new QMenu(this);
535 m_timelineContextTransitionMenu = new QMenu(this);
537 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
538 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
539 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
541 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
542 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
543 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
544 m_timelineContextClipMenu->addSeparator();
545 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
546 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
547 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
548 if (KdenliveSettings::enableaudioalign()) {
549 m_timelineContextClipMenu->addAction(actionCollection()->action("set_audio_align_ref"));
550 m_timelineContextClipMenu->addAction(actionCollection()->action("align_audio"));
552 m_timelineContextClipMenu->addSeparator();
553 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
554 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
555 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
556 m_timelineContextClipMenu->addSeparator();
558 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
559 m_timelineContextClipMenu->addMenu(markersMenu);
560 m_timelineContextClipMenu->addSeparator();
561 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
562 m_timelineContextClipMenu->addMenu(m_effectsMenu);
564 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
565 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
567 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
569 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
570 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
571 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
572 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
574 slotConnectMonitors();
576 // Open or create a file. Command line argument passed in Url has
577 // precedence, then "openlastproject", then just a plain empty file.
578 // If opening Url fails, openlastproject will _not_ be used.
579 if (!Url.isEmpty()) {
580 // delay loading so that the window shows up
582 QTimer::singleShot(500, this, SLOT(openFile()));
583 } else if (KdenliveSettings::openlastproject()) {
584 QTimer::singleShot(500, this, SLOT(openLastFile()));
585 } else { //if (m_timelineArea->count() == 0) {
589 if (!clipsToLoad.isEmpty() && m_activeDocument) {
590 QStringList list = clipsToLoad.split(',');
592 foreach(QString path, list) {
593 kDebug() << QDir::current().absoluteFilePath(path);
594 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
596 m_projectList->slotAddClip(urls);
599 #ifdef USE_JOGSHUTTLE
600 activateShuttleDevice();
602 m_projectListDock->raise();
604 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
605 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
607 // Populate encoding profiles
608 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
609 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
610 KConfigGroup group(&conf, "proxy");
611 QMap< QString, QString > values = group.entryMap();
612 QMapIterator<QString, QString> i(values);
615 QString data = i.value();
616 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
617 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
620 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
621 KConfigGroup group(&conf, "video4linux");
622 QMap< QString, QString > values = group.entryMap();
623 QMapIterator<QString, QString> i(values);
626 QString data = i.value();
627 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
628 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
631 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
632 KConfigGroup group(&conf, "decklink");
633 QMap< QString, QString > values = group.entryMap();
634 QMapIterator<QString, QString> i(values);
637 QString data = i.value();
638 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
639 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
643 connect (KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(slotChangePalette()));
646 MainWindow::~MainWindow()
651 m_effectStack->slotClipItemSelected(NULL);
652 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
654 if (m_projectMonitor) m_projectMonitor->stop();
655 if (m_clipMonitor) m_clipMonitor->stop();
657 delete m_activeTimeline;
658 delete m_effectStack;
659 delete m_transitionConfig;
660 delete m_activeDocument;
661 delete m_projectMonitor;
662 delete m_clipMonitor;
663 delete m_shortcutRemoveFocus;
664 delete[] m_transitions;
665 delete m_monitorManager;
666 delete m_scopeManager;
667 Mlt::Factory::close();
671 bool MainWindow::queryClose()
673 if (m_renderWidget) {
674 int waitingJobs = m_renderWidget->waitingJobsCount();
675 if (waitingJobs > 0) {
676 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")))) {
677 case KMessageBox::Yes :
678 // create script with waiting jobs and start it
679 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
681 case KMessageBox::No :
682 // Don't do anything, jobs will be deleted
690 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
691 // warn the user to save if document is modified and we have clips in our project list
692 if (m_activeDocument && m_activeDocument->isModified() &&
693 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
694 !m_projectList->documentClipList().isEmpty())) {
698 if (m_activeDocument->url().fileName().isEmpty())
699 message = i18n("Save changes to document?");
701 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
702 switch (KMessageBox::warningYesNoCancel(this, message)) {
703 case KMessageBox::Yes :
704 // save document here. If saving fails, return false;
706 case KMessageBox::No :
707 // User does not want to save the changes, clear recovery files
708 m_activeDocument->m_autosave->resize(0);
717 void MainWindow::loadPlugins()
719 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
720 populateMenus(plugin);
723 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
725 filters << "libkdenlive*";
726 foreach(const QString & folder, directories) {
727 kDebug() << "Parsing plugin folder: " << folder;
728 QDir pluginsDir(folder);
729 foreach(const QString & fileName,
730 pluginsDir.entryList(filters, QDir::Files)) {
732 * Avoid loading the same plugin twice when there is more than one
735 if (!m_pluginFileNames.contains(fileName)) {
736 kDebug() << "Found plugin: " << fileName;
737 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
738 QObject *plugin = loader.instance();
740 populateMenus(plugin);
741 m_pluginFileNames += fileName;
743 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
749 void MainWindow::populateMenus(QObject *plugin)
751 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
752 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
754 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
758 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
759 QMenu *menu, const char *member,
760 QActionGroup *actionGroup)
762 kDebug() << "// ADD to MENU" << texts;
763 foreach(const QString & text, texts) {
764 QAction *action = new QAction(text, plugin);
765 action->setData(text);
766 connect(action, SIGNAL(triggered()), this, member);
767 menu->addAction(action);
770 action->setCheckable(true);
771 actionGroup->addAction(action);
776 void MainWindow::aboutPlugins()
778 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
783 void MainWindow::generateClip()
785 QAction *action = qobject_cast<QAction *>(sender());
786 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
788 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
789 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
790 if (!clipUrl.isEmpty()) {
791 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
795 void MainWindow::saveProperties(KConfigGroup &config)
797 // save properties here,used by session management
799 KMainWindow::saveProperties(config);
803 void MainWindow::readProperties(const KConfigGroup &config)
805 // read properties here,used by session management
806 KMainWindow::readProperties(config);
807 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
808 openFile(KUrl(Lastproject));
811 void MainWindow::slotReloadEffects()
813 initEffects::parseCustomEffectsFile();
814 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
817 #ifdef USE_JOGSHUTTLE
818 void MainWindow::activateShuttleDevice()
824 if (KdenliveSettings::enableshuttle() == false) return;
826 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
827 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
829 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
830 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
831 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
832 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
833 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
835 #endif /* USE_JOGSHUTTLE */
837 void MainWindow::slotDoAction(const QString& action_name)
839 QAction* action = actionCollection()->action(action_name);
841 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
847 void MainWindow::configureNotifications()
849 KNotifyConfigWidget::configure(this);
852 void MainWindow::slotFullScreen()
854 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
857 void MainWindow::slotAddEffect(const QDomElement effect)
859 if (!m_activeDocument) return;
860 if (effect.isNull()) {
861 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
864 QDomElement effectToAdd = effect.cloneNode().toElement();
866 int ix = m_effectStack->isTrackMode(&ok);
867 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
868 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
871 void MainWindow::slotUpdateClip(const QString &id)
873 if (!m_activeDocument) return;
874 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
876 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
877 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
878 Mlt::Producer *monitorProducer = clip->getCloneProducer();
879 m_clipMonitor->updateClipProducer(monitorProducer);
881 clip->cleanupProducers();
884 void MainWindow::slotConnectMonitors()
886 m_projectList->setRenderer(m_projectMonitor->render);
887 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
888 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
889 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
890 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
891 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
892 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)));
894 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
896 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
898 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
900 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
901 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
903 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
905 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
906 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
909 void MainWindow::slotAdjustClipMonitor()
911 m_clipMonitorDock->updateGeometry();
912 m_clipMonitorDock->adjustSize();
913 m_clipMonitor->resetSize();
916 void MainWindow::slotAdjustProjectMonitor()
918 m_projectMonitorDock->updateGeometry();
919 m_projectMonitorDock->adjustSize();
920 m_projectMonitor->resetSize();
924 class NameGrabbingKActionCollection {
926 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
927 : m_collection(collection), m_action_names(action_names) {
928 m_action_names.clear();
930 KAction* addAction(const QString& action_name) {
931 m_action_names << action_name;
932 return m_collection->addAction(action_name);
934 void addAction(const QString& action_name, QAction* action) {
935 m_action_names << action_name;
936 m_collection->addAction(action_name, action);
938 operator KActionCollection*() { return m_collection; }
939 const QStringList& actionNames() const { return m_action_names; }
941 KActionCollection* m_collection;
942 QStringList& m_action_names;
945 void MainWindow::setupActions()
948 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
949 m_timecodeFormat = new KComboBox(this);
950 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
951 m_timecodeFormat->addItem(i18n("Frames"));
952 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
953 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
955 m_statusProgressBar = new QProgressBar(this);
956 m_statusProgressBar->setMinimum(0);
957 m_statusProgressBar->setMaximum(100);
958 m_statusProgressBar->setMaximumWidth(150);
959 m_statusProgressBar->setVisible(false);
961 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
962 toolbar->setMovable(false);
964 setStatusBarStyleSheet(palette());
965 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
967 //create edit mode buttons
968 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
969 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
970 toolbar->addAction(m_normalEditTool);
971 m_normalEditTool->setCheckable(true);
972 m_normalEditTool->setChecked(true);
974 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
975 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
976 toolbar->addAction(m_overwriteEditTool);
977 m_overwriteEditTool->setCheckable(true);
978 m_overwriteEditTool->setChecked(false);
980 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
981 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
982 toolbar->addAction(m_insertEditTool);
983 m_insertEditTool->setCheckable(true);
984 m_insertEditTool->setChecked(false);
985 // not implemented yet
986 m_insertEditTool->setEnabled(false);
988 QActionGroup *editGroup = new QActionGroup(this);
989 editGroup->addAction(m_normalEditTool);
990 editGroup->addAction(m_overwriteEditTool);
991 editGroup->addAction(m_insertEditTool);
992 editGroup->setExclusive(true);
993 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
994 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
996 toolbar->addSeparator();
998 // create tools buttons
999 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1000 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1001 toolbar->addAction(m_buttonSelectTool);
1002 m_buttonSelectTool->setCheckable(true);
1003 m_buttonSelectTool->setChecked(true);
1005 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1006 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1007 toolbar->addAction(m_buttonRazorTool);
1008 m_buttonRazorTool->setCheckable(true);
1009 m_buttonRazorTool->setChecked(false);
1011 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1012 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1013 toolbar->addAction(m_buttonSpacerTool);
1014 m_buttonSpacerTool->setCheckable(true);
1015 m_buttonSpacerTool->setChecked(false);
1017 QActionGroup *toolGroup = new QActionGroup(this);
1018 toolGroup->addAction(m_buttonSelectTool);
1019 toolGroup->addAction(m_buttonRazorTool);
1020 toolGroup->addAction(m_buttonSpacerTool);
1021 toolGroup->setExclusive(true);
1022 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1024 QWidget * actionWidget;
1025 int max = toolbar->iconSizeDefault() + 2;
1026 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1027 actionWidget->setMaximumWidth(max);
1028 actionWidget->setMaximumHeight(max - 4);
1030 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1031 actionWidget->setMaximumWidth(max);
1032 actionWidget->setMaximumHeight(max - 4);
1034 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1035 actionWidget->setMaximumWidth(max);
1036 actionWidget->setMaximumHeight(max - 4);
1038 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1039 actionWidget->setMaximumWidth(max);
1040 actionWidget->setMaximumHeight(max - 4);
1042 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1043 actionWidget->setMaximumWidth(max);
1044 actionWidget->setMaximumHeight(max - 4);
1046 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1047 actionWidget->setMaximumWidth(max);
1048 actionWidget->setMaximumHeight(max - 4);
1050 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1052 toolbar->addSeparator();
1053 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1054 toolbar->addAction(m_buttonFitZoom);
1055 m_buttonFitZoom->setCheckable(false);
1057 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1058 toolbar->addAction(m_zoomOut);
1059 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1061 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1062 m_zoomSlider->setMaximum(13);
1063 m_zoomSlider->setPageStep(1);
1064 m_zoomSlider->setInvertedAppearance(true);
1066 m_zoomSlider->setMaximumWidth(150);
1067 m_zoomSlider->setMinimumWidth(100);
1068 toolbar->addWidget(m_zoomSlider);
1070 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1071 toolbar->addAction(m_zoomIn);
1072 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1074 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1075 actionWidget->setMaximumWidth(max);
1076 actionWidget->setMaximumHeight(max - 4);
1077 actionWidget->setStyleSheet(styleBorderless);
1079 actionWidget = toolbar->widgetForAction(m_zoomIn);
1080 actionWidget->setMaximumWidth(max);
1081 actionWidget->setMaximumHeight(max - 4);
1082 actionWidget->setStyleSheet(styleBorderless);
1084 actionWidget = toolbar->widgetForAction(m_zoomOut);
1085 actionWidget->setMaximumWidth(max);
1086 actionWidget->setMaximumHeight(max - 4);
1087 actionWidget->setStyleSheet(styleBorderless);
1089 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1090 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1091 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1092 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1093 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1095 toolbar->addSeparator();
1097 //create automatic audio split button
1098 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1099 toolbar->addAction(m_buttonAutomaticSplitAudio);
1100 m_buttonAutomaticSplitAudio->setCheckable(true);
1101 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1102 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1104 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1105 toolbar->addAction(m_buttonVideoThumbs);
1106 m_buttonVideoThumbs->setCheckable(true);
1107 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1108 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1110 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1111 toolbar->addAction(m_buttonAudioThumbs);
1112 m_buttonAudioThumbs->setCheckable(true);
1113 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1114 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1116 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1117 toolbar->addAction(m_buttonShowMarkers);
1118 m_buttonShowMarkers->setCheckable(true);
1119 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1120 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1122 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1123 toolbar->addAction(m_buttonSnap);
1124 m_buttonSnap->setCheckable(true);
1125 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1126 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1128 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1129 actionWidget->setMaximumWidth(max);
1130 actionWidget->setMaximumHeight(max - 4);
1132 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1133 actionWidget->setMaximumWidth(max);
1134 actionWidget->setMaximumHeight(max - 4);
1136 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1137 actionWidget->setMaximumWidth(max);
1138 actionWidget->setMaximumHeight(max - 4);
1140 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1141 actionWidget->setMaximumWidth(max);
1142 actionWidget->setMaximumHeight(max - 4);
1144 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1145 actionWidget->setMaximumWidth(max);
1146 actionWidget->setMaximumHeight(max - 4);
1148 m_messageLabel = new StatusBarMessageLabel(this);
1149 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1151 statusBar()->addWidget(m_messageLabel, 10);
1152 statusBar()->addWidget(m_statusProgressBar, 0);
1153 statusBar()->addPermanentWidget(toolbar);
1154 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1155 statusBar()->addPermanentWidget(m_timecodeFormat);
1156 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1158 collection.addAction("normal_mode", m_normalEditTool);
1159 collection.addAction("overwrite_mode", m_overwriteEditTool);
1160 collection.addAction("insert_mode", m_insertEditTool);
1161 collection.addAction("select_tool", m_buttonSelectTool);
1162 collection.addAction("razor_tool", m_buttonRazorTool);
1163 collection.addAction("spacer_tool", m_buttonSpacerTool);
1165 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1166 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1167 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1168 collection.addAction("show_markers", m_buttonShowMarkers);
1169 collection.addAction("snap", m_buttonSnap);
1170 collection.addAction("zoom_fit", m_buttonFitZoom);
1171 collection.addAction("zoom_in", m_zoomIn);
1172 collection.addAction("zoom_out", m_zoomOut);
1174 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1175 collection.addAction("project_find", m_projectSearch);
1176 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1177 m_projectSearch->setShortcut(Qt::Key_Slash);
1179 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1180 collection.addAction("project_find_next", m_projectSearchNext);
1181 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1182 m_projectSearchNext->setShortcut(Qt::Key_F3);
1183 m_projectSearchNext->setEnabled(false);
1185 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1186 collection.addAction("manage_profiles", profilesAction);
1187 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1189 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1190 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1191 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1192 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1194 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1195 collection.addAction("run_wizard", wizAction);
1196 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1198 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1199 collection.addAction("project_settings", projectAction);
1200 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1202 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1203 collection.addAction("open_backup", backupAction);
1204 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1206 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1207 collection.addAction("project_render", projectRender);
1208 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1209 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1211 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1212 collection.addAction("project_clean", projectClean);
1213 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1215 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1216 collection.addAction("project_adjust_profile", projectAdjust);
1217 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1219 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1220 KShortcut playShortcut;
1221 playShortcut.setPrimary(Qt::Key_Space);
1222 playShortcut.setAlternate(Qt::Key_K);
1223 monitorPlay->setShortcut(playShortcut);
1224 collection.addAction("monitor_play", monitorPlay);
1225 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1227 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1228 collection.addAction("monitor_pause", monitorPause);
1229 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1231 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1232 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1233 collection.addAction("monitor_play_zone", m_playZone);
1234 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1236 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1237 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1238 collection.addAction("monitor_loop_zone", m_loopZone);
1239 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1241 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1242 m_loopClip->setEnabled(false);
1243 collection.addAction("monitor_loop_clip", m_loopClip);
1244 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1246 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1247 collection.addAction("dvd_wizard", dvdWizard);
1248 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1250 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1251 collection.addAction("transcode_clip", transcodeClip);
1252 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1254 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1255 collection.addAction("archive_project", archiveProject);
1256 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1259 KAction *markIn = collection.addAction("mark_in");
1260 markIn->setText(i18n("Set Zone In"));
1261 markIn->setShortcut(Qt::Key_I);
1262 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1264 KAction *markOut = collection.addAction("mark_out");
1265 markOut->setText(i18n("Set Zone Out"));
1266 markOut->setShortcut(Qt::Key_O);
1267 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1269 KAction *switchMon = collection.addAction("switch_monitor");
1270 switchMon->setText(i18n("Switch monitor"));
1271 switchMon->setShortcut(Qt::Key_T);
1272 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1274 KAction *fullMon = collection.addAction("monitor_fullscreen");
1275 fullMon->setText(i18n("Switch monitor fullscreen"));
1276 fullMon->setIcon(KIcon("view-fullscreen"));
1277 connect(fullMon, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotSwitchFullscreen()));
1279 KAction *insertTree = collection.addAction("insert_project_tree");
1280 insertTree->setText(i18n("Insert zone in project tree"));
1281 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1282 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1284 KAction *insertTimeline = collection.addAction("insert_timeline");
1285 insertTimeline->setText(i18n("Insert zone in timeline"));
1286 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1287 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1289 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1290 collection.addAction("resize_timeline_clip_start", resizeStart);
1291 resizeStart->setShortcut(Qt::Key_1);
1292 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1294 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1295 collection.addAction("resize_timeline_clip_end", resizeEnd);
1296 resizeEnd->setShortcut(Qt::Key_2);
1297 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1299 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1300 monitorSeekBackward->setShortcut(Qt::Key_J);
1301 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1302 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1304 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1305 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1306 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1307 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1309 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1310 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1311 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1312 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1314 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1315 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1316 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1317 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1319 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1320 monitorSeekForward->setShortcut(Qt::Key_L);
1321 collection.addAction("monitor_seek_forward", monitorSeekForward);
1322 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1324 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1325 clipStart->setShortcut(Qt::Key_Home);
1326 collection.addAction("seek_clip_start", clipStart);
1327 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1329 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1330 clipEnd->setShortcut(Qt::Key_End);
1331 collection.addAction("seek_clip_end", clipEnd);
1332 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1334 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1335 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1336 collection.addAction("seek_zone_start", zoneStart);
1337 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1339 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1340 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1341 collection.addAction("seek_zone_end", zoneEnd);
1342 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1344 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1345 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1346 collection.addAction("seek_start", projectStart);
1347 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1349 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1350 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1351 collection.addAction("seek_end", projectEnd);
1352 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1354 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1355 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1356 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1357 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1359 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1360 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1361 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1362 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1364 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1365 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1366 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1367 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1369 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1370 deleteItem->setShortcut(Qt::Key_Delete);
1371 collection.addAction("delete_timeline_clip", deleteItem);
1372 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1374 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1375 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1376 editTimelineClipSpeed->setData("change_speed");
1377 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1379 KAction *stickTransition = collection.addAction("auto_transition");
1380 stickTransition->setData(QString("auto"));
1381 stickTransition->setCheckable(true);
1382 stickTransition->setEnabled(false);
1383 stickTransition->setText(i18n("Automatic Transition"));
1384 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1386 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1387 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1388 collection.addAction("group_clip", groupClip);
1389 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1391 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1392 collection.addAction("ungroup_clip", ungroupClip);
1393 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1394 ungroupClip->setData("ungroup_clip");
1395 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1397 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1398 collection.addAction("edit_item_duration", editItemDuration);
1399 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1401 KAction* saveTimelineClip = new KAction(KIcon("document-save"), i18n("Save clip"), this);
1402 collection.addAction("save_timeline_clip", saveTimelineClip);
1403 connect(saveTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSaveTimelineClip()));
1405 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1406 collection.addAction("clip_in_project_tree", clipInProjectTree);
1407 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1409 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1410 collection.addAction("clip_to_project_tree", clipToProjectTree);
1411 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1413 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1414 insertOvertwrite->setShortcut(Qt::Key_V);
1415 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1416 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1418 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1419 selectTimelineClip->setShortcut(Qt::Key_Plus);
1420 collection.addAction("select_timeline_clip", selectTimelineClip);
1421 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1423 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1424 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1425 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1426 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1428 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1429 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1430 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1431 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1433 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1434 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1435 collection.addAction("select_timeline_transition", selectTimelineTransition);
1436 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1438 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1439 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1440 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1441 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1443 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1444 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1445 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1446 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1448 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1449 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1450 collection.addAction("cut_timeline_clip", cutTimelineClip);
1451 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1453 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1454 collection.addAction("add_clip_marker", addClipMarker);
1455 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1457 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1458 collection.addAction("delete_clip_marker", deleteClipMarker);
1459 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1461 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1462 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1463 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1465 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1466 editClipMarker->setData(QString("edit_marker"));
1467 collection.addAction("edit_clip_marker", editClipMarker);
1468 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1470 KAction* addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1471 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1472 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1473 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1475 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1476 collection.addAction("split_audio", splitAudio);
1477 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1479 KAction* setAudioAlignReference = new KAction(i18n("Set Audio Reference"), this);
1480 collection.addAction("set_audio_align_ref", setAudioAlignReference);
1481 connect(setAudioAlignReference, SIGNAL(triggered()), this, SLOT(slotSetAudioAlignReference()));
1483 KAction* alignAudio = new KAction(i18n("Align Audio to Reference"), this);
1484 collection.addAction("align_audio", alignAudio);
1485 connect(alignAudio, SIGNAL(triggered()), this, SLOT(slotAlignAudio()));
1487 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1488 collection.addAction("clip_audio_only", audioOnly);
1489 audioOnly->setData("clip_audio_only");
1490 audioOnly->setCheckable(true);
1492 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1493 collection.addAction("clip_video_only", videoOnly);
1494 videoOnly->setData("clip_video_only");
1495 videoOnly->setCheckable(true);
1497 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1498 collection.addAction("clip_audio_and_video", audioAndVideo);
1499 audioAndVideo->setData("clip_audio_and_video");
1500 audioAndVideo->setCheckable(true);
1502 m_clipTypeGroup = new QActionGroup(this);
1503 m_clipTypeGroup->addAction(audioOnly);
1504 m_clipTypeGroup->addAction(videoOnly);
1505 m_clipTypeGroup->addAction(audioAndVideo);
1506 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1507 m_clipTypeGroup->setEnabled(false);
1509 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1510 collection.addAction("insert_space", insertSpace);
1511 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1513 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1514 collection.addAction("delete_space", removeSpace);
1515 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1517 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1518 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1520 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1521 m_tracksActionCollection->addAction("insert_track", insertTrack);
1522 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1524 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1525 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1526 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1528 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1529 m_tracksActionCollection->addAction("config_tracks", configTracks);
1530 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1532 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1533 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1534 m_tracksActionCollection->addAction("select_track", selectTrack);
1536 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1537 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1538 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1540 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1541 collection.addAction("add_guide", addGuide);
1542 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1544 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1545 collection.addAction("delete_guide", delGuide);
1546 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1548 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1549 collection.addAction("edit_guide", editGuide);
1550 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1552 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1553 collection.addAction("delete_all_guides", delAllGuides);
1554 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1556 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1557 collection.addAction("paste_effects", pasteEffects);
1558 pasteEffects->setData("paste_effects");
1559 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1561 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1562 collection.addAction("show_timeline", showTimeline);
1563 showTimeline->setCheckable(true);
1564 showTimeline->setChecked(true);
1565 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1567 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1568 collection.addAction("show_titlebars", showTitleBar);
1569 showTitleBar->setCheckable(true);
1570 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1571 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1572 slotShowTitleBars(KdenliveSettings::showtitlebars());
1574 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1575 KStandardAction::quit(this, SLOT(close()), collection);
1576 KStandardAction::open(this, SLOT(openFile()), collection);
1577 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1578 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1579 KStandardAction::openNew(this, SLOT(newFile()), collection);
1580 // TODO: make the following connection to slotEditKeys work
1581 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1582 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1583 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1584 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1585 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1586 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1588 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1589 undo->setEnabled(false);
1590 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1592 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1593 redo->setEnabled(false);
1594 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1597 //TODO: Add status tooltip to actions ?
1598 connect(collection, SIGNAL(actionHovered(QAction*)),
1599 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1602 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1603 collection.addAction("add_clip", addClip);
1604 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1606 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1607 collection.addAction("add_color_clip", addColorClip);
1608 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1610 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1611 collection.addAction("add_slide_clip", addSlideClip);
1612 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1614 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1615 collection.addAction("add_text_clip", addTitleClip);
1616 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1618 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1619 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1620 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1622 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1623 collection.addAction("add_folder", addFolderButton);
1624 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1626 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1627 collection.addAction("download_resource", downloadResources);
1628 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1630 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1631 collection.addAction("clip_properties", clipProperties);
1632 clipProperties->setData("clip_properties");
1633 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1634 clipProperties->setEnabled(false);
1636 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1637 collection.addAction("edit_clip", openClip);
1638 openClip->setData("edit_clip");
1639 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1640 openClip->setEnabled(false);
1642 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1643 collection.addAction("delete_clip", deleteClip);
1644 deleteClip->setData("delete_clip");
1645 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1646 deleteClip->setEnabled(false);
1648 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1649 collection.addAction("reload_clip", reloadClip);
1650 reloadClip->setData("reload_clip");
1651 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1652 reloadClip->setEnabled(false);
1654 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1655 collection.addAction("proxy_clip", proxyClip);
1656 proxyClip->setData("proxy_clip");
1657 proxyClip->setCheckable(true);
1658 proxyClip->setChecked(false);
1659 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1661 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1662 collection.addAction("stopmotion", stopMotion);
1663 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1665 QMenu *addClips = new QMenu();
1666 addClips->addAction(addClip);
1667 addClips->addAction(addColorClip);
1668 addClips->addAction(addSlideClip);
1669 addClips->addAction(addTitleClip);
1670 addClips->addAction(addTitleTemplateClip);
1671 addClips->addAction(addFolderButton);
1672 addClips->addAction(downloadResources);
1674 addClips->addAction(reloadClip);
1675 addClips->addAction(proxyClip);
1676 addClips->addAction(clipProperties);
1677 addClips->addAction(openClip);
1678 addClips->addAction(deleteClip);
1679 m_projectList->setupMenu(addClips, addClip);
1681 // Setup effects and transitions actions.
1682 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1683 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1684 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1685 m_transitions = new KAction*[transitions.count()];
1686 for (int i = 0; i < transitions.count(); i++) {
1687 QStringList effectInfo = transitions.effectIdInfo(i);
1688 m_transitions[i] = new KAction(effectInfo.at(0), this);
1689 m_transitions[i]->setData(effectInfo);
1690 m_transitions[i]->setIconVisibleInMenu(false);
1691 QString id = effectInfo.at(2);
1692 if (id.isEmpty()) id = effectInfo.at(1);
1693 transitionActions->addAction("transition_" + id, m_transitions[i]);
1695 //m_effectsActionCollection->readSettings();
1699 void MainWindow::slotDisplayActionMessage(QAction *a)
1701 statusBar()->showMessage(a->data().toString(), 3000);
1704 void MainWindow::setStatusBarStyleSheet(const QPalette &p)
1706 KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
1707 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
1708 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
1709 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
1710 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
1711 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());
1712 statusBar()->setStyleSheet(style1);
1715 void MainWindow::loadLayouts()
1717 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1718 if (m_loadLayout == NULL || saveLayout == NULL) return;
1719 KSharedConfigPtr config = KGlobal::config();
1720 KConfigGroup layoutGroup(config, "Layouts");
1721 QStringList entries = layoutGroup.keyList();
1722 QList<QAction *> loadActions = m_loadLayout->actions();
1723 QList<QAction *> saveActions = saveLayout->actions();
1724 for (int i = 1; i < 5; i++) {
1725 // Rename the layouts actions
1726 foreach(const QString & key, entries) {
1727 if (key.endsWith(QString("_%1").arg(i))) {
1728 // Found previously saved layout
1729 QString layoutName = key.section("_", 0, -2);
1730 for (int j = 0; j < loadActions.count(); j++) {
1731 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1732 loadActions[j]->setText(layoutName);
1733 loadActions[j]->setData(key);
1737 for (int j = 0; j < saveActions.count(); j++) {
1738 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1739 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1740 saveActions[j]->setData(key);
1749 void MainWindow::slotLoadLayout(QAction *action)
1751 if (!action) return;
1752 QString layoutId = action->data().toString();
1753 if (layoutId.isEmpty()) return;
1754 KSharedConfigPtr config = KGlobal::config();
1755 KConfigGroup layouts(config, "Layouts");
1756 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1757 restoreState(state);
1760 void MainWindow::slotSaveLayout(QAction *action)
1762 QString originallayoutName = action->data().toString();
1763 int layoutId = originallayoutName.section('_', -1).toInt();
1765 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1766 if (layoutName.isEmpty()) return;
1767 KSharedConfigPtr config = KGlobal::config();
1768 KConfigGroup layouts(config, "Layouts");
1769 layouts.deleteEntry(originallayoutName);
1771 QByteArray st = saveState();
1772 layoutName.append("_" + QString::number(layoutId));
1773 layouts.writeEntry(layoutName, st.toBase64());
1777 void MainWindow::saveOptions()
1779 KdenliveSettings::self()->writeConfig();
1780 KSharedConfigPtr config = KGlobal::config();
1781 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1782 KConfigGroup treecolumns(config, "Project Tree");
1783 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1787 void MainWindow::readOptions()
1789 KSharedConfigPtr config = KGlobal::config();
1790 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1791 KConfigGroup initialGroup(config, "version");
1792 bool upgrade = false;
1793 if (initialGroup.exists()) {
1794 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1798 if (initialGroup.readEntry("version") == "0.7") {
1799 //Add new settings from 0.7.1
1800 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1801 QString path = QDir::homePath() + "/kdenlive";
1802 if (KStandardDirs::makeDir(path) == false) {
1803 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1804 } else KdenliveSettings::setDefaultprojectfolder(path);
1810 if (!initialGroup.exists() || upgrade) {
1811 // this is our first run, show Wizard
1812 Wizard *w = new Wizard(upgrade, this);
1813 if (w->exec() == QDialog::Accepted && w->isOk()) {
1814 w->adjustSettings();
1815 initialGroup.writeEntry("version", version);
1821 KConfigGroup treecolumns(config, "Project Tree");
1822 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1823 if (!state.isEmpty())
1824 m_projectList->setHeaderInfo(state);
1827 void MainWindow::slotRunWizard()
1829 Wizard *w = new Wizard(false, this);
1830 if (w->exec() == QDialog::Accepted && w->isOk()) {
1831 w->adjustSettings();
1836 void MainWindow::newFile(bool showProjectSettings, bool force)
1838 if (!m_timelineArea->isEnabled() && !force)
1840 m_fileRevert->setEnabled(false);
1841 QString profileName = KdenliveSettings::default_profile();
1842 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1843 QMap <QString, QString> documentProperties;
1844 QMap <QString, QString> documentMetadata;
1845 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1846 if (!showProjectSettings) {
1847 if (!KdenliveSettings::activatetabs())
1848 if (!closeCurrentDocument())
1851 ProjectSettings *w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1852 if (w->exec() != QDialog::Accepted)
1854 if (!KdenliveSettings::activatetabs())
1855 if (!closeCurrentDocument())
1857 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1858 slotSwitchVideoThumbs();
1859 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1860 slotSwitchAudioThumbs();
1861 profileName = w->selectedProfile();
1862 projectFolder = w->selectedFolder();
1863 projectTracks = w->tracks();
1864 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1865 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1866 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1867 documentProperties.insert("proxyparams", w->proxyParams());
1868 documentProperties.insert("proxyextension", w->proxyExtension());
1869 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1870 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1871 documentMetadata = w->metadata();
1874 m_timelineArea->setEnabled(true);
1875 m_projectList->setEnabled(true);
1877 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1878 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1880 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
1881 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1884 //m_timelineArea->setEnabled(false);
1885 //m_projectList->setEnabled(false);
1889 if (m_timelineArea->count() == 1) {
1890 connectDocumentInfo(doc);
1891 connectDocument(trackView, doc);
1893 m_timelineArea->setTabBarHidden(false);
1894 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
1895 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1898 void MainWindow::activateDocument()
1900 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1901 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1902 KdenliveDoc *currentDoc = currentTab->document();
1903 connectDocumentInfo(currentDoc);
1904 connectDocument(currentTab, currentDoc);
1907 bool MainWindow::closeCurrentDocument(bool saveChanges)
1909 QWidget *w = m_timelineArea->currentWidget();
1910 if (!w) return true;
1911 // closing current document
1912 int ix = m_timelineArea->currentIndex() + 1;
1913 if (ix == m_timelineArea->count()) ix = 0;
1914 m_timelineArea->setCurrentIndex(ix);
1915 TrackView *tabToClose = (TrackView *) w;
1916 KdenliveDoc *docToClose = tabToClose->document();
1917 if (docToClose && docToClose->isModified() && saveChanges) {
1919 if (m_activeDocument->url().fileName().isEmpty())
1920 message = i18n("Save changes to document?");
1922 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1923 switch (KMessageBox::warningYesNoCancel(this, message)) {
1924 case KMessageBox::Yes :
1925 // save document here. If saving fails, return false;
1926 if (saveFile() == false) return false;
1928 case KMessageBox::Cancel :
1935 m_clipMonitor->slotSetClipProducer(NULL);
1936 m_projectList->slotResetProjectList();
1937 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1938 if (m_timelineArea->count() == 1) {
1939 m_timelineArea->setTabBarHidden(true);
1940 m_closeAction->setEnabled(false);
1942 if (docToClose == m_activeDocument) {
1943 delete m_activeDocument;
1944 m_activeDocument = NULL;
1945 m_effectStack->clear();
1946 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1950 if (w == m_activeTimeline) {
1951 delete m_activeTimeline;
1952 m_activeTimeline = NULL;
1959 bool MainWindow::saveFileAs(const QString &outputFileName)
1961 QString currentSceneList;
1962 m_monitorManager->stopActiveMonitor();
1964 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1967 // Save timeline thumbnails
1968 m_activeTimeline->projectView()->saveThumbnails();
1969 m_activeDocument->setUrl(KUrl(outputFileName));
1970 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
1971 if (m_activeDocument->m_autosave == NULL) {
1972 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
1973 } else m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
1974 setCaption(m_activeDocument->description());
1975 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1976 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1977 m_activeDocument->setModified(false);
1978 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1979 m_fileRevert->setEnabled(true);
1980 m_undoView->stack()->setClean();
1984 bool MainWindow::saveFileAs()
1986 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1987 if (outputFile.isEmpty()) {
1990 if (QFile::exists(outputFile)) {
1991 // Show the file dialog again if the user does not want to overwrite the file
1992 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1993 return saveFileAs();
1995 return saveFileAs(outputFile);
1998 bool MainWindow::saveFile()
2000 if (!m_activeDocument) return true;
2001 if (m_activeDocument->url().isEmpty()) {
2002 return saveFileAs();
2004 bool result = saveFileAs(m_activeDocument->url().path());
2005 m_activeDocument->m_autosave->resize(0);
2010 void MainWindow::openFile()
2012 if (!m_startUrl.isEmpty()) {
2013 openFile(m_startUrl);
2014 m_startUrl = KUrl();
2017 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2018 if (url.isEmpty()) return;
2019 m_fileOpenRecent->addUrl(url);
2023 void MainWindow::openLastFile()
2025 KSharedConfigPtr config = KGlobal::config();
2026 KUrl::List urls = m_fileOpenRecent->urls();
2027 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2028 if (urls.isEmpty()) newFile(false);
2029 else openFile(urls.last());
2032 void MainWindow::openFile(const KUrl &url)
2034 // Make sure the url is a Kdenlive project file
2035 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2036 if (mime.data()->is("application/x-compressed-tar")) {
2037 // Opening a compressed project file, we need to process it
2038 kDebug()<<"Opening archive, processing";
2039 ArchiveWidget *ar = new ArchiveWidget(url);
2040 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2044 if (!url.fileName().endsWith(".kdenlive")) {
2045 // This is not a Kdenlive project file, abort loading
2046 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2050 // Check if the document is already opened
2051 const int ct = m_timelineArea->count();
2052 bool isOpened = false;
2054 for (i = 0; i < ct; i++) {
2055 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2056 KdenliveDoc *doc = tab->document();
2057 if (doc->url() == url) {
2063 m_timelineArea->setCurrentIndex(i);
2067 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2069 // Check for backup file
2070 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2071 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2072 if (!staleFiles.isEmpty()) {
2073 if (KMessageBox::questionYesNo(this,
2074 i18n("Auto-saved files exist. Do you want to recover them now?"),
2075 i18n("File Recovery"),
2076 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2077 recoverFiles(staleFiles, url);
2080 // remove the stale files
2081 foreach(KAutoSaveFile * stale, staleFiles) {
2082 stale->open(QIODevice::ReadWrite);
2087 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2088 m_messageLabel->repaint();
2089 doOpenFile(url, NULL);
2092 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2094 if (!m_timelineArea->isEnabled()) return;
2095 m_fileRevert->setEnabled(true);
2097 // Recreate stopmotion widget on document change
2099 delete m_stopmotion;
2100 m_stopmotion = NULL;
2104 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2105 progressDialog.setAllowCancel(false);
2106 progressDialog.progressBar()->setMaximum(4);
2107 progressDialog.show();
2108 progressDialog.progressBar()->setValue(0);
2109 qApp->processEvents();
2112 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);
2114 progressDialog.progressBar()->setValue(1);
2115 progressDialog.progressBar()->setMaximum(4);
2116 progressDialog.setLabelText(i18n("Loading project"));
2117 qApp->processEvents();
2119 if (stale == NULL) {
2120 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2121 stale = new KAutoSaveFile(KUrl(hash), doc);
2122 doc->m_autosave = stale;
2124 doc->m_autosave = stale;
2125 doc->setUrl(url);//stale->managedFile());
2126 doc->setModified(true);
2127 stale->setParent(doc);
2129 connectDocumentInfo(doc);
2131 progressDialog.progressBar()->setValue(2);
2132 qApp->processEvents();
2135 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2136 connectDocument(trackView, doc);
2137 progressDialog.progressBar()->setValue(3);
2138 qApp->processEvents();
2140 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2142 m_timelineArea->setEnabled(false);
2143 m_projectList->setEnabled(false);
2144 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2145 slotGotProgressInfo(QString(), -1);
2146 newFile(false, true);
2149 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2150 trackView->setDuration(trackView->duration());
2151 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2153 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2154 slotGotProgressInfo(QString(), -1);
2155 m_projectMonitor->adjustRulerSize(trackView->duration());
2156 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2157 progressDialog.progressBar()->setValue(4);
2158 if (openBackup) slotOpenBackupDialog(url);
2161 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl)
2163 foreach(KAutoSaveFile * stale, staleFiles) {
2164 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2165 // show an error message; we could not steal the lockfile
2166 // maybe another application got to the file before us?
2170 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2171 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2172 if (!stale->fileName().endsWith(".lock")) doOpenFile(originUrl, stale);
2173 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2177 void MainWindow::parseProfiles(const QString &mltPath)
2179 //KdenliveSettings::setDefaulttmpfolder();
2180 if (!mltPath.isEmpty()) {
2181 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2182 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2185 if (KdenliveSettings::mltpath().isEmpty())
2186 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2188 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2189 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2190 if (!QFile::exists(meltPath))
2191 meltPath = KStandardDirs::findExe("melt");
2192 KdenliveSettings::setRendererpath(meltPath);
2195 if (KdenliveSettings::rendererpath().isEmpty()) {
2196 // Cannot find the MLT melt renderer, ask for location
2197 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2198 if (getUrl->exec() == QDialog::Rejected) {
2201 KUrl rendererPath = getUrl->selectedUrl();
2203 if (rendererPath.isEmpty()) ::exit(0);
2204 KdenliveSettings::setRendererpath(rendererPath.path());
2207 QStringList profilesFilter;
2208 profilesFilter << "*";
2209 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2210 if (profilesList.isEmpty()) {
2211 // Cannot find MLT path, try finding melt
2212 QString profilePath = KdenliveSettings::rendererpath();
2213 if (!profilePath.isEmpty()) {
2214 profilePath = profilePath.section('/', 0, -3);
2215 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2216 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2218 if (profilesList.isEmpty()) {
2219 // Cannot find the MLT profiles, ask for location
2220 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2221 getUrl->fileDialog()->setMode(KFile::Directory);
2222 if (getUrl->exec() == QDialog::Rejected) {
2225 KUrl mltPath = getUrl->selectedUrl();
2227 if (mltPath.isEmpty()) ::exit(0);
2228 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2229 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2233 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2235 // Parse again MLT profiles to build a list of available video formats
2236 if (profilesList.isEmpty()) parseProfiles();
2240 void MainWindow::slotEditProfiles()
2242 ProfilesDialog *w = new ProfilesDialog;
2243 if (w->exec() == QDialog::Accepted) {
2244 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2245 if (d) d->checkProfile();
2250 void MainWindow::slotDetectAudioDriver()
2252 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2253 leading to no audio output, see bug #934 */
2255 //decide which audio driver is really best, in some cases SDL is wrong
2256 if (KdenliveSettings::audiodrivername().isEmpty()) {
2258 KProcess readProcess;
2259 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2260 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2261 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2262 readProcess.setProgram("pactl", QStringList() << "stat");
2263 readProcess.execute(2000); // Kill it after 2 seconds
2265 QString result = QString(readProcess.readAllStandardOutput());
2266 kDebug() << "// / / / / / READING PACTL: ";
2268 if (!result.isEmpty()) {
2270 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2274 KdenliveSettings::setAutoaudiodrivername(driver);
2278 void MainWindow::slotEditProjectSettings()
2280 QPoint p = m_activeDocument->getTracksCount();
2281 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);
2282 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2284 if (w->exec() == QDialog::Accepted) {
2285 QString profile = w->selectedProfile();
2286 m_activeDocument->setProjectFolder(w->selectedFolder());
2288 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2290 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2291 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2292 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2293 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2294 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2295 m_activeDocument->setModified();
2296 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2297 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) {
2298 //TODO: rebuild all proxies
2299 //m_projectList->rebuildProxies();
2302 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2303 m_activeDocument->setModified();
2304 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2306 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2307 m_activeDocument->setModified();
2308 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2310 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2311 m_activeDocument->setModified();
2312 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2314 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2315 m_activeDocument->setModified();
2316 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2318 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2319 m_activeDocument->setModified();
2320 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2322 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2323 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2324 m_activeDocument->setModified();
2325 slotUpdateProxySettings();
2327 m_activeDocument->setMetadata(w->metadata());
2332 void MainWindow::slotDisableProxies()
2334 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2335 m_activeDocument->setModified();
2336 slotUpdateProxySettings();
2339 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2341 // Recreate the stopmotion widget if profile changes
2343 delete m_stopmotion;
2344 m_stopmotion = NULL;
2347 // Deselect current effect / transition
2348 m_effectStack->slotClipItemSelected(NULL);
2349 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2350 m_clipMonitor->slotSetClipProducer(NULL);
2351 bool updateFps = m_activeDocument->setProfilePath(profile);
2352 KdenliveSettings::setCurrent_profile(profile);
2353 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2354 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2356 m_activeDocument->clipManager()->clearUnusedProducers();
2357 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2358 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2359 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2360 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2361 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2362 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2363 if (updateFps) m_activeTimeline->updateProjectFps();
2364 m_activeDocument->clipManager()->clearCache();
2365 m_activeTimeline->updateProfile();
2366 m_activeDocument->setModified(true);
2367 m_commandStack->activeStack()->clear();
2368 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2369 slotUpdateMousePosition(0);
2370 // We need to desactivate & reactivate monitors to get a refresh
2371 //m_monitorManager->switchMonitors();
2375 void MainWindow::slotRenderProject()
2377 if (!m_renderWidget) {
2378 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2379 MltVideoProfile profile;
2380 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2381 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2382 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2383 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2384 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2385 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2386 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2387 if (m_activeDocument) {
2388 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2389 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2390 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2391 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2394 slotCheckRenderStatus();
2395 m_renderWidget->show();
2396 m_renderWidget->showNormal();
2398 // What are the following lines supposed to do?
2399 //m_activeTimeline->tracksNumber();
2400 //m_renderWidget->enableAudio(false);
2401 //m_renderWidget->export_audio;
2404 void MainWindow::slotCheckRenderStatus()
2406 // Make sure there are no missing clips
2408 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2411 void MainWindow::setRenderingProgress(const QString &url, int progress)
2414 m_renderWidget->setRenderJob(url, progress);
2417 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2420 m_renderWidget->setRenderStatus(url, status, error);
2423 void MainWindow::slotCleanProject()
2425 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2426 m_projectList->cleanup();
2429 void MainWindow::slotUpdateMousePosition(int pos)
2431 if (m_activeDocument)
2432 switch (m_timecodeFormat->currentIndex()) {
2434 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2437 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2441 void MainWindow::slotUpdateDocumentState(bool modified)
2443 if (!m_activeDocument) return;
2444 setCaption(m_activeDocument->description(), modified);
2445 m_saveAction->setEnabled(modified);
2447 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2448 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2450 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2451 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2455 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2457 if (m_activeDocument) {
2458 if (m_activeDocument == doc) return;
2459 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2461 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2464 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2466 //m_projectMonitor->stop();
2467 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2468 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2469 if (m_activeDocument) {
2470 if (m_activeDocument == doc) return;
2471 if (m_activeTimeline) {
2472 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2473 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2474 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2475 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2476 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2477 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2478 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2480 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2482 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2483 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2484 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2485 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2486 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2487 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2488 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
2489 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2490 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2491 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2492 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2493 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2494 disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2496 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
2497 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2498 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2499 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2500 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2501 disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2502 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, QList <int>, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, QList <int>, bool)));
2503 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, QList<int>, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, QList <int>, int)));
2504 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2505 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2506 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2507 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2508 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2509 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2510 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2511 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2512 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2513 m_effectStack->clear();
2515 //m_activeDocument->setRenderer(NULL);
2516 m_clipMonitor->stop();
2518 KdenliveSettings::setCurrent_profile(doc->profilePath());
2519 KdenliveSettings::setProject_fps(doc->fps());
2520 m_monitorManager->resetProfiles(doc->timecode());
2521 m_clipMonitorDock->raise();
2522 m_projectList->setDocument(doc);
2523 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2524 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2525 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2527 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2528 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2530 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2531 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2532 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2533 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2534 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2535 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2536 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2537 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2538 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2539 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2540 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2542 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2543 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2544 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2545 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2546 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2548 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2549 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2550 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2552 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2554 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2555 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotTrackSelected(int, TrackInfo)));
2557 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
2558 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2559 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2560 m_zoomSlider->setValue(doc->zoom().x());
2561 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2562 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2563 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2564 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2566 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2567 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2569 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2571 connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2573 // Effect stack signals
2574 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2575 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2576 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2577 connect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2578 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, QList <int>, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, QList <int>, bool)));
2579 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, QList <int>, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, QList <int>, int)));
2580 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2581 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2582 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2583 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2585 // Transition config signals
2586 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2587 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2589 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2590 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2591 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2592 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2593 m_activeTimeline = trackView;
2594 if (m_renderWidget) {
2595 slotCheckRenderStatus();
2596 m_renderWidget->setProfile(doc->mltProfile());
2597 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2598 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2599 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2601 //doc->setRenderer(m_projectMonitor->render);
2602 m_commandStack->setActiveStack(doc->commandStack());
2603 KdenliveSettings::setProject_display_ratio(doc->dar());
2604 //doc->clipManager()->checkAudioThumbs();
2606 //m_overView->setScene(trackView->projectScene());
2607 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2608 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2610 setCaption(doc->description(), doc->isModified());
2611 m_saveAction->setEnabled(doc->isModified());
2612 m_normalEditTool->setChecked(true);
2613 m_activeDocument = doc;
2614 m_activeTimeline->updateProjectFps();
2615 m_activeDocument->checkProjectClips();
2617 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2619 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2620 slotUpdateMousePosition(0);
2621 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
2622 // set tool to select tool
2623 m_buttonSelectTool->setChecked(true);
2626 void MainWindow::slotZoneMoved(int start, int end)
2628 m_activeDocument->setZone(start, end);
2629 m_projectMonitor->slotZoneMoved(start, end);
2632 void MainWindow::slotGuidesUpdated()
2635 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2638 void MainWindow::slotEditKeys()
2640 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2641 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2642 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2643 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2647 void MainWindow::slotPreferences(int page, int option)
2650 * An instance of your dialog could be already created and could be
2651 * cached, in which case you want to display the cached dialog
2652 * instead of creating another one
2654 if (m_stopmotion) m_stopmotion->slotLive(false);
2655 if (KConfigDialog::showDialog("settings")) {
2656 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2657 if (page != -1) d->showPage(page, option);
2661 // KConfigDialog didn't find an instance of this dialog, so lets
2664 // Get the mappable actions in localized form
2665 QMap<QString, QString> actions;
2666 KActionCollection* collection = actionCollection();
2667 foreach (const QString& action_name, m_action_names) {
2668 actions[collection->action(action_name)->text()] = action_name;
2671 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2672 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2673 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2675 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2678 if (page != -1) dialog->showPage(page, option);
2681 void MainWindow::slotUpdateCaptureFolder()
2685 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2686 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2690 void MainWindow::updateConfiguration()
2692 //TODO: we should apply settings to all projects, not only the current one
2693 if (m_activeTimeline) {
2694 m_activeTimeline->refresh();
2695 m_activeTimeline->projectView()->checkAutoScroll();
2696 m_activeTimeline->checkTrackHeight();
2697 if (m_activeDocument)
2698 m_activeDocument->clipManager()->checkAudioThumbs();
2700 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2701 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2702 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2703 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2705 // Update list of transcoding profiles
2708 #ifdef USE_JOGSHUTTLE
2709 activateShuttleDevice();
2714 void MainWindow::slotSwitchSplitAudio()
2716 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2717 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2720 void MainWindow::slotSwitchVideoThumbs()
2722 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2723 if (m_activeTimeline)
2724 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2725 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2728 void MainWindow::slotSwitchAudioThumbs()
2730 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2731 if (m_activeTimeline) {
2732 m_activeTimeline->refresh();
2733 m_activeTimeline->projectView()->checkAutoScroll();
2734 if (m_activeDocument)
2735 m_activeDocument->clipManager()->checkAudioThumbs();
2737 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2740 void MainWindow::slotSwitchMarkersComments()
2742 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2743 if (m_activeTimeline)
2744 m_activeTimeline->refresh();
2745 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2748 void MainWindow::slotSwitchSnap()
2750 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2751 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2755 void MainWindow::slotDeleteItem()
2757 if (QApplication::focusWidget() &&
2758 QApplication::focusWidget()->parentWidget() &&
2759 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2760 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2761 m_projectList->slotRemoveClip();
2764 QWidget *widget = QApplication::focusWidget();
2766 if (widget == m_effectStackDock) {
2767 m_effectStack->deleteCurrentEffect();
2770 widget = widget->parentWidget();
2773 // effect stack has no focus
2774 if (m_activeTimeline)
2775 m_activeTimeline->projectView()->deleteSelectedClips();
2779 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2781 if (m_clipMonitor->isActive())
2782 m_clipMonitor->checkOverlay();
2783 m_clipMonitor->updateMarkers(clip);
2786 void MainWindow::slotAddClipMarker()
2788 DocClipBase *clip = NULL;
2790 if (m_projectMonitor->isActive()) {
2791 if (m_activeTimeline) {
2792 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2794 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2795 clip = item->baseClip();
2799 clip = m_clipMonitor->activeClip();
2800 pos = m_clipMonitor->position();
2803 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2806 QString id = clip->getId();
2807 CommentedTime marker(pos, i18n("Marker"));
2808 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2809 if (d.exec() == QDialog::Accepted)
2810 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2813 void MainWindow::slotDeleteClipMarker()
2815 DocClipBase *clip = NULL;
2817 if (m_projectMonitor->isActive()) {
2818 if (m_activeTimeline) {
2819 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2821 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2822 clip = item->baseClip();
2826 clip = m_clipMonitor->activeClip();
2827 pos = m_clipMonitor->position();
2830 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2834 QString id = clip->getId();
2835 QString comment = clip->markerComment(pos);
2836 if (comment.isEmpty()) {
2837 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2840 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2843 void MainWindow::slotDeleteAllClipMarkers()
2845 DocClipBase *clip = NULL;
2846 if (m_projectMonitor->isActive()) {
2847 if (m_activeTimeline) {
2848 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2850 clip = item->baseClip();
2854 clip = m_clipMonitor->activeClip();
2857 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2860 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2863 void MainWindow::slotEditClipMarker()
2865 DocClipBase *clip = NULL;
2867 if (m_projectMonitor->isActive()) {
2868 if (m_activeTimeline) {
2869 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2871 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2872 clip = item->baseClip();
2876 clip = m_clipMonitor->activeClip();
2877 pos = m_clipMonitor->position();
2880 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2884 QString id = clip->getId();
2885 QString oldcomment = clip->markerComment(pos);
2886 if (oldcomment.isEmpty()) {
2887 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2891 CommentedTime marker(pos, oldcomment);
2892 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2893 if (d.exec() == QDialog::Accepted) {
2894 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2895 if (d.newMarker().time() != pos) {
2896 // remove old marker
2897 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2902 void MainWindow::slotAddMarkerGuideQuickly()
2904 if (!m_activeTimeline || !m_activeDocument)
2907 if (m_clipMonitor->isActive()) {
2908 DocClipBase *clip = m_clipMonitor->activeClip();
2909 GenTime pos = m_clipMonitor->position();
2912 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2916 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2918 m_activeTimeline->projectView()->slotAddGuide(false);
2922 void MainWindow::slotAddGuide()
2924 if (m_activeTimeline)
2925 m_activeTimeline->projectView()->slotAddGuide();
2928 void MainWindow::slotInsertSpace()
2930 if (m_activeTimeline)
2931 m_activeTimeline->projectView()->slotInsertSpace();
2934 void MainWindow::slotRemoveSpace()
2936 if (m_activeTimeline)
2937 m_activeTimeline->projectView()->slotRemoveSpace();
2940 void MainWindow::slotInsertTrack(int ix)
2942 m_projectMonitor->slotActivateMonitor();
2943 if (m_activeTimeline) {
2944 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2945 m_activeTimeline->projectView()->slotInsertTrack(ix);
2947 if (m_activeDocument)
2948 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2951 void MainWindow::slotDeleteTrack(int ix)
2953 m_projectMonitor->slotActivateMonitor();
2954 if (m_activeTimeline) {
2955 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2956 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2958 if (m_activeDocument)
2959 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2962 void MainWindow::slotConfigTrack(int ix)
2964 m_projectMonitor->slotActivateMonitor();
2965 if (m_activeTimeline)
2966 m_activeTimeline->projectView()->slotConfigTracks(ix);
2967 if (m_activeDocument)
2968 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2971 void MainWindow::slotSelectTrack()
2973 m_projectMonitor->slotActivateMonitor();
2974 if (m_activeTimeline) {
2975 m_activeTimeline->projectView()->slotSelectClipsInTrack();
2979 void MainWindow::slotSelectAllTracks()
2981 m_projectMonitor->slotActivateMonitor();
2982 if (m_activeTimeline)
2983 m_activeTimeline->projectView()->slotSelectAllClips();
2986 void MainWindow::slotEditGuide()
2988 if (m_activeTimeline)
2989 m_activeTimeline->projectView()->slotEditGuide();
2992 void MainWindow::slotDeleteGuide()
2994 if (m_activeTimeline)
2995 m_activeTimeline->projectView()->slotDeleteGuide();
2998 void MainWindow::slotDeleteAllGuides()
3000 if (m_activeTimeline)
3001 m_activeTimeline->projectView()->slotDeleteAllGuides();
3004 void MainWindow::slotCutTimelineClip()
3006 if (m_activeTimeline)
3007 m_activeTimeline->projectView()->cutSelectedClips();
3010 void MainWindow::slotInsertClipOverwrite()
3012 if (m_activeTimeline) {
3013 QStringList data = m_clipMonitor->getZoneInfo();
3014 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
3018 void MainWindow::slotSelectTimelineClip()
3020 if (m_activeTimeline)
3021 m_activeTimeline->projectView()->selectClip(true);
3024 void MainWindow::slotSelectTimelineTransition()
3026 if (m_activeTimeline)
3027 m_activeTimeline->projectView()->selectTransition(true);
3030 void MainWindow::slotDeselectTimelineClip()
3032 if (m_activeTimeline)
3033 m_activeTimeline->projectView()->selectClip(false, true);
3036 void MainWindow::slotDeselectTimelineTransition()
3038 if (m_activeTimeline)
3039 m_activeTimeline->projectView()->selectTransition(false, true);
3042 void MainWindow::slotSelectAddTimelineClip()
3044 if (m_activeTimeline)
3045 m_activeTimeline->projectView()->selectClip(true, true);
3048 void MainWindow::slotSelectAddTimelineTransition()
3050 if (m_activeTimeline)
3051 m_activeTimeline->projectView()->selectTransition(true, true);
3054 void MainWindow::slotGroupClips()
3056 if (m_activeTimeline)
3057 m_activeTimeline->projectView()->groupClips();
3060 void MainWindow::slotUnGroupClips()
3062 if (m_activeTimeline)
3063 m_activeTimeline->projectView()->groupClips(false);
3066 void MainWindow::slotEditItemDuration()
3068 if (m_activeTimeline)
3069 m_activeTimeline->projectView()->editItemDuration();
3072 void MainWindow::slotAddProjectClip(KUrl url, const QString &comment)
3074 if (m_activeDocument)
3075 m_activeDocument->slotAddClipFile(url, QString(), QString(), comment);
3078 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3080 if (m_activeDocument)
3081 m_activeDocument->slotAddClipList(urls, QString());
3084 void MainWindow::slotAddTransition(QAction *result)
3086 if (!result) return;
3087 QStringList info = result->data().toStringList();
3088 if (info.isEmpty()) return;
3089 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3090 if (m_activeTimeline && !transition.isNull()) {
3091 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3095 void MainWindow::slotAddVideoEffect(QAction *result)
3097 if (!result) return;
3098 const int EFFECT_VIDEO = 1;
3099 const int EFFECT_AUDIO = 2;
3100 QStringList info = result->data().toStringList();
3102 if (info.isEmpty() || info.size() < 3) return;
3103 QDomElement effect ;
3104 if (info.last() == QString::number((int) EFFECT_VIDEO))
3105 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3106 else if (info.last() == QString::number((int) EFFECT_AUDIO))
3107 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3109 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3110 if (!effect.isNull()) slotAddEffect(effect);
3111 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3115 void MainWindow::slotZoomIn()
3117 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3118 slotShowZoomSliderToolTip();
3121 void MainWindow::slotZoomOut()
3123 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3124 slotShowZoomSliderToolTip();
3127 void MainWindow::slotFitZoom()
3129 if (m_activeTimeline)
3130 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3133 void MainWindow::slotSetZoom(int value)
3135 value = qMax(m_zoomSlider->minimum(), value);
3136 value = qMin(m_zoomSlider->maximum(), value);
3138 if (m_activeTimeline)
3139 m_activeTimeline->slotChangeZoom(value);
3141 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3142 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3143 slotUpdateZoomSliderToolTip(value);
3145 m_zoomSlider->blockSignals(true);
3146 m_zoomSlider->setValue(value);
3147 m_zoomSlider->blockSignals(false);
3150 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3152 if (zoomlevel != -1)
3153 slotUpdateZoomSliderToolTip(zoomlevel);
3155 QPoint global = m_zoomSlider->rect().topLeft();
3156 global.ry() += m_zoomSlider->height() / 2;
3157 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3158 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3161 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3163 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3166 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3168 m_statusProgressBar->setValue(progress);
3169 if (progress >= 0) {
3170 if (!message.isEmpty())
3171 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3172 m_statusProgressBar->setVisible(true);
3173 } else if (progress == -2) {
3174 if (!message.isEmpty())
3175 m_messageLabel->setMessage(message, ErrorMessage);
3176 m_statusProgressBar->setVisible(false);
3178 m_messageLabel->setMessage(QString(), DefaultMessage);
3179 m_statusProgressBar->setVisible(false);
3183 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3185 if (clip->clipType() == TEXT) {
3186 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3187 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3188 // template text clip
3190 // Get the list of existing templates
3192 filter << "*.kdenlivetitle";
3193 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3195 QDialog *dia = new QDialog(this);
3196 Ui::TemplateClip_UI dia_ui;
3197 dia_ui.setupUi(dia);
3199 const QString templatePath = clip->getProperty("resource");
3200 for (int i = 0; i < templateFiles.size(); ++i) {
3201 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3202 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3204 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3205 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3206 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3207 //warning: setting base directory doesn't work??
3208 KUrl startDir(titlepath);
3209 dia_ui.template_list->fileDialog()->setUrl(startDir);
3210 dia_ui.description->setText(clip->getProperty("description"));
3211 if (dia->exec() == QDialog::Accepted) {
3212 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3213 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3215 QMap <QString, QString> newprops;
3217 if (KUrl(textTemplate).path() != templatePath) {
3218 // The template was changed
3219 newprops.insert("resource", textTemplate);
3222 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3223 newprops.insert("description", dia_ui.description->toPlainText());
3226 QString newtemplate = newprops.value("xmltemplate");
3227 if (newtemplate.isEmpty()) newtemplate = templatePath;
3229 // template modified we need to update xmldata
3230 QString description = newprops.value("description");
3231 if (description.isEmpty()) description = clip->getProperty("description");
3232 else newprops.insert("templatetext", description);
3233 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3234 if (!newprops.isEmpty()) {
3235 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3236 m_activeDocument->commandStack()->push(command);
3242 QString path = clip->getProperty("resource");
3243 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3245 doc.setContent(clip->getProperty("xmldata"));
3246 dia_ui->setXml(doc);
3247 if (dia_ui->exec() == QDialog::Accepted) {
3248 QMap <QString, QString> newprops;
3249 newprops.insert("xmldata", dia_ui->xml().toString());
3250 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3251 // duration changed, we need to update duration
3252 newprops.insert("out", QString::number(dia_ui->outPoint()));
3253 int currentLength = QString(clip->producerProperty("length")).toInt();
3254 if (currentLength <= dia_ui->outPoint())
3255 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3256 else newprops.insert("length", clip->producerProperty("length"));
3258 if (!path.isEmpty()) {
3259 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3260 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) {
3261 // save to external file
3262 dia_ui->saveTitle(path);
3263 } else newprops.insert("resource", QString());
3265 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3266 m_activeDocument->commandStack()->push(command);
3267 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3268 m_activeDocument->setModified(true);
3272 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3276 // any type of clip but a title
3277 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3278 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3279 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3280 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)));
3285 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3287 if (newprops.isEmpty()) return;
3288 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3289 m_activeDocument->commandStack()->push(command);
3290 m_activeDocument->setModified();
3293 // update clip occurences in timeline
3294 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3299 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3301 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3302 if (dia.exec() == QDialog::Accepted) {
3303 QUndoCommand *command = new QUndoCommand();
3304 command->setText(i18n("Edit clips"));
3305 QMap <QString, QString> newImageProps = dia.properties();
3306 // Transparency setting applies only for images
3307 QMap <QString, QString> newProps = newImageProps;
3308 newProps.remove("transparency");
3310 for (int i = 0; i < cliplist.count(); i++) {
3311 DocClipBase *clip = cliplist.at(i);
3312 if (clip->clipType() == IMAGE)
3313 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3315 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3317 m_activeDocument->commandStack()->push(command);
3318 for (int i = 0; i < cliplist.count(); i++)
3319 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3323 void MainWindow::customEvent(QEvent* e)
3325 if (e->type() == QEvent::User)
3326 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3329 void MainWindow::slotTimelineClipSelected(ClipItem* item, bool raise)
3331 m_effectStack->slotClipItemSelected(item);
3332 m_projectMonitor->slotSetSelectedClip(item);
3334 m_effectStack->raiseWindow(m_effectStackDock);
3337 void MainWindow::slotTrackSelected(int index, TrackInfo info, bool raise)
3339 m_effectStack->slotTrackItemSelected(index, info);
3341 m_effectStack->raiseWindow(m_effectStackDock);
3344 void MainWindow::slotActivateTransitionView(Transition *t)
3347 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3350 void MainWindow::slotSnapRewind()
3352 if (m_projectMonitor->isActive()) {
3353 if (m_activeTimeline)
3354 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3356 m_clipMonitor->slotSeekToPreviousSnap();
3360 void MainWindow::slotSnapForward()
3362 if (m_projectMonitor->isActive()) {
3363 if (m_activeTimeline)
3364 m_activeTimeline->projectView()->slotSeekToNextSnap();
3366 m_clipMonitor->slotSeekToNextSnap();
3370 void MainWindow::slotClipStart()
3372 if (m_projectMonitor->isActive()) {
3373 if (m_activeTimeline)
3374 m_activeTimeline->projectView()->clipStart();
3378 void MainWindow::slotClipEnd()
3380 if (m_projectMonitor->isActive()) {
3381 if (m_activeTimeline)
3382 m_activeTimeline->projectView()->clipEnd();
3386 void MainWindow::slotZoneStart()
3388 if (m_projectMonitor->isActive())
3389 m_projectMonitor->slotZoneStart();
3391 m_clipMonitor->slotZoneStart();
3394 void MainWindow::slotZoneEnd()
3396 if (m_projectMonitor->isActive())
3397 m_projectMonitor->slotZoneEnd();
3399 m_clipMonitor->slotZoneEnd();
3402 void MainWindow::slotChangeTool(QAction * action)
3404 if (action == m_buttonSelectTool)
3405 slotSetTool(SELECTTOOL);
3406 else if (action == m_buttonRazorTool)
3407 slotSetTool(RAZORTOOL);
3408 else if (action == m_buttonSpacerTool)
3409 slotSetTool(SPACERTOOL);
3412 void MainWindow::slotChangeEdit(QAction * action)
3414 if (!m_activeTimeline)
3417 if (action == m_overwriteEditTool)
3418 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3419 else if (action == m_insertEditTool)
3420 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3422 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3425 void MainWindow::slotSetTool(PROJECTTOOL tool)
3427 if (m_activeDocument && m_activeTimeline) {
3428 //m_activeDocument->setTool(tool);
3432 message = i18n("Ctrl + click to use spacer on current track only");
3435 message = i18n("Click on a clip to cut it");
3438 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3441 m_messageLabel->setMessage(message, InformationMessage);
3442 m_activeTimeline->projectView()->setTool(tool);
3446 void MainWindow::slotCopy()
3448 if (m_activeDocument && m_activeTimeline)
3449 m_activeTimeline->projectView()->copyClip();
3452 void MainWindow::slotPaste()
3454 if (m_activeDocument && m_activeTimeline)
3455 m_activeTimeline->projectView()->pasteClip();
3458 void MainWindow::slotPasteEffects()
3460 if (m_activeDocument && m_activeTimeline)
3461 m_activeTimeline->projectView()->pasteClipEffects();
3464 void MainWindow::slotFind()
3466 if (!m_activeDocument || !m_activeTimeline) return;
3467 m_projectSearch->setEnabled(false);
3468 m_findActivated = true;
3469 m_findString.clear();
3470 m_activeTimeline->projectView()->initSearchStrings();
3471 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3472 m_findTimer.start(5000);
3473 qApp->installEventFilter(this);
3476 void MainWindow::slotFindNext()
3478 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3479 statusBar()->showMessage(i18n("Found: %1", m_findString));
3481 statusBar()->showMessage(i18n("Reached end of project"));
3482 m_findTimer.start(4000);
3485 void MainWindow::findAhead()
3487 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3488 m_projectSearchNext->setEnabled(true);
3489 statusBar()->showMessage(i18n("Found: %1", m_findString));
3491 m_projectSearchNext->setEnabled(false);
3492 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3496 void MainWindow::findTimeout()
3498 m_projectSearchNext->setEnabled(false);
3499 m_findActivated = false;
3500 m_findString.clear();
3501 statusBar()->showMessage(i18n("Find stopped"), 3000);
3502 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3503 m_projectSearch->setEnabled(true);
3504 removeEventFilter(this);
3507 void MainWindow::slotClipInTimeline(const QString &clipId)
3509 if (m_activeTimeline && m_activeDocument) {
3510 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3512 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3513 inTimelineMenu->clear();
3515 QList <QAction *> actionList;
3517 for (int i = 0; i < matching.count(); ++i) {
3518 QString track = QString::number(matching.at(i).track);
3519 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3521 QAction *a = new QAction(track + ": " + start, this);
3522 a->setData(QStringList() << track << start);
3523 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3524 while (j < actionList.count()) {
3525 if (actionList.at(j)->text() > a->text()) break;
3528 actionList.insert(j, a);
3530 inTimelineMenu->addActions(actionList);
3532 if (matching.empty())
3533 inTimelineMenu->setEnabled(false);
3535 inTimelineMenu->setEnabled(true);
3539 void MainWindow::slotClipInProjectTree()
3541 if (m_activeTimeline) {
3542 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3543 if (clipIds.isEmpty())
3545 m_projectListDock->raise();
3546 for (int i = 0; i < clipIds.count(); i++)
3547 m_projectList->selectItemById(clipIds.at(i));
3548 if (m_projectMonitor->isActive())
3549 slotSwitchMonitors();
3553 /*void MainWindow::slotClipToProjectTree()
3555 if (m_activeTimeline) {
3556 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3557 if (clips.isEmpty()) return;
3558 for (int i = 0; i < clips.count(); i++) {
3559 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3561 //m_projectList->selectItemById(clipIds.at(i));
3565 void MainWindow::slotSelectClipInTimeline()
3567 if (m_activeTimeline) {
3568 QAction *action = qobject_cast<QAction *>(sender());
3569 QStringList data = action->data().toStringList();
3570 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3574 void MainWindow::keyPressEvent(QKeyEvent *ke)
3576 if (m_findActivated) {
3577 if (ke->key() == Qt::Key_Backspace) {
3578 m_findString = m_findString.left(m_findString.length() - 1);
3580 if (!m_findString.isEmpty())
3585 m_findTimer.start(4000);
3588 } else if (ke->key() == Qt::Key_Escape) {
3592 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3593 m_findString += ke->text();
3597 m_findTimer.start(4000);
3602 KXmlGuiWindow::keyPressEvent(ke);
3607 /** Gets called when the window gets hidden */
3608 void MainWindow::hideEvent(QHideEvent */*event*/)
3610 if (isMinimized() && m_monitorManager)
3611 m_monitorManager->stopActiveMonitor();
3614 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3616 if (m_findActivated) {
3617 if (event->type() == QEvent::ShortcutOverride) {
3618 QKeyEvent* ke = (QKeyEvent*) event;
3619 if (ke->text().trimmed().isEmpty()) return false;
3626 // pass the event on to the parent class
3627 return QMainWindow::eventFilter(obj, event);
3632 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3634 KDialog *dialog = new KDialog(this);
3635 dialog->setCaption("Save clip zone");
3636 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3638 QWidget *widget = new QWidget(dialog);
3639 dialog->setMainWidget(widget);
3641 QVBoxLayout *vbox = new QVBoxLayout(widget);
3642 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3643 if (path.isEmpty()) {
3644 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3645 if (baseClip == NULL) tmppath.append("untitled.mlt");
3647 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3649 path = KUrl(tmppath);
3651 KUrlRequester *url = new KUrlRequester(path, this);
3652 url->setFilter("video/mlt-playlist");
3653 QLabel *label2 = new QLabel(i18n("Description:"), this);
3654 KLineEdit *edit = new KLineEdit(this);
3655 vbox->addWidget(label1);
3656 vbox->addWidget(url);
3657 vbox->addWidget(label2);
3658 vbox->addWidget(edit);
3659 if (dialog->exec() == QDialog::Accepted) {
3660 if (QFile::exists(url->url().path())) {
3661 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3662 slotSaveZone(render, zone, baseClip, url->url());
3666 if (baseClip && !baseClip->fileURL().isEmpty()) {
3667 // create zone from clip url, so that we don't have problems with proxy clips
3669 #if QT_VERSION >= 0x040600
3670 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3671 env.remove("MLT_PROFILE");
3672 p.setProcessEnvironment(env);
3674 QStringList env = QProcess::systemEnvironment();
3675 env << "MLT_PROFILE='\0'";
3676 p.setEnvironment(env);
3678 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3679 if (!p.waitForStarted(3000)) {
3680 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3682 else if (!p.waitForFinished(5000)) {
3683 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3686 else render->saveZone(url->url(), edit->text(), zone);
3691 void MainWindow::slotSetInPoint()
3693 if (m_clipMonitor->isActive()) {
3694 m_clipMonitor->slotSetZoneStart();
3696 m_projectMonitor->slotSetZoneStart();
3700 void MainWindow::slotSetOutPoint()
3702 if (m_clipMonitor->isActive()) {
3703 m_clipMonitor->slotSetZoneEnd();
3705 m_projectMonitor->slotSetZoneEnd();
3709 void MainWindow::slotResizeItemStart()
3711 if (m_activeTimeline)
3712 m_activeTimeline->projectView()->setInPoint();
3715 void MainWindow::slotResizeItemEnd()
3717 if (m_activeTimeline)
3718 m_activeTimeline->projectView()->setOutPoint();
3721 int MainWindow::getNewStuff(const QString &configFile)
3723 KNS3::Entry::List entries;
3724 #if KDE_IS_VERSION(4,3,80)
3725 KNS3::DownloadDialog dialog(configFile);
3727 entries = dialog.changedEntries();
3728 foreach(const KNS3::Entry & entry, entries) {
3729 if (entry.status() == KNS3::Entry::Installed)
3730 kDebug() << "// Installed files: " << entry.installedFiles();
3733 KNS::Engine engine(0);
3734 if (engine.init(configFile))
3735 entries = engine.downloadDialogModal(this);
3736 foreach(KNS::Entry * entry, entries) {
3737 if (entry->status() == KNS::Entry::Installed)
3738 kDebug() << "// Installed files: " << entry->installedFiles();
3741 return entries.size();
3744 void MainWindow::slotGetNewTitleStuff()
3746 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3747 TitleWidget::refreshTitleTemplates();
3750 void MainWindow::slotGetNewLumaStuff()
3752 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3753 initEffects::refreshLumas();
3754 m_activeTimeline->projectView()->reloadTransitionLumas();
3758 void MainWindow::slotGetNewRenderStuff()
3760 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3762 m_renderWidget->reloadProfiles();
3765 void MainWindow::slotGetNewMltProfileStuff()
3767 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3768 // update the list of profiles in settings dialog
3769 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3775 void MainWindow::slotAutoTransition()
3777 if (m_activeTimeline)
3778 m_activeTimeline->projectView()->autoTransition();
3781 void MainWindow::slotSplitAudio()
3783 if (m_activeTimeline)
3784 m_activeTimeline->projectView()->splitAudio();
3787 void MainWindow::slotSetAudioAlignReference()
3789 if (m_activeTimeline) {
3790 m_activeTimeline->projectView()->setAudioAlignReference();
3794 void MainWindow::slotAlignAudio()
3796 if (m_activeTimeline) {
3797 m_activeTimeline->projectView()->alignAudio();
3801 void MainWindow::slotUpdateClipType(QAction *action)
3803 if (m_activeTimeline) {
3804 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3805 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3806 else m_activeTimeline->projectView()->setAudioAndVideo();
3810 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3812 // We must stop the monitors since we create a new on in the dvd wizard
3813 m_clipMonitor->stop();
3814 m_projectMonitor->stop();
3815 DvdWizard w(url, profile, this);
3817 m_projectMonitor->start();
3820 void MainWindow::slotShowTimeline(bool show)
3822 if (show == false) {
3823 m_timelineState = saveState();
3824 centralWidget()->setHidden(true);
3826 centralWidget()->setHidden(false);
3827 restoreState(m_timelineState);
3831 void MainWindow::slotMaximizeCurrent(bool)
3833 //TODO: is there a way to maximize current widget?
3835 m_timelineState = saveState();
3836 QWidget *par = focusWidget()->parentWidget();
3837 while (par->parentWidget() && par->parentWidget() != this)
3838 par = par->parentWidget();
3839 kDebug() << "CURRENT WIDGET: " << par->objectName();
3842 void MainWindow::loadStabilize()
3844 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3847 Mlt::Profile profile;
3848 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3849 QAction *action=stabMenu->addAction("Videostab (vstab)");
3850 action->setData("videostab");
3851 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3853 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3854 QAction *action=stabMenu->addAction("Videostab (transcode)");
3855 action->setData("videostab2");
3856 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3863 void MainWindow::loadTranscoders()
3865 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3868 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
3869 extractAudioMenu->clear();
3871 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3872 KConfigGroup transConfig(config, "Transcoding");
3874 QMap< QString, QString > profiles = transConfig.entryMap();
3875 QMapIterator<QString, QString> i(profiles);
3876 while (i.hasNext()) {
3878 QStringList data = i.value().split(";");
3880 // separate audio transcoding in a separate menu
3881 if (data.count() > 2 && data.at(2) == "audio") {
3882 a = extractAudioMenu->addAction(i.key());
3885 a = transMenu->addAction(i.key());
3888 if (data.count() > 1) a->setToolTip(data.at(1));
3889 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3893 void MainWindow::slotStabilize()
3895 QString condition,filtername;
3898 // Stablize selected clips
3899 QAction *action = qobject_cast<QAction *>(sender());
3901 filtername=action->data().toString();
3903 m_projectList->startClipFilterJob(filtername, condition);
3905 if (ids.isEmpty()) {
3906 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3909 QString destination;
3910 ProjectItem *item = m_projectList->getClipById(ids.at(0));
3911 if (ids.count() == 1) {
3914 ClipStabilize *d = new ClipStabilize(destination, ids.count(), filtername);
3915 //connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3916 if (d->exec() == QDialog::Accepted) {
3917 m_projectList->slotStabilizeClipJob(ids, d->autoAddClip(), d->params(), d->desc());
3922 void MainWindow::slotTranscode(KUrl::List urls)
3927 if (urls.isEmpty()) {
3928 QAction *action = qobject_cast<QAction *>(sender());
3929 QStringList data = action->data().toStringList();
3930 params = data.at(0);
3931 if (data.count() > 1) desc = data.at(1);
3932 if (data.count() > 3) condition = data.at(3);
3933 m_projectList->slotTranscodeClipJob(condition, params, desc);
3936 if (urls.isEmpty()) {
3937 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3940 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3941 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3945 void MainWindow::slotTranscodeClip()
3947 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3948 if (urls.isEmpty()) return;
3949 slotTranscode(urls);
3952 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3954 if (m_activeDocument == NULL) return;
3955 QMapIterator<QString, QString> i(props);
3956 while (i.hasNext()) {
3958 m_activeDocument->setDocumentProperty(i.key(), i.value());
3960 m_activeDocument->setModified(true);
3964 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3966 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3968 QString playlistPath;
3971 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3972 QString path = m_renderWidget->getFreeScriptName();
3973 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3974 if (!ok || scriptPath.isEmpty()) return;
3975 scriptPath.prepend(scriptsFolder);
3976 QFile f(scriptPath);
3978 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3981 playlistPath = scriptPath + ".mlt";
3983 KTemporaryFile temp;
3984 temp.setAutoRemove(false);
3985 temp.setSuffix(".mlt");
3987 playlistPath = temp.fileName();
3989 QString playlistContent = m_projectMonitor->sceneList();
3990 if (!chapterFile.isEmpty()) {
3993 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3995 in = m_activeTimeline->inPoint();
3996 out = m_activeTimeline->outPoint();
3999 QDomElement chapters = doc.createElement("chapters");
4000 chapters.setAttribute("fps", m_activeDocument->fps());
4001 doc.appendChild(chapters);
4003 QDomElement guidesxml = m_activeDocument->guidesXml();
4004 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
4005 for (int i = 0; i < nodes.count(); i++) {
4006 QDomElement e = nodes.item(i).toElement();
4008 QString comment = e.attribute("comment");
4009 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
4010 if (time >= in && time < out) {
4011 if (zoneOnly) time = time - in;
4012 QDomElement chapter = doc.createElement("chapter");
4013 chapters.appendChild(chapter);
4014 chapter.setAttribute("title", comment);
4015 chapter.setAttribute("time", time);
4019 if (chapters.childNodes().count() > 0) {
4020 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
4021 // Always insert a guide in pos 0
4022 QDomElement chapter = doc.createElement("chapter");
4023 chapters.insertBefore(chapter, QDomNode());
4024 chapter.setAttribute("title", i18n("Start"));
4025 chapter.setAttribute("time", "0");
4027 // save chapters file
4028 QFile file(chapterFile);
4029 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4030 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4032 file.write(doc.toString().toUtf8());
4033 if (file.error() != QFile::NoError) {
4034 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4041 if (m_renderWidget->automaticAudioExport()) {
4042 exportAudio = m_activeTimeline->checkProjectAudio();
4043 } else exportAudio = m_renderWidget->selectedAudioExport();
4045 // Set playlist audio volume to 100%
4047 doc.setContent(playlistContent);
4048 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4049 if (!tractor.isNull()) {
4050 QDomNodeList props = tractor.elementsByTagName("property");
4051 for (int i = 0; i < props.count(); i++) {
4052 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4053 props.at(i).firstChild().setNodeValue("1");
4059 // Do we want proxy rendering
4060 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4061 QString root = doc.documentElement().attribute("root");
4063 // replace proxy clips with originals
4064 QMap <QString, QString> proxies = m_projectList->getProxies();
4066 QDomNodeList producers = doc.elementsByTagName("producer");
4067 QString producerResource;
4069 for (uint n = 0; n < producers.length(); n++) {
4070 QDomElement e = producers.item(n).toElement();
4071 producerResource = EffectsList::property(e, "resource");
4072 if (producerResource.isEmpty()) continue;
4073 if (!producerResource.startsWith("/")) {
4074 producerResource.prepend(root + "/");
4076 if (producerResource.contains('?')) {
4077 // slowmotion producer
4078 suffix = "?" + producerResource.section('?', 1);
4079 producerResource = producerResource.section('?', 0, 0);
4081 else suffix.clear();
4082 if (!producerResource.isEmpty()) {
4083 if (proxies.contains(producerResource)) {
4084 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4085 // We need to delete the "aspect_ratio" property because proxy clips
4086 // sometimes have different ratio than original clips
4087 EffectsList::removeProperty(e, "aspect_ratio");
4088 EffectsList::removeMetaProperties(e);
4093 /*QMapIterator<QString, QString> i(proxies);
4094 while (i.hasNext()) {
4096 // Replace all keys with their values (proxy path with original path)
4097 QString key = i.key();
4098 playlistContent.replace(key, i.value());
4099 if (!root.isEmpty() && key.startsWith(root)) {
4100 // in case the resource path in MLT playlist is relative
4101 key.remove(0, root.count() + 1);
4102 playlistContent.replace(key, i.value());
4106 playlistContent = doc.toString();
4108 // Do save scenelist
4109 QFile file(playlistPath);
4110 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4111 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4114 file.write(playlistContent.toUtf8());
4115 if (file.error() != QFile::NoError) {
4116 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4121 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4124 void MainWindow::slotUpdateTimecodeFormat(int ix)
4126 KdenliveSettings::setFrametimecode(ix == 1);
4127 m_clipMonitor->updateTimecodeFormat();
4128 m_projectMonitor->updateTimecodeFormat();
4129 m_transitionConfig->updateTimecodeFormat();
4130 m_effectStack->updateTimecodeFormat();
4131 //m_activeTimeline->projectView()->clearSelection();
4132 m_activeTimeline->updateRuler();
4135 void MainWindow::slotRemoveFocus()
4137 statusBar()->setFocus();
4138 statusBar()->clearFocus();
4141 void MainWindow::slotRevert()
4143 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;
4144 KUrl url = m_activeDocument->url();
4145 if (closeCurrentDocument(false))
4146 doOpenFile(url, NULL);
4150 void MainWindow::slotShutdown()
4152 if (m_activeDocument) m_activeDocument->setModified(false);
4154 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4155 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4156 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4157 smserver.call("logout", 1, 2, 2);
4158 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4159 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4160 smserver.call("Shutdown");
4164 void MainWindow::slotUpdateTrackInfo()
4166 if (m_activeDocument)
4167 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4170 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4172 // Load the theme file
4174 if (action == NULL) theme = themename;
4175 else theme = action->data().toString();
4176 KdenliveSettings::setColortheme(theme);
4177 // Make palette for all widgets.
4178 QPalette plt = kapp->palette();
4179 if (theme.isEmpty()) {
4180 plt = QApplication::desktop()->palette();
4182 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4184 #if KDE_IS_VERSION(4,6,3)
4185 plt = KGlobalSettings::createNewApplicationPalette(config);
4187 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4188 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4189 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4190 QPalette::Disabled };
4191 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4192 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4194 for ( int i = 0; i < 3 ; i++ ) {
4195 QPalette::ColorGroup state = states[i];
4196 KColorScheme schemeView(state, KColorScheme::View, config);
4197 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4198 KColorScheme schemeButton(state, KColorScheme::Button, config);
4199 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4201 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4202 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4203 plt.setBrush( state, QPalette::Base, schemeView.background() );
4204 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4205 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4206 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4207 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4208 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4209 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4210 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4212 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4213 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4214 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4215 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4216 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4218 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4219 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4220 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4225 kapp->setPalette(plt);
4226 slotChangePalette();
4227 const QObjectList children = statusBar()->children();
4229 foreach(QObject * child, children) {
4230 if (child->isWidgetType())
4231 ((QWidget*)child)->setPalette(plt);
4232 const QObjectList subchildren = child->children();
4233 foreach(QObject * subchild, subchildren) {
4234 if (subchild->isWidgetType())
4235 ((QWidget*)subchild)->setPalette(plt);
4241 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4243 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4244 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4245 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4246 const QSize bitsSize(24, 2);
4247 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4248 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4250 QPixmap pixmap(23, 16);
4251 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4253 KConfigGroup group(config, "WM");
4254 QPainter p(&pixmap);
4255 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4256 p.fillRect(1, 1, 7, 7, windowScheme.background());
4257 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4259 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4260 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4261 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4263 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4264 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4266 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4267 p.fillRect(1, 8, 7, 7, viewScheme.background());
4268 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4270 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4271 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4272 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4274 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4275 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4281 void MainWindow::slotSwitchMonitors()
4283 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4284 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4285 else m_projectList->focusTree();
4288 void MainWindow::slotInsertZoneToTree()
4290 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4291 QStringList info = m_clipMonitor->getZoneInfo();
4292 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4295 void MainWindow::slotInsertZoneToTimeline()
4297 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4298 QStringList info = m_clipMonitor->getZoneInfo();
4299 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4303 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4305 if (m_activeDocument && m_activeTimeline) {
4306 if (!ids.isEmpty()) {
4307 for (int i = 0; i < ids.size(); ++i) {
4308 m_activeTimeline->slotDeleteClip(ids.at(i));
4310 m_activeDocument->clipManager()->slotDeleteClips(ids);
4312 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4313 m_activeDocument->setModified(true);
4317 void MainWindow::slotShowTitleBars(bool show)
4319 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4320 for (int i = 0; i < docks.count(); i++) {
4321 QDockWidget* dock = docks.at(i);
4323 dock->setTitleBarWidget(0);
4325 if (!dock->isFloating()) {
4326 dock->setTitleBarWidget(new QWidget);
4330 KdenliveSettings::setShowtitlebars(show);
4333 void MainWindow::slotSwitchTitles()
4335 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4338 QString MainWindow::getMimeType(bool open)
4340 QString mimetype = "application/x-kdenlive";
4341 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4343 mimetype = "*.kdenlive";
4344 if (open) mimetype.append(" *.tar.gz");
4346 else if (open) mimetype.append(" application/x-compressed-tar");
4350 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4353 m_projectMonitor->render->sendFrameForAnalysis = true;
4356 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4357 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4364 qDebug() << "Any scope accepting new frames? " << request;
4367 m_projectMonitor->render->sendFrameForAnalysis = false;
4372 void MainWindow::slotOpenStopmotion()
4374 if (m_stopmotion == NULL) {
4375 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4376 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4377 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4378 // Check if we need the renderer to send a new frame for update
4379 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4380 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4381 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4384 m_stopmotion->show();
4387 void MainWindow::slotDeleteClip(const QString &id)
4389 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4390 for (int i = 0; i < list.size(); ++i) {
4391 list.at(i)->disableClipId(id);
4393 m_projectList->slotDeleteClip(id);
4396 void MainWindow::slotUpdateProxySettings()
4398 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4399 if (KdenliveSettings::enableproxy())
4400 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4401 m_projectList->updateProxyConfig();
4404 void MainWindow::slotInsertNotesTimecode()
4406 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4407 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4408 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4411 void MainWindow::slotArchiveProject()
4413 QList <DocClipBase*> list = m_projectList->documentClipList();
4414 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4415 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4420 void MainWindow::slotOpenBackupDialog(const KUrl url)
4425 kDebug()<<"// BACKUP URL: "<<url.path();
4426 if (!url.isEmpty()) {
4427 // we could not open the project file, guess where the backups are
4428 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4432 projectFolder = m_activeDocument->projectFolder();
4433 projectFile = m_activeDocument->url();
4434 projectId = m_activeDocument->getDocumentProperty("documentid");
4437 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4438 if (dia->exec() == QDialog::Accepted) {
4439 QString requestedBackup = dia->selectedFile();
4440 m_activeDocument->backupLastSavedVersion(projectFile.path());
4441 closeCurrentDocument(false);
4442 doOpenFile(KUrl(requestedBackup), NULL);
4443 m_activeDocument->setUrl(projectFile);
4444 m_activeDocument->setModified(true);
4445 setCaption(m_activeDocument->description());
4450 void MainWindow::slotElapsedTime()
4452 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4456 void MainWindow::slotDownloadResources()
4458 QString currentFolder;
4459 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4460 else currentFolder = KdenliveSettings::defaultprojectfolder();
4461 ResourceWidget *d = new ResourceWidget(currentFolder);
4462 connect(d, SIGNAL(addClip(KUrl, const QString &)), this, SLOT(slotAddProjectClip(KUrl, const QString &)));
4466 void MainWindow::slotChangePalette()
4468 QPalette plt = QApplication::palette();
4469 if (m_effectStack) m_effectStack->updatePalette();
4470 if (m_projectList) m_projectList->updatePalette();
4471 if (m_effectList) m_effectList->updatePalette();
4473 if (m_clipMonitor) m_clipMonitor->setPalette(plt);
4474 if (m_projectMonitor) m_projectMonitor->setPalette(plt);
4476 setStatusBarStyleSheet(plt);
4477 if (m_activeTimeline) {
4478 m_activeTimeline->updatePalette();
4482 void MainWindow::slotSaveTimelineClip()
4484 if (m_activeTimeline && m_projectMonitor->render) {
4485 ClipItem *clip = m_activeTimeline->projectView()->getActiveClipUnderCursor(true);
4487 m_messageLabel->setMessage(i18n("Select a clip to save"), InformationMessage);
4490 KUrl url = KFileDialog::getSaveUrl(m_activeDocument->projectFolder(), "video/mlt-playlist");
4491 if (!url.isEmpty()) m_projectMonitor->render->saveClip(m_activeDocument->tracksCount() - clip->track(), clip->startPos(), url);
4496 #include "mainwindow.moc"