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 "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audioscopes/audiospectrum.h"
63 #include "audioscopes/spectrogram.h"
64 #include "archivewidget.h"
65 #include "databackup/backupwidget.h"
66 #include "utils/resourcewidget.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)));
235 connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
237 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
238 m_projectMonitorDock->setObjectName("project_monitor");
239 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
240 m_projectMonitorDock->setWidget(m_projectMonitor);
243 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
244 m_recMonitorDock->setObjectName("record_monitor");
245 m_recMonitor = new RecMonitor("record", m_monitorManager);
246 m_recMonitorDock->setWidget(m_recMonitor);
247 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
248 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
249 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
251 #endif /* ! Q_WS_MAC */
252 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
254 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
255 m_notesDock->setObjectName("notes_widget");
256 m_notesWidget = new NotesWidget();
257 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
258 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
260 m_notesWidget->setTabChangesFocus(true);
261 #if KDE_IS_VERSION(4,4,0)
262 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
264 m_notesDock->setWidget(m_notesWidget);
265 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
267 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
268 m_effectStackDock->setObjectName("effect_stack");
269 m_effectStack = new EffectStackView(m_projectMonitor);
270 m_effectStackDock->setWidget(m_effectStack);
271 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
272 connect(m_effectStack, SIGNAL(startFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&)), m_projectList, SLOT(slotStartFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&)));
274 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
275 m_transitionConfigDock->setObjectName("transition");
276 m_transitionConfig = new TransitionSettings(m_projectMonitor);
277 m_transitionConfigDock->setWidget(m_transitionConfig);
278 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
280 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
281 m_effectListDock->setObjectName("effect_list");
282 m_effectList = new EffectsListView();
283 m_effectListDock->setWidget(m_effectList);
284 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
286 m_vectorscope = new Vectorscope(m_monitorManager);
287 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
288 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
289 m_vectorscopeDock->setWidget(m_vectorscope);
290 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
291 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
292 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
293 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
294 m_gfxScopesList.append(m_vectorscopeDock);
296 m_waveform = new Waveform(m_monitorManager);
297 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
298 m_waveformDock->setObjectName(m_waveform->widgetName());
299 m_waveformDock->setWidget(m_waveform);
300 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
301 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
302 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
303 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
304 m_gfxScopesList.append(m_waveformDock);
306 m_RGBParade = new RGBParade(m_monitorManager);
307 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
308 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
309 m_RGBParadeDock->setWidget(m_RGBParade);
310 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
311 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
312 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
313 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
314 m_gfxScopesList.append(m_RGBParadeDock);
316 m_histogram = new Histogram(m_monitorManager);
317 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
318 m_histogramDock->setObjectName(m_histogram->widgetName());
319 m_histogramDock->setWidget(m_histogram);
320 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
321 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
322 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
323 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
324 m_gfxScopesList.append(m_histogramDock);
327 m_audiosignal = new AudioSignal;
328 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
329 m_audiosignalDock->setObjectName("audiosignal");
330 m_audiosignalDock->setWidget(m_audiosignal);
331 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
332 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
333 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
335 m_audioSpectrum = new AudioSpectrum();
336 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
337 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
338 m_audioSpectrumDock->setWidget(m_audioSpectrum);
339 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
340 m_audioScopesList.append(m_audioSpectrum);
341 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
342 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
344 m_spectrogram = new Spectrogram();
345 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
346 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
347 m_spectrogramDock->setWidget(m_spectrogram);
348 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
349 m_audioScopesList.append(m_spectrogram);
350 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
351 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
353 // Connect the audio signal to the audio scope slots
355 if (m_projectMonitor) {
356 qDebug() << "project monitor connected";
357 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
358 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
359 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
360 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
361 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
362 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
365 qDebug() << "clip monitor connected";
366 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
367 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
368 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
369 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
370 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
371 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
373 // Ensure connections were set up correctly
378 // Add monitors here to keep them at the right of the window
379 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
380 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
382 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
385 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
386 m_undoViewDock->setObjectName("undo_history");
387 m_undoView = new QUndoView();
388 m_undoView->setCleanIcon(KIcon("edit-clear"));
389 m_undoView->setEmptyLabel(i18n("Clean"));
390 m_undoViewDock->setWidget(m_undoView);
391 m_undoView->setGroup(m_commandStack);
392 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
396 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
399 // Close non-general docks for the initial layout
400 // only show important ones
401 m_histogramDock->close();
402 m_RGBParadeDock->close();
403 m_waveformDock->close();
404 m_vectorscopeDock->close();
406 m_audioSpectrumDock->close();
407 m_spectrogramDock->close();
408 m_audiosignalDock->close();
410 m_undoViewDock->close();
414 /// Tabify Widgets ///
415 tabifyDockWidget(m_effectListDock, m_effectStackDock);
416 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
417 tabifyDockWidget(m_projectListDock, m_notesDock);
419 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
421 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
427 setCentralWidget(m_timelineArea);
430 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
432 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
433 m_fileRevert->setEnabled(false);
435 // Prepare layout actions
436 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
437 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
438 for (int i = 1; i < 5; i++) {
439 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
440 load->setData("_" + QString::number(i));
441 layoutActions->addAction("load_layout" + QString::number(i), load);
442 m_loadLayout->addAction(load);
443 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
444 save->setData("_" + QString::number(i));
445 layoutActions->addAction("save_layout" + QString::number(i), save);
447 layoutActions->addAction("load_layouts", m_loadLayout);
448 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
451 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
452 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
453 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
454 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
455 m_stopmotion_actions->addAction("stopmotion_capture", action);
456 action = new KAction(i18n("Switch live / captured frame"), this);
457 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
458 m_stopmotion_actions->addAction("stopmotion_switch", action);
459 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
460 action->setCheckable(true);
461 action->setChecked(false);
462 m_stopmotion_actions->addAction("stopmotion_overlay", action);
464 // Build effects menu
465 m_effectsMenu = new QMenu(i18n("Add Effect"));
466 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
467 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
468 m_effectsActionCollection->readSettings();
472 // Find QDockWidget tab bars and show / hide widget title bars on right click
473 QList <QTabBar *> tabs = findChildren<QTabBar *>();
474 for (int i = 0; i < tabs.count(); i++) {
475 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
476 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
479 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
480 guiFactory()->addClient(sp);*/
481 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
482 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
485 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
487 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
490 // Load layout names from config file
497 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
498 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
500 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
501 clipInTimeline->setIcon(KIcon("go-jump"));
502 QHash<QString,QMenu*> menus;
503 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
504 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
505 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
506 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
507 menus.insert("inTimelineMenu",clipInTimeline);
508 m_projectList->setupGeneratorMenu(menus);
510 // build themes menus
511 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
512 QActionGroup *themegroup = new QActionGroup(this);
513 themegroup->setExclusive(true);
514 action = new KAction(i18n("Default"), this);
515 action->setCheckable(true);
516 themegroup->addAction(action);
517 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
519 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
521 for (int i = 0; i < schemeFiles.size(); ++i) {
523 const QString filename = schemeFiles.at(i);
524 const QFileInfo info(filename);
527 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
528 QIcon icon = createSchemePreviewIcon(config);
529 KConfigGroup group(config, "General");
530 const QString name = group.readEntry("Name", info.baseName());
531 action = new KAction(name, this);
532 action->setData(filename);
533 action->setIcon(icon);
534 action->setCheckable(true);
535 themegroup->addAction(action);
536 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
539 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
540 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
541 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
544 action = new QAction(fi.fileName(), this);
545 action->setData(*it);
546 action->setCheckable(true);
547 themegroup->addAction(action);
548 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
550 themesMenu->addActions(themegroup->actions());
551 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
553 // Setup and fill effects and transitions menus.
556 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
557 m->addActions(m_effectsMenu->actions());
560 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
561 for (int i = 0; i < transitions.count(); ++i)
562 m_transitionsMenu->addAction(m_transitions[i]);
564 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
565 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
566 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
568 m_effectStack->setMenu(m_effectsMenu);
570 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
571 const QList<QAction *> viewActions = createPopupMenu()->actions();
572 viewMenu->insertActions(NULL, viewActions);
574 m_timelineContextMenu = new QMenu(this);
575 m_timelineContextClipMenu = new QMenu(this);
576 m_timelineContextTransitionMenu = new QMenu(this);
578 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
579 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
580 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
582 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
583 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
584 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
585 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
586 m_timelineContextClipMenu->addSeparator();
587 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
588 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
589 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
590 m_timelineContextClipMenu->addSeparator();
591 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
592 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
593 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
594 m_timelineContextClipMenu->addSeparator();
596 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
597 m_timelineContextClipMenu->addMenu(markersMenu);
598 m_timelineContextClipMenu->addSeparator();
599 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
600 m_timelineContextClipMenu->addMenu(m_effectsMenu);
602 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
603 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
604 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
606 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
608 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
609 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
610 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
611 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
612 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
613 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
615 slotConnectMonitors();
617 // Open or create a file. Command line argument passed in Url has
618 // precedence, then "openlastproject", then just a plain empty file.
619 // If opening Url fails, openlastproject will _not_ be used.
620 if (!Url.isEmpty()) {
621 // delay loading so that the window shows up
623 QTimer::singleShot(500, this, SLOT(openFile()));
624 } else if (KdenliveSettings::openlastproject()) {
625 QTimer::singleShot(500, this, SLOT(openLastFile()));
626 } else { //if (m_timelineArea->count() == 0) {
630 if (!clipsToLoad.isEmpty() && m_activeDocument) {
631 QStringList list = clipsToLoad.split(',');
633 foreach(QString path, list) {
634 kDebug() << QDir::current().absoluteFilePath(path);
635 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
637 m_projectList->slotAddClip(urls);
640 #ifdef USE_JOGSHUTTLE
641 activateShuttleDevice();
643 m_projectListDock->raise();
645 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
646 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
648 // Populate encoding profiles
649 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
650 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
651 KConfigGroup group(&conf, "proxy");
652 QMap< QString, QString > values = group.entryMap();
653 QMapIterator<QString, QString> i(values);
656 QString data = i.value();
657 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
658 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
661 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
662 KConfigGroup group(&conf, "video4linux");
663 QMap< QString, QString > values = group.entryMap();
664 QMapIterator<QString, QString> i(values);
667 QString data = i.value();
668 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
669 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
672 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
673 KConfigGroup group(&conf, "decklink");
674 QMap< QString, QString > values = group.entryMap();
675 QMapIterator<QString, QString> i(values);
678 QString data = i.value();
679 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
680 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
685 MainWindow::~MainWindow()
690 m_effectStack->slotClipItemSelected(NULL, 0);
691 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
693 if (m_projectMonitor) m_projectMonitor->stop();
694 if (m_clipMonitor) m_clipMonitor->stop();
696 delete m_activeTimeline;
697 delete m_effectStack;
698 delete m_transitionConfig;
699 delete m_activeDocument;
700 delete m_projectMonitor;
701 delete m_clipMonitor;
702 delete m_shortcutRemoveFocus;
703 delete[] m_transitions;
704 Mlt::Factory::close();
708 bool MainWindow::queryClose()
710 if (m_renderWidget) {
711 int waitingJobs = m_renderWidget->waitingJobsCount();
712 if (waitingJobs > 0) {
713 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")))) {
714 case KMessageBox::Yes :
715 // create script with waiting jobs and start it
716 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
718 case KMessageBox::No :
719 // Don't do anything, jobs will be deleted
727 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
728 // warn the user to save if document is modified and we have clips in our project list
729 if (m_activeDocument && m_activeDocument->isModified() &&
730 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
731 !m_projectList->documentClipList().isEmpty())) {
735 if (m_activeDocument->url().fileName().isEmpty())
736 message = i18n("Save changes to document?");
738 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
739 switch (KMessageBox::warningYesNoCancel(this, message)) {
740 case KMessageBox::Yes :
741 // save document here. If saving fails, return false;
743 case KMessageBox::No :
744 // User does not want to save the changes, clear recovery files
745 m_activeDocument->m_autosave->resize(0);
754 void MainWindow::loadPlugins()
756 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
757 populateMenus(plugin);
760 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
762 filters << "libkdenlive*";
763 foreach(const QString & folder, directories) {
764 kDebug() << "Parsing plugin folder: " << folder;
765 QDir pluginsDir(folder);
766 foreach(const QString & fileName,
767 pluginsDir.entryList(filters, QDir::Files)) {
769 * Avoid loading the same plugin twice when there is more than one
772 if (!m_pluginFileNames.contains(fileName)) {
773 kDebug() << "Found plugin: " << fileName;
774 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
775 QObject *plugin = loader.instance();
777 populateMenus(plugin);
778 m_pluginFileNames += fileName;
780 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
786 void MainWindow::populateMenus(QObject *plugin)
788 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
789 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
791 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
795 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
796 QMenu *menu, const char *member,
797 QActionGroup *actionGroup)
799 kDebug() << "// ADD to MENU" << texts;
800 foreach(const QString & text, texts) {
801 QAction *action = new QAction(text, plugin);
802 action->setData(text);
803 connect(action, SIGNAL(triggered()), this, member);
804 menu->addAction(action);
807 action->setCheckable(true);
808 actionGroup->addAction(action);
813 void MainWindow::aboutPlugins()
815 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
820 void MainWindow::generateClip()
822 QAction *action = qobject_cast<QAction *>(sender());
823 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
825 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
826 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
827 if (!clipUrl.isEmpty()) {
828 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
832 void MainWindow::saveProperties(KConfigGroup &config)
834 // save properties here,used by session management
836 KMainWindow::saveProperties(config);
840 void MainWindow::readProperties(const KConfigGroup &config)
842 // read properties here,used by session management
843 KMainWindow::readProperties(config);
844 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
845 openFile(KUrl(Lastproject));
848 void MainWindow::slotReloadEffects()
850 initEffects::parseCustomEffectsFile();
851 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
854 #ifdef USE_JOGSHUTTLE
855 void MainWindow::activateShuttleDevice()
861 if (KdenliveSettings::enableshuttle() == false) return;
863 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
864 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
866 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
867 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
868 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
869 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
870 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
872 #endif /* USE_JOGSHUTTLE */
874 void MainWindow::slotDoAction(const QString& action_name)
876 QAction* action = actionCollection()->action(action_name);
878 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
884 void MainWindow::configureNotifications()
886 KNotifyConfigWidget::configure(this);
889 void MainWindow::slotFullScreen()
891 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
894 void MainWindow::slotAddEffect(const QDomElement effect)
896 if (!m_activeDocument) return;
897 if (effect.isNull()) {
898 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
901 QDomElement effectToAdd = effect.cloneNode().toElement();
903 int ix = m_effectStack->isTrackMode(&ok);
904 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
905 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
908 void MainWindow::slotUpdateClip(const QString &id)
910 if (!m_activeDocument) return;
911 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
913 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
914 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
915 Mlt::Producer *monitorProducer = clip->getCloneProducer();
916 m_clipMonitor->updateClipProducer(monitorProducer);
918 clip->cleanupProducers();
921 void MainWindow::slotConnectMonitors()
923 m_projectList->setRenderer(m_projectMonitor->render);
924 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
925 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
926 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
927 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
928 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
929 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)));
931 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
933 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
935 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
937 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
938 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
940 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
942 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
943 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
946 void MainWindow::slotAdjustClipMonitor()
948 m_clipMonitorDock->updateGeometry();
949 m_clipMonitorDock->adjustSize();
950 m_clipMonitor->resetSize();
953 void MainWindow::slotAdjustProjectMonitor()
955 m_projectMonitorDock->updateGeometry();
956 m_projectMonitorDock->adjustSize();
957 m_projectMonitor->resetSize();
961 class NameGrabbingKActionCollection {
963 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
964 : m_collection(collection), m_action_names(action_names) {
965 m_action_names.clear();
967 KAction* addAction(const QString& action_name) {
968 m_action_names << action_name;
969 return m_collection->addAction(action_name);
971 void addAction(const QString& action_name, QAction* action) {
972 m_action_names << action_name;
973 m_collection->addAction(action_name, action);
975 operator KActionCollection*() { return m_collection; }
976 const QStringList& actionNames() const { return m_action_names; }
978 KActionCollection* m_collection;
979 QStringList& m_action_names;
982 void MainWindow::setupActions()
985 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
986 m_timecodeFormat = new KComboBox(this);
987 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
988 m_timecodeFormat->addItem(i18n("Frames"));
989 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
990 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
992 m_statusProgressBar = new QProgressBar(this);
993 m_statusProgressBar->setMinimum(0);
994 m_statusProgressBar->setMaximum(100);
995 m_statusProgressBar->setMaximumWidth(150);
996 m_statusProgressBar->setVisible(false);
998 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
999 toolbar->setMovable(false);
1000 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
1001 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
1002 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
1003 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
1004 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
1005 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());
1006 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
1008 //create edit mode buttons
1009 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
1010 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
1011 toolbar->addAction(m_normalEditTool);
1012 m_normalEditTool->setCheckable(true);
1013 m_normalEditTool->setChecked(true);
1015 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
1016 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
1017 toolbar->addAction(m_overwriteEditTool);
1018 m_overwriteEditTool->setCheckable(true);
1019 m_overwriteEditTool->setChecked(false);
1021 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
1022 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
1023 toolbar->addAction(m_insertEditTool);
1024 m_insertEditTool->setCheckable(true);
1025 m_insertEditTool->setChecked(false);
1026 // not implemented yet
1027 m_insertEditTool->setEnabled(false);
1029 QActionGroup *editGroup = new QActionGroup(this);
1030 editGroup->addAction(m_normalEditTool);
1031 editGroup->addAction(m_overwriteEditTool);
1032 editGroup->addAction(m_insertEditTool);
1033 editGroup->setExclusive(true);
1034 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
1035 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1037 toolbar->addSeparator();
1039 // create tools buttons
1040 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1041 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1042 toolbar->addAction(m_buttonSelectTool);
1043 m_buttonSelectTool->setCheckable(true);
1044 m_buttonSelectTool->setChecked(true);
1046 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1047 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1048 toolbar->addAction(m_buttonRazorTool);
1049 m_buttonRazorTool->setCheckable(true);
1050 m_buttonRazorTool->setChecked(false);
1052 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1053 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1054 toolbar->addAction(m_buttonSpacerTool);
1055 m_buttonSpacerTool->setCheckable(true);
1056 m_buttonSpacerTool->setChecked(false);
1058 QActionGroup *toolGroup = new QActionGroup(this);
1059 toolGroup->addAction(m_buttonSelectTool);
1060 toolGroup->addAction(m_buttonRazorTool);
1061 toolGroup->addAction(m_buttonSpacerTool);
1062 toolGroup->setExclusive(true);
1063 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1065 QWidget * actionWidget;
1066 int max = toolbar->iconSizeDefault() + 2;
1067 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1068 actionWidget->setMaximumWidth(max);
1069 actionWidget->setMaximumHeight(max - 4);
1071 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1072 actionWidget->setMaximumWidth(max);
1073 actionWidget->setMaximumHeight(max - 4);
1075 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1076 actionWidget->setMaximumWidth(max);
1077 actionWidget->setMaximumHeight(max - 4);
1079 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1080 actionWidget->setMaximumWidth(max);
1081 actionWidget->setMaximumHeight(max - 4);
1083 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1084 actionWidget->setMaximumWidth(max);
1085 actionWidget->setMaximumHeight(max - 4);
1087 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1088 actionWidget->setMaximumWidth(max);
1089 actionWidget->setMaximumHeight(max - 4);
1091 toolbar->setStyleSheet(style1);
1092 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1094 toolbar->addSeparator();
1095 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1096 toolbar->addAction(m_buttonFitZoom);
1097 m_buttonFitZoom->setCheckable(false);
1099 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1100 toolbar->addAction(m_zoomOut);
1101 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1103 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1104 m_zoomSlider->setMaximum(13);
1105 m_zoomSlider->setPageStep(1);
1106 m_zoomSlider->setInvertedAppearance(true);
1108 m_zoomSlider->setMaximumWidth(150);
1109 m_zoomSlider->setMinimumWidth(100);
1110 toolbar->addWidget(m_zoomSlider);
1112 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1113 toolbar->addAction(m_zoomIn);
1114 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1116 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1117 actionWidget->setMaximumWidth(max);
1118 actionWidget->setMaximumHeight(max - 4);
1119 actionWidget->setStyleSheet(styleBorderless);
1121 actionWidget = toolbar->widgetForAction(m_zoomIn);
1122 actionWidget->setMaximumWidth(max);
1123 actionWidget->setMaximumHeight(max - 4);
1124 actionWidget->setStyleSheet(styleBorderless);
1126 actionWidget = toolbar->widgetForAction(m_zoomOut);
1127 actionWidget->setMaximumWidth(max);
1128 actionWidget->setMaximumHeight(max - 4);
1129 actionWidget->setStyleSheet(styleBorderless);
1131 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1132 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1133 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1134 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1135 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1137 toolbar->addSeparator();
1139 //create automatic audio split button
1140 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1141 toolbar->addAction(m_buttonAutomaticSplitAudio);
1142 m_buttonAutomaticSplitAudio->setCheckable(true);
1143 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1144 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1146 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1147 toolbar->addAction(m_buttonVideoThumbs);
1148 m_buttonVideoThumbs->setCheckable(true);
1149 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1150 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1152 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1153 toolbar->addAction(m_buttonAudioThumbs);
1154 m_buttonAudioThumbs->setCheckable(true);
1155 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1156 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1158 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1159 toolbar->addAction(m_buttonShowMarkers);
1160 m_buttonShowMarkers->setCheckable(true);
1161 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1162 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1164 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1165 toolbar->addAction(m_buttonSnap);
1166 m_buttonSnap->setCheckable(true);
1167 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1168 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1170 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1171 actionWidget->setMaximumWidth(max);
1172 actionWidget->setMaximumHeight(max - 4);
1174 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1175 actionWidget->setMaximumWidth(max);
1176 actionWidget->setMaximumHeight(max - 4);
1178 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1179 actionWidget->setMaximumWidth(max);
1180 actionWidget->setMaximumHeight(max - 4);
1182 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1183 actionWidget->setMaximumWidth(max);
1184 actionWidget->setMaximumHeight(max - 4);
1186 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1187 actionWidget->setMaximumWidth(max);
1188 actionWidget->setMaximumHeight(max - 4);
1190 m_messageLabel = new StatusBarMessageLabel(this);
1191 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1193 statusBar()->addWidget(m_messageLabel, 10);
1194 statusBar()->addWidget(m_statusProgressBar, 0);
1195 statusBar()->addPermanentWidget(toolbar);
1196 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1197 statusBar()->addPermanentWidget(m_timecodeFormat);
1198 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1200 collection.addAction("normal_mode", m_normalEditTool);
1201 collection.addAction("overwrite_mode", m_overwriteEditTool);
1202 collection.addAction("insert_mode", m_insertEditTool);
1203 collection.addAction("select_tool", m_buttonSelectTool);
1204 collection.addAction("razor_tool", m_buttonRazorTool);
1205 collection.addAction("spacer_tool", m_buttonSpacerTool);
1207 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1208 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1209 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1210 collection.addAction("show_markers", m_buttonShowMarkers);
1211 collection.addAction("snap", m_buttonSnap);
1212 collection.addAction("zoom_fit", m_buttonFitZoom);
1213 collection.addAction("zoom_in", m_zoomIn);
1214 collection.addAction("zoom_out", m_zoomOut);
1216 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1217 collection.addAction("project_find", m_projectSearch);
1218 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1219 m_projectSearch->setShortcut(Qt::Key_Slash);
1221 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1222 collection.addAction("project_find_next", m_projectSearchNext);
1223 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1224 m_projectSearchNext->setShortcut(Qt::Key_F3);
1225 m_projectSearchNext->setEnabled(false);
1227 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1228 collection.addAction("manage_profiles", profilesAction);
1229 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1231 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1232 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1233 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1234 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1236 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1237 collection.addAction("run_wizard", wizAction);
1238 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1240 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1241 collection.addAction("project_settings", projectAction);
1242 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1244 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1245 collection.addAction("open_backup", backupAction);
1246 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1248 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1249 collection.addAction("project_render", projectRender);
1250 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1251 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1253 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1254 collection.addAction("project_clean", projectClean);
1255 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1257 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1258 collection.addAction("project_adjust_profile", projectAdjust);
1259 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1261 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1262 KShortcut playShortcut;
1263 playShortcut.setPrimary(Qt::Key_Space);
1264 playShortcut.setAlternate(Qt::Key_K);
1265 monitorPlay->setShortcut(playShortcut);
1266 collection.addAction("monitor_play", monitorPlay);
1267 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1269 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1270 collection.addAction("monitor_pause", monitorPause);
1271 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1273 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1274 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1275 collection.addAction("monitor_play_zone", m_playZone);
1276 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1278 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1279 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1280 collection.addAction("monitor_loop_zone", m_loopZone);
1281 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1283 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1284 m_loopClip->setEnabled(false);
1285 collection.addAction("monitor_loop_clip", m_loopClip);
1286 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1288 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1289 collection.addAction("dvd_wizard", dvdWizard);
1290 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1292 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1293 collection.addAction("transcode_clip", transcodeClip);
1294 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1296 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1297 collection.addAction("archive_project", archiveProject);
1298 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1301 KAction *markIn = collection.addAction("mark_in");
1302 markIn->setText(i18n("Set Zone In"));
1303 markIn->setShortcut(Qt::Key_I);
1304 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1306 KAction *markOut = collection.addAction("mark_out");
1307 markOut->setText(i18n("Set Zone Out"));
1308 markOut->setShortcut(Qt::Key_O);
1309 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1311 KAction *switchMon = collection.addAction("switch_monitor");
1312 switchMon->setText(i18n("Switch monitor"));
1313 switchMon->setShortcut(Qt::Key_T);
1314 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1316 KAction *fullMon = collection.addAction("monitor_fullscreen");
1317 fullMon->setText(i18n("Switch monitor fullscreen"));
1318 fullMon->setIcon(KIcon("view-fullscreen"));
1319 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1321 KAction *insertTree = collection.addAction("insert_project_tree");
1322 insertTree->setText(i18n("Insert zone in project tree"));
1323 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1324 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1326 KAction *insertTimeline = collection.addAction("insert_timeline");
1327 insertTimeline->setText(i18n("Insert zone in timeline"));
1328 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1329 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1331 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1332 collection.addAction("resize_timeline_clip_start", resizeStart);
1333 resizeStart->setShortcut(Qt::Key_1);
1334 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1336 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1337 collection.addAction("resize_timeline_clip_end", resizeEnd);
1338 resizeEnd->setShortcut(Qt::Key_2);
1339 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1341 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1342 monitorSeekBackward->setShortcut(Qt::Key_J);
1343 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1344 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1346 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1347 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1348 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1349 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1351 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1352 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1353 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1354 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1356 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1357 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1358 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1359 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1361 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1362 monitorSeekForward->setShortcut(Qt::Key_L);
1363 collection.addAction("monitor_seek_forward", monitorSeekForward);
1364 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1366 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1367 clipStart->setShortcut(Qt::Key_Home);
1368 collection.addAction("seek_clip_start", clipStart);
1369 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1371 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1372 clipEnd->setShortcut(Qt::Key_End);
1373 collection.addAction("seek_clip_end", clipEnd);
1374 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1376 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1377 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1378 collection.addAction("seek_zone_start", zoneStart);
1379 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1381 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1382 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1383 collection.addAction("seek_zone_end", zoneEnd);
1384 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1386 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1387 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1388 collection.addAction("seek_start", projectStart);
1389 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1391 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1392 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1393 collection.addAction("seek_end", projectEnd);
1394 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1396 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1397 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1398 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1399 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1401 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1402 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1403 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1404 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1406 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1407 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1408 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1409 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1411 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1412 deleteItem->setShortcut(Qt::Key_Delete);
1413 collection.addAction("delete_timeline_clip", deleteItem);
1414 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1416 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1417 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1418 editTimelineClipSpeed->setData("change_speed");
1419 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1421 KAction *stickTransition = collection.addAction("auto_transition");
1422 stickTransition->setData(QString("auto"));
1423 stickTransition->setCheckable(true);
1424 stickTransition->setEnabled(false);
1425 stickTransition->setText(i18n("Automatic Transition"));
1426 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1428 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1429 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1430 collection.addAction("group_clip", groupClip);
1431 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1433 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1434 collection.addAction("ungroup_clip", ungroupClip);
1435 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1436 ungroupClip->setData("ungroup_clip");
1437 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1439 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1440 collection.addAction("edit_item_duration", editItemDuration);
1441 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1443 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1444 collection.addAction("clip_in_project_tree", clipInProjectTree);
1445 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1447 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1448 collection.addAction("clip_to_project_tree", clipToProjectTree);
1449 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1451 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1452 insertOvertwrite->setShortcut(Qt::Key_V);
1453 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1454 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1456 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1457 selectTimelineClip->setShortcut(Qt::Key_Plus);
1458 collection.addAction("select_timeline_clip", selectTimelineClip);
1459 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1461 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1462 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1463 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1464 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1466 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1467 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1468 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1469 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1471 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1472 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1473 collection.addAction("select_timeline_transition", selectTimelineTransition);
1474 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1476 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1477 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1478 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1479 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1481 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1482 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1483 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1484 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1486 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1487 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1488 collection.addAction("cut_timeline_clip", cutTimelineClip);
1489 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1491 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1492 collection.addAction("add_clip_marker", addClipMarker);
1493 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1495 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1496 collection.addAction("delete_clip_marker", deleteClipMarker);
1497 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1499 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1500 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1501 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1503 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1504 editClipMarker->setData(QString("edit_marker"));
1505 collection.addAction("edit_clip_marker", editClipMarker);
1506 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1508 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1509 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1510 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1511 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1513 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1514 collection.addAction("split_audio", splitAudio);
1515 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1517 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1518 collection.addAction("clip_audio_only", audioOnly);
1519 audioOnly->setData("clip_audio_only");
1520 audioOnly->setCheckable(true);
1522 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1523 collection.addAction("clip_video_only", videoOnly);
1524 videoOnly->setData("clip_video_only");
1525 videoOnly->setCheckable(true);
1527 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1528 collection.addAction("clip_audio_and_video", audioAndVideo);
1529 audioAndVideo->setData("clip_audio_and_video");
1530 audioAndVideo->setCheckable(true);
1532 m_clipTypeGroup = new QActionGroup(this);
1533 m_clipTypeGroup->addAction(audioOnly);
1534 m_clipTypeGroup->addAction(videoOnly);
1535 m_clipTypeGroup->addAction(audioAndVideo);
1536 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1537 m_clipTypeGroup->setEnabled(false);
1539 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1540 collection.addAction("insert_space", insertSpace);
1541 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1543 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1544 collection.addAction("delete_space", removeSpace);
1545 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1547 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1548 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1550 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1551 m_tracksActionCollection->addAction("insert_track", insertTrack);
1552 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1554 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1555 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1556 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1558 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1559 m_tracksActionCollection->addAction("config_tracks", configTracks);
1560 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1562 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1563 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1564 m_tracksActionCollection->addAction("select_track", selectTrack);
1566 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1567 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1568 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1570 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1571 collection.addAction("add_guide", addGuide);
1572 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1574 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1575 collection.addAction("delete_guide", delGuide);
1576 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1578 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1579 collection.addAction("edit_guide", editGuide);
1580 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1582 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1583 collection.addAction("delete_all_guides", delAllGuides);
1584 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1586 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1587 collection.addAction("paste_effects", pasteEffects);
1588 pasteEffects->setData("paste_effects");
1589 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1591 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1592 collection.addAction("show_timeline", showTimeline);
1593 showTimeline->setCheckable(true);
1594 showTimeline->setChecked(true);
1595 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1597 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1598 collection.addAction("show_titlebars", showTitleBar);
1599 showTitleBar->setCheckable(true);
1600 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1601 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1602 slotShowTitleBars(KdenliveSettings::showtitlebars());
1604 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1605 KStandardAction::quit(this, SLOT(close()), collection);
1606 KStandardAction::open(this, SLOT(openFile()), collection);
1607 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1608 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1609 KStandardAction::openNew(this, SLOT(newFile()), collection);
1610 // TODO: make the following connection to slotEditKeys work
1611 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1612 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1613 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1614 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1615 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1616 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1618 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1619 undo->setEnabled(false);
1620 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1622 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1623 redo->setEnabled(false);
1624 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1627 //TODO: Add status tooltip to actions ?
1628 connect(collection, SIGNAL(actionHovered(QAction*)),
1629 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1632 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1633 collection.addAction("add_clip", addClip);
1634 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1636 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1637 collection.addAction("add_color_clip", addColorClip);
1638 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1640 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1641 collection.addAction("add_slide_clip", addSlideClip);
1642 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1644 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1645 collection.addAction("add_text_clip", addTitleClip);
1646 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1648 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1649 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1650 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1652 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1653 collection.addAction("add_folder", addFolderButton);
1654 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1656 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1657 collection.addAction("download_resource", downloadResources);
1658 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1660 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1661 collection.addAction("clip_properties", clipProperties);
1662 clipProperties->setData("clip_properties");
1663 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1664 clipProperties->setEnabled(false);
1666 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1667 collection.addAction("edit_clip", openClip);
1668 openClip->setData("edit_clip");
1669 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1670 openClip->setEnabled(false);
1672 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1673 collection.addAction("delete_clip", deleteClip);
1674 deleteClip->setData("delete_clip");
1675 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1676 deleteClip->setEnabled(false);
1678 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1679 collection.addAction("reload_clip", reloadClip);
1680 reloadClip->setData("reload_clip");
1681 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1682 reloadClip->setEnabled(false);
1684 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1685 collection.addAction("proxy_clip", proxyClip);
1686 proxyClip->setData("proxy_clip");
1687 proxyClip->setCheckable(true);
1688 proxyClip->setChecked(false);
1689 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1691 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1692 collection.addAction("stopmotion", stopMotion);
1693 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1695 QMenu *addClips = new QMenu();
1696 addClips->addAction(addClip);
1697 addClips->addAction(addColorClip);
1698 addClips->addAction(addSlideClip);
1699 addClips->addAction(addTitleClip);
1700 addClips->addAction(addTitleTemplateClip);
1701 addClips->addAction(addFolderButton);
1702 addClips->addAction(downloadResources);
1704 addClips->addAction(reloadClip);
1705 addClips->addAction(proxyClip);
1706 addClips->addAction(clipProperties);
1707 addClips->addAction(openClip);
1708 addClips->addAction(deleteClip);
1709 m_projectList->setupMenu(addClips, addClip);
1711 // Setup effects and transitions actions.
1712 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1713 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1714 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1715 m_transitions = new KAction*[transitions.count()];
1716 for (int i = 0; i < transitions.count(); i++) {
1717 QStringList effectInfo = transitions.effectIdInfo(i);
1718 m_transitions[i] = new KAction(effectInfo.at(0), this);
1719 m_transitions[i]->setData(effectInfo);
1720 m_transitions[i]->setIconVisibleInMenu(false);
1721 QString id = effectInfo.at(2);
1722 if (id.isEmpty()) id = effectInfo.at(1);
1723 transitionActions->addAction("transition_" + id, m_transitions[i]);
1725 //m_effectsActionCollection->readSettings();
1729 void MainWindow::slotDisplayActionMessage(QAction *a)
1731 statusBar()->showMessage(a->data().toString(), 3000);
1734 void MainWindow::loadLayouts()
1736 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1737 if (m_loadLayout == NULL || saveLayout == NULL) return;
1738 KSharedConfigPtr config = KGlobal::config();
1739 KConfigGroup layoutGroup(config, "Layouts");
1740 QStringList entries = layoutGroup.keyList();
1741 QList<QAction *> loadActions = m_loadLayout->actions();
1742 QList<QAction *> saveActions = saveLayout->actions();
1743 for (int i = 1; i < 5; i++) {
1744 // Rename the layouts actions
1745 foreach(const QString & key, entries) {
1746 if (key.endsWith(QString("_%1").arg(i))) {
1747 // Found previously saved layout
1748 QString layoutName = key.section("_", 0, -2);
1749 for (int j = 0; j < loadActions.count(); j++) {
1750 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1751 loadActions[j]->setText(layoutName);
1752 loadActions[j]->setData(key);
1756 for (int j = 0; j < saveActions.count(); j++) {
1757 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1758 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1759 saveActions[j]->setData(key);
1768 void MainWindow::slotLoadLayout(QAction *action)
1770 if (!action) return;
1771 QString layoutId = action->data().toString();
1772 if (layoutId.isEmpty()) return;
1773 KSharedConfigPtr config = KGlobal::config();
1774 KConfigGroup layouts(config, "Layouts");
1775 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1776 restoreState(state);
1779 void MainWindow::slotSaveLayout(QAction *action)
1781 QString originallayoutName = action->data().toString();
1782 int layoutId = originallayoutName.section('_', -1).toInt();
1784 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1785 if (layoutName.isEmpty()) return;
1786 KSharedConfigPtr config = KGlobal::config();
1787 KConfigGroup layouts(config, "Layouts");
1788 layouts.deleteEntry(originallayoutName);
1790 QByteArray st = saveState();
1791 layoutName.append("_" + QString::number(layoutId));
1792 layouts.writeEntry(layoutName, st.toBase64());
1796 void MainWindow::saveOptions()
1798 KdenliveSettings::self()->writeConfig();
1799 KSharedConfigPtr config = KGlobal::config();
1800 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1801 KConfigGroup treecolumns(config, "Project Tree");
1802 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1806 void MainWindow::readOptions()
1808 KSharedConfigPtr config = KGlobal::config();
1809 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1810 KConfigGroup initialGroup(config, "version");
1811 bool upgrade = false;
1812 if (initialGroup.exists()) {
1813 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1817 if (initialGroup.readEntry("version") == "0.7") {
1818 //Add new settings from 0.7.1
1819 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1820 QString path = QDir::homePath() + "/kdenlive";
1821 if (KStandardDirs::makeDir(path) == false) {
1822 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1823 } else KdenliveSettings::setDefaultprojectfolder(path);
1829 if (!initialGroup.exists() || upgrade) {
1830 // this is our first run, show Wizard
1831 Wizard *w = new Wizard(upgrade, this);
1832 if (w->exec() == QDialog::Accepted && w->isOk()) {
1833 w->adjustSettings();
1834 initialGroup.writeEntry("version", version);
1840 KConfigGroup treecolumns(config, "Project Tree");
1841 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1842 if (!state.isEmpty())
1843 m_projectList->setHeaderInfo(state);
1846 void MainWindow::slotRunWizard()
1848 Wizard *w = new Wizard(false, this);
1849 if (w->exec() == QDialog::Accepted && w->isOk()) {
1850 w->adjustSettings();
1855 void MainWindow::newFile(bool showProjectSettings, bool force)
1857 if (!m_timelineArea->isEnabled() && !force)
1859 m_fileRevert->setEnabled(false);
1860 QString profileName = KdenliveSettings::default_profile();
1861 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1862 QMap <QString, QString> documentProperties;
1863 QMap <QString, QString> documentMetadata;
1864 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1865 if (!showProjectSettings) {
1866 if (!KdenliveSettings::activatetabs())
1867 if (!closeCurrentDocument())
1870 ProjectSettings *w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1871 if (w->exec() != QDialog::Accepted)
1873 if (!KdenliveSettings::activatetabs())
1874 if (!closeCurrentDocument())
1876 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1877 slotSwitchVideoThumbs();
1878 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1879 slotSwitchAudioThumbs();
1880 profileName = w->selectedProfile();
1881 projectFolder = w->selectedFolder();
1882 projectTracks = w->tracks();
1883 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1884 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1885 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1886 documentProperties.insert("proxyparams", w->proxyParams());
1887 documentProperties.insert("proxyextension", w->proxyExtension());
1888 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1889 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1890 documentMetadata = w->metadata();
1893 m_timelineArea->setEnabled(true);
1894 m_projectList->setEnabled(true);
1896 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1897 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1899 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
1900 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1903 //m_timelineArea->setEnabled(false);
1904 //m_projectList->setEnabled(false);
1908 if (m_timelineArea->count() == 1) {
1909 connectDocumentInfo(doc);
1910 connectDocument(trackView, doc);
1912 m_timelineArea->setTabBarHidden(false);
1913 m_monitorManager->activateMonitor("clip");
1914 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1917 void MainWindow::activateDocument()
1919 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1920 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1921 KdenliveDoc *currentDoc = currentTab->document();
1922 connectDocumentInfo(currentDoc);
1923 connectDocument(currentTab, currentDoc);
1926 bool MainWindow::closeCurrentDocument(bool saveChanges)
1928 QWidget *w = m_timelineArea->currentWidget();
1929 if (!w) return true;
1930 // closing current document
1931 int ix = m_timelineArea->currentIndex() + 1;
1932 if (ix == m_timelineArea->count()) ix = 0;
1933 m_timelineArea->setCurrentIndex(ix);
1934 TrackView *tabToClose = (TrackView *) w;
1935 KdenliveDoc *docToClose = tabToClose->document();
1936 if (docToClose && docToClose->isModified() && saveChanges) {
1938 if (m_activeDocument->url().fileName().isEmpty())
1939 message = i18n("Save changes to document?");
1941 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1942 switch (KMessageBox::warningYesNoCancel(this, message)) {
1943 case KMessageBox::Yes :
1944 // save document here. If saving fails, return false;
1945 if (saveFile() == false) return false;
1947 case KMessageBox::Cancel :
1954 m_clipMonitor->slotSetClipProducer(NULL);
1955 m_projectList->slotResetProjectList();
1956 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1957 if (m_timelineArea->count() == 1) {
1958 m_timelineArea->setTabBarHidden(true);
1959 m_closeAction->setEnabled(false);
1961 if (docToClose == m_activeDocument) {
1962 delete m_activeDocument;
1963 m_activeDocument = NULL;
1964 m_effectStack->clear();
1965 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1969 if (w == m_activeTimeline) {
1970 delete m_activeTimeline;
1971 m_activeTimeline = NULL;
1978 bool MainWindow::saveFileAs(const QString &outputFileName)
1980 QString currentSceneList;
1981 m_monitorManager->stopActiveMonitor();
1983 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1986 // Save timeline thumbnails
1987 m_activeTimeline->projectView()->saveThumbnails();
1988 m_activeDocument->setUrl(KUrl(outputFileName));
1989 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
1990 if (m_activeDocument->m_autosave == NULL) {
1991 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
1992 } else m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
1993 setCaption(m_activeDocument->description());
1994 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1995 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1996 m_activeDocument->setModified(false);
1997 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1998 m_fileRevert->setEnabled(true);
1999 m_undoView->stack()->setClean();
2003 bool MainWindow::saveFileAs()
2005 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
2006 if (outputFile.isEmpty()) {
2009 if (QFile::exists(outputFile)) {
2010 // Show the file dialog again if the user does not want to overwrite the file
2011 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
2012 return saveFileAs();
2014 return saveFileAs(outputFile);
2017 bool MainWindow::saveFile()
2019 if (!m_activeDocument) return true;
2020 if (m_activeDocument->url().isEmpty()) {
2021 return saveFileAs();
2023 bool result = saveFileAs(m_activeDocument->url().path());
2024 m_activeDocument->m_autosave->resize(0);
2029 void MainWindow::openFile()
2031 if (!m_startUrl.isEmpty()) {
2032 openFile(m_startUrl);
2033 m_startUrl = KUrl();
2036 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2037 if (url.isEmpty()) return;
2038 m_fileOpenRecent->addUrl(url);
2042 void MainWindow::openLastFile()
2044 KSharedConfigPtr config = KGlobal::config();
2045 KUrl::List urls = m_fileOpenRecent->urls();
2046 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2047 if (urls.isEmpty()) newFile(false);
2048 else openFile(urls.last());
2051 void MainWindow::openFile(const KUrl &url)
2053 // Make sure the url is a Kdenlive project file
2054 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2055 if (mime.data()->is("application/x-compressed-tar")) {
2056 // Opening a compressed project file, we need to process it
2057 kDebug()<<"Opening archive, processing";
2058 ArchiveWidget *ar = new ArchiveWidget(url);
2059 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2063 if (!url.fileName().endsWith(".kdenlive")) {
2064 // This is not a Kdenlive project file, abort loading
2065 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2069 // Check if the document is already opened
2070 const int ct = m_timelineArea->count();
2071 bool isOpened = false;
2073 for (i = 0; i < ct; i++) {
2074 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2075 KdenliveDoc *doc = tab->document();
2076 if (doc->url() == url) {
2082 m_timelineArea->setCurrentIndex(i);
2086 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2088 // Check for backup file
2089 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2090 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2091 if (!staleFiles.isEmpty()) {
2092 if (KMessageBox::questionYesNo(this,
2093 i18n("Auto-saved files exist. Do you want to recover them now?"),
2094 i18n("File Recovery"),
2095 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2096 recoverFiles(staleFiles, url);
2099 // remove the stale files
2100 foreach(KAutoSaveFile * stale, staleFiles) {
2101 stale->open(QIODevice::ReadWrite);
2106 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2107 m_messageLabel->repaint();
2108 doOpenFile(url, NULL);
2111 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2113 if (!m_timelineArea->isEnabled()) return;
2114 m_fileRevert->setEnabled(true);
2116 // Recreate stopmotion widget on document change
2118 delete m_stopmotion;
2119 m_stopmotion = NULL;
2123 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2124 progressDialog.setAllowCancel(false);
2125 progressDialog.progressBar()->setMaximum(4);
2126 progressDialog.show();
2127 progressDialog.progressBar()->setValue(0);
2128 qApp->processEvents();
2131 KdenliveDoc *doc = new KdenliveDoc(stale ? KUrl(stale->fileName()) : url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
2133 progressDialog.progressBar()->setValue(1);
2134 progressDialog.progressBar()->setMaximum(4);
2135 progressDialog.setLabelText(i18n("Loading project"));
2136 qApp->processEvents();
2138 if (stale == NULL) {
2139 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2140 stale = new KAutoSaveFile(KUrl(hash), doc);
2141 doc->m_autosave = stale;
2143 doc->m_autosave = stale;
2144 doc->setUrl(url);//stale->managedFile());
2145 doc->setModified(true);
2146 stale->setParent(doc);
2148 connectDocumentInfo(doc);
2150 progressDialog.progressBar()->setValue(2);
2151 qApp->processEvents();
2154 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2155 connectDocument(trackView, doc);
2156 progressDialog.progressBar()->setValue(3);
2157 qApp->processEvents();
2159 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2161 m_timelineArea->setEnabled(false);
2162 m_projectList->setEnabled(false);
2163 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2164 slotGotProgressInfo(QString(), -1);
2165 newFile(false, true);
2168 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2169 trackView->setDuration(trackView->duration());
2170 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2172 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2173 slotGotProgressInfo(QString(), -1);
2174 m_projectMonitor->adjustRulerSize(trackView->duration());
2175 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2176 progressDialog.progressBar()->setValue(4);
2177 if (openBackup) slotOpenBackupDialog(url);
2180 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl)
2182 foreach(KAutoSaveFile * stale, staleFiles) {
2183 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2184 // show an error message; we could not steal the lockfile
2185 // maybe another application got to the file before us?
2189 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2190 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2191 if (!stale->fileName().endsWith(".lock")) doOpenFile(originUrl, stale);
2192 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2196 void MainWindow::parseProfiles(const QString &mltPath)
2198 //KdenliveSettings::setDefaulttmpfolder();
2199 if (!mltPath.isEmpty()) {
2200 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2201 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2204 if (KdenliveSettings::mltpath().isEmpty())
2205 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2207 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2208 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2209 if (!QFile::exists(meltPath))
2210 meltPath = KStandardDirs::findExe("melt");
2211 KdenliveSettings::setRendererpath(meltPath);
2214 if (KdenliveSettings::rendererpath().isEmpty()) {
2215 // Cannot find the MLT melt renderer, ask for location
2216 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2217 if (getUrl->exec() == QDialog::Rejected) {
2220 KUrl rendererPath = getUrl->selectedUrl();
2222 if (rendererPath.isEmpty()) ::exit(0);
2223 KdenliveSettings::setRendererpath(rendererPath.path());
2226 QStringList profilesFilter;
2227 profilesFilter << "*";
2228 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2229 if (profilesList.isEmpty()) {
2230 // Cannot find MLT path, try finding melt
2231 QString profilePath = KdenliveSettings::rendererpath();
2232 if (!profilePath.isEmpty()) {
2233 profilePath = profilePath.section('/', 0, -3);
2234 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2235 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2237 if (profilesList.isEmpty()) {
2238 // Cannot find the MLT profiles, ask for location
2239 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2240 getUrl->fileDialog()->setMode(KFile::Directory);
2241 if (getUrl->exec() == QDialog::Rejected) {
2244 KUrl mltPath = getUrl->selectedUrl();
2246 if (mltPath.isEmpty()) ::exit(0);
2247 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2248 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2252 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2254 // Parse again MLT profiles to build a list of available video formats
2255 if (profilesList.isEmpty()) parseProfiles();
2259 void MainWindow::slotEditProfiles()
2261 ProfilesDialog *w = new ProfilesDialog;
2262 if (w->exec() == QDialog::Accepted) {
2263 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2264 if (d) d->checkProfile();
2269 void MainWindow::slotDetectAudioDriver()
2271 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2272 leading to no audio output, see bug #934 */
2274 //decide which audio driver is really best, in some cases SDL is wrong
2275 if (KdenliveSettings::audiodrivername().isEmpty()) {
2277 KProcess readProcess;
2278 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2279 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2280 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2281 readProcess.setProgram("pactl", QStringList() << "stat");
2282 readProcess.execute(2000); // Kill it after 2 seconds
2284 QString result = QString(readProcess.readAllStandardOutput());
2285 kDebug() << "// / / / / / READING PACTL: ";
2287 if (!result.isEmpty()) {
2289 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2293 KdenliveSettings::setAutoaudiodrivername(driver);
2297 void MainWindow::slotEditProjectSettings()
2299 QPoint p = m_activeDocument->getTracksCount();
2300 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeDocument->metadata(), m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2301 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2303 if (w->exec() == QDialog::Accepted) {
2304 QString profile = w->selectedProfile();
2305 m_activeDocument->setProjectFolder(w->selectedFolder());
2307 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2309 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2310 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2311 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2312 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2313 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2314 m_activeDocument->setModified();
2315 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2316 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) {
2317 //TODO: rebuild all proxies
2318 //m_projectList->rebuildProxies();
2321 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2322 m_activeDocument->setModified();
2323 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2325 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2326 m_activeDocument->setModified();
2327 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2329 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2330 m_activeDocument->setModified();
2331 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2333 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2334 m_activeDocument->setModified();
2335 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2337 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2338 m_activeDocument->setModified();
2339 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2341 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2342 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2343 m_activeDocument->setModified();
2344 slotUpdateProxySettings();
2346 m_activeDocument->setMetadata(w->metadata());
2351 void MainWindow::slotDisableProxies()
2353 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2354 m_activeDocument->setModified();
2355 slotUpdateProxySettings();
2358 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2360 // Recreate the stopmotion widget if profile changes
2362 delete m_stopmotion;
2363 m_stopmotion = NULL;
2366 // Deselect current effect / transition
2367 m_effectStack->slotClipItemSelected(NULL, 0);
2368 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2369 m_clipMonitor->slotSetClipProducer(NULL);
2370 bool updateFps = m_activeDocument->setProfilePath(profile);
2371 KdenliveSettings::setCurrent_profile(profile);
2372 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2373 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2375 m_activeDocument->clipManager()->clearUnusedProducers();
2376 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2377 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2378 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2379 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2380 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2381 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2382 if (updateFps) m_activeTimeline->updateProjectFps();
2383 m_activeDocument->clipManager()->clearCache();
2384 m_activeTimeline->updateProfile();
2385 m_activeDocument->setModified(true);
2386 m_commandStack->activeStack()->clear();
2387 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2388 slotUpdateMousePosition(0);
2389 // We need to desactivate & reactivate monitors to get a refresh
2390 //m_monitorManager->switchMonitors();
2394 void MainWindow::slotRenderProject()
2396 if (!m_renderWidget) {
2397 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2398 MltVideoProfile profile;
2399 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2400 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2401 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2402 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2403 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2404 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2405 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2406 if (m_activeDocument) {
2407 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2408 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2409 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2410 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2413 slotCheckRenderStatus();
2414 m_renderWidget->show();
2415 m_renderWidget->showNormal();
2417 // What are the following lines supposed to do?
2418 //m_activeTimeline->tracksNumber();
2419 //m_renderWidget->enableAudio(false);
2420 //m_renderWidget->export_audio;
2423 void MainWindow::slotCheckRenderStatus()
2425 // Make sure there are no missing clips
2427 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2430 void MainWindow::setRenderingProgress(const QString &url, int progress)
2433 m_renderWidget->setRenderJob(url, progress);
2436 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2439 m_renderWidget->setRenderStatus(url, status, error);
2442 void MainWindow::slotCleanProject()
2444 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2445 m_projectList->cleanup();
2448 void MainWindow::slotUpdateMousePosition(int pos)
2450 if (m_activeDocument)
2451 switch (m_timecodeFormat->currentIndex()) {
2453 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2456 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2460 void MainWindow::slotUpdateDocumentState(bool modified)
2462 if (!m_activeDocument) return;
2463 setCaption(m_activeDocument->description(), modified);
2464 m_saveAction->setEnabled(modified);
2466 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2467 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2469 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2470 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2474 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2476 if (m_activeDocument) {
2477 if (m_activeDocument == doc) return;
2478 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2480 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2483 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2485 //m_projectMonitor->stop();
2486 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2487 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2488 if (m_activeDocument) {
2489 if (m_activeDocument == doc) return;
2490 if (m_activeTimeline) {
2491 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2492 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2493 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2494 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2495 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2496 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2497 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2499 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2501 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2502 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2503 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2504 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2505 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2506 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2507 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2508 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2509 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2510 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2511 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2512 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2513 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2514 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2515 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2516 disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2518 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2519 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2520 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2521 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2522 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2523 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2524 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2525 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2526 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2527 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2528 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2529 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2530 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2531 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2532 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2533 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2534 m_effectStack->clear();
2536 //m_activeDocument->setRenderer(NULL);
2537 m_clipMonitor->stop();
2539 KdenliveSettings::setCurrent_profile(doc->profilePath());
2540 KdenliveSettings::setProject_fps(doc->fps());
2541 m_monitorManager->resetProfiles(doc->timecode());
2542 m_clipMonitorDock->raise();
2543 m_projectList->setDocument(doc);
2544 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2545 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2546 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2548 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2549 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2551 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2552 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2553 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2554 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2555 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2556 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2557 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2558 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2559 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2560 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2561 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2563 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2564 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2565 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2566 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2567 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2569 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2570 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2571 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2573 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2575 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2576 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2577 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2578 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2580 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2581 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2582 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2583 m_zoomSlider->setValue(doc->zoom().x());
2584 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2585 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2586 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2587 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2589 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2590 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2592 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2593 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2595 connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2597 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2598 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2599 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2600 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2601 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2602 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2603 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2604 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2605 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2606 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2607 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2609 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2610 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2611 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2612 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2613 m_activeTimeline = trackView;
2614 if (m_renderWidget) {
2615 slotCheckRenderStatus();
2616 m_renderWidget->setProfile(doc->mltProfile());
2617 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2618 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2619 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2621 //doc->setRenderer(m_projectMonitor->render);
2622 m_commandStack->setActiveStack(doc->commandStack());
2623 KdenliveSettings::setProject_display_ratio(doc->dar());
2624 //doc->clipManager()->checkAudioThumbs();
2626 //m_overView->setScene(trackView->projectScene());
2627 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2628 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2630 setCaption(doc->description(), doc->isModified());
2631 m_saveAction->setEnabled(doc->isModified());
2632 m_normalEditTool->setChecked(true);
2633 m_activeDocument = doc;
2634 m_activeTimeline->updateProjectFps();
2635 m_activeDocument->checkProjectClips();
2637 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2639 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2640 slotUpdateMousePosition(0);
2641 m_monitorManager->activateMonitor("clip");
2642 // set tool to select tool
2643 m_buttonSelectTool->setChecked(true);
2646 void MainWindow::slotZoneMoved(int start, int end)
2648 m_activeDocument->setZone(start, end);
2649 m_projectMonitor->slotZoneMoved(start, end);
2652 void MainWindow::slotGuidesUpdated()
2655 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2658 void MainWindow::slotEditKeys()
2660 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2661 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2662 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2663 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2667 void MainWindow::slotPreferences(int page, int option)
2670 * An instance of your dialog could be already created and could be
2671 * cached, in which case you want to display the cached dialog
2672 * instead of creating another one
2674 if (m_stopmotion) m_stopmotion->slotLive(false);
2675 if (KConfigDialog::showDialog("settings")) {
2676 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2677 if (page != -1) d->showPage(page, option);
2681 // KConfigDialog didn't find an instance of this dialog, so lets
2684 // Get the mappable actions in localized form
2685 QMap<QString, QString> actions;
2686 KActionCollection* collection = actionCollection();
2687 foreach (const QString& action_name, m_action_names) {
2688 actions[collection->action(action_name)->text()] = action_name;
2691 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2692 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2693 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2695 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2698 if (page != -1) dialog->showPage(page, option);
2701 void MainWindow::slotUpdateCaptureFolder()
2705 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2706 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2710 void MainWindow::updateConfiguration()
2712 //TODO: we should apply settings to all projects, not only the current one
2713 if (m_activeTimeline) {
2714 m_activeTimeline->refresh();
2715 m_activeTimeline->projectView()->checkAutoScroll();
2716 m_activeTimeline->checkTrackHeight();
2717 if (m_activeDocument)
2718 m_activeDocument->clipManager()->checkAudioThumbs();
2720 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2721 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2722 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2723 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2725 // Update list of transcoding profiles
2728 #ifdef USE_JOGSHUTTLE
2729 activateShuttleDevice();
2734 void MainWindow::slotSwitchSplitAudio()
2736 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2737 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2740 void MainWindow::slotSwitchVideoThumbs()
2742 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2743 if (m_activeTimeline)
2744 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2745 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2748 void MainWindow::slotSwitchAudioThumbs()
2750 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2751 if (m_activeTimeline) {
2752 m_activeTimeline->refresh();
2753 m_activeTimeline->projectView()->checkAutoScroll();
2754 if (m_activeDocument)
2755 m_activeDocument->clipManager()->checkAudioThumbs();
2757 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2760 void MainWindow::slotSwitchMarkersComments()
2762 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2763 if (m_activeTimeline)
2764 m_activeTimeline->refresh();
2765 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2768 void MainWindow::slotSwitchSnap()
2770 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2771 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2775 void MainWindow::slotDeleteItem()
2777 if (QApplication::focusWidget() &&
2778 QApplication::focusWidget()->parentWidget() &&
2779 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2780 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2781 m_projectList->slotRemoveClip();
2784 QWidget *widget = QApplication::focusWidget();
2786 if (widget == m_effectStackDock) {
2787 m_effectStack->slotItemDel();
2790 widget = widget->parentWidget();
2793 // effect stack has no focus
2794 if (m_activeTimeline)
2795 m_activeTimeline->projectView()->deleteSelectedClips();
2799 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2801 if (m_clipMonitor->isActive())
2802 m_clipMonitor->checkOverlay();
2803 m_clipMonitor->updateMarkers(clip);
2806 void MainWindow::slotAddClipMarker()
2808 DocClipBase *clip = NULL;
2810 if (m_projectMonitor->isActive()) {
2811 if (m_activeTimeline) {
2812 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2814 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2815 clip = item->baseClip();
2819 clip = m_clipMonitor->activeClip();
2820 pos = m_clipMonitor->position();
2823 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2826 QString id = clip->getId();
2827 CommentedTime marker(pos, i18n("Marker"));
2828 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2829 if (d.exec() == QDialog::Accepted)
2830 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2833 void MainWindow::slotDeleteClipMarker()
2835 DocClipBase *clip = NULL;
2837 if (m_projectMonitor->isActive()) {
2838 if (m_activeTimeline) {
2839 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2841 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2842 clip = item->baseClip();
2846 clip = m_clipMonitor->activeClip();
2847 pos = m_clipMonitor->position();
2850 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2854 QString id = clip->getId();
2855 QString comment = clip->markerComment(pos);
2856 if (comment.isEmpty()) {
2857 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2860 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2863 void MainWindow::slotDeleteAllClipMarkers()
2865 DocClipBase *clip = NULL;
2866 if (m_projectMonitor->isActive()) {
2867 if (m_activeTimeline) {
2868 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2870 clip = item->baseClip();
2874 clip = m_clipMonitor->activeClip();
2877 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2880 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2883 void MainWindow::slotEditClipMarker()
2885 DocClipBase *clip = NULL;
2887 if (m_projectMonitor->isActive()) {
2888 if (m_activeTimeline) {
2889 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2891 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2892 clip = item->baseClip();
2896 clip = m_clipMonitor->activeClip();
2897 pos = m_clipMonitor->position();
2900 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2904 QString id = clip->getId();
2905 QString oldcomment = clip->markerComment(pos);
2906 if (oldcomment.isEmpty()) {
2907 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2911 CommentedTime marker(pos, oldcomment);
2912 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2913 if (d.exec() == QDialog::Accepted) {
2914 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2915 if (d.newMarker().time() != pos) {
2916 // remove old marker
2917 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2922 void MainWindow::slotAddMarkerGuideQuickly()
2924 if (!m_activeTimeline || !m_activeDocument)
2927 if (m_clipMonitor->isActive()) {
2928 DocClipBase *clip = m_clipMonitor->activeClip();
2929 GenTime pos = m_clipMonitor->position();
2932 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2936 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2938 m_activeTimeline->projectView()->slotAddGuide(false);
2942 void MainWindow::slotAddGuide()
2944 if (m_activeTimeline)
2945 m_activeTimeline->projectView()->slotAddGuide();
2948 void MainWindow::slotInsertSpace()
2950 if (m_activeTimeline)
2951 m_activeTimeline->projectView()->slotInsertSpace();
2954 void MainWindow::slotRemoveSpace()
2956 if (m_activeTimeline)
2957 m_activeTimeline->projectView()->slotRemoveSpace();
2960 void MainWindow::slotInsertTrack(int ix)
2962 m_projectMonitor->activateMonitor();
2963 if (m_activeTimeline) {
2964 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2965 m_activeTimeline->projectView()->slotInsertTrack(ix);
2967 if (m_activeDocument)
2968 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2971 void MainWindow::slotDeleteTrack(int ix)
2973 m_projectMonitor->activateMonitor();
2974 if (m_activeTimeline) {
2975 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2976 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2978 if (m_activeDocument)
2979 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2982 void MainWindow::slotConfigTrack(int ix)
2984 m_projectMonitor->activateMonitor();
2985 if (m_activeTimeline)
2986 m_activeTimeline->projectView()->slotConfigTracks(ix);
2987 if (m_activeDocument)
2988 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2991 void MainWindow::slotSelectTrack()
2993 m_projectMonitor->activateMonitor();
2994 if (m_activeTimeline) {
2995 m_activeTimeline->projectView()->slotSelectClipsInTrack();
2999 void MainWindow::slotSelectAllTracks()
3001 m_projectMonitor->activateMonitor();
3002 if (m_activeTimeline)
3003 m_activeTimeline->projectView()->slotSelectAllClips();
3006 void MainWindow::slotEditGuide()
3008 if (m_activeTimeline)
3009 m_activeTimeline->projectView()->slotEditGuide();
3012 void MainWindow::slotDeleteGuide()
3014 if (m_activeTimeline)
3015 m_activeTimeline->projectView()->slotDeleteGuide();
3018 void MainWindow::slotDeleteAllGuides()
3020 if (m_activeTimeline)
3021 m_activeTimeline->projectView()->slotDeleteAllGuides();
3024 void MainWindow::slotCutTimelineClip()
3026 if (m_activeTimeline)
3027 m_activeTimeline->projectView()->cutSelectedClips();
3030 void MainWindow::slotInsertClipOverwrite()
3032 if (m_activeTimeline) {
3033 QStringList data = m_clipMonitor->getZoneInfo();
3034 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
3038 void MainWindow::slotSelectTimelineClip()
3040 if (m_activeTimeline)
3041 m_activeTimeline->projectView()->selectClip(true);
3044 void MainWindow::slotSelectTimelineTransition()
3046 if (m_activeTimeline)
3047 m_activeTimeline->projectView()->selectTransition(true);
3050 void MainWindow::slotDeselectTimelineClip()
3052 if (m_activeTimeline)
3053 m_activeTimeline->projectView()->selectClip(false, true);
3056 void MainWindow::slotDeselectTimelineTransition()
3058 if (m_activeTimeline)
3059 m_activeTimeline->projectView()->selectTransition(false, true);
3062 void MainWindow::slotSelectAddTimelineClip()
3064 if (m_activeTimeline)
3065 m_activeTimeline->projectView()->selectClip(true, true);
3068 void MainWindow::slotSelectAddTimelineTransition()
3070 if (m_activeTimeline)
3071 m_activeTimeline->projectView()->selectTransition(true, true);
3074 void MainWindow::slotGroupClips()
3076 if (m_activeTimeline)
3077 m_activeTimeline->projectView()->groupClips();
3080 void MainWindow::slotUnGroupClips()
3082 if (m_activeTimeline)
3083 m_activeTimeline->projectView()->groupClips(false);
3086 void MainWindow::slotEditItemDuration()
3088 if (m_activeTimeline)
3089 m_activeTimeline->projectView()->editItemDuration();
3092 void MainWindow::slotAddProjectClip(KUrl url, const QString &comment)
3094 if (m_activeDocument)
3095 m_activeDocument->slotAddClipFile(url, QString(), QString(), comment);
3098 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3100 if (m_activeDocument)
3101 m_activeDocument->slotAddClipList(urls, QString());
3104 void MainWindow::slotAddTransition(QAction *result)
3106 if (!result) return;
3107 QStringList info = result->data().toStringList();
3108 if (info.isEmpty()) return;
3109 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3110 if (m_activeTimeline && !transition.isNull()) {
3111 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3115 void MainWindow::slotAddVideoEffect(QAction *result)
3117 if (!result) return;
3118 const int EFFECT_VIDEO = 1;
3119 const int EFFECT_AUDIO = 2;
3120 QStringList info = result->data().toStringList();
3122 if (info.isEmpty() || info.size() < 3) return;
3123 QDomElement effect ;
3124 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3125 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3126 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3127 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3129 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3130 if (!effect.isNull()) slotAddEffect(effect);
3131 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3135 void MainWindow::slotZoomIn()
3137 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3138 slotShowZoomSliderToolTip();
3141 void MainWindow::slotZoomOut()
3143 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3144 slotShowZoomSliderToolTip();
3147 void MainWindow::slotFitZoom()
3149 if (m_activeTimeline)
3150 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3153 void MainWindow::slotSetZoom(int value)
3155 value = qMax(m_zoomSlider->minimum(), value);
3156 value = qMin(m_zoomSlider->maximum(), value);
3158 if (m_activeTimeline)
3159 m_activeTimeline->slotChangeZoom(value);
3161 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3162 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3163 slotUpdateZoomSliderToolTip(value);
3165 m_zoomSlider->blockSignals(true);
3166 m_zoomSlider->setValue(value);
3167 m_zoomSlider->blockSignals(false);
3170 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3172 if (zoomlevel != -1)
3173 slotUpdateZoomSliderToolTip(zoomlevel);
3175 QPoint global = m_zoomSlider->rect().topLeft();
3176 global.ry() += m_zoomSlider->height() / 2;
3177 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3178 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3181 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3183 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3186 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3188 m_statusProgressBar->setValue(progress);
3189 if (progress >= 0) {
3190 if (!message.isEmpty())
3191 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3192 m_statusProgressBar->setVisible(true);
3193 } else if (progress == -2) {
3194 if (!message.isEmpty())
3195 m_messageLabel->setMessage(message, ErrorMessage);
3196 m_statusProgressBar->setVisible(false);
3198 m_messageLabel->setMessage(QString(), DefaultMessage);
3199 m_statusProgressBar->setVisible(false);
3203 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3205 if (clip->clipType() == TEXT) {
3206 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3207 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3208 // template text clip
3210 // Get the list of existing templates
3212 filter << "*.kdenlivetitle";
3213 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3215 QDialog *dia = new QDialog(this);
3216 Ui::TemplateClip_UI dia_ui;
3217 dia_ui.setupUi(dia);
3219 const QString templatePath = clip->getProperty("resource");
3220 for (int i = 0; i < templateFiles.size(); ++i) {
3221 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3222 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3224 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3225 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3226 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3227 //warning: setting base directory doesn't work??
3228 KUrl startDir(titlepath);
3229 dia_ui.template_list->fileDialog()->setUrl(startDir);
3230 dia_ui.description->setText(clip->getProperty("description"));
3231 if (dia->exec() == QDialog::Accepted) {
3232 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3233 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3235 QMap <QString, QString> newprops;
3237 if (KUrl(textTemplate).path() != templatePath) {
3238 // The template was changed
3239 newprops.insert("resource", textTemplate);
3242 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3243 newprops.insert("description", dia_ui.description->toPlainText());
3246 QString newtemplate = newprops.value("xmltemplate");
3247 if (newtemplate.isEmpty()) newtemplate = templatePath;
3249 // template modified we need to update xmldata
3250 QString description = newprops.value("description");
3251 if (description.isEmpty()) description = clip->getProperty("description");
3252 else newprops.insert("templatetext", description);
3253 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3254 if (!newprops.isEmpty()) {
3255 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3256 m_activeDocument->commandStack()->push(command);
3262 QString path = clip->getProperty("resource");
3263 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3265 doc.setContent(clip->getProperty("xmldata"));
3266 dia_ui->setXml(doc);
3267 if (dia_ui->exec() == QDialog::Accepted) {
3268 QMap <QString, QString> newprops;
3269 newprops.insert("xmldata", dia_ui->xml().toString());
3270 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3271 // duration changed, we need to update duration
3272 newprops.insert("out", QString::number(dia_ui->outPoint()));
3273 int currentLength = QString(clip->producerProperty("length")).toInt();
3274 if (currentLength <= dia_ui->outPoint())
3275 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3276 else newprops.insert("length", clip->producerProperty("length"));
3278 if (!path.isEmpty()) {
3279 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3280 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) {
3281 // save to external file
3282 dia_ui->saveTitle(path);
3283 } else newprops.insert("resource", QString());
3285 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3286 m_activeDocument->commandStack()->push(command);
3287 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3288 m_activeDocument->setModified(true);
3292 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3296 // any type of clip but a title
3297 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3298 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3299 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3300 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)));
3305 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3307 if (newprops.isEmpty()) return;
3308 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3309 m_activeDocument->commandStack()->push(command);
3310 m_activeDocument->setModified();
3313 // update clip occurences in timeline
3314 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3319 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3321 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3322 if (dia.exec() == QDialog::Accepted) {
3323 QUndoCommand *command = new QUndoCommand();
3324 command->setText(i18n("Edit clips"));
3325 QMap <QString, QString> newImageProps = dia.properties();
3326 // Transparency setting applies only for images
3327 QMap <QString, QString> newProps = newImageProps;
3328 newProps.remove("transparency");
3330 for (int i = 0; i < cliplist.count(); i++) {
3331 DocClipBase *clip = cliplist.at(i);
3332 if (clip->clipType() == IMAGE)
3333 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3335 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3337 m_activeDocument->commandStack()->push(command);
3338 for (int i = 0; i < cliplist.count(); i++)
3339 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3343 void MainWindow::customEvent(QEvent* e)
3345 if (e->type() == QEvent::User)
3346 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3348 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3354 m_effectStack->raiseWindow(m_effectStackDock);
3357 void MainWindow::slotActivateTransitionView(Transition *t)
3360 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3363 void MainWindow::slotSnapRewind()
3365 if (m_projectMonitor->isActive()) {
3366 if (m_activeTimeline)
3367 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3369 m_clipMonitor->slotSeekToPreviousSnap();
3373 void MainWindow::slotSnapForward()
3375 if (m_projectMonitor->isActive()) {
3376 if (m_activeTimeline)
3377 m_activeTimeline->projectView()->slotSeekToNextSnap();
3379 m_clipMonitor->slotSeekToNextSnap();
3383 void MainWindow::slotClipStart()
3385 if (m_projectMonitor->isActive()) {
3386 if (m_activeTimeline)
3387 m_activeTimeline->projectView()->clipStart();
3391 void MainWindow::slotClipEnd()
3393 if (m_projectMonitor->isActive()) {
3394 if (m_activeTimeline)
3395 m_activeTimeline->projectView()->clipEnd();
3399 void MainWindow::slotZoneStart()
3401 if (m_projectMonitor->isActive())
3402 m_projectMonitor->slotZoneStart();
3404 m_clipMonitor->slotZoneStart();
3407 void MainWindow::slotZoneEnd()
3409 if (m_projectMonitor->isActive())
3410 m_projectMonitor->slotZoneEnd();
3412 m_clipMonitor->slotZoneEnd();
3415 void MainWindow::slotChangeTool(QAction * action)
3417 if (action == m_buttonSelectTool)
3418 slotSetTool(SELECTTOOL);
3419 else if (action == m_buttonRazorTool)
3420 slotSetTool(RAZORTOOL);
3421 else if (action == m_buttonSpacerTool)
3422 slotSetTool(SPACERTOOL);
3425 void MainWindow::slotChangeEdit(QAction * action)
3427 if (!m_activeTimeline)
3430 if (action == m_overwriteEditTool)
3431 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3432 else if (action == m_insertEditTool)
3433 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3435 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3438 void MainWindow::slotSetTool(PROJECTTOOL tool)
3440 if (m_activeDocument && m_activeTimeline) {
3441 //m_activeDocument->setTool(tool);
3445 message = i18n("Ctrl + click to use spacer on current track only");
3448 message = i18n("Click on a clip to cut it");
3451 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3454 m_messageLabel->setMessage(message, InformationMessage);
3455 m_activeTimeline->projectView()->setTool(tool);
3459 void MainWindow::slotCopy()
3461 if (m_activeDocument && m_activeTimeline)
3462 m_activeTimeline->projectView()->copyClip();
3465 void MainWindow::slotPaste()
3467 if (m_activeDocument && m_activeTimeline)
3468 m_activeTimeline->projectView()->pasteClip();
3471 void MainWindow::slotPasteEffects()
3473 if (m_activeDocument && m_activeTimeline)
3474 m_activeTimeline->projectView()->pasteClipEffects();
3477 void MainWindow::slotFind()
3479 if (!m_activeDocument || !m_activeTimeline) return;
3480 m_projectSearch->setEnabled(false);
3481 m_findActivated = true;
3482 m_findString.clear();
3483 m_activeTimeline->projectView()->initSearchStrings();
3484 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3485 m_findTimer.start(5000);
3486 qApp->installEventFilter(this);
3489 void MainWindow::slotFindNext()
3491 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3492 statusBar()->showMessage(i18n("Found: %1", m_findString));
3494 statusBar()->showMessage(i18n("Reached end of project"));
3495 m_findTimer.start(4000);
3498 void MainWindow::findAhead()
3500 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3501 m_projectSearchNext->setEnabled(true);
3502 statusBar()->showMessage(i18n("Found: %1", m_findString));
3504 m_projectSearchNext->setEnabled(false);
3505 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3509 void MainWindow::findTimeout()
3511 m_projectSearchNext->setEnabled(false);
3512 m_findActivated = false;
3513 m_findString.clear();
3514 statusBar()->showMessage(i18n("Find stopped"), 3000);
3515 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3516 m_projectSearch->setEnabled(true);
3517 removeEventFilter(this);
3520 void MainWindow::slotClipInTimeline(const QString &clipId)
3522 if (m_activeTimeline && m_activeDocument) {
3523 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3525 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3526 inTimelineMenu->clear();
3528 QList <QAction *> actionList;
3530 for (int i = 0; i < matching.count(); ++i) {
3531 QString track = QString::number(matching.at(i).track);
3532 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3534 QAction *a = new QAction(track + ": " + start, this);
3535 a->setData(QStringList() << track << start);
3536 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3537 while (j < actionList.count()) {
3538 if (actionList.at(j)->text() > a->text()) break;
3541 actionList.insert(j, a);
3543 inTimelineMenu->addActions(actionList);
3545 if (matching.empty())
3546 inTimelineMenu->setEnabled(false);
3548 inTimelineMenu->setEnabled(true);
3552 void MainWindow::slotClipInProjectTree()
3554 if (m_activeTimeline) {
3555 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3556 if (clipIds.isEmpty())
3558 m_projectListDock->raise();
3559 for (int i = 0; i < clipIds.count(); i++)
3560 m_projectList->selectItemById(clipIds.at(i));
3561 if (m_projectMonitor->isActive())
3562 slotSwitchMonitors();
3566 /*void MainWindow::slotClipToProjectTree()
3568 if (m_activeTimeline) {
3569 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3570 if (clips.isEmpty()) return;
3571 for (int i = 0; i < clips.count(); i++) {
3572 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3574 //m_projectList->selectItemById(clipIds.at(i));
3578 void MainWindow::slotSelectClipInTimeline()
3580 if (m_activeTimeline) {
3581 QAction *action = qobject_cast<QAction *>(sender());
3582 QStringList data = action->data().toStringList();
3583 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3587 void MainWindow::keyPressEvent(QKeyEvent *ke)
3589 if (m_findActivated) {
3590 if (ke->key() == Qt::Key_Backspace) {
3591 m_findString = m_findString.left(m_findString.length() - 1);
3593 if (!m_findString.isEmpty())
3598 m_findTimer.start(4000);
3601 } else if (ke->key() == Qt::Key_Escape) {
3605 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3606 m_findString += ke->text();
3610 m_findTimer.start(4000);
3615 KXmlGuiWindow::keyPressEvent(ke);
3620 /** Gets called when the window gets hidden */
3621 void MainWindow::hideEvent(QHideEvent */*event*/)
3623 if (isMinimized() && m_monitorManager)
3624 m_monitorManager->stopActiveMonitor();
3627 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3629 if (m_findActivated) {
3630 if (event->type() == QEvent::ShortcutOverride) {
3631 QKeyEvent* ke = (QKeyEvent*) event;
3632 if (ke->text().trimmed().isEmpty()) return false;
3639 // pass the event on to the parent class
3640 return QMainWindow::eventFilter(obj, event);
3645 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3647 KDialog *dialog = new KDialog(this);
3648 dialog->setCaption("Save clip zone");
3649 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3651 QWidget *widget = new QWidget(dialog);
3652 dialog->setMainWidget(widget);
3654 QVBoxLayout *vbox = new QVBoxLayout(widget);
3655 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3656 if (path.isEmpty()) {
3657 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3658 if (baseClip == NULL) tmppath.append("untitled.mlt");
3660 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3662 path = KUrl(tmppath);
3664 KUrlRequester *url = new KUrlRequester(path, this);
3665 url->setFilter("video/mlt-playlist");
3666 QLabel *label2 = new QLabel(i18n("Description:"), this);
3667 KLineEdit *edit = new KLineEdit(this);
3668 vbox->addWidget(label1);
3669 vbox->addWidget(url);
3670 vbox->addWidget(label2);
3671 vbox->addWidget(edit);
3672 if (dialog->exec() == QDialog::Accepted) {
3673 if (QFile::exists(url->url().path())) {
3674 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3675 slotSaveZone(render, zone, baseClip, url->url());
3679 if (baseClip && !baseClip->fileURL().isEmpty()) {
3680 // create zone from clip url, so that we don't have problems with proxy clips
3682 #if QT_VERSION >= 0x040600
3683 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3684 env.remove("MLT_PROFILE");
3685 p.setProcessEnvironment(env);
3687 QStringList env = QProcess::systemEnvironment();
3688 env << "MLT_PROFILE='\0'";
3689 p.setEnvironment(env);
3691 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3692 if (!p.waitForStarted(3000)) {
3693 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3695 else if (!p.waitForFinished(5000)) {
3696 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3699 else render->saveZone(url->url(), edit->text(), zone);
3704 void MainWindow::slotSetInPoint()
3706 if (m_clipMonitor->isActive()) {
3707 m_clipMonitor->slotSetZoneStart();
3709 m_projectMonitor->slotSetZoneStart();
3713 void MainWindow::slotSetOutPoint()
3715 if (m_clipMonitor->isActive()) {
3716 m_clipMonitor->slotSetZoneEnd();
3718 m_projectMonitor->slotSetZoneEnd();
3722 void MainWindow::slotResizeItemStart()
3724 if (m_activeTimeline)
3725 m_activeTimeline->projectView()->setInPoint();
3728 void MainWindow::slotResizeItemEnd()
3730 if (m_activeTimeline)
3731 m_activeTimeline->projectView()->setOutPoint();
3734 int MainWindow::getNewStuff(const QString &configFile)
3736 KNS3::Entry::List entries;
3737 #if KDE_IS_VERSION(4,3,80)
3738 KNS3::DownloadDialog dialog(configFile);
3740 entries = dialog.changedEntries();
3741 foreach(const KNS3::Entry & entry, entries) {
3742 if (entry.status() == KNS3::Entry::Installed)
3743 kDebug() << "// Installed files: " << entry.installedFiles();
3746 KNS::Engine engine(0);
3747 if (engine.init(configFile))
3748 entries = engine.downloadDialogModal(this);
3749 foreach(KNS::Entry * entry, entries) {
3750 if (entry->status() == KNS::Entry::Installed)
3751 kDebug() << "// Installed files: " << entry->installedFiles();
3754 return entries.size();
3757 void MainWindow::slotGetNewTitleStuff()
3759 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3760 TitleWidget::refreshTitleTemplates();
3763 void MainWindow::slotGetNewLumaStuff()
3765 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3766 initEffects::refreshLumas();
3767 m_activeTimeline->projectView()->reloadTransitionLumas();
3771 void MainWindow::slotGetNewRenderStuff()
3773 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3775 m_renderWidget->reloadProfiles();
3778 void MainWindow::slotGetNewMltProfileStuff()
3780 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3781 // update the list of profiles in settings dialog
3782 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3788 void MainWindow::slotAutoTransition()
3790 if (m_activeTimeline)
3791 m_activeTimeline->projectView()->autoTransition();
3794 void MainWindow::slotSplitAudio()
3796 if (m_activeTimeline)
3797 m_activeTimeline->projectView()->splitAudio();
3800 void MainWindow::slotUpdateClipType(QAction *action)
3802 if (m_activeTimeline) {
3803 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3804 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3805 else m_activeTimeline->projectView()->setAudioAndVideo();
3809 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3811 // We must stop the monitors since we create a new on in the dvd wizard
3812 m_clipMonitor->stop();
3813 m_projectMonitor->stop();
3814 DvdWizard w(url, profile, this);
3816 m_projectMonitor->start();
3819 void MainWindow::slotShowTimeline(bool show)
3821 if (show == false) {
3822 m_timelineState = saveState();
3823 centralWidget()->setHidden(true);
3825 centralWidget()->setHidden(false);
3826 restoreState(m_timelineState);
3830 void MainWindow::slotMaximizeCurrent(bool)
3832 //TODO: is there a way to maximize current widget?
3834 m_timelineState = saveState();
3835 QWidget *par = focusWidget()->parentWidget();
3836 while (par->parentWidget() && par->parentWidget() != this)
3837 par = par->parentWidget();
3838 kDebug() << "CURRENT WIDGET: " << par->objectName();
3841 void MainWindow::loadStabilize()
3843 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3846 Mlt::Profile profile;
3847 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3848 QAction *action=stabMenu->addAction("Videostab (vstab)");
3849 action->setData("videostab");
3850 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3852 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3853 QAction *action=stabMenu->addAction("Videostab (transcode)");
3854 action->setData("videostab2");
3855 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3862 void MainWindow::loadTranscoders()
3864 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3867 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
3868 extractAudioMenu->clear();
3870 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3871 KConfigGroup transConfig(config, "Transcoding");
3873 QMap< QString, QString > profiles = transConfig.entryMap();
3874 QMapIterator<QString, QString> i(profiles);
3875 while (i.hasNext()) {
3877 QStringList data = i.value().split(";");
3879 // separate audio transcoding in a separate menu
3880 if (data.count() > 2 && data.at(2) == "audio") {
3881 a = extractAudioMenu->addAction(i.key());
3884 a = transMenu->addAction(i.key());
3887 if (data.count() > 1) a->setToolTip(data.at(1));
3888 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3892 void MainWindow::slotStabilize()
3894 QString condition,filtername;
3897 // Stablize selected clips
3898 QAction *action = qobject_cast<QAction *>(sender());
3900 filtername=action->data().toString();
3902 m_projectList->startClipFilterJob(filtername, condition);
3904 if (ids.isEmpty()) {
3905 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3908 QString destination;
3909 ProjectItem *item = m_projectList->getClipById(ids.at(0));
3910 if (ids.count() == 1) {
3913 ClipStabilize *d = new ClipStabilize(destination, ids.count(), filtername);
3914 //connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3915 if (d->exec() == QDialog::Accepted) {
3916 m_projectList->slotStabilizeClipJob(ids, d->autoAddClip(), d->params(), d->desc());
3921 void MainWindow::slotTranscode(KUrl::List urls)
3926 if (urls.isEmpty()) {
3927 QAction *action = qobject_cast<QAction *>(sender());
3928 QStringList data = action->data().toStringList();
3929 params = data.at(0);
3930 if (data.count() > 1) desc = data.at(1);
3931 if (data.count() > 3) condition = data.at(3);
3932 m_projectList->slotTranscodeClipJob(condition, params, desc);
3935 if (urls.isEmpty()) {
3936 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3939 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3940 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3944 void MainWindow::slotTranscodeClip()
3946 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3947 if (urls.isEmpty()) return;
3948 slotTranscode(urls);
3951 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3953 if (m_activeDocument == NULL) return;
3954 QMapIterator<QString, QString> i(props);
3955 while (i.hasNext()) {
3957 m_activeDocument->setDocumentProperty(i.key(), i.value());
3959 m_activeDocument->setModified(true);
3963 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3965 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3967 QString playlistPath;
3970 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3971 QString path = m_renderWidget->getFreeScriptName();
3972 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3973 if (!ok || scriptPath.isEmpty()) return;
3974 scriptPath.prepend(scriptsFolder);
3975 QFile f(scriptPath);
3977 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3980 playlistPath = scriptPath + ".mlt";
3982 KTemporaryFile temp;
3983 temp.setAutoRemove(false);
3984 temp.setSuffix(".mlt");
3986 playlistPath = temp.fileName();
3988 QString playlistContent = m_projectMonitor->sceneList();
3989 if (!chapterFile.isEmpty()) {
3992 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3994 in = m_activeTimeline->inPoint();
3995 out = m_activeTimeline->outPoint();
3998 QDomElement chapters = doc.createElement("chapters");
3999 chapters.setAttribute("fps", m_activeDocument->fps());
4000 doc.appendChild(chapters);
4002 QDomElement guidesxml = m_activeDocument->guidesXml();
4003 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
4004 for (int i = 0; i < nodes.count(); i++) {
4005 QDomElement e = nodes.item(i).toElement();
4007 QString comment = e.attribute("comment");
4008 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
4009 if (time >= in && time < out) {
4010 if (zoneOnly) time = time - in;
4011 QDomElement chapter = doc.createElement("chapter");
4012 chapters.appendChild(chapter);
4013 chapter.setAttribute("title", comment);
4014 chapter.setAttribute("time", time);
4018 if (chapters.childNodes().count() > 0) {
4019 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
4020 // Always insert a guide in pos 0
4021 QDomElement chapter = doc.createElement("chapter");
4022 chapters.insertBefore(chapter, QDomNode());
4023 chapter.setAttribute("title", i18n("Start"));
4024 chapter.setAttribute("time", "0");
4026 // save chapters file
4027 QFile file(chapterFile);
4028 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4029 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4031 file.write(doc.toString().toUtf8());
4032 if (file.error() != QFile::NoError) {
4033 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4040 if (m_renderWidget->automaticAudioExport()) {
4041 exportAudio = m_activeTimeline->checkProjectAudio();
4042 } else exportAudio = m_renderWidget->selectedAudioExport();
4044 // Set playlist audio volume to 100%
4046 doc.setContent(playlistContent);
4047 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4048 if (!tractor.isNull()) {
4049 QDomNodeList props = tractor.elementsByTagName("property");
4050 for (int i = 0; i < props.count(); i++) {
4051 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4052 props.at(i).firstChild().setNodeValue("1");
4058 // Do we want proxy rendering
4059 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4060 QString root = doc.documentElement().attribute("root");
4062 // replace proxy clips with originals
4063 QMap <QString, QString> proxies = m_projectList->getProxies();
4065 QDomNodeList producers = doc.elementsByTagName("producer");
4066 QString producerResource;
4068 for (uint n = 0; n < producers.length(); n++) {
4069 QDomElement e = producers.item(n).toElement();
4070 producerResource = EffectsList::property(e, "resource");
4071 if (producerResource.isEmpty()) continue;
4072 if (!producerResource.startsWith("/")) {
4073 producerResource.prepend(root + "/");
4075 if (producerResource.contains('?')) {
4076 // slowmotion producer
4077 suffix = "?" + producerResource.section('?', 1);
4078 producerResource = producerResource.section('?', 0, 0);
4080 else suffix.clear();
4081 if (!producerResource.isEmpty()) {
4082 if (proxies.contains(producerResource)) {
4083 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4084 // We need to delete the "aspect_ratio" property because proxy clips
4085 // sometimes have different ratio than original clips
4086 EffectsList::removeProperty(e, "aspect_ratio");
4087 EffectsList::removeMetaProperties(e);
4092 /*QMapIterator<QString, QString> i(proxies);
4093 while (i.hasNext()) {
4095 // Replace all keys with their values (proxy path with original path)
4096 QString key = i.key();
4097 playlistContent.replace(key, i.value());
4098 if (!root.isEmpty() && key.startsWith(root)) {
4099 // in case the resource path in MLT playlist is relative
4100 key.remove(0, root.count() + 1);
4101 playlistContent.replace(key, i.value());
4105 playlistContent = doc.toString();
4107 // Do save scenelist
4108 QFile file(playlistPath);
4109 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4110 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4113 file.write(playlistContent.toUtf8());
4114 if (file.error() != QFile::NoError) {
4115 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4120 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4123 void MainWindow::slotUpdateTimecodeFormat(int ix)
4125 KdenliveSettings::setFrametimecode(ix == 1);
4126 m_clipMonitor->updateTimecodeFormat();
4127 m_projectMonitor->updateTimecodeFormat();
4128 m_transitionConfig->updateTimecodeFormat();
4129 m_effectStack->updateTimecodeFormat();
4130 //m_activeTimeline->projectView()->clearSelection();
4131 m_activeTimeline->updateRuler();
4134 void MainWindow::slotRemoveFocus()
4136 statusBar()->setFocus();
4137 statusBar()->clearFocus();
4140 void MainWindow::slotRevert()
4142 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;
4143 KUrl url = m_activeDocument->url();
4144 if (closeCurrentDocument(false))
4145 doOpenFile(url, NULL);
4149 void MainWindow::slotShutdown()
4151 if (m_activeDocument) m_activeDocument->setModified(false);
4153 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4154 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4155 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4156 smserver.call("logout", 1, 2, 2);
4157 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4158 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4159 smserver.call("Shutdown");
4163 void MainWindow::slotUpdateTrackInfo()
4165 if (m_activeDocument)
4166 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4169 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4171 // Load the theme file
4173 if (action == NULL) theme = themename;
4174 else theme = action->data().toString();
4175 KdenliveSettings::setColortheme(theme);
4176 // Make palette for all widgets.
4177 QPalette plt = kapp->palette();
4178 if (theme.isEmpty()) {
4179 plt = QApplication::desktop()->palette();
4181 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4183 #if KDE_IS_VERSION(4,6,3)
4184 plt = KGlobalSettings::createNewApplicationPalette(config);
4186 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4187 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4188 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4189 QPalette::Disabled };
4190 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4191 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4193 for ( int i = 0; i < 3 ; i++ ) {
4194 QPalette::ColorGroup state = states[i];
4195 KColorScheme schemeView(state, KColorScheme::View, config);
4196 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4197 KColorScheme schemeButton(state, KColorScheme::Button, config);
4198 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4200 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4201 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4202 plt.setBrush( state, QPalette::Base, schemeView.background() );
4203 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4204 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4205 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4206 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4207 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4208 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4209 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4211 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4212 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4213 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4214 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4215 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4217 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4218 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4219 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4224 kapp->setPalette(plt);
4225 const QObjectList children = statusBar()->children();
4227 foreach(QObject * child, children) {
4228 if (child->isWidgetType())
4229 ((QWidget*)child)->setPalette(plt);
4230 const QObjectList subchildren = child->children();
4231 foreach(QObject * subchild, subchildren) {
4232 if (subchild->isWidgetType())
4233 ((QWidget*)subchild)->setPalette(plt);
4236 if (m_activeTimeline) {
4237 m_activeTimeline->projectView()->updatePalette();
4242 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4244 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4245 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4246 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4247 const QSize bitsSize(24, 2);
4248 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4249 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4251 QPixmap pixmap(23, 16);
4252 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4254 KConfigGroup group(config, "WM");
4255 QPainter p(&pixmap);
4256 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4257 p.fillRect(1, 1, 7, 7, windowScheme.background());
4258 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4260 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4261 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4262 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4264 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4265 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4267 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4268 p.fillRect(1, 8, 7, 7, viewScheme.background());
4269 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4271 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4272 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4273 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4275 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4276 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4282 void MainWindow::slotSwitchMonitors()
4284 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4285 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4286 else m_projectList->focusTree();
4289 void MainWindow::slotSwitchFullscreen()
4291 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4292 else m_clipMonitor->slotSwitchFullScreen();
4295 void MainWindow::slotInsertZoneToTree()
4297 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4298 QStringList info = m_clipMonitor->getZoneInfo();
4299 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4302 void MainWindow::slotInsertZoneToTimeline()
4304 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4305 QStringList info = m_clipMonitor->getZoneInfo();
4306 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4310 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4312 if (m_activeDocument && m_activeTimeline) {
4313 if (!ids.isEmpty()) {
4314 for (int i = 0; i < ids.size(); ++i) {
4315 m_activeTimeline->slotDeleteClip(ids.at(i));
4317 m_activeDocument->clipManager()->slotDeleteClips(ids);
4319 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4320 m_activeDocument->setModified(true);
4324 void MainWindow::slotShowTitleBars(bool show)
4326 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4327 for (int i = 0; i < docks.count(); i++) {
4328 QDockWidget* dock = docks.at(i);
4330 dock->setTitleBarWidget(0);
4332 if (!dock->isFloating()) {
4333 dock->setTitleBarWidget(new QWidget);
4337 KdenliveSettings::setShowtitlebars(show);
4340 void MainWindow::slotSwitchTitles()
4342 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4345 QString MainWindow::getMimeType(bool open)
4347 QString mimetype = "application/x-kdenlive";
4348 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4350 mimetype = "*.kdenlive";
4351 if (open) mimetype.append(" *.tar.gz");
4353 else if (open) mimetype.append(" application/x-compressed-tar");
4357 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4360 m_projectMonitor->render->sendFrameForAnalysis = true;
4363 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4364 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4371 qDebug() << "Any scope accepting new frames? " << request;
4374 m_projectMonitor->render->sendFrameForAnalysis = false;
4378 void MainWindow::slotUpdateGfxScopeFrameRequest()
4380 // We need a delay to make sure widgets are hidden after a close event for example
4381 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4384 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4387 bool request = false;
4388 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4389 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4390 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4396 if (!m_projectMonitor->effectSceneDisplayed()) {
4397 m_projectMonitor->render->sendFrameForAnalysis = false;
4399 m_clipMonitor->render->sendFrameForAnalysis = false;
4401 m_recMonitor->analyseFrames(false);
4403 m_projectMonitor->render->sendFrameForAnalysis = true;
4404 m_clipMonitor->render->sendFrameForAnalysis = true;
4406 m_recMonitor->analyseFrames(true);
4410 void MainWindow::slotUpdateAudioScopeFrameRequest()
4412 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4415 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4417 bool request = false;
4418 for (int i = 0; i < m_audioScopesList.count(); i++) {
4419 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4420 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4425 // Handle audio signal separately (no common interface)
4426 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4427 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4431 qDebug() << "Scopes Requesting Audio data: " << request;
4433 KdenliveSettings::setMonitor_audio(request);
4434 m_monitorManager->slotUpdateAudioMonitoring();
4437 void MainWindow::slotUpdateColorScopes()
4439 bool request = false;
4440 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4441 // Check if we need the renderer to send a new frame for update
4442 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4443 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4445 if (request && m_monitorManager->activeRenderer()) {
4446 m_monitorManager->activeRenderer()->sendFrameUpdate();
4448 if (m_audiosignal->isVisible() && m_recMonitor->abstractRender()) {
4449 connect(m_recMonitor->abstractRender(), SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)), m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
4453 void MainWindow::slotClearColorScopes()
4455 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4456 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4460 void MainWindow::slotOpenStopmotion()
4462 if (m_stopmotion == NULL) {
4463 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4464 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4465 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4466 // Check if we need the renderer to send a new frame for update
4467 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4468 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4469 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4472 m_stopmotion->show();
4475 void MainWindow::slotDeleteClip(const QString &id)
4477 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4478 for (int i = 0; i < list.size(); ++i) {
4479 list.at(i)->disableClipId(id);
4481 m_projectList->slotDeleteClip(id);
4484 void MainWindow::slotUpdateProxySettings()
4486 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4487 if (KdenliveSettings::enableproxy())
4488 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4489 m_projectList->updateProxyConfig();
4492 void MainWindow::slotInsertNotesTimecode()
4494 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4495 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4496 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4499 void MainWindow::slotArchiveProject()
4501 QList <DocClipBase*> list = m_projectList->documentClipList();
4502 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4503 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4508 void MainWindow::slotOpenBackupDialog(const KUrl url)
4513 kDebug()<<"// BACKUP URL: "<<url.path();
4514 if (!url.isEmpty()) {
4515 // we could not open the project file, guess where the backups are
4516 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4520 projectFolder = m_activeDocument->projectFolder();
4521 projectFile = m_activeDocument->url();
4522 projectId = m_activeDocument->getDocumentProperty("documentid");
4525 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4526 if (dia->exec() == QDialog::Accepted) {
4527 QString requestedBackup = dia->selectedFile();
4528 m_activeDocument->backupLastSavedVersion(projectFile.path());
4529 closeCurrentDocument(false);
4530 doOpenFile(KUrl(requestedBackup), NULL);
4531 m_activeDocument->setUrl(projectFile);
4532 m_activeDocument->setModified(true);
4533 setCaption(m_activeDocument->description());
4538 void MainWindow::slotElapsedTime()
4540 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4544 void MainWindow::slotDownloadResources()
4546 QString currentFolder;
4547 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4548 else currentFolder = KdenliveSettings::defaultprojectfolder();
4549 ResourceWidget *d = new ResourceWidget(currentFolder);
4550 connect(d, SIGNAL(addClip(KUrl, const QString &)), this, SLOT(slotAddProjectClip(KUrl, const QString &)));
4554 #include "mainwindow.moc"