1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
42 #include "audiosignal.h"
44 #include "jogshuttle.h"
45 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
47 #endif /* NO_JOGSHUTTLE */
48 #include "clipproperties.h"
50 #include "editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "kdenlive-config.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audiospectrum.h"
63 #include "spectrogram.h"
64 #include "archivewidget.h"
65 #include "databackup/backupwidget.h"
67 #include <KApplication>
71 #include <KActionCollection>
72 #include <KActionCategory>
73 #include <KStandardAction>
74 #include <KShortcutsDialog>
75 #include <KFileDialog>
76 #include <KMessageBox>
78 #include <KIO/NetAccess>
81 #include <KConfigDialog>
82 #include <KXMLGUIFactory>
84 #include <kstandarddirs.h>
85 #include <KUrlRequesterDialog>
86 #include <KTemporaryFile>
88 #include <KActionMenu>
90 #include <ktogglefullscreenaction.h>
92 #include <KNotification>
93 #include <KNotifyConfigWidget>
94 #if KDE_IS_VERSION(4,3,80)
95 #include <knewstuff3/downloaddialog.h>
96 #include <knewstuff3/knewstuffaction.h>
98 #include <knewstuff2/engine.h>
99 #include <knewstuff2/ui/knewstuffaction.h>
101 #endif /* KDE_IS_VERSION(4,3,80) */
103 #include <KColorScheme>
104 #include <KProgressDialog>
106 #include <QTextStream>
110 #include <QInputDialog>
111 #include <QDesktopWidget>
116 // Uncomment for deeper debugging
117 //#define DEBUG_MAINW
123 static const char version[] = VERSION;
125 static const int ID_TIMELINE_POS = 0;
131 Q_DECLARE_METATYPE(QVector<int16_t>)
133 EffectsList MainWindow::videoEffects;
134 EffectsList MainWindow::audioEffects;
135 EffectsList MainWindow::customEffects;
136 EffectsList MainWindow::transitions;
138 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
139 KXmlGuiWindow(parent),
140 m_activeDocument(NULL),
141 m_activeTimeline(NULL),
143 m_renderWidget(NULL),
144 #ifndef NO_JOGSHUTTLE
147 #endif /* NO_JOGSHUTTLE */
148 m_findActivated(false),
151 qRegisterMetaType<QVector<int16_t> > ();
152 qRegisterMetaType<stringMap> ("stringMap");
154 QLocale systemLocale = QLocale();
155 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
156 QLocale::setDefault(systemLocale);
158 // Create DBus interface
159 new MainWindowAdaptor(this);
160 QDBusConnection dbus = QDBusConnection::sessionBus();
161 dbus.registerObject("/MainWindow", this);
163 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
164 setFont(KGlobalSettings::toolBarFont());
165 parseProfiles(MltPath);
166 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
167 m_commandStack = new QUndoGroup;
168 setDockNestingEnabled(true);
169 m_timelineArea = new KTabWidget(this);
170 m_timelineArea->setTabReorderingEnabled(true);
171 m_timelineArea->setTabBarHidden(true);
172 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
173 m_timelineArea->setMinimumHeight(200);
175 QToolButton *closeTabButton = new QToolButton;
176 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
177 closeTabButton->setIcon(KIcon("tab-close"));
178 closeTabButton->adjustSize();
179 closeTabButton->setToolTip(i18n("Close the current tab"));
180 m_timelineArea->setCornerWidget(closeTabButton);
181 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
183 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
184 m_findTimer.setSingleShot(true);
186 // FIXME: the next call returns a newly allocated object, which leaks
187 initEffects::parseEffectFiles();
188 //initEffects::parseCustomEffectsFile();
190 m_monitorManager = new MonitorManager();
192 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
193 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
198 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
199 m_projectListDock->setObjectName("project_tree");
200 m_projectList = new ProjectList();
201 m_projectListDock->setWidget(m_projectList);
202 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
204 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
205 m_clipMonitorDock->setObjectName("clip_monitor");
206 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
207 m_clipMonitorDock->setWidget(m_clipMonitor);
208 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
210 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
211 m_projectMonitorDock->setObjectName("project_monitor");
212 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
213 m_projectMonitorDock->setWidget(m_projectMonitor);
216 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
217 m_recMonitorDock->setObjectName("record_monitor");
218 m_recMonitor = new RecMonitor("record", m_monitorManager);
219 m_recMonitorDock->setWidget(m_recMonitor);
220 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
221 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
222 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
224 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
226 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
227 m_notesDock->setObjectName("notes_widget");
228 m_notesWidget = new NotesWidget();
229 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
230 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
232 m_notesWidget->setTabChangesFocus(true);
233 #if KDE_IS_VERSION(4,4,0)
234 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
236 m_notesDock->setWidget(m_notesWidget);
237 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
239 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
240 m_effectStackDock->setObjectName("effect_stack");
241 m_effectStack = new EffectStackView(m_projectMonitor);
242 m_effectStackDock->setWidget(m_effectStack);
243 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
245 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
246 m_transitionConfigDock->setObjectName("transition");
247 m_transitionConfig = new TransitionSettings(m_projectMonitor);
248 m_transitionConfigDock->setWidget(m_transitionConfig);
249 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
251 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
252 m_effectListDock->setObjectName("effect_list");
253 m_effectList = new EffectsListView();
254 m_effectListDock->setWidget(m_effectList);
255 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
257 m_vectorscope = new Vectorscope(m_monitorManager);
258 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
259 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
260 m_vectorscopeDock->setWidget(m_vectorscope);
261 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
262 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
263 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
264 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
265 m_gfxScopesList.append(m_vectorscopeDock);
267 m_waveform = new Waveform(m_monitorManager);
268 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
269 m_waveformDock->setObjectName(m_waveform->widgetName());
270 m_waveformDock->setWidget(m_waveform);
271 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
272 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
273 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
274 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
275 m_gfxScopesList.append(m_waveformDock);
277 m_RGBParade = new RGBParade(m_monitorManager);
278 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
279 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
280 m_RGBParadeDock->setWidget(m_RGBParade);
281 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
282 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
283 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
284 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
285 m_gfxScopesList.append(m_RGBParadeDock);
287 m_histogram = new Histogram(m_monitorManager);
288 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
289 m_histogramDock->setObjectName(m_histogram->widgetName());
290 m_histogramDock->setWidget(m_histogram);
291 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
292 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
293 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
294 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
295 m_gfxScopesList.append(m_histogramDock);
298 m_audiosignal = new AudioSignal;
299 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
300 m_audiosignalDock->setObjectName("audiosignal");
301 m_audiosignalDock->setWidget(m_audiosignal);
302 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
303 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
304 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
306 m_audioSpectrum = new AudioSpectrum();
307 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
308 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
309 m_audioSpectrumDock->setWidget(m_audioSpectrum);
310 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
311 m_audioScopesList.append(m_audioSpectrum);
312 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
313 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
315 m_spectrogram = new Spectrogram();
316 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
317 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
318 m_spectrogramDock->setWidget(m_spectrogram);
319 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
320 m_audioScopesList.append(m_spectrogram);
321 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
322 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
324 // Connect the audio signal to the audio scope slots
326 if (m_projectMonitor) {
327 qDebug() << "project monitor connected";
328 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
329 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
330 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
331 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
332 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
333 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
336 qDebug() << "clip monitor connected";
337 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
338 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
339 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
340 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
341 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
342 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
344 // Ensure connections were set up correctly
349 // Add monitors here to keep them at the right of the window
350 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
351 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
353 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
356 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
357 m_undoViewDock->setObjectName("undo_history");
358 m_undoView = new QUndoView();
359 m_undoView->setCleanIcon(KIcon("edit-clear"));
360 m_undoView->setEmptyLabel(i18n("Clean"));
361 m_undoViewDock->setWidget(m_undoView);
362 m_undoView->setGroup(m_commandStack);
363 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
367 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
370 // Close non-general docks for the initial layout
371 // only show important ones
372 m_histogramDock->close();
373 m_RGBParadeDock->close();
374 m_waveformDock->close();
375 m_vectorscopeDock->close();
377 m_audioSpectrumDock->close();
378 m_spectrogramDock->close();
379 m_audiosignalDock->close();
381 m_undoViewDock->close();
385 /// Tabify Widgets ///
386 tabifyDockWidget(m_effectListDock, m_effectStackDock);
387 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
388 tabifyDockWidget(m_projectListDock, m_notesDock);
390 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
392 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
398 setCentralWidget(m_timelineArea);
401 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
403 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
404 m_fileRevert->setEnabled(false);
406 // Prepare layout actions
407 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
408 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
409 for (int i = 1; i < 5; i++) {
410 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
411 load->setData("_" + QString::number(i));
412 layoutActions->addAction("load_layout" + QString::number(i), load);
413 m_loadLayout->addAction(load);
414 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
415 save->setData("_" + QString::number(i));
416 layoutActions->addAction("save_layout" + QString::number(i), save);
418 layoutActions->addAction("load_layouts", m_loadLayout);
419 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
422 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
423 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
424 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
425 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
426 m_stopmotion_actions->addAction("stopmotion_capture", action);
427 action = new KAction(i18n("Switch live / captured frame"), this);
428 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
429 m_stopmotion_actions->addAction("stopmotion_switch", action);
430 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
431 action->setCheckable(true);
432 action->setChecked(false);
433 m_stopmotion_actions->addAction("stopmotion_overlay", action);
435 // Build effects menu
436 m_effectsMenu = new QMenu(i18n("Add Effect"));
437 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
438 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
439 m_effectsActionCollection->readSettings();
443 // Find QDockWidget tab bars and show / hide widget title bars on right click
444 QList <QTabBar *> tabs = findChildren<QTabBar *>();
445 for (int i = 0; i < tabs.count(); i++) {
446 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
447 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
450 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
451 guiFactory()->addClient(sp);*/
453 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
455 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
458 // Load layout names from config file
464 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
465 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
467 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
468 clipInTimeline->setIcon(KIcon("go-jump"));
469 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
470 static_cast<QMenu*>(factory()->container("transcoders", this)),
473 // build themes menus
474 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
475 QActionGroup *themegroup = new QActionGroup(this);
476 themegroup->setExclusive(true);
477 action = new KAction(i18n("Default"), this);
478 action->setCheckable(true);
479 themegroup->addAction(action);
480 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
482 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
484 for (int i = 0; i < schemeFiles.size(); ++i) {
486 const QString filename = schemeFiles.at(i);
487 const QFileInfo info(filename);
490 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
491 QIcon icon = createSchemePreviewIcon(config);
492 KConfigGroup group(config, "General");
493 const QString name = group.readEntry("Name", info.baseName());
494 action = new KAction(name, this);
495 action->setData(filename);
496 action->setIcon(icon);
497 action->setCheckable(true);
498 themegroup->addAction(action);
499 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
502 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
503 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
504 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
507 action = new QAction(fi.fileName(), this);
508 action->setData(*it);
509 action->setCheckable(true);
510 themegroup->addAction(action);
511 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
513 themesMenu->addActions(themegroup->actions());
514 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
516 // Setup and fill effects and transitions menus.
519 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
520 m->addActions(m_effectsMenu->actions());
523 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
524 for (int i = 0; i < transitions.count(); ++i)
525 m_transitionsMenu->addAction(m_transitions[i]);
527 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
528 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
529 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
531 m_effectStack->setMenu(m_effectsMenu);
533 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
534 const QList<QAction *> viewActions = createPopupMenu()->actions();
535 viewMenu->insertActions(NULL, viewActions);
537 m_timelineContextMenu = new QMenu(this);
538 m_timelineContextClipMenu = new QMenu(this);
539 m_timelineContextTransitionMenu = new QMenu(this);
541 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
542 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
543 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
545 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
546 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
547 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
548 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
549 m_timelineContextClipMenu->addSeparator();
550 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
551 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
552 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
553 m_timelineContextClipMenu->addSeparator();
554 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
555 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
556 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
557 m_timelineContextClipMenu->addSeparator();
559 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
560 m_timelineContextClipMenu->addMenu(markersMenu);
561 m_timelineContextClipMenu->addSeparator();
562 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
563 m_timelineContextClipMenu->addMenu(m_effectsMenu);
565 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
566 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
567 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
569 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
571 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
572 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
573 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
574 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
575 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
576 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
577 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
579 slotConnectMonitors();
581 // Open or create a file. Command line argument passed in Url has
582 // precedence, then "openlastproject", then just a plain empty file.
583 // If opening Url fails, openlastproject will _not_ be used.
584 if (!Url.isEmpty()) {
585 // delay loading so that the window shows up
587 QTimer::singleShot(500, this, SLOT(openFile()));
588 } else if (KdenliveSettings::openlastproject()) {
589 QTimer::singleShot(500, this, SLOT(openLastFile()));
590 } else { //if (m_timelineArea->count() == 0) {
594 if (!clipsToLoad.isEmpty() && m_activeDocument) {
595 QStringList list = clipsToLoad.split(',');
597 foreach(QString path, list) {
598 kDebug() << QDir::current().absoluteFilePath(path);
599 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
601 m_projectList->slotAddClip(urls);
604 #ifndef NO_JOGSHUTTLE
605 activateShuttleDevice();
606 #endif /* NO_JOGSHUTTLE */
607 m_projectListDock->raise();
609 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
610 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
613 MainWindow::~MainWindow()
618 m_effectStack->slotClipItemSelected(NULL, 0);
619 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
621 if (m_projectMonitor) m_projectMonitor->stop();
622 if (m_clipMonitor) m_clipMonitor->stop();
624 delete m_activeTimeline;
625 delete m_effectStack;
626 delete m_transitionConfig;
627 delete m_activeDocument;
628 delete m_projectMonitor;
629 delete m_clipMonitor;
630 delete m_shortcutRemoveFocus;
631 delete[] m_transitions;
632 Mlt::Factory::close();
636 bool MainWindow::queryClose()
638 if (m_renderWidget) {
639 int waitingJobs = m_renderWidget->waitingJobsCount();
640 if (waitingJobs > 0) {
641 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")))) {
642 case KMessageBox::Yes :
643 // create script with waiting jobs and start it
644 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
646 case KMessageBox::No :
647 // Don't do anything, jobs will be deleted
655 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
656 // warn the user to save if document is modified and we have clips in our project list
657 if (m_activeDocument && m_activeDocument->isModified() &&
658 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
659 !m_projectList->documentClipList().isEmpty())) {
663 if (m_activeDocument->url().fileName().isEmpty())
664 message = i18n("Save changes to document?");
666 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
667 switch (KMessageBox::warningYesNoCancel(this, message)) {
668 case KMessageBox::Yes :
669 // save document here. If saving fails, return false;
671 case KMessageBox::No :
672 // User does not want to save the changes, clear recovery files
673 m_activeDocument->m_autosave->resize(0);
682 void MainWindow::loadPlugins()
684 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
685 populateMenus(plugin);
688 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
690 filters << "libkdenlive*";
691 foreach(const QString & folder, directories) {
692 kDebug() << "Parsing plugin folder: " << folder;
693 QDir pluginsDir(folder);
694 foreach(const QString & fileName,
695 pluginsDir.entryList(filters, QDir::Files)) {
697 * Avoid loading the same plugin twice when there is more than one
700 if (!m_pluginFileNames.contains(fileName)) {
701 kDebug() << "Found plugin: " << fileName;
702 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
703 QObject *plugin = loader.instance();
705 populateMenus(plugin);
706 m_pluginFileNames += fileName;
708 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
714 void MainWindow::populateMenus(QObject *plugin)
716 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
717 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
719 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
723 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
724 QMenu *menu, const char *member,
725 QActionGroup *actionGroup)
727 kDebug() << "// ADD to MENU" << texts;
728 foreach(const QString & text, texts) {
729 QAction *action = new QAction(text, plugin);
730 action->setData(text);
731 connect(action, SIGNAL(triggered()), this, member);
732 menu->addAction(action);
735 action->setCheckable(true);
736 actionGroup->addAction(action);
741 void MainWindow::aboutPlugins()
743 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
748 void MainWindow::generateClip()
750 QAction *action = qobject_cast<QAction *>(sender());
751 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
753 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
754 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
755 if (!clipUrl.isEmpty()) {
756 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
760 void MainWindow::saveProperties(KConfigGroup &config)
762 // save properties here,used by session management
764 KMainWindow::saveProperties(config);
768 void MainWindow::readProperties(const KConfigGroup &config)
770 // read properties here,used by session management
771 KMainWindow::readProperties(config);
772 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
773 openFile(KUrl(Lastproject));
776 void MainWindow::slotReloadEffects()
778 initEffects::parseCustomEffectsFile();
779 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
782 #ifndef NO_JOGSHUTTLE
783 void MainWindow::activateShuttleDevice()
789 if (KdenliveSettings::enableshuttle() == false) return;
791 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
792 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
794 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
795 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
796 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
797 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
798 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
800 #endif /* NO_JOGSHUTTLE */
802 void MainWindow::slotDoAction(const QString& action_name)
804 QAction* action = actionCollection()->action(action_name);
806 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
812 void MainWindow::configureNotifications()
814 KNotifyConfigWidget::configure(this);
817 void MainWindow::slotFullScreen()
819 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
822 void MainWindow::slotAddEffect(const QDomElement effect)
824 if (!m_activeDocument) return;
825 if (effect.isNull()) {
826 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
829 QDomElement effectToAdd = effect.cloneNode().toElement();
831 int ix = m_effectStack->isTrackMode(&ok);
832 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
833 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
836 void MainWindow::slotUpdateClip(const QString &id)
838 if (!m_activeDocument) return;
839 m_activeTimeline->projectView()->slotUpdateClip(id);
842 void MainWindow::slotConnectMonitors()
844 m_projectList->setRenderer(m_projectMonitor->render);
845 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
846 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
847 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
848 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
849 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
850 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
851 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
852 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)));
854 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
856 connect(m_projectMonitor->render, SIGNAL(blockClipMonitor(const QString)), this, SLOT(slotBlockClipMonitor(const QString)));
857 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
859 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
861 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
862 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
864 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
866 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
867 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
870 void MainWindow::slotAdjustClipMonitor()
872 m_clipMonitorDock->updateGeometry();
873 m_clipMonitorDock->adjustSize();
874 m_clipMonitor->resetSize();
877 void MainWindow::slotAdjustProjectMonitor()
879 m_projectMonitorDock->updateGeometry();
880 m_projectMonitorDock->adjustSize();
881 m_projectMonitor->resetSize();
885 class NameGrabbingKActionCollection {
887 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
888 : m_collection(collection), m_action_names(action_names) {
889 m_action_names.clear();
891 KAction* addAction(const QString& action_name) {
892 m_action_names << action_name;
893 return m_collection->addAction(action_name);
895 void addAction(const QString& action_name, QAction* action) {
896 m_action_names << action_name;
897 m_collection->addAction(action_name, action);
899 operator KActionCollection*() { return m_collection; }
900 const QStringList& actionNames() const { return m_action_names; }
902 KActionCollection* m_collection;
903 QStringList& m_action_names;
906 void MainWindow::setupActions()
909 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
910 m_timecodeFormat = new KComboBox(this);
911 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
912 m_timecodeFormat->addItem(i18n("Frames"));
913 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
914 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
916 m_statusProgressBar = new QProgressBar(this);
917 m_statusProgressBar->setMinimum(0);
918 m_statusProgressBar->setMaximum(100);
919 m_statusProgressBar->setMaximumWidth(150);
920 m_statusProgressBar->setVisible(false);
922 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
923 toolbar->setMovable(false);
924 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
925 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
926 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
927 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
928 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
929 QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
930 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
932 //create edit mode buttons
933 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
934 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
935 toolbar->addAction(m_normalEditTool);
936 m_normalEditTool->setCheckable(true);
937 m_normalEditTool->setChecked(true);
939 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
940 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
941 toolbar->addAction(m_overwriteEditTool);
942 m_overwriteEditTool->setCheckable(true);
943 m_overwriteEditTool->setChecked(false);
945 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
946 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
947 toolbar->addAction(m_insertEditTool);
948 m_insertEditTool->setCheckable(true);
949 m_insertEditTool->setChecked(false);
950 // not implemented yet
951 m_insertEditTool->setEnabled(false);
953 QActionGroup *editGroup = new QActionGroup(this);
954 editGroup->addAction(m_normalEditTool);
955 editGroup->addAction(m_overwriteEditTool);
956 editGroup->addAction(m_insertEditTool);
957 editGroup->setExclusive(true);
958 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
959 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
961 toolbar->addSeparator();
963 // create tools buttons
964 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
965 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
966 toolbar->addAction(m_buttonSelectTool);
967 m_buttonSelectTool->setCheckable(true);
968 m_buttonSelectTool->setChecked(true);
970 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
971 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
972 toolbar->addAction(m_buttonRazorTool);
973 m_buttonRazorTool->setCheckable(true);
974 m_buttonRazorTool->setChecked(false);
976 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
977 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
978 toolbar->addAction(m_buttonSpacerTool);
979 m_buttonSpacerTool->setCheckable(true);
980 m_buttonSpacerTool->setChecked(false);
982 QActionGroup *toolGroup = new QActionGroup(this);
983 toolGroup->addAction(m_buttonSelectTool);
984 toolGroup->addAction(m_buttonRazorTool);
985 toolGroup->addAction(m_buttonSpacerTool);
986 toolGroup->setExclusive(true);
987 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
989 QWidget * actionWidget;
990 int max = toolbar->iconSizeDefault() + 2;
991 actionWidget = toolbar->widgetForAction(m_normalEditTool);
992 actionWidget->setMaximumWidth(max);
993 actionWidget->setMaximumHeight(max - 4);
995 actionWidget = toolbar->widgetForAction(m_insertEditTool);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
999 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1000 actionWidget->setMaximumWidth(max);
1001 actionWidget->setMaximumHeight(max - 4);
1003 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1004 actionWidget->setMaximumWidth(max);
1005 actionWidget->setMaximumHeight(max - 4);
1007 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1008 actionWidget->setMaximumWidth(max);
1009 actionWidget->setMaximumHeight(max - 4);
1011 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1012 actionWidget->setMaximumWidth(max);
1013 actionWidget->setMaximumHeight(max - 4);
1015 toolbar->setStyleSheet(style1);
1016 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1018 toolbar->addSeparator();
1019 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1020 toolbar->addAction(m_buttonFitZoom);
1021 m_buttonFitZoom->setCheckable(false);
1023 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1024 toolbar->addAction(m_zoomOut);
1025 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1027 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1028 m_zoomSlider->setMaximum(13);
1029 m_zoomSlider->setPageStep(1);
1030 m_zoomSlider->setInvertedAppearance(true);
1032 m_zoomSlider->setMaximumWidth(150);
1033 m_zoomSlider->setMinimumWidth(100);
1034 toolbar->addWidget(m_zoomSlider);
1036 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1037 toolbar->addAction(m_zoomIn);
1038 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1040 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1041 actionWidget->setMaximumWidth(max);
1042 actionWidget->setMaximumHeight(max - 4);
1043 actionWidget->setStyleSheet(styleBorderless);
1045 actionWidget = toolbar->widgetForAction(m_zoomIn);
1046 actionWidget->setMaximumWidth(max);
1047 actionWidget->setMaximumHeight(max - 4);
1048 actionWidget->setStyleSheet(styleBorderless);
1050 actionWidget = toolbar->widgetForAction(m_zoomOut);
1051 actionWidget->setMaximumWidth(max);
1052 actionWidget->setMaximumHeight(max - 4);
1053 actionWidget->setStyleSheet(styleBorderless);
1055 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1056 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1057 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1058 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1059 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1061 toolbar->addSeparator();
1063 //create automatic audio split button
1064 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1065 toolbar->addAction(m_buttonAutomaticSplitAudio);
1066 m_buttonAutomaticSplitAudio->setCheckable(true);
1067 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1068 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1070 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1071 toolbar->addAction(m_buttonVideoThumbs);
1072 m_buttonVideoThumbs->setCheckable(true);
1073 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1074 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1076 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1077 toolbar->addAction(m_buttonAudioThumbs);
1078 m_buttonAudioThumbs->setCheckable(true);
1079 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1080 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1082 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1083 toolbar->addAction(m_buttonShowMarkers);
1084 m_buttonShowMarkers->setCheckable(true);
1085 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1086 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1088 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1089 toolbar->addAction(m_buttonSnap);
1090 m_buttonSnap->setCheckable(true);
1091 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1092 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1094 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1095 actionWidget->setMaximumWidth(max);
1096 actionWidget->setMaximumHeight(max - 4);
1098 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1099 actionWidget->setMaximumWidth(max);
1100 actionWidget->setMaximumHeight(max - 4);
1102 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1103 actionWidget->setMaximumWidth(max);
1104 actionWidget->setMaximumHeight(max - 4);
1106 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1107 actionWidget->setMaximumWidth(max);
1108 actionWidget->setMaximumHeight(max - 4);
1110 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1111 actionWidget->setMaximumWidth(max);
1112 actionWidget->setMaximumHeight(max - 4);
1114 m_messageLabel = new StatusBarMessageLabel(this);
1115 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1117 statusBar()->addWidget(m_messageLabel, 10);
1118 statusBar()->addWidget(m_statusProgressBar, 0);
1119 statusBar()->addPermanentWidget(toolbar);
1120 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1121 statusBar()->addPermanentWidget(m_timecodeFormat);
1122 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1124 collection.addAction("normal_mode", m_normalEditTool);
1125 collection.addAction("overwrite_mode", m_overwriteEditTool);
1126 collection.addAction("insert_mode", m_insertEditTool);
1127 collection.addAction("select_tool", m_buttonSelectTool);
1128 collection.addAction("razor_tool", m_buttonRazorTool);
1129 collection.addAction("spacer_tool", m_buttonSpacerTool);
1131 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1132 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1133 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1134 collection.addAction("show_markers", m_buttonShowMarkers);
1135 collection.addAction("snap", m_buttonSnap);
1136 collection.addAction("zoom_fit", m_buttonFitZoom);
1137 collection.addAction("zoom_in", m_zoomIn);
1138 collection.addAction("zoom_out", m_zoomOut);
1140 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1141 collection.addAction("project_find", m_projectSearch);
1142 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1143 m_projectSearch->setShortcut(Qt::Key_Slash);
1145 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1146 collection.addAction("project_find_next", m_projectSearchNext);
1147 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1148 m_projectSearchNext->setShortcut(Qt::Key_F3);
1149 m_projectSearchNext->setEnabled(false);
1151 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1152 collection.addAction("manage_profiles", profilesAction);
1153 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1155 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1156 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1157 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1158 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1160 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1161 collection.addAction("run_wizard", wizAction);
1162 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1164 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1165 collection.addAction("project_settings", projectAction);
1166 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1168 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1169 collection.addAction("open_backup", backupAction);
1170 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1172 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1173 collection.addAction("project_render", projectRender);
1174 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1175 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1177 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1178 collection.addAction("project_clean", projectClean);
1179 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1181 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1182 collection.addAction("project_adjust_profile", projectAdjust);
1183 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1185 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1186 KShortcut playShortcut;
1187 playShortcut.setPrimary(Qt::Key_Space);
1188 playShortcut.setAlternate(Qt::Key_K);
1189 monitorPlay->setShortcut(playShortcut);
1190 collection.addAction("monitor_play", monitorPlay);
1191 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1193 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1194 collection.addAction("monitor_pause", monitorPause);
1195 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1197 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1198 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1199 collection.addAction("monitor_play_zone", m_playZone);
1200 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1202 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1203 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1204 collection.addAction("monitor_loop_zone", m_loopZone);
1205 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1207 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1208 m_loopClip->setEnabled(false);
1209 collection.addAction("monitor_loop_clip", m_loopClip);
1210 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1212 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1213 collection.addAction("dvd_wizard", dvdWizard);
1214 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1216 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1217 collection.addAction("transcode_clip", transcodeClip);
1218 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1220 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1221 collection.addAction("archive_project", archiveProject);
1222 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1225 KAction *markIn = collection.addAction("mark_in");
1226 markIn->setText(i18n("Set Zone In"));
1227 markIn->setShortcut(Qt::Key_I);
1228 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1230 KAction *markOut = collection.addAction("mark_out");
1231 markOut->setText(i18n("Set Zone Out"));
1232 markOut->setShortcut(Qt::Key_O);
1233 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1235 KAction *switchMon = collection.addAction("switch_monitor");
1236 switchMon->setText(i18n("Switch monitor"));
1237 switchMon->setShortcut(Qt::Key_T);
1238 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1240 KAction *fullMon = collection.addAction("monitor_fullscreen");
1241 fullMon->setText(i18n("Switch monitor fullscreen"));
1242 fullMon->setIcon(KIcon("view-fullscreen"));
1243 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1245 KAction *insertTree = collection.addAction("insert_project_tree");
1246 insertTree->setText(i18n("Insert zone in project tree"));
1247 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1248 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1250 KAction *insertTimeline = collection.addAction("insert_timeline");
1251 insertTimeline->setText(i18n("Insert zone in timeline"));
1252 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1253 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1255 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1256 collection.addAction("resize_timeline_clip_start", resizeStart);
1257 resizeStart->setShortcut(Qt::Key_1);
1258 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1260 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1261 collection.addAction("resize_timeline_clip_end", resizeEnd);
1262 resizeEnd->setShortcut(Qt::Key_2);
1263 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1265 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1266 monitorSeekBackward->setShortcut(Qt::Key_J);
1267 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1268 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1270 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1271 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1272 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1273 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1275 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1276 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1277 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1278 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1280 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1281 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1282 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1283 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1285 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1286 monitorSeekForward->setShortcut(Qt::Key_L);
1287 collection.addAction("monitor_seek_forward", monitorSeekForward);
1288 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1290 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1291 clipStart->setShortcut(Qt::Key_Home);
1292 collection.addAction("seek_clip_start", clipStart);
1293 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1295 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1296 clipEnd->setShortcut(Qt::Key_End);
1297 collection.addAction("seek_clip_end", clipEnd);
1298 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1300 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1301 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1302 collection.addAction("seek_zone_start", zoneStart);
1303 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1305 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1306 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1307 collection.addAction("seek_zone_end", zoneEnd);
1308 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1310 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1311 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1312 collection.addAction("seek_start", projectStart);
1313 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1315 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1316 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1317 collection.addAction("seek_end", projectEnd);
1318 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1320 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1321 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1322 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1323 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1325 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1326 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1327 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1328 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1330 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1331 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1332 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1333 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1335 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1336 deleteItem->setShortcut(Qt::Key_Delete);
1337 collection.addAction("delete_timeline_clip", deleteItem);
1338 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1340 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1341 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1342 editTimelineClipSpeed->setData("change_speed");
1343 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1345 KAction *stickTransition = collection.addAction("auto_transition");
1346 stickTransition->setData(QString("auto"));
1347 stickTransition->setCheckable(true);
1348 stickTransition->setEnabled(false);
1349 stickTransition->setText(i18n("Automatic Transition"));
1350 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1352 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1353 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1354 collection.addAction("group_clip", groupClip);
1355 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1357 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1358 collection.addAction("ungroup_clip", ungroupClip);
1359 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1360 ungroupClip->setData("ungroup_clip");
1361 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1363 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1364 collection.addAction("edit_item_duration", editItemDuration);
1365 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1367 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1368 collection.addAction("clip_in_project_tree", clipInProjectTree);
1369 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1371 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1372 collection.addAction("clip_to_project_tree", clipToProjectTree);
1373 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1375 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1376 insertOvertwrite->setShortcut(Qt::Key_V);
1377 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1378 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1380 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1381 selectTimelineClip->setShortcut(Qt::Key_Plus);
1382 collection.addAction("select_timeline_clip", selectTimelineClip);
1383 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1385 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1386 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1387 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1388 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1390 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1391 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1392 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1393 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1395 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1396 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1397 collection.addAction("select_timeline_transition", selectTimelineTransition);
1398 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1400 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1401 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1402 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1403 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1405 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1406 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1407 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1408 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1410 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1411 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1412 collection.addAction("cut_timeline_clip", cutTimelineClip);
1413 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1415 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1416 collection.addAction("add_clip_marker", addClipMarker);
1417 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1419 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1420 collection.addAction("delete_clip_marker", deleteClipMarker);
1421 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1423 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1424 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1425 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1427 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1428 editClipMarker->setData(QString("edit_marker"));
1429 collection.addAction("edit_clip_marker", editClipMarker);
1430 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1432 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1433 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1434 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1435 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1437 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1438 collection.addAction("split_audio", splitAudio);
1439 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1441 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1442 collection.addAction("clip_audio_only", audioOnly);
1443 audioOnly->setData("clip_audio_only");
1444 audioOnly->setCheckable(true);
1446 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1447 collection.addAction("clip_video_only", videoOnly);
1448 videoOnly->setData("clip_video_only");
1449 videoOnly->setCheckable(true);
1451 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1452 collection.addAction("clip_audio_and_video", audioAndVideo);
1453 audioAndVideo->setData("clip_audio_and_video");
1454 audioAndVideo->setCheckable(true);
1456 m_clipTypeGroup = new QActionGroup(this);
1457 m_clipTypeGroup->addAction(audioOnly);
1458 m_clipTypeGroup->addAction(videoOnly);
1459 m_clipTypeGroup->addAction(audioAndVideo);
1460 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1461 m_clipTypeGroup->setEnabled(false);
1463 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1464 collection.addAction("insert_space", insertSpace);
1465 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1467 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1468 collection.addAction("delete_space", removeSpace);
1469 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1471 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1472 collection.addAction("insert_track", insertTrack);
1473 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1475 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1476 collection.addAction("delete_track", deleteTrack);
1477 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1479 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1480 collection.addAction("config_tracks", configTracks);
1481 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1483 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1484 collection.addAction("add_guide", addGuide);
1485 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1487 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1488 collection.addAction("delete_guide", delGuide);
1489 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1491 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1492 collection.addAction("edit_guide", editGuide);
1493 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1495 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1496 collection.addAction("delete_all_guides", delAllGuides);
1497 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1499 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1500 collection.addAction("paste_effects", pasteEffects);
1501 pasteEffects->setData("paste_effects");
1502 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1504 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1505 collection.addAction("show_timeline", showTimeline);
1506 showTimeline->setCheckable(true);
1507 showTimeline->setChecked(true);
1508 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1510 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1511 collection.addAction("show_titlebars", showTitleBar);
1512 showTitleBar->setCheckable(true);
1513 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1514 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1515 slotShowTitleBars(KdenliveSettings::showtitlebars());
1517 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1518 KStandardAction::quit(this, SLOT(close()), collection);
1519 KStandardAction::open(this, SLOT(openFile()), collection);
1520 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1521 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1522 KStandardAction::openNew(this, SLOT(newFile()), collection);
1523 // TODO: make the following connection to slotEditKeys work
1524 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1525 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1526 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1527 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1528 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1529 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1531 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1532 undo->setEnabled(false);
1533 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1535 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1536 redo->setEnabled(false);
1537 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1540 //TODO: Add status tooltip to actions ?
1541 connect(collection, SIGNAL(actionHovered(QAction*)),
1542 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1545 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1546 collection.addAction("add_clip", addClip);
1547 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1549 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1550 collection.addAction("add_color_clip", addColorClip);
1551 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1553 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1554 collection.addAction("add_slide_clip", addSlideClip);
1555 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1557 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1558 collection.addAction("add_text_clip", addTitleClip);
1559 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1561 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1562 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1563 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1565 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1566 collection.addAction("add_folder", addFolderButton);
1567 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1569 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1570 collection.addAction("clip_properties", clipProperties);
1571 clipProperties->setData("clip_properties");
1572 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1573 clipProperties->setEnabled(false);
1575 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1576 collection.addAction("edit_clip", openClip);
1577 openClip->setData("edit_clip");
1578 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1579 openClip->setEnabled(false);
1581 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1582 collection.addAction("delete_clip", deleteClip);
1583 deleteClip->setData("delete_clip");
1584 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1585 deleteClip->setEnabled(false);
1587 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1588 collection.addAction("reload_clip", reloadClip);
1589 reloadClip->setData("reload_clip");
1590 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1591 reloadClip->setEnabled(false);
1593 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1594 collection.addAction("proxy_clip", proxyClip);
1595 proxyClip->setData("proxy_clip");
1596 proxyClip->setCheckable(true);
1597 proxyClip->setChecked(false);
1598 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1600 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1601 collection.addAction("stopmotion", stopMotion);
1602 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1604 QMenu *addClips = new QMenu();
1605 addClips->addAction(addClip);
1606 addClips->addAction(addColorClip);
1607 addClips->addAction(addSlideClip);
1608 addClips->addAction(addTitleClip);
1609 addClips->addAction(addTitleTemplateClip);
1610 addClips->addAction(addFolderButton);
1612 addClips->addAction(reloadClip);
1613 addClips->addAction(proxyClip);
1614 addClips->addAction(clipProperties);
1615 addClips->addAction(openClip);
1616 addClips->addAction(deleteClip);
1617 m_projectList->setupMenu(addClips, addClip);
1619 // Setup effects and transitions actions.
1620 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1621 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1622 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1623 m_transitions = new KAction*[transitions.count()];
1624 for (int i = 0; i < transitions.count(); i++) {
1625 QStringList effectInfo = transitions.effectIdInfo(i);
1626 m_transitions[i] = new KAction(effectInfo.at(0), this);
1627 m_transitions[i]->setData(effectInfo);
1628 m_transitions[i]->setIconVisibleInMenu(false);
1629 QString id = effectInfo.at(2);
1630 if (id.isEmpty()) id = effectInfo.at(1);
1631 transitionActions->addAction("transition_" + id, m_transitions[i]);
1633 //m_effectsActionCollection->readSettings();
1637 void MainWindow::slotDisplayActionMessage(QAction *a)
1639 statusBar()->showMessage(a->data().toString(), 3000);
1642 void MainWindow::loadLayouts()
1644 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1645 if (m_loadLayout == NULL || saveLayout == NULL) return;
1646 KSharedConfigPtr config = KGlobal::config();
1647 KConfigGroup layoutGroup(config, "Layouts");
1648 QStringList entries = layoutGroup.keyList();
1649 QList<QAction *> loadActions = m_loadLayout->actions();
1650 QList<QAction *> saveActions = saveLayout->actions();
1651 for (int i = 1; i < 5; i++) {
1652 // Rename the layouts actions
1653 foreach(const QString & key, entries) {
1654 if (key.endsWith(QString("_%1").arg(i))) {
1655 // Found previously saved layout
1656 QString layoutName = key.section("_", 0, -2);
1657 for (int j = 0; j < loadActions.count(); j++) {
1658 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1659 loadActions[j]->setText(layoutName);
1660 loadActions[j]->setData(key);
1664 for (int j = 0; j < saveActions.count(); j++) {
1665 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1666 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1667 saveActions[j]->setData(key);
1676 void MainWindow::slotLoadLayout(QAction *action)
1678 if (!action) return;
1679 QString layoutId = action->data().toString();
1680 if (layoutId.isEmpty()) return;
1681 KSharedConfigPtr config = KGlobal::config();
1682 KConfigGroup layouts(config, "Layouts");
1683 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1684 restoreState(state);
1687 void MainWindow::slotSaveLayout(QAction *action)
1689 QString originallayoutName = action->data().toString();
1690 int layoutId = originallayoutName.section('_', -1).toInt();
1692 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1693 if (layoutName.isEmpty()) return;
1694 KSharedConfigPtr config = KGlobal::config();
1695 KConfigGroup layouts(config, "Layouts");
1696 layouts.deleteEntry(originallayoutName);
1698 QByteArray st = saveState();
1699 layoutName.append("_" + QString::number(layoutId));
1700 layouts.writeEntry(layoutName, st.toBase64());
1704 void MainWindow::saveOptions()
1706 KdenliveSettings::self()->writeConfig();
1707 KSharedConfigPtr config = KGlobal::config();
1708 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1709 KConfigGroup treecolumns(config, "Project Tree");
1710 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1714 void MainWindow::readOptions()
1716 KSharedConfigPtr config = KGlobal::config();
1717 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1718 KConfigGroup initialGroup(config, "version");
1719 bool upgrade = false;
1720 if (initialGroup.exists()) {
1721 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1725 if (initialGroup.readEntry("version") == "0.7") {
1726 //Add new settings from 0.7.1
1727 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1728 QString path = QDir::homePath() + "/kdenlive";
1729 if (KStandardDirs::makeDir(path) == false) {
1730 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1731 } else KdenliveSettings::setDefaultprojectfolder(path);
1737 if (!initialGroup.exists() || upgrade) {
1738 // this is our first run, show Wizard
1739 Wizard *w = new Wizard(upgrade, this);
1740 if (w->exec() == QDialog::Accepted && w->isOk()) {
1741 w->adjustSettings();
1742 initialGroup.writeEntry("version", version);
1748 KConfigGroup treecolumns(config, "Project Tree");
1749 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1750 if (!state.isEmpty())
1751 m_projectList->setHeaderInfo(state);
1754 void MainWindow::slotRunWizard()
1756 Wizard *w = new Wizard(false, this);
1757 if (w->exec() == QDialog::Accepted && w->isOk()) {
1758 w->adjustSettings();
1763 void MainWindow::newFile(bool showProjectSettings, bool force)
1765 if (!m_timelineArea->isEnabled() && !force)
1767 m_fileRevert->setEnabled(false);
1768 QString profileName = KdenliveSettings::default_profile();
1769 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1770 QMap <QString, QString> documentProperties;
1771 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1772 if (!showProjectSettings) {
1773 // set up default properties
1774 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1775 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1776 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1777 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1778 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1779 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1780 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1781 if (!KdenliveSettings::activatetabs())
1782 if (!closeCurrentDocument())
1785 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1786 if (w->exec() != QDialog::Accepted)
1788 if (!KdenliveSettings::activatetabs())
1789 if (!closeCurrentDocument())
1791 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1792 slotSwitchVideoThumbs();
1793 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1794 slotSwitchAudioThumbs();
1795 profileName = w->selectedProfile();
1796 projectFolder = w->selectedFolder();
1797 projectTracks = w->tracks();
1798 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1799 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1800 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1801 documentProperties.insert("proxyparams", w->proxyParams());
1802 documentProperties.insert("proxyextension", w->proxyExtension());
1803 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1804 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1807 m_timelineArea->setEnabled(true);
1808 m_projectList->setEnabled(true);
1810 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1811 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1813 TrackView *trackView = new TrackView(doc, &ok, this);
1814 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1817 //m_timelineArea->setEnabled(false);
1818 //m_projectList->setEnabled(false);
1822 if (m_timelineArea->count() == 1) {
1823 connectDocumentInfo(doc);
1824 connectDocument(trackView, doc);
1826 m_timelineArea->setTabBarHidden(false);
1827 m_monitorManager->activateMonitor("clip");
1828 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1831 void MainWindow::activateDocument()
1833 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1834 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1835 KdenliveDoc *currentDoc = currentTab->document();
1836 connectDocumentInfo(currentDoc);
1837 connectDocument(currentTab, currentDoc);
1840 bool MainWindow::closeCurrentDocument(bool saveChanges)
1842 QWidget *w = m_timelineArea->currentWidget();
1843 if (!w) return true;
1844 // closing current document
1845 int ix = m_timelineArea->currentIndex() + 1;
1846 if (ix == m_timelineArea->count()) ix = 0;
1847 m_timelineArea->setCurrentIndex(ix);
1848 TrackView *tabToClose = (TrackView *) w;
1849 KdenliveDoc *docToClose = tabToClose->document();
1850 if (docToClose && docToClose->isModified() && saveChanges) {
1852 if (m_activeDocument->url().fileName().isEmpty())
1853 message = i18n("Save changes to document?");
1855 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1856 switch (KMessageBox::warningYesNoCancel(this, message)) {
1857 case KMessageBox::Yes :
1858 // save document here. If saving fails, return false;
1859 if (saveFile() == false) return false;
1861 case KMessageBox::Cancel :
1868 m_clipMonitor->slotSetXml(NULL);
1869 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1870 if (m_timelineArea->count() == 1) {
1871 m_timelineArea->setTabBarHidden(true);
1872 m_closeAction->setEnabled(false);
1874 if (docToClose == m_activeDocument) {
1875 delete m_activeDocument;
1876 m_activeDocument = NULL;
1877 m_effectStack->clear();
1878 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1882 if (w == m_activeTimeline) {
1883 delete m_activeTimeline;
1884 m_activeTimeline = NULL;
1891 bool MainWindow::saveFileAs(const QString &outputFileName)
1893 QString currentSceneList;
1894 m_monitorManager->stopActiveMonitor();
1896 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1899 // Save timeline thumbnails
1900 m_activeTimeline->projectView()->saveThumbnails();
1901 m_activeDocument->setUrl(KUrl(outputFileName));
1902 if (m_activeDocument->m_autosave == NULL) {
1903 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1904 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1905 setCaption(m_activeDocument->description());
1906 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1907 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1908 m_activeDocument->setModified(false);
1909 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1910 m_fileRevert->setEnabled(true);
1911 m_undoView->stack()->setClean();
1915 bool MainWindow::saveFileAs()
1917 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1918 if (outputFile.isEmpty()) {
1921 if (QFile::exists(outputFile)) {
1922 // Show the file dialog again if the user does not want to overwrite the file
1923 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1924 return saveFileAs();
1926 return saveFileAs(outputFile);
1929 bool MainWindow::saveFile()
1931 if (!m_activeDocument) return true;
1932 if (m_activeDocument->url().isEmpty()) {
1933 return saveFileAs();
1935 bool result = saveFileAs(m_activeDocument->url().path());
1936 m_activeDocument->m_autosave->resize(0);
1941 void MainWindow::openFile()
1943 if (!m_startUrl.isEmpty()) {
1944 openFile(m_startUrl);
1945 m_startUrl = KUrl();
1948 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1949 if (url.isEmpty()) return;
1950 m_fileOpenRecent->addUrl(url);
1954 void MainWindow::openLastFile()
1956 KSharedConfigPtr config = KGlobal::config();
1957 KUrl::List urls = m_fileOpenRecent->urls();
1958 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1959 if (urls.isEmpty()) newFile(false);
1960 else openFile(urls.last());
1963 void MainWindow::openFile(const KUrl &url)
1965 // Make sure the url is a Kdenlive project file
1966 KMimeType::Ptr mime = KMimeType::findByUrl(url);
1967 if (mime.data()->is("application/x-compressed-tar")) {
1968 // Opening a compressed project file, we need to process it
1969 kDebug()<<"Opening archive, processing";
1970 ArchiveWidget *ar = new ArchiveWidget(url);
1971 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
1975 if (!url.fileName().endsWith(".kdenlive")) {
1976 // This is not a Kdenlive project file, abort loading
1977 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
1981 // Check if the document is already opened
1982 const int ct = m_timelineArea->count();
1983 bool isOpened = false;
1985 for (i = 0; i < ct; i++) {
1986 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1987 KdenliveDoc *doc = tab->document();
1988 if (doc->url() == url) {
1994 m_timelineArea->setCurrentIndex(i);
1998 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2000 // Check for backup file
2001 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2002 if (!staleFiles.isEmpty()) {
2003 if (KMessageBox::questionYesNo(this,
2004 i18n("Auto-saved files exist. Do you want to recover them now?"),
2005 i18n("File Recovery"),
2006 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2007 recoverFiles(staleFiles);
2010 // remove the stale files
2011 foreach(KAutoSaveFile * stale, staleFiles) {
2012 stale->open(QIODevice::ReadWrite);
2017 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2018 m_messageLabel->repaint();
2019 doOpenFile(url, NULL);
2022 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2024 if (!m_timelineArea->isEnabled()) return;
2025 m_fileRevert->setEnabled(true);
2027 // Recreate stopmotion widget on document change
2029 delete m_stopmotion;
2030 m_stopmotion = NULL;
2034 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2035 progressDialog.setAllowCancel(false);
2036 progressDialog.progressBar()->setMaximum(4);
2037 progressDialog.show();
2038 progressDialog.progressBar()->setValue(0);
2039 qApp->processEvents();
2042 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
2044 progressDialog.progressBar()->setValue(1);
2045 progressDialog.progressBar()->setMaximum(4);
2046 progressDialog.setLabelText(i18n("Loading project"));
2047 qApp->processEvents();
2049 if (stale == NULL) {
2050 stale = new KAutoSaveFile(url, doc);
2051 doc->m_autosave = stale;
2053 doc->m_autosave = stale;
2054 doc->setUrl(stale->managedFile());
2055 doc->setModified(true);
2056 stale->setParent(doc);
2058 connectDocumentInfo(doc);
2060 progressDialog.progressBar()->setValue(2);
2061 qApp->processEvents();
2064 TrackView *trackView = new TrackView(doc, &ok, this);
2066 progressDialog.progressBar()->setValue(3);
2067 qApp->processEvents();
2069 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2071 m_timelineArea->setEnabled(false);
2072 m_projectList->setEnabled(false);
2073 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2074 slotGotProgressInfo(QString(), -1);
2075 newFile(false, true);
2078 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2079 trackView->setDuration(trackView->duration());
2080 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2082 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2083 slotGotProgressInfo(QString(), -1);
2084 m_projectMonitor->adjustRulerSize(trackView->duration());
2085 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2086 m_clipMonitor->refreshMonitor(true);
2088 progressDialog.progressBar()->setValue(4);
2089 if (openBackup) slotOpenBackupDialog(url);
2092 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2094 foreach(KAutoSaveFile * stale, staleFiles) {
2095 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2096 // show an error message; we could not steal the lockfile
2097 // maybe another application got to the file before us?
2101 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2102 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2103 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2104 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2108 void MainWindow::parseProfiles(const QString &mltPath)
2110 //KdenliveSettings::setDefaulttmpfolder();
2111 if (!mltPath.isEmpty()) {
2112 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2113 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2116 if (KdenliveSettings::mltpath().isEmpty())
2117 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2119 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2120 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2121 if (!QFile::exists(meltPath))
2122 meltPath = KStandardDirs::findExe("melt");
2123 KdenliveSettings::setRendererpath(meltPath);
2126 if (KdenliveSettings::rendererpath().isEmpty()) {
2127 // Cannot find the MLT melt renderer, ask for location
2128 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2129 if (getUrl->exec() == QDialog::Rejected) {
2132 KUrl rendererPath = getUrl->selectedUrl();
2134 if (rendererPath.isEmpty()) ::exit(0);
2135 KdenliveSettings::setRendererpath(rendererPath.path());
2138 QStringList profilesFilter;
2139 profilesFilter << "*";
2140 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2141 if (profilesList.isEmpty()) {
2142 // Cannot find MLT path, try finding melt
2143 QString profilePath = KdenliveSettings::rendererpath();
2144 if (!profilePath.isEmpty()) {
2145 profilePath = profilePath.section('/', 0, -3);
2146 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2147 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2149 if (profilesList.isEmpty()) {
2150 // Cannot find the MLT profiles, ask for location
2151 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2152 getUrl->fileDialog()->setMode(KFile::Directory);
2153 if (getUrl->exec() == QDialog::Rejected) {
2156 KUrl mltPath = getUrl->selectedUrl();
2158 if (mltPath.isEmpty()) ::exit(0);
2159 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2160 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2164 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2166 // Parse again MLT profiles to build a list of available video formats
2167 if (profilesList.isEmpty()) parseProfiles();
2171 void MainWindow::slotEditProfiles()
2173 ProfilesDialog *w = new ProfilesDialog;
2174 if (w->exec() == QDialog::Accepted) {
2175 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2176 if (d) d->checkProfile();
2181 void MainWindow::slotDetectAudioDriver()
2183 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2184 leading to no audio output, see bug #934 */
2186 //decide which audio driver is really best, in some cases SDL is wrong
2187 if (KdenliveSettings::audiodrivername().isEmpty()) {
2189 KProcess readProcess;
2190 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2191 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2192 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2193 readProcess.setProgram("pactl", QStringList() << "stat");
2194 readProcess.execute(2000); // Kill it after 2 seconds
2196 QString result = QString(readProcess.readAllStandardOutput());
2197 kDebug() << "// / / / / / READING PACTL: ";
2199 if (!result.isEmpty()) {
2201 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2205 KdenliveSettings::setAutoaudiodrivername(driver);
2209 void MainWindow::slotEditProjectSettings()
2211 QPoint p = m_activeDocument->getTracksCount();
2212 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2213 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2215 if (w->exec() == QDialog::Accepted) {
2216 QString profile = w->selectedProfile();
2217 m_activeDocument->setProjectFolder(w->selectedFolder());
2219 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2221 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2222 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2223 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2224 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2225 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2226 m_activeDocument->setModified();
2227 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2228 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) {
2229 //TODO: rebuild all proxies
2230 //m_projectList->rebuildProxies();
2233 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2234 m_activeDocument->setModified();
2235 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2237 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2238 m_activeDocument->setModified();
2239 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2241 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2242 m_activeDocument->setModified();
2243 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2245 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2246 m_activeDocument->setModified();
2247 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2249 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2250 m_activeDocument->setModified();
2251 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2253 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2254 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2255 m_activeDocument->setModified();
2256 slotUpdateProxySettings();
2262 void MainWindow::slotDisableProxies()
2264 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2265 m_activeDocument->setModified();
2266 slotUpdateProxySettings();
2269 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2271 // Recreate the stopmotion widget if profile changes
2273 delete m_stopmotion;
2274 m_stopmotion = NULL;
2277 // Deselect current effect / transition
2278 m_effectStack->slotClipItemSelected(NULL, 0);
2279 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2280 m_clipMonitor->slotSetXml(NULL);
2281 bool updateFps = m_activeDocument->setProfilePath(profile);
2282 KdenliveSettings::setCurrent_profile(profile);
2283 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2284 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2286 m_activeDocument->clipManager()->clearUnusedProducers();
2287 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2288 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2289 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2290 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2291 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2292 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2293 if (updateFps) m_activeTimeline->updateProjectFps();
2294 m_activeDocument->clipManager()->clearCache();
2295 m_activeTimeline->updateProfile();
2296 m_activeDocument->setModified(true);
2297 m_commandStack->activeStack()->clear();
2298 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2299 slotUpdateMousePosition(0);
2300 // We need to desactivate & reactivate monitors to get a refresh
2301 //m_monitorManager->switchMonitors();
2305 void MainWindow::slotRenderProject()
2307 if (!m_renderWidget) {
2308 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2309 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2310 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2311 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2312 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2313 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2314 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2315 if (m_activeDocument) {
2316 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2317 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2318 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2319 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2322 slotCheckRenderStatus();
2323 m_renderWidget->show();
2324 m_renderWidget->showNormal();
2326 // What are the following lines supposed to do?
2327 //m_activeTimeline->tracksNumber();
2328 //m_renderWidget->enableAudio(false);
2329 //m_renderWidget->export_audio;
2332 void MainWindow::slotCheckRenderStatus()
2334 // Make sure there are no missing clips
2336 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2339 void MainWindow::setRenderingProgress(const QString &url, int progress)
2342 m_renderWidget->setRenderJob(url, progress);
2345 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2348 m_renderWidget->setRenderStatus(url, status, error);
2351 void MainWindow::slotCleanProject()
2353 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2354 m_projectList->cleanup();
2357 void MainWindow::slotUpdateMousePosition(int pos)
2359 if (m_activeDocument)
2360 switch (m_timecodeFormat->currentIndex()) {
2362 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2365 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2369 void MainWindow::slotUpdateDocumentState(bool modified)
2371 if (!m_activeDocument) return;
2372 setCaption(m_activeDocument->description(), modified);
2373 m_saveAction->setEnabled(modified);
2375 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2376 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2378 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2379 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2383 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2385 if (m_activeDocument) {
2386 if (m_activeDocument == doc) return;
2387 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2389 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2392 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2394 //m_projectMonitor->stop();
2395 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2396 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2397 if (m_activeDocument) {
2398 if (m_activeDocument == doc) return;
2399 if (m_activeTimeline) {
2400 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2401 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2402 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2403 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2404 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2405 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2406 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2407 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2409 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2411 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2412 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2413 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2414 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2415 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2416 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2417 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2418 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2419 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2420 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2421 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2422 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2423 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2424 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2425 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2426 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2427 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2428 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2429 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2430 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2431 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2432 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2433 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2434 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2435 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2436 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2437 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2438 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2439 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2440 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2441 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2442 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2443 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2444 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2445 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2446 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2447 m_effectStack->clear();
2449 //m_activeDocument->setRenderer(NULL);
2450 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2451 m_clipMonitor->stop();
2453 KdenliveSettings::setCurrent_profile(doc->profilePath());
2454 KdenliveSettings::setProject_fps(doc->fps());
2455 m_monitorManager->resetProfiles(doc->timecode());
2456 m_projectList->setDocument(doc);
2457 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2458 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2459 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2460 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2461 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2463 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2464 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2465 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2467 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2470 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2471 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2472 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2473 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2474 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2475 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2476 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2477 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2478 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2479 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2480 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2481 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2482 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2483 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2485 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2486 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2487 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2488 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2489 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2491 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2492 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2493 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2495 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2497 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2498 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2499 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2500 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2502 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2503 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2504 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2505 m_zoomSlider->setValue(doc->zoom().x());
2506 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2507 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2508 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2509 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2511 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2512 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2514 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2515 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2517 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2518 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2519 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2520 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2521 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2522 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2523 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2524 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2525 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2526 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2527 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2529 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2530 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2531 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2532 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
2533 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2534 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2537 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2538 m_activeTimeline = trackView;
2539 if (m_renderWidget) {
2540 slotCheckRenderStatus();
2541 m_renderWidget->setProfile(doc->mltProfile());
2542 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2543 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2544 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2546 //doc->setRenderer(m_projectMonitor->render);
2547 m_commandStack->setActiveStack(doc->commandStack());
2548 KdenliveSettings::setProject_display_ratio(doc->dar());
2549 //doc->clipManager()->checkAudioThumbs();
2551 //m_overView->setScene(trackView->projectScene());
2552 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2553 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2555 setCaption(doc->description(), doc->isModified());
2556 m_saveAction->setEnabled(doc->isModified());
2557 m_normalEditTool->setChecked(true);
2558 m_activeDocument = doc;
2559 m_activeTimeline->updateProjectFps();
2560 m_activeDocument->checkProjectClips();
2562 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2564 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2565 slotUpdateMousePosition(0);
2566 // set tool to select tool
2567 m_buttonSelectTool->setChecked(true);
2570 void MainWindow::slotZoneMoved(int start, int end)
2572 m_activeDocument->setZone(start, end);
2573 m_projectMonitor->slotZoneMoved(start, end);
2576 void MainWindow::slotGuidesUpdated()
2579 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2582 void MainWindow::slotEditKeys()
2584 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2585 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2586 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2590 void MainWindow::slotPreferences(int page, int option)
2593 * An instance of your dialog could be already created and could be
2594 * cached, in which case you want to display the cached dialog
2595 * instead of creating another one
2597 if (m_stopmotion) m_stopmotion->slotLive(false);
2598 if (KConfigDialog::showDialog("settings")) {
2599 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2600 if (page != -1) d->showPage(page, option);
2604 // KConfigDialog didn't find an instance of this dialog, so lets
2607 // Get the mappable actions in localized form
2608 QMap<QString, QString> actions;
2609 KActionCollection* collection = actionCollection();
2610 foreach (const QString& action_name, m_action_names) {
2611 actions[collection->action(action_name)->text()] = action_name;
2614 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2615 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2616 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2618 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2621 if (page != -1) dialog->showPage(page, option);
2624 void MainWindow::slotUpdateCaptureFolder()
2628 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2629 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2633 void MainWindow::updateConfiguration()
2635 //TODO: we should apply settings to all projects, not only the current one
2636 if (m_activeTimeline) {
2637 m_activeTimeline->refresh();
2638 m_activeTimeline->projectView()->checkAutoScroll();
2639 m_activeTimeline->checkTrackHeight();
2640 if (m_activeDocument)
2641 m_activeDocument->clipManager()->checkAudioThumbs();
2643 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2644 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2645 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2646 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2648 // Update list of transcoding profiles
2650 #ifndef NO_JOGSHUTTLE
2651 activateShuttleDevice();
2652 #endif /* NO_JOGSHUTTLE */
2656 void MainWindow::slotSwitchSplitAudio()
2658 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2659 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2662 void MainWindow::slotSwitchVideoThumbs()
2664 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2665 if (m_activeTimeline)
2666 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2667 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2670 void MainWindow::slotSwitchAudioThumbs()
2672 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2673 if (m_activeTimeline) {
2674 m_activeTimeline->refresh();
2675 m_activeTimeline->projectView()->checkAutoScroll();
2676 if (m_activeDocument)
2677 m_activeDocument->clipManager()->checkAudioThumbs();
2679 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2682 void MainWindow::slotSwitchMarkersComments()
2684 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2685 if (m_activeTimeline)
2686 m_activeTimeline->refresh();
2687 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2690 void MainWindow::slotSwitchSnap()
2692 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2693 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2697 void MainWindow::slotDeleteItem()
2699 if (QApplication::focusWidget() &&
2700 QApplication::focusWidget()->parentWidget() &&
2701 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2702 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2703 m_projectList->slotRemoveClip();
2706 QWidget *widget = QApplication::focusWidget();
2708 if (widget == m_effectStackDock) {
2709 m_effectStack->slotItemDel();
2712 widget = widget->parentWidget();
2715 // effect stack has no focus
2716 if (m_activeTimeline)
2717 m_activeTimeline->projectView()->deleteSelectedClips();
2721 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2723 if (m_clipMonitor->isActive())
2724 m_clipMonitor->checkOverlay();
2725 m_clipMonitor->updateMarkers(clip);
2728 void MainWindow::slotAddClipMarker()
2730 DocClipBase *clip = NULL;
2732 if (m_projectMonitor->isActive()) {
2733 if (m_activeTimeline) {
2734 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2736 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2737 clip = item->baseClip();
2741 clip = m_clipMonitor->activeClip();
2742 pos = m_clipMonitor->position();
2745 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2748 QString id = clip->getId();
2749 CommentedTime marker(pos, i18n("Marker"));
2750 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2751 if (d.exec() == QDialog::Accepted)
2752 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2755 void MainWindow::slotDeleteClipMarker()
2757 DocClipBase *clip = NULL;
2759 if (m_projectMonitor->isActive()) {
2760 if (m_activeTimeline) {
2761 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2763 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2764 clip = item->baseClip();
2768 clip = m_clipMonitor->activeClip();
2769 pos = m_clipMonitor->position();
2772 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2776 QString id = clip->getId();
2777 QString comment = clip->markerComment(pos);
2778 if (comment.isEmpty()) {
2779 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2782 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2785 void MainWindow::slotDeleteAllClipMarkers()
2787 DocClipBase *clip = NULL;
2788 if (m_projectMonitor->isActive()) {
2789 if (m_activeTimeline) {
2790 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2792 clip = item->baseClip();
2796 clip = m_clipMonitor->activeClip();
2799 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2802 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2805 void MainWindow::slotEditClipMarker()
2807 DocClipBase *clip = NULL;
2809 if (m_projectMonitor->isActive()) {
2810 if (m_activeTimeline) {
2811 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2813 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2814 clip = item->baseClip();
2818 clip = m_clipMonitor->activeClip();
2819 pos = m_clipMonitor->position();
2822 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2826 QString id = clip->getId();
2827 QString oldcomment = clip->markerComment(pos);
2828 if (oldcomment.isEmpty()) {
2829 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2833 CommentedTime marker(pos, oldcomment);
2834 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2835 if (d.exec() == QDialog::Accepted) {
2836 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2837 if (d.newMarker().time() != pos) {
2838 // remove old marker
2839 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2844 void MainWindow::slotAddMarkerGuideQuickly()
2846 if (!m_activeTimeline || !m_activeDocument)
2849 if (m_clipMonitor->isActive()) {
2850 DocClipBase *clip = m_clipMonitor->activeClip();
2851 GenTime pos = m_clipMonitor->position();
2854 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2858 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2860 m_activeTimeline->projectView()->slotAddGuide(false);
2864 void MainWindow::slotAddGuide()
2866 if (m_activeTimeline)
2867 m_activeTimeline->projectView()->slotAddGuide();
2870 void MainWindow::slotInsertSpace()
2872 if (m_activeTimeline)
2873 m_activeTimeline->projectView()->slotInsertSpace();
2876 void MainWindow::slotRemoveSpace()
2878 if (m_activeTimeline)
2879 m_activeTimeline->projectView()->slotRemoveSpace();
2882 void MainWindow::slotInsertTrack(int ix)
2884 m_projectMonitor->activateMonitor();
2885 if (m_activeTimeline)
2886 m_activeTimeline->projectView()->slotInsertTrack(ix);
2887 if (m_activeDocument)
2888 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2891 void MainWindow::slotDeleteTrack(int ix)
2893 m_projectMonitor->activateMonitor();
2894 if (m_activeTimeline)
2895 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2896 if (m_activeDocument)
2897 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2900 void MainWindow::slotConfigTrack(int ix)
2902 m_projectMonitor->activateMonitor();
2903 if (m_activeTimeline)
2904 m_activeTimeline->projectView()->slotConfigTracks(ix);
2905 if (m_activeDocument)
2906 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2909 void MainWindow::slotEditGuide()
2911 if (m_activeTimeline)
2912 m_activeTimeline->projectView()->slotEditGuide();
2915 void MainWindow::slotDeleteGuide()
2917 if (m_activeTimeline)
2918 m_activeTimeline->projectView()->slotDeleteGuide();
2921 void MainWindow::slotDeleteAllGuides()
2923 if (m_activeTimeline)
2924 m_activeTimeline->projectView()->slotDeleteAllGuides();
2927 void MainWindow::slotCutTimelineClip()
2929 if (m_activeTimeline)
2930 m_activeTimeline->projectView()->cutSelectedClips();
2933 void MainWindow::slotInsertClipOverwrite()
2935 if (m_activeTimeline) {
2936 QStringList data = m_clipMonitor->getZoneInfo();
2937 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2941 void MainWindow::slotSelectTimelineClip()
2943 if (m_activeTimeline)
2944 m_activeTimeline->projectView()->selectClip(true);
2947 void MainWindow::slotSelectTimelineTransition()
2949 if (m_activeTimeline)
2950 m_activeTimeline->projectView()->selectTransition(true);
2953 void MainWindow::slotDeselectTimelineClip()
2955 if (m_activeTimeline)
2956 m_activeTimeline->projectView()->selectClip(false, true);
2959 void MainWindow::slotDeselectTimelineTransition()
2961 if (m_activeTimeline)
2962 m_activeTimeline->projectView()->selectTransition(false, true);
2965 void MainWindow::slotSelectAddTimelineClip()
2967 if (m_activeTimeline)
2968 m_activeTimeline->projectView()->selectClip(true, true);
2971 void MainWindow::slotSelectAddTimelineTransition()
2973 if (m_activeTimeline)
2974 m_activeTimeline->projectView()->selectTransition(true, true);
2977 void MainWindow::slotGroupClips()
2979 if (m_activeTimeline)
2980 m_activeTimeline->projectView()->groupClips();
2983 void MainWindow::slotUnGroupClips()
2985 if (m_activeTimeline)
2986 m_activeTimeline->projectView()->groupClips(false);
2989 void MainWindow::slotEditItemDuration()
2991 if (m_activeTimeline)
2992 m_activeTimeline->projectView()->editItemDuration();
2995 void MainWindow::slotAddProjectClip(KUrl url)
2997 if (m_activeDocument)
2998 m_activeDocument->slotAddClipFile(url, QString());
3001 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3003 if (m_activeDocument)
3004 m_activeDocument->slotAddClipList(urls, QString());
3007 void MainWindow::slotAddTransition(QAction *result)
3009 if (!result) return;
3010 QStringList info = result->data().toStringList();
3011 if (info.isEmpty()) return;
3012 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3013 if (m_activeTimeline && !transition.isNull()) {
3014 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3018 void MainWindow::slotAddVideoEffect(QAction *result)
3020 if (!result) return;
3021 const int EFFECT_VIDEO = 1;
3022 const int EFFECT_AUDIO = 2;
3023 QStringList info = result->data().toStringList();
3025 if (info.isEmpty() || info.size() < 3) return;
3026 QDomElement effect ;
3027 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3028 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3029 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3030 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3032 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3033 if (!effect.isNull()) slotAddEffect(effect);
3034 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3038 void MainWindow::slotZoomIn()
3040 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3041 slotShowZoomSliderToolTip();
3044 void MainWindow::slotZoomOut()
3046 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3047 slotShowZoomSliderToolTip();
3050 void MainWindow::slotFitZoom()
3052 if (m_activeTimeline)
3053 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3056 void MainWindow::slotSetZoom(int value)
3058 value = qMax(m_zoomSlider->minimum(), value);
3059 value = qMin(m_zoomSlider->maximum(), value);
3061 if (m_activeTimeline)
3062 m_activeTimeline->slotChangeZoom(value);
3064 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3065 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3066 slotUpdateZoomSliderToolTip(value);
3068 m_zoomSlider->blockSignals(true);
3069 m_zoomSlider->setValue(value);
3070 m_zoomSlider->blockSignals(false);
3073 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3075 if (zoomlevel != -1)
3076 slotUpdateZoomSliderToolTip(zoomlevel);
3078 QPoint global = m_zoomSlider->rect().topLeft();
3079 global.ry() += m_zoomSlider->height() / 2;
3080 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3081 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3084 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3086 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3089 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3091 m_statusProgressBar->setValue(progress);
3092 if (progress >= 0) {
3093 if (!message.isEmpty())
3094 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3095 m_statusProgressBar->setVisible(true);
3096 } else if (progress == -2) {
3097 if (!message.isEmpty())
3098 m_messageLabel->setMessage(message, ErrorMessage);
3099 m_statusProgressBar->setVisible(false);
3101 m_messageLabel->setMessage(QString(), DefaultMessage);
3102 m_statusProgressBar->setVisible(false);
3106 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3108 if (clip->clipType() == TEXT) {
3109 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3110 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3111 // template text clip
3113 // Get the list of existing templates
3115 filter << "*.kdenlivetitle";
3116 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3118 QDialog *dia = new QDialog(this);
3119 Ui::TemplateClip_UI dia_ui;
3120 dia_ui.setupUi(dia);
3122 const QString templatePath = clip->getProperty("resource");
3123 for (int i = 0; i < templateFiles.size(); ++i) {
3124 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3125 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3127 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3128 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3129 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3130 //warning: setting base directory doesn't work??
3131 KUrl startDir(titlepath);
3132 dia_ui.template_list->fileDialog()->setUrl(startDir);
3133 dia_ui.description->setText(clip->getProperty("description"));
3134 if (dia->exec() == QDialog::Accepted) {
3135 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3136 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3138 QMap <QString, QString> newprops;
3140 if (KUrl(textTemplate).path() != templatePath) {
3141 // The template was changed
3142 newprops.insert("resource", textTemplate);
3145 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3146 newprops.insert("description", dia_ui.description->toPlainText());
3149 QString newtemplate = newprops.value("xmltemplate");
3150 if (newtemplate.isEmpty()) newtemplate = templatePath;
3152 // template modified we need to update xmldata
3153 QString description = newprops.value("description");
3154 if (description.isEmpty()) description = clip->getProperty("description");
3155 else newprops.insert("templatetext", description);
3156 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3157 if (!newprops.isEmpty()) {
3158 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3159 m_activeDocument->commandStack()->push(command);
3165 QString path = clip->getProperty("resource");
3166 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3168 doc.setContent(clip->getProperty("xmldata"));
3169 dia_ui->setXml(doc);
3170 if (dia_ui->exec() == QDialog::Accepted) {
3171 QMap <QString, QString> newprops;
3172 newprops.insert("xmldata", dia_ui->xml().toString());
3173 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3174 // duration changed, we need to update duration
3175 newprops.insert("out", QString::number(dia_ui->outPoint()));
3176 int currentLength = QString(clip->producerProperty("length")).toInt();
3177 if (currentLength <= dia_ui->outPoint())
3178 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3179 else newprops.insert("length", clip->producerProperty("length"));
3181 if (!path.isEmpty()) {
3182 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3183 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) {
3184 // save to external file
3185 dia_ui->saveTitle(path);
3186 } else newprops.insert("resource", QString());
3188 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3189 m_activeDocument->commandStack()->push(command);
3190 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3191 m_activeDocument->setModified(true);
3195 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3199 // any type of clip but a title
3200 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3201 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3202 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3203 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)));
3208 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3210 if (newprops.isEmpty()) return;
3211 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3212 m_activeDocument->commandStack()->push(command);
3213 m_activeDocument->setModified();
3216 // update clip occurences in timeline
3217 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3222 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3224 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3225 if (dia.exec() == QDialog::Accepted) {
3226 QUndoCommand *command = new QUndoCommand();
3227 command->setText(i18n("Edit clips"));
3228 QMap <QString, QString> newImageProps = dia.properties();
3229 // Transparency setting applies only for images
3230 QMap <QString, QString> newProps = newImageProps;
3231 newProps.remove("transparency");
3233 for (int i = 0; i < cliplist.count(); i++) {
3234 DocClipBase *clip = cliplist.at(i);
3235 if (clip->clipType() == IMAGE)
3236 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3238 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3240 m_activeDocument->commandStack()->push(command);
3241 for (int i = 0; i < cliplist.count(); i++)
3242 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3246 void MainWindow::customEvent(QEvent* e)
3248 if (e->type() == QEvent::User)
3249 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3251 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3257 m_effectStack->raiseWindow(m_effectStackDock);
3260 void MainWindow::slotActivateTransitionView(Transition *t)
3263 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3266 void MainWindow::slotSnapRewind()
3268 if (m_projectMonitor->isActive()) {
3269 if (m_activeTimeline)
3270 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3272 m_clipMonitor->slotSeekToPreviousSnap();
3276 void MainWindow::slotSnapForward()
3278 if (m_projectMonitor->isActive()) {
3279 if (m_activeTimeline)
3280 m_activeTimeline->projectView()->slotSeekToNextSnap();
3282 m_clipMonitor->slotSeekToNextSnap();
3286 void MainWindow::slotClipStart()
3288 if (m_projectMonitor->isActive()) {
3289 if (m_activeTimeline)
3290 m_activeTimeline->projectView()->clipStart();
3294 void MainWindow::slotClipEnd()
3296 if (m_projectMonitor->isActive()) {
3297 if (m_activeTimeline)
3298 m_activeTimeline->projectView()->clipEnd();
3302 void MainWindow::slotZoneStart()
3304 if (m_projectMonitor->isActive())
3305 m_projectMonitor->slotZoneStart();
3307 m_clipMonitor->slotZoneStart();
3310 void MainWindow::slotZoneEnd()
3312 if (m_projectMonitor->isActive())
3313 m_projectMonitor->slotZoneEnd();
3315 m_clipMonitor->slotZoneEnd();
3318 void MainWindow::slotChangeTool(QAction * action)
3320 if (action == m_buttonSelectTool)
3321 slotSetTool(SELECTTOOL);
3322 else if (action == m_buttonRazorTool)
3323 slotSetTool(RAZORTOOL);
3324 else if (action == m_buttonSpacerTool)
3325 slotSetTool(SPACERTOOL);
3328 void MainWindow::slotChangeEdit(QAction * action)
3330 if (!m_activeTimeline)
3333 if (action == m_overwriteEditTool)
3334 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3335 else if (action == m_insertEditTool)
3336 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3338 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3341 void MainWindow::slotSetTool(PROJECTTOOL tool)
3343 if (m_activeDocument && m_activeTimeline) {
3344 //m_activeDocument->setTool(tool);
3348 message = i18n("Ctrl + click to use spacer on current track only");
3351 message = i18n("Click on a clip to cut it");
3354 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3357 m_messageLabel->setMessage(message, InformationMessage);
3358 m_activeTimeline->projectView()->setTool(tool);
3362 void MainWindow::slotCopy()
3364 if (m_activeDocument && m_activeTimeline)
3365 m_activeTimeline->projectView()->copyClip();
3368 void MainWindow::slotPaste()
3370 if (m_activeDocument && m_activeTimeline)
3371 m_activeTimeline->projectView()->pasteClip();
3374 void MainWindow::slotPasteEffects()
3376 if (m_activeDocument && m_activeTimeline)
3377 m_activeTimeline->projectView()->pasteClipEffects();
3380 void MainWindow::slotFind()
3382 if (!m_activeDocument || !m_activeTimeline) return;
3383 m_projectSearch->setEnabled(false);
3384 m_findActivated = true;
3385 m_findString.clear();
3386 m_activeTimeline->projectView()->initSearchStrings();
3387 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3388 m_findTimer.start(5000);
3389 qApp->installEventFilter(this);
3392 void MainWindow::slotFindNext()
3394 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3395 statusBar()->showMessage(i18n("Found: %1", m_findString));
3397 statusBar()->showMessage(i18n("Reached end of project"));
3398 m_findTimer.start(4000);
3401 void MainWindow::findAhead()
3403 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3404 m_projectSearchNext->setEnabled(true);
3405 statusBar()->showMessage(i18n("Found: %1", m_findString));
3407 m_projectSearchNext->setEnabled(false);
3408 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3412 void MainWindow::findTimeout()
3414 m_projectSearchNext->setEnabled(false);
3415 m_findActivated = false;
3416 m_findString.clear();
3417 statusBar()->showMessage(i18n("Find stopped"), 3000);
3418 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3419 m_projectSearch->setEnabled(true);
3420 removeEventFilter(this);
3423 void MainWindow::slotClipInTimeline(const QString &clipId)
3425 if (m_activeTimeline && m_activeDocument) {
3426 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3428 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3429 inTimelineMenu->clear();
3431 QList <QAction *> actionList;
3433 for (int i = 0; i < matching.count(); ++i) {
3434 QString track = QString::number(matching.at(i).track);
3435 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3437 QAction *a = new QAction(track + ": " + start, this);
3438 a->setData(QStringList() << track << start);
3439 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3440 while (j < actionList.count()) {
3441 if (actionList.at(j)->text() > a->text()) break;
3444 actionList.insert(j, a);
3446 inTimelineMenu->addActions(actionList);
3448 if (matching.empty())
3449 inTimelineMenu->setEnabled(false);
3451 inTimelineMenu->setEnabled(true);
3455 void MainWindow::slotClipInProjectTree()
3457 if (m_activeTimeline) {
3458 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3459 if (clipIds.isEmpty())
3461 m_projectListDock->raise();
3462 for (int i = 0; i < clipIds.count(); i++)
3463 m_projectList->selectItemById(clipIds.at(i));
3464 if (m_projectMonitor->isActive())
3465 slotSwitchMonitors();
3469 /*void MainWindow::slotClipToProjectTree()
3471 if (m_activeTimeline) {
3472 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3473 if (clips.isEmpty()) return;
3474 for (int i = 0; i < clips.count(); i++) {
3475 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3477 //m_projectList->selectItemById(clipIds.at(i));
3481 void MainWindow::slotSelectClipInTimeline()
3483 if (m_activeTimeline) {
3484 QAction *action = qobject_cast<QAction *>(sender());
3485 QStringList data = action->data().toStringList();
3486 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3490 void MainWindow::keyPressEvent(QKeyEvent *ke)
3492 if (m_findActivated) {
3493 if (ke->key() == Qt::Key_Backspace) {
3494 m_findString = m_findString.left(m_findString.length() - 1);
3496 if (!m_findString.isEmpty())
3501 m_findTimer.start(4000);
3504 } else if (ke->key() == Qt::Key_Escape) {
3508 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3509 m_findString += ke->text();
3513 m_findTimer.start(4000);
3518 KXmlGuiWindow::keyPressEvent(ke);
3523 /** Gets called when the window gets hidden */
3524 void MainWindow::hideEvent(QHideEvent */*event*/)
3526 if (isMinimized() && m_monitorManager)
3527 m_monitorManager->stopActiveMonitor();
3530 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3532 if (m_findActivated) {
3533 if (event->type() == QEvent::ShortcutOverride) {
3534 QKeyEvent* ke = (QKeyEvent*) event;
3535 if (ke->text().trimmed().isEmpty()) return false;
3542 // pass the event on to the parent class
3543 return QMainWindow::eventFilter(obj, event);
3548 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3550 KDialog *dialog = new KDialog(this);
3551 dialog->setCaption("Save clip zone");
3552 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3554 QWidget *widget = new QWidget(dialog);
3555 dialog->setMainWidget(widget);
3557 QVBoxLayout *vbox = new QVBoxLayout(widget);
3558 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3559 if (path.isEmpty()) {
3560 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3561 if (baseClip == NULL) tmppath.append("untitled.mlt");
3563 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3565 path = KUrl(tmppath);
3567 KUrlRequester *url = new KUrlRequester(path, this);
3568 url->setFilter("video/mlt-playlist");
3569 QLabel *label2 = new QLabel(i18n("Description:"), this);
3570 KLineEdit *edit = new KLineEdit(this);
3571 vbox->addWidget(label1);
3572 vbox->addWidget(url);
3573 vbox->addWidget(label2);
3574 vbox->addWidget(edit);
3575 if (dialog->exec() == QDialog::Accepted) {
3576 if (QFile::exists(url->url().path())) {
3577 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3578 slotSaveZone(render, zone, baseClip, url->url());
3582 if (baseClip && !baseClip->fileURL().isEmpty()) {
3583 // create zone from clip url, so that we don't have problems with proxy clips
3585 #if QT_VERSION >= 0x040600
3586 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3587 env.remove("MLT_PROFILE");
3588 p.setProcessEnvironment(env);
3590 QStringList env = QProcess::systemEnvironment();
3591 env << "MLT_PROFILE='\0'";
3592 p.setEnvironment(env);
3594 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3595 if (!p.waitForStarted(3000)) {
3596 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3598 else if (!p.waitForFinished(5000)) {
3599 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3602 else render->saveZone(url->url(), edit->text(), zone);
3607 void MainWindow::slotSetInPoint()
3609 if (m_clipMonitor->isActive()) {
3610 m_clipMonitor->slotSetZoneStart();
3612 m_projectMonitor->slotSetZoneStart();
3616 void MainWindow::slotSetOutPoint()
3618 if (m_clipMonitor->isActive()) {
3619 m_clipMonitor->slotSetZoneEnd();
3621 m_projectMonitor->slotSetZoneEnd();
3625 void MainWindow::slotResizeItemStart()
3627 if (m_activeTimeline)
3628 m_activeTimeline->projectView()->setInPoint();
3631 void MainWindow::slotResizeItemEnd()
3633 if (m_activeTimeline)
3634 m_activeTimeline->projectView()->setOutPoint();
3637 int MainWindow::getNewStuff(const QString &configFile)
3639 KNS3::Entry::List entries;
3640 #if KDE_IS_VERSION(4,3,80)
3641 KNS3::DownloadDialog dialog(configFile);
3643 entries = dialog.changedEntries();
3644 foreach(const KNS3::Entry & entry, entries) {
3645 if (entry.status() == KNS3::Entry::Installed)
3646 kDebug() << "// Installed files: " << entry.installedFiles();
3649 KNS::Engine engine(0);
3650 if (engine.init(configFile))
3651 entries = engine.downloadDialogModal(this);
3652 foreach(KNS::Entry * entry, entries) {
3653 if (entry->status() == KNS::Entry::Installed)
3654 kDebug() << "// Installed files: " << entry->installedFiles();
3656 #endif /* KDE_IS_VERSION(4,3,80) */
3657 return entries.size();
3660 void MainWindow::slotGetNewTitleStuff()
3662 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3663 TitleWidget::refreshTitleTemplates();
3666 void MainWindow::slotGetNewLumaStuff()
3668 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3669 initEffects::refreshLumas();
3670 m_activeTimeline->projectView()->reloadTransitionLumas();
3674 void MainWindow::slotGetNewRenderStuff()
3676 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3678 m_renderWidget->reloadProfiles();
3681 void MainWindow::slotGetNewMltProfileStuff()
3683 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3684 // update the list of profiles in settings dialog
3685 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3691 void MainWindow::slotAutoTransition()
3693 if (m_activeTimeline)
3694 m_activeTimeline->projectView()->autoTransition();
3697 void MainWindow::slotSplitAudio()
3699 if (m_activeTimeline)
3700 m_activeTimeline->projectView()->splitAudio();
3703 void MainWindow::slotUpdateClipType(QAction *action)
3705 if (m_activeTimeline) {
3706 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3707 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3708 else m_activeTimeline->projectView()->setAudioAndVideo();
3712 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3714 // We must stop the monitors since we create a new on in the dvd wizard
3715 m_clipMonitor->stop();
3716 m_projectMonitor->stop();
3717 DvdWizard w(url, profile, this);
3719 m_projectMonitor->start();
3722 void MainWindow::slotShowTimeline(bool show)
3724 if (show == false) {
3725 m_timelineState = saveState();
3726 centralWidget()->setHidden(true);
3728 centralWidget()->setHidden(false);
3729 restoreState(m_timelineState);
3733 void MainWindow::slotMaximizeCurrent(bool)
3735 //TODO: is there a way to maximize current widget?
3737 m_timelineState = saveState();
3738 QWidget *par = focusWidget()->parentWidget();
3739 while (par->parentWidget() && par->parentWidget() != this)
3740 par = par->parentWidget();
3741 kDebug() << "CURRENT WIDGET: " << par->objectName();
3744 void MainWindow::loadTranscoders()
3746 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3749 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3750 KConfigGroup transConfig(config, "Transcoding");
3752 QMap< QString, QString > profiles = transConfig.entryMap();
3753 QMapIterator<QString, QString> i(profiles);
3754 while (i.hasNext()) {
3756 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3757 QAction *a = transMenu->addAction(i.key());
3759 if (data.count() > 1)
3760 a->setToolTip(data.at(1));
3761 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3765 void MainWindow::slotTranscode(KUrl::List urls)
3770 if (urls.isEmpty()) {
3771 QAction *action = qobject_cast<QAction *>(sender());
3772 QStringList data = action->data().toStringList();
3773 params = data.at(0);
3774 if (data.count() > 1) desc = data.at(1);
3775 if (data.count() > 2) condition = data.at(2);
3776 urls << m_projectList->getConditionalUrls(condition);
3777 urls.removeAll(KUrl());
3779 if (urls.isEmpty()) {
3780 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3783 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3784 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3786 //QProcess::startDetached("ffmpeg", parameters);
3789 void MainWindow::slotTranscodeClip()
3791 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3792 if (urls.isEmpty()) return;
3793 slotTranscode(urls);
3796 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3798 if (m_activeDocument == NULL) return;
3799 QMapIterator<QString, QString> i(props);
3800 while (i.hasNext()) {
3802 m_activeDocument->setDocumentProperty(i.key(), i.value());
3804 m_activeDocument->setModified(true);
3808 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3810 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3812 QString playlistPath;
3815 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3816 QString path = m_renderWidget->getFreeScriptName();
3817 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3818 if (!ok || scriptPath.isEmpty()) return;
3819 scriptPath.prepend(scriptsFolder);
3820 QFile f(scriptPath);
3822 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3825 playlistPath = scriptPath + ".mlt";
3827 KTemporaryFile temp;
3828 temp.setAutoRemove(false);
3829 temp.setSuffix(".mlt");
3831 playlistPath = temp.fileName();
3833 QString playlistContent = m_projectMonitor->sceneList();
3834 if (!chapterFile.isEmpty()) {
3837 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3839 in = m_activeTimeline->inPoint();
3840 out = m_activeTimeline->outPoint();
3843 QDomElement chapters = doc.createElement("chapters");
3844 chapters.setAttribute("fps", m_activeDocument->fps());
3845 doc.appendChild(chapters);
3847 QDomElement guidesxml = m_activeDocument->guidesXml();
3848 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3849 for (int i = 0; i < nodes.count(); i++) {
3850 QDomElement e = nodes.item(i).toElement();
3852 QString comment = e.attribute("comment");
3853 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3854 if (time >= in && time < out) {
3855 if (zoneOnly) time = time - in;
3856 QDomElement chapter = doc.createElement("chapter");
3857 chapters.appendChild(chapter);
3858 chapter.setAttribute("title", comment);
3859 chapter.setAttribute("time", time);
3863 if (chapters.childNodes().count() > 0) {
3864 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3865 // Always insert a guide in pos 0
3866 QDomElement chapter = doc.createElement("chapter");
3867 chapters.insertBefore(chapter, QDomNode());
3868 chapter.setAttribute("title", i18n("Start"));
3869 chapter.setAttribute("time", "0");
3871 // save chapters file
3872 QFile file(chapterFile);
3873 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3874 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3876 file.write(doc.toString().toUtf8());
3877 if (file.error() != QFile::NoError) {
3878 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3885 if (m_renderWidget->automaticAudioExport()) {
3886 exportAudio = m_activeTimeline->checkProjectAudio();
3887 } else exportAudio = m_renderWidget->selectedAudioExport();
3889 // Set playlist audio volume to 100%
3891 doc.setContent(playlistContent);
3892 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3893 if (!tractor.isNull()) {
3894 QDomNodeList props = tractor.elementsByTagName("property");
3895 for (int i = 0; i < props.count(); i++) {
3896 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3897 props.at(i).firstChild().setNodeValue("1");
3903 // Do we want proxy rendering
3904 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3905 QString root = doc.documentElement().attribute("root");
3907 // replace proxy clips with originals
3908 QMap <QString, QString> proxies = m_projectList->getProxies();
3910 QDomNodeList producers = doc.elementsByTagName("producer");
3911 QString producerResource;
3913 for (uint n = 0; n < producers.length(); n++) {
3914 QDomElement e = producers.item(n).toElement();
3915 producerResource = EffectsList::property(e, "resource");
3916 if (producerResource.isEmpty()) continue;
3917 if (!producerResource.startsWith("/")) {
3918 producerResource.prepend(root + "/");
3920 if (producerResource.contains('?')) {
3921 // slowmotion producer
3922 suffix = "?" + producerResource.section('?', 1);
3923 producerResource = producerResource.section('?', 0, 0);
3925 else suffix.clear();
3926 if (!producerResource.isEmpty()) {
3927 if (proxies.contains(producerResource)) {
3928 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3929 // We need to delete the "aspect_ratio" property because proxy clips
3930 // sometimes have different ratio than original clips
3931 EffectsList::removeProperty(e, "aspect_ratio");
3936 /*QMapIterator<QString, QString> i(proxies);
3937 while (i.hasNext()) {
3939 // Replace all keys with their values (proxy path with original path)
3940 QString key = i.key();
3941 playlistContent.replace(key, i.value());
3942 if (!root.isEmpty() && key.startsWith(root)) {
3943 // in case the resource path in MLT playlist is relative
3944 key.remove(0, root.count() + 1);
3945 playlistContent.replace(key, i.value());
3949 playlistContent = doc.toString();
3951 // Do save scenelist
3952 QFile file(playlistPath);
3953 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3954 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3957 file.write(playlistContent.toUtf8());
3958 if (file.error() != QFile::NoError) {
3959 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3964 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3967 void MainWindow::slotUpdateTimecodeFormat(int ix)
3969 KdenliveSettings::setFrametimecode(ix == 1);
3970 m_clipMonitor->updateTimecodeFormat();
3971 m_projectMonitor->updateTimecodeFormat();
3972 m_transitionConfig->updateTimecodeFormat();
3973 m_effectStack->updateTimecodeFormat();
3974 //m_activeTimeline->projectView()->clearSelection();
3975 m_activeTimeline->updateRuler();
3978 void MainWindow::slotRemoveFocus()
3980 statusBar()->setFocus();
3981 statusBar()->clearFocus();
3984 void MainWindow::slotRevert()
3986 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;
3987 KUrl url = m_activeDocument->url();
3988 if (closeCurrentDocument(false))
3989 doOpenFile(url, NULL);
3993 void MainWindow::slotShutdown()
3995 if (m_activeDocument) m_activeDocument->setModified(false);
3997 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3998 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3999 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4000 smserver.call("logout", 1, 2, 2);
4001 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4002 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4003 smserver.call("Shutdown");
4007 void MainWindow::slotUpdateTrackInfo()
4009 if (m_activeDocument)
4010 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4013 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4015 // Load the theme file
4017 if (action == NULL) theme = themename;
4018 else theme = action->data().toString();
4019 KdenliveSettings::setColortheme(theme);
4020 // Make palette for all widgets.
4021 QPalette plt = kapp->palette();
4022 if (theme.isEmpty()) {
4023 plt = QApplication::desktop()->palette();
4025 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4027 #if KDE_IS_VERSION(4,6,3)
4028 plt = KGlobalSettings::createNewApplicationPalette(config);
4030 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4031 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4032 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4033 QPalette::Disabled };
4034 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4035 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4037 for ( int i = 0; i < 3 ; i++ ) {
4038 QPalette::ColorGroup state = states[i];
4039 KColorScheme schemeView(state, KColorScheme::View, config);
4040 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4041 KColorScheme schemeButton(state, KColorScheme::Button, config);
4042 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4044 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4045 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4046 plt.setBrush( state, QPalette::Base, schemeView.background() );
4047 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4048 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4049 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4050 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4051 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4052 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4053 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4055 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4056 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4057 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4058 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4059 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4061 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4062 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4063 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4068 kapp->setPalette(plt);
4069 const QObjectList children = statusBar()->children();
4071 foreach(QObject * child, children) {
4072 if (child->isWidgetType())
4073 ((QWidget*)child)->setPalette(plt);
4074 const QObjectList subchildren = child->children();
4075 foreach(QObject * subchild, subchildren) {
4076 if (subchild->isWidgetType())
4077 ((QWidget*)subchild)->setPalette(plt);
4080 if (m_activeTimeline) {
4081 m_activeTimeline->projectView()->updatePalette();
4086 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4088 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4089 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4090 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4091 const QSize bitsSize(24, 2);
4092 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4093 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4095 QPixmap pixmap(23, 16);
4096 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4098 KConfigGroup group(config, "WM");
4099 QPainter p(&pixmap);
4100 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4101 p.fillRect(1, 1, 7, 7, windowScheme.background());
4102 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4104 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4105 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4106 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4108 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4109 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4111 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4112 p.fillRect(1, 8, 7, 7, viewScheme.background());
4113 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4115 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4116 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4117 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4119 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4120 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4126 void MainWindow::slotSwitchMonitors()
4128 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4129 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4130 else m_projectList->focusTree();
4133 void MainWindow::slotSwitchFullscreen()
4135 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4136 else m_clipMonitor->slotSwitchFullScreen();
4139 void MainWindow::slotInsertZoneToTree()
4141 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4142 QStringList info = m_clipMonitor->getZoneInfo();
4143 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4146 void MainWindow::slotInsertZoneToTimeline()
4148 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4149 QStringList info = m_clipMonitor->getZoneInfo();
4150 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4154 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4156 if (m_activeDocument && m_activeTimeline) {
4157 if (!ids.isEmpty()) {
4158 for (int i = 0; i < ids.size(); ++i) {
4159 m_activeTimeline->slotDeleteClip(ids.at(i));
4161 m_activeDocument->clipManager()->slotDeleteClips(ids);
4163 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4164 m_activeDocument->setModified(true);
4168 void MainWindow::slotShowTitleBars(bool show)
4170 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4171 for (int i = 0; i < docks.count(); i++) {
4172 QDockWidget* dock = docks.at(i);
4174 dock->setTitleBarWidget(0);
4176 if (!dock->isFloating()) {
4177 dock->setTitleBarWidget(new QWidget);
4181 KdenliveSettings::setShowtitlebars(show);
4184 void MainWindow::slotSwitchTitles()
4186 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4189 QString MainWindow::getMimeType(bool open)
4191 QString mimetype = "application/x-kdenlive";
4192 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4194 mimetype = "*.kdenlive";
4195 if (open) mimetype.append(" *.tar.gz");
4197 else if (open) mimetype.append(" application/x-compressed-tar");
4201 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4204 m_projectMonitor->render->sendFrameForAnalysis = true;
4207 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4208 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4215 qDebug() << "Any scope accepting new frames? " << request;
4218 m_projectMonitor->render->sendFrameForAnalysis = false;
4222 void MainWindow::slotUpdateGfxScopeFrameRequest()
4224 // We need a delay to make sure widgets are hidden after a close event for example
4225 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4228 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4231 bool request = false;
4232 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4233 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4234 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4240 if (!m_projectMonitor->effectSceneDisplayed()) {
4241 m_projectMonitor->render->sendFrameForAnalysis = false;
4243 m_clipMonitor->render->sendFrameForAnalysis = false;
4245 m_recMonitor->analyseFrames(false);
4247 m_projectMonitor->render->sendFrameForAnalysis = true;
4248 m_clipMonitor->render->sendFrameForAnalysis = true;
4250 m_recMonitor->analyseFrames(true);
4254 void MainWindow::slotUpdateAudioScopeFrameRequest()
4256 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4259 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4261 bool request = false;
4262 for (int i = 0; i < m_audioScopesList.count(); i++) {
4263 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4264 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4269 // Handle audio signal separately (no common interface)
4270 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4271 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4275 qDebug() << "Scopes Requesting Audio data: " << request;
4277 KdenliveSettings::setMonitor_audio(request);
4278 m_monitorManager->slotUpdateAudioMonitoring();
4281 void MainWindow::slotUpdateColorScopes()
4283 bool request = false;
4284 kDebug()<<"// UPDATE SCOPES";
4285 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4286 // Check if we need the renderer to send a new frame for update
4287 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4288 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4290 if (request && m_monitorManager->activeRenderer()) {
4291 m_monitorManager->activeRenderer()->sendFrameUpdate();
4295 void MainWindow::slotClearColorScopes()
4297 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4298 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4302 void MainWindow::slotOpenStopmotion()
4304 if (m_stopmotion == NULL) {
4305 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4306 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4307 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4308 // Check if we need the renderer to send a new frame for update
4309 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4310 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4311 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4314 m_stopmotion->show();
4317 void MainWindow::slotDeleteClip(const QString &id)
4319 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4320 for (int i = 0; i < list.size(); ++i) {
4321 list.at(i)->disableClipId(id);
4323 m_projectList->slotDeleteClip(id);
4326 void MainWindow::slotUpdateProxySettings()
4328 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4329 if (KdenliveSettings::enableproxy())
4330 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4331 m_projectList->updateProxyConfig();
4334 void MainWindow::slotInsertNotesTimecode()
4336 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4337 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4338 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4341 void MainWindow::slotArchiveProject()
4343 QList <DocClipBase*> list = m_projectList->documentClipList();
4344 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4345 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4350 void MainWindow::slotOpenBackupDialog(const KUrl url)
4355 kDebug()<<"// BACKUP URL: "<<url.path();
4356 if (!url.isEmpty()) {
4357 // we could not open the project file, guess where the backups are
4358 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4362 projectFolder = m_activeDocument->projectFolder();
4363 projectFile = m_activeDocument->url();
4364 projectId = m_activeDocument->getDocumentProperty("documentid");
4367 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4368 if (dia->exec() == QDialog::Accepted) {
4369 QString requestedBackup = dia->selectedFile();
4370 m_activeDocument->backupLastSavedVersion(projectFile.path());
4371 closeCurrentDocument(false);
4372 doOpenFile(KUrl(requestedBackup), NULL);
4373 m_activeDocument->setUrl(projectFile);
4374 m_activeDocument->setModified(true);
4375 setCaption(m_activeDocument->description());
4380 void MainWindow::slotBlockClipMonitor(const QString id)
4382 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) m_clipMonitor->slotSetXml(NULL);
4386 void MainWindow::slotElapsedTime()
4388 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4391 #include "mainwindow.moc"