1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
42 #include "audiosignal.h"
44 #include "jogshuttle.h"
45 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
47 #endif /* NO_JOGSHUTTLE */
48 #include "clipproperties.h"
50 #include "editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "kdenlive-config.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audiospectrum.h"
63 #include "spectrogram.h"
64 #include "archivewidget.h"
65 #include "databackup/backupwidget.h"
67 #include <KApplication>
71 #include <KActionCollection>
72 #include <KActionCategory>
73 #include <KStandardAction>
74 #include <KShortcutsDialog>
75 #include <KFileDialog>
76 #include <KMessageBox>
78 #include <KIO/NetAccess>
81 #include <KConfigDialog>
82 #include <KXMLGUIFactory>
84 #include <kstandarddirs.h>
85 #include <KUrlRequesterDialog>
86 #include <KTemporaryFile>
88 #include <KActionMenu>
90 #include <ktogglefullscreenaction.h>
92 #include <KNotification>
93 #include <KNotifyConfigWidget>
94 #if KDE_IS_VERSION(4,3,80)
95 #include <knewstuff3/downloaddialog.h>
96 #include <knewstuff3/knewstuffaction.h>
98 #include <knewstuff2/engine.h>
99 #include <knewstuff2/ui/knewstuffaction.h>
101 #endif /* KDE_IS_VERSION(4,3,80) */
103 #include <KColorScheme>
104 #include <KProgressDialog>
106 #include <QTextStream>
110 #include <QInputDialog>
111 #include <QDesktopWidget>
116 // Uncomment for deeper debugging
117 //#define DEBUG_MAINW
123 static const char version[] = VERSION;
125 static const int ID_TIMELINE_POS = 0;
131 Q_DECLARE_METATYPE(QVector<int16_t>)
134 EffectsList MainWindow::videoEffects;
135 EffectsList MainWindow::audioEffects;
136 EffectsList MainWindow::customEffects;
137 EffectsList MainWindow::transitions;
139 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
140 KXmlGuiWindow(parent),
141 m_activeDocument(NULL),
142 m_activeTimeline(NULL),
144 m_renderWidget(NULL),
145 #ifndef NO_JOGSHUTTLE
148 #endif /* NO_JOGSHUTTLE */
149 m_findActivated(false),
152 qRegisterMetaType<QVector<int16_t> > ();
153 qRegisterMetaType<stringMap> ("stringMap");
154 qRegisterMetaType<audioByteArray> ("audioByteArray");
157 QLocale systemLocale = QLocale();
158 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
159 QLocale::setDefault(systemLocale);
161 // Create DBus interface
162 new MainWindowAdaptor(this);
163 QDBusConnection dbus = QDBusConnection::sessionBus();
164 dbus.registerObject("/MainWindow", this);
166 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
167 setFont(KGlobalSettings::toolBarFont());
168 parseProfiles(MltPath);
169 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
170 m_commandStack = new QUndoGroup;
171 setDockNestingEnabled(true);
172 m_timelineArea = new KTabWidget(this);
173 m_timelineArea->setTabReorderingEnabled(true);
174 m_timelineArea->setTabBarHidden(true);
175 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
176 m_timelineArea->setMinimumHeight(200);
178 QToolButton *closeTabButton = new QToolButton;
179 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
180 closeTabButton->setIcon(KIcon("tab-close"));
181 closeTabButton->adjustSize();
182 closeTabButton->setToolTip(i18n("Close the current tab"));
183 m_timelineArea->setCornerWidget(closeTabButton);
184 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
186 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
187 m_findTimer.setSingleShot(true);
189 // FIXME: the next call returns a newly allocated object, which leaks
190 initEffects::parseEffectFiles();
191 //initEffects::parseCustomEffectsFile();
193 m_monitorManager = new MonitorManager();
195 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
196 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
201 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
202 m_projectListDock->setObjectName("project_tree");
203 m_projectList = new ProjectList();
204 m_projectListDock->setWidget(m_projectList);
205 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
207 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
208 m_clipMonitorDock->setObjectName("clip_monitor");
209 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
210 m_clipMonitorDock->setWidget(m_clipMonitor);
211 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
213 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
214 m_projectMonitorDock->setObjectName("project_monitor");
215 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
216 m_projectMonitorDock->setWidget(m_projectMonitor);
219 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
220 m_recMonitorDock->setObjectName("record_monitor");
221 m_recMonitor = new RecMonitor("record", m_monitorManager);
222 m_recMonitorDock->setWidget(m_recMonitor);
223 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
224 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
225 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
227 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
229 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
230 m_notesDock->setObjectName("notes_widget");
231 m_notesWidget = new NotesWidget();
232 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
233 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
235 m_notesWidget->setTabChangesFocus(true);
236 #if KDE_IS_VERSION(4,4,0)
237 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
239 m_notesDock->setWidget(m_notesWidget);
240 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
242 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
243 m_effectStackDock->setObjectName("effect_stack");
244 m_effectStack = new EffectStackView(m_projectMonitor);
245 m_effectStackDock->setWidget(m_effectStack);
246 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
248 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
249 m_transitionConfigDock->setObjectName("transition");
250 m_transitionConfig = new TransitionSettings(m_projectMonitor);
251 m_transitionConfigDock->setWidget(m_transitionConfig);
252 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
254 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
255 m_effectListDock->setObjectName("effect_list");
256 m_effectList = new EffectsListView();
257 m_effectListDock->setWidget(m_effectList);
258 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
260 m_vectorscope = new Vectorscope(m_monitorManager);
261 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
262 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
263 m_vectorscopeDock->setWidget(m_vectorscope);
264 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
265 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
266 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
267 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
268 m_gfxScopesList.append(m_vectorscopeDock);
270 m_waveform = new Waveform(m_monitorManager);
271 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
272 m_waveformDock->setObjectName(m_waveform->widgetName());
273 m_waveformDock->setWidget(m_waveform);
274 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
275 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
276 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
277 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
278 m_gfxScopesList.append(m_waveformDock);
280 m_RGBParade = new RGBParade(m_monitorManager);
281 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
282 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
283 m_RGBParadeDock->setWidget(m_RGBParade);
284 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
285 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
286 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
287 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
288 m_gfxScopesList.append(m_RGBParadeDock);
290 m_histogram = new Histogram(m_monitorManager);
291 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
292 m_histogramDock->setObjectName(m_histogram->widgetName());
293 m_histogramDock->setWidget(m_histogram);
294 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
295 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
296 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
297 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
298 m_gfxScopesList.append(m_histogramDock);
301 m_audiosignal = new AudioSignal;
302 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
303 m_audiosignalDock->setObjectName("audiosignal");
304 m_audiosignalDock->setWidget(m_audiosignal);
305 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
306 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
307 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
309 m_audioSpectrum = new AudioSpectrum();
310 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
311 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
312 m_audioSpectrumDock->setWidget(m_audioSpectrum);
313 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
314 m_audioScopesList.append(m_audioSpectrum);
315 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
316 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
318 m_spectrogram = new Spectrogram();
319 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
320 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
321 m_spectrogramDock->setWidget(m_spectrogram);
322 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
323 m_audioScopesList.append(m_spectrogram);
324 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
325 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
327 // Connect the audio signal to the audio scope slots
329 if (m_projectMonitor) {
330 qDebug() << "project monitor connected";
331 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
332 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
333 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
334 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
335 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
336 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
339 qDebug() << "clip monitor connected";
340 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
341 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
342 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
343 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
344 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
345 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
347 // Ensure connections were set up correctly
352 // Add monitors here to keep them at the right of the window
353 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
354 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
356 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
359 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
360 m_undoViewDock->setObjectName("undo_history");
361 m_undoView = new QUndoView();
362 m_undoView->setCleanIcon(KIcon("edit-clear"));
363 m_undoView->setEmptyLabel(i18n("Clean"));
364 m_undoViewDock->setWidget(m_undoView);
365 m_undoView->setGroup(m_commandStack);
366 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
370 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
373 // Close non-general docks for the initial layout
374 // only show important ones
375 m_histogramDock->close();
376 m_RGBParadeDock->close();
377 m_waveformDock->close();
378 m_vectorscopeDock->close();
380 m_audioSpectrumDock->close();
381 m_spectrogramDock->close();
382 m_audiosignalDock->close();
384 m_undoViewDock->close();
388 /// Tabify Widgets ///
389 tabifyDockWidget(m_effectListDock, m_effectStackDock);
390 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
391 tabifyDockWidget(m_projectListDock, m_notesDock);
393 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
395 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
401 setCentralWidget(m_timelineArea);
404 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
406 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
407 m_fileRevert->setEnabled(false);
409 // Prepare layout actions
410 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
411 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
412 for (int i = 1; i < 5; i++) {
413 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
414 load->setData("_" + QString::number(i));
415 layoutActions->addAction("load_layout" + QString::number(i), load);
416 m_loadLayout->addAction(load);
417 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
418 save->setData("_" + QString::number(i));
419 layoutActions->addAction("save_layout" + QString::number(i), save);
421 layoutActions->addAction("load_layouts", m_loadLayout);
422 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
425 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
426 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
427 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
428 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
429 m_stopmotion_actions->addAction("stopmotion_capture", action);
430 action = new KAction(i18n("Switch live / captured frame"), this);
431 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
432 m_stopmotion_actions->addAction("stopmotion_switch", action);
433 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
434 action->setCheckable(true);
435 action->setChecked(false);
436 m_stopmotion_actions->addAction("stopmotion_overlay", action);
438 // Build effects menu
439 m_effectsMenu = new QMenu(i18n("Add Effect"));
440 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
441 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
442 m_effectsActionCollection->readSettings();
446 // Find QDockWidget tab bars and show / hide widget title bars on right click
447 QList <QTabBar *> tabs = findChildren<QTabBar *>();
448 for (int i = 0; i < tabs.count(); i++) {
449 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
450 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
453 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
454 guiFactory()->addClient(sp);*/
456 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
458 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
461 // Load layout names from config file
467 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
468 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
470 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
471 clipInTimeline->setIcon(KIcon("go-jump"));
472 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
473 static_cast<QMenu*>(factory()->container("transcoders", this)),
476 // build themes menus
477 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
478 QActionGroup *themegroup = new QActionGroup(this);
479 themegroup->setExclusive(true);
480 action = new KAction(i18n("Default"), this);
481 action->setCheckable(true);
482 themegroup->addAction(action);
483 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
485 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
487 for (int i = 0; i < schemeFiles.size(); ++i) {
489 const QString filename = schemeFiles.at(i);
490 const QFileInfo info(filename);
493 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
494 QIcon icon = createSchemePreviewIcon(config);
495 KConfigGroup group(config, "General");
496 const QString name = group.readEntry("Name", info.baseName());
497 action = new KAction(name, this);
498 action->setData(filename);
499 action->setIcon(icon);
500 action->setCheckable(true);
501 themegroup->addAction(action);
502 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
505 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
506 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
507 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
510 action = new QAction(fi.fileName(), this);
511 action->setData(*it);
512 action->setCheckable(true);
513 themegroup->addAction(action);
514 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
516 themesMenu->addActions(themegroup->actions());
517 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
519 // Setup and fill effects and transitions menus.
522 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
523 m->addActions(m_effectsMenu->actions());
526 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
527 for (int i = 0; i < transitions.count(); ++i)
528 m_transitionsMenu->addAction(m_transitions[i]);
530 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
531 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
532 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
534 m_effectStack->setMenu(m_effectsMenu);
536 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
537 const QList<QAction *> viewActions = createPopupMenu()->actions();
538 viewMenu->insertActions(NULL, viewActions);
540 m_timelineContextMenu = new QMenu(this);
541 m_timelineContextClipMenu = new QMenu(this);
542 m_timelineContextTransitionMenu = new QMenu(this);
544 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
545 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
546 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
548 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
549 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
550 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
551 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
552 m_timelineContextClipMenu->addSeparator();
553 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
554 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
555 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
556 m_timelineContextClipMenu->addSeparator();
557 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
558 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
559 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
560 m_timelineContextClipMenu->addSeparator();
562 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
563 m_timelineContextClipMenu->addMenu(markersMenu);
564 m_timelineContextClipMenu->addSeparator();
565 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
566 m_timelineContextClipMenu->addMenu(m_effectsMenu);
568 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
569 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
570 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
572 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
574 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
575 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
576 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
577 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
578 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
579 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
580 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
582 slotConnectMonitors();
584 // Open or create a file. Command line argument passed in Url has
585 // precedence, then "openlastproject", then just a plain empty file.
586 // If opening Url fails, openlastproject will _not_ be used.
587 if (!Url.isEmpty()) {
588 // delay loading so that the window shows up
590 QTimer::singleShot(500, this, SLOT(openFile()));
591 } else if (KdenliveSettings::openlastproject()) {
592 QTimer::singleShot(500, this, SLOT(openLastFile()));
593 } else { //if (m_timelineArea->count() == 0) {
597 if (!clipsToLoad.isEmpty() && m_activeDocument) {
598 QStringList list = clipsToLoad.split(',');
600 foreach(QString path, list) {
601 kDebug() << QDir::current().absoluteFilePath(path);
602 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
604 m_projectList->slotAddClip(urls);
607 #ifndef NO_JOGSHUTTLE
608 activateShuttleDevice();
609 #endif /* NO_JOGSHUTTLE */
610 m_projectListDock->raise();
612 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
613 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
616 MainWindow::~MainWindow()
621 m_effectStack->slotClipItemSelected(NULL, 0);
622 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
624 if (m_projectMonitor) m_projectMonitor->stop();
625 if (m_clipMonitor) m_clipMonitor->stop();
627 delete m_activeTimeline;
628 delete m_effectStack;
629 delete m_transitionConfig;
630 delete m_activeDocument;
631 delete m_projectMonitor;
632 delete m_clipMonitor;
633 delete m_shortcutRemoveFocus;
634 delete[] m_transitions;
635 Mlt::Factory::close();
639 bool MainWindow::queryClose()
641 if (m_renderWidget) {
642 int waitingJobs = m_renderWidget->waitingJobsCount();
643 if (waitingJobs > 0) {
644 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")))) {
645 case KMessageBox::Yes :
646 // create script with waiting jobs and start it
647 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
649 case KMessageBox::No :
650 // Don't do anything, jobs will be deleted
658 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
659 // warn the user to save if document is modified and we have clips in our project list
660 if (m_activeDocument && m_activeDocument->isModified() &&
661 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
662 !m_projectList->documentClipList().isEmpty())) {
666 if (m_activeDocument->url().fileName().isEmpty())
667 message = i18n("Save changes to document?");
669 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
670 switch (KMessageBox::warningYesNoCancel(this, message)) {
671 case KMessageBox::Yes :
672 // save document here. If saving fails, return false;
674 case KMessageBox::No :
675 // User does not want to save the changes, clear recovery files
676 m_activeDocument->m_autosave->resize(0);
685 void MainWindow::loadPlugins()
687 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
688 populateMenus(plugin);
691 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
693 filters << "libkdenlive*";
694 foreach(const QString & folder, directories) {
695 kDebug() << "Parsing plugin folder: " << folder;
696 QDir pluginsDir(folder);
697 foreach(const QString & fileName,
698 pluginsDir.entryList(filters, QDir::Files)) {
700 * Avoid loading the same plugin twice when there is more than one
703 if (!m_pluginFileNames.contains(fileName)) {
704 kDebug() << "Found plugin: " << fileName;
705 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
706 QObject *plugin = loader.instance();
708 populateMenus(plugin);
709 m_pluginFileNames += fileName;
711 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
717 void MainWindow::populateMenus(QObject *plugin)
719 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
720 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
722 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
726 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
727 QMenu *menu, const char *member,
728 QActionGroup *actionGroup)
730 kDebug() << "// ADD to MENU" << texts;
731 foreach(const QString & text, texts) {
732 QAction *action = new QAction(text, plugin);
733 action->setData(text);
734 connect(action, SIGNAL(triggered()), this, member);
735 menu->addAction(action);
738 action->setCheckable(true);
739 actionGroup->addAction(action);
744 void MainWindow::aboutPlugins()
746 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
751 void MainWindow::generateClip()
753 QAction *action = qobject_cast<QAction *>(sender());
754 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
756 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
757 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
758 if (!clipUrl.isEmpty()) {
759 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
763 void MainWindow::saveProperties(KConfigGroup &config)
765 // save properties here,used by session management
767 KMainWindow::saveProperties(config);
771 void MainWindow::readProperties(const KConfigGroup &config)
773 // read properties here,used by session management
774 KMainWindow::readProperties(config);
775 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
776 openFile(KUrl(Lastproject));
779 void MainWindow::slotReloadEffects()
781 initEffects::parseCustomEffectsFile();
782 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
785 #ifndef NO_JOGSHUTTLE
786 void MainWindow::activateShuttleDevice()
792 if (KdenliveSettings::enableshuttle() == false) return;
794 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
795 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
797 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
798 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
799 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
800 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
801 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
803 #endif /* NO_JOGSHUTTLE */
805 void MainWindow::slotDoAction(const QString& action_name)
807 QAction* action = actionCollection()->action(action_name);
809 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
815 void MainWindow::configureNotifications()
817 KNotifyConfigWidget::configure(this);
820 void MainWindow::slotFullScreen()
822 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
825 void MainWindow::slotAddEffect(const QDomElement effect)
827 if (!m_activeDocument) return;
828 if (effect.isNull()) {
829 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
832 QDomElement effectToAdd = effect.cloneNode().toElement();
834 int ix = m_effectStack->isTrackMode(&ok);
835 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
836 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
839 void MainWindow::slotUpdateClip(const QString &id)
841 if (!m_activeDocument) return;
842 m_activeTimeline->projectView()->slotUpdateClip(id);
845 void MainWindow::slotConnectMonitors()
847 m_projectList->setRenderer(m_projectMonitor->render);
848 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
849 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
850 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
851 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
852 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
853 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
854 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
855 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool, bool)));
857 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
859 connect(m_projectMonitor->render, SIGNAL(blockClipMonitor(const QString)), this, SLOT(slotBlockClipMonitor(const QString)));
860 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
862 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
864 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
865 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
867 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
869 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
870 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
873 void MainWindow::slotAdjustClipMonitor()
875 m_clipMonitorDock->updateGeometry();
876 m_clipMonitorDock->adjustSize();
877 m_clipMonitor->resetSize();
880 void MainWindow::slotAdjustProjectMonitor()
882 m_projectMonitorDock->updateGeometry();
883 m_projectMonitorDock->adjustSize();
884 m_projectMonitor->resetSize();
888 class NameGrabbingKActionCollection {
890 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
891 : m_collection(collection), m_action_names(action_names) {
892 m_action_names.clear();
894 KAction* addAction(const QString& action_name) {
895 m_action_names << action_name;
896 return m_collection->addAction(action_name);
898 void addAction(const QString& action_name, QAction* action) {
899 m_action_names << action_name;
900 m_collection->addAction(action_name, action);
902 operator KActionCollection*() { return m_collection; }
903 const QStringList& actionNames() const { return m_action_names; }
905 KActionCollection* m_collection;
906 QStringList& m_action_names;
909 void MainWindow::setupActions()
912 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
913 m_timecodeFormat = new KComboBox(this);
914 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
915 m_timecodeFormat->addItem(i18n("Frames"));
916 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
917 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
919 m_statusProgressBar = new QProgressBar(this);
920 m_statusProgressBar->setMinimum(0);
921 m_statusProgressBar->setMaximum(100);
922 m_statusProgressBar->setMaximumWidth(150);
923 m_statusProgressBar->setVisible(false);
925 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
926 toolbar->setMovable(false);
927 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
928 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
929 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
930 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
931 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
932 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());
933 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
935 //create edit mode buttons
936 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
937 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
938 toolbar->addAction(m_normalEditTool);
939 m_normalEditTool->setCheckable(true);
940 m_normalEditTool->setChecked(true);
942 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
943 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
944 toolbar->addAction(m_overwriteEditTool);
945 m_overwriteEditTool->setCheckable(true);
946 m_overwriteEditTool->setChecked(false);
948 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
949 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
950 toolbar->addAction(m_insertEditTool);
951 m_insertEditTool->setCheckable(true);
952 m_insertEditTool->setChecked(false);
953 // not implemented yet
954 m_insertEditTool->setEnabled(false);
956 QActionGroup *editGroup = new QActionGroup(this);
957 editGroup->addAction(m_normalEditTool);
958 editGroup->addAction(m_overwriteEditTool);
959 editGroup->addAction(m_insertEditTool);
960 editGroup->setExclusive(true);
961 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
962 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
964 toolbar->addSeparator();
966 // create tools buttons
967 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
968 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
969 toolbar->addAction(m_buttonSelectTool);
970 m_buttonSelectTool->setCheckable(true);
971 m_buttonSelectTool->setChecked(true);
973 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
974 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
975 toolbar->addAction(m_buttonRazorTool);
976 m_buttonRazorTool->setCheckable(true);
977 m_buttonRazorTool->setChecked(false);
979 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
980 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
981 toolbar->addAction(m_buttonSpacerTool);
982 m_buttonSpacerTool->setCheckable(true);
983 m_buttonSpacerTool->setChecked(false);
985 QActionGroup *toolGroup = new QActionGroup(this);
986 toolGroup->addAction(m_buttonSelectTool);
987 toolGroup->addAction(m_buttonRazorTool);
988 toolGroup->addAction(m_buttonSpacerTool);
989 toolGroup->setExclusive(true);
990 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
992 QWidget * actionWidget;
993 int max = toolbar->iconSizeDefault() + 2;
994 actionWidget = toolbar->widgetForAction(m_normalEditTool);
995 actionWidget->setMaximumWidth(max);
996 actionWidget->setMaximumHeight(max - 4);
998 actionWidget = toolbar->widgetForAction(m_insertEditTool);
999 actionWidget->setMaximumWidth(max);
1000 actionWidget->setMaximumHeight(max - 4);
1002 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1003 actionWidget->setMaximumWidth(max);
1004 actionWidget->setMaximumHeight(max - 4);
1006 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1007 actionWidget->setMaximumWidth(max);
1008 actionWidget->setMaximumHeight(max - 4);
1010 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1011 actionWidget->setMaximumWidth(max);
1012 actionWidget->setMaximumHeight(max - 4);
1014 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1015 actionWidget->setMaximumWidth(max);
1016 actionWidget->setMaximumHeight(max - 4);
1018 toolbar->setStyleSheet(style1);
1019 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1021 toolbar->addSeparator();
1022 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1023 toolbar->addAction(m_buttonFitZoom);
1024 m_buttonFitZoom->setCheckable(false);
1026 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1027 toolbar->addAction(m_zoomOut);
1028 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1030 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1031 m_zoomSlider->setMaximum(13);
1032 m_zoomSlider->setPageStep(1);
1033 m_zoomSlider->setInvertedAppearance(true);
1035 m_zoomSlider->setMaximumWidth(150);
1036 m_zoomSlider->setMinimumWidth(100);
1037 toolbar->addWidget(m_zoomSlider);
1039 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1040 toolbar->addAction(m_zoomIn);
1041 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1043 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1044 actionWidget->setMaximumWidth(max);
1045 actionWidget->setMaximumHeight(max - 4);
1046 actionWidget->setStyleSheet(styleBorderless);
1048 actionWidget = toolbar->widgetForAction(m_zoomIn);
1049 actionWidget->setMaximumWidth(max);
1050 actionWidget->setMaximumHeight(max - 4);
1051 actionWidget->setStyleSheet(styleBorderless);
1053 actionWidget = toolbar->widgetForAction(m_zoomOut);
1054 actionWidget->setMaximumWidth(max);
1055 actionWidget->setMaximumHeight(max - 4);
1056 actionWidget->setStyleSheet(styleBorderless);
1058 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1059 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1060 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1061 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1062 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1064 toolbar->addSeparator();
1066 //create automatic audio split button
1067 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1068 toolbar->addAction(m_buttonAutomaticSplitAudio);
1069 m_buttonAutomaticSplitAudio->setCheckable(true);
1070 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1071 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1073 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1074 toolbar->addAction(m_buttonVideoThumbs);
1075 m_buttonVideoThumbs->setCheckable(true);
1076 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1077 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1079 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1080 toolbar->addAction(m_buttonAudioThumbs);
1081 m_buttonAudioThumbs->setCheckable(true);
1082 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1083 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1085 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1086 toolbar->addAction(m_buttonShowMarkers);
1087 m_buttonShowMarkers->setCheckable(true);
1088 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1089 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1091 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1092 toolbar->addAction(m_buttonSnap);
1093 m_buttonSnap->setCheckable(true);
1094 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1095 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1097 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1098 actionWidget->setMaximumWidth(max);
1099 actionWidget->setMaximumHeight(max - 4);
1101 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1102 actionWidget->setMaximumWidth(max);
1103 actionWidget->setMaximumHeight(max - 4);
1105 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1106 actionWidget->setMaximumWidth(max);
1107 actionWidget->setMaximumHeight(max - 4);
1109 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1110 actionWidget->setMaximumWidth(max);
1111 actionWidget->setMaximumHeight(max - 4);
1113 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1114 actionWidget->setMaximumWidth(max);
1115 actionWidget->setMaximumHeight(max - 4);
1117 m_messageLabel = new StatusBarMessageLabel(this);
1118 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1120 statusBar()->addWidget(m_messageLabel, 10);
1121 statusBar()->addWidget(m_statusProgressBar, 0);
1122 statusBar()->addPermanentWidget(toolbar);
1123 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1124 statusBar()->addPermanentWidget(m_timecodeFormat);
1125 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1127 collection.addAction("normal_mode", m_normalEditTool);
1128 collection.addAction("overwrite_mode", m_overwriteEditTool);
1129 collection.addAction("insert_mode", m_insertEditTool);
1130 collection.addAction("select_tool", m_buttonSelectTool);
1131 collection.addAction("razor_tool", m_buttonRazorTool);
1132 collection.addAction("spacer_tool", m_buttonSpacerTool);
1134 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1135 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1136 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1137 collection.addAction("show_markers", m_buttonShowMarkers);
1138 collection.addAction("snap", m_buttonSnap);
1139 collection.addAction("zoom_fit", m_buttonFitZoom);
1140 collection.addAction("zoom_in", m_zoomIn);
1141 collection.addAction("zoom_out", m_zoomOut);
1143 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1144 collection.addAction("project_find", m_projectSearch);
1145 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1146 m_projectSearch->setShortcut(Qt::Key_Slash);
1148 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1149 collection.addAction("project_find_next", m_projectSearchNext);
1150 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1151 m_projectSearchNext->setShortcut(Qt::Key_F3);
1152 m_projectSearchNext->setEnabled(false);
1154 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1155 collection.addAction("manage_profiles", profilesAction);
1156 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1158 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1159 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1160 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1161 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1163 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1164 collection.addAction("run_wizard", wizAction);
1165 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1167 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1168 collection.addAction("project_settings", projectAction);
1169 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1171 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1172 collection.addAction("open_backup", backupAction);
1173 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1175 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1176 collection.addAction("project_render", projectRender);
1177 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1178 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1180 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1181 collection.addAction("project_clean", projectClean);
1182 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1184 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1185 collection.addAction("project_adjust_profile", projectAdjust);
1186 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1188 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1189 KShortcut playShortcut;
1190 playShortcut.setPrimary(Qt::Key_Space);
1191 playShortcut.setAlternate(Qt::Key_K);
1192 monitorPlay->setShortcut(playShortcut);
1193 collection.addAction("monitor_play", monitorPlay);
1194 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1196 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1197 collection.addAction("monitor_pause", monitorPause);
1198 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1200 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1201 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1202 collection.addAction("monitor_play_zone", m_playZone);
1203 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1205 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1206 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1207 collection.addAction("monitor_loop_zone", m_loopZone);
1208 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1210 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1211 m_loopClip->setEnabled(false);
1212 collection.addAction("monitor_loop_clip", m_loopClip);
1213 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1215 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1216 collection.addAction("dvd_wizard", dvdWizard);
1217 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1219 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1220 collection.addAction("transcode_clip", transcodeClip);
1221 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1223 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1224 collection.addAction("archive_project", archiveProject);
1225 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1228 KAction *markIn = collection.addAction("mark_in");
1229 markIn->setText(i18n("Set Zone In"));
1230 markIn->setShortcut(Qt::Key_I);
1231 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1233 KAction *markOut = collection.addAction("mark_out");
1234 markOut->setText(i18n("Set Zone Out"));
1235 markOut->setShortcut(Qt::Key_O);
1236 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1238 KAction *switchMon = collection.addAction("switch_monitor");
1239 switchMon->setText(i18n("Switch monitor"));
1240 switchMon->setShortcut(Qt::Key_T);
1241 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1243 KAction *fullMon = collection.addAction("monitor_fullscreen");
1244 fullMon->setText(i18n("Switch monitor fullscreen"));
1245 fullMon->setIcon(KIcon("view-fullscreen"));
1246 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1248 KAction *insertTree = collection.addAction("insert_project_tree");
1249 insertTree->setText(i18n("Insert zone in project tree"));
1250 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1251 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1253 KAction *insertTimeline = collection.addAction("insert_timeline");
1254 insertTimeline->setText(i18n("Insert zone in timeline"));
1255 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1256 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1258 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1259 collection.addAction("resize_timeline_clip_start", resizeStart);
1260 resizeStart->setShortcut(Qt::Key_1);
1261 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1263 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1264 collection.addAction("resize_timeline_clip_end", resizeEnd);
1265 resizeEnd->setShortcut(Qt::Key_2);
1266 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1268 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1269 monitorSeekBackward->setShortcut(Qt::Key_J);
1270 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1271 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1273 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1274 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1275 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1276 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1278 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1279 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1280 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1281 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1283 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1284 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1285 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1286 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1288 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1289 monitorSeekForward->setShortcut(Qt::Key_L);
1290 collection.addAction("monitor_seek_forward", monitorSeekForward);
1291 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1293 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1294 clipStart->setShortcut(Qt::Key_Home);
1295 collection.addAction("seek_clip_start", clipStart);
1296 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1298 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1299 clipEnd->setShortcut(Qt::Key_End);
1300 collection.addAction("seek_clip_end", clipEnd);
1301 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1303 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1304 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1305 collection.addAction("seek_zone_start", zoneStart);
1306 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1308 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1309 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1310 collection.addAction("seek_zone_end", zoneEnd);
1311 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1313 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1314 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1315 collection.addAction("seek_start", projectStart);
1316 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1318 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1319 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1320 collection.addAction("seek_end", projectEnd);
1321 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1323 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1324 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1325 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1326 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1328 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1329 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1330 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1331 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1333 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1334 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1335 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1336 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1338 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1339 deleteItem->setShortcut(Qt::Key_Delete);
1340 collection.addAction("delete_timeline_clip", deleteItem);
1341 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1343 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1344 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1345 editTimelineClipSpeed->setData("change_speed");
1346 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1348 KAction *stickTransition = collection.addAction("auto_transition");
1349 stickTransition->setData(QString("auto"));
1350 stickTransition->setCheckable(true);
1351 stickTransition->setEnabled(false);
1352 stickTransition->setText(i18n("Automatic Transition"));
1353 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1355 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1356 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1357 collection.addAction("group_clip", groupClip);
1358 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1360 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1361 collection.addAction("ungroup_clip", ungroupClip);
1362 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1363 ungroupClip->setData("ungroup_clip");
1364 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1366 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1367 collection.addAction("edit_item_duration", editItemDuration);
1368 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1370 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1371 collection.addAction("clip_in_project_tree", clipInProjectTree);
1372 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1374 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1375 collection.addAction("clip_to_project_tree", clipToProjectTree);
1376 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1378 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1379 insertOvertwrite->setShortcut(Qt::Key_V);
1380 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1381 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1383 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1384 selectTimelineClip->setShortcut(Qt::Key_Plus);
1385 collection.addAction("select_timeline_clip", selectTimelineClip);
1386 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1388 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1389 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1390 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1391 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1393 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1394 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1395 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1396 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1398 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1399 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1400 collection.addAction("select_timeline_transition", selectTimelineTransition);
1401 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1403 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1404 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1405 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1406 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1408 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1409 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1410 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1411 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1413 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1414 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1415 collection.addAction("cut_timeline_clip", cutTimelineClip);
1416 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1418 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1419 collection.addAction("add_clip_marker", addClipMarker);
1420 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1422 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1423 collection.addAction("delete_clip_marker", deleteClipMarker);
1424 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1426 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1427 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1428 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1430 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1431 editClipMarker->setData(QString("edit_marker"));
1432 collection.addAction("edit_clip_marker", editClipMarker);
1433 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1435 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1436 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1437 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1438 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1440 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1441 collection.addAction("split_audio", splitAudio);
1442 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1444 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1445 collection.addAction("clip_audio_only", audioOnly);
1446 audioOnly->setData("clip_audio_only");
1447 audioOnly->setCheckable(true);
1449 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1450 collection.addAction("clip_video_only", videoOnly);
1451 videoOnly->setData("clip_video_only");
1452 videoOnly->setCheckable(true);
1454 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1455 collection.addAction("clip_audio_and_video", audioAndVideo);
1456 audioAndVideo->setData("clip_audio_and_video");
1457 audioAndVideo->setCheckable(true);
1459 m_clipTypeGroup = new QActionGroup(this);
1460 m_clipTypeGroup->addAction(audioOnly);
1461 m_clipTypeGroup->addAction(videoOnly);
1462 m_clipTypeGroup->addAction(audioAndVideo);
1463 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1464 m_clipTypeGroup->setEnabled(false);
1466 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1467 collection.addAction("insert_space", insertSpace);
1468 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1470 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1471 collection.addAction("delete_space", removeSpace);
1472 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1474 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1475 collection.addAction("insert_track", insertTrack);
1476 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1478 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1479 collection.addAction("delete_track", deleteTrack);
1480 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1482 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1483 collection.addAction("config_tracks", configTracks);
1484 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1486 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1487 collection.addAction("add_guide", addGuide);
1488 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1490 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1491 collection.addAction("delete_guide", delGuide);
1492 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1494 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1495 collection.addAction("edit_guide", editGuide);
1496 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1498 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1499 collection.addAction("delete_all_guides", delAllGuides);
1500 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1502 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1503 collection.addAction("paste_effects", pasteEffects);
1504 pasteEffects->setData("paste_effects");
1505 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1507 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1508 collection.addAction("show_timeline", showTimeline);
1509 showTimeline->setCheckable(true);
1510 showTimeline->setChecked(true);
1511 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1513 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1514 collection.addAction("show_titlebars", showTitleBar);
1515 showTitleBar->setCheckable(true);
1516 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1517 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1518 slotShowTitleBars(KdenliveSettings::showtitlebars());
1520 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1521 KStandardAction::quit(this, SLOT(close()), collection);
1522 KStandardAction::open(this, SLOT(openFile()), collection);
1523 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1524 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1525 KStandardAction::openNew(this, SLOT(newFile()), collection);
1526 // TODO: make the following connection to slotEditKeys work
1527 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1528 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1529 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1530 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1531 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1532 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1534 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1535 undo->setEnabled(false);
1536 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1538 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1539 redo->setEnabled(false);
1540 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1543 //TODO: Add status tooltip to actions ?
1544 connect(collection, SIGNAL(actionHovered(QAction*)),
1545 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1548 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1549 collection.addAction("add_clip", addClip);
1550 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1552 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1553 collection.addAction("add_color_clip", addColorClip);
1554 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1556 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1557 collection.addAction("add_slide_clip", addSlideClip);
1558 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1560 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1561 collection.addAction("add_text_clip", addTitleClip);
1562 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1564 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1565 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1566 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1568 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1569 collection.addAction("add_folder", addFolderButton);
1570 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1572 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1573 collection.addAction("clip_properties", clipProperties);
1574 clipProperties->setData("clip_properties");
1575 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1576 clipProperties->setEnabled(false);
1578 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1579 collection.addAction("edit_clip", openClip);
1580 openClip->setData("edit_clip");
1581 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1582 openClip->setEnabled(false);
1584 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1585 collection.addAction("delete_clip", deleteClip);
1586 deleteClip->setData("delete_clip");
1587 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1588 deleteClip->setEnabled(false);
1590 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1591 collection.addAction("reload_clip", reloadClip);
1592 reloadClip->setData("reload_clip");
1593 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1594 reloadClip->setEnabled(false);
1596 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1597 collection.addAction("proxy_clip", proxyClip);
1598 proxyClip->setData("proxy_clip");
1599 proxyClip->setCheckable(true);
1600 proxyClip->setChecked(false);
1601 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1603 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1604 collection.addAction("stopmotion", stopMotion);
1605 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1607 QMenu *addClips = new QMenu();
1608 addClips->addAction(addClip);
1609 addClips->addAction(addColorClip);
1610 addClips->addAction(addSlideClip);
1611 addClips->addAction(addTitleClip);
1612 addClips->addAction(addTitleTemplateClip);
1613 addClips->addAction(addFolderButton);
1615 addClips->addAction(reloadClip);
1616 addClips->addAction(proxyClip);
1617 addClips->addAction(clipProperties);
1618 addClips->addAction(openClip);
1619 addClips->addAction(deleteClip);
1620 m_projectList->setupMenu(addClips, addClip);
1622 // Setup effects and transitions actions.
1623 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1624 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1625 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1626 m_transitions = new KAction*[transitions.count()];
1627 for (int i = 0; i < transitions.count(); i++) {
1628 QStringList effectInfo = transitions.effectIdInfo(i);
1629 m_transitions[i] = new KAction(effectInfo.at(0), this);
1630 m_transitions[i]->setData(effectInfo);
1631 m_transitions[i]->setIconVisibleInMenu(false);
1632 QString id = effectInfo.at(2);
1633 if (id.isEmpty()) id = effectInfo.at(1);
1634 transitionActions->addAction("transition_" + id, m_transitions[i]);
1636 //m_effectsActionCollection->readSettings();
1640 void MainWindow::slotDisplayActionMessage(QAction *a)
1642 statusBar()->showMessage(a->data().toString(), 3000);
1645 void MainWindow::loadLayouts()
1647 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1648 if (m_loadLayout == NULL || saveLayout == NULL) return;
1649 KSharedConfigPtr config = KGlobal::config();
1650 KConfigGroup layoutGroup(config, "Layouts");
1651 QStringList entries = layoutGroup.keyList();
1652 QList<QAction *> loadActions = m_loadLayout->actions();
1653 QList<QAction *> saveActions = saveLayout->actions();
1654 for (int i = 1; i < 5; i++) {
1655 // Rename the layouts actions
1656 foreach(const QString & key, entries) {
1657 if (key.endsWith(QString("_%1").arg(i))) {
1658 // Found previously saved layout
1659 QString layoutName = key.section("_", 0, -2);
1660 for (int j = 0; j < loadActions.count(); j++) {
1661 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1662 loadActions[j]->setText(layoutName);
1663 loadActions[j]->setData(key);
1667 for (int j = 0; j < saveActions.count(); j++) {
1668 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1669 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1670 saveActions[j]->setData(key);
1679 void MainWindow::slotLoadLayout(QAction *action)
1681 if (!action) return;
1682 QString layoutId = action->data().toString();
1683 if (layoutId.isEmpty()) return;
1684 KSharedConfigPtr config = KGlobal::config();
1685 KConfigGroup layouts(config, "Layouts");
1686 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1687 restoreState(state);
1690 void MainWindow::slotSaveLayout(QAction *action)
1692 QString originallayoutName = action->data().toString();
1693 int layoutId = originallayoutName.section('_', -1).toInt();
1695 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1696 if (layoutName.isEmpty()) return;
1697 KSharedConfigPtr config = KGlobal::config();
1698 KConfigGroup layouts(config, "Layouts");
1699 layouts.deleteEntry(originallayoutName);
1701 QByteArray st = saveState();
1702 layoutName.append("_" + QString::number(layoutId));
1703 layouts.writeEntry(layoutName, st.toBase64());
1707 void MainWindow::saveOptions()
1709 KdenliveSettings::self()->writeConfig();
1710 KSharedConfigPtr config = KGlobal::config();
1711 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1712 KConfigGroup treecolumns(config, "Project Tree");
1713 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1717 void MainWindow::readOptions()
1719 KSharedConfigPtr config = KGlobal::config();
1720 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1721 KConfigGroup initialGroup(config, "version");
1722 bool upgrade = false;
1723 if (initialGroup.exists()) {
1724 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1728 if (initialGroup.readEntry("version") == "0.7") {
1729 //Add new settings from 0.7.1
1730 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1731 QString path = QDir::homePath() + "/kdenlive";
1732 if (KStandardDirs::makeDir(path) == false) {
1733 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1734 } else KdenliveSettings::setDefaultprojectfolder(path);
1740 if (!initialGroup.exists() || upgrade) {
1741 // this is our first run, show Wizard
1742 Wizard *w = new Wizard(upgrade, this);
1743 if (w->exec() == QDialog::Accepted && w->isOk()) {
1744 w->adjustSettings();
1745 initialGroup.writeEntry("version", version);
1751 KConfigGroup treecolumns(config, "Project Tree");
1752 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1753 if (!state.isEmpty())
1754 m_projectList->setHeaderInfo(state);
1757 void MainWindow::slotRunWizard()
1759 Wizard *w = new Wizard(false, this);
1760 if (w->exec() == QDialog::Accepted && w->isOk()) {
1761 w->adjustSettings();
1766 void MainWindow::newFile(bool showProjectSettings, bool force)
1768 if (!m_timelineArea->isEnabled() && !force)
1770 m_fileRevert->setEnabled(false);
1771 QString profileName = KdenliveSettings::default_profile();
1772 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1773 QMap <QString, QString> documentProperties;
1774 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1775 if (!showProjectSettings) {
1776 // set up default properties
1777 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1778 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1779 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1780 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1781 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1782 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1783 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1784 if (!KdenliveSettings::activatetabs())
1785 if (!closeCurrentDocument())
1788 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1789 if (w->exec() != QDialog::Accepted)
1791 if (!KdenliveSettings::activatetabs())
1792 if (!closeCurrentDocument())
1794 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1795 slotSwitchVideoThumbs();
1796 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1797 slotSwitchAudioThumbs();
1798 profileName = w->selectedProfile();
1799 projectFolder = w->selectedFolder();
1800 projectTracks = w->tracks();
1801 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1802 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1803 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1804 documentProperties.insert("proxyparams", w->proxyParams());
1805 documentProperties.insert("proxyextension", w->proxyExtension());
1806 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1807 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1810 m_timelineArea->setEnabled(true);
1811 m_projectList->setEnabled(true);
1813 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1814 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1816 TrackView *trackView = new TrackView(doc, &ok, this);
1817 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1820 //m_timelineArea->setEnabled(false);
1821 //m_projectList->setEnabled(false);
1825 if (m_timelineArea->count() == 1) {
1826 connectDocumentInfo(doc);
1827 connectDocument(trackView, doc);
1829 m_timelineArea->setTabBarHidden(false);
1830 m_monitorManager->activateMonitor("clip");
1831 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1834 void MainWindow::activateDocument()
1836 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1837 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1838 KdenliveDoc *currentDoc = currentTab->document();
1839 connectDocumentInfo(currentDoc);
1840 connectDocument(currentTab, currentDoc);
1843 bool MainWindow::closeCurrentDocument(bool saveChanges)
1845 QWidget *w = m_timelineArea->currentWidget();
1846 if (!w) return true;
1847 // closing current document
1848 int ix = m_timelineArea->currentIndex() + 1;
1849 if (ix == m_timelineArea->count()) ix = 0;
1850 m_timelineArea->setCurrentIndex(ix);
1851 TrackView *tabToClose = (TrackView *) w;
1852 KdenliveDoc *docToClose = tabToClose->document();
1853 if (docToClose && docToClose->isModified() && saveChanges) {
1855 if (m_activeDocument->url().fileName().isEmpty())
1856 message = i18n("Save changes to document?");
1858 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1859 switch (KMessageBox::warningYesNoCancel(this, message)) {
1860 case KMessageBox::Yes :
1861 // save document here. If saving fails, return false;
1862 if (saveFile() == false) return false;
1864 case KMessageBox::Cancel :
1871 m_clipMonitor->slotSetXml(NULL);
1872 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1873 if (m_timelineArea->count() == 1) {
1874 m_timelineArea->setTabBarHidden(true);
1875 m_closeAction->setEnabled(false);
1877 if (docToClose == m_activeDocument) {
1878 delete m_activeDocument;
1879 m_activeDocument = NULL;
1880 m_effectStack->clear();
1881 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1885 if (w == m_activeTimeline) {
1886 delete m_activeTimeline;
1887 m_activeTimeline = NULL;
1894 bool MainWindow::saveFileAs(const QString &outputFileName)
1896 QString currentSceneList;
1897 m_monitorManager->stopActiveMonitor();
1899 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1902 // Save timeline thumbnails
1903 m_activeTimeline->projectView()->saveThumbnails();
1904 m_activeDocument->setUrl(KUrl(outputFileName));
1905 if (m_activeDocument->m_autosave == NULL) {
1906 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1907 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1908 setCaption(m_activeDocument->description());
1909 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1910 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1911 m_activeDocument->setModified(false);
1912 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1913 m_fileRevert->setEnabled(true);
1914 m_undoView->stack()->setClean();
1918 bool MainWindow::saveFileAs()
1920 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1921 if (outputFile.isEmpty()) {
1924 if (QFile::exists(outputFile)) {
1925 // Show the file dialog again if the user does not want to overwrite the file
1926 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1927 return saveFileAs();
1929 return saveFileAs(outputFile);
1932 bool MainWindow::saveFile()
1934 if (!m_activeDocument) return true;
1935 if (m_activeDocument->url().isEmpty()) {
1936 return saveFileAs();
1938 bool result = saveFileAs(m_activeDocument->url().path());
1939 m_activeDocument->m_autosave->resize(0);
1944 void MainWindow::openFile()
1946 if (!m_startUrl.isEmpty()) {
1947 openFile(m_startUrl);
1948 m_startUrl = KUrl();
1951 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1952 if (url.isEmpty()) return;
1953 m_fileOpenRecent->addUrl(url);
1957 void MainWindow::openLastFile()
1959 KSharedConfigPtr config = KGlobal::config();
1960 KUrl::List urls = m_fileOpenRecent->urls();
1961 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1962 if (urls.isEmpty()) newFile(false);
1963 else openFile(urls.last());
1966 void MainWindow::openFile(const KUrl &url)
1968 // Make sure the url is a Kdenlive project file
1969 KMimeType::Ptr mime = KMimeType::findByUrl(url);
1970 if (mime.data()->is("application/x-compressed-tar")) {
1971 // Opening a compressed project file, we need to process it
1972 kDebug()<<"Opening archive, processing";
1973 ArchiveWidget *ar = new ArchiveWidget(url);
1974 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
1978 if (!url.fileName().endsWith(".kdenlive")) {
1979 // This is not a Kdenlive project file, abort loading
1980 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
1984 // Check if the document is already opened
1985 const int ct = m_timelineArea->count();
1986 bool isOpened = false;
1988 for (i = 0; i < ct; i++) {
1989 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1990 KdenliveDoc *doc = tab->document();
1991 if (doc->url() == url) {
1997 m_timelineArea->setCurrentIndex(i);
2001 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2003 // Check for backup file
2004 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2005 if (!staleFiles.isEmpty()) {
2006 if (KMessageBox::questionYesNo(this,
2007 i18n("Auto-saved files exist. Do you want to recover them now?"),
2008 i18n("File Recovery"),
2009 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2010 recoverFiles(staleFiles);
2013 // remove the stale files
2014 foreach(KAutoSaveFile * stale, staleFiles) {
2015 stale->open(QIODevice::ReadWrite);
2020 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2021 m_messageLabel->repaint();
2022 doOpenFile(url, NULL);
2025 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2027 if (!m_timelineArea->isEnabled()) return;
2028 m_fileRevert->setEnabled(true);
2030 // Recreate stopmotion widget on document change
2032 delete m_stopmotion;
2033 m_stopmotion = NULL;
2037 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2038 progressDialog.setAllowCancel(false);
2039 progressDialog.progressBar()->setMaximum(4);
2040 progressDialog.show();
2041 progressDialog.progressBar()->setValue(0);
2042 qApp->processEvents();
2045 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
2047 progressDialog.progressBar()->setValue(1);
2048 progressDialog.progressBar()->setMaximum(4);
2049 progressDialog.setLabelText(i18n("Loading project"));
2050 qApp->processEvents();
2052 if (stale == NULL) {
2053 stale = new KAutoSaveFile(url, doc);
2054 doc->m_autosave = stale;
2056 doc->m_autosave = stale;
2057 doc->setUrl(stale->managedFile());
2058 doc->setModified(true);
2059 stale->setParent(doc);
2061 connectDocumentInfo(doc);
2063 progressDialog.progressBar()->setValue(2);
2064 qApp->processEvents();
2067 TrackView *trackView = new TrackView(doc, &ok, this);
2069 progressDialog.progressBar()->setValue(3);
2070 qApp->processEvents();
2072 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2074 m_timelineArea->setEnabled(false);
2075 m_projectList->setEnabled(false);
2076 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2077 slotGotProgressInfo(QString(), -1);
2078 newFile(false, true);
2081 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2082 trackView->setDuration(trackView->duration());
2083 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2085 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2086 slotGotProgressInfo(QString(), -1);
2087 m_projectMonitor->adjustRulerSize(trackView->duration());
2088 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2089 m_clipMonitor->refreshMonitor(true);
2091 progressDialog.progressBar()->setValue(4);
2092 if (openBackup) slotOpenBackupDialog(url);
2095 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2097 foreach(KAutoSaveFile * stale, staleFiles) {
2098 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2099 // show an error message; we could not steal the lockfile
2100 // maybe another application got to the file before us?
2104 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2105 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2106 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2107 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2111 void MainWindow::parseProfiles(const QString &mltPath)
2113 //KdenliveSettings::setDefaulttmpfolder();
2114 if (!mltPath.isEmpty()) {
2115 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2116 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2119 if (KdenliveSettings::mltpath().isEmpty())
2120 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2122 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2123 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2124 if (!QFile::exists(meltPath))
2125 meltPath = KStandardDirs::findExe("melt");
2126 KdenliveSettings::setRendererpath(meltPath);
2129 if (KdenliveSettings::rendererpath().isEmpty()) {
2130 // Cannot find the MLT melt renderer, ask for location
2131 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2132 if (getUrl->exec() == QDialog::Rejected) {
2135 KUrl rendererPath = getUrl->selectedUrl();
2137 if (rendererPath.isEmpty()) ::exit(0);
2138 KdenliveSettings::setRendererpath(rendererPath.path());
2141 QStringList profilesFilter;
2142 profilesFilter << "*";
2143 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2144 if (profilesList.isEmpty()) {
2145 // Cannot find MLT path, try finding melt
2146 QString profilePath = KdenliveSettings::rendererpath();
2147 if (!profilePath.isEmpty()) {
2148 profilePath = profilePath.section('/', 0, -3);
2149 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2150 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2152 if (profilesList.isEmpty()) {
2153 // Cannot find the MLT profiles, ask for location
2154 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2155 getUrl->fileDialog()->setMode(KFile::Directory);
2156 if (getUrl->exec() == QDialog::Rejected) {
2159 KUrl mltPath = getUrl->selectedUrl();
2161 if (mltPath.isEmpty()) ::exit(0);
2162 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2163 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2167 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2169 // Parse again MLT profiles to build a list of available video formats
2170 if (profilesList.isEmpty()) parseProfiles();
2174 void MainWindow::slotEditProfiles()
2176 ProfilesDialog *w = new ProfilesDialog;
2177 if (w->exec() == QDialog::Accepted) {
2178 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2179 if (d) d->checkProfile();
2184 void MainWindow::slotDetectAudioDriver()
2186 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2187 leading to no audio output, see bug #934 */
2189 //decide which audio driver is really best, in some cases SDL is wrong
2190 if (KdenliveSettings::audiodrivername().isEmpty()) {
2192 KProcess readProcess;
2193 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2194 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2195 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2196 readProcess.setProgram("pactl", QStringList() << "stat");
2197 readProcess.execute(2000); // Kill it after 2 seconds
2199 QString result = QString(readProcess.readAllStandardOutput());
2200 kDebug() << "// / / / / / READING PACTL: ";
2202 if (!result.isEmpty()) {
2204 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2208 KdenliveSettings::setAutoaudiodrivername(driver);
2212 void MainWindow::slotEditProjectSettings()
2214 QPoint p = m_activeDocument->getTracksCount();
2215 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2216 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2218 if (w->exec() == QDialog::Accepted) {
2219 QString profile = w->selectedProfile();
2220 m_activeDocument->setProjectFolder(w->selectedFolder());
2222 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2224 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2225 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2226 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2227 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2228 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2229 m_activeDocument->setModified();
2230 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2231 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) {
2232 //TODO: rebuild all proxies
2233 //m_projectList->rebuildProxies();
2236 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2237 m_activeDocument->setModified();
2238 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2240 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2241 m_activeDocument->setModified();
2242 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2244 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2245 m_activeDocument->setModified();
2246 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2248 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2249 m_activeDocument->setModified();
2250 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2252 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2253 m_activeDocument->setModified();
2254 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2256 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2257 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2258 m_activeDocument->setModified();
2259 slotUpdateProxySettings();
2265 void MainWindow::slotDisableProxies()
2267 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2268 m_activeDocument->setModified();
2269 slotUpdateProxySettings();
2272 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2274 // Recreate the stopmotion widget if profile changes
2276 delete m_stopmotion;
2277 m_stopmotion = NULL;
2280 // Deselect current effect / transition
2281 m_effectStack->slotClipItemSelected(NULL, 0);
2282 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2283 m_clipMonitor->slotSetXml(NULL);
2284 bool updateFps = m_activeDocument->setProfilePath(profile);
2285 KdenliveSettings::setCurrent_profile(profile);
2286 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2287 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2289 m_activeDocument->clipManager()->clearUnusedProducers();
2290 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2291 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2292 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2293 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2294 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2295 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2296 if (updateFps) m_activeTimeline->updateProjectFps();
2297 m_activeDocument->clipManager()->clearCache();
2298 m_activeTimeline->updateProfile();
2299 m_activeDocument->setModified(true);
2300 m_commandStack->activeStack()->clear();
2301 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2302 slotUpdateMousePosition(0);
2303 // We need to desactivate & reactivate monitors to get a refresh
2304 //m_monitorManager->switchMonitors();
2308 void MainWindow::slotRenderProject()
2310 if (!m_renderWidget) {
2311 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2312 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2313 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2314 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2315 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2316 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2317 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2318 if (m_activeDocument) {
2319 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2320 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2321 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2322 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2325 slotCheckRenderStatus();
2326 m_renderWidget->show();
2327 m_renderWidget->showNormal();
2329 // What are the following lines supposed to do?
2330 //m_activeTimeline->tracksNumber();
2331 //m_renderWidget->enableAudio(false);
2332 //m_renderWidget->export_audio;
2335 void MainWindow::slotCheckRenderStatus()
2337 // Make sure there are no missing clips
2339 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2342 void MainWindow::setRenderingProgress(const QString &url, int progress)
2345 m_renderWidget->setRenderJob(url, progress);
2348 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2351 m_renderWidget->setRenderStatus(url, status, error);
2354 void MainWindow::slotCleanProject()
2356 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2357 m_projectList->cleanup();
2360 void MainWindow::slotUpdateMousePosition(int pos)
2362 if (m_activeDocument)
2363 switch (m_timecodeFormat->currentIndex()) {
2365 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2368 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2372 void MainWindow::slotUpdateDocumentState(bool modified)
2374 if (!m_activeDocument) return;
2375 setCaption(m_activeDocument->description(), modified);
2376 m_saveAction->setEnabled(modified);
2378 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2379 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2381 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2382 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2386 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2388 if (m_activeDocument) {
2389 if (m_activeDocument == doc) return;
2390 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2392 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2395 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2397 //m_projectMonitor->stop();
2398 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2399 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2400 if (m_activeDocument) {
2401 if (m_activeDocument == doc) return;
2402 if (m_activeTimeline) {
2403 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2404 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2405 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2406 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2407 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2408 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2409 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2410 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2412 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2414 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2415 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2416 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2417 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2418 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2419 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2420 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2421 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2422 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2423 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2424 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2425 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2426 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2427 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2428 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2429 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2430 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2431 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2432 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2433 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2434 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2435 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2436 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2437 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2438 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2439 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2440 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2441 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2442 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2443 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2444 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2445 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2446 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2447 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2448 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2449 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2450 m_effectStack->clear();
2452 //m_activeDocument->setRenderer(NULL);
2453 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2454 m_clipMonitor->stop();
2456 KdenliveSettings::setCurrent_profile(doc->profilePath());
2457 KdenliveSettings::setProject_fps(doc->fps());
2458 m_monitorManager->resetProfiles(doc->timecode());
2459 m_projectList->setDocument(doc);
2460 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2461 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2462 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2463 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2464 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2466 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2467 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2468 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2470 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2473 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2474 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2475 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2476 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2477 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2478 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2479 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2480 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2481 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2482 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2483 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2484 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2485 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2486 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2488 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2489 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2490 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2491 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2492 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2494 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2495 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2496 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2498 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2500 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2501 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2502 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2503 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2505 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2506 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2507 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2508 m_zoomSlider->setValue(doc->zoom().x());
2509 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2510 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2511 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2512 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2514 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2515 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2517 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2518 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2520 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2521 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2522 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2523 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2524 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2525 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2526 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2527 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2528 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2529 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2530 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2532 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2533 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2534 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2535 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
2536 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2537 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2540 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2541 m_activeTimeline = trackView;
2542 if (m_renderWidget) {
2543 slotCheckRenderStatus();
2544 m_renderWidget->setProfile(doc->mltProfile());
2545 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2546 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2547 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2549 //doc->setRenderer(m_projectMonitor->render);
2550 m_commandStack->setActiveStack(doc->commandStack());
2551 KdenliveSettings::setProject_display_ratio(doc->dar());
2552 //doc->clipManager()->checkAudioThumbs();
2554 //m_overView->setScene(trackView->projectScene());
2555 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2556 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2558 setCaption(doc->description(), doc->isModified());
2559 m_saveAction->setEnabled(doc->isModified());
2560 m_normalEditTool->setChecked(true);
2561 m_activeDocument = doc;
2562 m_activeTimeline->updateProjectFps();
2563 m_activeDocument->checkProjectClips();
2565 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2567 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2568 slotUpdateMousePosition(0);
2569 // set tool to select tool
2570 m_buttonSelectTool->setChecked(true);
2573 void MainWindow::slotZoneMoved(int start, int end)
2575 m_activeDocument->setZone(start, end);
2576 m_projectMonitor->slotZoneMoved(start, end);
2579 void MainWindow::slotGuidesUpdated()
2582 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2585 void MainWindow::slotEditKeys()
2587 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2588 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2589 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2593 void MainWindow::slotPreferences(int page, int option)
2596 * An instance of your dialog could be already created and could be
2597 * cached, in which case you want to display the cached dialog
2598 * instead of creating another one
2600 if (m_stopmotion) m_stopmotion->slotLive(false);
2601 if (KConfigDialog::showDialog("settings")) {
2602 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2603 if (page != -1) d->showPage(page, option);
2607 // KConfigDialog didn't find an instance of this dialog, so lets
2610 // Get the mappable actions in localized form
2611 QMap<QString, QString> actions;
2612 KActionCollection* collection = actionCollection();
2613 foreach (const QString& action_name, m_action_names) {
2614 actions[collection->action(action_name)->text()] = action_name;
2617 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2618 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2619 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2621 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2624 if (page != -1) dialog->showPage(page, option);
2627 void MainWindow::slotUpdateCaptureFolder()
2631 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2632 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2636 void MainWindow::updateConfiguration()
2638 //TODO: we should apply settings to all projects, not only the current one
2639 if (m_activeTimeline) {
2640 m_activeTimeline->refresh();
2641 m_activeTimeline->projectView()->checkAutoScroll();
2642 m_activeTimeline->checkTrackHeight();
2643 if (m_activeDocument)
2644 m_activeDocument->clipManager()->checkAudioThumbs();
2646 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2647 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2648 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2649 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2651 // Update list of transcoding profiles
2653 #ifndef NO_JOGSHUTTLE
2654 activateShuttleDevice();
2655 #endif /* NO_JOGSHUTTLE */
2659 void MainWindow::slotSwitchSplitAudio()
2661 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2662 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2665 void MainWindow::slotSwitchVideoThumbs()
2667 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2668 if (m_activeTimeline)
2669 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2670 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2673 void MainWindow::slotSwitchAudioThumbs()
2675 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2676 if (m_activeTimeline) {
2677 m_activeTimeline->refresh();
2678 m_activeTimeline->projectView()->checkAutoScroll();
2679 if (m_activeDocument)
2680 m_activeDocument->clipManager()->checkAudioThumbs();
2682 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2685 void MainWindow::slotSwitchMarkersComments()
2687 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2688 if (m_activeTimeline)
2689 m_activeTimeline->refresh();
2690 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2693 void MainWindow::slotSwitchSnap()
2695 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2696 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2700 void MainWindow::slotDeleteItem()
2702 if (QApplication::focusWidget() &&
2703 QApplication::focusWidget()->parentWidget() &&
2704 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2705 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2706 m_projectList->slotRemoveClip();
2709 QWidget *widget = QApplication::focusWidget();
2711 if (widget == m_effectStackDock) {
2712 m_effectStack->slotItemDel();
2715 widget = widget->parentWidget();
2718 // effect stack has no focus
2719 if (m_activeTimeline)
2720 m_activeTimeline->projectView()->deleteSelectedClips();
2724 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2726 if (m_clipMonitor->isActive())
2727 m_clipMonitor->checkOverlay();
2728 m_clipMonitor->updateMarkers(clip);
2731 void MainWindow::slotAddClipMarker()
2733 DocClipBase *clip = NULL;
2735 if (m_projectMonitor->isActive()) {
2736 if (m_activeTimeline) {
2737 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2739 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2740 clip = item->baseClip();
2744 clip = m_clipMonitor->activeClip();
2745 pos = m_clipMonitor->position();
2748 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2751 QString id = clip->getId();
2752 CommentedTime marker(pos, i18n("Marker"));
2753 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2754 if (d.exec() == QDialog::Accepted)
2755 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2758 void MainWindow::slotDeleteClipMarker()
2760 DocClipBase *clip = NULL;
2762 if (m_projectMonitor->isActive()) {
2763 if (m_activeTimeline) {
2764 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2766 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2767 clip = item->baseClip();
2771 clip = m_clipMonitor->activeClip();
2772 pos = m_clipMonitor->position();
2775 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2779 QString id = clip->getId();
2780 QString comment = clip->markerComment(pos);
2781 if (comment.isEmpty()) {
2782 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2785 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2788 void MainWindow::slotDeleteAllClipMarkers()
2790 DocClipBase *clip = NULL;
2791 if (m_projectMonitor->isActive()) {
2792 if (m_activeTimeline) {
2793 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2795 clip = item->baseClip();
2799 clip = m_clipMonitor->activeClip();
2802 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2805 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2808 void MainWindow::slotEditClipMarker()
2810 DocClipBase *clip = NULL;
2812 if (m_projectMonitor->isActive()) {
2813 if (m_activeTimeline) {
2814 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2816 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2817 clip = item->baseClip();
2821 clip = m_clipMonitor->activeClip();
2822 pos = m_clipMonitor->position();
2825 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2829 QString id = clip->getId();
2830 QString oldcomment = clip->markerComment(pos);
2831 if (oldcomment.isEmpty()) {
2832 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2836 CommentedTime marker(pos, oldcomment);
2837 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2838 if (d.exec() == QDialog::Accepted) {
2839 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2840 if (d.newMarker().time() != pos) {
2841 // remove old marker
2842 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2847 void MainWindow::slotAddMarkerGuideQuickly()
2849 if (!m_activeTimeline || !m_activeDocument)
2852 if (m_clipMonitor->isActive()) {
2853 DocClipBase *clip = m_clipMonitor->activeClip();
2854 GenTime pos = m_clipMonitor->position();
2857 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2861 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2863 m_activeTimeline->projectView()->slotAddGuide(false);
2867 void MainWindow::slotAddGuide()
2869 if (m_activeTimeline)
2870 m_activeTimeline->projectView()->slotAddGuide();
2873 void MainWindow::slotInsertSpace()
2875 if (m_activeTimeline)
2876 m_activeTimeline->projectView()->slotInsertSpace();
2879 void MainWindow::slotRemoveSpace()
2881 if (m_activeTimeline)
2882 m_activeTimeline->projectView()->slotRemoveSpace();
2885 void MainWindow::slotInsertTrack(int ix)
2887 m_projectMonitor->activateMonitor();
2888 if (m_activeTimeline)
2889 m_activeTimeline->projectView()->slotInsertTrack(ix);
2890 if (m_activeDocument)
2891 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2894 void MainWindow::slotDeleteTrack(int ix)
2896 m_projectMonitor->activateMonitor();
2897 if (m_activeTimeline)
2898 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2899 if (m_activeDocument)
2900 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2903 void MainWindow::slotConfigTrack(int ix)
2905 m_projectMonitor->activateMonitor();
2906 if (m_activeTimeline)
2907 m_activeTimeline->projectView()->slotConfigTracks(ix);
2908 if (m_activeDocument)
2909 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2912 void MainWindow::slotEditGuide()
2914 if (m_activeTimeline)
2915 m_activeTimeline->projectView()->slotEditGuide();
2918 void MainWindow::slotDeleteGuide()
2920 if (m_activeTimeline)
2921 m_activeTimeline->projectView()->slotDeleteGuide();
2924 void MainWindow::slotDeleteAllGuides()
2926 if (m_activeTimeline)
2927 m_activeTimeline->projectView()->slotDeleteAllGuides();
2930 void MainWindow::slotCutTimelineClip()
2932 if (m_activeTimeline)
2933 m_activeTimeline->projectView()->cutSelectedClips();
2936 void MainWindow::slotInsertClipOverwrite()
2938 if (m_activeTimeline) {
2939 QStringList data = m_clipMonitor->getZoneInfo();
2940 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2944 void MainWindow::slotSelectTimelineClip()
2946 if (m_activeTimeline)
2947 m_activeTimeline->projectView()->selectClip(true);
2950 void MainWindow::slotSelectTimelineTransition()
2952 if (m_activeTimeline)
2953 m_activeTimeline->projectView()->selectTransition(true);
2956 void MainWindow::slotDeselectTimelineClip()
2958 if (m_activeTimeline)
2959 m_activeTimeline->projectView()->selectClip(false, true);
2962 void MainWindow::slotDeselectTimelineTransition()
2964 if (m_activeTimeline)
2965 m_activeTimeline->projectView()->selectTransition(false, true);
2968 void MainWindow::slotSelectAddTimelineClip()
2970 if (m_activeTimeline)
2971 m_activeTimeline->projectView()->selectClip(true, true);
2974 void MainWindow::slotSelectAddTimelineTransition()
2976 if (m_activeTimeline)
2977 m_activeTimeline->projectView()->selectTransition(true, true);
2980 void MainWindow::slotGroupClips()
2982 if (m_activeTimeline)
2983 m_activeTimeline->projectView()->groupClips();
2986 void MainWindow::slotUnGroupClips()
2988 if (m_activeTimeline)
2989 m_activeTimeline->projectView()->groupClips(false);
2992 void MainWindow::slotEditItemDuration()
2994 if (m_activeTimeline)
2995 m_activeTimeline->projectView()->editItemDuration();
2998 void MainWindow::slotAddProjectClip(KUrl url)
3000 if (m_activeDocument)
3001 m_activeDocument->slotAddClipFile(url, QString());
3004 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3006 if (m_activeDocument)
3007 m_activeDocument->slotAddClipList(urls, QString());
3010 void MainWindow::slotAddTransition(QAction *result)
3012 if (!result) return;
3013 QStringList info = result->data().toStringList();
3014 if (info.isEmpty()) return;
3015 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3016 if (m_activeTimeline && !transition.isNull()) {
3017 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3021 void MainWindow::slotAddVideoEffect(QAction *result)
3023 if (!result) return;
3024 const int EFFECT_VIDEO = 1;
3025 const int EFFECT_AUDIO = 2;
3026 QStringList info = result->data().toStringList();
3028 if (info.isEmpty() || info.size() < 3) return;
3029 QDomElement effect ;
3030 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3031 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3032 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3033 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3035 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3036 if (!effect.isNull()) slotAddEffect(effect);
3037 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3041 void MainWindow::slotZoomIn()
3043 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3044 slotShowZoomSliderToolTip();
3047 void MainWindow::slotZoomOut()
3049 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3050 slotShowZoomSliderToolTip();
3053 void MainWindow::slotFitZoom()
3055 if (m_activeTimeline)
3056 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3059 void MainWindow::slotSetZoom(int value)
3061 value = qMax(m_zoomSlider->minimum(), value);
3062 value = qMin(m_zoomSlider->maximum(), value);
3064 if (m_activeTimeline)
3065 m_activeTimeline->slotChangeZoom(value);
3067 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3068 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3069 slotUpdateZoomSliderToolTip(value);
3071 m_zoomSlider->blockSignals(true);
3072 m_zoomSlider->setValue(value);
3073 m_zoomSlider->blockSignals(false);
3076 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3078 if (zoomlevel != -1)
3079 slotUpdateZoomSliderToolTip(zoomlevel);
3081 QPoint global = m_zoomSlider->rect().topLeft();
3082 global.ry() += m_zoomSlider->height() / 2;
3083 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3084 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3087 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3089 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3092 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3094 m_statusProgressBar->setValue(progress);
3095 if (progress >= 0) {
3096 if (!message.isEmpty())
3097 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3098 m_statusProgressBar->setVisible(true);
3099 } else if (progress == -2) {
3100 if (!message.isEmpty())
3101 m_messageLabel->setMessage(message, ErrorMessage);
3102 m_statusProgressBar->setVisible(false);
3104 m_messageLabel->setMessage(QString(), DefaultMessage);
3105 m_statusProgressBar->setVisible(false);
3109 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3111 if (clip->clipType() == TEXT) {
3112 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3113 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3114 // template text clip
3116 // Get the list of existing templates
3118 filter << "*.kdenlivetitle";
3119 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3121 QDialog *dia = new QDialog(this);
3122 Ui::TemplateClip_UI dia_ui;
3123 dia_ui.setupUi(dia);
3125 const QString templatePath = clip->getProperty("resource");
3126 for (int i = 0; i < templateFiles.size(); ++i) {
3127 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3128 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3130 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3131 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3132 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3133 //warning: setting base directory doesn't work??
3134 KUrl startDir(titlepath);
3135 dia_ui.template_list->fileDialog()->setUrl(startDir);
3136 dia_ui.description->setText(clip->getProperty("description"));
3137 if (dia->exec() == QDialog::Accepted) {
3138 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3139 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3141 QMap <QString, QString> newprops;
3143 if (KUrl(textTemplate).path() != templatePath) {
3144 // The template was changed
3145 newprops.insert("resource", textTemplate);
3148 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3149 newprops.insert("description", dia_ui.description->toPlainText());
3152 QString newtemplate = newprops.value("xmltemplate");
3153 if (newtemplate.isEmpty()) newtemplate = templatePath;
3155 // template modified we need to update xmldata
3156 QString description = newprops.value("description");
3157 if (description.isEmpty()) description = clip->getProperty("description");
3158 else newprops.insert("templatetext", description);
3159 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3160 if (!newprops.isEmpty()) {
3161 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3162 m_activeDocument->commandStack()->push(command);
3168 QString path = clip->getProperty("resource");
3169 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3171 doc.setContent(clip->getProperty("xmldata"));
3172 dia_ui->setXml(doc);
3173 if (dia_ui->exec() == QDialog::Accepted) {
3174 QMap <QString, QString> newprops;
3175 newprops.insert("xmldata", dia_ui->xml().toString());
3176 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3177 // duration changed, we need to update duration
3178 newprops.insert("out", QString::number(dia_ui->outPoint()));
3179 int currentLength = QString(clip->producerProperty("length")).toInt();
3180 if (currentLength <= dia_ui->outPoint())
3181 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3182 else newprops.insert("length", clip->producerProperty("length"));
3184 if (!path.isEmpty()) {
3185 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3186 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) {
3187 // save to external file
3188 dia_ui->saveTitle(path);
3189 } else newprops.insert("resource", QString());
3191 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3192 m_activeDocument->commandStack()->push(command);
3193 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3194 m_activeDocument->setModified(true);
3198 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3202 // any type of clip but a title
3203 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3204 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3205 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3206 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)));
3211 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3213 if (newprops.isEmpty()) return;
3214 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3215 m_activeDocument->commandStack()->push(command);
3216 m_activeDocument->setModified();
3219 // update clip occurences in timeline
3220 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3225 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3227 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3228 if (dia.exec() == QDialog::Accepted) {
3229 QUndoCommand *command = new QUndoCommand();
3230 command->setText(i18n("Edit clips"));
3231 QMap <QString, QString> newImageProps = dia.properties();
3232 // Transparency setting applies only for images
3233 QMap <QString, QString> newProps = newImageProps;
3234 newProps.remove("transparency");
3236 for (int i = 0; i < cliplist.count(); i++) {
3237 DocClipBase *clip = cliplist.at(i);
3238 if (clip->clipType() == IMAGE)
3239 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3241 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3243 m_activeDocument->commandStack()->push(command);
3244 for (int i = 0; i < cliplist.count(); i++)
3245 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3249 void MainWindow::customEvent(QEvent* e)
3251 if (e->type() == QEvent::User)
3252 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3254 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3260 m_effectStack->raiseWindow(m_effectStackDock);
3263 void MainWindow::slotActivateTransitionView(Transition *t)
3266 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3269 void MainWindow::slotSnapRewind()
3271 if (m_projectMonitor->isActive()) {
3272 if (m_activeTimeline)
3273 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3275 m_clipMonitor->slotSeekToPreviousSnap();
3279 void MainWindow::slotSnapForward()
3281 if (m_projectMonitor->isActive()) {
3282 if (m_activeTimeline)
3283 m_activeTimeline->projectView()->slotSeekToNextSnap();
3285 m_clipMonitor->slotSeekToNextSnap();
3289 void MainWindow::slotClipStart()
3291 if (m_projectMonitor->isActive()) {
3292 if (m_activeTimeline)
3293 m_activeTimeline->projectView()->clipStart();
3297 void MainWindow::slotClipEnd()
3299 if (m_projectMonitor->isActive()) {
3300 if (m_activeTimeline)
3301 m_activeTimeline->projectView()->clipEnd();
3305 void MainWindow::slotZoneStart()
3307 if (m_projectMonitor->isActive())
3308 m_projectMonitor->slotZoneStart();
3310 m_clipMonitor->slotZoneStart();
3313 void MainWindow::slotZoneEnd()
3315 if (m_projectMonitor->isActive())
3316 m_projectMonitor->slotZoneEnd();
3318 m_clipMonitor->slotZoneEnd();
3321 void MainWindow::slotChangeTool(QAction * action)
3323 if (action == m_buttonSelectTool)
3324 slotSetTool(SELECTTOOL);
3325 else if (action == m_buttonRazorTool)
3326 slotSetTool(RAZORTOOL);
3327 else if (action == m_buttonSpacerTool)
3328 slotSetTool(SPACERTOOL);
3331 void MainWindow::slotChangeEdit(QAction * action)
3333 if (!m_activeTimeline)
3336 if (action == m_overwriteEditTool)
3337 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3338 else if (action == m_insertEditTool)
3339 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3341 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3344 void MainWindow::slotSetTool(PROJECTTOOL tool)
3346 if (m_activeDocument && m_activeTimeline) {
3347 //m_activeDocument->setTool(tool);
3351 message = i18n("Ctrl + click to use spacer on current track only");
3354 message = i18n("Click on a clip to cut it");
3357 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3360 m_messageLabel->setMessage(message, InformationMessage);
3361 m_activeTimeline->projectView()->setTool(tool);
3365 void MainWindow::slotCopy()
3367 if (m_activeDocument && m_activeTimeline)
3368 m_activeTimeline->projectView()->copyClip();
3371 void MainWindow::slotPaste()
3373 if (m_activeDocument && m_activeTimeline)
3374 m_activeTimeline->projectView()->pasteClip();
3377 void MainWindow::slotPasteEffects()
3379 if (m_activeDocument && m_activeTimeline)
3380 m_activeTimeline->projectView()->pasteClipEffects();
3383 void MainWindow::slotFind()
3385 if (!m_activeDocument || !m_activeTimeline) return;
3386 m_projectSearch->setEnabled(false);
3387 m_findActivated = true;
3388 m_findString.clear();
3389 m_activeTimeline->projectView()->initSearchStrings();
3390 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3391 m_findTimer.start(5000);
3392 qApp->installEventFilter(this);
3395 void MainWindow::slotFindNext()
3397 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3398 statusBar()->showMessage(i18n("Found: %1", m_findString));
3400 statusBar()->showMessage(i18n("Reached end of project"));
3401 m_findTimer.start(4000);
3404 void MainWindow::findAhead()
3406 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3407 m_projectSearchNext->setEnabled(true);
3408 statusBar()->showMessage(i18n("Found: %1", m_findString));
3410 m_projectSearchNext->setEnabled(false);
3411 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3415 void MainWindow::findTimeout()
3417 m_projectSearchNext->setEnabled(false);
3418 m_findActivated = false;
3419 m_findString.clear();
3420 statusBar()->showMessage(i18n("Find stopped"), 3000);
3421 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3422 m_projectSearch->setEnabled(true);
3423 removeEventFilter(this);
3426 void MainWindow::slotClipInTimeline(const QString &clipId)
3428 if (m_activeTimeline && m_activeDocument) {
3429 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3431 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3432 inTimelineMenu->clear();
3434 QList <QAction *> actionList;
3436 for (int i = 0; i < matching.count(); ++i) {
3437 QString track = QString::number(matching.at(i).track);
3438 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3440 QAction *a = new QAction(track + ": " + start, this);
3441 a->setData(QStringList() << track << start);
3442 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3443 while (j < actionList.count()) {
3444 if (actionList.at(j)->text() > a->text()) break;
3447 actionList.insert(j, a);
3449 inTimelineMenu->addActions(actionList);
3451 if (matching.empty())
3452 inTimelineMenu->setEnabled(false);
3454 inTimelineMenu->setEnabled(true);
3458 void MainWindow::slotClipInProjectTree()
3460 if (m_activeTimeline) {
3461 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3462 if (clipIds.isEmpty())
3464 m_projectListDock->raise();
3465 for (int i = 0; i < clipIds.count(); i++)
3466 m_projectList->selectItemById(clipIds.at(i));
3467 if (m_projectMonitor->isActive())
3468 slotSwitchMonitors();
3472 /*void MainWindow::slotClipToProjectTree()
3474 if (m_activeTimeline) {
3475 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3476 if (clips.isEmpty()) return;
3477 for (int i = 0; i < clips.count(); i++) {
3478 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3480 //m_projectList->selectItemById(clipIds.at(i));
3484 void MainWindow::slotSelectClipInTimeline()
3486 if (m_activeTimeline) {
3487 QAction *action = qobject_cast<QAction *>(sender());
3488 QStringList data = action->data().toStringList();
3489 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3493 void MainWindow::keyPressEvent(QKeyEvent *ke)
3495 if (m_findActivated) {
3496 if (ke->key() == Qt::Key_Backspace) {
3497 m_findString = m_findString.left(m_findString.length() - 1);
3499 if (!m_findString.isEmpty())
3504 m_findTimer.start(4000);
3507 } else if (ke->key() == Qt::Key_Escape) {
3511 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3512 m_findString += ke->text();
3516 m_findTimer.start(4000);
3521 KXmlGuiWindow::keyPressEvent(ke);
3526 /** Gets called when the window gets hidden */
3527 void MainWindow::hideEvent(QHideEvent */*event*/)
3529 if (isMinimized() && m_monitorManager)
3530 m_monitorManager->stopActiveMonitor();
3533 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3535 if (m_findActivated) {
3536 if (event->type() == QEvent::ShortcutOverride) {
3537 QKeyEvent* ke = (QKeyEvent*) event;
3538 if (ke->text().trimmed().isEmpty()) return false;
3545 // pass the event on to the parent class
3546 return QMainWindow::eventFilter(obj, event);
3551 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3553 KDialog *dialog = new KDialog(this);
3554 dialog->setCaption("Save clip zone");
3555 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3557 QWidget *widget = new QWidget(dialog);
3558 dialog->setMainWidget(widget);
3560 QVBoxLayout *vbox = new QVBoxLayout(widget);
3561 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3562 if (path.isEmpty()) {
3563 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3564 if (baseClip == NULL) tmppath.append("untitled.mlt");
3566 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3568 path = KUrl(tmppath);
3570 KUrlRequester *url = new KUrlRequester(path, this);
3571 url->setFilter("video/mlt-playlist");
3572 QLabel *label2 = new QLabel(i18n("Description:"), this);
3573 KLineEdit *edit = new KLineEdit(this);
3574 vbox->addWidget(label1);
3575 vbox->addWidget(url);
3576 vbox->addWidget(label2);
3577 vbox->addWidget(edit);
3578 if (dialog->exec() == QDialog::Accepted) {
3579 if (QFile::exists(url->url().path())) {
3580 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3581 slotSaveZone(render, zone, baseClip, url->url());
3585 if (baseClip && !baseClip->fileURL().isEmpty()) {
3586 // create zone from clip url, so that we don't have problems with proxy clips
3588 #if QT_VERSION >= 0x040600
3589 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3590 env.remove("MLT_PROFILE");
3591 p.setProcessEnvironment(env);
3593 QStringList env = QProcess::systemEnvironment();
3594 env << "MLT_PROFILE='\0'";
3595 p.setEnvironment(env);
3597 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3598 if (!p.waitForStarted(3000)) {
3599 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3601 else if (!p.waitForFinished(5000)) {
3602 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3605 else render->saveZone(url->url(), edit->text(), zone);
3610 void MainWindow::slotSetInPoint()
3612 if (m_clipMonitor->isActive()) {
3613 m_clipMonitor->slotSetZoneStart();
3615 m_projectMonitor->slotSetZoneStart();
3619 void MainWindow::slotSetOutPoint()
3621 if (m_clipMonitor->isActive()) {
3622 m_clipMonitor->slotSetZoneEnd();
3624 m_projectMonitor->slotSetZoneEnd();
3628 void MainWindow::slotResizeItemStart()
3630 if (m_activeTimeline)
3631 m_activeTimeline->projectView()->setInPoint();
3634 void MainWindow::slotResizeItemEnd()
3636 if (m_activeTimeline)
3637 m_activeTimeline->projectView()->setOutPoint();
3640 int MainWindow::getNewStuff(const QString &configFile)
3642 KNS3::Entry::List entries;
3643 #if KDE_IS_VERSION(4,3,80)
3644 KNS3::DownloadDialog dialog(configFile);
3646 entries = dialog.changedEntries();
3647 foreach(const KNS3::Entry & entry, entries) {
3648 if (entry.status() == KNS3::Entry::Installed)
3649 kDebug() << "// Installed files: " << entry.installedFiles();
3652 KNS::Engine engine(0);
3653 if (engine.init(configFile))
3654 entries = engine.downloadDialogModal(this);
3655 foreach(KNS::Entry * entry, entries) {
3656 if (entry->status() == KNS::Entry::Installed)
3657 kDebug() << "// Installed files: " << entry->installedFiles();
3659 #endif /* KDE_IS_VERSION(4,3,80) */
3660 return entries.size();
3663 void MainWindow::slotGetNewTitleStuff()
3665 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3666 TitleWidget::refreshTitleTemplates();
3669 void MainWindow::slotGetNewLumaStuff()
3671 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3672 initEffects::refreshLumas();
3673 m_activeTimeline->projectView()->reloadTransitionLumas();
3677 void MainWindow::slotGetNewRenderStuff()
3679 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3681 m_renderWidget->reloadProfiles();
3684 void MainWindow::slotGetNewMltProfileStuff()
3686 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3687 // update the list of profiles in settings dialog
3688 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3694 void MainWindow::slotAutoTransition()
3696 if (m_activeTimeline)
3697 m_activeTimeline->projectView()->autoTransition();
3700 void MainWindow::slotSplitAudio()
3702 if (m_activeTimeline)
3703 m_activeTimeline->projectView()->splitAudio();
3706 void MainWindow::slotUpdateClipType(QAction *action)
3708 if (m_activeTimeline) {
3709 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3710 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3711 else m_activeTimeline->projectView()->setAudioAndVideo();
3715 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3717 // We must stop the monitors since we create a new on in the dvd wizard
3718 m_clipMonitor->stop();
3719 m_projectMonitor->stop();
3720 DvdWizard w(url, profile, this);
3722 m_projectMonitor->start();
3725 void MainWindow::slotShowTimeline(bool show)
3727 if (show == false) {
3728 m_timelineState = saveState();
3729 centralWidget()->setHidden(true);
3731 centralWidget()->setHidden(false);
3732 restoreState(m_timelineState);
3736 void MainWindow::slotMaximizeCurrent(bool)
3738 //TODO: is there a way to maximize current widget?
3740 m_timelineState = saveState();
3741 QWidget *par = focusWidget()->parentWidget();
3742 while (par->parentWidget() && par->parentWidget() != this)
3743 par = par->parentWidget();
3744 kDebug() << "CURRENT WIDGET: " << par->objectName();
3747 void MainWindow::loadTranscoders()
3749 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3752 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3753 KConfigGroup transConfig(config, "Transcoding");
3755 QMap< QString, QString > profiles = transConfig.entryMap();
3756 QMapIterator<QString, QString> i(profiles);
3757 while (i.hasNext()) {
3759 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3760 QAction *a = transMenu->addAction(i.key());
3762 if (data.count() > 1)
3763 a->setToolTip(data.at(1));
3764 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3768 void MainWindow::slotTranscode(KUrl::List urls)
3773 if (urls.isEmpty()) {
3774 QAction *action = qobject_cast<QAction *>(sender());
3775 QStringList data = action->data().toStringList();
3776 params = data.at(0);
3777 if (data.count() > 1) desc = data.at(1);
3778 if (data.count() > 2) condition = data.at(2);
3779 urls << m_projectList->getConditionalUrls(condition);
3780 urls.removeAll(KUrl());
3782 if (urls.isEmpty()) {
3783 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3786 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3787 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3789 //QProcess::startDetached("ffmpeg", parameters);
3792 void MainWindow::slotTranscodeClip()
3794 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3795 if (urls.isEmpty()) return;
3796 slotTranscode(urls);
3799 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3801 if (m_activeDocument == NULL) return;
3802 QMapIterator<QString, QString> i(props);
3803 while (i.hasNext()) {
3805 m_activeDocument->setDocumentProperty(i.key(), i.value());
3807 m_activeDocument->setModified(true);
3811 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3813 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3815 QString playlistPath;
3818 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3819 QString path = m_renderWidget->getFreeScriptName();
3820 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3821 if (!ok || scriptPath.isEmpty()) return;
3822 scriptPath.prepend(scriptsFolder);
3823 QFile f(scriptPath);
3825 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3828 playlistPath = scriptPath + ".mlt";
3830 KTemporaryFile temp;
3831 temp.setAutoRemove(false);
3832 temp.setSuffix(".mlt");
3834 playlistPath = temp.fileName();
3836 QString playlistContent = m_projectMonitor->sceneList();
3837 if (!chapterFile.isEmpty()) {
3840 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3842 in = m_activeTimeline->inPoint();
3843 out = m_activeTimeline->outPoint();
3846 QDomElement chapters = doc.createElement("chapters");
3847 chapters.setAttribute("fps", m_activeDocument->fps());
3848 doc.appendChild(chapters);
3850 QDomElement guidesxml = m_activeDocument->guidesXml();
3851 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3852 for (int i = 0; i < nodes.count(); i++) {
3853 QDomElement e = nodes.item(i).toElement();
3855 QString comment = e.attribute("comment");
3856 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3857 if (time >= in && time < out) {
3858 if (zoneOnly) time = time - in;
3859 QDomElement chapter = doc.createElement("chapter");
3860 chapters.appendChild(chapter);
3861 chapter.setAttribute("title", comment);
3862 chapter.setAttribute("time", time);
3866 if (chapters.childNodes().count() > 0) {
3867 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3868 // Always insert a guide in pos 0
3869 QDomElement chapter = doc.createElement("chapter");
3870 chapters.insertBefore(chapter, QDomNode());
3871 chapter.setAttribute("title", i18n("Start"));
3872 chapter.setAttribute("time", "0");
3874 // save chapters file
3875 QFile file(chapterFile);
3876 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3877 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3879 file.write(doc.toString().toUtf8());
3880 if (file.error() != QFile::NoError) {
3881 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3888 if (m_renderWidget->automaticAudioExport()) {
3889 exportAudio = m_activeTimeline->checkProjectAudio();
3890 } else exportAudio = m_renderWidget->selectedAudioExport();
3892 // Set playlist audio volume to 100%
3894 doc.setContent(playlistContent);
3895 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3896 if (!tractor.isNull()) {
3897 QDomNodeList props = tractor.elementsByTagName("property");
3898 for (int i = 0; i < props.count(); i++) {
3899 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3900 props.at(i).firstChild().setNodeValue("1");
3906 // Do we want proxy rendering
3907 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3908 QString root = doc.documentElement().attribute("root");
3910 // replace proxy clips with originals
3911 QMap <QString, QString> proxies = m_projectList->getProxies();
3913 QDomNodeList producers = doc.elementsByTagName("producer");
3914 QString producerResource;
3916 for (uint n = 0; n < producers.length(); n++) {
3917 QDomElement e = producers.item(n).toElement();
3918 producerResource = EffectsList::property(e, "resource");
3919 if (producerResource.isEmpty()) continue;
3920 if (!producerResource.startsWith("/")) {
3921 producerResource.prepend(root + "/");
3923 if (producerResource.contains('?')) {
3924 // slowmotion producer
3925 suffix = "?" + producerResource.section('?', 1);
3926 producerResource = producerResource.section('?', 0, 0);
3928 else suffix.clear();
3929 if (!producerResource.isEmpty()) {
3930 if (proxies.contains(producerResource)) {
3931 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3932 // We need to delete the "aspect_ratio" property because proxy clips
3933 // sometimes have different ratio than original clips
3934 EffectsList::removeProperty(e, "aspect_ratio");
3939 /*QMapIterator<QString, QString> i(proxies);
3940 while (i.hasNext()) {
3942 // Replace all keys with their values (proxy path with original path)
3943 QString key = i.key();
3944 playlistContent.replace(key, i.value());
3945 if (!root.isEmpty() && key.startsWith(root)) {
3946 // in case the resource path in MLT playlist is relative
3947 key.remove(0, root.count() + 1);
3948 playlistContent.replace(key, i.value());
3952 playlistContent = doc.toString();
3954 // Do save scenelist
3955 QFile file(playlistPath);
3956 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3957 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3960 file.write(playlistContent.toUtf8());
3961 if (file.error() != QFile::NoError) {
3962 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3967 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3970 void MainWindow::slotUpdateTimecodeFormat(int ix)
3972 KdenliveSettings::setFrametimecode(ix == 1);
3973 m_clipMonitor->updateTimecodeFormat();
3974 m_projectMonitor->updateTimecodeFormat();
3975 m_transitionConfig->updateTimecodeFormat();
3976 m_effectStack->updateTimecodeFormat();
3977 //m_activeTimeline->projectView()->clearSelection();
3978 m_activeTimeline->updateRuler();
3981 void MainWindow::slotRemoveFocus()
3983 statusBar()->setFocus();
3984 statusBar()->clearFocus();
3987 void MainWindow::slotRevert()
3989 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;
3990 KUrl url = m_activeDocument->url();
3991 if (closeCurrentDocument(false))
3992 doOpenFile(url, NULL);
3996 void MainWindow::slotShutdown()
3998 if (m_activeDocument) m_activeDocument->setModified(false);
4000 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4001 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4002 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4003 smserver.call("logout", 1, 2, 2);
4004 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4005 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4006 smserver.call("Shutdown");
4010 void MainWindow::slotUpdateTrackInfo()
4012 if (m_activeDocument)
4013 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4016 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4018 // Load the theme file
4020 if (action == NULL) theme = themename;
4021 else theme = action->data().toString();
4022 KdenliveSettings::setColortheme(theme);
4023 // Make palette for all widgets.
4024 QPalette plt = kapp->palette();
4025 if (theme.isEmpty()) {
4026 plt = QApplication::desktop()->palette();
4028 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4030 #if KDE_IS_VERSION(4,6,3)
4031 plt = KGlobalSettings::createNewApplicationPalette(config);
4033 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4034 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4035 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4036 QPalette::Disabled };
4037 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4038 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4040 for ( int i = 0; i < 3 ; i++ ) {
4041 QPalette::ColorGroup state = states[i];
4042 KColorScheme schemeView(state, KColorScheme::View, config);
4043 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4044 KColorScheme schemeButton(state, KColorScheme::Button, config);
4045 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4047 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4048 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4049 plt.setBrush( state, QPalette::Base, schemeView.background() );
4050 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4051 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4052 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4053 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4054 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4055 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4056 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4058 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4059 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4060 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4061 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4062 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4064 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4065 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4066 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4071 kapp->setPalette(plt);
4072 const QObjectList children = statusBar()->children();
4074 foreach(QObject * child, children) {
4075 if (child->isWidgetType())
4076 ((QWidget*)child)->setPalette(plt);
4077 const QObjectList subchildren = child->children();
4078 foreach(QObject * subchild, subchildren) {
4079 if (subchild->isWidgetType())
4080 ((QWidget*)subchild)->setPalette(plt);
4083 if (m_activeTimeline) {
4084 m_activeTimeline->projectView()->updatePalette();
4089 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4091 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4092 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4093 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4094 const QSize bitsSize(24, 2);
4095 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4096 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4098 QPixmap pixmap(23, 16);
4099 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4101 KConfigGroup group(config, "WM");
4102 QPainter p(&pixmap);
4103 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4104 p.fillRect(1, 1, 7, 7, windowScheme.background());
4105 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4107 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4108 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4109 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4111 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4112 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4114 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4115 p.fillRect(1, 8, 7, 7, viewScheme.background());
4116 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4118 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4119 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4120 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4122 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4123 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4129 void MainWindow::slotSwitchMonitors()
4131 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4132 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4133 else m_projectList->focusTree();
4136 void MainWindow::slotSwitchFullscreen()
4138 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4139 else m_clipMonitor->slotSwitchFullScreen();
4142 void MainWindow::slotInsertZoneToTree()
4144 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4145 QStringList info = m_clipMonitor->getZoneInfo();
4146 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4149 void MainWindow::slotInsertZoneToTimeline()
4151 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4152 QStringList info = m_clipMonitor->getZoneInfo();
4153 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4157 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4159 if (m_activeDocument && m_activeTimeline) {
4160 if (!ids.isEmpty()) {
4161 for (int i = 0; i < ids.size(); ++i) {
4162 m_activeTimeline->slotDeleteClip(ids.at(i));
4164 m_activeDocument->clipManager()->slotDeleteClips(ids);
4166 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4167 m_activeDocument->setModified(true);
4171 void MainWindow::slotShowTitleBars(bool show)
4173 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4174 for (int i = 0; i < docks.count(); i++) {
4175 QDockWidget* dock = docks.at(i);
4177 dock->setTitleBarWidget(0);
4179 if (!dock->isFloating()) {
4180 dock->setTitleBarWidget(new QWidget);
4184 KdenliveSettings::setShowtitlebars(show);
4187 void MainWindow::slotSwitchTitles()
4189 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4192 QString MainWindow::getMimeType(bool open)
4194 QString mimetype = "application/x-kdenlive";
4195 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4197 mimetype = "*.kdenlive";
4198 if (open) mimetype.append(" *.tar.gz");
4200 else if (open) mimetype.append(" application/x-compressed-tar");
4204 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4207 m_projectMonitor->render->sendFrameForAnalysis = true;
4210 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4211 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4218 qDebug() << "Any scope accepting new frames? " << request;
4221 m_projectMonitor->render->sendFrameForAnalysis = false;
4225 void MainWindow::slotUpdateGfxScopeFrameRequest()
4227 // We need a delay to make sure widgets are hidden after a close event for example
4228 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4231 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4234 bool request = false;
4235 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4236 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4237 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4243 if (!m_projectMonitor->effectSceneDisplayed()) {
4244 m_projectMonitor->render->sendFrameForAnalysis = false;
4246 m_clipMonitor->render->sendFrameForAnalysis = false;
4248 m_recMonitor->analyseFrames(false);
4250 m_projectMonitor->render->sendFrameForAnalysis = true;
4251 m_clipMonitor->render->sendFrameForAnalysis = true;
4253 m_recMonitor->analyseFrames(true);
4257 void MainWindow::slotUpdateAudioScopeFrameRequest()
4259 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4262 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4264 bool request = false;
4265 for (int i = 0; i < m_audioScopesList.count(); i++) {
4266 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4267 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4272 // Handle audio signal separately (no common interface)
4273 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4274 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4278 qDebug() << "Scopes Requesting Audio data: " << request;
4280 KdenliveSettings::setMonitor_audio(request);
4281 m_monitorManager->slotUpdateAudioMonitoring();
4284 void MainWindow::slotUpdateColorScopes()
4286 bool request = false;
4287 kDebug()<<"// UPDATE SCOPES";
4288 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4289 // Check if we need the renderer to send a new frame for update
4290 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4291 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4293 if (request && m_monitorManager->activeRenderer()) {
4294 m_monitorManager->activeRenderer()->sendFrameUpdate();
4298 void MainWindow::slotClearColorScopes()
4300 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4301 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4305 void MainWindow::slotOpenStopmotion()
4307 if (m_stopmotion == NULL) {
4308 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4309 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4310 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4311 // Check if we need the renderer to send a new frame for update
4312 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4313 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4314 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4317 m_stopmotion->show();
4320 void MainWindow::slotDeleteClip(const QString &id)
4322 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4323 for (int i = 0; i < list.size(); ++i) {
4324 list.at(i)->disableClipId(id);
4326 m_projectList->slotDeleteClip(id);
4329 void MainWindow::slotUpdateProxySettings()
4331 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4332 if (KdenliveSettings::enableproxy())
4333 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4334 m_projectList->updateProxyConfig();
4337 void MainWindow::slotInsertNotesTimecode()
4339 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4340 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4341 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4344 void MainWindow::slotArchiveProject()
4346 QList <DocClipBase*> list = m_projectList->documentClipList();
4347 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4348 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4353 void MainWindow::slotOpenBackupDialog(const KUrl url)
4358 kDebug()<<"// BACKUP URL: "<<url.path();
4359 if (!url.isEmpty()) {
4360 // we could not open the project file, guess where the backups are
4361 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4365 projectFolder = m_activeDocument->projectFolder();
4366 projectFile = m_activeDocument->url();
4367 projectId = m_activeDocument->getDocumentProperty("documentid");
4370 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4371 if (dia->exec() == QDialog::Accepted) {
4372 QString requestedBackup = dia->selectedFile();
4373 m_activeDocument->backupLastSavedVersion(projectFile.path());
4374 closeCurrentDocument(false);
4375 doOpenFile(KUrl(requestedBackup), NULL);
4376 m_activeDocument->setUrl(projectFile);
4377 m_activeDocument->setModified(true);
4378 setCaption(m_activeDocument->description());
4383 void MainWindow::slotBlockClipMonitor(const QString id)
4385 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) m_clipMonitor->slotSetXml(NULL);
4389 void MainWindow::slotElapsedTime()
4391 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4394 #include "mainwindow.moc"