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"
48 #include "clipproperties.h"
50 #include "commands/editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "config-kdenlive.h"
56 #include "cliptranscode.h"
57 #include "clipstabilize.h"
58 #include "ui_templateclip_ui.h"
59 #include "colorscopes/vectorscope.h"
60 #include "colorscopes/waveform.h"
61 #include "colorscopes/rgbparade.h"
62 #include "colorscopes/histogram.h"
63 #include "audioscopes/audiospectrum.h"
64 #include "audioscopes/spectrogram.h"
65 #include "archivewidget.h"
66 #include "databackup/backupwidget.h"
69 #include <KApplication>
73 #include <KActionCollection>
74 #include <KActionCategory>
75 #include <KStandardAction>
76 #include <KShortcutsDialog>
77 #include <KFileDialog>
78 #include <KMessageBox>
80 #include <KIO/NetAccess>
83 #include <KConfigDialog>
84 #include <KXMLGUIFactory>
86 #include <kstandarddirs.h>
87 #include <KUrlRequesterDialog>
88 #include <KTemporaryFile>
90 #include <KActionMenu>
92 #include <ktogglefullscreenaction.h>
94 #include <KNotification>
95 #include <KNotifyConfigWidget>
96 #if KDE_IS_VERSION(4,3,80)
97 #include <knewstuff3/downloaddialog.h>
98 #include <knewstuff3/knewstuffaction.h>
100 #include <knewstuff2/engine.h>
101 #include <knewstuff2/ui/knewstuffaction.h>
105 #include <KColorScheme>
106 #include <KProgressDialog>
108 #include <QTextStream>
112 #include <QInputDialog>
113 #include <QDesktopWidget>
119 // Uncomment for deeper debugging
120 //#define DEBUG_MAINW
126 static const char version[] = VERSION;
128 static const int ID_TIMELINE_POS = 0;
134 Q_DECLARE_METATYPE(QVector<int16_t>)
137 EffectsList MainWindow::videoEffects;
138 EffectsList MainWindow::audioEffects;
139 EffectsList MainWindow::customEffects;
140 EffectsList MainWindow::transitions;
142 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
143 KXmlGuiWindow(parent),
144 m_activeDocument(NULL),
145 m_activeTimeline(NULL),
147 m_renderWidget(NULL),
148 #ifdef USE_JOGSHUTTLE
152 m_findActivated(false),
155 qRegisterMetaType<QVector<int16_t> > ();
156 qRegisterMetaType<stringMap> ("stringMap");
157 qRegisterMetaType<audioByteArray> ("audioByteArray");
160 QLocale systemLocale = QLocale();
161 setlocale(LC_NUMERIC, NULL);
162 char *separator = localeconv()->decimal_point;
163 if (separator != systemLocale.decimalPoint()) {
164 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
165 // HACK: There is a locale conflict, so set locale to at least have correct decimal point
166 if (strncmp(separator, ".", 1) == 0) systemLocale = QLocale::c();
167 else if (strncmp(separator, ",", 1) == 0) systemLocale = QLocale("fr_FR.UTF-8");
170 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
171 QLocale::setDefault(systemLocale);
173 // Create DBus interface
174 new MainWindowAdaptor(this);
175 QDBusConnection dbus = QDBusConnection::sessionBus();
176 dbus.registerObject("/MainWindow", this);
178 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
179 setFont(KGlobalSettings::toolBarFont());
180 parseProfiles(MltPath);
181 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
182 m_commandStack = new QUndoGroup;
183 setDockNestingEnabled(true);
184 m_timelineArea = new KTabWidget(this);
185 m_timelineArea->setTabReorderingEnabled(true);
186 m_timelineArea->setTabBarHidden(true);
187 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
188 m_timelineArea->setMinimumHeight(200);
190 QToolButton *closeTabButton = new QToolButton;
191 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
192 closeTabButton->setIcon(KIcon("tab-close"));
193 closeTabButton->adjustSize();
194 closeTabButton->setToolTip(i18n("Close the current tab"));
195 m_timelineArea->setCornerWidget(closeTabButton);
196 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
198 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
199 m_findTimer.setSingleShot(true);
201 // FIXME: the next call returns a newly allocated object, which leaks
202 initEffects::parseEffectFiles();
203 //initEffects::parseCustomEffectsFile();
205 m_monitorManager = new MonitorManager();
207 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
208 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
213 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
214 m_projectListDock->setObjectName("project_tree");
215 m_projectList = new ProjectList();
216 m_projectListDock->setWidget(m_projectList);
217 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
219 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
220 m_clipMonitorDock->setObjectName("clip_monitor");
221 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
222 m_clipMonitorDock->setWidget(m_clipMonitor);
224 // Connect the project list
225 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
226 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
227 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
228 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
229 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
230 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
231 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
232 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
233 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
234 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
236 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
237 m_projectMonitorDock->setObjectName("project_monitor");
238 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
239 m_projectMonitorDock->setWidget(m_projectMonitor);
242 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
243 m_recMonitorDock->setObjectName("record_monitor");
244 m_recMonitor = new RecMonitor("record", m_monitorManager);
245 m_recMonitorDock->setWidget(m_recMonitor);
246 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
247 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
248 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
249 #endif /* ! Q_WS_MAC */
250 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
252 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
253 m_notesDock->setObjectName("notes_widget");
254 m_notesWidget = new NotesWidget();
255 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
256 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
258 m_notesWidget->setTabChangesFocus(true);
259 #if KDE_IS_VERSION(4,4,0)
260 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
262 m_notesDock->setWidget(m_notesWidget);
263 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
265 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
266 m_effectStackDock->setObjectName("effect_stack");
267 m_effectStack = new EffectStackView(m_projectMonitor);
268 m_effectStackDock->setWidget(m_effectStack);
269 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
271 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
272 m_transitionConfigDock->setObjectName("transition");
273 m_transitionConfig = new TransitionSettings(m_projectMonitor);
274 m_transitionConfigDock->setWidget(m_transitionConfig);
275 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
277 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
278 m_effectListDock->setObjectName("effect_list");
279 m_effectList = new EffectsListView();
280 m_effectListDock->setWidget(m_effectList);
281 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
283 m_vectorscope = new Vectorscope(m_monitorManager);
284 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
285 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
286 m_vectorscopeDock->setWidget(m_vectorscope);
287 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
288 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
289 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
290 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
291 m_gfxScopesList.append(m_vectorscopeDock);
293 m_waveform = new Waveform(m_monitorManager);
294 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
295 m_waveformDock->setObjectName(m_waveform->widgetName());
296 m_waveformDock->setWidget(m_waveform);
297 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
298 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
299 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
300 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
301 m_gfxScopesList.append(m_waveformDock);
303 m_RGBParade = new RGBParade(m_monitorManager);
304 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
305 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
306 m_RGBParadeDock->setWidget(m_RGBParade);
307 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
308 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
309 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
310 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
311 m_gfxScopesList.append(m_RGBParadeDock);
313 m_histogram = new Histogram(m_monitorManager);
314 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
315 m_histogramDock->setObjectName(m_histogram->widgetName());
316 m_histogramDock->setWidget(m_histogram);
317 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
318 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
319 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
320 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
321 m_gfxScopesList.append(m_histogramDock);
324 m_audiosignal = new AudioSignal;
325 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
326 m_audiosignalDock->setObjectName("audiosignal");
327 m_audiosignalDock->setWidget(m_audiosignal);
328 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
329 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
330 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
332 m_audioSpectrum = new AudioSpectrum();
333 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
334 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
335 m_audioSpectrumDock->setWidget(m_audioSpectrum);
336 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
337 m_audioScopesList.append(m_audioSpectrum);
338 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
339 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
341 m_spectrogram = new Spectrogram();
342 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
343 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
344 m_spectrogramDock->setWidget(m_spectrogram);
345 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
346 m_audioScopesList.append(m_spectrogram);
347 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
348 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
350 // Connect the audio signal to the audio scope slots
352 if (m_projectMonitor) {
353 qDebug() << "project monitor connected";
354 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
355 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
356 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
357 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
358 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
359 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
362 qDebug() << "clip monitor connected";
363 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
364 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
365 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
366 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
367 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
368 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
370 // Ensure connections were set up correctly
375 // Add monitors here to keep them at the right of the window
376 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
377 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
379 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
382 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
383 m_undoViewDock->setObjectName("undo_history");
384 m_undoView = new QUndoView();
385 m_undoView->setCleanIcon(KIcon("edit-clear"));
386 m_undoView->setEmptyLabel(i18n("Clean"));
387 m_undoViewDock->setWidget(m_undoView);
388 m_undoView->setGroup(m_commandStack);
389 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
393 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
396 // Close non-general docks for the initial layout
397 // only show important ones
398 m_histogramDock->close();
399 m_RGBParadeDock->close();
400 m_waveformDock->close();
401 m_vectorscopeDock->close();
403 m_audioSpectrumDock->close();
404 m_spectrogramDock->close();
405 m_audiosignalDock->close();
407 m_undoViewDock->close();
411 /// Tabify Widgets ///
412 tabifyDockWidget(m_effectListDock, m_effectStackDock);
413 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
414 tabifyDockWidget(m_projectListDock, m_notesDock);
416 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
418 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
424 setCentralWidget(m_timelineArea);
427 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
429 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
430 m_fileRevert->setEnabled(false);
432 // Prepare layout actions
433 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
434 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
435 for (int i = 1; i < 5; i++) {
436 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
437 load->setData("_" + QString::number(i));
438 layoutActions->addAction("load_layout" + QString::number(i), load);
439 m_loadLayout->addAction(load);
440 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
441 save->setData("_" + QString::number(i));
442 layoutActions->addAction("save_layout" + QString::number(i), save);
444 layoutActions->addAction("load_layouts", m_loadLayout);
445 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
448 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
449 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
450 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
451 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
452 m_stopmotion_actions->addAction("stopmotion_capture", action);
453 action = new KAction(i18n("Switch live / captured frame"), this);
454 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
455 m_stopmotion_actions->addAction("stopmotion_switch", action);
456 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
457 action->setCheckable(true);
458 action->setChecked(false);
459 m_stopmotion_actions->addAction("stopmotion_overlay", action);
461 // Build effects menu
462 m_effectsMenu = new QMenu(i18n("Add Effect"));
463 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
464 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
465 m_effectsActionCollection->readSettings();
469 // Find QDockWidget tab bars and show / hide widget title bars on right click
470 QList <QTabBar *> tabs = findChildren<QTabBar *>();
471 for (int i = 0; i < tabs.count(); i++) {
472 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
473 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
476 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
477 guiFactory()->addClient(sp);*/
479 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
481 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
484 // Load layout names from config file
491 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
492 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
494 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
495 clipInTimeline->setIcon(KIcon("go-jump"));
496 QHash<QString,QMenu*> menus;
497 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
498 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
499 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
500 menus.insert("inTimelineMenu",clipInTimeline);
501 m_projectList->setupGeneratorMenu(menus);
503 // build themes menus
504 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
505 QActionGroup *themegroup = new QActionGroup(this);
506 themegroup->setExclusive(true);
507 action = new KAction(i18n("Default"), this);
508 action->setCheckable(true);
509 themegroup->addAction(action);
510 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
512 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
514 for (int i = 0; i < schemeFiles.size(); ++i) {
516 const QString filename = schemeFiles.at(i);
517 const QFileInfo info(filename);
520 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
521 QIcon icon = createSchemePreviewIcon(config);
522 KConfigGroup group(config, "General");
523 const QString name = group.readEntry("Name", info.baseName());
524 action = new KAction(name, this);
525 action->setData(filename);
526 action->setIcon(icon);
527 action->setCheckable(true);
528 themegroup->addAction(action);
529 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
532 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
533 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
534 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
537 action = new QAction(fi.fileName(), this);
538 action->setData(*it);
539 action->setCheckable(true);
540 themegroup->addAction(action);
541 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
543 themesMenu->addActions(themegroup->actions());
544 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
546 // Setup and fill effects and transitions menus.
549 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
550 m->addActions(m_effectsMenu->actions());
553 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
554 for (int i = 0; i < transitions.count(); ++i)
555 m_transitionsMenu->addAction(m_transitions[i]);
557 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
558 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
559 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
561 m_effectStack->setMenu(m_effectsMenu);
563 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
564 const QList<QAction *> viewActions = createPopupMenu()->actions();
565 viewMenu->insertActions(NULL, viewActions);
567 m_timelineContextMenu = new QMenu(this);
568 m_timelineContextClipMenu = new QMenu(this);
569 m_timelineContextTransitionMenu = new QMenu(this);
571 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
572 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
573 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
575 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
576 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
577 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
578 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
579 m_timelineContextClipMenu->addSeparator();
580 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
581 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
582 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
583 m_timelineContextClipMenu->addSeparator();
584 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
585 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
586 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
587 m_timelineContextClipMenu->addSeparator();
589 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
590 m_timelineContextClipMenu->addMenu(markersMenu);
591 m_timelineContextClipMenu->addSeparator();
592 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
593 m_timelineContextClipMenu->addMenu(m_effectsMenu);
595 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
596 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
597 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
599 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
601 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
602 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
603 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
604 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
605 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
606 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
608 slotConnectMonitors();
610 // Open or create a file. Command line argument passed in Url has
611 // precedence, then "openlastproject", then just a plain empty file.
612 // If opening Url fails, openlastproject will _not_ be used.
613 if (!Url.isEmpty()) {
614 // delay loading so that the window shows up
616 QTimer::singleShot(500, this, SLOT(openFile()));
617 } else if (KdenliveSettings::openlastproject()) {
618 QTimer::singleShot(500, this, SLOT(openLastFile()));
619 } else { //if (m_timelineArea->count() == 0) {
623 if (!clipsToLoad.isEmpty() && m_activeDocument) {
624 QStringList list = clipsToLoad.split(',');
626 foreach(QString path, list) {
627 kDebug() << QDir::current().absoluteFilePath(path);
628 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
630 m_projectList->slotAddClip(urls);
633 #ifdef USE_JOGSHUTTLE
634 activateShuttleDevice();
636 m_projectListDock->raise();
638 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
639 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
641 // Populate encoding profiles
642 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
643 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
644 KConfigGroup group(&conf, "proxy");
645 QMap< QString, QString > values = group.entryMap();
646 QMapIterator<QString, QString> i(values);
649 QString data = i.value();
650 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
651 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
654 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
655 KConfigGroup group(&conf, "video4linux");
656 QMap< QString, QString > values = group.entryMap();
657 QMapIterator<QString, QString> i(values);
660 QString data = i.value();
661 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
662 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
665 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
666 KConfigGroup group(&conf, "decklink");
667 QMap< QString, QString > values = group.entryMap();
668 QMapIterator<QString, QString> i(values);
671 QString data = i.value();
672 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
673 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
678 MainWindow::~MainWindow()
683 m_effectStack->slotClipItemSelected(NULL, 0);
684 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
686 if (m_projectMonitor) m_projectMonitor->stop();
687 if (m_clipMonitor) m_clipMonitor->stop();
689 delete m_activeTimeline;
690 delete m_effectStack;
691 delete m_transitionConfig;
692 delete m_activeDocument;
693 delete m_projectMonitor;
694 delete m_clipMonitor;
695 delete m_shortcutRemoveFocus;
696 delete[] m_transitions;
697 Mlt::Factory::close();
701 bool MainWindow::queryClose()
703 if (m_renderWidget) {
704 int waitingJobs = m_renderWidget->waitingJobsCount();
705 if (waitingJobs > 0) {
706 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")))) {
707 case KMessageBox::Yes :
708 // create script with waiting jobs and start it
709 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
711 case KMessageBox::No :
712 // Don't do anything, jobs will be deleted
720 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
721 // warn the user to save if document is modified and we have clips in our project list
722 if (m_activeDocument && m_activeDocument->isModified() &&
723 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
724 !m_projectList->documentClipList().isEmpty())) {
728 if (m_activeDocument->url().fileName().isEmpty())
729 message = i18n("Save changes to document?");
731 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
732 switch (KMessageBox::warningYesNoCancel(this, message)) {
733 case KMessageBox::Yes :
734 // save document here. If saving fails, return false;
736 case KMessageBox::No :
737 // User does not want to save the changes, clear recovery files
738 m_activeDocument->m_autosave->resize(0);
747 void MainWindow::loadPlugins()
749 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
750 populateMenus(plugin);
753 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
755 filters << "libkdenlive*";
756 foreach(const QString & folder, directories) {
757 kDebug() << "Parsing plugin folder: " << folder;
758 QDir pluginsDir(folder);
759 foreach(const QString & fileName,
760 pluginsDir.entryList(filters, QDir::Files)) {
762 * Avoid loading the same plugin twice when there is more than one
765 if (!m_pluginFileNames.contains(fileName)) {
766 kDebug() << "Found plugin: " << fileName;
767 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
768 QObject *plugin = loader.instance();
770 populateMenus(plugin);
771 m_pluginFileNames += fileName;
773 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
779 void MainWindow::populateMenus(QObject *plugin)
781 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
782 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
784 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
788 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
789 QMenu *menu, const char *member,
790 QActionGroup *actionGroup)
792 kDebug() << "// ADD to MENU" << texts;
793 foreach(const QString & text, texts) {
794 QAction *action = new QAction(text, plugin);
795 action->setData(text);
796 connect(action, SIGNAL(triggered()), this, member);
797 menu->addAction(action);
800 action->setCheckable(true);
801 actionGroup->addAction(action);
806 void MainWindow::aboutPlugins()
808 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
813 void MainWindow::generateClip()
815 QAction *action = qobject_cast<QAction *>(sender());
816 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
818 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
819 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
820 if (!clipUrl.isEmpty()) {
821 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
825 void MainWindow::saveProperties(KConfigGroup &config)
827 // save properties here,used by session management
829 KMainWindow::saveProperties(config);
833 void MainWindow::readProperties(const KConfigGroup &config)
835 // read properties here,used by session management
836 KMainWindow::readProperties(config);
837 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
838 openFile(KUrl(Lastproject));
841 void MainWindow::slotReloadEffects()
843 initEffects::parseCustomEffectsFile();
844 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
847 #ifdef USE_JOGSHUTTLE
848 void MainWindow::activateShuttleDevice()
854 if (KdenliveSettings::enableshuttle() == false) return;
856 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
857 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
859 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
860 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
861 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
862 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
863 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
865 #endif /* USE_JOGSHUTTLE */
867 void MainWindow::slotDoAction(const QString& action_name)
869 QAction* action = actionCollection()->action(action_name);
871 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
877 void MainWindow::configureNotifications()
879 KNotifyConfigWidget::configure(this);
882 void MainWindow::slotFullScreen()
884 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
887 void MainWindow::slotAddEffect(const QDomElement effect)
889 if (!m_activeDocument) return;
890 if (effect.isNull()) {
891 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
894 QDomElement effectToAdd = effect.cloneNode().toElement();
896 int ix = m_effectStack->isTrackMode(&ok);
897 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
898 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
901 void MainWindow::slotUpdateClip(const QString &id)
903 if (!m_activeDocument) return;
904 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
906 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
907 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
908 Mlt::Producer *monitorProducer = clip->getCloneProducer();
909 m_clipMonitor->updateClipProducer(monitorProducer);
911 clip->cleanupProducers();
914 void MainWindow::slotConnectMonitors()
916 m_projectList->setRenderer(m_projectMonitor->render);
917 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
918 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
919 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
920 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
921 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
922 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)));
924 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
926 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
928 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
930 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
931 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
933 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
935 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
936 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
939 void MainWindow::slotAdjustClipMonitor()
941 m_clipMonitorDock->updateGeometry();
942 m_clipMonitorDock->adjustSize();
943 m_clipMonitor->resetSize();
946 void MainWindow::slotAdjustProjectMonitor()
948 m_projectMonitorDock->updateGeometry();
949 m_projectMonitorDock->adjustSize();
950 m_projectMonitor->resetSize();
954 class NameGrabbingKActionCollection {
956 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
957 : m_collection(collection), m_action_names(action_names) {
958 m_action_names.clear();
960 KAction* addAction(const QString& action_name) {
961 m_action_names << action_name;
962 return m_collection->addAction(action_name);
964 void addAction(const QString& action_name, QAction* action) {
965 m_action_names << action_name;
966 m_collection->addAction(action_name, action);
968 operator KActionCollection*() { return m_collection; }
969 const QStringList& actionNames() const { return m_action_names; }
971 KActionCollection* m_collection;
972 QStringList& m_action_names;
975 void MainWindow::setupActions()
978 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
979 m_timecodeFormat = new KComboBox(this);
980 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
981 m_timecodeFormat->addItem(i18n("Frames"));
982 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
983 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
985 m_statusProgressBar = new QProgressBar(this);
986 m_statusProgressBar->setMinimum(0);
987 m_statusProgressBar->setMaximum(100);
988 m_statusProgressBar->setMaximumWidth(150);
989 m_statusProgressBar->setVisible(false);
991 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
992 toolbar->setMovable(false);
993 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
994 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
995 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
996 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
997 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
998 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());
999 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
1001 //create edit mode buttons
1002 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
1003 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
1004 toolbar->addAction(m_normalEditTool);
1005 m_normalEditTool->setCheckable(true);
1006 m_normalEditTool->setChecked(true);
1008 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
1009 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
1010 toolbar->addAction(m_overwriteEditTool);
1011 m_overwriteEditTool->setCheckable(true);
1012 m_overwriteEditTool->setChecked(false);
1014 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
1015 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
1016 toolbar->addAction(m_insertEditTool);
1017 m_insertEditTool->setCheckable(true);
1018 m_insertEditTool->setChecked(false);
1019 // not implemented yet
1020 m_insertEditTool->setEnabled(false);
1022 QActionGroup *editGroup = new QActionGroup(this);
1023 editGroup->addAction(m_normalEditTool);
1024 editGroup->addAction(m_overwriteEditTool);
1025 editGroup->addAction(m_insertEditTool);
1026 editGroup->setExclusive(true);
1027 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
1028 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1030 toolbar->addSeparator();
1032 // create tools buttons
1033 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1034 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1035 toolbar->addAction(m_buttonSelectTool);
1036 m_buttonSelectTool->setCheckable(true);
1037 m_buttonSelectTool->setChecked(true);
1039 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1040 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1041 toolbar->addAction(m_buttonRazorTool);
1042 m_buttonRazorTool->setCheckable(true);
1043 m_buttonRazorTool->setChecked(false);
1045 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1046 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1047 toolbar->addAction(m_buttonSpacerTool);
1048 m_buttonSpacerTool->setCheckable(true);
1049 m_buttonSpacerTool->setChecked(false);
1051 QActionGroup *toolGroup = new QActionGroup(this);
1052 toolGroup->addAction(m_buttonSelectTool);
1053 toolGroup->addAction(m_buttonRazorTool);
1054 toolGroup->addAction(m_buttonSpacerTool);
1055 toolGroup->setExclusive(true);
1056 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1058 QWidget * actionWidget;
1059 int max = toolbar->iconSizeDefault() + 2;
1060 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1061 actionWidget->setMaximumWidth(max);
1062 actionWidget->setMaximumHeight(max - 4);
1064 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1065 actionWidget->setMaximumWidth(max);
1066 actionWidget->setMaximumHeight(max - 4);
1068 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1069 actionWidget->setMaximumWidth(max);
1070 actionWidget->setMaximumHeight(max - 4);
1072 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1073 actionWidget->setMaximumWidth(max);
1074 actionWidget->setMaximumHeight(max - 4);
1076 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1077 actionWidget->setMaximumWidth(max);
1078 actionWidget->setMaximumHeight(max - 4);
1080 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1081 actionWidget->setMaximumWidth(max);
1082 actionWidget->setMaximumHeight(max - 4);
1084 toolbar->setStyleSheet(style1);
1085 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1087 toolbar->addSeparator();
1088 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1089 toolbar->addAction(m_buttonFitZoom);
1090 m_buttonFitZoom->setCheckable(false);
1092 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1093 toolbar->addAction(m_zoomOut);
1094 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1096 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1097 m_zoomSlider->setMaximum(13);
1098 m_zoomSlider->setPageStep(1);
1099 m_zoomSlider->setInvertedAppearance(true);
1101 m_zoomSlider->setMaximumWidth(150);
1102 m_zoomSlider->setMinimumWidth(100);
1103 toolbar->addWidget(m_zoomSlider);
1105 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1106 toolbar->addAction(m_zoomIn);
1107 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1109 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1110 actionWidget->setMaximumWidth(max);
1111 actionWidget->setMaximumHeight(max - 4);
1112 actionWidget->setStyleSheet(styleBorderless);
1114 actionWidget = toolbar->widgetForAction(m_zoomIn);
1115 actionWidget->setMaximumWidth(max);
1116 actionWidget->setMaximumHeight(max - 4);
1117 actionWidget->setStyleSheet(styleBorderless);
1119 actionWidget = toolbar->widgetForAction(m_zoomOut);
1120 actionWidget->setMaximumWidth(max);
1121 actionWidget->setMaximumHeight(max - 4);
1122 actionWidget->setStyleSheet(styleBorderless);
1124 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1125 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1126 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1127 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1128 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1130 toolbar->addSeparator();
1132 //create automatic audio split button
1133 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1134 toolbar->addAction(m_buttonAutomaticSplitAudio);
1135 m_buttonAutomaticSplitAudio->setCheckable(true);
1136 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1137 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1139 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1140 toolbar->addAction(m_buttonVideoThumbs);
1141 m_buttonVideoThumbs->setCheckable(true);
1142 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1143 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1145 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1146 toolbar->addAction(m_buttonAudioThumbs);
1147 m_buttonAudioThumbs->setCheckable(true);
1148 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1149 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1151 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1152 toolbar->addAction(m_buttonShowMarkers);
1153 m_buttonShowMarkers->setCheckable(true);
1154 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1155 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1157 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1158 toolbar->addAction(m_buttonSnap);
1159 m_buttonSnap->setCheckable(true);
1160 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1161 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1163 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1164 actionWidget->setMaximumWidth(max);
1165 actionWidget->setMaximumHeight(max - 4);
1167 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1168 actionWidget->setMaximumWidth(max);
1169 actionWidget->setMaximumHeight(max - 4);
1171 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1172 actionWidget->setMaximumWidth(max);
1173 actionWidget->setMaximumHeight(max - 4);
1175 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1176 actionWidget->setMaximumWidth(max);
1177 actionWidget->setMaximumHeight(max - 4);
1179 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1180 actionWidget->setMaximumWidth(max);
1181 actionWidget->setMaximumHeight(max - 4);
1183 m_messageLabel = new StatusBarMessageLabel(this);
1184 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1186 statusBar()->addWidget(m_messageLabel, 10);
1187 statusBar()->addWidget(m_statusProgressBar, 0);
1188 statusBar()->addPermanentWidget(toolbar);
1189 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1190 statusBar()->addPermanentWidget(m_timecodeFormat);
1191 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1193 collection.addAction("normal_mode", m_normalEditTool);
1194 collection.addAction("overwrite_mode", m_overwriteEditTool);
1195 collection.addAction("insert_mode", m_insertEditTool);
1196 collection.addAction("select_tool", m_buttonSelectTool);
1197 collection.addAction("razor_tool", m_buttonRazorTool);
1198 collection.addAction("spacer_tool", m_buttonSpacerTool);
1200 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1201 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1202 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1203 collection.addAction("show_markers", m_buttonShowMarkers);
1204 collection.addAction("snap", m_buttonSnap);
1205 collection.addAction("zoom_fit", m_buttonFitZoom);
1206 collection.addAction("zoom_in", m_zoomIn);
1207 collection.addAction("zoom_out", m_zoomOut);
1209 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1210 collection.addAction("project_find", m_projectSearch);
1211 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1212 m_projectSearch->setShortcut(Qt::Key_Slash);
1214 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1215 collection.addAction("project_find_next", m_projectSearchNext);
1216 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1217 m_projectSearchNext->setShortcut(Qt::Key_F3);
1218 m_projectSearchNext->setEnabled(false);
1220 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1221 collection.addAction("manage_profiles", profilesAction);
1222 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1224 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1225 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1226 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1227 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1229 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1230 collection.addAction("run_wizard", wizAction);
1231 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1233 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1234 collection.addAction("project_settings", projectAction);
1235 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1237 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1238 collection.addAction("open_backup", backupAction);
1239 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1241 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1242 collection.addAction("project_render", projectRender);
1243 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1244 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1246 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1247 collection.addAction("project_clean", projectClean);
1248 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1250 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1251 collection.addAction("project_adjust_profile", projectAdjust);
1252 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1254 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1255 KShortcut playShortcut;
1256 playShortcut.setPrimary(Qt::Key_Space);
1257 playShortcut.setAlternate(Qt::Key_K);
1258 monitorPlay->setShortcut(playShortcut);
1259 collection.addAction("monitor_play", monitorPlay);
1260 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1262 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1263 collection.addAction("monitor_pause", monitorPause);
1264 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1266 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1267 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1268 collection.addAction("monitor_play_zone", m_playZone);
1269 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1271 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1272 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1273 collection.addAction("monitor_loop_zone", m_loopZone);
1274 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1276 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1277 m_loopClip->setEnabled(false);
1278 collection.addAction("monitor_loop_clip", m_loopClip);
1279 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1281 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1282 collection.addAction("dvd_wizard", dvdWizard);
1283 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1285 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1286 collection.addAction("transcode_clip", transcodeClip);
1287 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1289 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1290 collection.addAction("archive_project", archiveProject);
1291 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1294 KAction *markIn = collection.addAction("mark_in");
1295 markIn->setText(i18n("Set Zone In"));
1296 markIn->setShortcut(Qt::Key_I);
1297 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1299 KAction *markOut = collection.addAction("mark_out");
1300 markOut->setText(i18n("Set Zone Out"));
1301 markOut->setShortcut(Qt::Key_O);
1302 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1304 KAction *switchMon = collection.addAction("switch_monitor");
1305 switchMon->setText(i18n("Switch monitor"));
1306 switchMon->setShortcut(Qt::Key_T);
1307 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1309 KAction *fullMon = collection.addAction("monitor_fullscreen");
1310 fullMon->setText(i18n("Switch monitor fullscreen"));
1311 fullMon->setIcon(KIcon("view-fullscreen"));
1312 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1314 KAction *insertTree = collection.addAction("insert_project_tree");
1315 insertTree->setText(i18n("Insert zone in project tree"));
1316 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1317 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1319 KAction *insertTimeline = collection.addAction("insert_timeline");
1320 insertTimeline->setText(i18n("Insert zone in timeline"));
1321 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1322 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1324 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1325 collection.addAction("resize_timeline_clip_start", resizeStart);
1326 resizeStart->setShortcut(Qt::Key_1);
1327 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1329 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1330 collection.addAction("resize_timeline_clip_end", resizeEnd);
1331 resizeEnd->setShortcut(Qt::Key_2);
1332 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1334 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1335 monitorSeekBackward->setShortcut(Qt::Key_J);
1336 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1337 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1339 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1340 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1341 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1342 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1344 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1345 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1346 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1347 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1349 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1350 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1351 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1352 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1354 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1355 monitorSeekForward->setShortcut(Qt::Key_L);
1356 collection.addAction("monitor_seek_forward", monitorSeekForward);
1357 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1359 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1360 clipStart->setShortcut(Qt::Key_Home);
1361 collection.addAction("seek_clip_start", clipStart);
1362 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1364 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1365 clipEnd->setShortcut(Qt::Key_End);
1366 collection.addAction("seek_clip_end", clipEnd);
1367 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1369 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1370 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1371 collection.addAction("seek_zone_start", zoneStart);
1372 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1374 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1375 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1376 collection.addAction("seek_zone_end", zoneEnd);
1377 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1379 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1380 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1381 collection.addAction("seek_start", projectStart);
1382 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1384 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1385 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1386 collection.addAction("seek_end", projectEnd);
1387 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1389 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1390 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1391 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1392 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1394 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1395 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1396 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1397 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1399 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1400 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1401 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1402 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1404 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1405 deleteItem->setShortcut(Qt::Key_Delete);
1406 collection.addAction("delete_timeline_clip", deleteItem);
1407 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1409 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1410 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1411 editTimelineClipSpeed->setData("change_speed");
1412 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1414 KAction *stickTransition = collection.addAction("auto_transition");
1415 stickTransition->setData(QString("auto"));
1416 stickTransition->setCheckable(true);
1417 stickTransition->setEnabled(false);
1418 stickTransition->setText(i18n("Automatic Transition"));
1419 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1421 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1422 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1423 collection.addAction("group_clip", groupClip);
1424 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1426 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1427 collection.addAction("ungroup_clip", ungroupClip);
1428 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1429 ungroupClip->setData("ungroup_clip");
1430 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1432 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1433 collection.addAction("edit_item_duration", editItemDuration);
1434 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1436 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1437 collection.addAction("clip_in_project_tree", clipInProjectTree);
1438 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1440 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1441 collection.addAction("clip_to_project_tree", clipToProjectTree);
1442 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1444 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1445 insertOvertwrite->setShortcut(Qt::Key_V);
1446 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1447 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1449 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1450 selectTimelineClip->setShortcut(Qt::Key_Plus);
1451 collection.addAction("select_timeline_clip", selectTimelineClip);
1452 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1454 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1455 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1456 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1457 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1459 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1460 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1461 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1462 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1464 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1465 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1466 collection.addAction("select_timeline_transition", selectTimelineTransition);
1467 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1469 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1470 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1471 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1472 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1474 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1475 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1476 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1477 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1479 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1480 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1481 collection.addAction("cut_timeline_clip", cutTimelineClip);
1482 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1484 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1485 collection.addAction("add_clip_marker", addClipMarker);
1486 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1488 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1489 collection.addAction("delete_clip_marker", deleteClipMarker);
1490 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1492 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1493 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1494 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1496 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1497 editClipMarker->setData(QString("edit_marker"));
1498 collection.addAction("edit_clip_marker", editClipMarker);
1499 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1501 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1502 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1503 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1504 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1506 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1507 collection.addAction("split_audio", splitAudio);
1508 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1510 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1511 collection.addAction("clip_audio_only", audioOnly);
1512 audioOnly->setData("clip_audio_only");
1513 audioOnly->setCheckable(true);
1515 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1516 collection.addAction("clip_video_only", videoOnly);
1517 videoOnly->setData("clip_video_only");
1518 videoOnly->setCheckable(true);
1520 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1521 collection.addAction("clip_audio_and_video", audioAndVideo);
1522 audioAndVideo->setData("clip_audio_and_video");
1523 audioAndVideo->setCheckable(true);
1525 m_clipTypeGroup = new QActionGroup(this);
1526 m_clipTypeGroup->addAction(audioOnly);
1527 m_clipTypeGroup->addAction(videoOnly);
1528 m_clipTypeGroup->addAction(audioAndVideo);
1529 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1530 m_clipTypeGroup->setEnabled(false);
1532 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1533 collection.addAction("insert_space", insertSpace);
1534 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1536 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1537 collection.addAction("delete_space", removeSpace);
1538 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1540 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1541 collection.addAction("insert_track", insertTrack);
1542 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1544 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1545 collection.addAction("delete_track", deleteTrack);
1546 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1548 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1549 collection.addAction("config_tracks", configTracks);
1550 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1552 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1553 collection.addAction("add_guide", addGuide);
1554 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1556 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1557 collection.addAction("delete_guide", delGuide);
1558 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1560 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1561 collection.addAction("edit_guide", editGuide);
1562 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1564 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1565 collection.addAction("delete_all_guides", delAllGuides);
1566 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1568 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1569 collection.addAction("paste_effects", pasteEffects);
1570 pasteEffects->setData("paste_effects");
1571 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1573 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1574 collection.addAction("show_timeline", showTimeline);
1575 showTimeline->setCheckable(true);
1576 showTimeline->setChecked(true);
1577 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1579 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1580 collection.addAction("show_titlebars", showTitleBar);
1581 showTitleBar->setCheckable(true);
1582 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1583 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1584 slotShowTitleBars(KdenliveSettings::showtitlebars());
1586 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1587 KStandardAction::quit(this, SLOT(close()), collection);
1588 KStandardAction::open(this, SLOT(openFile()), collection);
1589 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1590 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1591 KStandardAction::openNew(this, SLOT(newFile()), collection);
1592 // TODO: make the following connection to slotEditKeys work
1593 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1594 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1595 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1596 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1597 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1598 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1600 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1601 undo->setEnabled(false);
1602 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1604 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1605 redo->setEnabled(false);
1606 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1609 //TODO: Add status tooltip to actions ?
1610 connect(collection, SIGNAL(actionHovered(QAction*)),
1611 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1614 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1615 collection.addAction("add_clip", addClip);
1616 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1618 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1619 collection.addAction("add_color_clip", addColorClip);
1620 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1622 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1623 collection.addAction("add_slide_clip", addSlideClip);
1624 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1626 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1627 collection.addAction("add_text_clip", addTitleClip);
1628 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1630 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1631 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1632 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1634 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1635 collection.addAction("add_folder", addFolderButton);
1636 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1638 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1639 collection.addAction("clip_properties", clipProperties);
1640 clipProperties->setData("clip_properties");
1641 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1642 clipProperties->setEnabled(false);
1644 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1645 collection.addAction("edit_clip", openClip);
1646 openClip->setData("edit_clip");
1647 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1648 openClip->setEnabled(false);
1650 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1651 collection.addAction("delete_clip", deleteClip);
1652 deleteClip->setData("delete_clip");
1653 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1654 deleteClip->setEnabled(false);
1656 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1657 collection.addAction("reload_clip", reloadClip);
1658 reloadClip->setData("reload_clip");
1659 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1660 reloadClip->setEnabled(false);
1662 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1663 collection.addAction("proxy_clip", proxyClip);
1664 proxyClip->setData("proxy_clip");
1665 proxyClip->setCheckable(true);
1666 proxyClip->setChecked(false);
1667 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1669 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1670 collection.addAction("stopmotion", stopMotion);
1671 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1673 QMenu *addClips = new QMenu();
1674 addClips->addAction(addClip);
1675 addClips->addAction(addColorClip);
1676 addClips->addAction(addSlideClip);
1677 addClips->addAction(addTitleClip);
1678 addClips->addAction(addTitleTemplateClip);
1679 addClips->addAction(addFolderButton);
1681 addClips->addAction(reloadClip);
1682 addClips->addAction(proxyClip);
1683 addClips->addAction(clipProperties);
1684 addClips->addAction(openClip);
1685 addClips->addAction(deleteClip);
1686 m_projectList->setupMenu(addClips, addClip);
1688 // Setup effects and transitions actions.
1689 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1690 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1691 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1692 m_transitions = new KAction*[transitions.count()];
1693 for (int i = 0; i < transitions.count(); i++) {
1694 QStringList effectInfo = transitions.effectIdInfo(i);
1695 m_transitions[i] = new KAction(effectInfo.at(0), this);
1696 m_transitions[i]->setData(effectInfo);
1697 m_transitions[i]->setIconVisibleInMenu(false);
1698 QString id = effectInfo.at(2);
1699 if (id.isEmpty()) id = effectInfo.at(1);
1700 transitionActions->addAction("transition_" + id, m_transitions[i]);
1702 //m_effectsActionCollection->readSettings();
1706 void MainWindow::slotDisplayActionMessage(QAction *a)
1708 statusBar()->showMessage(a->data().toString(), 3000);
1711 void MainWindow::loadLayouts()
1713 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1714 if (m_loadLayout == NULL || saveLayout == NULL) return;
1715 KSharedConfigPtr config = KGlobal::config();
1716 KConfigGroup layoutGroup(config, "Layouts");
1717 QStringList entries = layoutGroup.keyList();
1718 QList<QAction *> loadActions = m_loadLayout->actions();
1719 QList<QAction *> saveActions = saveLayout->actions();
1720 for (int i = 1; i < 5; i++) {
1721 // Rename the layouts actions
1722 foreach(const QString & key, entries) {
1723 if (key.endsWith(QString("_%1").arg(i))) {
1724 // Found previously saved layout
1725 QString layoutName = key.section("_", 0, -2);
1726 for (int j = 0; j < loadActions.count(); j++) {
1727 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1728 loadActions[j]->setText(layoutName);
1729 loadActions[j]->setData(key);
1733 for (int j = 0; j < saveActions.count(); j++) {
1734 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1735 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1736 saveActions[j]->setData(key);
1745 void MainWindow::slotLoadLayout(QAction *action)
1747 if (!action) return;
1748 QString layoutId = action->data().toString();
1749 if (layoutId.isEmpty()) return;
1750 KSharedConfigPtr config = KGlobal::config();
1751 KConfigGroup layouts(config, "Layouts");
1752 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1753 restoreState(state);
1756 void MainWindow::slotSaveLayout(QAction *action)
1758 QString originallayoutName = action->data().toString();
1759 int layoutId = originallayoutName.section('_', -1).toInt();
1761 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1762 if (layoutName.isEmpty()) return;
1763 KSharedConfigPtr config = KGlobal::config();
1764 KConfigGroup layouts(config, "Layouts");
1765 layouts.deleteEntry(originallayoutName);
1767 QByteArray st = saveState();
1768 layoutName.append("_" + QString::number(layoutId));
1769 layouts.writeEntry(layoutName, st.toBase64());
1773 void MainWindow::saveOptions()
1775 KdenliveSettings::self()->writeConfig();
1776 KSharedConfigPtr config = KGlobal::config();
1777 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1778 KConfigGroup treecolumns(config, "Project Tree");
1779 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1783 void MainWindow::readOptions()
1785 KSharedConfigPtr config = KGlobal::config();
1786 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1787 KConfigGroup initialGroup(config, "version");
1788 bool upgrade = false;
1789 if (initialGroup.exists()) {
1790 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1794 if (initialGroup.readEntry("version") == "0.7") {
1795 //Add new settings from 0.7.1
1796 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1797 QString path = QDir::homePath() + "/kdenlive";
1798 if (KStandardDirs::makeDir(path) == false) {
1799 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1800 } else KdenliveSettings::setDefaultprojectfolder(path);
1806 if (!initialGroup.exists() || upgrade) {
1807 // this is our first run, show Wizard
1808 Wizard *w = new Wizard(upgrade, this);
1809 if (w->exec() == QDialog::Accepted && w->isOk()) {
1810 w->adjustSettings();
1811 initialGroup.writeEntry("version", version);
1817 KConfigGroup treecolumns(config, "Project Tree");
1818 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1819 if (!state.isEmpty())
1820 m_projectList->setHeaderInfo(state);
1823 void MainWindow::slotRunWizard()
1825 Wizard *w = new Wizard(false, this);
1826 if (w->exec() == QDialog::Accepted && w->isOk()) {
1827 w->adjustSettings();
1832 void MainWindow::newFile(bool showProjectSettings, bool force)
1834 if (!m_timelineArea->isEnabled() && !force)
1836 m_fileRevert->setEnabled(false);
1837 QString profileName = KdenliveSettings::default_profile();
1838 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1839 QMap <QString, QString> documentProperties;
1840 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1841 if (!showProjectSettings) {
1842 if (!KdenliveSettings::activatetabs())
1843 if (!closeCurrentDocument())
1846 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1847 if (w->exec() != QDialog::Accepted)
1849 if (!KdenliveSettings::activatetabs())
1850 if (!closeCurrentDocument())
1852 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1853 slotSwitchVideoThumbs();
1854 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1855 slotSwitchAudioThumbs();
1856 profileName = w->selectedProfile();
1857 projectFolder = w->selectedFolder();
1858 projectTracks = w->tracks();
1859 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1860 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1861 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1862 documentProperties.insert("proxyparams", w->proxyParams());
1863 documentProperties.insert("proxyextension", w->proxyExtension());
1864 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1865 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1868 m_timelineArea->setEnabled(true);
1869 m_projectList->setEnabled(true);
1871 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1872 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1874 TrackView *trackView = new TrackView(doc, &ok, this);
1875 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1878 //m_timelineArea->setEnabled(false);
1879 //m_projectList->setEnabled(false);
1883 if (m_timelineArea->count() == 1) {
1884 connectDocumentInfo(doc);
1885 connectDocument(trackView, doc);
1887 m_timelineArea->setTabBarHidden(false);
1888 m_monitorManager->activateMonitor("clip");
1889 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1892 void MainWindow::activateDocument()
1894 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1895 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1896 KdenliveDoc *currentDoc = currentTab->document();
1897 connectDocumentInfo(currentDoc);
1898 connectDocument(currentTab, currentDoc);
1901 bool MainWindow::closeCurrentDocument(bool saveChanges)
1903 QWidget *w = m_timelineArea->currentWidget();
1904 if (!w) return true;
1905 // closing current document
1906 int ix = m_timelineArea->currentIndex() + 1;
1907 if (ix == m_timelineArea->count()) ix = 0;
1908 m_timelineArea->setCurrentIndex(ix);
1909 TrackView *tabToClose = (TrackView *) w;
1910 KdenliveDoc *docToClose = tabToClose->document();
1911 if (docToClose && docToClose->isModified() && saveChanges) {
1913 if (m_activeDocument->url().fileName().isEmpty())
1914 message = i18n("Save changes to document?");
1916 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1917 switch (KMessageBox::warningYesNoCancel(this, message)) {
1918 case KMessageBox::Yes :
1919 // save document here. If saving fails, return false;
1920 if (saveFile() == false) return false;
1922 case KMessageBox::Cancel :
1929 m_clipMonitor->slotSetClipProducer(NULL);
1930 m_projectList->slotResetProjectList();
1931 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1932 if (m_timelineArea->count() == 1) {
1933 m_timelineArea->setTabBarHidden(true);
1934 m_closeAction->setEnabled(false);
1936 if (docToClose == m_activeDocument) {
1937 delete m_activeDocument;
1938 m_activeDocument = NULL;
1939 m_effectStack->clear();
1940 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1944 if (w == m_activeTimeline) {
1945 delete m_activeTimeline;
1946 m_activeTimeline = NULL;
1953 bool MainWindow::saveFileAs(const QString &outputFileName)
1955 QString currentSceneList;
1956 m_monitorManager->stopActiveMonitor();
1958 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1961 // Save timeline thumbnails
1962 m_activeTimeline->projectView()->saveThumbnails();
1963 m_activeDocument->setUrl(KUrl(outputFileName));
1964 if (m_activeDocument->m_autosave == NULL) {
1965 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1966 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1967 setCaption(m_activeDocument->description());
1968 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1969 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1970 m_activeDocument->setModified(false);
1971 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1972 m_fileRevert->setEnabled(true);
1973 m_undoView->stack()->setClean();
1977 bool MainWindow::saveFileAs()
1979 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1980 if (outputFile.isEmpty()) {
1983 if (QFile::exists(outputFile)) {
1984 // Show the file dialog again if the user does not want to overwrite the file
1985 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1986 return saveFileAs();
1988 return saveFileAs(outputFile);
1991 bool MainWindow::saveFile()
1993 if (!m_activeDocument) return true;
1994 if (m_activeDocument->url().isEmpty()) {
1995 return saveFileAs();
1997 bool result = saveFileAs(m_activeDocument->url().path());
1998 m_activeDocument->m_autosave->resize(0);
2003 void MainWindow::openFile()
2005 if (!m_startUrl.isEmpty()) {
2006 openFile(m_startUrl);
2007 m_startUrl = KUrl();
2010 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2011 if (url.isEmpty()) return;
2012 m_fileOpenRecent->addUrl(url);
2016 void MainWindow::openLastFile()
2018 KSharedConfigPtr config = KGlobal::config();
2019 KUrl::List urls = m_fileOpenRecent->urls();
2020 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2021 if (urls.isEmpty()) newFile(false);
2022 else openFile(urls.last());
2025 void MainWindow::openFile(const KUrl &url)
2027 // Make sure the url is a Kdenlive project file
2028 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2029 if (mime.data()->is("application/x-compressed-tar")) {
2030 // Opening a compressed project file, we need to process it
2031 kDebug()<<"Opening archive, processing";
2032 ArchiveWidget *ar = new ArchiveWidget(url);
2033 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2037 if (!url.fileName().endsWith(".kdenlive")) {
2038 // This is not a Kdenlive project file, abort loading
2039 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2043 // Check if the document is already opened
2044 const int ct = m_timelineArea->count();
2045 bool isOpened = false;
2047 for (i = 0; i < ct; i++) {
2048 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2049 KdenliveDoc *doc = tab->document();
2050 if (doc->url() == url) {
2056 m_timelineArea->setCurrentIndex(i);
2060 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2062 // Check for backup file
2063 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2064 if (!staleFiles.isEmpty()) {
2065 if (KMessageBox::questionYesNo(this,
2066 i18n("Auto-saved files exist. Do you want to recover them now?"),
2067 i18n("File Recovery"),
2068 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2069 recoverFiles(staleFiles);
2072 // remove the stale files
2073 foreach(KAutoSaveFile * stale, staleFiles) {
2074 stale->open(QIODevice::ReadWrite);
2079 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2080 m_messageLabel->repaint();
2081 doOpenFile(url, NULL);
2084 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2086 if (!m_timelineArea->isEnabled()) return;
2087 m_fileRevert->setEnabled(true);
2089 // Recreate stopmotion widget on document change
2091 delete m_stopmotion;
2092 m_stopmotion = NULL;
2096 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2097 progressDialog.setAllowCancel(false);
2098 progressDialog.progressBar()->setMaximum(4);
2099 progressDialog.show();
2100 progressDialog.progressBar()->setValue(0);
2101 qApp->processEvents();
2104 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);
2106 progressDialog.progressBar()->setValue(1);
2107 progressDialog.progressBar()->setMaximum(4);
2108 progressDialog.setLabelText(i18n("Loading project"));
2109 qApp->processEvents();
2111 if (stale == NULL) {
2112 stale = new KAutoSaveFile(url, doc);
2113 doc->m_autosave = stale;
2115 doc->m_autosave = stale;
2116 doc->setUrl(stale->managedFile());
2117 doc->setModified(true);
2118 stale->setParent(doc);
2120 connectDocumentInfo(doc);
2122 progressDialog.progressBar()->setValue(2);
2123 qApp->processEvents();
2126 TrackView *trackView = new TrackView(doc, &ok, this);
2127 connectDocument(trackView, doc);
2128 progressDialog.progressBar()->setValue(3);
2129 qApp->processEvents();
2131 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2133 m_timelineArea->setEnabled(false);
2134 m_projectList->setEnabled(false);
2135 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2136 slotGotProgressInfo(QString(), -1);
2137 newFile(false, true);
2140 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2141 trackView->setDuration(trackView->duration());
2142 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2144 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2145 slotGotProgressInfo(QString(), -1);
2146 m_projectMonitor->adjustRulerSize(trackView->duration());
2147 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2148 progressDialog.progressBar()->setValue(4);
2149 if (openBackup) slotOpenBackupDialog(url);
2152 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2154 foreach(KAutoSaveFile * stale, staleFiles) {
2155 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2156 // show an error message; we could not steal the lockfile
2157 // maybe another application got to the file before us?
2161 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2162 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2163 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2164 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2168 void MainWindow::parseProfiles(const QString &mltPath)
2170 //KdenliveSettings::setDefaulttmpfolder();
2171 if (!mltPath.isEmpty()) {
2172 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2173 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2176 if (KdenliveSettings::mltpath().isEmpty())
2177 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2179 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2180 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2181 if (!QFile::exists(meltPath))
2182 meltPath = KStandardDirs::findExe("melt");
2183 KdenliveSettings::setRendererpath(meltPath);
2186 if (KdenliveSettings::rendererpath().isEmpty()) {
2187 // Cannot find the MLT melt renderer, ask for location
2188 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2189 if (getUrl->exec() == QDialog::Rejected) {
2192 KUrl rendererPath = getUrl->selectedUrl();
2194 if (rendererPath.isEmpty()) ::exit(0);
2195 KdenliveSettings::setRendererpath(rendererPath.path());
2198 QStringList profilesFilter;
2199 profilesFilter << "*";
2200 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2201 if (profilesList.isEmpty()) {
2202 // Cannot find MLT path, try finding melt
2203 QString profilePath = KdenliveSettings::rendererpath();
2204 if (!profilePath.isEmpty()) {
2205 profilePath = profilePath.section('/', 0, -3);
2206 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2207 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2209 if (profilesList.isEmpty()) {
2210 // Cannot find the MLT profiles, ask for location
2211 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2212 getUrl->fileDialog()->setMode(KFile::Directory);
2213 if (getUrl->exec() == QDialog::Rejected) {
2216 KUrl mltPath = getUrl->selectedUrl();
2218 if (mltPath.isEmpty()) ::exit(0);
2219 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2220 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2224 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2226 // Parse again MLT profiles to build a list of available video formats
2227 if (profilesList.isEmpty()) parseProfiles();
2231 void MainWindow::slotEditProfiles()
2233 ProfilesDialog *w = new ProfilesDialog;
2234 if (w->exec() == QDialog::Accepted) {
2235 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2236 if (d) d->checkProfile();
2241 void MainWindow::slotDetectAudioDriver()
2243 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2244 leading to no audio output, see bug #934 */
2246 //decide which audio driver is really best, in some cases SDL is wrong
2247 if (KdenliveSettings::audiodrivername().isEmpty()) {
2249 KProcess readProcess;
2250 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2251 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2252 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2253 readProcess.setProgram("pactl", QStringList() << "stat");
2254 readProcess.execute(2000); // Kill it after 2 seconds
2256 QString result = QString(readProcess.readAllStandardOutput());
2257 kDebug() << "// / / / / / READING PACTL: ";
2259 if (!result.isEmpty()) {
2261 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2265 KdenliveSettings::setAutoaudiodrivername(driver);
2269 void MainWindow::slotEditProjectSettings()
2271 QPoint p = m_activeDocument->getTracksCount();
2272 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2273 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2275 if (w->exec() == QDialog::Accepted) {
2276 QString profile = w->selectedProfile();
2277 m_activeDocument->setProjectFolder(w->selectedFolder());
2279 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2281 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2282 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2283 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2284 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2285 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2286 m_activeDocument->setModified();
2287 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2288 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) {
2289 //TODO: rebuild all proxies
2290 //m_projectList->rebuildProxies();
2293 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2294 m_activeDocument->setModified();
2295 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2297 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2298 m_activeDocument->setModified();
2299 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2301 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2302 m_activeDocument->setModified();
2303 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2305 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2306 m_activeDocument->setModified();
2307 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2309 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2310 m_activeDocument->setModified();
2311 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2313 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2314 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2315 m_activeDocument->setModified();
2316 slotUpdateProxySettings();
2322 void MainWindow::slotDisableProxies()
2324 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2325 m_activeDocument->setModified();
2326 slotUpdateProxySettings();
2329 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2331 // Recreate the stopmotion widget if profile changes
2333 delete m_stopmotion;
2334 m_stopmotion = NULL;
2337 // Deselect current effect / transition
2338 m_effectStack->slotClipItemSelected(NULL, 0);
2339 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2340 m_clipMonitor->slotSetClipProducer(NULL);
2341 bool updateFps = m_activeDocument->setProfilePath(profile);
2342 KdenliveSettings::setCurrent_profile(profile);
2343 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2344 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2346 m_activeDocument->clipManager()->clearUnusedProducers();
2347 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2348 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2349 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2350 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2351 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2352 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2353 if (updateFps) m_activeTimeline->updateProjectFps();
2354 m_activeDocument->clipManager()->clearCache();
2355 m_activeTimeline->updateProfile();
2356 m_activeDocument->setModified(true);
2357 m_commandStack->activeStack()->clear();
2358 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2359 slotUpdateMousePosition(0);
2360 // We need to desactivate & reactivate monitors to get a refresh
2361 //m_monitorManager->switchMonitors();
2365 void MainWindow::slotRenderProject()
2367 if (!m_renderWidget) {
2368 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2369 MltVideoProfile profile;
2370 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2371 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2372 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2373 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2374 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2375 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2376 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2377 if (m_activeDocument) {
2378 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2379 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2380 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2381 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2384 slotCheckRenderStatus();
2385 m_renderWidget->show();
2386 m_renderWidget->showNormal();
2388 // What are the following lines supposed to do?
2389 //m_activeTimeline->tracksNumber();
2390 //m_renderWidget->enableAudio(false);
2391 //m_renderWidget->export_audio;
2394 void MainWindow::slotCheckRenderStatus()
2396 // Make sure there are no missing clips
2398 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2401 void MainWindow::setRenderingProgress(const QString &url, int progress)
2404 m_renderWidget->setRenderJob(url, progress);
2407 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2410 m_renderWidget->setRenderStatus(url, status, error);
2413 void MainWindow::slotCleanProject()
2415 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2416 m_projectList->cleanup();
2419 void MainWindow::slotUpdateMousePosition(int pos)
2421 if (m_activeDocument)
2422 switch (m_timecodeFormat->currentIndex()) {
2424 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2427 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2431 void MainWindow::slotUpdateDocumentState(bool modified)
2433 if (!m_activeDocument) return;
2434 setCaption(m_activeDocument->description(), modified);
2435 m_saveAction->setEnabled(modified);
2437 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2438 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2440 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2441 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2445 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2447 if (m_activeDocument) {
2448 if (m_activeDocument == doc) return;
2449 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2451 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2454 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2456 //m_projectMonitor->stop();
2457 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2458 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2459 if (m_activeDocument) {
2460 if (m_activeDocument == doc) return;
2461 if (m_activeTimeline) {
2462 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2463 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2464 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2465 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2466 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2467 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2468 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2470 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2472 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2473 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2474 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2475 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2476 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2477 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2478 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2479 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2480 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2481 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2482 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2483 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2484 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2485 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2486 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2487 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2488 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2489 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2490 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2491 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2492 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2493 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2494 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2495 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2496 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2497 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2498 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2499 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2500 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2501 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2502 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2503 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2504 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2505 m_effectStack->clear();
2507 //m_activeDocument->setRenderer(NULL);
2508 m_clipMonitor->stop();
2510 KdenliveSettings::setCurrent_profile(doc->profilePath());
2511 KdenliveSettings::setProject_fps(doc->fps());
2512 m_monitorManager->resetProfiles(doc->timecode());
2513 m_clipMonitorDock->raise();
2514 m_projectList->setDocument(doc);
2515 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2516 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2517 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2519 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2520 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2522 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2523 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2524 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2525 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2526 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2527 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2528 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2529 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2530 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2531 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2532 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2533 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2534 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2536 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2537 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2538 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2539 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2540 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2542 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2543 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2544 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2546 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2548 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2549 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2550 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2551 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2553 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2554 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2555 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2556 m_zoomSlider->setValue(doc->zoom().x());
2557 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2558 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2559 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2560 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2562 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2563 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2565 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2566 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2568 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2569 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2570 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2571 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2572 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2573 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2574 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2575 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2576 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2577 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2578 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2580 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2581 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2582 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2585 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2586 m_activeTimeline = trackView;
2587 if (m_renderWidget) {
2588 slotCheckRenderStatus();
2589 m_renderWidget->setProfile(doc->mltProfile());
2590 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2591 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2592 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2594 //doc->setRenderer(m_projectMonitor->render);
2595 m_commandStack->setActiveStack(doc->commandStack());
2596 KdenliveSettings::setProject_display_ratio(doc->dar());
2597 //doc->clipManager()->checkAudioThumbs();
2599 //m_overView->setScene(trackView->projectScene());
2600 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2601 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2603 setCaption(doc->description(), doc->isModified());
2604 m_saveAction->setEnabled(doc->isModified());
2605 m_normalEditTool->setChecked(true);
2606 m_activeDocument = doc;
2607 m_activeTimeline->updateProjectFps();
2608 m_activeDocument->checkProjectClips();
2610 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2612 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2613 slotUpdateMousePosition(0);
2614 m_monitorManager->activateMonitor("clip");
2615 // set tool to select tool
2616 m_buttonSelectTool->setChecked(true);
2619 void MainWindow::slotZoneMoved(int start, int end)
2621 m_activeDocument->setZone(start, end);
2622 m_projectMonitor->slotZoneMoved(start, end);
2625 void MainWindow::slotGuidesUpdated()
2628 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2631 void MainWindow::slotEditKeys()
2633 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2634 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2635 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2639 void MainWindow::slotPreferences(int page, int option)
2642 * An instance of your dialog could be already created and could be
2643 * cached, in which case you want to display the cached dialog
2644 * instead of creating another one
2646 if (m_stopmotion) m_stopmotion->slotLive(false);
2647 if (KConfigDialog::showDialog("settings")) {
2648 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2649 if (page != -1) d->showPage(page, option);
2653 // KConfigDialog didn't find an instance of this dialog, so lets
2656 // Get the mappable actions in localized form
2657 QMap<QString, QString> actions;
2658 KActionCollection* collection = actionCollection();
2659 foreach (const QString& action_name, m_action_names) {
2660 actions[collection->action(action_name)->text()] = action_name;
2663 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2664 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2665 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2667 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2670 if (page != -1) dialog->showPage(page, option);
2673 void MainWindow::slotUpdateCaptureFolder()
2677 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2678 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2682 void MainWindow::updateConfiguration()
2684 //TODO: we should apply settings to all projects, not only the current one
2685 if (m_activeTimeline) {
2686 m_activeTimeline->refresh();
2687 m_activeTimeline->projectView()->checkAutoScroll();
2688 m_activeTimeline->checkTrackHeight();
2689 if (m_activeDocument)
2690 m_activeDocument->clipManager()->checkAudioThumbs();
2692 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2693 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2694 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2695 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2697 // Update list of transcoding profiles
2700 #ifdef USE_JOGSHUTTLE
2701 activateShuttleDevice();
2706 void MainWindow::slotSwitchSplitAudio()
2708 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2709 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2712 void MainWindow::slotSwitchVideoThumbs()
2714 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2715 if (m_activeTimeline)
2716 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2717 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2720 void MainWindow::slotSwitchAudioThumbs()
2722 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2723 if (m_activeTimeline) {
2724 m_activeTimeline->refresh();
2725 m_activeTimeline->projectView()->checkAutoScroll();
2726 if (m_activeDocument)
2727 m_activeDocument->clipManager()->checkAudioThumbs();
2729 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2732 void MainWindow::slotSwitchMarkersComments()
2734 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2735 if (m_activeTimeline)
2736 m_activeTimeline->refresh();
2737 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2740 void MainWindow::slotSwitchSnap()
2742 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2743 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2747 void MainWindow::slotDeleteItem()
2749 if (QApplication::focusWidget() &&
2750 QApplication::focusWidget()->parentWidget() &&
2751 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2752 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2753 m_projectList->slotRemoveClip();
2756 QWidget *widget = QApplication::focusWidget();
2758 if (widget == m_effectStackDock) {
2759 m_effectStack->slotItemDel();
2762 widget = widget->parentWidget();
2765 // effect stack has no focus
2766 if (m_activeTimeline)
2767 m_activeTimeline->projectView()->deleteSelectedClips();
2771 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2773 if (m_clipMonitor->isActive())
2774 m_clipMonitor->checkOverlay();
2775 m_clipMonitor->updateMarkers(clip);
2778 void MainWindow::slotAddClipMarker()
2780 DocClipBase *clip = NULL;
2782 if (m_projectMonitor->isActive()) {
2783 if (m_activeTimeline) {
2784 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2786 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2787 clip = item->baseClip();
2791 clip = m_clipMonitor->activeClip();
2792 pos = m_clipMonitor->position();
2795 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2798 QString id = clip->getId();
2799 CommentedTime marker(pos, i18n("Marker"));
2800 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2801 if (d.exec() == QDialog::Accepted)
2802 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2805 void MainWindow::slotDeleteClipMarker()
2807 DocClipBase *clip = NULL;
2809 if (m_projectMonitor->isActive()) {
2810 if (m_activeTimeline) {
2811 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2813 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2814 clip = item->baseClip();
2818 clip = m_clipMonitor->activeClip();
2819 pos = m_clipMonitor->position();
2822 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2826 QString id = clip->getId();
2827 QString comment = clip->markerComment(pos);
2828 if (comment.isEmpty()) {
2829 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2832 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2835 void MainWindow::slotDeleteAllClipMarkers()
2837 DocClipBase *clip = NULL;
2838 if (m_projectMonitor->isActive()) {
2839 if (m_activeTimeline) {
2840 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2842 clip = item->baseClip();
2846 clip = m_clipMonitor->activeClip();
2849 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2852 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2855 void MainWindow::slotEditClipMarker()
2857 DocClipBase *clip = NULL;
2859 if (m_projectMonitor->isActive()) {
2860 if (m_activeTimeline) {
2861 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2863 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2864 clip = item->baseClip();
2868 clip = m_clipMonitor->activeClip();
2869 pos = m_clipMonitor->position();
2872 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2876 QString id = clip->getId();
2877 QString oldcomment = clip->markerComment(pos);
2878 if (oldcomment.isEmpty()) {
2879 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2883 CommentedTime marker(pos, oldcomment);
2884 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2885 if (d.exec() == QDialog::Accepted) {
2886 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2887 if (d.newMarker().time() != pos) {
2888 // remove old marker
2889 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2894 void MainWindow::slotAddMarkerGuideQuickly()
2896 if (!m_activeTimeline || !m_activeDocument)
2899 if (m_clipMonitor->isActive()) {
2900 DocClipBase *clip = m_clipMonitor->activeClip();
2901 GenTime pos = m_clipMonitor->position();
2904 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2908 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2910 m_activeTimeline->projectView()->slotAddGuide(false);
2914 void MainWindow::slotAddGuide()
2916 if (m_activeTimeline)
2917 m_activeTimeline->projectView()->slotAddGuide();
2920 void MainWindow::slotInsertSpace()
2922 if (m_activeTimeline)
2923 m_activeTimeline->projectView()->slotInsertSpace();
2926 void MainWindow::slotRemoveSpace()
2928 if (m_activeTimeline)
2929 m_activeTimeline->projectView()->slotRemoveSpace();
2932 void MainWindow::slotInsertTrack(int ix)
2934 m_projectMonitor->activateMonitor();
2935 if (m_activeTimeline)
2936 m_activeTimeline->projectView()->slotInsertTrack(ix);
2937 if (m_activeDocument)
2938 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2941 void MainWindow::slotDeleteTrack(int ix)
2943 m_projectMonitor->activateMonitor();
2944 if (m_activeTimeline)
2945 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2946 if (m_activeDocument)
2947 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2950 void MainWindow::slotConfigTrack(int ix)
2952 m_projectMonitor->activateMonitor();
2953 if (m_activeTimeline)
2954 m_activeTimeline->projectView()->slotConfigTracks(ix);
2955 if (m_activeDocument)
2956 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2959 void MainWindow::slotEditGuide()
2961 if (m_activeTimeline)
2962 m_activeTimeline->projectView()->slotEditGuide();
2965 void MainWindow::slotDeleteGuide()
2967 if (m_activeTimeline)
2968 m_activeTimeline->projectView()->slotDeleteGuide();
2971 void MainWindow::slotDeleteAllGuides()
2973 if (m_activeTimeline)
2974 m_activeTimeline->projectView()->slotDeleteAllGuides();
2977 void MainWindow::slotCutTimelineClip()
2979 if (m_activeTimeline)
2980 m_activeTimeline->projectView()->cutSelectedClips();
2983 void MainWindow::slotInsertClipOverwrite()
2985 if (m_activeTimeline) {
2986 QStringList data = m_clipMonitor->getZoneInfo();
2987 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2991 void MainWindow::slotSelectTimelineClip()
2993 if (m_activeTimeline)
2994 m_activeTimeline->projectView()->selectClip(true);
2997 void MainWindow::slotSelectTimelineTransition()
2999 if (m_activeTimeline)
3000 m_activeTimeline->projectView()->selectTransition(true);
3003 void MainWindow::slotDeselectTimelineClip()
3005 if (m_activeTimeline)
3006 m_activeTimeline->projectView()->selectClip(false, true);
3009 void MainWindow::slotDeselectTimelineTransition()
3011 if (m_activeTimeline)
3012 m_activeTimeline->projectView()->selectTransition(false, true);
3015 void MainWindow::slotSelectAddTimelineClip()
3017 if (m_activeTimeline)
3018 m_activeTimeline->projectView()->selectClip(true, true);
3021 void MainWindow::slotSelectAddTimelineTransition()
3023 if (m_activeTimeline)
3024 m_activeTimeline->projectView()->selectTransition(true, true);
3027 void MainWindow::slotGroupClips()
3029 if (m_activeTimeline)
3030 m_activeTimeline->projectView()->groupClips();
3033 void MainWindow::slotUnGroupClips()
3035 if (m_activeTimeline)
3036 m_activeTimeline->projectView()->groupClips(false);
3039 void MainWindow::slotEditItemDuration()
3041 if (m_activeTimeline)
3042 m_activeTimeline->projectView()->editItemDuration();
3045 void MainWindow::slotAddProjectClip(KUrl url)
3047 if (m_activeDocument)
3048 m_activeDocument->slotAddClipFile(url, QString());
3051 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3053 if (m_activeDocument)
3054 m_activeDocument->slotAddClipList(urls, QString());
3057 void MainWindow::slotAddTransition(QAction *result)
3059 if (!result) return;
3060 QStringList info = result->data().toStringList();
3061 if (info.isEmpty()) return;
3062 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3063 if (m_activeTimeline && !transition.isNull()) {
3064 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3068 void MainWindow::slotAddVideoEffect(QAction *result)
3070 if (!result) return;
3071 const int EFFECT_VIDEO = 1;
3072 const int EFFECT_AUDIO = 2;
3073 QStringList info = result->data().toStringList();
3075 if (info.isEmpty() || info.size() < 3) return;
3076 QDomElement effect ;
3077 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3078 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3079 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3080 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3082 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3083 if (!effect.isNull()) slotAddEffect(effect);
3084 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3088 void MainWindow::slotZoomIn()
3090 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3091 slotShowZoomSliderToolTip();
3094 void MainWindow::slotZoomOut()
3096 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3097 slotShowZoomSliderToolTip();
3100 void MainWindow::slotFitZoom()
3102 if (m_activeTimeline)
3103 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3106 void MainWindow::slotSetZoom(int value)
3108 value = qMax(m_zoomSlider->minimum(), value);
3109 value = qMin(m_zoomSlider->maximum(), value);
3111 if (m_activeTimeline)
3112 m_activeTimeline->slotChangeZoom(value);
3114 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3115 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3116 slotUpdateZoomSliderToolTip(value);
3118 m_zoomSlider->blockSignals(true);
3119 m_zoomSlider->setValue(value);
3120 m_zoomSlider->blockSignals(false);
3123 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3125 if (zoomlevel != -1)
3126 slotUpdateZoomSliderToolTip(zoomlevel);
3128 QPoint global = m_zoomSlider->rect().topLeft();
3129 global.ry() += m_zoomSlider->height() / 2;
3130 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3131 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3134 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3136 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3139 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3141 m_statusProgressBar->setValue(progress);
3142 if (progress >= 0) {
3143 if (!message.isEmpty())
3144 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3145 m_statusProgressBar->setVisible(true);
3146 } else if (progress == -2) {
3147 if (!message.isEmpty())
3148 m_messageLabel->setMessage(message, ErrorMessage);
3149 m_statusProgressBar->setVisible(false);
3151 m_messageLabel->setMessage(QString(), DefaultMessage);
3152 m_statusProgressBar->setVisible(false);
3156 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3158 if (clip->clipType() == TEXT) {
3159 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3160 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3161 // template text clip
3163 // Get the list of existing templates
3165 filter << "*.kdenlivetitle";
3166 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3168 QDialog *dia = new QDialog(this);
3169 Ui::TemplateClip_UI dia_ui;
3170 dia_ui.setupUi(dia);
3172 const QString templatePath = clip->getProperty("resource");
3173 for (int i = 0; i < templateFiles.size(); ++i) {
3174 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3175 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3177 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3178 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3179 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3180 //warning: setting base directory doesn't work??
3181 KUrl startDir(titlepath);
3182 dia_ui.template_list->fileDialog()->setUrl(startDir);
3183 dia_ui.description->setText(clip->getProperty("description"));
3184 if (dia->exec() == QDialog::Accepted) {
3185 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3186 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3188 QMap <QString, QString> newprops;
3190 if (KUrl(textTemplate).path() != templatePath) {
3191 // The template was changed
3192 newprops.insert("resource", textTemplate);
3195 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3196 newprops.insert("description", dia_ui.description->toPlainText());
3199 QString newtemplate = newprops.value("xmltemplate");
3200 if (newtemplate.isEmpty()) newtemplate = templatePath;
3202 // template modified we need to update xmldata
3203 QString description = newprops.value("description");
3204 if (description.isEmpty()) description = clip->getProperty("description");
3205 else newprops.insert("templatetext", description);
3206 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3207 if (!newprops.isEmpty()) {
3208 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3209 m_activeDocument->commandStack()->push(command);
3215 QString path = clip->getProperty("resource");
3216 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3218 doc.setContent(clip->getProperty("xmldata"));
3219 dia_ui->setXml(doc);
3220 if (dia_ui->exec() == QDialog::Accepted) {
3221 QMap <QString, QString> newprops;
3222 newprops.insert("xmldata", dia_ui->xml().toString());
3223 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3224 // duration changed, we need to update duration
3225 newprops.insert("out", QString::number(dia_ui->outPoint()));
3226 int currentLength = QString(clip->producerProperty("length")).toInt();
3227 if (currentLength <= dia_ui->outPoint())
3228 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3229 else newprops.insert("length", clip->producerProperty("length"));
3231 if (!path.isEmpty()) {
3232 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3233 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) {
3234 // save to external file
3235 dia_ui->saveTitle(path);
3236 } else newprops.insert("resource", QString());
3238 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3239 m_activeDocument->commandStack()->push(command);
3240 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3241 m_activeDocument->setModified(true);
3245 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3249 // any type of clip but a title
3250 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3251 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3252 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3253 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)));
3258 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3260 if (newprops.isEmpty()) return;
3261 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3262 m_activeDocument->commandStack()->push(command);
3263 m_activeDocument->setModified();
3266 // update clip occurences in timeline
3267 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3272 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3274 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3275 if (dia.exec() == QDialog::Accepted) {
3276 QUndoCommand *command = new QUndoCommand();
3277 command->setText(i18n("Edit clips"));
3278 QMap <QString, QString> newImageProps = dia.properties();
3279 // Transparency setting applies only for images
3280 QMap <QString, QString> newProps = newImageProps;
3281 newProps.remove("transparency");
3283 for (int i = 0; i < cliplist.count(); i++) {
3284 DocClipBase *clip = cliplist.at(i);
3285 if (clip->clipType() == IMAGE)
3286 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3288 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3290 m_activeDocument->commandStack()->push(command);
3291 for (int i = 0; i < cliplist.count(); i++)
3292 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3296 void MainWindow::customEvent(QEvent* e)
3298 if (e->type() == QEvent::User)
3299 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3301 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3307 m_effectStack->raiseWindow(m_effectStackDock);
3310 void MainWindow::slotActivateTransitionView(Transition *t)
3313 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3316 void MainWindow::slotSnapRewind()
3318 if (m_projectMonitor->isActive()) {
3319 if (m_activeTimeline)
3320 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3322 m_clipMonitor->slotSeekToPreviousSnap();
3326 void MainWindow::slotSnapForward()
3328 if (m_projectMonitor->isActive()) {
3329 if (m_activeTimeline)
3330 m_activeTimeline->projectView()->slotSeekToNextSnap();
3332 m_clipMonitor->slotSeekToNextSnap();
3336 void MainWindow::slotClipStart()
3338 if (m_projectMonitor->isActive()) {
3339 if (m_activeTimeline)
3340 m_activeTimeline->projectView()->clipStart();
3344 void MainWindow::slotClipEnd()
3346 if (m_projectMonitor->isActive()) {
3347 if (m_activeTimeline)
3348 m_activeTimeline->projectView()->clipEnd();
3352 void MainWindow::slotZoneStart()
3354 if (m_projectMonitor->isActive())
3355 m_projectMonitor->slotZoneStart();
3357 m_clipMonitor->slotZoneStart();
3360 void MainWindow::slotZoneEnd()
3362 if (m_projectMonitor->isActive())
3363 m_projectMonitor->slotZoneEnd();
3365 m_clipMonitor->slotZoneEnd();
3368 void MainWindow::slotChangeTool(QAction * action)
3370 if (action == m_buttonSelectTool)
3371 slotSetTool(SELECTTOOL);
3372 else if (action == m_buttonRazorTool)
3373 slotSetTool(RAZORTOOL);
3374 else if (action == m_buttonSpacerTool)
3375 slotSetTool(SPACERTOOL);
3378 void MainWindow::slotChangeEdit(QAction * action)
3380 if (!m_activeTimeline)
3383 if (action == m_overwriteEditTool)
3384 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3385 else if (action == m_insertEditTool)
3386 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3388 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3391 void MainWindow::slotSetTool(PROJECTTOOL tool)
3393 if (m_activeDocument && m_activeTimeline) {
3394 //m_activeDocument->setTool(tool);
3398 message = i18n("Ctrl + click to use spacer on current track only");
3401 message = i18n("Click on a clip to cut it");
3404 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3407 m_messageLabel->setMessage(message, InformationMessage);
3408 m_activeTimeline->projectView()->setTool(tool);
3412 void MainWindow::slotCopy()
3414 if (m_activeDocument && m_activeTimeline)
3415 m_activeTimeline->projectView()->copyClip();
3418 void MainWindow::slotPaste()
3420 if (m_activeDocument && m_activeTimeline)
3421 m_activeTimeline->projectView()->pasteClip();
3424 void MainWindow::slotPasteEffects()
3426 if (m_activeDocument && m_activeTimeline)
3427 m_activeTimeline->projectView()->pasteClipEffects();
3430 void MainWindow::slotFind()
3432 if (!m_activeDocument || !m_activeTimeline) return;
3433 m_projectSearch->setEnabled(false);
3434 m_findActivated = true;
3435 m_findString.clear();
3436 m_activeTimeline->projectView()->initSearchStrings();
3437 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3438 m_findTimer.start(5000);
3439 qApp->installEventFilter(this);
3442 void MainWindow::slotFindNext()
3444 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3445 statusBar()->showMessage(i18n("Found: %1", m_findString));
3447 statusBar()->showMessage(i18n("Reached end of project"));
3448 m_findTimer.start(4000);
3451 void MainWindow::findAhead()
3453 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3454 m_projectSearchNext->setEnabled(true);
3455 statusBar()->showMessage(i18n("Found: %1", m_findString));
3457 m_projectSearchNext->setEnabled(false);
3458 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3462 void MainWindow::findTimeout()
3464 m_projectSearchNext->setEnabled(false);
3465 m_findActivated = false;
3466 m_findString.clear();
3467 statusBar()->showMessage(i18n("Find stopped"), 3000);
3468 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3469 m_projectSearch->setEnabled(true);
3470 removeEventFilter(this);
3473 void MainWindow::slotClipInTimeline(const QString &clipId)
3475 if (m_activeTimeline && m_activeDocument) {
3476 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3478 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3479 inTimelineMenu->clear();
3481 QList <QAction *> actionList;
3483 for (int i = 0; i < matching.count(); ++i) {
3484 QString track = QString::number(matching.at(i).track);
3485 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3487 QAction *a = new QAction(track + ": " + start, this);
3488 a->setData(QStringList() << track << start);
3489 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3490 while (j < actionList.count()) {
3491 if (actionList.at(j)->text() > a->text()) break;
3494 actionList.insert(j, a);
3496 inTimelineMenu->addActions(actionList);
3498 if (matching.empty())
3499 inTimelineMenu->setEnabled(false);
3501 inTimelineMenu->setEnabled(true);
3505 void MainWindow::slotClipInProjectTree()
3507 if (m_activeTimeline) {
3508 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3509 if (clipIds.isEmpty())
3511 m_projectListDock->raise();
3512 for (int i = 0; i < clipIds.count(); i++)
3513 m_projectList->selectItemById(clipIds.at(i));
3514 if (m_projectMonitor->isActive())
3515 slotSwitchMonitors();
3519 /*void MainWindow::slotClipToProjectTree()
3521 if (m_activeTimeline) {
3522 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3523 if (clips.isEmpty()) return;
3524 for (int i = 0; i < clips.count(); i++) {
3525 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3527 //m_projectList->selectItemById(clipIds.at(i));
3531 void MainWindow::slotSelectClipInTimeline()
3533 if (m_activeTimeline) {
3534 QAction *action = qobject_cast<QAction *>(sender());
3535 QStringList data = action->data().toStringList();
3536 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3540 void MainWindow::keyPressEvent(QKeyEvent *ke)
3542 if (m_findActivated) {
3543 if (ke->key() == Qt::Key_Backspace) {
3544 m_findString = m_findString.left(m_findString.length() - 1);
3546 if (!m_findString.isEmpty())
3551 m_findTimer.start(4000);
3554 } else if (ke->key() == Qt::Key_Escape) {
3558 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3559 m_findString += ke->text();
3563 m_findTimer.start(4000);
3568 KXmlGuiWindow::keyPressEvent(ke);
3573 /** Gets called when the window gets hidden */
3574 void MainWindow::hideEvent(QHideEvent */*event*/)
3576 if (isMinimized() && m_monitorManager)
3577 m_monitorManager->stopActiveMonitor();
3580 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3582 if (m_findActivated) {
3583 if (event->type() == QEvent::ShortcutOverride) {
3584 QKeyEvent* ke = (QKeyEvent*) event;
3585 if (ke->text().trimmed().isEmpty()) return false;
3592 // pass the event on to the parent class
3593 return QMainWindow::eventFilter(obj, event);
3598 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3600 KDialog *dialog = new KDialog(this);
3601 dialog->setCaption("Save clip zone");
3602 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3604 QWidget *widget = new QWidget(dialog);
3605 dialog->setMainWidget(widget);
3607 QVBoxLayout *vbox = new QVBoxLayout(widget);
3608 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3609 if (path.isEmpty()) {
3610 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3611 if (baseClip == NULL) tmppath.append("untitled.mlt");
3613 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3615 path = KUrl(tmppath);
3617 KUrlRequester *url = new KUrlRequester(path, this);
3618 url->setFilter("video/mlt-playlist");
3619 QLabel *label2 = new QLabel(i18n("Description:"), this);
3620 KLineEdit *edit = new KLineEdit(this);
3621 vbox->addWidget(label1);
3622 vbox->addWidget(url);
3623 vbox->addWidget(label2);
3624 vbox->addWidget(edit);
3625 if (dialog->exec() == QDialog::Accepted) {
3626 if (QFile::exists(url->url().path())) {
3627 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3628 slotSaveZone(render, zone, baseClip, url->url());
3632 if (baseClip && !baseClip->fileURL().isEmpty()) {
3633 // create zone from clip url, so that we don't have problems with proxy clips
3635 #if QT_VERSION >= 0x040600
3636 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3637 env.remove("MLT_PROFILE");
3638 p.setProcessEnvironment(env);
3640 QStringList env = QProcess::systemEnvironment();
3641 env << "MLT_PROFILE='\0'";
3642 p.setEnvironment(env);
3644 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3645 if (!p.waitForStarted(3000)) {
3646 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3648 else if (!p.waitForFinished(5000)) {
3649 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3652 else render->saveZone(url->url(), edit->text(), zone);
3657 void MainWindow::slotSetInPoint()
3659 if (m_clipMonitor->isActive()) {
3660 m_clipMonitor->slotSetZoneStart();
3662 m_projectMonitor->slotSetZoneStart();
3666 void MainWindow::slotSetOutPoint()
3668 if (m_clipMonitor->isActive()) {
3669 m_clipMonitor->slotSetZoneEnd();
3671 m_projectMonitor->slotSetZoneEnd();
3675 void MainWindow::slotResizeItemStart()
3677 if (m_activeTimeline)
3678 m_activeTimeline->projectView()->setInPoint();
3681 void MainWindow::slotResizeItemEnd()
3683 if (m_activeTimeline)
3684 m_activeTimeline->projectView()->setOutPoint();
3687 int MainWindow::getNewStuff(const QString &configFile)
3689 KNS3::Entry::List entries;
3690 #if KDE_IS_VERSION(4,3,80)
3691 KNS3::DownloadDialog dialog(configFile);
3693 entries = dialog.changedEntries();
3694 foreach(const KNS3::Entry & entry, entries) {
3695 if (entry.status() == KNS3::Entry::Installed)
3696 kDebug() << "// Installed files: " << entry.installedFiles();
3699 KNS::Engine engine(0);
3700 if (engine.init(configFile))
3701 entries = engine.downloadDialogModal(this);
3702 foreach(KNS::Entry * entry, entries) {
3703 if (entry->status() == KNS::Entry::Installed)
3704 kDebug() << "// Installed files: " << entry->installedFiles();
3707 return entries.size();
3710 void MainWindow::slotGetNewTitleStuff()
3712 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3713 TitleWidget::refreshTitleTemplates();
3716 void MainWindow::slotGetNewLumaStuff()
3718 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3719 initEffects::refreshLumas();
3720 m_activeTimeline->projectView()->reloadTransitionLumas();
3724 void MainWindow::slotGetNewRenderStuff()
3726 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3728 m_renderWidget->reloadProfiles();
3731 void MainWindow::slotGetNewMltProfileStuff()
3733 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3734 // update the list of profiles in settings dialog
3735 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3741 void MainWindow::slotAutoTransition()
3743 if (m_activeTimeline)
3744 m_activeTimeline->projectView()->autoTransition();
3747 void MainWindow::slotSplitAudio()
3749 if (m_activeTimeline)
3750 m_activeTimeline->projectView()->splitAudio();
3753 void MainWindow::slotUpdateClipType(QAction *action)
3755 if (m_activeTimeline) {
3756 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3757 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3758 else m_activeTimeline->projectView()->setAudioAndVideo();
3762 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3764 // We must stop the monitors since we create a new on in the dvd wizard
3765 m_clipMonitor->stop();
3766 m_projectMonitor->stop();
3767 DvdWizard w(url, profile, this);
3769 m_projectMonitor->start();
3772 void MainWindow::slotShowTimeline(bool show)
3774 if (show == false) {
3775 m_timelineState = saveState();
3776 centralWidget()->setHidden(true);
3778 centralWidget()->setHidden(false);
3779 restoreState(m_timelineState);
3783 void MainWindow::slotMaximizeCurrent(bool)
3785 //TODO: is there a way to maximize current widget?
3787 m_timelineState = saveState();
3788 QWidget *par = focusWidget()->parentWidget();
3789 while (par->parentWidget() && par->parentWidget() != this)
3790 par = par->parentWidget();
3791 kDebug() << "CURRENT WIDGET: " << par->objectName();
3794 void MainWindow::loadStabilize()
3796 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3798 Mlt::Profile profile;
3799 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3800 QAction *action=stabMenu->addAction("Videostab (vstab)");
3801 action->setData("videostab");
3802 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3804 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3805 QAction *action=stabMenu->addAction("Videostab (transcode)");
3806 action->setData("videostab2");
3807 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3813 void MainWindow::loadTranscoders()
3815 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3818 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3819 KConfigGroup transConfig(config, "Transcoding");
3821 QMap< QString, QString > profiles = transConfig.entryMap();
3822 QMapIterator<QString, QString> i(profiles);
3823 while (i.hasNext()) {
3825 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3826 QAction *a = transMenu->addAction(i.key());
3828 if (data.count() > 1)
3829 a->setToolTip(data.at(1));
3830 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3834 void MainWindow::slotStabilize(KUrl::List urls)
3836 QString condition,filtername;
3838 if (urls.isEmpty()) {
3839 QAction *action = qobject_cast<QAction *>(sender());
3841 filtername=action->data().toString();
3842 urls = m_projectList->getConditionalUrls(condition);
3845 if (urls.isEmpty()) {
3846 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3849 Mlt::Profile profile;
3850 Mlt::Filter filter(profile,filtername.toUtf8().data());
3851 ClipStabilize *d=new ClipStabilize(urls,filtername,&filter);
3852 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3857 void MainWindow::slotTranscode(KUrl::List urls)
3862 if (urls.isEmpty()) {
3863 QAction *action = qobject_cast<QAction *>(sender());
3864 QStringList data = action->data().toStringList();
3865 params = data.at(0);
3866 if (data.count() > 1) desc = data.at(1);
3867 if (data.count() > 2) condition = data.at(2);
3868 urls << m_projectList->getConditionalUrls(condition);
3869 urls.removeAll(KUrl());
3871 if (urls.isEmpty()) {
3872 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3875 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3876 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3878 //QProcess::startDetached("ffmpeg", parameters);
3881 void MainWindow::slotTranscodeClip()
3883 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3884 if (urls.isEmpty()) return;
3885 slotTranscode(urls);
3888 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3890 if (m_activeDocument == NULL) return;
3891 QMapIterator<QString, QString> i(props);
3892 while (i.hasNext()) {
3894 m_activeDocument->setDocumentProperty(i.key(), i.value());
3896 m_activeDocument->setModified(true);
3900 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3902 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3904 QString playlistPath;
3907 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3908 QString path = m_renderWidget->getFreeScriptName();
3909 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3910 if (!ok || scriptPath.isEmpty()) return;
3911 scriptPath.prepend(scriptsFolder);
3912 QFile f(scriptPath);
3914 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3917 playlistPath = scriptPath + ".mlt";
3919 KTemporaryFile temp;
3920 temp.setAutoRemove(false);
3921 temp.setSuffix(".mlt");
3923 playlistPath = temp.fileName();
3925 QString playlistContent = m_projectMonitor->sceneList();
3926 if (!chapterFile.isEmpty()) {
3929 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3931 in = m_activeTimeline->inPoint();
3932 out = m_activeTimeline->outPoint();
3935 QDomElement chapters = doc.createElement("chapters");
3936 chapters.setAttribute("fps", m_activeDocument->fps());
3937 doc.appendChild(chapters);
3939 QDomElement guidesxml = m_activeDocument->guidesXml();
3940 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3941 for (int i = 0; i < nodes.count(); i++) {
3942 QDomElement e = nodes.item(i).toElement();
3944 QString comment = e.attribute("comment");
3945 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3946 if (time >= in && time < out) {
3947 if (zoneOnly) time = time - in;
3948 QDomElement chapter = doc.createElement("chapter");
3949 chapters.appendChild(chapter);
3950 chapter.setAttribute("title", comment);
3951 chapter.setAttribute("time", time);
3955 if (chapters.childNodes().count() > 0) {
3956 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3957 // Always insert a guide in pos 0
3958 QDomElement chapter = doc.createElement("chapter");
3959 chapters.insertBefore(chapter, QDomNode());
3960 chapter.setAttribute("title", i18n("Start"));
3961 chapter.setAttribute("time", "0");
3963 // save chapters file
3964 QFile file(chapterFile);
3965 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3966 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3968 file.write(doc.toString().toUtf8());
3969 if (file.error() != QFile::NoError) {
3970 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3977 if (m_renderWidget->automaticAudioExport()) {
3978 exportAudio = m_activeTimeline->checkProjectAudio();
3979 } else exportAudio = m_renderWidget->selectedAudioExport();
3981 // Set playlist audio volume to 100%
3983 doc.setContent(playlistContent);
3984 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3985 if (!tractor.isNull()) {
3986 QDomNodeList props = tractor.elementsByTagName("property");
3987 for (int i = 0; i < props.count(); i++) {
3988 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3989 props.at(i).firstChild().setNodeValue("1");
3995 // Do we want proxy rendering
3996 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3997 QString root = doc.documentElement().attribute("root");
3999 // replace proxy clips with originals
4000 QMap <QString, QString> proxies = m_projectList->getProxies();
4002 QDomNodeList producers = doc.elementsByTagName("producer");
4003 QString producerResource;
4005 for (uint n = 0; n < producers.length(); n++) {
4006 QDomElement e = producers.item(n).toElement();
4007 producerResource = EffectsList::property(e, "resource");
4008 if (producerResource.isEmpty()) continue;
4009 if (!producerResource.startsWith("/")) {
4010 producerResource.prepend(root + "/");
4012 if (producerResource.contains('?')) {
4013 // slowmotion producer
4014 suffix = "?" + producerResource.section('?', 1);
4015 producerResource = producerResource.section('?', 0, 0);
4017 else suffix.clear();
4018 if (!producerResource.isEmpty()) {
4019 if (proxies.contains(producerResource)) {
4020 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4021 // We need to delete the "aspect_ratio" property because proxy clips
4022 // sometimes have different ratio than original clips
4023 EffectsList::removeProperty(e, "aspect_ratio");
4024 EffectsList::removeMetaProperties(e);
4029 /*QMapIterator<QString, QString> i(proxies);
4030 while (i.hasNext()) {
4032 // Replace all keys with their values (proxy path with original path)
4033 QString key = i.key();
4034 playlistContent.replace(key, i.value());
4035 if (!root.isEmpty() && key.startsWith(root)) {
4036 // in case the resource path in MLT playlist is relative
4037 key.remove(0, root.count() + 1);
4038 playlistContent.replace(key, i.value());
4042 playlistContent = doc.toString();
4044 // Do save scenelist
4045 QFile file(playlistPath);
4046 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4047 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4050 file.write(playlistContent.toUtf8());
4051 if (file.error() != QFile::NoError) {
4052 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4057 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
4060 void MainWindow::slotUpdateTimecodeFormat(int ix)
4062 KdenliveSettings::setFrametimecode(ix == 1);
4063 m_clipMonitor->updateTimecodeFormat();
4064 m_projectMonitor->updateTimecodeFormat();
4065 m_transitionConfig->updateTimecodeFormat();
4066 m_effectStack->updateTimecodeFormat();
4067 //m_activeTimeline->projectView()->clearSelection();
4068 m_activeTimeline->updateRuler();
4071 void MainWindow::slotRemoveFocus()
4073 statusBar()->setFocus();
4074 statusBar()->clearFocus();
4077 void MainWindow::slotRevert()
4079 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;
4080 KUrl url = m_activeDocument->url();
4081 if (closeCurrentDocument(false))
4082 doOpenFile(url, NULL);
4086 void MainWindow::slotShutdown()
4088 if (m_activeDocument) m_activeDocument->setModified(false);
4090 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4091 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4092 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4093 smserver.call("logout", 1, 2, 2);
4094 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4095 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4096 smserver.call("Shutdown");
4100 void MainWindow::slotUpdateTrackInfo()
4102 if (m_activeDocument)
4103 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4106 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4108 // Load the theme file
4110 if (action == NULL) theme = themename;
4111 else theme = action->data().toString();
4112 KdenliveSettings::setColortheme(theme);
4113 // Make palette for all widgets.
4114 QPalette plt = kapp->palette();
4115 if (theme.isEmpty()) {
4116 plt = QApplication::desktop()->palette();
4118 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4120 #if KDE_IS_VERSION(4,6,3)
4121 plt = KGlobalSettings::createNewApplicationPalette(config);
4123 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4124 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4125 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4126 QPalette::Disabled };
4127 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4128 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4130 for ( int i = 0; i < 3 ; i++ ) {
4131 QPalette::ColorGroup state = states[i];
4132 KColorScheme schemeView(state, KColorScheme::View, config);
4133 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4134 KColorScheme schemeButton(state, KColorScheme::Button, config);
4135 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4137 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4138 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4139 plt.setBrush( state, QPalette::Base, schemeView.background() );
4140 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4141 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4142 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4143 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4144 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4145 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4146 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4148 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4149 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4150 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4151 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4152 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4154 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4155 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4156 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4161 kapp->setPalette(plt);
4162 const QObjectList children = statusBar()->children();
4164 foreach(QObject * child, children) {
4165 if (child->isWidgetType())
4166 ((QWidget*)child)->setPalette(plt);
4167 const QObjectList subchildren = child->children();
4168 foreach(QObject * subchild, subchildren) {
4169 if (subchild->isWidgetType())
4170 ((QWidget*)subchild)->setPalette(plt);
4173 if (m_activeTimeline) {
4174 m_activeTimeline->projectView()->updatePalette();
4179 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4181 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4182 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4183 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4184 const QSize bitsSize(24, 2);
4185 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4186 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4188 QPixmap pixmap(23, 16);
4189 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4191 KConfigGroup group(config, "WM");
4192 QPainter p(&pixmap);
4193 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4194 p.fillRect(1, 1, 7, 7, windowScheme.background());
4195 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4197 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4198 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4199 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4201 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4202 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4204 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4205 p.fillRect(1, 8, 7, 7, viewScheme.background());
4206 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4208 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4209 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4210 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4212 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4213 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4219 void MainWindow::slotSwitchMonitors()
4221 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4222 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4223 else m_projectList->focusTree();
4226 void MainWindow::slotSwitchFullscreen()
4228 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4229 else m_clipMonitor->slotSwitchFullScreen();
4232 void MainWindow::slotInsertZoneToTree()
4234 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4235 QStringList info = m_clipMonitor->getZoneInfo();
4236 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4239 void MainWindow::slotInsertZoneToTimeline()
4241 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4242 QStringList info = m_clipMonitor->getZoneInfo();
4243 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4247 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4249 if (m_activeDocument && m_activeTimeline) {
4250 if (!ids.isEmpty()) {
4251 for (int i = 0; i < ids.size(); ++i) {
4252 m_activeTimeline->slotDeleteClip(ids.at(i));
4254 m_activeDocument->clipManager()->slotDeleteClips(ids);
4256 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4257 m_activeDocument->setModified(true);
4261 void MainWindow::slotShowTitleBars(bool show)
4263 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4264 for (int i = 0; i < docks.count(); i++) {
4265 QDockWidget* dock = docks.at(i);
4267 dock->setTitleBarWidget(0);
4269 if (!dock->isFloating()) {
4270 dock->setTitleBarWidget(new QWidget);
4274 KdenliveSettings::setShowtitlebars(show);
4277 void MainWindow::slotSwitchTitles()
4279 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4282 QString MainWindow::getMimeType(bool open)
4284 QString mimetype = "application/x-kdenlive";
4285 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4287 mimetype = "*.kdenlive";
4288 if (open) mimetype.append(" *.tar.gz");
4290 else if (open) mimetype.append(" application/x-compressed-tar");
4294 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4297 m_projectMonitor->render->sendFrameForAnalysis = true;
4300 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4301 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4308 qDebug() << "Any scope accepting new frames? " << request;
4311 m_projectMonitor->render->sendFrameForAnalysis = false;
4315 void MainWindow::slotUpdateGfxScopeFrameRequest()
4317 // We need a delay to make sure widgets are hidden after a close event for example
4318 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4321 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4324 bool request = false;
4325 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4326 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4327 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4333 if (!m_projectMonitor->effectSceneDisplayed()) {
4334 m_projectMonitor->render->sendFrameForAnalysis = false;
4336 m_clipMonitor->render->sendFrameForAnalysis = false;
4338 m_recMonitor->analyseFrames(false);
4340 m_projectMonitor->render->sendFrameForAnalysis = true;
4341 m_clipMonitor->render->sendFrameForAnalysis = true;
4343 m_recMonitor->analyseFrames(true);
4347 void MainWindow::slotUpdateAudioScopeFrameRequest()
4349 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4352 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4354 bool request = false;
4355 for (int i = 0; i < m_audioScopesList.count(); i++) {
4356 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4357 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4362 // Handle audio signal separately (no common interface)
4363 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4364 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4368 qDebug() << "Scopes Requesting Audio data: " << request;
4370 KdenliveSettings::setMonitor_audio(request);
4371 m_monitorManager->slotUpdateAudioMonitoring();
4374 void MainWindow::slotUpdateColorScopes()
4376 bool request = false;
4377 kDebug()<<"// UPDATE SCOPES";
4378 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4379 // Check if we need the renderer to send a new frame for update
4380 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4381 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4383 if (request && m_monitorManager->activeRenderer()) {
4384 m_monitorManager->activeRenderer()->sendFrameUpdate();
4388 void MainWindow::slotClearColorScopes()
4390 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4391 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4395 void MainWindow::slotOpenStopmotion()
4397 if (m_stopmotion == NULL) {
4398 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4399 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4400 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4401 // Check if we need the renderer to send a new frame for update
4402 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4403 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4404 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4407 m_stopmotion->show();
4410 void MainWindow::slotDeleteClip(const QString &id)
4412 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4413 for (int i = 0; i < list.size(); ++i) {
4414 list.at(i)->disableClipId(id);
4416 m_projectList->slotDeleteClip(id);
4419 void MainWindow::slotUpdateProxySettings()
4421 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4422 if (KdenliveSettings::enableproxy())
4423 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4424 m_projectList->updateProxyConfig();
4427 void MainWindow::slotInsertNotesTimecode()
4429 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4430 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4431 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4434 void MainWindow::slotArchiveProject()
4436 QList <DocClipBase*> list = m_projectList->documentClipList();
4437 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4438 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4443 void MainWindow::slotOpenBackupDialog(const KUrl url)
4448 kDebug()<<"// BACKUP URL: "<<url.path();
4449 if (!url.isEmpty()) {
4450 // we could not open the project file, guess where the backups are
4451 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4455 projectFolder = m_activeDocument->projectFolder();
4456 projectFile = m_activeDocument->url();
4457 projectId = m_activeDocument->getDocumentProperty("documentid");
4460 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4461 if (dia->exec() == QDialog::Accepted) {
4462 QString requestedBackup = dia->selectedFile();
4463 m_activeDocument->backupLastSavedVersion(projectFile.path());
4464 closeCurrentDocument(false);
4465 doOpenFile(KUrl(requestedBackup), NULL);
4466 m_activeDocument->setUrl(projectFile);
4467 m_activeDocument->setModified(true);
4468 setCaption(m_activeDocument->description());
4473 void MainWindow::slotElapsedTime()
4475 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4478 #include "mainwindow.moc"