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"
68 #include <KApplication>
72 #include <KActionCollection>
73 #include <KActionCategory>
74 #include <KStandardAction>
75 #include <KShortcutsDialog>
76 #include <KFileDialog>
77 #include <KMessageBox>
79 #include <KIO/NetAccess>
82 #include <KConfigDialog>
83 #include <KXMLGUIFactory>
85 #include <kstandarddirs.h>
86 #include <KUrlRequesterDialog>
87 #include <KTemporaryFile>
89 #include <KActionMenu>
91 #include <ktogglefullscreenaction.h>
93 #include <KNotification>
94 #include <KNotifyConfigWidget>
95 #if KDE_IS_VERSION(4,3,80)
96 #include <knewstuff3/downloaddialog.h>
97 #include <knewstuff3/knewstuffaction.h>
99 #include <knewstuff2/engine.h>
100 #include <knewstuff2/ui/knewstuffaction.h>
102 #endif /* KDE_IS_VERSION(4,3,80) */
104 #include <KColorScheme>
105 #include <KProgressDialog>
107 #include <QTextStream>
111 #include <QInputDialog>
112 #include <QDesktopWidget>
117 // Uncomment for deeper debugging
118 //#define DEBUG_MAINW
124 static const char version[] = VERSION;
126 static const int ID_TIMELINE_POS = 0;
132 Q_DECLARE_METATYPE(QVector<int16_t>)
135 EffectsList MainWindow::videoEffects;
136 EffectsList MainWindow::audioEffects;
137 EffectsList MainWindow::customEffects;
138 EffectsList MainWindow::transitions;
140 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
141 KXmlGuiWindow(parent),
142 m_activeDocument(NULL),
143 m_activeTimeline(NULL),
145 m_renderWidget(NULL),
146 #ifndef NO_JOGSHUTTLE
149 #endif /* NO_JOGSHUTTLE */
150 m_findActivated(false),
153 qRegisterMetaType<QVector<int16_t> > ();
154 qRegisterMetaType<stringMap> ("stringMap");
155 qRegisterMetaType<audioByteArray> ("audioByteArray");
158 QLocale systemLocale = QLocale();
159 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
160 QLocale::setDefault(systemLocale);
162 // Create DBus interface
163 new MainWindowAdaptor(this);
164 QDBusConnection dbus = QDBusConnection::sessionBus();
165 dbus.registerObject("/MainWindow", this);
167 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
168 setFont(KGlobalSettings::toolBarFont());
169 parseProfiles(MltPath);
170 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
171 m_commandStack = new QUndoGroup;
172 setDockNestingEnabled(true);
173 m_timelineArea = new KTabWidget(this);
174 m_timelineArea->setTabReorderingEnabled(true);
175 m_timelineArea->setTabBarHidden(true);
176 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
177 m_timelineArea->setMinimumHeight(200);
179 QToolButton *closeTabButton = new QToolButton;
180 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
181 closeTabButton->setIcon(KIcon("tab-close"));
182 closeTabButton->adjustSize();
183 closeTabButton->setToolTip(i18n("Close the current tab"));
184 m_timelineArea->setCornerWidget(closeTabButton);
185 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
187 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
188 m_findTimer.setSingleShot(true);
190 // FIXME: the next call returns a newly allocated object, which leaks
191 initEffects::parseEffectFiles();
192 //initEffects::parseCustomEffectsFile();
194 m_monitorManager = new MonitorManager();
196 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
197 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
202 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
203 m_projectListDock->setObjectName("project_tree");
204 m_projectList = new ProjectList();
205 m_projectListDock->setWidget(m_projectList);
206 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
208 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
209 m_clipMonitorDock->setObjectName("clip_monitor");
210 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
211 m_clipMonitorDock->setWidget(m_clipMonitor);
213 // Connect the project list
214 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint)));
215 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
216 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
217 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
218 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
219 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
220 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
221 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
222 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
223 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
225 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
226 m_projectMonitorDock->setObjectName("project_monitor");
227 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
228 m_projectMonitorDock->setWidget(m_projectMonitor);
231 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
232 m_recMonitorDock->setObjectName("record_monitor");
233 m_recMonitor = new RecMonitor("record", m_monitorManager);
234 m_recMonitorDock->setWidget(m_recMonitor);
235 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
236 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
237 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
239 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
241 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
242 m_notesDock->setObjectName("notes_widget");
243 m_notesWidget = new NotesWidget();
244 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
245 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
247 m_notesWidget->setTabChangesFocus(true);
248 #if KDE_IS_VERSION(4,4,0)
249 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
251 m_notesDock->setWidget(m_notesWidget);
252 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
254 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
255 m_effectStackDock->setObjectName("effect_stack");
256 m_effectStack = new EffectStackView(m_projectMonitor);
257 m_effectStackDock->setWidget(m_effectStack);
258 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
260 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
261 m_transitionConfigDock->setObjectName("transition");
262 m_transitionConfig = new TransitionSettings(m_projectMonitor);
263 m_transitionConfigDock->setWidget(m_transitionConfig);
264 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
266 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
267 m_effectListDock->setObjectName("effect_list");
268 m_effectList = new EffectsListView();
269 m_effectListDock->setWidget(m_effectList);
270 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
272 m_vectorscope = new Vectorscope(m_monitorManager);
273 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
274 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
275 m_vectorscopeDock->setWidget(m_vectorscope);
276 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
277 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
278 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
279 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
280 m_gfxScopesList.append(m_vectorscopeDock);
282 m_waveform = new Waveform(m_monitorManager);
283 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
284 m_waveformDock->setObjectName(m_waveform->widgetName());
285 m_waveformDock->setWidget(m_waveform);
286 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
287 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
288 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
289 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
290 m_gfxScopesList.append(m_waveformDock);
292 m_RGBParade = new RGBParade(m_monitorManager);
293 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
294 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
295 m_RGBParadeDock->setWidget(m_RGBParade);
296 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
297 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
298 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
299 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
300 m_gfxScopesList.append(m_RGBParadeDock);
302 m_histogram = new Histogram(m_monitorManager);
303 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
304 m_histogramDock->setObjectName(m_histogram->widgetName());
305 m_histogramDock->setWidget(m_histogram);
306 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
307 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
308 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
309 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
310 m_gfxScopesList.append(m_histogramDock);
313 m_audiosignal = new AudioSignal;
314 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
315 m_audiosignalDock->setObjectName("audiosignal");
316 m_audiosignalDock->setWidget(m_audiosignal);
317 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
318 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
319 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
321 m_audioSpectrum = new AudioSpectrum();
322 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
323 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
324 m_audioSpectrumDock->setWidget(m_audioSpectrum);
325 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
326 m_audioScopesList.append(m_audioSpectrum);
327 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
328 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
330 m_spectrogram = new Spectrogram();
331 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
332 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
333 m_spectrogramDock->setWidget(m_spectrogram);
334 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
335 m_audioScopesList.append(m_spectrogram);
336 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
337 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
339 // Connect the audio signal to the audio scope slots
341 if (m_projectMonitor) {
342 qDebug() << "project monitor connected";
343 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
344 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
345 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
346 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
347 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
348 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
351 qDebug() << "clip monitor connected";
352 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
353 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
354 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
355 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
356 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
357 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
359 // Ensure connections were set up correctly
364 // Add monitors here to keep them at the right of the window
365 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
366 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
368 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
371 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
372 m_undoViewDock->setObjectName("undo_history");
373 m_undoView = new QUndoView();
374 m_undoView->setCleanIcon(KIcon("edit-clear"));
375 m_undoView->setEmptyLabel(i18n("Clean"));
376 m_undoViewDock->setWidget(m_undoView);
377 m_undoView->setGroup(m_commandStack);
378 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
382 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
385 // Close non-general docks for the initial layout
386 // only show important ones
387 m_histogramDock->close();
388 m_RGBParadeDock->close();
389 m_waveformDock->close();
390 m_vectorscopeDock->close();
392 m_audioSpectrumDock->close();
393 m_spectrogramDock->close();
394 m_audiosignalDock->close();
396 m_undoViewDock->close();
400 /// Tabify Widgets ///
401 tabifyDockWidget(m_effectListDock, m_effectStackDock);
402 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
403 tabifyDockWidget(m_projectListDock, m_notesDock);
405 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
407 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
413 setCentralWidget(m_timelineArea);
416 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
418 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
419 m_fileRevert->setEnabled(false);
421 // Prepare layout actions
422 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
423 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
424 for (int i = 1; i < 5; i++) {
425 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
426 load->setData("_" + QString::number(i));
427 layoutActions->addAction("load_layout" + QString::number(i), load);
428 m_loadLayout->addAction(load);
429 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
430 save->setData("_" + QString::number(i));
431 layoutActions->addAction("save_layout" + QString::number(i), save);
433 layoutActions->addAction("load_layouts", m_loadLayout);
434 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
437 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
438 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
439 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
440 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
441 m_stopmotion_actions->addAction("stopmotion_capture", action);
442 action = new KAction(i18n("Switch live / captured frame"), this);
443 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
444 m_stopmotion_actions->addAction("stopmotion_switch", action);
445 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
446 action->setCheckable(true);
447 action->setChecked(false);
448 m_stopmotion_actions->addAction("stopmotion_overlay", action);
450 // Build effects menu
451 m_effectsMenu = new QMenu(i18n("Add Effect"));
452 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
453 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
454 m_effectsActionCollection->readSettings();
458 // Find QDockWidget tab bars and show / hide widget title bars on right click
459 QList <QTabBar *> tabs = findChildren<QTabBar *>();
460 for (int i = 0; i < tabs.count(); i++) {
461 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
462 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
465 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
466 guiFactory()->addClient(sp);*/
468 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
470 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
473 // Load layout names from config file
479 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
480 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
482 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
483 clipInTimeline->setIcon(KIcon("go-jump"));
484 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
485 static_cast<QMenu*>(factory()->container("transcoders", this)),
488 // build themes menus
489 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
490 QActionGroup *themegroup = new QActionGroup(this);
491 themegroup->setExclusive(true);
492 action = new KAction(i18n("Default"), this);
493 action->setCheckable(true);
494 themegroup->addAction(action);
495 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
497 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
499 for (int i = 0; i < schemeFiles.size(); ++i) {
501 const QString filename = schemeFiles.at(i);
502 const QFileInfo info(filename);
505 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
506 QIcon icon = createSchemePreviewIcon(config);
507 KConfigGroup group(config, "General");
508 const QString name = group.readEntry("Name", info.baseName());
509 action = new KAction(name, this);
510 action->setData(filename);
511 action->setIcon(icon);
512 action->setCheckable(true);
513 themegroup->addAction(action);
514 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
517 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
518 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
519 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
522 action = new QAction(fi.fileName(), this);
523 action->setData(*it);
524 action->setCheckable(true);
525 themegroup->addAction(action);
526 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
528 themesMenu->addActions(themegroup->actions());
529 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
531 // Setup and fill effects and transitions menus.
534 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
535 m->addActions(m_effectsMenu->actions());
538 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
539 for (int i = 0; i < transitions.count(); ++i)
540 m_transitionsMenu->addAction(m_transitions[i]);
542 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
543 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
544 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
546 m_effectStack->setMenu(m_effectsMenu);
548 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
549 const QList<QAction *> viewActions = createPopupMenu()->actions();
550 viewMenu->insertActions(NULL, viewActions);
552 m_timelineContextMenu = new QMenu(this);
553 m_timelineContextClipMenu = new QMenu(this);
554 m_timelineContextTransitionMenu = new QMenu(this);
556 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
557 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
558 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
560 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
561 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
562 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
563 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
564 m_timelineContextClipMenu->addSeparator();
565 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
566 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
567 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
568 m_timelineContextClipMenu->addSeparator();
569 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
570 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
571 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
572 m_timelineContextClipMenu->addSeparator();
574 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
575 m_timelineContextClipMenu->addMenu(markersMenu);
576 m_timelineContextClipMenu->addSeparator();
577 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
578 m_timelineContextClipMenu->addMenu(m_effectsMenu);
580 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
581 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
582 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
584 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
586 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
587 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
588 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
589 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
590 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
591 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
593 slotConnectMonitors();
595 // Open or create a file. Command line argument passed in Url has
596 // precedence, then "openlastproject", then just a plain empty file.
597 // If opening Url fails, openlastproject will _not_ be used.
598 if (!Url.isEmpty()) {
599 // delay loading so that the window shows up
601 QTimer::singleShot(500, this, SLOT(openFile()));
602 } else if (KdenliveSettings::openlastproject()) {
603 QTimer::singleShot(500, this, SLOT(openLastFile()));
604 } else { //if (m_timelineArea->count() == 0) {
608 if (!clipsToLoad.isEmpty() && m_activeDocument) {
609 QStringList list = clipsToLoad.split(',');
611 foreach(QString path, list) {
612 kDebug() << QDir::current().absoluteFilePath(path);
613 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
615 m_projectList->slotAddClip(urls);
618 #ifndef NO_JOGSHUTTLE
619 activateShuttleDevice();
620 #endif /* NO_JOGSHUTTLE */
621 m_projectListDock->raise();
623 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
624 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
626 // Populate encoding profiles
627 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
628 if (KdenliveSettings::proxyparams().isEmpty()) {
629 KConfigGroup group(&conf, "proxy");
630 QMap< QString, QString > values = group.entryMap();
631 QMapIterator<QString, QString> i(values);
634 QString data = i.value();
635 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
636 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
639 if (KdenliveSettings::v4l_parameters().isEmpty()) {
640 KConfigGroup group(&conf, "video4linux");
641 QMap< QString, QString > values = group.entryMap();
642 QMapIterator<QString, QString> i(values);
645 QString data = i.value();
646 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
647 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
650 if (KdenliveSettings::decklink_parameters().isEmpty()) {
651 KConfigGroup group(&conf, "decklink");
652 QMap< QString, QString > values = group.entryMap();
653 QMapIterator<QString, QString> i(values);
656 QString data = i.value();
657 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
658 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
663 MainWindow::~MainWindow()
668 m_effectStack->slotClipItemSelected(NULL, 0);
669 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
671 if (m_projectMonitor) m_projectMonitor->stop();
672 if (m_clipMonitor) m_clipMonitor->stop();
674 delete m_activeTimeline;
675 delete m_effectStack;
676 delete m_transitionConfig;
677 delete m_activeDocument;
678 delete m_projectMonitor;
679 delete m_clipMonitor;
680 delete m_shortcutRemoveFocus;
681 delete[] m_transitions;
682 Mlt::Factory::close();
686 bool MainWindow::queryClose()
688 if (m_renderWidget) {
689 int waitingJobs = m_renderWidget->waitingJobsCount();
690 if (waitingJobs > 0) {
691 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")))) {
692 case KMessageBox::Yes :
693 // create script with waiting jobs and start it
694 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
696 case KMessageBox::No :
697 // Don't do anything, jobs will be deleted
705 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
706 // warn the user to save if document is modified and we have clips in our project list
707 if (m_activeDocument && m_activeDocument->isModified() &&
708 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
709 !m_projectList->documentClipList().isEmpty())) {
713 if (m_activeDocument->url().fileName().isEmpty())
714 message = i18n("Save changes to document?");
716 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
717 switch (KMessageBox::warningYesNoCancel(this, message)) {
718 case KMessageBox::Yes :
719 // save document here. If saving fails, return false;
721 case KMessageBox::No :
722 // User does not want to save the changes, clear recovery files
723 m_activeDocument->m_autosave->resize(0);
732 void MainWindow::loadPlugins()
734 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
735 populateMenus(plugin);
738 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
740 filters << "libkdenlive*";
741 foreach(const QString & folder, directories) {
742 kDebug() << "Parsing plugin folder: " << folder;
743 QDir pluginsDir(folder);
744 foreach(const QString & fileName,
745 pluginsDir.entryList(filters, QDir::Files)) {
747 * Avoid loading the same plugin twice when there is more than one
750 if (!m_pluginFileNames.contains(fileName)) {
751 kDebug() << "Found plugin: " << fileName;
752 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
753 QObject *plugin = loader.instance();
755 populateMenus(plugin);
756 m_pluginFileNames += fileName;
758 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
764 void MainWindow::populateMenus(QObject *plugin)
766 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
767 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
769 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
773 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
774 QMenu *menu, const char *member,
775 QActionGroup *actionGroup)
777 kDebug() << "// ADD to MENU" << texts;
778 foreach(const QString & text, texts) {
779 QAction *action = new QAction(text, plugin);
780 action->setData(text);
781 connect(action, SIGNAL(triggered()), this, member);
782 menu->addAction(action);
785 action->setCheckable(true);
786 actionGroup->addAction(action);
791 void MainWindow::aboutPlugins()
793 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
798 void MainWindow::generateClip()
800 QAction *action = qobject_cast<QAction *>(sender());
801 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
803 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
804 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
805 if (!clipUrl.isEmpty()) {
806 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
810 void MainWindow::saveProperties(KConfigGroup &config)
812 // save properties here,used by session management
814 KMainWindow::saveProperties(config);
818 void MainWindow::readProperties(const KConfigGroup &config)
820 // read properties here,used by session management
821 KMainWindow::readProperties(config);
822 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
823 openFile(KUrl(Lastproject));
826 void MainWindow::slotReloadEffects()
828 initEffects::parseCustomEffectsFile();
829 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
832 #ifndef NO_JOGSHUTTLE
833 void MainWindow::activateShuttleDevice()
839 if (KdenliveSettings::enableshuttle() == false) return;
841 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
842 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
844 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
845 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
846 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
847 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
848 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
850 #endif /* NO_JOGSHUTTLE */
852 void MainWindow::slotDoAction(const QString& action_name)
854 QAction* action = actionCollection()->action(action_name);
856 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
862 void MainWindow::configureNotifications()
864 KNotifyConfigWidget::configure(this);
867 void MainWindow::slotFullScreen()
869 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
872 void MainWindow::slotAddEffect(const QDomElement effect)
874 if (!m_activeDocument) return;
875 if (effect.isNull()) {
876 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
879 QDomElement effectToAdd = effect.cloneNode().toElement();
881 int ix = m_effectStack->isTrackMode(&ok);
882 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
883 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
886 void MainWindow::slotUpdateClip(const QString &id)
888 if (!m_activeDocument) return;
889 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
891 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
892 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
893 Mlt::Producer *monitorProducer = clip->getCloneProducer();
894 m_clipMonitor->updateClipProducer(monitorProducer);
896 clip->cleanupProducers();
899 void MainWindow::slotConnectMonitors()
901 m_projectList->setRenderer(m_projectMonitor->render);
902 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
903 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
904 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
905 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
906 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
907 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)));
909 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
911 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
913 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
915 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
916 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
918 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
920 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
921 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
924 void MainWindow::slotAdjustClipMonitor()
926 m_clipMonitorDock->updateGeometry();
927 m_clipMonitorDock->adjustSize();
928 m_clipMonitor->resetSize();
931 void MainWindow::slotAdjustProjectMonitor()
933 m_projectMonitorDock->updateGeometry();
934 m_projectMonitorDock->adjustSize();
935 m_projectMonitor->resetSize();
939 class NameGrabbingKActionCollection {
941 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
942 : m_collection(collection), m_action_names(action_names) {
943 m_action_names.clear();
945 KAction* addAction(const QString& action_name) {
946 m_action_names << action_name;
947 return m_collection->addAction(action_name);
949 void addAction(const QString& action_name, QAction* action) {
950 m_action_names << action_name;
951 m_collection->addAction(action_name, action);
953 operator KActionCollection*() { return m_collection; }
954 const QStringList& actionNames() const { return m_action_names; }
956 KActionCollection* m_collection;
957 QStringList& m_action_names;
960 void MainWindow::setupActions()
963 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
964 m_timecodeFormat = new KComboBox(this);
965 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
966 m_timecodeFormat->addItem(i18n("Frames"));
967 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
968 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
970 m_statusProgressBar = new QProgressBar(this);
971 m_statusProgressBar->setMinimum(0);
972 m_statusProgressBar->setMaximum(100);
973 m_statusProgressBar->setMaximumWidth(150);
974 m_statusProgressBar->setVisible(false);
976 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
977 toolbar->setMovable(false);
978 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
979 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
980 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
981 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
982 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
983 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());
984 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
986 //create edit mode buttons
987 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
988 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
989 toolbar->addAction(m_normalEditTool);
990 m_normalEditTool->setCheckable(true);
991 m_normalEditTool->setChecked(true);
993 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
994 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
995 toolbar->addAction(m_overwriteEditTool);
996 m_overwriteEditTool->setCheckable(true);
997 m_overwriteEditTool->setChecked(false);
999 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
1000 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
1001 toolbar->addAction(m_insertEditTool);
1002 m_insertEditTool->setCheckable(true);
1003 m_insertEditTool->setChecked(false);
1004 // not implemented yet
1005 m_insertEditTool->setEnabled(false);
1007 QActionGroup *editGroup = new QActionGroup(this);
1008 editGroup->addAction(m_normalEditTool);
1009 editGroup->addAction(m_overwriteEditTool);
1010 editGroup->addAction(m_insertEditTool);
1011 editGroup->setExclusive(true);
1012 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
1013 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1015 toolbar->addSeparator();
1017 // create tools buttons
1018 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1019 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1020 toolbar->addAction(m_buttonSelectTool);
1021 m_buttonSelectTool->setCheckable(true);
1022 m_buttonSelectTool->setChecked(true);
1024 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1025 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1026 toolbar->addAction(m_buttonRazorTool);
1027 m_buttonRazorTool->setCheckable(true);
1028 m_buttonRazorTool->setChecked(false);
1030 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1031 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1032 toolbar->addAction(m_buttonSpacerTool);
1033 m_buttonSpacerTool->setCheckable(true);
1034 m_buttonSpacerTool->setChecked(false);
1036 QActionGroup *toolGroup = new QActionGroup(this);
1037 toolGroup->addAction(m_buttonSelectTool);
1038 toolGroup->addAction(m_buttonRazorTool);
1039 toolGroup->addAction(m_buttonSpacerTool);
1040 toolGroup->setExclusive(true);
1041 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1043 QWidget * actionWidget;
1044 int max = toolbar->iconSizeDefault() + 2;
1045 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1046 actionWidget->setMaximumWidth(max);
1047 actionWidget->setMaximumHeight(max - 4);
1049 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1050 actionWidget->setMaximumWidth(max);
1051 actionWidget->setMaximumHeight(max - 4);
1053 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1054 actionWidget->setMaximumWidth(max);
1055 actionWidget->setMaximumHeight(max - 4);
1057 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1058 actionWidget->setMaximumWidth(max);
1059 actionWidget->setMaximumHeight(max - 4);
1061 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1062 actionWidget->setMaximumWidth(max);
1063 actionWidget->setMaximumHeight(max - 4);
1065 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1066 actionWidget->setMaximumWidth(max);
1067 actionWidget->setMaximumHeight(max - 4);
1069 toolbar->setStyleSheet(style1);
1070 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1072 toolbar->addSeparator();
1073 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1074 toolbar->addAction(m_buttonFitZoom);
1075 m_buttonFitZoom->setCheckable(false);
1077 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1078 toolbar->addAction(m_zoomOut);
1079 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1081 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1082 m_zoomSlider->setMaximum(13);
1083 m_zoomSlider->setPageStep(1);
1084 m_zoomSlider->setInvertedAppearance(true);
1086 m_zoomSlider->setMaximumWidth(150);
1087 m_zoomSlider->setMinimumWidth(100);
1088 toolbar->addWidget(m_zoomSlider);
1090 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1091 toolbar->addAction(m_zoomIn);
1092 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1094 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1095 actionWidget->setMaximumWidth(max);
1096 actionWidget->setMaximumHeight(max - 4);
1097 actionWidget->setStyleSheet(styleBorderless);
1099 actionWidget = toolbar->widgetForAction(m_zoomIn);
1100 actionWidget->setMaximumWidth(max);
1101 actionWidget->setMaximumHeight(max - 4);
1102 actionWidget->setStyleSheet(styleBorderless);
1104 actionWidget = toolbar->widgetForAction(m_zoomOut);
1105 actionWidget->setMaximumWidth(max);
1106 actionWidget->setMaximumHeight(max - 4);
1107 actionWidget->setStyleSheet(styleBorderless);
1109 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1110 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1111 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1112 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1113 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1115 toolbar->addSeparator();
1117 //create automatic audio split button
1118 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1119 toolbar->addAction(m_buttonAutomaticSplitAudio);
1120 m_buttonAutomaticSplitAudio->setCheckable(true);
1121 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1122 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1124 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1125 toolbar->addAction(m_buttonVideoThumbs);
1126 m_buttonVideoThumbs->setCheckable(true);
1127 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1128 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1130 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1131 toolbar->addAction(m_buttonAudioThumbs);
1132 m_buttonAudioThumbs->setCheckable(true);
1133 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1134 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1136 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1137 toolbar->addAction(m_buttonShowMarkers);
1138 m_buttonShowMarkers->setCheckable(true);
1139 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1140 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1142 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1143 toolbar->addAction(m_buttonSnap);
1144 m_buttonSnap->setCheckable(true);
1145 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1146 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1148 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1149 actionWidget->setMaximumWidth(max);
1150 actionWidget->setMaximumHeight(max - 4);
1152 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1153 actionWidget->setMaximumWidth(max);
1154 actionWidget->setMaximumHeight(max - 4);
1156 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1157 actionWidget->setMaximumWidth(max);
1158 actionWidget->setMaximumHeight(max - 4);
1160 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1161 actionWidget->setMaximumWidth(max);
1162 actionWidget->setMaximumHeight(max - 4);
1164 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1165 actionWidget->setMaximumWidth(max);
1166 actionWidget->setMaximumHeight(max - 4);
1168 m_messageLabel = new StatusBarMessageLabel(this);
1169 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1171 statusBar()->addWidget(m_messageLabel, 10);
1172 statusBar()->addWidget(m_statusProgressBar, 0);
1173 statusBar()->addPermanentWidget(toolbar);
1174 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1175 statusBar()->addPermanentWidget(m_timecodeFormat);
1176 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1178 collection.addAction("normal_mode", m_normalEditTool);
1179 collection.addAction("overwrite_mode", m_overwriteEditTool);
1180 collection.addAction("insert_mode", m_insertEditTool);
1181 collection.addAction("select_tool", m_buttonSelectTool);
1182 collection.addAction("razor_tool", m_buttonRazorTool);
1183 collection.addAction("spacer_tool", m_buttonSpacerTool);
1185 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1186 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1187 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1188 collection.addAction("show_markers", m_buttonShowMarkers);
1189 collection.addAction("snap", m_buttonSnap);
1190 collection.addAction("zoom_fit", m_buttonFitZoom);
1191 collection.addAction("zoom_in", m_zoomIn);
1192 collection.addAction("zoom_out", m_zoomOut);
1194 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1195 collection.addAction("project_find", m_projectSearch);
1196 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1197 m_projectSearch->setShortcut(Qt::Key_Slash);
1199 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1200 collection.addAction("project_find_next", m_projectSearchNext);
1201 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1202 m_projectSearchNext->setShortcut(Qt::Key_F3);
1203 m_projectSearchNext->setEnabled(false);
1205 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1206 collection.addAction("manage_profiles", profilesAction);
1207 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1209 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1210 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1211 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1212 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1214 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1215 collection.addAction("run_wizard", wizAction);
1216 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1218 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1219 collection.addAction("project_settings", projectAction);
1220 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1222 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1223 collection.addAction("open_backup", backupAction);
1224 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1226 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1227 collection.addAction("project_render", projectRender);
1228 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1229 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1231 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1232 collection.addAction("project_clean", projectClean);
1233 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1235 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1236 collection.addAction("project_adjust_profile", projectAdjust);
1237 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1239 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1240 KShortcut playShortcut;
1241 playShortcut.setPrimary(Qt::Key_Space);
1242 playShortcut.setAlternate(Qt::Key_K);
1243 monitorPlay->setShortcut(playShortcut);
1244 collection.addAction("monitor_play", monitorPlay);
1245 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1247 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1248 collection.addAction("monitor_pause", monitorPause);
1249 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1251 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1252 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1253 collection.addAction("monitor_play_zone", m_playZone);
1254 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1256 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1257 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1258 collection.addAction("monitor_loop_zone", m_loopZone);
1259 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1261 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1262 m_loopClip->setEnabled(false);
1263 collection.addAction("monitor_loop_clip", m_loopClip);
1264 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1266 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1267 collection.addAction("dvd_wizard", dvdWizard);
1268 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1270 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1271 collection.addAction("transcode_clip", transcodeClip);
1272 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1274 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1275 collection.addAction("archive_project", archiveProject);
1276 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1279 KAction *markIn = collection.addAction("mark_in");
1280 markIn->setText(i18n("Set Zone In"));
1281 markIn->setShortcut(Qt::Key_I);
1282 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1284 KAction *markOut = collection.addAction("mark_out");
1285 markOut->setText(i18n("Set Zone Out"));
1286 markOut->setShortcut(Qt::Key_O);
1287 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1289 KAction *switchMon = collection.addAction("switch_monitor");
1290 switchMon->setText(i18n("Switch monitor"));
1291 switchMon->setShortcut(Qt::Key_T);
1292 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1294 KAction *fullMon = collection.addAction("monitor_fullscreen");
1295 fullMon->setText(i18n("Switch monitor fullscreen"));
1296 fullMon->setIcon(KIcon("view-fullscreen"));
1297 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1299 KAction *insertTree = collection.addAction("insert_project_tree");
1300 insertTree->setText(i18n("Insert zone in project tree"));
1301 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1302 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1304 KAction *insertTimeline = collection.addAction("insert_timeline");
1305 insertTimeline->setText(i18n("Insert zone in timeline"));
1306 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1307 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1309 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1310 collection.addAction("resize_timeline_clip_start", resizeStart);
1311 resizeStart->setShortcut(Qt::Key_1);
1312 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1314 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1315 collection.addAction("resize_timeline_clip_end", resizeEnd);
1316 resizeEnd->setShortcut(Qt::Key_2);
1317 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1319 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1320 monitorSeekBackward->setShortcut(Qt::Key_J);
1321 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1322 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1324 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1325 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1326 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1327 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1329 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1330 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1331 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1332 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1334 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1335 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1336 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1337 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1339 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1340 monitorSeekForward->setShortcut(Qt::Key_L);
1341 collection.addAction("monitor_seek_forward", monitorSeekForward);
1342 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1344 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1345 clipStart->setShortcut(Qt::Key_Home);
1346 collection.addAction("seek_clip_start", clipStart);
1347 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1349 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1350 clipEnd->setShortcut(Qt::Key_End);
1351 collection.addAction("seek_clip_end", clipEnd);
1352 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1354 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1355 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1356 collection.addAction("seek_zone_start", zoneStart);
1357 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1359 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1360 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1361 collection.addAction("seek_zone_end", zoneEnd);
1362 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1364 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1365 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1366 collection.addAction("seek_start", projectStart);
1367 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1369 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1370 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1371 collection.addAction("seek_end", projectEnd);
1372 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1374 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1375 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1376 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1377 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1379 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1380 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1381 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1382 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1384 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1385 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1386 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1387 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1389 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1390 deleteItem->setShortcut(Qt::Key_Delete);
1391 collection.addAction("delete_timeline_clip", deleteItem);
1392 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1394 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1395 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1396 editTimelineClipSpeed->setData("change_speed");
1397 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1399 KAction *stickTransition = collection.addAction("auto_transition");
1400 stickTransition->setData(QString("auto"));
1401 stickTransition->setCheckable(true);
1402 stickTransition->setEnabled(false);
1403 stickTransition->setText(i18n("Automatic Transition"));
1404 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1406 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1407 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1408 collection.addAction("group_clip", groupClip);
1409 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1411 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1412 collection.addAction("ungroup_clip", ungroupClip);
1413 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1414 ungroupClip->setData("ungroup_clip");
1415 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1417 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1418 collection.addAction("edit_item_duration", editItemDuration);
1419 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1421 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1422 collection.addAction("clip_in_project_tree", clipInProjectTree);
1423 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1425 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1426 collection.addAction("clip_to_project_tree", clipToProjectTree);
1427 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1429 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1430 insertOvertwrite->setShortcut(Qt::Key_V);
1431 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1432 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1434 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1435 selectTimelineClip->setShortcut(Qt::Key_Plus);
1436 collection.addAction("select_timeline_clip", selectTimelineClip);
1437 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1439 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1440 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1441 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1442 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1444 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1445 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1446 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1447 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1449 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1450 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1451 collection.addAction("select_timeline_transition", selectTimelineTransition);
1452 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1454 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1455 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1456 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1457 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1459 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1460 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1461 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1462 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1464 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1465 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1466 collection.addAction("cut_timeline_clip", cutTimelineClip);
1467 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1469 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1470 collection.addAction("add_clip_marker", addClipMarker);
1471 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1473 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1474 collection.addAction("delete_clip_marker", deleteClipMarker);
1475 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1477 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1478 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1479 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1481 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1482 editClipMarker->setData(QString("edit_marker"));
1483 collection.addAction("edit_clip_marker", editClipMarker);
1484 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1486 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1487 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1488 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1489 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1491 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1492 collection.addAction("split_audio", splitAudio);
1493 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1495 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1496 collection.addAction("clip_audio_only", audioOnly);
1497 audioOnly->setData("clip_audio_only");
1498 audioOnly->setCheckable(true);
1500 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1501 collection.addAction("clip_video_only", videoOnly);
1502 videoOnly->setData("clip_video_only");
1503 videoOnly->setCheckable(true);
1505 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1506 collection.addAction("clip_audio_and_video", audioAndVideo);
1507 audioAndVideo->setData("clip_audio_and_video");
1508 audioAndVideo->setCheckable(true);
1510 m_clipTypeGroup = new QActionGroup(this);
1511 m_clipTypeGroup->addAction(audioOnly);
1512 m_clipTypeGroup->addAction(videoOnly);
1513 m_clipTypeGroup->addAction(audioAndVideo);
1514 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1515 m_clipTypeGroup->setEnabled(false);
1517 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1518 collection.addAction("insert_space", insertSpace);
1519 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1521 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1522 collection.addAction("delete_space", removeSpace);
1523 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1525 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1526 collection.addAction("insert_track", insertTrack);
1527 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1529 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1530 collection.addAction("delete_track", deleteTrack);
1531 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1533 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1534 collection.addAction("config_tracks", configTracks);
1535 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1537 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1538 collection.addAction("add_guide", addGuide);
1539 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1541 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1542 collection.addAction("delete_guide", delGuide);
1543 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1545 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1546 collection.addAction("edit_guide", editGuide);
1547 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1549 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1550 collection.addAction("delete_all_guides", delAllGuides);
1551 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1553 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1554 collection.addAction("paste_effects", pasteEffects);
1555 pasteEffects->setData("paste_effects");
1556 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1558 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1559 collection.addAction("show_timeline", showTimeline);
1560 showTimeline->setCheckable(true);
1561 showTimeline->setChecked(true);
1562 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1564 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1565 collection.addAction("show_titlebars", showTitleBar);
1566 showTitleBar->setCheckable(true);
1567 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1568 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1569 slotShowTitleBars(KdenliveSettings::showtitlebars());
1571 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1572 KStandardAction::quit(this, SLOT(close()), collection);
1573 KStandardAction::open(this, SLOT(openFile()), collection);
1574 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1575 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1576 KStandardAction::openNew(this, SLOT(newFile()), collection);
1577 // TODO: make the following connection to slotEditKeys work
1578 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1579 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1580 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1581 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1582 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1583 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1585 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1586 undo->setEnabled(false);
1587 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1589 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1590 redo->setEnabled(false);
1591 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1594 //TODO: Add status tooltip to actions ?
1595 connect(collection, SIGNAL(actionHovered(QAction*)),
1596 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1599 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1600 collection.addAction("add_clip", addClip);
1601 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1603 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1604 collection.addAction("add_color_clip", addColorClip);
1605 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1607 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1608 collection.addAction("add_slide_clip", addSlideClip);
1609 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1611 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1612 collection.addAction("add_text_clip", addTitleClip);
1613 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1615 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1616 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1617 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1619 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1620 collection.addAction("add_folder", addFolderButton);
1621 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1623 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1624 collection.addAction("clip_properties", clipProperties);
1625 clipProperties->setData("clip_properties");
1626 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1627 clipProperties->setEnabled(false);
1629 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1630 collection.addAction("edit_clip", openClip);
1631 openClip->setData("edit_clip");
1632 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1633 openClip->setEnabled(false);
1635 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1636 collection.addAction("delete_clip", deleteClip);
1637 deleteClip->setData("delete_clip");
1638 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1639 deleteClip->setEnabled(false);
1641 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1642 collection.addAction("reload_clip", reloadClip);
1643 reloadClip->setData("reload_clip");
1644 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1645 reloadClip->setEnabled(false);
1647 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1648 collection.addAction("proxy_clip", proxyClip);
1649 proxyClip->setData("proxy_clip");
1650 proxyClip->setCheckable(true);
1651 proxyClip->setChecked(false);
1652 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1654 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1655 collection.addAction("stopmotion", stopMotion);
1656 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1658 QMenu *addClips = new QMenu();
1659 addClips->addAction(addClip);
1660 addClips->addAction(addColorClip);
1661 addClips->addAction(addSlideClip);
1662 addClips->addAction(addTitleClip);
1663 addClips->addAction(addTitleTemplateClip);
1664 addClips->addAction(addFolderButton);
1666 addClips->addAction(reloadClip);
1667 addClips->addAction(proxyClip);
1668 addClips->addAction(clipProperties);
1669 addClips->addAction(openClip);
1670 addClips->addAction(deleteClip);
1671 m_projectList->setupMenu(addClips, addClip);
1673 // Setup effects and transitions actions.
1674 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1675 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1676 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1677 m_transitions = new KAction*[transitions.count()];
1678 for (int i = 0; i < transitions.count(); i++) {
1679 QStringList effectInfo = transitions.effectIdInfo(i);
1680 m_transitions[i] = new KAction(effectInfo.at(0), this);
1681 m_transitions[i]->setData(effectInfo);
1682 m_transitions[i]->setIconVisibleInMenu(false);
1683 QString id = effectInfo.at(2);
1684 if (id.isEmpty()) id = effectInfo.at(1);
1685 transitionActions->addAction("transition_" + id, m_transitions[i]);
1687 //m_effectsActionCollection->readSettings();
1691 void MainWindow::slotDisplayActionMessage(QAction *a)
1693 statusBar()->showMessage(a->data().toString(), 3000);
1696 void MainWindow::loadLayouts()
1698 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1699 if (m_loadLayout == NULL || saveLayout == NULL) return;
1700 KSharedConfigPtr config = KGlobal::config();
1701 KConfigGroup layoutGroup(config, "Layouts");
1702 QStringList entries = layoutGroup.keyList();
1703 QList<QAction *> loadActions = m_loadLayout->actions();
1704 QList<QAction *> saveActions = saveLayout->actions();
1705 for (int i = 1; i < 5; i++) {
1706 // Rename the layouts actions
1707 foreach(const QString & key, entries) {
1708 if (key.endsWith(QString("_%1").arg(i))) {
1709 // Found previously saved layout
1710 QString layoutName = key.section("_", 0, -2);
1711 for (int j = 0; j < loadActions.count(); j++) {
1712 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1713 loadActions[j]->setText(layoutName);
1714 loadActions[j]->setData(key);
1718 for (int j = 0; j < saveActions.count(); j++) {
1719 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1720 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1721 saveActions[j]->setData(key);
1730 void MainWindow::slotLoadLayout(QAction *action)
1732 if (!action) return;
1733 QString layoutId = action->data().toString();
1734 if (layoutId.isEmpty()) return;
1735 KSharedConfigPtr config = KGlobal::config();
1736 KConfigGroup layouts(config, "Layouts");
1737 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1738 restoreState(state);
1741 void MainWindow::slotSaveLayout(QAction *action)
1743 QString originallayoutName = action->data().toString();
1744 int layoutId = originallayoutName.section('_', -1).toInt();
1746 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1747 if (layoutName.isEmpty()) return;
1748 KSharedConfigPtr config = KGlobal::config();
1749 KConfigGroup layouts(config, "Layouts");
1750 layouts.deleteEntry(originallayoutName);
1752 QByteArray st = saveState();
1753 layoutName.append("_" + QString::number(layoutId));
1754 layouts.writeEntry(layoutName, st.toBase64());
1758 void MainWindow::saveOptions()
1760 KdenliveSettings::self()->writeConfig();
1761 KSharedConfigPtr config = KGlobal::config();
1762 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1763 KConfigGroup treecolumns(config, "Project Tree");
1764 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1768 void MainWindow::readOptions()
1770 KSharedConfigPtr config = KGlobal::config();
1771 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1772 KConfigGroup initialGroup(config, "version");
1773 bool upgrade = false;
1774 if (initialGroup.exists()) {
1775 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1779 if (initialGroup.readEntry("version") == "0.7") {
1780 //Add new settings from 0.7.1
1781 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1782 QString path = QDir::homePath() + "/kdenlive";
1783 if (KStandardDirs::makeDir(path) == false) {
1784 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1785 } else KdenliveSettings::setDefaultprojectfolder(path);
1791 if (!initialGroup.exists() || upgrade) {
1792 // this is our first run, show Wizard
1793 Wizard *w = new Wizard(upgrade, this);
1794 if (w->exec() == QDialog::Accepted && w->isOk()) {
1795 w->adjustSettings();
1796 initialGroup.writeEntry("version", version);
1802 KConfigGroup treecolumns(config, "Project Tree");
1803 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1804 if (!state.isEmpty())
1805 m_projectList->setHeaderInfo(state);
1808 void MainWindow::slotRunWizard()
1810 Wizard *w = new Wizard(false, this);
1811 if (w->exec() == QDialog::Accepted && w->isOk()) {
1812 w->adjustSettings();
1817 void MainWindow::newFile(bool showProjectSettings, bool force)
1819 if (!m_timelineArea->isEnabled() && !force)
1821 m_fileRevert->setEnabled(false);
1822 QString profileName = KdenliveSettings::default_profile();
1823 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1824 QMap <QString, QString> documentProperties;
1825 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1826 if (!showProjectSettings) {
1827 if (!KdenliveSettings::activatetabs())
1828 if (!closeCurrentDocument())
1831 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1832 if (w->exec() != QDialog::Accepted)
1834 if (!KdenliveSettings::activatetabs())
1835 if (!closeCurrentDocument())
1837 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1838 slotSwitchVideoThumbs();
1839 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1840 slotSwitchAudioThumbs();
1841 profileName = w->selectedProfile();
1842 projectFolder = w->selectedFolder();
1843 projectTracks = w->tracks();
1844 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1845 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1846 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1847 documentProperties.insert("proxyparams", w->proxyParams());
1848 documentProperties.insert("proxyextension", w->proxyExtension());
1849 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1850 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1853 m_timelineArea->setEnabled(true);
1854 m_projectList->setEnabled(true);
1856 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1857 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1859 TrackView *trackView = new TrackView(doc, &ok, this);
1860 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1863 //m_timelineArea->setEnabled(false);
1864 //m_projectList->setEnabled(false);
1868 if (m_timelineArea->count() == 1) {
1869 connectDocumentInfo(doc);
1870 connectDocument(trackView, doc);
1872 m_timelineArea->setTabBarHidden(false);
1873 m_monitorManager->activateMonitor("clip");
1874 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1877 void MainWindow::activateDocument()
1879 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1880 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1881 KdenliveDoc *currentDoc = currentTab->document();
1882 connectDocumentInfo(currentDoc);
1883 connectDocument(currentTab, currentDoc);
1886 bool MainWindow::closeCurrentDocument(bool saveChanges)
1888 QWidget *w = m_timelineArea->currentWidget();
1889 if (!w) return true;
1890 // closing current document
1891 int ix = m_timelineArea->currentIndex() + 1;
1892 if (ix == m_timelineArea->count()) ix = 0;
1893 m_timelineArea->setCurrentIndex(ix);
1894 TrackView *tabToClose = (TrackView *) w;
1895 KdenliveDoc *docToClose = tabToClose->document();
1896 if (docToClose && docToClose->isModified() && saveChanges) {
1898 if (m_activeDocument->url().fileName().isEmpty())
1899 message = i18n("Save changes to document?");
1901 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1902 switch (KMessageBox::warningYesNoCancel(this, message)) {
1903 case KMessageBox::Yes :
1904 // save document here. If saving fails, return false;
1905 if (saveFile() == false) return false;
1907 case KMessageBox::Cancel :
1914 m_clipMonitor->slotSetClipProducer(NULL);
1915 m_projectList->slotResetProjectList();
1916 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1917 if (m_timelineArea->count() == 1) {
1918 m_timelineArea->setTabBarHidden(true);
1919 m_closeAction->setEnabled(false);
1921 if (docToClose == m_activeDocument) {
1922 delete m_activeDocument;
1923 m_activeDocument = NULL;
1924 m_effectStack->clear();
1925 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1929 if (w == m_activeTimeline) {
1930 delete m_activeTimeline;
1931 m_activeTimeline = NULL;
1938 bool MainWindow::saveFileAs(const QString &outputFileName)
1940 QString currentSceneList;
1941 m_monitorManager->stopActiveMonitor();
1943 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1946 // Save timeline thumbnails
1947 m_activeTimeline->projectView()->saveThumbnails();
1948 m_activeDocument->setUrl(KUrl(outputFileName));
1949 if (m_activeDocument->m_autosave == NULL) {
1950 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1951 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1952 setCaption(m_activeDocument->description());
1953 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1954 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1955 m_activeDocument->setModified(false);
1956 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1957 m_fileRevert->setEnabled(true);
1958 m_undoView->stack()->setClean();
1962 bool MainWindow::saveFileAs()
1964 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1965 if (outputFile.isEmpty()) {
1968 if (QFile::exists(outputFile)) {
1969 // Show the file dialog again if the user does not want to overwrite the file
1970 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1971 return saveFileAs();
1973 return saveFileAs(outputFile);
1976 bool MainWindow::saveFile()
1978 if (!m_activeDocument) return true;
1979 if (m_activeDocument->url().isEmpty()) {
1980 return saveFileAs();
1982 bool result = saveFileAs(m_activeDocument->url().path());
1983 m_activeDocument->m_autosave->resize(0);
1988 void MainWindow::openFile()
1990 if (!m_startUrl.isEmpty()) {
1991 openFile(m_startUrl);
1992 m_startUrl = KUrl();
1995 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1996 if (url.isEmpty()) return;
1997 m_fileOpenRecent->addUrl(url);
2001 void MainWindow::openLastFile()
2003 KSharedConfigPtr config = KGlobal::config();
2004 KUrl::List urls = m_fileOpenRecent->urls();
2005 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2006 if (urls.isEmpty()) newFile(false);
2007 else openFile(urls.last());
2010 void MainWindow::openFile(const KUrl &url)
2012 // Make sure the url is a Kdenlive project file
2013 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2014 if (mime.data()->is("application/x-compressed-tar")) {
2015 // Opening a compressed project file, we need to process it
2016 kDebug()<<"Opening archive, processing";
2017 ArchiveWidget *ar = new ArchiveWidget(url);
2018 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2022 if (!url.fileName().endsWith(".kdenlive")) {
2023 // This is not a Kdenlive project file, abort loading
2024 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2028 // Check if the document is already opened
2029 const int ct = m_timelineArea->count();
2030 bool isOpened = false;
2032 for (i = 0; i < ct; i++) {
2033 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2034 KdenliveDoc *doc = tab->document();
2035 if (doc->url() == url) {
2041 m_timelineArea->setCurrentIndex(i);
2045 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2047 // Check for backup file
2048 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2049 if (!staleFiles.isEmpty()) {
2050 if (KMessageBox::questionYesNo(this,
2051 i18n("Auto-saved files exist. Do you want to recover them now?"),
2052 i18n("File Recovery"),
2053 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2054 recoverFiles(staleFiles);
2057 // remove the stale files
2058 foreach(KAutoSaveFile * stale, staleFiles) {
2059 stale->open(QIODevice::ReadWrite);
2064 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2065 m_messageLabel->repaint();
2066 doOpenFile(url, NULL);
2069 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2071 if (!m_timelineArea->isEnabled()) return;
2072 m_fileRevert->setEnabled(true);
2074 // Recreate stopmotion widget on document change
2076 delete m_stopmotion;
2077 m_stopmotion = NULL;
2081 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2082 progressDialog.setAllowCancel(false);
2083 progressDialog.progressBar()->setMaximum(4);
2084 progressDialog.show();
2085 progressDialog.progressBar()->setValue(0);
2086 qApp->processEvents();
2089 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);
2091 progressDialog.progressBar()->setValue(1);
2092 progressDialog.progressBar()->setMaximum(4);
2093 progressDialog.setLabelText(i18n("Loading project"));
2094 qApp->processEvents();
2096 if (stale == NULL) {
2097 stale = new KAutoSaveFile(url, doc);
2098 doc->m_autosave = stale;
2100 doc->m_autosave = stale;
2101 doc->setUrl(stale->managedFile());
2102 doc->setModified(true);
2103 stale->setParent(doc);
2105 connectDocumentInfo(doc);
2107 progressDialog.progressBar()->setValue(2);
2108 qApp->processEvents();
2111 TrackView *trackView = new TrackView(doc, &ok, this);
2112 connectDocument(trackView, doc);
2113 progressDialog.progressBar()->setValue(3);
2114 qApp->processEvents();
2116 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2118 m_timelineArea->setEnabled(false);
2119 m_projectList->setEnabled(false);
2120 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2121 slotGotProgressInfo(QString(), -1);
2122 newFile(false, true);
2125 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2126 trackView->setDuration(trackView->duration());
2127 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2129 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2130 slotGotProgressInfo(QString(), -1);
2131 m_projectMonitor->adjustRulerSize(trackView->duration());
2132 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2133 progressDialog.progressBar()->setValue(4);
2134 if (openBackup) slotOpenBackupDialog(url);
2137 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2139 foreach(KAutoSaveFile * stale, staleFiles) {
2140 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2141 // show an error message; we could not steal the lockfile
2142 // maybe another application got to the file before us?
2146 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2147 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2148 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2149 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2153 void MainWindow::parseProfiles(const QString &mltPath)
2155 //KdenliveSettings::setDefaulttmpfolder();
2156 if (!mltPath.isEmpty()) {
2157 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2158 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2161 if (KdenliveSettings::mltpath().isEmpty())
2162 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2164 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2165 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2166 if (!QFile::exists(meltPath))
2167 meltPath = KStandardDirs::findExe("melt");
2168 KdenliveSettings::setRendererpath(meltPath);
2171 if (KdenliveSettings::rendererpath().isEmpty()) {
2172 // Cannot find the MLT melt renderer, ask for location
2173 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2174 if (getUrl->exec() == QDialog::Rejected) {
2177 KUrl rendererPath = getUrl->selectedUrl();
2179 if (rendererPath.isEmpty()) ::exit(0);
2180 KdenliveSettings::setRendererpath(rendererPath.path());
2183 QStringList profilesFilter;
2184 profilesFilter << "*";
2185 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2186 if (profilesList.isEmpty()) {
2187 // Cannot find MLT path, try finding melt
2188 QString profilePath = KdenliveSettings::rendererpath();
2189 if (!profilePath.isEmpty()) {
2190 profilePath = profilePath.section('/', 0, -3);
2191 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2192 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2194 if (profilesList.isEmpty()) {
2195 // Cannot find the MLT profiles, ask for location
2196 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2197 getUrl->fileDialog()->setMode(KFile::Directory);
2198 if (getUrl->exec() == QDialog::Rejected) {
2201 KUrl mltPath = getUrl->selectedUrl();
2203 if (mltPath.isEmpty()) ::exit(0);
2204 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2205 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2209 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2211 // Parse again MLT profiles to build a list of available video formats
2212 if (profilesList.isEmpty()) parseProfiles();
2216 void MainWindow::slotEditProfiles()
2218 ProfilesDialog *w = new ProfilesDialog;
2219 if (w->exec() == QDialog::Accepted) {
2220 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2221 if (d) d->checkProfile();
2226 void MainWindow::slotDetectAudioDriver()
2228 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2229 leading to no audio output, see bug #934 */
2231 //decide which audio driver is really best, in some cases SDL is wrong
2232 if (KdenliveSettings::audiodrivername().isEmpty()) {
2234 KProcess readProcess;
2235 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2236 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2237 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2238 readProcess.setProgram("pactl", QStringList() << "stat");
2239 readProcess.execute(2000); // Kill it after 2 seconds
2241 QString result = QString(readProcess.readAllStandardOutput());
2242 kDebug() << "// / / / / / READING PACTL: ";
2244 if (!result.isEmpty()) {
2246 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2250 KdenliveSettings::setAutoaudiodrivername(driver);
2254 void MainWindow::slotEditProjectSettings()
2256 QPoint p = m_activeDocument->getTracksCount();
2257 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2258 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2260 if (w->exec() == QDialog::Accepted) {
2261 QString profile = w->selectedProfile();
2262 m_activeDocument->setProjectFolder(w->selectedFolder());
2264 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2266 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2267 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2268 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2269 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2270 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2271 m_activeDocument->setModified();
2272 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2273 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) {
2274 //TODO: rebuild all proxies
2275 //m_projectList->rebuildProxies();
2278 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2279 m_activeDocument->setModified();
2280 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2282 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2283 m_activeDocument->setModified();
2284 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2286 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2287 m_activeDocument->setModified();
2288 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2290 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2291 m_activeDocument->setModified();
2292 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2294 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2295 m_activeDocument->setModified();
2296 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2298 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2299 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2300 m_activeDocument->setModified();
2301 slotUpdateProxySettings();
2307 void MainWindow::slotDisableProxies()
2309 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2310 m_activeDocument->setModified();
2311 slotUpdateProxySettings();
2314 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2316 // Recreate the stopmotion widget if profile changes
2318 delete m_stopmotion;
2319 m_stopmotion = NULL;
2322 // Deselect current effect / transition
2323 m_effectStack->slotClipItemSelected(NULL, 0);
2324 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2325 m_clipMonitor->slotSetClipProducer(NULL);
2326 bool updateFps = m_activeDocument->setProfilePath(profile);
2327 KdenliveSettings::setCurrent_profile(profile);
2328 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2329 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2331 m_activeDocument->clipManager()->clearUnusedProducers();
2332 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2333 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2334 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2335 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2336 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2337 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2338 if (updateFps) m_activeTimeline->updateProjectFps();
2339 m_activeDocument->clipManager()->clearCache();
2340 m_activeTimeline->updateProfile();
2341 m_activeDocument->setModified(true);
2342 m_commandStack->activeStack()->clear();
2343 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2344 slotUpdateMousePosition(0);
2345 // We need to desactivate & reactivate monitors to get a refresh
2346 //m_monitorManager->switchMonitors();
2350 void MainWindow::slotRenderProject()
2352 if (!m_renderWidget) {
2353 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2354 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2355 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2356 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2357 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2358 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2359 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2360 if (m_activeDocument) {
2361 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2362 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2363 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2364 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2367 slotCheckRenderStatus();
2368 m_renderWidget->show();
2369 m_renderWidget->showNormal();
2371 // What are the following lines supposed to do?
2372 //m_activeTimeline->tracksNumber();
2373 //m_renderWidget->enableAudio(false);
2374 //m_renderWidget->export_audio;
2377 void MainWindow::slotCheckRenderStatus()
2379 // Make sure there are no missing clips
2381 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2384 void MainWindow::setRenderingProgress(const QString &url, int progress)
2387 m_renderWidget->setRenderJob(url, progress);
2390 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2393 m_renderWidget->setRenderStatus(url, status, error);
2396 void MainWindow::slotCleanProject()
2398 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2399 m_projectList->cleanup();
2402 void MainWindow::slotUpdateMousePosition(int pos)
2404 if (m_activeDocument)
2405 switch (m_timecodeFormat->currentIndex()) {
2407 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2410 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2414 void MainWindow::slotUpdateDocumentState(bool modified)
2416 if (!m_activeDocument) return;
2417 setCaption(m_activeDocument->description(), modified);
2418 m_saveAction->setEnabled(modified);
2420 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2421 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2423 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2424 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2428 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2430 if (m_activeDocument) {
2431 if (m_activeDocument == doc) return;
2432 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2434 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2437 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2439 //m_projectMonitor->stop();
2440 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2441 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2442 if (m_activeDocument) {
2443 if (m_activeDocument == doc) return;
2444 if (m_activeTimeline) {
2445 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2446 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2447 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2448 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2449 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2450 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2451 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2453 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2455 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2456 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2457 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2458 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2459 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2460 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2461 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2462 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2463 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2464 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2465 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2466 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2467 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2468 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2469 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2470 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2471 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2472 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2473 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2474 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2475 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2476 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2477 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2478 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2479 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2480 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2481 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2482 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2483 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2484 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2485 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2486 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2487 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2488 m_effectStack->clear();
2490 //m_activeDocument->setRenderer(NULL);
2491 m_clipMonitor->stop();
2493 KdenliveSettings::setCurrent_profile(doc->profilePath());
2494 KdenliveSettings::setProject_fps(doc->fps());
2495 m_monitorManager->resetProfiles(doc->timecode());
2496 m_clipMonitorDock->raise();
2497 m_projectList->setDocument(doc);
2498 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2499 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2500 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2502 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2503 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2505 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2506 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2507 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2508 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2509 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2510 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2511 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2512 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2513 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2514 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2515 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2516 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2517 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2519 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2520 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2521 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2522 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2523 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2525 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2526 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2527 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2529 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2531 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2532 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2533 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2534 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2536 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2537 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2538 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2539 m_zoomSlider->setValue(doc->zoom().x());
2540 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2541 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2542 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2543 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2545 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2546 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2548 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2549 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2551 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2552 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2553 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2554 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2555 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2556 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2557 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2558 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2559 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2560 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2561 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2563 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2564 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2565 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2568 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2569 m_activeTimeline = trackView;
2570 if (m_renderWidget) {
2571 slotCheckRenderStatus();
2572 m_renderWidget->setProfile(doc->mltProfile());
2573 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2574 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2575 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2577 //doc->setRenderer(m_projectMonitor->render);
2578 m_commandStack->setActiveStack(doc->commandStack());
2579 KdenliveSettings::setProject_display_ratio(doc->dar());
2580 //doc->clipManager()->checkAudioThumbs();
2582 //m_overView->setScene(trackView->projectScene());
2583 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2584 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2586 setCaption(doc->description(), doc->isModified());
2587 m_saveAction->setEnabled(doc->isModified());
2588 m_normalEditTool->setChecked(true);
2589 m_activeDocument = doc;
2590 m_activeTimeline->updateProjectFps();
2591 m_activeDocument->checkProjectClips();
2593 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2595 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2596 slotUpdateMousePosition(0);
2597 m_monitorManager->activateMonitor("clip");
2598 // set tool to select tool
2599 m_buttonSelectTool->setChecked(true);
2602 void MainWindow::slotZoneMoved(int start, int end)
2604 m_activeDocument->setZone(start, end);
2605 m_projectMonitor->slotZoneMoved(start, end);
2608 void MainWindow::slotGuidesUpdated()
2611 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2614 void MainWindow::slotEditKeys()
2616 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2617 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2618 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2622 void MainWindow::slotPreferences(int page, int option)
2625 * An instance of your dialog could be already created and could be
2626 * cached, in which case you want to display the cached dialog
2627 * instead of creating another one
2629 if (m_stopmotion) m_stopmotion->slotLive(false);
2630 if (KConfigDialog::showDialog("settings")) {
2631 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2632 if (page != -1) d->showPage(page, option);
2636 // KConfigDialog didn't find an instance of this dialog, so lets
2639 // Get the mappable actions in localized form
2640 QMap<QString, QString> actions;
2641 KActionCollection* collection = actionCollection();
2642 foreach (const QString& action_name, m_action_names) {
2643 actions[collection->action(action_name)->text()] = action_name;
2646 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2647 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2648 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2650 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2653 if (page != -1) dialog->showPage(page, option);
2656 void MainWindow::slotUpdateCaptureFolder()
2660 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2661 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2665 void MainWindow::updateConfiguration()
2667 //TODO: we should apply settings to all projects, not only the current one
2668 if (m_activeTimeline) {
2669 m_activeTimeline->refresh();
2670 m_activeTimeline->projectView()->checkAutoScroll();
2671 m_activeTimeline->checkTrackHeight();
2672 if (m_activeDocument)
2673 m_activeDocument->clipManager()->checkAudioThumbs();
2675 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2676 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2677 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2678 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2680 // Update list of transcoding profiles
2682 #ifndef NO_JOGSHUTTLE
2683 activateShuttleDevice();
2684 #endif /* NO_JOGSHUTTLE */
2688 void MainWindow::slotSwitchSplitAudio()
2690 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2691 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2694 void MainWindow::slotSwitchVideoThumbs()
2696 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2697 if (m_activeTimeline)
2698 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2699 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2702 void MainWindow::slotSwitchAudioThumbs()
2704 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2705 if (m_activeTimeline) {
2706 m_activeTimeline->refresh();
2707 m_activeTimeline->projectView()->checkAutoScroll();
2708 if (m_activeDocument)
2709 m_activeDocument->clipManager()->checkAudioThumbs();
2711 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2714 void MainWindow::slotSwitchMarkersComments()
2716 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2717 if (m_activeTimeline)
2718 m_activeTimeline->refresh();
2719 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2722 void MainWindow::slotSwitchSnap()
2724 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2725 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2729 void MainWindow::slotDeleteItem()
2731 if (QApplication::focusWidget() &&
2732 QApplication::focusWidget()->parentWidget() &&
2733 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2734 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2735 m_projectList->slotRemoveClip();
2738 QWidget *widget = QApplication::focusWidget();
2740 if (widget == m_effectStackDock) {
2741 m_effectStack->slotItemDel();
2744 widget = widget->parentWidget();
2747 // effect stack has no focus
2748 if (m_activeTimeline)
2749 m_activeTimeline->projectView()->deleteSelectedClips();
2753 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2755 if (m_clipMonitor->isActive())
2756 m_clipMonitor->checkOverlay();
2757 m_clipMonitor->updateMarkers(clip);
2760 void MainWindow::slotAddClipMarker()
2762 DocClipBase *clip = NULL;
2764 if (m_projectMonitor->isActive()) {
2765 if (m_activeTimeline) {
2766 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2768 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2769 clip = item->baseClip();
2773 clip = m_clipMonitor->activeClip();
2774 pos = m_clipMonitor->position();
2777 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2780 QString id = clip->getId();
2781 CommentedTime marker(pos, i18n("Marker"));
2782 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2783 if (d.exec() == QDialog::Accepted)
2784 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2787 void MainWindow::slotDeleteClipMarker()
2789 DocClipBase *clip = NULL;
2791 if (m_projectMonitor->isActive()) {
2792 if (m_activeTimeline) {
2793 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2795 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2796 clip = item->baseClip();
2800 clip = m_clipMonitor->activeClip();
2801 pos = m_clipMonitor->position();
2804 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2808 QString id = clip->getId();
2809 QString comment = clip->markerComment(pos);
2810 if (comment.isEmpty()) {
2811 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2814 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2817 void MainWindow::slotDeleteAllClipMarkers()
2819 DocClipBase *clip = NULL;
2820 if (m_projectMonitor->isActive()) {
2821 if (m_activeTimeline) {
2822 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2824 clip = item->baseClip();
2828 clip = m_clipMonitor->activeClip();
2831 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2834 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2837 void MainWindow::slotEditClipMarker()
2839 DocClipBase *clip = NULL;
2841 if (m_projectMonitor->isActive()) {
2842 if (m_activeTimeline) {
2843 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2845 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2846 clip = item->baseClip();
2850 clip = m_clipMonitor->activeClip();
2851 pos = m_clipMonitor->position();
2854 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2858 QString id = clip->getId();
2859 QString oldcomment = clip->markerComment(pos);
2860 if (oldcomment.isEmpty()) {
2861 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2865 CommentedTime marker(pos, oldcomment);
2866 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2867 if (d.exec() == QDialog::Accepted) {
2868 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2869 if (d.newMarker().time() != pos) {
2870 // remove old marker
2871 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2876 void MainWindow::slotAddMarkerGuideQuickly()
2878 if (!m_activeTimeline || !m_activeDocument)
2881 if (m_clipMonitor->isActive()) {
2882 DocClipBase *clip = m_clipMonitor->activeClip();
2883 GenTime pos = m_clipMonitor->position();
2886 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2890 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2892 m_activeTimeline->projectView()->slotAddGuide(false);
2896 void MainWindow::slotAddGuide()
2898 if (m_activeTimeline)
2899 m_activeTimeline->projectView()->slotAddGuide();
2902 void MainWindow::slotInsertSpace()
2904 if (m_activeTimeline)
2905 m_activeTimeline->projectView()->slotInsertSpace();
2908 void MainWindow::slotRemoveSpace()
2910 if (m_activeTimeline)
2911 m_activeTimeline->projectView()->slotRemoveSpace();
2914 void MainWindow::slotInsertTrack(int ix)
2916 m_projectMonitor->activateMonitor();
2917 if (m_activeTimeline)
2918 m_activeTimeline->projectView()->slotInsertTrack(ix);
2919 if (m_activeDocument)
2920 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2923 void MainWindow::slotDeleteTrack(int ix)
2925 m_projectMonitor->activateMonitor();
2926 if (m_activeTimeline)
2927 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2928 if (m_activeDocument)
2929 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2932 void MainWindow::slotConfigTrack(int ix)
2934 m_projectMonitor->activateMonitor();
2935 if (m_activeTimeline)
2936 m_activeTimeline->projectView()->slotConfigTracks(ix);
2937 if (m_activeDocument)
2938 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2941 void MainWindow::slotEditGuide()
2943 if (m_activeTimeline)
2944 m_activeTimeline->projectView()->slotEditGuide();
2947 void MainWindow::slotDeleteGuide()
2949 if (m_activeTimeline)
2950 m_activeTimeline->projectView()->slotDeleteGuide();
2953 void MainWindow::slotDeleteAllGuides()
2955 if (m_activeTimeline)
2956 m_activeTimeline->projectView()->slotDeleteAllGuides();
2959 void MainWindow::slotCutTimelineClip()
2961 if (m_activeTimeline)
2962 m_activeTimeline->projectView()->cutSelectedClips();
2965 void MainWindow::slotInsertClipOverwrite()
2967 if (m_activeTimeline) {
2968 QStringList data = m_clipMonitor->getZoneInfo();
2969 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2973 void MainWindow::slotSelectTimelineClip()
2975 if (m_activeTimeline)
2976 m_activeTimeline->projectView()->selectClip(true);
2979 void MainWindow::slotSelectTimelineTransition()
2981 if (m_activeTimeline)
2982 m_activeTimeline->projectView()->selectTransition(true);
2985 void MainWindow::slotDeselectTimelineClip()
2987 if (m_activeTimeline)
2988 m_activeTimeline->projectView()->selectClip(false, true);
2991 void MainWindow::slotDeselectTimelineTransition()
2993 if (m_activeTimeline)
2994 m_activeTimeline->projectView()->selectTransition(false, true);
2997 void MainWindow::slotSelectAddTimelineClip()
2999 if (m_activeTimeline)
3000 m_activeTimeline->projectView()->selectClip(true, true);
3003 void MainWindow::slotSelectAddTimelineTransition()
3005 if (m_activeTimeline)
3006 m_activeTimeline->projectView()->selectTransition(true, true);
3009 void MainWindow::slotGroupClips()
3011 if (m_activeTimeline)
3012 m_activeTimeline->projectView()->groupClips();
3015 void MainWindow::slotUnGroupClips()
3017 if (m_activeTimeline)
3018 m_activeTimeline->projectView()->groupClips(false);
3021 void MainWindow::slotEditItemDuration()
3023 if (m_activeTimeline)
3024 m_activeTimeline->projectView()->editItemDuration();
3027 void MainWindow::slotAddProjectClip(KUrl url)
3029 if (m_activeDocument)
3030 m_activeDocument->slotAddClipFile(url, QString());
3033 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3035 if (m_activeDocument)
3036 m_activeDocument->slotAddClipList(urls, QString());
3039 void MainWindow::slotAddTransition(QAction *result)
3041 if (!result) return;
3042 QStringList info = result->data().toStringList();
3043 if (info.isEmpty()) return;
3044 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3045 if (m_activeTimeline && !transition.isNull()) {
3046 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3050 void MainWindow::slotAddVideoEffect(QAction *result)
3052 if (!result) return;
3053 const int EFFECT_VIDEO = 1;
3054 const int EFFECT_AUDIO = 2;
3055 QStringList info = result->data().toStringList();
3057 if (info.isEmpty() || info.size() < 3) return;
3058 QDomElement effect ;
3059 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3060 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3061 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3062 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3064 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3065 if (!effect.isNull()) slotAddEffect(effect);
3066 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3070 void MainWindow::slotZoomIn()
3072 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3073 slotShowZoomSliderToolTip();
3076 void MainWindow::slotZoomOut()
3078 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3079 slotShowZoomSliderToolTip();
3082 void MainWindow::slotFitZoom()
3084 if (m_activeTimeline)
3085 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3088 void MainWindow::slotSetZoom(int value)
3090 value = qMax(m_zoomSlider->minimum(), value);
3091 value = qMin(m_zoomSlider->maximum(), value);
3093 if (m_activeTimeline)
3094 m_activeTimeline->slotChangeZoom(value);
3096 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3097 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3098 slotUpdateZoomSliderToolTip(value);
3100 m_zoomSlider->blockSignals(true);
3101 m_zoomSlider->setValue(value);
3102 m_zoomSlider->blockSignals(false);
3105 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3107 if (zoomlevel != -1)
3108 slotUpdateZoomSliderToolTip(zoomlevel);
3110 QPoint global = m_zoomSlider->rect().topLeft();
3111 global.ry() += m_zoomSlider->height() / 2;
3112 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3113 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3116 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3118 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3121 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3123 m_statusProgressBar->setValue(progress);
3124 if (progress >= 0) {
3125 if (!message.isEmpty())
3126 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3127 m_statusProgressBar->setVisible(true);
3128 } else if (progress == -2) {
3129 if (!message.isEmpty())
3130 m_messageLabel->setMessage(message, ErrorMessage);
3131 m_statusProgressBar->setVisible(false);
3133 m_messageLabel->setMessage(QString(), DefaultMessage);
3134 m_statusProgressBar->setVisible(false);
3138 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3140 if (clip->clipType() == TEXT) {
3141 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3142 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3143 // template text clip
3145 // Get the list of existing templates
3147 filter << "*.kdenlivetitle";
3148 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3150 QDialog *dia = new QDialog(this);
3151 Ui::TemplateClip_UI dia_ui;
3152 dia_ui.setupUi(dia);
3154 const QString templatePath = clip->getProperty("resource");
3155 for (int i = 0; i < templateFiles.size(); ++i) {
3156 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3157 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3159 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3160 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3161 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3162 //warning: setting base directory doesn't work??
3163 KUrl startDir(titlepath);
3164 dia_ui.template_list->fileDialog()->setUrl(startDir);
3165 dia_ui.description->setText(clip->getProperty("description"));
3166 if (dia->exec() == QDialog::Accepted) {
3167 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3168 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3170 QMap <QString, QString> newprops;
3172 if (KUrl(textTemplate).path() != templatePath) {
3173 // The template was changed
3174 newprops.insert("resource", textTemplate);
3177 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3178 newprops.insert("description", dia_ui.description->toPlainText());
3181 QString newtemplate = newprops.value("xmltemplate");
3182 if (newtemplate.isEmpty()) newtemplate = templatePath;
3184 // template modified we need to update xmldata
3185 QString description = newprops.value("description");
3186 if (description.isEmpty()) description = clip->getProperty("description");
3187 else newprops.insert("templatetext", description);
3188 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3189 if (!newprops.isEmpty()) {
3190 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3191 m_activeDocument->commandStack()->push(command);
3197 QString path = clip->getProperty("resource");
3198 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3200 doc.setContent(clip->getProperty("xmldata"));
3201 dia_ui->setXml(doc);
3202 if (dia_ui->exec() == QDialog::Accepted) {
3203 QMap <QString, QString> newprops;
3204 newprops.insert("xmldata", dia_ui->xml().toString());
3205 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3206 // duration changed, we need to update duration
3207 newprops.insert("out", QString::number(dia_ui->outPoint()));
3208 int currentLength = QString(clip->producerProperty("length")).toInt();
3209 if (currentLength <= dia_ui->outPoint())
3210 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3211 else newprops.insert("length", clip->producerProperty("length"));
3213 if (!path.isEmpty()) {
3214 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3215 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) {
3216 // save to external file
3217 dia_ui->saveTitle(path);
3218 } else newprops.insert("resource", QString());
3220 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3221 m_activeDocument->commandStack()->push(command);
3222 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3223 m_activeDocument->setModified(true);
3227 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3231 // any type of clip but a title
3232 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3233 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3234 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3235 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)));
3240 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3242 if (newprops.isEmpty()) return;
3243 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3244 m_activeDocument->commandStack()->push(command);
3245 m_activeDocument->setModified();
3248 // update clip occurences in timeline
3249 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3254 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3256 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3257 if (dia.exec() == QDialog::Accepted) {
3258 QUndoCommand *command = new QUndoCommand();
3259 command->setText(i18n("Edit clips"));
3260 QMap <QString, QString> newImageProps = dia.properties();
3261 // Transparency setting applies only for images
3262 QMap <QString, QString> newProps = newImageProps;
3263 newProps.remove("transparency");
3265 for (int i = 0; i < cliplist.count(); i++) {
3266 DocClipBase *clip = cliplist.at(i);
3267 if (clip->clipType() == IMAGE)
3268 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3270 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3272 m_activeDocument->commandStack()->push(command);
3273 for (int i = 0; i < cliplist.count(); i++)
3274 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3278 void MainWindow::customEvent(QEvent* e)
3280 if (e->type() == QEvent::User)
3281 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3283 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3289 m_effectStack->raiseWindow(m_effectStackDock);
3292 void MainWindow::slotActivateTransitionView(Transition *t)
3295 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3298 void MainWindow::slotSnapRewind()
3300 if (m_projectMonitor->isActive()) {
3301 if (m_activeTimeline)
3302 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3304 m_clipMonitor->slotSeekToPreviousSnap();
3308 void MainWindow::slotSnapForward()
3310 if (m_projectMonitor->isActive()) {
3311 if (m_activeTimeline)
3312 m_activeTimeline->projectView()->slotSeekToNextSnap();
3314 m_clipMonitor->slotSeekToNextSnap();
3318 void MainWindow::slotClipStart()
3320 if (m_projectMonitor->isActive()) {
3321 if (m_activeTimeline)
3322 m_activeTimeline->projectView()->clipStart();
3326 void MainWindow::slotClipEnd()
3328 if (m_projectMonitor->isActive()) {
3329 if (m_activeTimeline)
3330 m_activeTimeline->projectView()->clipEnd();
3334 void MainWindow::slotZoneStart()
3336 if (m_projectMonitor->isActive())
3337 m_projectMonitor->slotZoneStart();
3339 m_clipMonitor->slotZoneStart();
3342 void MainWindow::slotZoneEnd()
3344 if (m_projectMonitor->isActive())
3345 m_projectMonitor->slotZoneEnd();
3347 m_clipMonitor->slotZoneEnd();
3350 void MainWindow::slotChangeTool(QAction * action)
3352 if (action == m_buttonSelectTool)
3353 slotSetTool(SELECTTOOL);
3354 else if (action == m_buttonRazorTool)
3355 slotSetTool(RAZORTOOL);
3356 else if (action == m_buttonSpacerTool)
3357 slotSetTool(SPACERTOOL);
3360 void MainWindow::slotChangeEdit(QAction * action)
3362 if (!m_activeTimeline)
3365 if (action == m_overwriteEditTool)
3366 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3367 else if (action == m_insertEditTool)
3368 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3370 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3373 void MainWindow::slotSetTool(PROJECTTOOL tool)
3375 if (m_activeDocument && m_activeTimeline) {
3376 //m_activeDocument->setTool(tool);
3380 message = i18n("Ctrl + click to use spacer on current track only");
3383 message = i18n("Click on a clip to cut it");
3386 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3389 m_messageLabel->setMessage(message, InformationMessage);
3390 m_activeTimeline->projectView()->setTool(tool);
3394 void MainWindow::slotCopy()
3396 if (m_activeDocument && m_activeTimeline)
3397 m_activeTimeline->projectView()->copyClip();
3400 void MainWindow::slotPaste()
3402 if (m_activeDocument && m_activeTimeline)
3403 m_activeTimeline->projectView()->pasteClip();
3406 void MainWindow::slotPasteEffects()
3408 if (m_activeDocument && m_activeTimeline)
3409 m_activeTimeline->projectView()->pasteClipEffects();
3412 void MainWindow::slotFind()
3414 if (!m_activeDocument || !m_activeTimeline) return;
3415 m_projectSearch->setEnabled(false);
3416 m_findActivated = true;
3417 m_findString.clear();
3418 m_activeTimeline->projectView()->initSearchStrings();
3419 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3420 m_findTimer.start(5000);
3421 qApp->installEventFilter(this);
3424 void MainWindow::slotFindNext()
3426 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3427 statusBar()->showMessage(i18n("Found: %1", m_findString));
3429 statusBar()->showMessage(i18n("Reached end of project"));
3430 m_findTimer.start(4000);
3433 void MainWindow::findAhead()
3435 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3436 m_projectSearchNext->setEnabled(true);
3437 statusBar()->showMessage(i18n("Found: %1", m_findString));
3439 m_projectSearchNext->setEnabled(false);
3440 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3444 void MainWindow::findTimeout()
3446 m_projectSearchNext->setEnabled(false);
3447 m_findActivated = false;
3448 m_findString.clear();
3449 statusBar()->showMessage(i18n("Find stopped"), 3000);
3450 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3451 m_projectSearch->setEnabled(true);
3452 removeEventFilter(this);
3455 void MainWindow::slotClipInTimeline(const QString &clipId)
3457 if (m_activeTimeline && m_activeDocument) {
3458 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3460 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3461 inTimelineMenu->clear();
3463 QList <QAction *> actionList;
3465 for (int i = 0; i < matching.count(); ++i) {
3466 QString track = QString::number(matching.at(i).track);
3467 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3469 QAction *a = new QAction(track + ": " + start, this);
3470 a->setData(QStringList() << track << start);
3471 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3472 while (j < actionList.count()) {
3473 if (actionList.at(j)->text() > a->text()) break;
3476 actionList.insert(j, a);
3478 inTimelineMenu->addActions(actionList);
3480 if (matching.empty())
3481 inTimelineMenu->setEnabled(false);
3483 inTimelineMenu->setEnabled(true);
3487 void MainWindow::slotClipInProjectTree()
3489 if (m_activeTimeline) {
3490 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3491 if (clipIds.isEmpty())
3493 m_projectListDock->raise();
3494 for (int i = 0; i < clipIds.count(); i++)
3495 m_projectList->selectItemById(clipIds.at(i));
3496 if (m_projectMonitor->isActive())
3497 slotSwitchMonitors();
3501 /*void MainWindow::slotClipToProjectTree()
3503 if (m_activeTimeline) {
3504 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3505 if (clips.isEmpty()) return;
3506 for (int i = 0; i < clips.count(); i++) {
3507 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3509 //m_projectList->selectItemById(clipIds.at(i));
3513 void MainWindow::slotSelectClipInTimeline()
3515 if (m_activeTimeline) {
3516 QAction *action = qobject_cast<QAction *>(sender());
3517 QStringList data = action->data().toStringList();
3518 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3522 void MainWindow::keyPressEvent(QKeyEvent *ke)
3524 if (m_findActivated) {
3525 if (ke->key() == Qt::Key_Backspace) {
3526 m_findString = m_findString.left(m_findString.length() - 1);
3528 if (!m_findString.isEmpty())
3533 m_findTimer.start(4000);
3536 } else if (ke->key() == Qt::Key_Escape) {
3540 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3541 m_findString += ke->text();
3545 m_findTimer.start(4000);
3550 KXmlGuiWindow::keyPressEvent(ke);
3555 /** Gets called when the window gets hidden */
3556 void MainWindow::hideEvent(QHideEvent */*event*/)
3558 if (isMinimized() && m_monitorManager)
3559 m_monitorManager->stopActiveMonitor();
3562 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3564 if (m_findActivated) {
3565 if (event->type() == QEvent::ShortcutOverride) {
3566 QKeyEvent* ke = (QKeyEvent*) event;
3567 if (ke->text().trimmed().isEmpty()) return false;
3574 // pass the event on to the parent class
3575 return QMainWindow::eventFilter(obj, event);
3580 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3582 KDialog *dialog = new KDialog(this);
3583 dialog->setCaption("Save clip zone");
3584 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3586 QWidget *widget = new QWidget(dialog);
3587 dialog->setMainWidget(widget);
3589 QVBoxLayout *vbox = new QVBoxLayout(widget);
3590 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3591 if (path.isEmpty()) {
3592 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3593 if (baseClip == NULL) tmppath.append("untitled.mlt");
3595 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3597 path = KUrl(tmppath);
3599 KUrlRequester *url = new KUrlRequester(path, this);
3600 url->setFilter("video/mlt-playlist");
3601 QLabel *label2 = new QLabel(i18n("Description:"), this);
3602 KLineEdit *edit = new KLineEdit(this);
3603 vbox->addWidget(label1);
3604 vbox->addWidget(url);
3605 vbox->addWidget(label2);
3606 vbox->addWidget(edit);
3607 if (dialog->exec() == QDialog::Accepted) {
3608 if (QFile::exists(url->url().path())) {
3609 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3610 slotSaveZone(render, zone, baseClip, url->url());
3614 if (baseClip && !baseClip->fileURL().isEmpty()) {
3615 // create zone from clip url, so that we don't have problems with proxy clips
3617 #if QT_VERSION >= 0x040600
3618 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3619 env.remove("MLT_PROFILE");
3620 p.setProcessEnvironment(env);
3622 QStringList env = QProcess::systemEnvironment();
3623 env << "MLT_PROFILE='\0'";
3624 p.setEnvironment(env);
3626 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3627 if (!p.waitForStarted(3000)) {
3628 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3630 else if (!p.waitForFinished(5000)) {
3631 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3634 else render->saveZone(url->url(), edit->text(), zone);
3639 void MainWindow::slotSetInPoint()
3641 if (m_clipMonitor->isActive()) {
3642 m_clipMonitor->slotSetZoneStart();
3644 m_projectMonitor->slotSetZoneStart();
3648 void MainWindow::slotSetOutPoint()
3650 if (m_clipMonitor->isActive()) {
3651 m_clipMonitor->slotSetZoneEnd();
3653 m_projectMonitor->slotSetZoneEnd();
3657 void MainWindow::slotResizeItemStart()
3659 if (m_activeTimeline)
3660 m_activeTimeline->projectView()->setInPoint();
3663 void MainWindow::slotResizeItemEnd()
3665 if (m_activeTimeline)
3666 m_activeTimeline->projectView()->setOutPoint();
3669 int MainWindow::getNewStuff(const QString &configFile)
3671 KNS3::Entry::List entries;
3672 #if KDE_IS_VERSION(4,3,80)
3673 KNS3::DownloadDialog dialog(configFile);
3675 entries = dialog.changedEntries();
3676 foreach(const KNS3::Entry & entry, entries) {
3677 if (entry.status() == KNS3::Entry::Installed)
3678 kDebug() << "// Installed files: " << entry.installedFiles();
3681 KNS::Engine engine(0);
3682 if (engine.init(configFile))
3683 entries = engine.downloadDialogModal(this);
3684 foreach(KNS::Entry * entry, entries) {
3685 if (entry->status() == KNS::Entry::Installed)
3686 kDebug() << "// Installed files: " << entry->installedFiles();
3688 #endif /* KDE_IS_VERSION(4,3,80) */
3689 return entries.size();
3692 void MainWindow::slotGetNewTitleStuff()
3694 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3695 TitleWidget::refreshTitleTemplates();
3698 void MainWindow::slotGetNewLumaStuff()
3700 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3701 initEffects::refreshLumas();
3702 m_activeTimeline->projectView()->reloadTransitionLumas();
3706 void MainWindow::slotGetNewRenderStuff()
3708 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3710 m_renderWidget->reloadProfiles();
3713 void MainWindow::slotGetNewMltProfileStuff()
3715 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3716 // update the list of profiles in settings dialog
3717 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3723 void MainWindow::slotAutoTransition()
3725 if (m_activeTimeline)
3726 m_activeTimeline->projectView()->autoTransition();
3729 void MainWindow::slotSplitAudio()
3731 if (m_activeTimeline)
3732 m_activeTimeline->projectView()->splitAudio();
3735 void MainWindow::slotUpdateClipType(QAction *action)
3737 if (m_activeTimeline) {
3738 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3739 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3740 else m_activeTimeline->projectView()->setAudioAndVideo();
3744 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3746 // We must stop the monitors since we create a new on in the dvd wizard
3747 m_clipMonitor->stop();
3748 m_projectMonitor->stop();
3749 DvdWizard w(url, profile, this);
3751 m_projectMonitor->start();
3754 void MainWindow::slotShowTimeline(bool show)
3756 if (show == false) {
3757 m_timelineState = saveState();
3758 centralWidget()->setHidden(true);
3760 centralWidget()->setHidden(false);
3761 restoreState(m_timelineState);
3765 void MainWindow::slotMaximizeCurrent(bool)
3767 //TODO: is there a way to maximize current widget?
3769 m_timelineState = saveState();
3770 QWidget *par = focusWidget()->parentWidget();
3771 while (par->parentWidget() && par->parentWidget() != this)
3772 par = par->parentWidget();
3773 kDebug() << "CURRENT WIDGET: " << par->objectName();
3776 void MainWindow::loadTranscoders()
3778 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3781 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3782 KConfigGroup transConfig(config, "Transcoding");
3784 QMap< QString, QString > profiles = transConfig.entryMap();
3785 QMapIterator<QString, QString> i(profiles);
3786 while (i.hasNext()) {
3788 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3789 QAction *a = transMenu->addAction(i.key());
3791 if (data.count() > 1)
3792 a->setToolTip(data.at(1));
3793 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3797 void MainWindow::slotTranscode(KUrl::List urls)
3802 if (urls.isEmpty()) {
3803 QAction *action = qobject_cast<QAction *>(sender());
3804 QStringList data = action->data().toStringList();
3805 params = data.at(0);
3806 if (data.count() > 1) desc = data.at(1);
3807 if (data.count() > 2) condition = data.at(2);
3808 urls << m_projectList->getConditionalUrls(condition);
3809 urls.removeAll(KUrl());
3811 if (urls.isEmpty()) {
3812 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3815 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3816 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3818 //QProcess::startDetached("ffmpeg", parameters);
3821 void MainWindow::slotTranscodeClip()
3823 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3824 if (urls.isEmpty()) return;
3825 slotTranscode(urls);
3828 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3830 if (m_activeDocument == NULL) return;
3831 QMapIterator<QString, QString> i(props);
3832 while (i.hasNext()) {
3834 m_activeDocument->setDocumentProperty(i.key(), i.value());
3836 m_activeDocument->setModified(true);
3840 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3842 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3844 QString playlistPath;
3847 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3848 QString path = m_renderWidget->getFreeScriptName();
3849 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3850 if (!ok || scriptPath.isEmpty()) return;
3851 scriptPath.prepend(scriptsFolder);
3852 QFile f(scriptPath);
3854 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3857 playlistPath = scriptPath + ".mlt";
3859 KTemporaryFile temp;
3860 temp.setAutoRemove(false);
3861 temp.setSuffix(".mlt");
3863 playlistPath = temp.fileName();
3865 QString playlistContent = m_projectMonitor->sceneList();
3866 if (!chapterFile.isEmpty()) {
3869 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3871 in = m_activeTimeline->inPoint();
3872 out = m_activeTimeline->outPoint();
3875 QDomElement chapters = doc.createElement("chapters");
3876 chapters.setAttribute("fps", m_activeDocument->fps());
3877 doc.appendChild(chapters);
3879 QDomElement guidesxml = m_activeDocument->guidesXml();
3880 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3881 for (int i = 0; i < nodes.count(); i++) {
3882 QDomElement e = nodes.item(i).toElement();
3884 QString comment = e.attribute("comment");
3885 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3886 if (time >= in && time < out) {
3887 if (zoneOnly) time = time - in;
3888 QDomElement chapter = doc.createElement("chapter");
3889 chapters.appendChild(chapter);
3890 chapter.setAttribute("title", comment);
3891 chapter.setAttribute("time", time);
3895 if (chapters.childNodes().count() > 0) {
3896 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3897 // Always insert a guide in pos 0
3898 QDomElement chapter = doc.createElement("chapter");
3899 chapters.insertBefore(chapter, QDomNode());
3900 chapter.setAttribute("title", i18n("Start"));
3901 chapter.setAttribute("time", "0");
3903 // save chapters file
3904 QFile file(chapterFile);
3905 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3906 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3908 file.write(doc.toString().toUtf8());
3909 if (file.error() != QFile::NoError) {
3910 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3917 if (m_renderWidget->automaticAudioExport()) {
3918 exportAudio = m_activeTimeline->checkProjectAudio();
3919 } else exportAudio = m_renderWidget->selectedAudioExport();
3921 // Set playlist audio volume to 100%
3923 doc.setContent(playlistContent);
3924 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3925 if (!tractor.isNull()) {
3926 QDomNodeList props = tractor.elementsByTagName("property");
3927 for (int i = 0; i < props.count(); i++) {
3928 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3929 props.at(i).firstChild().setNodeValue("1");
3935 // Do we want proxy rendering
3936 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3937 QString root = doc.documentElement().attribute("root");
3939 // replace proxy clips with originals
3940 QMap <QString, QString> proxies = m_projectList->getProxies();
3942 QDomNodeList producers = doc.elementsByTagName("producer");
3943 QString producerResource;
3945 for (uint n = 0; n < producers.length(); n++) {
3946 QDomElement e = producers.item(n).toElement();
3947 producerResource = EffectsList::property(e, "resource");
3948 if (producerResource.isEmpty()) continue;
3949 if (!producerResource.startsWith("/")) {
3950 producerResource.prepend(root + "/");
3952 if (producerResource.contains('?')) {
3953 // slowmotion producer
3954 suffix = "?" + producerResource.section('?', 1);
3955 producerResource = producerResource.section('?', 0, 0);
3957 else suffix.clear();
3958 if (!producerResource.isEmpty()) {
3959 if (proxies.contains(producerResource)) {
3960 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3961 // We need to delete the "aspect_ratio" property because proxy clips
3962 // sometimes have different ratio than original clips
3963 EffectsList::removeProperty(e, "aspect_ratio");
3964 EffectsList::removeMetaProperties(e);
3969 /*QMapIterator<QString, QString> i(proxies);
3970 while (i.hasNext()) {
3972 // Replace all keys with their values (proxy path with original path)
3973 QString key = i.key();
3974 playlistContent.replace(key, i.value());
3975 if (!root.isEmpty() && key.startsWith(root)) {
3976 // in case the resource path in MLT playlist is relative
3977 key.remove(0, root.count() + 1);
3978 playlistContent.replace(key, i.value());
3982 playlistContent = doc.toString();
3984 // Do save scenelist
3985 QFile file(playlistPath);
3986 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3987 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3990 file.write(playlistContent.toUtf8());
3991 if (file.error() != QFile::NoError) {
3992 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3997 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
4000 void MainWindow::slotUpdateTimecodeFormat(int ix)
4002 KdenliveSettings::setFrametimecode(ix == 1);
4003 m_clipMonitor->updateTimecodeFormat();
4004 m_projectMonitor->updateTimecodeFormat();
4005 m_transitionConfig->updateTimecodeFormat();
4006 m_effectStack->updateTimecodeFormat();
4007 //m_activeTimeline->projectView()->clearSelection();
4008 m_activeTimeline->updateRuler();
4011 void MainWindow::slotRemoveFocus()
4013 statusBar()->setFocus();
4014 statusBar()->clearFocus();
4017 void MainWindow::slotRevert()
4019 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;
4020 KUrl url = m_activeDocument->url();
4021 if (closeCurrentDocument(false))
4022 doOpenFile(url, NULL);
4026 void MainWindow::slotShutdown()
4028 if (m_activeDocument) m_activeDocument->setModified(false);
4030 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4031 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4032 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4033 smserver.call("logout", 1, 2, 2);
4034 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4035 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4036 smserver.call("Shutdown");
4040 void MainWindow::slotUpdateTrackInfo()
4042 if (m_activeDocument)
4043 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4046 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4048 // Load the theme file
4050 if (action == NULL) theme = themename;
4051 else theme = action->data().toString();
4052 KdenliveSettings::setColortheme(theme);
4053 // Make palette for all widgets.
4054 QPalette plt = kapp->palette();
4055 if (theme.isEmpty()) {
4056 plt = QApplication::desktop()->palette();
4058 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4060 #if KDE_IS_VERSION(4,6,3)
4061 plt = KGlobalSettings::createNewApplicationPalette(config);
4063 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4064 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4065 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4066 QPalette::Disabled };
4067 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4068 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4070 for ( int i = 0; i < 3 ; i++ ) {
4071 QPalette::ColorGroup state = states[i];
4072 KColorScheme schemeView(state, KColorScheme::View, config);
4073 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4074 KColorScheme schemeButton(state, KColorScheme::Button, config);
4075 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4077 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4078 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4079 plt.setBrush( state, QPalette::Base, schemeView.background() );
4080 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4081 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4082 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4083 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4084 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4085 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4086 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4088 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4089 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4090 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4091 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4092 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4094 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4095 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4096 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4101 kapp->setPalette(plt);
4102 const QObjectList children = statusBar()->children();
4104 foreach(QObject * child, children) {
4105 if (child->isWidgetType())
4106 ((QWidget*)child)->setPalette(plt);
4107 const QObjectList subchildren = child->children();
4108 foreach(QObject * subchild, subchildren) {
4109 if (subchild->isWidgetType())
4110 ((QWidget*)subchild)->setPalette(plt);
4113 if (m_activeTimeline) {
4114 m_activeTimeline->projectView()->updatePalette();
4119 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4121 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4122 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4123 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4124 const QSize bitsSize(24, 2);
4125 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4126 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4128 QPixmap pixmap(23, 16);
4129 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4131 KConfigGroup group(config, "WM");
4132 QPainter p(&pixmap);
4133 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4134 p.fillRect(1, 1, 7, 7, windowScheme.background());
4135 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4137 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4138 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4139 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4141 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4142 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4144 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4145 p.fillRect(1, 8, 7, 7, viewScheme.background());
4146 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4148 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4149 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4150 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4152 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4153 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4159 void MainWindow::slotSwitchMonitors()
4161 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4162 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4163 else m_projectList->focusTree();
4166 void MainWindow::slotSwitchFullscreen()
4168 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4169 else m_clipMonitor->slotSwitchFullScreen();
4172 void MainWindow::slotInsertZoneToTree()
4174 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4175 QStringList info = m_clipMonitor->getZoneInfo();
4176 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4179 void MainWindow::slotInsertZoneToTimeline()
4181 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4182 QStringList info = m_clipMonitor->getZoneInfo();
4183 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4187 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4189 if (m_activeDocument && m_activeTimeline) {
4190 if (!ids.isEmpty()) {
4191 for (int i = 0; i < ids.size(); ++i) {
4192 m_activeTimeline->slotDeleteClip(ids.at(i));
4194 m_activeDocument->clipManager()->slotDeleteClips(ids);
4196 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4197 m_activeDocument->setModified(true);
4201 void MainWindow::slotShowTitleBars(bool show)
4203 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4204 for (int i = 0; i < docks.count(); i++) {
4205 QDockWidget* dock = docks.at(i);
4207 dock->setTitleBarWidget(0);
4209 if (!dock->isFloating()) {
4210 dock->setTitleBarWidget(new QWidget);
4214 KdenliveSettings::setShowtitlebars(show);
4217 void MainWindow::slotSwitchTitles()
4219 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4222 QString MainWindow::getMimeType(bool open)
4224 QString mimetype = "application/x-kdenlive";
4225 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4227 mimetype = "*.kdenlive";
4228 if (open) mimetype.append(" *.tar.gz");
4230 else if (open) mimetype.append(" application/x-compressed-tar");
4234 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4237 m_projectMonitor->render->sendFrameForAnalysis = true;
4240 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4241 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4248 qDebug() << "Any scope accepting new frames? " << request;
4251 m_projectMonitor->render->sendFrameForAnalysis = false;
4255 void MainWindow::slotUpdateGfxScopeFrameRequest()
4257 // We need a delay to make sure widgets are hidden after a close event for example
4258 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4261 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4264 bool request = false;
4265 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4266 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4267 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4273 if (!m_projectMonitor->effectSceneDisplayed()) {
4274 m_projectMonitor->render->sendFrameForAnalysis = false;
4276 m_clipMonitor->render->sendFrameForAnalysis = false;
4278 m_recMonitor->analyseFrames(false);
4280 m_projectMonitor->render->sendFrameForAnalysis = true;
4281 m_clipMonitor->render->sendFrameForAnalysis = true;
4283 m_recMonitor->analyseFrames(true);
4287 void MainWindow::slotUpdateAudioScopeFrameRequest()
4289 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4292 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4294 bool request = false;
4295 for (int i = 0; i < m_audioScopesList.count(); i++) {
4296 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4297 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4302 // Handle audio signal separately (no common interface)
4303 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4304 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4308 qDebug() << "Scopes Requesting Audio data: " << request;
4310 KdenliveSettings::setMonitor_audio(request);
4311 m_monitorManager->slotUpdateAudioMonitoring();
4314 void MainWindow::slotUpdateColorScopes()
4316 bool request = false;
4317 kDebug()<<"// UPDATE SCOPES";
4318 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4319 // Check if we need the renderer to send a new frame for update
4320 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4321 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4323 if (request && m_monitorManager->activeRenderer()) {
4324 m_monitorManager->activeRenderer()->sendFrameUpdate();
4328 void MainWindow::slotClearColorScopes()
4330 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4331 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4335 void MainWindow::slotOpenStopmotion()
4337 if (m_stopmotion == NULL) {
4338 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4339 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4340 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4341 // Check if we need the renderer to send a new frame for update
4342 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4343 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4344 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4347 m_stopmotion->show();
4350 void MainWindow::slotDeleteClip(const QString &id)
4352 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4353 for (int i = 0; i < list.size(); ++i) {
4354 list.at(i)->disableClipId(id);
4356 m_projectList->slotDeleteClip(id);
4359 void MainWindow::slotUpdateProxySettings()
4361 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4362 if (KdenliveSettings::enableproxy())
4363 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4364 m_projectList->updateProxyConfig();
4367 void MainWindow::slotInsertNotesTimecode()
4369 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4370 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4371 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4374 void MainWindow::slotArchiveProject()
4376 QList <DocClipBase*> list = m_projectList->documentClipList();
4377 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4378 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4383 void MainWindow::slotOpenBackupDialog(const KUrl url)
4388 kDebug()<<"// BACKUP URL: "<<url.path();
4389 if (!url.isEmpty()) {
4390 // we could not open the project file, guess where the backups are
4391 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4395 projectFolder = m_activeDocument->projectFolder();
4396 projectFile = m_activeDocument->url();
4397 projectId = m_activeDocument->getDocumentProperty("documentid");
4400 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4401 if (dia->exec() == QDialog::Accepted) {
4402 QString requestedBackup = dia->selectedFile();
4403 m_activeDocument->backupLastSavedVersion(projectFile.path());
4404 closeCurrentDocument(false);
4405 doOpenFile(KUrl(requestedBackup), NULL);
4406 m_activeDocument->setUrl(projectFile);
4407 m_activeDocument->setModified(true);
4408 setCaption(m_activeDocument->description());
4413 void MainWindow::slotElapsedTime()
4415 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4418 #include "mainwindow.moc"