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 #endif /* NO_JOGSHUTTLE */
46 #include "clipproperties.h"
48 #include "editclipcommand.h"
49 #include "titlewidget.h"
50 #include "markerdialog.h"
52 #include "interfaces.h"
53 #include "kdenlive-config.h"
54 #include "cliptranscode.h"
55 #include "ui_templateclip_ui.h"
56 #include "colorscopes/vectorscope.h"
57 #include "colorscopes/waveform.h"
58 #include "colorscopes/rgbparade.h"
59 #include "colorscopes/histogram.h"
60 #include "audiospectrum.h"
61 #include "spectrogram.h"
63 #include <KApplication>
67 #include <KActionCollection>
68 #include <KActionCategory>
69 #include <KStandardAction>
70 #include <KShortcutsDialog>
71 #include <KFileDialog>
72 #include <KMessageBox>
74 #include <KIO/NetAccess>
77 #include <KConfigDialog>
78 #include <KXMLGUIFactory>
80 #include <kstandarddirs.h>
81 #include <KUrlRequesterDialog>
82 #include <KTemporaryFile>
84 #include <KActionMenu>
87 #include <ktogglefullscreenaction.h>
89 #include <KNotification>
90 #include <KNotifyConfigWidget>
91 #if KDE_IS_VERSION(4,3,80)
92 #include <knewstuff3/downloaddialog.h>
93 #include <knewstuff3/knewstuffaction.h>
95 #include <knewstuff2/engine.h>
96 #include <knewstuff2/ui/knewstuffaction.h>
98 #endif /* KDE_IS_VERSION(4,3,80) */
100 #include <KColorScheme>
101 #include <KProgressDialog>
103 #include <QTextStream>
107 #include <QInputDialog>
108 #include <QDesktopWidget>
113 static const char version[] = VERSION;
115 static const int ID_TIMELINE_POS = 0;
121 Q_DECLARE_METATYPE(QVector<int16_t>)
123 EffectsList MainWindow::videoEffects;
124 EffectsList MainWindow::audioEffects;
125 EffectsList MainWindow::customEffects;
126 EffectsList MainWindow::transitions;
128 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
129 KXmlGuiWindow(parent),
130 m_activeDocument(NULL),
131 m_activeTimeline(NULL),
132 m_renderWidget(NULL),
133 #ifndef NO_JOGSHUTTLE
135 #endif /* NO_JOGSHUTTLE */
136 m_findActivated(false),
139 qRegisterMetaType<QVector<int16_t> > ();
140 // Create DBus interface
141 new MainWindowAdaptor(this);
142 QDBusConnection dbus = QDBusConnection::sessionBus();
143 dbus.registerObject("/MainWindow", this);
145 setlocale(LC_NUMERIC, "POSIX");
146 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
147 setFont(KGlobalSettings::toolBarFont());
148 parseProfiles(MltPath);
149 m_commandStack = new QUndoGroup;
150 setDockNestingEnabled(true);
151 m_timelineArea = new KTabWidget(this);
152 m_timelineArea->setTabReorderingEnabled(true);
153 m_timelineArea->setTabBarHidden(true);
154 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
155 m_timelineArea->setMinimumHeight(200);
157 QToolButton *closeTabButton = new QToolButton;
158 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
159 closeTabButton->setIcon(KIcon("tab-close"));
160 closeTabButton->adjustSize();
161 closeTabButton->setToolTip(i18n("Close the current tab"));
162 m_timelineArea->setCornerWidget(closeTabButton);
163 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
165 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
166 m_findTimer.setSingleShot(true);
168 // FIXME: the next call returns a newly allocated object, which leaks
169 initEffects::parseEffectFiles();
170 //initEffects::parseCustomEffectsFile();
172 m_monitorManager = new MonitorManager();
174 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
175 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
180 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
181 m_projectListDock->setObjectName("project_tree");
182 m_projectList = new ProjectList();
183 m_projectListDock->setWidget(m_projectList);
184 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
186 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
187 m_clipMonitorDock->setObjectName("clip_monitor");
188 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
189 m_clipMonitorDock->setWidget(m_clipMonitor);
190 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
192 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
193 m_projectMonitorDock->setObjectName("project_monitor");
194 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
195 m_projectMonitorDock->setWidget(m_projectMonitor);
196 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
199 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
200 m_recMonitorDock->setObjectName("record_monitor");
201 m_recMonitor = new RecMonitor("record");
202 m_recMonitorDock->setWidget(m_recMonitor);
203 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
204 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
205 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
208 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
209 m_notesDock->setObjectName("notes_widget");
210 m_notesWidget = new KTextEdit();
211 m_notesWidget->setTabChangesFocus(true);
212 #if KDE_IS_VERSION(4,4,0)
213 m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
215 m_notesDock->setWidget(m_notesWidget);
216 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
218 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
219 m_effectStackDock->setObjectName("effect_stack");
220 m_effectStack = new EffectStackView(m_projectMonitor);
221 m_effectStackDock->setWidget(m_effectStack);
222 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
224 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
225 m_transitionConfigDock->setObjectName("transition");
226 m_transitionConfig = new TransitionSettings(m_projectMonitor);
227 m_transitionConfigDock->setWidget(m_transitionConfig);
228 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
230 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
231 m_effectListDock->setObjectName("effect_list");
232 m_effectList = new EffectsListView();
233 m_effectListDock->setWidget(m_effectList);
234 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
236 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
237 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
238 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
239 m_vectorscopeDock->setWidget(m_vectorscope);
240 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
241 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
242 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
243 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
244 m_scopesList.append(m_vectorscopeDock);
246 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
247 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
248 m_waveformDock->setObjectName(m_waveform->widgetName());
249 m_waveformDock->setWidget(m_waveform);
250 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
251 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
252 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
253 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
254 m_scopesList.append(m_waveformDock);
256 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
257 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
258 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
259 m_RGBParadeDock->setWidget(m_RGBParade);
260 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
261 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
262 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
263 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
264 m_scopesList.append(m_RGBParadeDock);
266 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
267 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
268 m_histogramDock->setObjectName(m_histogram->widgetName());
269 m_histogramDock->setWidget(m_histogram);
270 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
271 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
272 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
273 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
274 m_scopesList.append(m_histogramDock);
277 m_audiosignal = new AudioSignal;
278 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
279 m_audiosignalDock->setObjectName("audiosignal");
280 m_audiosignalDock->setWidget(m_audiosignal);
281 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
282 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
283 /*if (m_projectMonitor) {
284 connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
287 connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
290 m_audioSpectrum = new AudioSpectrum();
291 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
292 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
293 m_audioSpectrumDock->setWidget(m_audioSpectrum);
294 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
296 m_spectrogram = new Spectrogram();
297 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
298 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
299 m_spectrogramDock->setWidget(m_spectrogram);
300 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
302 // Connect the audio signal to the audio scope slots
304 if (m_projectMonitor) {
305 qDebug() << "project monitor connected";
306 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
307 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
308 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
309 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
310 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
311 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
314 qDebug() << "clip monitor connected";
315 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
316 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
317 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
318 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
319 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
320 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
322 // Ensure connections were set up correctly
325 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
326 m_undoViewDock->setObjectName("undo_history");
327 m_undoView = new QUndoView();
328 m_undoView->setCleanIcon(KIcon("edit-clear"));
329 m_undoView->setEmptyLabel(i18n("Clean"));
330 m_undoViewDock->setWidget(m_undoView);
331 m_undoView->setGroup(m_commandStack);
332 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
334 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
335 //overviewDock->setObjectName("project_overview");
336 //m_overView = new CustomTrackView(NULL, NULL, this);
337 //overviewDock->setWidget(m_overView);
338 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
343 /// Tabify Widgets ///
344 tabifyDockWidget(m_projectListDock, m_effectStackDock);
345 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
346 tabifyDockWidget(m_projectListDock, m_notesDock);
349 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
351 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
354 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
355 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
356 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
357 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
358 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
361 setCentralWidget(m_timelineArea);
364 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
365 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
367 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
368 m_fileRevert->setEnabled(false);
370 // Prepare layout actions
371 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
372 for (int i = 1; i < 5; i++) {
373 KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
374 load->setData("_" + QString::number(i));
375 layoutActions->addAction("load_layout" + QString::number(i), load);
376 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
377 save->setData("_" + QString::number(i));
378 layoutActions->addAction("save_layout" + QString::number(i), save);
382 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
383 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
384 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
385 action->setShortcut(Qt::Key_Space);
386 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
387 m_stopmotion_actions->addAction("stopmotion_capture", action);
388 action = new KAction(i18n("Switch live / captured frame"), this);
389 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
390 m_stopmotion_actions->addAction("stopmotion_switch", action);
391 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
392 action->setCheckable(true);
393 action->setChecked(false);
394 m_stopmotion_actions->addAction("stopmotion_overlay", action);
398 // Find QDockWidget tab bars and show / hide widget title bars on right click
399 QList <QTabBar *> tabs = findChildren<QTabBar *>();
400 for (int i = 0; i < tabs.count(); i++) {
401 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
402 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
405 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
406 guiFactory()->addClient(sp);*/
409 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
411 connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
412 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
414 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
417 // Load layout names from config file
422 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
424 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
425 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
427 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
428 clipInTimeline->setIcon(KIcon("go-jump"));
429 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
430 static_cast<QMenu*>(factory()->container("transcoders", this)),
433 // build themes menus
434 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
435 QActionGroup *themegroup = new QActionGroup(this);
436 themegroup->setExclusive(true);
437 action = new KAction(i18n("Default"), this);
438 action->setCheckable(true);
439 themegroup->addAction(action);
440 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
442 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
444 for (int i = 0; i < schemeFiles.size(); ++i) {
446 const QString filename = schemeFiles.at(i);
447 const QFileInfo info(filename);
450 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
451 QIcon icon = createSchemePreviewIcon(config);
452 KConfigGroup group(config, "General");
453 const QString name = group.readEntry("Name", info.baseName());
454 action = new KAction(name, this);
455 action->setData(filename);
456 action->setIcon(icon);
457 action->setCheckable(true);
458 themegroup->addAction(action);
459 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
462 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
463 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
464 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
467 action = new QAction(fi.fileName(), this);
468 action->setData(*it);
469 action->setCheckable(true);
470 themegroup->addAction(action);
471 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
473 themesMenu->addActions(themegroup->actions());
474 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
476 // Setup and fill effects and transitions menus.
477 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
478 for (int i = 0; i < videoEffects.count(); ++i)
479 m_videoEffectsMenu->addAction(m_videoEffects[i]);
480 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
481 for (int i = 0; i < audioEffects.count(); ++i)
482 m_audioEffectsMenu->addAction(m_audioEffects[i]);
483 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
484 if (customEffects.isEmpty())
485 m_customEffectsMenu->setEnabled(false);
487 m_customEffectsMenu->setEnabled(true);
488 for (int i = 0; i < customEffects.count(); ++i)
489 m_customEffectsMenu->addAction(m_customEffects[i]);
490 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
491 for (int i = 0; i < transitions.count(); ++i)
492 m_transitionsMenu->addAction(m_transitions[i]);
494 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
495 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
496 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
497 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
499 QMenu *newEffect = new QMenu(this);
500 newEffect->addMenu(m_videoEffectsMenu);
501 newEffect->addMenu(m_audioEffectsMenu);
502 newEffect->addMenu(m_customEffectsMenu);
503 m_effectStack->setMenu(newEffect);
505 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
506 const QList<QAction *> viewActions = createPopupMenu()->actions();
507 viewMenu->insertActions(NULL, viewActions);
509 m_timelineContextMenu = new QMenu(this);
510 m_timelineContextClipMenu = new QMenu(this);
511 m_timelineContextTransitionMenu = new QMenu(this);
513 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
514 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
515 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
517 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
518 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
519 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
520 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
521 m_timelineContextClipMenu->addSeparator();
522 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
523 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
524 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
525 m_timelineContextClipMenu->addSeparator();
526 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
527 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
528 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
529 m_timelineContextClipMenu->addSeparator();
531 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
532 m_timelineContextClipMenu->addMenu(markersMenu);
533 m_timelineContextClipMenu->addSeparator();
534 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
535 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
536 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
537 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
539 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
540 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
541 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
543 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
545 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
546 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
547 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
548 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
549 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
550 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
551 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
553 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
554 slotConnectMonitors();
556 // Open or create a file. Command line argument passed in Url has
557 // precedence, then "openlastproject", then just a plain empty file.
558 // If opening Url fails, openlastproject will _not_ be used.
559 if (!Url.isEmpty()) {
560 // delay loading so that the window shows up
562 QTimer::singleShot(500, this, SLOT(openFile()));
563 } else if (KdenliveSettings::openlastproject()) {
564 QTimer::singleShot(500, this, SLOT(openLastFile()));
565 } else { //if (m_timelineArea->count() == 0) {
569 if (!clipsToLoad.isEmpty() && m_activeDocument) {
570 QStringList list = clipsToLoad.split(',');
572 foreach(QString path, list) {
573 kDebug() << QDir::current().absoluteFilePath(path);
574 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
576 m_projectList->slotAddClip(urls);
579 #ifndef NO_JOGSHUTTLE
580 activateShuttleDevice();
581 #endif /* NO_JOGSHUTTLE */
582 m_projectListDock->raise();
584 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
585 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
588 MainWindow::~MainWindow()
593 m_effectStack->slotClipItemSelected(NULL, 0);
594 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
596 if (m_projectMonitor) m_projectMonitor->stop();
597 if (m_clipMonitor) m_clipMonitor->stop();
599 delete m_activeTimeline;
600 delete m_effectStack;
601 delete m_transitionConfig;
602 delete m_activeDocument;
603 delete m_projectMonitor;
604 delete m_clipMonitor;
605 delete m_shortcutRemoveFocus;
606 Mlt::Factory::close();
609 void MainWindow::queryQuit()
617 bool MainWindow::queryClose()
619 if (m_renderWidget) {
620 int waitingJobs = m_renderWidget->waitingJobsCount();
621 if (waitingJobs > 0) {
622 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")))) {
623 case KMessageBox::Yes :
624 // create script with waiting jobs and start it
625 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
627 case KMessageBox::No :
628 // Don't do anything, jobs will be deleted
636 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
637 // warn the user to save if document is modified and we have clips in our project list
638 if (m_activeDocument && m_activeDocument->isModified() &&
639 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
640 !m_projectList->documentClipList().isEmpty())) {
644 if (m_activeDocument->url().fileName().isEmpty())
645 message = i18n("Save changes to document?");
647 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
648 switch (KMessageBox::warningYesNoCancel(this, message)) {
649 case KMessageBox::Yes :
650 // save document here. If saving fails, return false;
652 case KMessageBox::No :
653 // User does not want to save the changes, clear recovery files
654 m_activeDocument->m_autosave->resize(0);
663 void MainWindow::loadPlugins()
665 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
666 populateMenus(plugin);
669 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
671 filters << "libkdenlive*";
672 foreach(const QString & folder, directories) {
673 kDebug() << "Parsing plugin folder: " << folder;
674 QDir pluginsDir(folder);
675 foreach(const QString & fileName,
676 pluginsDir.entryList(filters, QDir::Files)) {
678 * Avoid loading the same plugin twice when there is more than one
681 if (!m_pluginFileNames.contains(fileName)) {
682 kDebug() << "Found plugin: " << fileName;
683 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
684 QObject *plugin = loader.instance();
686 populateMenus(plugin);
687 m_pluginFileNames += fileName;
689 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
695 void MainWindow::populateMenus(QObject *plugin)
697 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
698 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
700 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
704 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
705 QMenu *menu, const char *member,
706 QActionGroup *actionGroup)
708 kDebug() << "// ADD to MENU" << texts;
709 foreach(const QString & text, texts) {
710 QAction *action = new QAction(text, plugin);
711 action->setData(text);
712 connect(action, SIGNAL(triggered()), this, member);
713 menu->addAction(action);
716 action->setCheckable(true);
717 actionGroup->addAction(action);
722 void MainWindow::aboutPlugins()
724 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
729 void MainWindow::generateClip()
731 QAction *action = qobject_cast<QAction *>(sender());
732 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
734 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
735 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
736 if (!clipUrl.isEmpty()) {
737 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
741 void MainWindow::saveProperties(KConfigGroup &config)
743 // save properties here,used by session management
745 KMainWindow::saveProperties(config);
749 void MainWindow::readProperties(const KConfigGroup &config)
751 // read properties here,used by session management
752 KMainWindow::readProperties(config);
753 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
754 openFile(KUrl(Lastproject));
757 void MainWindow::slotReloadEffects()
759 m_customEffectsMenu->clear();
760 initEffects::parseCustomEffectsFile();
762 QStringList effectInfo;
763 QMap<QString, QStringList> effectsList;
764 for (int ix = 0; ix < customEffects.count(); ix++) {
765 effectInfo = customEffects.effectIdInfo(ix);
766 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
768 if (effectsList.isEmpty())
769 m_customEffectsMenu->setEnabled(false);
771 m_customEffectsMenu->setEnabled(true);
773 foreach(const QStringList & value, effectsList) {
774 action = new QAction(value.at(0), this);
775 action->setData(value);
776 m_customEffectsMenu->addAction(action);
778 m_effectList->reloadEffectList();
781 #ifndef NO_JOGSHUTTLE
782 void MainWindow::activateShuttleDevice()
786 if (KdenliveSettings::enableshuttle() == false) return;
787 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
788 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
789 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
790 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
791 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
792 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
795 void MainWindow::slotShuttleButton(int code)
799 slotShuttleAction(KdenliveSettings::shuttle1());
802 slotShuttleAction(KdenliveSettings::shuttle2());
805 slotShuttleAction(KdenliveSettings::shuttle3());
808 slotShuttleAction(KdenliveSettings::shuttle4());
811 slotShuttleAction(KdenliveSettings::shuttle5());
816 void MainWindow::slotShuttleAction(int code)
822 m_monitorManager->slotPlay();
825 m_monitorManager->slotPlay();
829 #endif /* NO_JOGSHUTTLE */
831 void MainWindow::configureNotifications()
833 KNotifyConfigWidget::configure(this);
836 void MainWindow::slotFullScreen()
838 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
841 void MainWindow::slotAddEffect(const QDomElement effect)
843 if (!m_activeDocument) return;
844 if (effect.isNull()) {
845 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
848 QDomElement effectToAdd = effect.cloneNode().toElement();
850 int ix = m_effectStack->isTrackMode(&ok);
851 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
852 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
855 void MainWindow::slotRaiseMonitor(bool clipMonitor)
857 if (clipMonitor) m_clipMonitorDock->raise();
858 else m_projectMonitorDock->raise();
861 void MainWindow::slotUpdateClip(const QString &id)
863 if (!m_activeDocument) return;
864 m_activeTimeline->projectView()->slotUpdateClip(id);
867 void MainWindow::slotConnectMonitors()
869 m_projectList->setRenderer(m_projectMonitor->render);
870 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
871 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
872 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
873 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
874 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
875 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
876 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
878 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
880 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
882 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
883 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
885 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
887 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
888 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
891 void MainWindow::slotAdjustClipMonitor()
893 m_clipMonitorDock->updateGeometry();
894 m_clipMonitorDock->adjustSize();
895 m_clipMonitor->resetSize();
898 void MainWindow::slotAdjustProjectMonitor()
900 m_projectMonitorDock->updateGeometry();
901 m_projectMonitorDock->adjustSize();
902 m_projectMonitor->resetSize();
905 void MainWindow::setupActions()
908 KActionCollection* collection = actionCollection();
909 m_timecodeFormat = new KComboBox(this);
910 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
911 m_timecodeFormat->addItem(i18n("Frames"));
912 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
913 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
915 m_statusProgressBar = new QProgressBar(this);
916 m_statusProgressBar->setMinimum(0);
917 m_statusProgressBar->setMaximum(100);
918 m_statusProgressBar->setMaximumWidth(150);
919 m_statusProgressBar->setVisible(false);
921 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
922 toolbar->setMovable(false);
923 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
924 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
925 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
926 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
927 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
928 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());
929 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
931 //create edit mode buttons
932 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
933 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
934 toolbar->addAction(m_normalEditTool);
935 m_normalEditTool->setCheckable(true);
936 m_normalEditTool->setChecked(true);
938 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
939 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
940 toolbar->addAction(m_overwriteEditTool);
941 m_overwriteEditTool->setCheckable(true);
942 m_overwriteEditTool->setChecked(false);
944 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
945 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
946 toolbar->addAction(m_insertEditTool);
947 m_insertEditTool->setCheckable(true);
948 m_insertEditTool->setChecked(false);
949 // not implemented yet
950 m_insertEditTool->setEnabled(false);
952 QActionGroup *editGroup = new QActionGroup(this);
953 editGroup->addAction(m_normalEditTool);
954 editGroup->addAction(m_overwriteEditTool);
955 editGroup->addAction(m_insertEditTool);
956 editGroup->setExclusive(true);
957 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
958 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
960 toolbar->addSeparator();
962 // create tools buttons
963 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
964 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
965 toolbar->addAction(m_buttonSelectTool);
966 m_buttonSelectTool->setCheckable(true);
967 m_buttonSelectTool->setChecked(true);
969 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
970 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
971 toolbar->addAction(m_buttonRazorTool);
972 m_buttonRazorTool->setCheckable(true);
973 m_buttonRazorTool->setChecked(false);
975 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
976 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
977 toolbar->addAction(m_buttonSpacerTool);
978 m_buttonSpacerTool->setCheckable(true);
979 m_buttonSpacerTool->setChecked(false);
981 QActionGroup *toolGroup = new QActionGroup(this);
982 toolGroup->addAction(m_buttonSelectTool);
983 toolGroup->addAction(m_buttonRazorTool);
984 toolGroup->addAction(m_buttonSpacerTool);
985 toolGroup->setExclusive(true);
986 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
988 QWidget * actionWidget;
989 int max = toolbar->iconSizeDefault() + 2;
990 actionWidget = toolbar->widgetForAction(m_normalEditTool);
991 actionWidget->setMaximumWidth(max);
992 actionWidget->setMaximumHeight(max - 4);
994 actionWidget = toolbar->widgetForAction(m_insertEditTool);
995 actionWidget->setMaximumWidth(max);
996 actionWidget->setMaximumHeight(max - 4);
998 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
999 actionWidget->setMaximumWidth(max);
1000 actionWidget->setMaximumHeight(max - 4);
1002 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1003 actionWidget->setMaximumWidth(max);
1004 actionWidget->setMaximumHeight(max - 4);
1006 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1007 actionWidget->setMaximumWidth(max);
1008 actionWidget->setMaximumHeight(max - 4);
1010 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1011 actionWidget->setMaximumWidth(max);
1012 actionWidget->setMaximumHeight(max - 4);
1014 toolbar->setStyleSheet(style1);
1015 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1017 toolbar->addSeparator();
1018 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1019 toolbar->addAction(m_buttonFitZoom);
1020 m_buttonFitZoom->setCheckable(false);
1022 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1023 toolbar->addAction(m_zoomOut);
1024 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1026 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1027 m_zoomSlider->setMaximum(13);
1028 m_zoomSlider->setPageStep(1);
1029 m_zoomSlider->setInvertedAppearance(true);
1031 m_zoomSlider->setMaximumWidth(150);
1032 m_zoomSlider->setMinimumWidth(100);
1033 toolbar->addWidget(m_zoomSlider);
1035 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1036 toolbar->addAction(m_zoomIn);
1037 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1039 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1040 actionWidget->setMaximumWidth(max);
1041 actionWidget->setMaximumHeight(max - 4);
1042 actionWidget->setStyleSheet(styleBorderless);
1044 actionWidget = toolbar->widgetForAction(m_zoomIn);
1045 actionWidget->setMaximumWidth(max);
1046 actionWidget->setMaximumHeight(max - 4);
1047 actionWidget->setStyleSheet(styleBorderless);
1049 actionWidget = toolbar->widgetForAction(m_zoomOut);
1050 actionWidget->setMaximumWidth(max);
1051 actionWidget->setMaximumHeight(max - 4);
1052 actionWidget->setStyleSheet(styleBorderless);
1054 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1055 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1056 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1057 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1058 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1060 toolbar->addSeparator();
1062 //create automatic audio split button
1063 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1064 toolbar->addAction(m_buttonAutomaticSplitAudio);
1065 m_buttonAutomaticSplitAudio->setCheckable(true);
1066 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1067 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1069 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1070 toolbar->addAction(m_buttonVideoThumbs);
1071 m_buttonVideoThumbs->setCheckable(true);
1072 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1073 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1075 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1076 toolbar->addAction(m_buttonAudioThumbs);
1077 m_buttonAudioThumbs->setCheckable(true);
1078 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1079 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1081 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1082 toolbar->addAction(m_buttonShowMarkers);
1083 m_buttonShowMarkers->setCheckable(true);
1084 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1085 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1087 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1088 toolbar->addAction(m_buttonSnap);
1089 m_buttonSnap->setCheckable(true);
1090 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1091 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1093 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1094 actionWidget->setMaximumWidth(max);
1095 actionWidget->setMaximumHeight(max - 4);
1097 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1098 actionWidget->setMaximumWidth(max);
1099 actionWidget->setMaximumHeight(max - 4);
1101 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1102 actionWidget->setMaximumWidth(max);
1103 actionWidget->setMaximumHeight(max - 4);
1105 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1106 actionWidget->setMaximumWidth(max);
1107 actionWidget->setMaximumHeight(max - 4);
1109 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1110 actionWidget->setMaximumWidth(max);
1111 actionWidget->setMaximumHeight(max - 4);
1113 m_messageLabel = new StatusBarMessageLabel(this);
1114 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1116 statusBar()->addWidget(m_messageLabel, 10);
1117 statusBar()->addWidget(m_statusProgressBar, 0);
1118 statusBar()->addPermanentWidget(toolbar);
1119 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1120 statusBar()->addPermanentWidget(m_timecodeFormat);
1121 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1123 collection->addAction("normal_mode", m_normalEditTool);
1124 collection->addAction("overwrite_mode", m_overwriteEditTool);
1125 collection->addAction("insert_mode", m_insertEditTool);
1126 collection->addAction("select_tool", m_buttonSelectTool);
1127 collection->addAction("razor_tool", m_buttonRazorTool);
1128 collection->addAction("spacer_tool", m_buttonSpacerTool);
1130 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1131 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1132 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1133 collection->addAction("show_markers", m_buttonShowMarkers);
1134 collection->addAction("snap", m_buttonSnap);
1135 collection->addAction("zoom_fit", m_buttonFitZoom);
1136 collection->addAction("zoom_in", m_zoomIn);
1137 collection->addAction("zoom_out", m_zoomOut);
1139 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1140 collection->addAction("project_find", m_projectSearch);
1141 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1142 m_projectSearch->setShortcut(Qt::Key_Slash);
1144 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1145 collection->addAction("project_find_next", m_projectSearchNext);
1146 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1147 m_projectSearchNext->setShortcut(Qt::Key_F3);
1148 m_projectSearchNext->setEnabled(false);
1150 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1151 collection->addAction("manage_profiles", profilesAction);
1152 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1154 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1155 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1156 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1157 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1159 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1160 collection->addAction("run_wizard", wizAction);
1161 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1163 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1164 collection->addAction("project_settings", projectAction);
1165 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1167 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1168 collection->addAction("project_render", projectRender);
1169 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1170 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1172 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1173 collection->addAction("project_clean", projectClean);
1174 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1176 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1177 collection->addAction("project_adjust_profile", projectAdjust);
1178 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1180 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1181 KShortcut playShortcut;
1182 playShortcut.setPrimary(Qt::Key_Space);
1183 playShortcut.setAlternate(Qt::Key_K);
1184 monitorPlay->setShortcut(playShortcut);
1185 collection->addAction("monitor_play", monitorPlay);
1186 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1188 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1189 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1190 collection->addAction("monitor_play_zone", m_playZone);
1191 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1193 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1194 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1195 collection->addAction("monitor_loop_zone", m_loopZone);
1196 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1198 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1199 m_loopClip->setEnabled(false);
1200 collection->addAction("monitor_loop_clip", m_loopClip);
1201 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1203 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1204 collection->addAction("dvd_wizard", dvdWizard);
1205 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1207 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1208 collection->addAction("transcode_clip", transcodeClip);
1209 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1211 KAction *markIn = collection->addAction("mark_in");
1212 markIn->setText(i18n("Set Zone In"));
1213 markIn->setShortcut(Qt::Key_I);
1214 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1216 KAction *markOut = collection->addAction("mark_out");
1217 markOut->setText(i18n("Set Zone Out"));
1218 markOut->setShortcut(Qt::Key_O);
1219 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1221 KAction *switchMon = collection->addAction("switch_monitor");
1222 switchMon->setText(i18n("Switch monitor"));
1223 switchMon->setShortcut(Qt::Key_T);
1224 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1226 KAction *fullMon = collection->addAction("monitor_fullscreen");
1227 fullMon->setText(i18n("Switch monitor fullscreen"));
1228 fullMon->setIcon(KIcon("view-fullscreen"));
1229 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1231 KAction *insertTree = collection->addAction("insert_project_tree");
1232 insertTree->setText(i18n("Insert zone in project tree"));
1233 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1234 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1236 KAction *insertTimeline = collection->addAction("insert_timeline");
1237 insertTimeline->setText(i18n("Insert zone in timeline"));
1238 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1239 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1241 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1242 collection->addAction("resize_timeline_clip_start", resizeStart);
1243 resizeStart->setShortcut(Qt::Key_1);
1244 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1246 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1247 collection->addAction("resize_timeline_clip_end", resizeEnd);
1248 resizeEnd->setShortcut(Qt::Key_2);
1249 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1251 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1252 monitorSeekBackward->setShortcut(Qt::Key_J);
1253 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1254 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1256 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1257 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1258 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1259 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1261 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1262 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1263 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1264 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1266 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1267 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1268 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1269 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1271 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1272 monitorSeekForward->setShortcut(Qt::Key_L);
1273 collection->addAction("monitor_seek_forward", monitorSeekForward);
1274 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1276 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1277 clipStart->setShortcut(Qt::Key_Home);
1278 collection->addAction("seek_clip_start", clipStart);
1279 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1281 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1282 clipEnd->setShortcut(Qt::Key_End);
1283 collection->addAction("seek_clip_end", clipEnd);
1284 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1286 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1287 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1288 collection->addAction("seek_zone_start", zoneStart);
1289 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1291 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1292 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1293 collection->addAction("seek_zone_end", zoneEnd);
1294 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1296 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1297 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1298 collection->addAction("seek_start", projectStart);
1299 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1301 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1302 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1303 collection->addAction("seek_end", projectEnd);
1304 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1306 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1307 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1308 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1309 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1311 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1312 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1313 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1314 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1316 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1317 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1318 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1319 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1321 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1322 deleteItem->setShortcut(Qt::Key_Delete);
1323 collection->addAction("delete_timeline_clip", deleteItem);
1324 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1326 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1327 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1328 editTimelineClipSpeed->setData("change_speed");
1329 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1331 KAction *stickTransition = collection->addAction("auto_transition");
1332 stickTransition->setData(QString("auto"));
1333 stickTransition->setCheckable(true);
1334 stickTransition->setEnabled(false);
1335 stickTransition->setText(i18n("Automatic Transition"));
1336 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1338 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1339 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1340 collection->addAction("group_clip", groupClip);
1341 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1343 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1344 collection->addAction("ungroup_clip", ungroupClip);
1345 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1346 ungroupClip->setData("ungroup_clip");
1347 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1349 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1350 collection->addAction("edit_item_duration", editItemDuration);
1351 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1353 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1354 collection->addAction("clip_in_project_tree", clipInProjectTree);
1355 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1357 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1358 collection->addAction("clip_to_project_tree", clipToProjectTree);
1359 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1361 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1362 insertOvertwrite->setShortcut(Qt::Key_V);
1363 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1364 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1366 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1367 selectTimelineClip->setShortcut(Qt::Key_Plus);
1368 collection->addAction("select_timeline_clip", selectTimelineClip);
1369 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1371 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1372 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1373 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1374 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1376 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1377 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1378 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1379 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1381 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1382 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1383 collection->addAction("select_timeline_transition", selectTimelineTransition);
1384 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1386 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1387 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1388 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1389 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1391 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1392 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1393 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1394 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1396 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1397 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1398 collection->addAction("cut_timeline_clip", cutTimelineClip);
1399 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1401 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1402 collection->addAction("add_clip_marker", addClipMarker);
1403 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1405 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1406 collection->addAction("delete_clip_marker", deleteClipMarker);
1407 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1409 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1410 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1411 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1413 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1414 collection->addAction("edit_clip_marker", editClipMarker);
1415 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1417 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1418 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1419 collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1420 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1422 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1423 collection->addAction("split_audio", splitAudio);
1424 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1426 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1427 collection->addAction("clip_audio_only", audioOnly);
1428 audioOnly->setData("clip_audio_only");
1429 audioOnly->setCheckable(true);
1431 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1432 collection->addAction("clip_video_only", videoOnly);
1433 videoOnly->setData("clip_video_only");
1434 videoOnly->setCheckable(true);
1436 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1437 collection->addAction("clip_audio_and_video", audioAndVideo);
1438 audioAndVideo->setData("clip_audio_and_video");
1439 audioAndVideo->setCheckable(true);
1441 m_clipTypeGroup = new QActionGroup(this);
1442 m_clipTypeGroup->addAction(audioOnly);
1443 m_clipTypeGroup->addAction(videoOnly);
1444 m_clipTypeGroup->addAction(audioAndVideo);
1445 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1446 m_clipTypeGroup->setEnabled(false);
1448 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1449 collection->addAction("insert_space", insertSpace);
1450 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1452 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1453 collection->addAction("delete_space", removeSpace);
1454 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1456 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1457 collection->addAction("insert_track", insertTrack);
1458 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1460 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1461 collection->addAction("delete_track", deleteTrack);
1462 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1464 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1465 collection->addAction("config_tracks", configTracks);
1466 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1468 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1469 collection->addAction("add_guide", addGuide);
1470 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1472 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1473 collection->addAction("delete_guide", delGuide);
1474 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1476 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1477 collection->addAction("edit_guide", editGuide);
1478 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1480 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1481 collection->addAction("delete_all_guides", delAllGuides);
1482 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1484 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1485 collection->addAction("paste_effects", pasteEffects);
1486 pasteEffects->setData("paste_effects");
1487 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1489 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1490 collection->addAction("show_timeline", showTimeline);
1491 showTimeline->setCheckable(true);
1492 showTimeline->setChecked(true);
1493 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1495 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1496 collection->addAction("show_titlebars", showTitleBar);
1497 showTitleBar->setCheckable(true);
1498 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1499 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1500 slotShowTitleBars(KdenliveSettings::showtitlebars());
1503 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1505 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1506 collection->addAction("maximize_current", maxCurrent);
1507 maxCurrent->setCheckable(true);
1508 maxCurrent->setChecked(false);
1509 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1511 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1512 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1513 KStandardAction::open(this, SLOT(openFile()), collection);
1514 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1515 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1516 KStandardAction::openNew(this, SLOT(newFile()), collection);
1517 // TODO: make the following connection to slotEditKeys work
1518 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1519 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1520 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1521 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1522 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1523 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1525 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1526 undo->setEnabled(false);
1527 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1529 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1530 redo->setEnabled(false);
1531 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1534 //TODO: Add status tooltip to actions ?
1535 connect(collection, SIGNAL(actionHovered(QAction*)),
1536 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1539 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1540 collection->addAction("add_clip", addClip);
1541 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1543 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1544 collection->addAction("add_color_clip", addColorClip);
1545 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1547 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1548 collection->addAction("add_slide_clip", addSlideClip);
1549 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1551 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1552 collection->addAction("add_text_clip", addTitleClip);
1553 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1555 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1556 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1557 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1559 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1560 collection->addAction("add_folder", addFolderButton);
1561 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1563 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1564 collection->addAction("clip_properties", clipProperties);
1565 clipProperties->setData("clip_properties");
1566 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1567 clipProperties->setEnabled(false);
1569 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1570 collection->addAction("edit_clip", openClip);
1571 openClip->setData("edit_clip");
1572 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1573 openClip->setEnabled(false);
1575 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1576 collection->addAction("delete_clip", deleteClip);
1577 deleteClip->setData("delete_clip");
1578 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1579 deleteClip->setEnabled(false);
1581 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1582 collection->addAction("reload_clip", reloadClip);
1583 reloadClip->setData("reload_clip");
1584 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1585 reloadClip->setEnabled(false);
1587 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1588 collection->addAction("stopmotion", stopMotion);
1589 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1591 QMenu *addClips = new QMenu();
1592 addClips->addAction(addClip);
1593 addClips->addAction(addColorClip);
1594 addClips->addAction(addSlideClip);
1595 addClips->addAction(addTitleClip);
1596 addClips->addAction(addTitleTemplateClip);
1597 addClips->addAction(addFolderButton);
1599 addClips->addAction(reloadClip);
1600 addClips->addAction(clipProperties);
1601 addClips->addAction(openClip);
1602 addClips->addAction(deleteClip);
1603 m_projectList->setupMenu(addClips, addClip);
1605 // Setup effects and transitions actions.
1606 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1607 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1608 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1609 m_videoEffects = new KAction*[videoEffects.count()];
1610 for (int i = 0; i < videoEffects.count(); ++i) {
1611 QStringList effectInfo = videoEffects.effectIdInfo(i);
1612 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1613 m_videoEffects[i]->setData(effectInfo);
1614 m_videoEffects[i]->setIconVisibleInMenu(false);
1615 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1617 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1618 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1619 m_audioEffects = new KAction*[audioEffects.count()];
1620 for (int i = 0; i < audioEffects.count(); ++i) {
1621 QStringList effectInfo = audioEffects.effectIdInfo(i);
1622 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1623 m_audioEffects[i]->setData(effectInfo);
1624 m_audioEffects[i]->setIconVisibleInMenu(false);
1625 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1627 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1628 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1629 m_customEffects = new KAction*[customEffects.count()];
1630 for (int i = 0; i < customEffects.count(); ++i) {
1631 QStringList effectInfo = customEffects.effectIdInfo(i);
1632 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1633 m_customEffects[i]->setData(effectInfo);
1634 m_customEffects[i]->setIconVisibleInMenu(false);
1635 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1637 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1638 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1639 m_transitions = new KAction*[transitions.count()];
1640 for (int i = 0; i < transitions.count(); i++) {
1641 QStringList effectInfo = transitions.effectIdInfo(i);
1642 m_transitions[i] = new KAction(effectInfo.at(0), this);
1643 m_transitions[i]->setData(effectInfo);
1644 m_transitions[i]->setIconVisibleInMenu(false);
1645 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1647 m_effectsActionCollection->readSettings();
1649 //connect(collection, SIGNAL( clearStatusText() ),
1650 //statusBar(), SLOT( clear() ) );
1653 void MainWindow::slotDisplayActionMessage(QAction *a)
1655 statusBar()->showMessage(a->data().toString(), 3000);
1658 void MainWindow::loadLayouts()
1660 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1661 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1662 if (loadLayout == NULL || saveLayout == NULL) return;
1663 KSharedConfigPtr config = KGlobal::config();
1664 KConfigGroup layoutGroup(config, "Layouts");
1665 QStringList entries = layoutGroup.keyList();
1666 QList<QAction *> loadActions = loadLayout->actions();
1667 QList<QAction *> saveActions = saveLayout->actions();
1668 for (int i = 1; i < 5; i++) {
1669 // Rename the layouts actions
1670 foreach(const QString & key, entries) {
1671 if (key.endsWith(QString("_%1").arg(i))) {
1672 // Found previously saved layout
1673 QString layoutName = key.section("_", 0, -2);
1674 for (int j = 0; j < loadActions.count(); j++) {
1675 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1676 loadActions[j]->setText(layoutName);
1677 loadActions[j]->setData(key);
1681 for (int j = 0; j < saveActions.count(); j++) {
1682 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1683 saveActions[j]->setText(layoutName);
1684 saveActions[j]->setData(key);
1693 void MainWindow::slotLoadLayout(QAction *action)
1695 if (!action) return;
1696 QString layoutId = action->data().toString();
1697 if (layoutId.isEmpty()) return;
1698 KSharedConfigPtr config = KGlobal::config();
1699 KConfigGroup layouts(config, "Layouts");
1700 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1701 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1702 //restoreGeometry(geom);
1703 restoreState(state);
1706 void MainWindow::slotSaveLayout(QAction *action)
1708 QString originallayoutName = action->data().toString();
1709 int layoutId = originallayoutName.section('_', -1).toInt();
1711 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1712 if (layoutName.isEmpty()) return;
1713 KSharedConfigPtr config = KGlobal::config();
1714 KConfigGroup layouts(config, "Layouts");
1715 layouts.deleteEntry(originallayoutName);
1717 QByteArray st = saveState();
1718 layoutName.append("_" + QString::number(layoutId));
1719 layouts.writeEntry(layoutName, st.toBase64());
1723 void MainWindow::saveOptions()
1725 KdenliveSettings::self()->writeConfig();
1726 KSharedConfigPtr config = KGlobal::config();
1727 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1728 KConfigGroup treecolumns(config, "Project Tree");
1729 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1733 void MainWindow::readOptions()
1735 KSharedConfigPtr config = KGlobal::config();
1736 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1737 KConfigGroup initialGroup(config, "version");
1738 bool upgrade = false;
1739 if (initialGroup.exists()) {
1740 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1744 if (initialGroup.readEntry("version") == "0.7") {
1745 //Add new settings from 0.7.1
1746 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1747 QString path = QDir::homePath() + "/kdenlive";
1748 if (KStandardDirs::makeDir(path) == false) {
1749 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1750 } else KdenliveSettings::setDefaultprojectfolder(path);
1756 if (!initialGroup.exists() || upgrade) {
1757 // this is our first run, show Wizard
1758 Wizard *w = new Wizard(upgrade, this);
1759 if (w->exec() == QDialog::Accepted && w->isOk()) {
1760 w->adjustSettings();
1761 initialGroup.writeEntry("version", version);
1767 KConfigGroup treecolumns(config, "Project Tree");
1768 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1769 if (!state.isEmpty())
1770 m_projectList->setHeaderInfo(state);
1773 void MainWindow::slotRunWizard()
1775 Wizard *w = new Wizard(false, this);
1776 if (w->exec() == QDialog::Accepted && w->isOk()) {
1777 w->adjustSettings();
1782 void MainWindow::newFile(bool showProjectSettings, bool force)
1784 if (!m_timelineArea->isEnabled() && !force)
1786 m_fileRevert->setEnabled(false);
1787 QString profileName = KdenliveSettings::default_profile();
1788 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1789 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1790 if (!showProjectSettings) {
1791 if (!KdenliveSettings::activatetabs())
1792 if (!closeCurrentDocument())
1795 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1796 if (w->exec() != QDialog::Accepted)
1798 if (!KdenliveSettings::activatetabs())
1799 if (!closeCurrentDocument())
1801 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1802 slotSwitchVideoThumbs();
1803 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1804 slotSwitchAudioThumbs();
1805 profileName = w->selectedProfile();
1806 projectFolder = w->selectedFolder();
1807 projectTracks = w->tracks();
1810 m_timelineArea->setEnabled(true);
1811 m_projectList->setEnabled(true);
1812 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1813 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1815 TrackView *trackView = new TrackView(doc, &ok, this);
1816 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1819 //m_timelineArea->setEnabled(false);
1820 //m_projectList->setEnabled(false);
1824 if (m_timelineArea->count() == 1) {
1825 connectDocumentInfo(doc);
1826 connectDocument(trackView, doc);
1828 m_timelineArea->setTabBarHidden(false);
1829 m_monitorManager->activateMonitor("clip");
1830 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1833 void MainWindow::activateDocument()
1835 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1836 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1837 KdenliveDoc *currentDoc = currentTab->document();
1838 connectDocumentInfo(currentDoc);
1839 connectDocument(currentTab, currentDoc);
1842 bool MainWindow::closeCurrentDocument(bool saveChanges)
1844 QWidget *w = m_timelineArea->currentWidget();
1845 if (!w) return true;
1846 // closing current document
1847 int ix = m_timelineArea->currentIndex() + 1;
1848 if (ix == m_timelineArea->count()) ix = 0;
1849 m_timelineArea->setCurrentIndex(ix);
1850 TrackView *tabToClose = (TrackView *) w;
1851 KdenliveDoc *docToClose = tabToClose->document();
1852 if (docToClose && docToClose->isModified() && saveChanges) {
1854 if (m_activeDocument->url().fileName().isEmpty())
1855 message = i18n("Save changes to document?");
1857 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1858 switch (KMessageBox::warningYesNoCancel(this, message)) {
1859 case KMessageBox::Yes :
1860 // save document here. If saving fails, return false;
1861 if (saveFile() == false) return false;
1863 case KMessageBox::Cancel :
1870 m_clipMonitor->slotSetXml(NULL);
1871 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1872 if (m_timelineArea->count() == 1) {
1873 m_timelineArea->setTabBarHidden(true);
1874 m_closeAction->setEnabled(false);
1876 if (docToClose == m_activeDocument) {
1877 delete m_activeDocument;
1878 m_activeDocument = NULL;
1879 m_effectStack->clear();
1880 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1884 if (w == m_activeTimeline) {
1885 delete m_activeTimeline;
1886 m_activeTimeline = NULL;
1893 bool MainWindow::saveFileAs(const QString &outputFileName)
1895 QString currentSceneList;
1896 m_monitorManager->stopActiveMonitor();
1898 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
1901 // Save timeline thumbnails
1902 m_activeTimeline->projectView()->saveThumbnails();
1903 m_activeDocument->setUrl(KUrl(outputFileName));
1904 if (m_activeDocument->m_autosave == NULL) {
1905 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1906 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1907 setCaption(m_activeDocument->description());
1908 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1909 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1910 m_activeDocument->setModified(false);
1911 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1912 m_fileRevert->setEnabled(true);
1916 bool MainWindow::saveFileAs()
1918 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1919 if (outputFile.isEmpty()) {
1922 if (QFile::exists(outputFile)) {
1923 // Show the file dialog again if the user does not want to overwrite the file
1924 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1925 return saveFileAs();
1927 return saveFileAs(outputFile);
1930 bool MainWindow::saveFile()
1932 if (!m_activeDocument) return true;
1933 if (m_activeDocument->url().isEmpty()) {
1934 return saveFileAs();
1936 bool result = saveFileAs(m_activeDocument->url().path());
1937 m_activeDocument->m_autosave->resize(0);
1942 void MainWindow::openFile()
1944 if (!m_startUrl.isEmpty()) {
1945 openFile(m_startUrl);
1946 m_startUrl = KUrl();
1949 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1950 if (url.isEmpty()) return;
1951 m_fileOpenRecent->addUrl(url);
1955 void MainWindow::openLastFile()
1957 KSharedConfigPtr config = KGlobal::config();
1958 KUrl::List urls = m_fileOpenRecent->urls();
1959 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1960 if (urls.isEmpty()) newFile(false);
1961 else openFile(urls.last());
1964 void MainWindow::openFile(const KUrl &url)
1966 // Check if the document is already opened
1967 const int ct = m_timelineArea->count();
1968 bool isOpened = false;
1970 for (i = 0; i < ct; i++) {
1971 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1972 KdenliveDoc *doc = tab->document();
1973 if (doc->url() == url) {
1979 m_timelineArea->setCurrentIndex(i);
1983 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1985 // Check for backup file
1986 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1987 if (!staleFiles.isEmpty()) {
1988 if (KMessageBox::questionYesNo(this,
1989 i18n("Auto-saved files exist. Do you want to recover them now?"),
1990 i18n("File Recovery"),
1991 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1992 recoverFiles(staleFiles);
1995 // remove the stale files
1996 foreach(KAutoSaveFile * stale, staleFiles) {
1997 stale->open(QIODevice::ReadWrite);
2002 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2003 m_messageLabel->repaint();
2004 doOpenFile(url, NULL);
2007 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2009 if (!m_timelineArea->isEnabled()) return;
2010 m_fileRevert->setEnabled(true);
2012 // Recreate stopmotion widget on document change
2014 delete m_stopmotion;
2015 m_stopmotion = NULL;
2018 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2019 progressDialog.setAllowCancel(false);
2020 progressDialog.progressBar()->setMaximum(4);
2021 progressDialog.show();
2022 progressDialog.progressBar()->setValue(0);
2023 qApp->processEvents();
2025 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2027 progressDialog.progressBar()->setValue(1);
2028 progressDialog.progressBar()->setMaximum(4);
2029 progressDialog.setLabelText(i18n("Loading project"));
2030 qApp->processEvents();
2032 if (stale == NULL) {
2033 stale = new KAutoSaveFile(url, doc);
2034 doc->m_autosave = stale;
2036 doc->m_autosave = stale;
2037 doc->setUrl(stale->managedFile());
2038 doc->setModified(true);
2039 stale->setParent(doc);
2041 connectDocumentInfo(doc);
2043 progressDialog.progressBar()->setValue(2);
2044 qApp->processEvents();
2047 TrackView *trackView = new TrackView(doc, &ok, this);
2049 progressDialog.progressBar()->setValue(3);
2050 qApp->processEvents();
2052 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2054 m_timelineArea->setEnabled(false);
2055 m_projectList->setEnabled(false);
2056 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2057 slotGotProgressInfo(QString(), -1);
2058 newFile(false, true);
2061 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2062 trackView->setDuration(trackView->duration());
2063 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2065 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2066 slotGotProgressInfo(QString(), -1);
2067 m_projectMonitor->adjustRulerSize(trackView->duration());
2068 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2069 m_clipMonitor->refreshMonitor(true);
2071 progressDialog.progressBar()->setValue(4);
2074 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2076 foreach(KAutoSaveFile * stale, staleFiles) {
2077 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2078 // show an error message; we could not steal the lockfile
2079 // maybe another application got to the file before us?
2083 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2084 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2085 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2086 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2090 void MainWindow::parseProfiles(const QString &mltPath)
2092 //KdenliveSettings::setDefaulttmpfolder();
2093 if (!mltPath.isEmpty()) {
2094 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2095 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2098 if (KdenliveSettings::mltpath().isEmpty())
2099 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2101 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2102 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2103 if (!QFile::exists(meltPath))
2104 meltPath = KStandardDirs::findExe("melt");
2105 KdenliveSettings::setRendererpath(meltPath);
2108 if (KdenliveSettings::rendererpath().isEmpty()) {
2109 // Cannot find the MLT melt renderer, ask for location
2110 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2111 if (getUrl->exec() == QDialog::Rejected) {
2114 KUrl rendererPath = getUrl->selectedUrl();
2116 if (rendererPath.isEmpty()) ::exit(0);
2117 KdenliveSettings::setRendererpath(rendererPath.path());
2120 QStringList profilesFilter;
2121 profilesFilter << "*";
2122 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2123 if (profilesList.isEmpty()) {
2124 // Cannot find MLT path, try finding melt
2125 QString profilePath = KdenliveSettings::rendererpath();
2126 if (!profilePath.isEmpty()) {
2127 profilePath = profilePath.section('/', 0, -3);
2128 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2129 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2131 if (profilesList.isEmpty()) {
2132 // Cannot find the MLT profiles, ask for location
2133 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2134 getUrl->fileDialog()->setMode(KFile::Directory);
2135 if (getUrl->exec() == QDialog::Rejected) {
2138 KUrl mltPath = getUrl->selectedUrl();
2140 if (mltPath.isEmpty()) ::exit(0);
2141 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2142 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2146 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2148 // Parse again MLT profiles to build a list of available video formats
2149 if (profilesList.isEmpty()) parseProfiles();
2153 void MainWindow::slotEditProfiles()
2155 ProfilesDialog *w = new ProfilesDialog;
2156 if (w->exec() == QDialog::Accepted) {
2157 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2158 if (d) d->checkProfile();
2163 void MainWindow::slotDetectAudioDriver()
2165 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2166 leading to no audio output, see bug #934 */
2168 //decide which audio driver is really best, in some cases SDL is wrong
2169 if (KdenliveSettings::audiodrivername().isEmpty()) {
2171 KProcess readProcess;
2172 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2173 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2174 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2175 readProcess.setProgram("pactl", QStringList() << "stat");
2176 readProcess.execute(2000); // Kill it after 2 seconds
2178 QString result = QString(readProcess.readAllStandardOutput());
2179 kDebug() << "// / / / / / READING PACTL: ";
2181 if (!result.isEmpty()) {
2183 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2187 KdenliveSettings::setAutoaudiodrivername(driver);
2191 void MainWindow::slotEditProjectSettings()
2193 QPoint p = m_activeDocument->getTracksCount();
2194 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2196 if (w->exec() == QDialog::Accepted) {
2197 QString profile = w->selectedProfile();
2198 m_activeDocument->setProjectFolder(w->selectedFolder());
2200 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2202 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2203 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2204 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2205 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2210 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2212 double dar = m_activeDocument->dar();
2214 // Recreate the stopmotion widget if profile changes
2216 delete m_stopmotion;
2217 m_stopmotion = NULL;
2220 // Deselect current effect / transition
2221 m_effectStack->slotClipItemSelected(NULL, 0);
2222 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2223 m_clipMonitor->slotSetXml(NULL);
2224 bool updateFps = m_activeDocument->setProfilePath(profile);
2225 KdenliveSettings::setCurrent_profile(profile);
2226 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2227 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2229 m_activeDocument->clipManager()->clearUnusedProducers();
2230 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2231 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2232 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2233 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2234 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2235 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2236 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2237 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2238 if (updateFps) m_activeTimeline->updateProjectFps();
2239 m_activeDocument->setModified(true);
2240 m_commandStack->activeStack()->clear();
2241 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2242 slotUpdateMousePosition(0);
2243 // We need to desactivate & reactivate monitors to get a refresh
2244 //m_monitorManager->switchMonitors();
2248 void MainWindow::slotRenderProject()
2250 if (!m_renderWidget) {
2251 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2252 m_renderWidget = new RenderWidget(projectfolder, this);
2253 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2254 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2255 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2256 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2257 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2258 if (m_activeDocument) {
2259 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2260 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2261 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2262 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2265 slotCheckRenderStatus();
2266 m_renderWidget->show();
2267 m_renderWidget->showNormal();
2269 // What are the following lines supposed to do?
2270 //m_activeTimeline->tracksNumber();
2271 //m_renderWidget->enableAudio(false);
2272 //m_renderWidget->export_audio;
2275 void MainWindow::slotCheckRenderStatus()
2277 // Make sure there are no missing clips
2279 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2282 void MainWindow::setRenderingProgress(const QString &url, int progress)
2285 m_renderWidget->setRenderJob(url, progress);
2288 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2291 m_renderWidget->setRenderStatus(url, status, error);
2294 void MainWindow::slotCleanProject()
2296 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2297 m_projectList->cleanup();
2300 void MainWindow::slotUpdateMousePosition(int pos)
2302 if (m_activeDocument)
2303 switch (m_timecodeFormat->currentIndex()) {
2305 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2308 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2312 void MainWindow::slotUpdateDocumentState(bool modified)
2314 if (!m_activeDocument) return;
2315 setCaption(m_activeDocument->description(), modified);
2316 m_saveAction->setEnabled(modified);
2318 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2319 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2321 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2322 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2326 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2328 if (m_activeDocument) {
2329 if (m_activeDocument == doc) return;
2330 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2332 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2335 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2337 //m_projectMonitor->stop();
2338 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2339 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2340 if (m_activeDocument) {
2341 if (m_activeDocument == doc) return;
2342 if (m_activeTimeline) {
2343 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2344 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2345 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2346 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2347 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2348 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2349 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2350 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2352 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2354 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2355 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2356 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2357 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2358 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2359 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2360 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2361 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2362 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2363 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2364 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2365 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2366 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2367 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2368 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2369 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2370 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2371 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2372 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2373 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2374 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2375 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2376 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2377 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2378 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2379 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2380 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2381 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2382 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2383 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2384 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2385 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2386 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2387 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2388 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2389 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2390 m_effectStack->clear();
2392 //m_activeDocument->setRenderer(NULL);
2393 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2394 disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2395 m_clipMonitor->stop();
2397 KdenliveSettings::setCurrent_profile(doc->profilePath());
2398 KdenliveSettings::setProject_fps(doc->fps());
2399 m_monitorManager->resetProfiles(doc->timecode());
2400 m_projectList->setDocument(doc);
2401 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2402 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2403 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2404 connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2405 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2407 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2408 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2409 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2411 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2414 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2415 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2416 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2417 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2418 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2419 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2420 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2421 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2422 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2423 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2424 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2425 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2426 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2427 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2429 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2430 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2431 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2432 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2433 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2435 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2436 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2437 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2438 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2440 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2441 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2442 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2443 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2445 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2446 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2447 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2448 m_zoomSlider->setValue(doc->zoom().x());
2449 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2450 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2451 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2452 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2454 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2455 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2457 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2458 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2460 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2461 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2462 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2463 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2464 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2465 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2466 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2467 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2468 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2469 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2470 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2472 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2473 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2474 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2475 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2476 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2479 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2480 m_activeTimeline = trackView;
2481 if (m_renderWidget) {
2482 slotCheckRenderStatus();
2483 m_renderWidget->setProfile(doc->mltProfile());
2484 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2485 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2486 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2488 //doc->setRenderer(m_projectMonitor->render);
2489 m_commandStack->setActiveStack(doc->commandStack());
2490 KdenliveSettings::setProject_display_ratio(doc->dar());
2491 //doc->clipManager()->checkAudioThumbs();
2493 //m_overView->setScene(trackView->projectScene());
2494 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2495 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2497 setCaption(doc->description(), doc->isModified());
2498 m_saveAction->setEnabled(doc->isModified());
2499 m_normalEditTool->setChecked(true);
2500 m_activeDocument = doc;
2501 m_activeTimeline->updateProjectFps();
2502 m_activeDocument->checkProjectClips();
2504 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2506 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2507 slotUpdateMousePosition(0);
2508 // set tool to select tool
2509 m_buttonSelectTool->setChecked(true);
2512 void MainWindow::slotZoneMoved(int start, int end)
2514 m_activeDocument->setZone(start, end);
2515 m_projectMonitor->slotZoneMoved(start, end);
2518 void MainWindow::slotGuidesUpdated()
2521 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2524 void MainWindow::slotEditKeys()
2526 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2527 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2528 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2532 void MainWindow::slotPreferences(int page, int option)
2535 * An instance of your dialog could be already created and could be
2536 * cached, in which case you want to display the cached dialog
2537 * instead of creating another one
2539 if (m_stopmotion) m_stopmotion->slotLive(false);
2540 if (KConfigDialog::showDialog("settings")) {
2541 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2542 if (page != -1) d->showPage(page, option);
2546 // KConfigDialog didn't find an instance of this dialog, so lets
2548 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2549 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2550 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2551 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2553 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2556 if (page != -1) dialog->showPage(page, option);
2559 void MainWindow::slotUpdateCaptureFolder()
2563 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2564 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2568 void MainWindow::updateConfiguration()
2570 //TODO: we should apply settings to all projects, not only the current one
2571 if (m_activeTimeline) {
2572 m_activeTimeline->refresh();
2573 m_activeTimeline->projectView()->checkAutoScroll();
2574 m_activeTimeline->projectView()->checkTrackHeight();
2575 if (m_activeDocument)
2576 m_activeDocument->clipManager()->checkAudioThumbs();
2578 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2579 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2580 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2581 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2583 // Update list of transcoding profiles
2585 #ifndef NO_JOGSHUTTLE
2586 activateShuttleDevice();
2587 #endif /* NO_JOGSHUTTLE */
2591 void MainWindow::slotSwitchSplitAudio()
2593 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2594 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2597 void MainWindow::slotSwitchVideoThumbs()
2599 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2600 if (m_activeTimeline)
2601 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2602 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2605 void MainWindow::slotSwitchAudioThumbs()
2607 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2608 if (m_activeTimeline) {
2609 m_activeTimeline->refresh();
2610 m_activeTimeline->projectView()->checkAutoScroll();
2611 if (m_activeDocument)
2612 m_activeDocument->clipManager()->checkAudioThumbs();
2614 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2617 void MainWindow::slotSwitchMarkersComments()
2619 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2620 if (m_activeTimeline)
2621 m_activeTimeline->refresh();
2622 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2625 void MainWindow::slotSwitchSnap()
2627 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2628 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2632 void MainWindow::slotDeleteItem()
2634 if (QApplication::focusWidget() &&
2635 QApplication::focusWidget()->parentWidget() &&
2636 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2637 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2638 m_projectList->slotRemoveClip();
2641 QWidget *widget = QApplication::focusWidget();
2643 if (widget == m_effectStackDock) {
2644 m_effectStack->slotItemDel();
2647 widget = widget->parentWidget();
2650 // effect stack has no focus
2651 if (m_activeTimeline)
2652 m_activeTimeline->projectView()->deleteSelectedClips();
2656 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2658 if (m_clipMonitor->isActive())
2659 m_clipMonitor->checkOverlay();
2660 m_clipMonitor->updateMarkers(clip);
2663 void MainWindow::slotAddClipMarker()
2665 DocClipBase *clip = NULL;
2667 if (m_projectMonitor->isActive()) {
2668 if (m_activeTimeline) {
2669 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2671 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2672 clip = item->baseClip();
2676 clip = m_clipMonitor->activeClip();
2677 pos = m_clipMonitor->position();
2680 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2683 QString id = clip->getId();
2684 CommentedTime marker(pos, i18n("Marker"));
2685 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2686 if (d.exec() == QDialog::Accepted)
2687 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2690 void MainWindow::slotDeleteClipMarker()
2692 DocClipBase *clip = NULL;
2694 if (m_projectMonitor->isActive()) {
2695 if (m_activeTimeline) {
2696 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2698 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2699 clip = item->baseClip();
2703 clip = m_clipMonitor->activeClip();
2704 pos = m_clipMonitor->position();
2707 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2711 QString id = clip->getId();
2712 QString comment = clip->markerComment(pos);
2713 if (comment.isEmpty()) {
2714 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2717 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2720 void MainWindow::slotDeleteAllClipMarkers()
2722 DocClipBase *clip = NULL;
2723 if (m_projectMonitor->isActive()) {
2724 if (m_activeTimeline) {
2725 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2727 clip = item->baseClip();
2731 clip = m_clipMonitor->activeClip();
2734 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2737 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2740 void MainWindow::slotEditClipMarker()
2742 DocClipBase *clip = NULL;
2744 if (m_projectMonitor->isActive()) {
2745 if (m_activeTimeline) {
2746 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2748 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2749 clip = item->baseClip();
2753 clip = m_clipMonitor->activeClip();
2754 pos = m_clipMonitor->position();
2757 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2761 QString id = clip->getId();
2762 QString oldcomment = clip->markerComment(pos);
2763 if (oldcomment.isEmpty()) {
2764 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2768 CommentedTime marker(pos, oldcomment);
2769 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2770 if (d.exec() == QDialog::Accepted) {
2771 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2772 if (d.newMarker().time() != pos) {
2773 // remove old marker
2774 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2779 void MainWindow::slotAddMarkerGuideQuickly()
2781 if (!m_activeTimeline || !m_activeDocument)
2784 if (m_clipMonitor->isActive()) {
2785 DocClipBase *clip = m_clipMonitor->activeClip();
2786 GenTime pos = m_clipMonitor->position();
2789 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2793 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2795 m_activeTimeline->projectView()->slotAddGuide(false);
2799 void MainWindow::slotAddGuide()
2801 if (m_activeTimeline)
2802 m_activeTimeline->projectView()->slotAddGuide();
2805 void MainWindow::slotInsertSpace()
2807 if (m_activeTimeline)
2808 m_activeTimeline->projectView()->slotInsertSpace();
2811 void MainWindow::slotRemoveSpace()
2813 if (m_activeTimeline)
2814 m_activeTimeline->projectView()->slotRemoveSpace();
2817 void MainWindow::slotInsertTrack(int ix)
2819 m_projectMonitor->activateMonitor();
2820 if (m_activeTimeline)
2821 m_activeTimeline->projectView()->slotInsertTrack(ix);
2822 if (m_activeDocument)
2823 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2826 void MainWindow::slotDeleteTrack(int ix)
2828 m_projectMonitor->activateMonitor();
2829 if (m_activeTimeline)
2830 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2831 if (m_activeDocument)
2832 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2835 void MainWindow::slotConfigTrack(int ix)
2837 m_projectMonitor->activateMonitor();
2838 if (m_activeTimeline)
2839 m_activeTimeline->projectView()->slotConfigTracks(ix);
2840 if (m_activeDocument)
2841 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2844 void MainWindow::slotEditGuide()
2846 if (m_activeTimeline)
2847 m_activeTimeline->projectView()->slotEditGuide();
2850 void MainWindow::slotDeleteGuide()
2852 if (m_activeTimeline)
2853 m_activeTimeline->projectView()->slotDeleteGuide();
2856 void MainWindow::slotDeleteAllGuides()
2858 if (m_activeTimeline)
2859 m_activeTimeline->projectView()->slotDeleteAllGuides();
2862 void MainWindow::slotCutTimelineClip()
2864 if (m_activeTimeline)
2865 m_activeTimeline->projectView()->cutSelectedClips();
2868 void MainWindow::slotInsertClipOverwrite()
2870 if (m_activeTimeline) {
2871 QStringList data = m_clipMonitor->getZoneInfo();
2872 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2876 void MainWindow::slotSelectTimelineClip()
2878 if (m_activeTimeline)
2879 m_activeTimeline->projectView()->selectClip(true);
2882 void MainWindow::slotSelectTimelineTransition()
2884 if (m_activeTimeline)
2885 m_activeTimeline->projectView()->selectTransition(true);
2888 void MainWindow::slotDeselectTimelineClip()
2890 if (m_activeTimeline)
2891 m_activeTimeline->projectView()->selectClip(false, true);
2894 void MainWindow::slotDeselectTimelineTransition()
2896 if (m_activeTimeline)
2897 m_activeTimeline->projectView()->selectTransition(false, true);
2900 void MainWindow::slotSelectAddTimelineClip()
2902 if (m_activeTimeline)
2903 m_activeTimeline->projectView()->selectClip(true, true);
2906 void MainWindow::slotSelectAddTimelineTransition()
2908 if (m_activeTimeline)
2909 m_activeTimeline->projectView()->selectTransition(true, true);
2912 void MainWindow::slotGroupClips()
2914 if (m_activeTimeline)
2915 m_activeTimeline->projectView()->groupClips();
2918 void MainWindow::slotUnGroupClips()
2920 if (m_activeTimeline)
2921 m_activeTimeline->projectView()->groupClips(false);
2924 void MainWindow::slotEditItemDuration()
2926 if (m_activeTimeline)
2927 m_activeTimeline->projectView()->editItemDuration();
2930 void MainWindow::slotAddProjectClip(KUrl url)
2932 if (m_activeDocument)
2933 m_activeDocument->slotAddClipFile(url, QString());
2936 void MainWindow::slotAddTransition(QAction *result)
2938 if (!result) return;
2939 QStringList info = result->data().toStringList();
2940 if (info.isEmpty()) return;
2941 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2942 if (m_activeTimeline && !transition.isNull()) {
2943 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2947 void MainWindow::slotAddVideoEffect(QAction *result)
2949 if (!result) return;
2950 QStringList info = result->data().toStringList();
2951 if (info.isEmpty()) return;
2952 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2953 slotAddEffect(effect);
2956 void MainWindow::slotAddAudioEffect(QAction *result)
2958 if (!result) return;
2959 QStringList info = result->data().toStringList();
2960 if (info.isEmpty()) return;
2961 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2962 slotAddEffect(effect);
2965 void MainWindow::slotAddCustomEffect(QAction *result)
2967 if (!result) return;
2968 QStringList info = result->data().toStringList();
2969 if (info.isEmpty()) return;
2970 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2971 slotAddEffect(effect);
2974 void MainWindow::slotZoomIn()
2976 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2977 slotShowZoomSliderToolTip();
2980 void MainWindow::slotZoomOut()
2982 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2983 slotShowZoomSliderToolTip();
2986 void MainWindow::slotFitZoom()
2988 if (m_activeTimeline)
2989 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2992 void MainWindow::slotSetZoom(int value)
2994 value = qMax(m_zoomSlider->minimum(), value);
2995 value = qMin(m_zoomSlider->maximum(), value);
2997 if (m_activeTimeline)
2998 m_activeTimeline->slotChangeZoom(value);
3000 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3001 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3002 slotUpdateZoomSliderToolTip(value);
3004 m_zoomSlider->blockSignals(true);
3005 m_zoomSlider->setValue(value);
3006 m_zoomSlider->blockSignals(false);
3009 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3011 if (zoomlevel != -1)
3012 slotUpdateZoomSliderToolTip(zoomlevel);
3014 QPoint global = m_zoomSlider->rect().topLeft();
3015 global.ry() += m_zoomSlider->height() / 2;
3016 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3017 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3020 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3022 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3025 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3027 m_statusProgressBar->setValue(progress);
3028 if (progress >= 0) {
3029 if (!message.isEmpty())
3030 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3031 m_statusProgressBar->setVisible(true);
3032 } else if (progress == -2) {
3033 if (!message.isEmpty())
3034 m_messageLabel->setMessage(message, ErrorMessage);
3035 m_statusProgressBar->setVisible(false);
3037 m_messageLabel->setMessage(QString(), DefaultMessage);
3038 m_statusProgressBar->setVisible(false);
3042 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3044 if (clip->clipType() == TEXT) {
3045 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3046 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3047 // template text clip
3049 // Get the list of existing templates
3051 filter << "*.kdenlivetitle";
3052 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3054 QDialog *dia = new QDialog(this);
3055 Ui::TemplateClip_UI dia_ui;
3056 dia_ui.setupUi(dia);
3058 const QString templatePath = clip->getProperty("resource");
3059 for (int i = 0; i < templateFiles.size(); ++i) {
3060 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3061 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3063 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3064 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3065 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3066 //warning: setting base directory doesn't work??
3067 KUrl startDir(titlepath);
3068 dia_ui.template_list->fileDialog()->setUrl(startDir);
3069 dia_ui.description->setText(clip->getProperty("description"));
3070 if (dia->exec() == QDialog::Accepted) {
3071 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3072 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3074 QMap <QString, QString> newprops;
3076 if (KUrl(textTemplate).path() != templatePath) {
3077 // The template was changed
3078 newprops.insert("resource", textTemplate);
3081 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3082 newprops.insert("description", dia_ui.description->toPlainText());
3085 QString newtemplate = newprops.value("xmltemplate");
3086 if (newtemplate.isEmpty()) newtemplate = templatePath;
3088 // template modified we need to update xmldata
3089 QString description = newprops.value("description");
3090 if (description.isEmpty()) description = clip->getProperty("description");
3091 else newprops.insert("templatetext", description);
3092 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3093 if (!newprops.isEmpty()) {
3094 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3095 m_activeDocument->commandStack()->push(command);
3101 QString path = clip->getProperty("resource");
3102 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3104 doc.setContent(clip->getProperty("xmldata"));
3105 dia_ui->setXml(doc);
3106 if (dia_ui->exec() == QDialog::Accepted) {
3107 QMap <QString, QString> newprops;
3108 newprops.insert("xmldata", dia_ui->xml().toString());
3109 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3110 // duration changed, we need to update duration
3111 newprops.insert("out", QString::number(dia_ui->outPoint()));
3113 if (!path.isEmpty()) {
3114 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3115 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) {
3116 // save to external file
3117 dia_ui->saveTitle(path);
3118 } else newprops.insert("resource", QString());
3120 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3121 m_activeDocument->commandStack()->push(command);
3122 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3123 m_activeDocument->setModified(true);
3127 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3131 // any type of clip but a title
3132 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3133 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3134 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)));
3139 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3141 if (newprops.isEmpty()) return;
3142 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3143 m_activeDocument->commandStack()->push(command);
3144 m_activeDocument->setModified();
3147 // update clip occurences in timeline
3148 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3153 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3155 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3156 if (dia.exec() == QDialog::Accepted) {
3157 QUndoCommand *command = new QUndoCommand();
3158 command->setText(i18n("Edit clips"));
3159 for (int i = 0; i < cliplist.count(); i++) {
3160 DocClipBase *clip = cliplist.at(i);
3161 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3163 m_activeDocument->commandStack()->push(command);
3164 for (int i = 0; i < cliplist.count(); i++)
3165 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3169 void MainWindow::customEvent(QEvent* e)
3171 if (e->type() == QEvent::User)
3172 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3174 void MainWindow::slotActivateEffectStackView()
3176 m_effectStack->raiseWindow(m_effectStackDock);
3179 void MainWindow::slotActivateTransitionView(Transition *t)
3182 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3185 void MainWindow::slotSnapRewind()
3187 if (m_projectMonitor->isActive()) {
3188 if (m_activeTimeline)
3189 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3191 m_clipMonitor->slotSeekToPreviousSnap();
3195 void MainWindow::slotSnapForward()
3197 if (m_projectMonitor->isActive()) {
3198 if (m_activeTimeline)
3199 m_activeTimeline->projectView()->slotSeekToNextSnap();
3201 m_clipMonitor->slotSeekToNextSnap();
3205 void MainWindow::slotClipStart()
3207 if (m_projectMonitor->isActive()) {
3208 if (m_activeTimeline)
3209 m_activeTimeline->projectView()->clipStart();
3213 void MainWindow::slotClipEnd()
3215 if (m_projectMonitor->isActive()) {
3216 if (m_activeTimeline)
3217 m_activeTimeline->projectView()->clipEnd();
3221 void MainWindow::slotZoneStart()
3223 if (m_projectMonitor->isActive())
3224 m_projectMonitor->slotZoneStart();
3226 m_clipMonitor->slotZoneStart();
3229 void MainWindow::slotZoneEnd()
3231 if (m_projectMonitor->isActive())
3232 m_projectMonitor->slotZoneEnd();
3234 m_clipMonitor->slotZoneEnd();
3237 void MainWindow::slotChangeTool(QAction * action)
3239 if (action == m_buttonSelectTool)
3240 slotSetTool(SELECTTOOL);
3241 else if (action == m_buttonRazorTool)
3242 slotSetTool(RAZORTOOL);
3243 else if (action == m_buttonSpacerTool)
3244 slotSetTool(SPACERTOOL);
3247 void MainWindow::slotChangeEdit(QAction * action)
3249 if (!m_activeTimeline)
3252 if (action == m_overwriteEditTool)
3253 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3254 else if (action == m_insertEditTool)
3255 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3257 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3260 void MainWindow::slotSetTool(PROJECTTOOL tool)
3262 if (m_activeDocument && m_activeTimeline) {
3263 //m_activeDocument->setTool(tool);
3267 message = i18n("Ctrl + click to use spacer on current track only");
3270 message = i18n("Click on a clip to cut it");
3273 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3276 m_messageLabel->setMessage(message, InformationMessage);
3277 m_activeTimeline->projectView()->setTool(tool);
3281 void MainWindow::slotCopy()
3283 if (m_activeDocument && m_activeTimeline)
3284 m_activeTimeline->projectView()->copyClip();
3287 void MainWindow::slotPaste()
3289 if (m_activeDocument && m_activeTimeline)
3290 m_activeTimeline->projectView()->pasteClip();
3293 void MainWindow::slotPasteEffects()
3295 if (m_activeDocument && m_activeTimeline)
3296 m_activeTimeline->projectView()->pasteClipEffects();
3299 void MainWindow::slotFind()
3301 if (!m_activeDocument || !m_activeTimeline) return;
3302 m_projectSearch->setEnabled(false);
3303 m_findActivated = true;
3304 m_findString.clear();
3305 m_activeTimeline->projectView()->initSearchStrings();
3306 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3307 m_findTimer.start(5000);
3308 qApp->installEventFilter(this);
3311 void MainWindow::slotFindNext()
3313 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3314 statusBar()->showMessage(i18n("Found: %1", m_findString));
3316 statusBar()->showMessage(i18n("Reached end of project"));
3317 m_findTimer.start(4000);
3320 void MainWindow::findAhead()
3322 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3323 m_projectSearchNext->setEnabled(true);
3324 statusBar()->showMessage(i18n("Found: %1", m_findString));
3326 m_projectSearchNext->setEnabled(false);
3327 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3331 void MainWindow::findTimeout()
3333 m_projectSearchNext->setEnabled(false);
3334 m_findActivated = false;
3335 m_findString.clear();
3336 statusBar()->showMessage(i18n("Find stopped"), 3000);
3337 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3338 m_projectSearch->setEnabled(true);
3339 removeEventFilter(this);
3342 void MainWindow::slotClipInTimeline(const QString &clipId)
3344 if (m_activeTimeline && m_activeDocument) {
3345 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3347 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3348 inTimelineMenu->clear();
3350 QList <QAction *> actionList;
3352 for (int i = 0; i < matching.count(); ++i) {
3353 QString track = QString::number(matching.at(i).track);
3354 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3356 QAction *a = new QAction(track + ": " + start, this);
3357 a->setData(QStringList() << track << start);
3358 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3359 while (j < actionList.count()) {
3360 if (actionList.at(j)->text() > a->text()) break;
3363 actionList.insert(j, a);
3365 inTimelineMenu->addActions(actionList);
3367 if (matching.empty())
3368 inTimelineMenu->setEnabled(false);
3370 inTimelineMenu->setEnabled(true);
3374 void MainWindow::slotClipInProjectTree()
3376 if (m_activeTimeline) {
3377 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3378 if (clipIds.isEmpty())
3380 m_projectListDock->raise();
3381 for (int i = 0; i < clipIds.count(); i++)
3382 m_projectList->selectItemById(clipIds.at(i));
3383 if (m_projectMonitor->isActive())
3384 slotSwitchMonitors();
3388 /*void MainWindow::slotClipToProjectTree()
3390 if (m_activeTimeline) {
3391 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3392 if (clips.isEmpty()) return;
3393 for (int i = 0; i < clips.count(); i++) {
3394 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3396 //m_projectList->selectItemById(clipIds.at(i));
3400 void MainWindow::slotSelectClipInTimeline()
3402 if (m_activeTimeline) {
3403 QAction *action = qobject_cast<QAction *>(sender());
3404 QStringList data = action->data().toStringList();
3405 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3409 void MainWindow::keyPressEvent(QKeyEvent *ke)
3411 if (m_findActivated) {
3412 if (ke->key() == Qt::Key_Backspace) {
3413 m_findString = m_findString.left(m_findString.length() - 1);
3415 if (!m_findString.isEmpty())
3420 m_findTimer.start(4000);
3423 } else if (ke->key() == Qt::Key_Escape) {
3427 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3428 m_findString += ke->text();
3432 m_findTimer.start(4000);
3437 KXmlGuiWindow::keyPressEvent(ke);
3442 /** Gets called when the window gets hidden */
3443 void MainWindow::hideEvent(QHideEvent */*event*/)
3445 if (isMinimized() && m_monitorManager)
3446 m_monitorManager->stopActiveMonitor();
3449 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3451 if (m_findActivated) {
3452 if (event->type() == QEvent::ShortcutOverride) {
3453 QKeyEvent* ke = (QKeyEvent*) event;
3454 if (ke->text().trimmed().isEmpty()) return false;
3461 // pass the event on to the parent class
3462 return QMainWindow::eventFilter(obj, event);
3467 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3469 KDialog *dialog = new KDialog(this);
3470 dialog->setCaption("Save clip zone");
3471 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3473 QWidget *widget = new QWidget(dialog);
3474 dialog->setMainWidget(widget);
3476 QVBoxLayout *vbox = new QVBoxLayout(widget);
3477 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3478 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3479 path.append("untitled.mlt");
3480 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3481 url->setFilter("video/mlt-playlist");
3482 QLabel *label2 = new QLabel(i18n("Description:"), this);
3483 KLineEdit *edit = new KLineEdit(this);
3484 vbox->addWidget(label1);
3485 vbox->addWidget(url);
3486 vbox->addWidget(label2);
3487 vbox->addWidget(edit);
3488 if (dialog->exec() == QDialog::Accepted)
3489 render->saveZone(url->url(), edit->text(), zone);
3493 void MainWindow::slotSetInPoint()
3495 if (m_clipMonitor->isActive())
3496 m_clipMonitor->slotSetZoneStart();
3498 m_projectMonitor->slotSetZoneStart();
3499 //else m_activeTimeline->projectView()->setInPoint();
3502 void MainWindow::slotSetOutPoint()
3504 if (m_clipMonitor->isActive())
3505 m_clipMonitor->slotSetZoneEnd();
3507 m_projectMonitor->slotSetZoneEnd();
3508 // else m_activeTimeline->projectView()->setOutPoint();
3511 void MainWindow::slotResizeItemStart()
3513 if (m_activeTimeline)
3514 m_activeTimeline->projectView()->setInPoint();
3517 void MainWindow::slotResizeItemEnd()
3519 if (m_activeTimeline)
3520 m_activeTimeline->projectView()->setOutPoint();
3523 int MainWindow::getNewStuff(const QString &configFile)
3525 KNS3::Entry::List entries;
3526 #if KDE_IS_VERSION(4,3,80)
3527 KNS3::DownloadDialog dialog(configFile);
3529 entries = dialog.changedEntries();
3530 foreach(const KNS3::Entry & entry, entries) {
3531 if (entry.status() == KNS3::Entry::Installed)
3532 kDebug() << "// Installed files: " << entry.installedFiles();
3535 KNS::Engine engine(0);
3536 if (engine.init(configFile))
3537 entries = engine.downloadDialogModal(this);
3538 foreach(KNS::Entry * entry, entries) {
3539 if (entry->status() == KNS::Entry::Installed)
3540 kDebug() << "// Installed files: " << entry->installedFiles();
3542 #endif /* KDE_IS_VERSION(4,3,80) */
3543 return entries.size();
3546 void MainWindow::slotGetNewTitleStuff()
3548 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3549 TitleWidget::refreshTitleTemplates();
3552 void MainWindow::slotGetNewLumaStuff()
3554 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3555 initEffects::refreshLumas();
3556 m_activeTimeline->projectView()->reloadTransitionLumas();
3560 void MainWindow::slotGetNewRenderStuff()
3562 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3564 m_renderWidget->reloadProfiles();
3567 void MainWindow::slotGetNewMltProfileStuff()
3569 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3570 // update the list of profiles in settings dialog
3571 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3577 void MainWindow::slotAutoTransition()
3579 if (m_activeTimeline)
3580 m_activeTimeline->projectView()->autoTransition();
3583 void MainWindow::slotSplitAudio()
3585 if (m_activeTimeline)
3586 m_activeTimeline->projectView()->splitAudio();
3589 void MainWindow::slotUpdateClipType(QAction *action)
3591 if (m_activeTimeline) {
3592 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3593 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3594 else m_activeTimeline->projectView()->setAudioAndVideo();
3598 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3600 // We must stop the monitors since we create a new on in the dvd wizard
3601 m_clipMonitor->stop();
3602 m_projectMonitor->stop();
3603 DvdWizard w(url, profile, this);
3605 m_projectMonitor->start();
3608 void MainWindow::slotShowTimeline(bool show)
3610 if (show == false) {
3611 m_timelineState = saveState();
3612 centralWidget()->setHidden(true);
3614 centralWidget()->setHidden(false);
3615 restoreState(m_timelineState);
3619 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3621 //TODO: is there a way to maximize current widget?
3624 m_timelineState = saveState();
3625 QWidget *par = focusWidget()->parentWidget();
3626 while (par->parentWidget() && par->parentWidget() != this)
3627 par = par->parentWidget();
3628 kDebug() << "CURRENT WIDGET: " << par->objectName();
3631 //centralWidget()->setHidden(false);
3632 //restoreState(m_timelineState);
3636 void MainWindow::loadTranscoders()
3638 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3641 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3642 KConfigGroup transConfig(config, "Transcoding");
3644 QMap< QString, QString > profiles = transConfig.entryMap();
3645 QMapIterator<QString, QString> i(profiles);
3646 while (i.hasNext()) {
3648 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3649 QAction *a = transMenu->addAction(i.key());
3651 if (data.count() > 1)
3652 a->setToolTip(data.at(1));
3653 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3657 void MainWindow::slotTranscode(KUrl::List urls)
3662 if (urls.isEmpty()) {
3663 QAction *action = qobject_cast<QAction *>(sender());
3664 QStringList data = action->data().toStringList();
3665 params = data.at(0);
3666 if (data.count() > 1) desc = data.at(1);
3667 if (data.count() > 2) condition = data.at(2);
3668 urls << m_projectList->getConditionalUrls(condition);
3669 urls.removeAll(KUrl());
3671 if (urls.isEmpty()) {
3672 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3675 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3676 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3678 //QProcess::startDetached("ffmpeg", parameters);
3681 void MainWindow::slotTranscodeClip()
3683 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3684 if (urls.isEmpty()) return;
3685 slotTranscode(urls);
3688 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3690 if (m_activeDocument == NULL) return;
3691 QMapIterator<QString, QString> i(props);
3692 while (i.hasNext()) {
3694 m_activeDocument->setDocumentProperty(i.key(), i.value());
3696 m_activeDocument->setModified(true);
3700 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3702 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3704 QString playlistPath;
3707 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3708 QString path = m_renderWidget->getFreeScriptName();
3709 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3710 if (!ok || scriptPath.isEmpty()) return;
3711 scriptPath.prepend(scriptsFolder);
3712 QFile f(scriptPath);
3714 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3717 playlistPath = scriptPath + ".mlt";
3718 m_projectMonitor->saveSceneList(playlistPath);
3720 KTemporaryFile temp;
3721 temp.setAutoRemove(false);
3722 temp.setSuffix(".mlt");
3724 playlistPath = temp.fileName();
3725 m_projectMonitor->saveSceneList(playlistPath);
3728 if (!chapterFile.isEmpty()) {
3731 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3733 in = m_activeTimeline->inPoint();
3734 out = m_activeTimeline->outPoint();
3737 QDomElement chapters = doc.createElement("chapters");
3738 chapters.setAttribute("fps", m_activeDocument->fps());
3739 doc.appendChild(chapters);
3741 QDomElement guidesxml = m_activeDocument->guidesXml();
3742 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3743 for (int i = 0; i < nodes.count(); i++) {
3744 QDomElement e = nodes.item(i).toElement();
3746 QString comment = e.attribute("comment");
3747 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3748 if (time >= in && time < out) {
3749 if (zoneOnly) time = time - in;
3750 QDomElement chapter = doc.createElement("chapter");
3751 chapters.appendChild(chapter);
3752 chapter.setAttribute("title", comment);
3753 chapter.setAttribute("time", time);
3757 if (chapters.childNodes().count() > 0) {
3758 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3759 // Always insert a guide in pos 0
3760 QDomElement chapter = doc.createElement("chapter");
3761 chapters.insertBefore(chapter, QDomNode());
3762 chapter.setAttribute("title", i18n("Start"));
3763 chapter.setAttribute("time", "0");
3765 // save chapters file
3766 QFile file(chapterFile);
3767 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3768 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3770 file.write(doc.toString().toUtf8());
3771 if (file.error() != QFile::NoError) {
3772 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3779 if (m_renderWidget->automaticAudioExport()) {
3780 exportAudio = m_activeTimeline->checkProjectAudio();
3781 } else exportAudio = m_renderWidget->selectedAudioExport();
3782 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3785 void MainWindow::slotUpdateTimecodeFormat(int ix)
3787 KdenliveSettings::setFrametimecode(ix == 1);
3788 m_clipMonitor->updateTimecodeFormat();
3789 m_projectMonitor->updateTimecodeFormat();
3790 m_transitionConfig->updateTimecodeFormat();
3791 m_effectStack->updateTimecodeFormat();
3792 //m_activeTimeline->projectView()->clearSelection();
3793 m_activeTimeline->updateRuler();
3796 void MainWindow::slotRemoveFocus()
3798 statusBar()->setFocus();
3799 statusBar()->clearFocus();
3802 void MainWindow::slotRevert()
3804 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;
3805 KUrl url = m_activeDocument->url();
3806 if (closeCurrentDocument(false))
3807 doOpenFile(url, NULL);
3811 void MainWindow::slotShutdown()
3813 if (m_activeDocument) m_activeDocument->setModified(false);
3815 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3816 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3817 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3818 smserver.call("logout", 1, 2, 2);
3819 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3820 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3821 smserver.call("Shutdown");
3825 void MainWindow::slotUpdateTrackInfo()
3827 if (m_activeDocument)
3828 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3831 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3833 // Load the theme file
3835 if (action == NULL) theme = themename;
3836 else theme = action->data().toString();
3837 KdenliveSettings::setColortheme(theme);
3838 // Make palette for all widgets.
3840 if (theme.isEmpty())
3841 plt = QApplication::desktop()->palette();
3843 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3844 plt = KGlobalSettings::createApplicationPalette(config);
3847 kapp->setPalette(plt);
3848 const QObjectList children = statusBar()->children();
3850 foreach(QObject * child, children) {
3851 if (child->isWidgetType())
3852 ((QWidget*)child)->setPalette(plt);
3853 const QObjectList subchildren = child->children();
3854 foreach(QObject * subchild, subchildren) {
3855 if (subchild->isWidgetType())
3856 ((QWidget*)subchild)->setPalette(plt);
3859 if (m_activeTimeline) {
3860 m_activeTimeline->projectView()->updatePalette();
3865 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3867 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3868 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3869 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3870 const QSize bitsSize(24, 2);
3871 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3872 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3874 QPixmap pixmap(23, 16);
3875 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3877 KConfigGroup group(config, "WM");
3878 QPainter p(&pixmap);
3879 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3880 p.fillRect(1, 1, 7, 7, windowScheme.background());
3881 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3883 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3884 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3885 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3887 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3888 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3890 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3891 p.fillRect(1, 8, 7, 7, viewScheme.background());
3892 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3894 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3895 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3896 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3898 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3899 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3905 void MainWindow::slotSwitchMonitors()
3907 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3908 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3909 else m_projectList->focusTree();
3912 void MainWindow::slotSwitchFullscreen()
3914 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3915 else m_clipMonitor->slotSwitchFullScreen();
3918 void MainWindow::slotInsertZoneToTree()
3920 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3921 QStringList info = m_clipMonitor->getZoneInfo();
3922 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3925 void MainWindow::slotInsertZoneToTimeline()
3927 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3928 QStringList info = m_clipMonitor->getZoneInfo();
3929 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3933 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3935 if (m_activeDocument && m_activeTimeline) {
3936 if (!ids.isEmpty()) {
3937 for (int i = 0; i < ids.size(); ++i) {
3938 m_activeTimeline->slotDeleteClip(ids.at(i));
3940 m_activeDocument->clipManager()->slotDeleteClips(ids);
3942 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3943 m_activeDocument->setModified(true);
3947 void MainWindow::slotShowTitleBars(bool show)
3949 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
3950 for (int i = 0; i < docks.count(); i++) {
3951 QDockWidget* dock = docks.at(i);
3953 dock->setTitleBarWidget(0);
3955 if (!dock->isFloating()) {
3956 dock->setTitleBarWidget(new QWidget);
3960 KdenliveSettings::setShowtitlebars(show);
3963 void MainWindow::slotSwitchTitles()
3965 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3968 QString MainWindow::getMimeType()
3970 QString mimetype = "application/x-kdenlive";
3971 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3972 if (!mime) mimetype = "*.kdenlive";
3976 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3979 m_projectMonitor->render->sendFrameForAnalysis = true;
3982 for (int i = 0; i < m_scopesList.count(); i++) {
3983 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3990 m_projectMonitor->render->sendFrameForAnalysis = false;
3994 void MainWindow::slotUpdateScopeFrameRequest()
3996 // We need a delay to make sure widgets are hidden after a close event for example
3997 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
4000 void MainWindow::slotDoUpdateScopeFrameRequest()
4003 bool request = false;
4004 for (int i = 0; i < m_scopesList.count(); i++) {
4005 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
4006 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
4012 if (!m_projectMonitor->effectSceneDisplayed())
4013 m_projectMonitor->render->sendFrameForAnalysis = false;
4014 m_clipMonitor->render->sendFrameForAnalysis = false;
4016 m_projectMonitor->render->sendFrameForAnalysis = true;
4017 m_clipMonitor->render->sendFrameForAnalysis = true;
4021 void MainWindow::slotUpdateColorScopes()
4023 bool request = false;
4024 for (int i = 0; i < m_scopesList.count(); i++) {
4025 // Check if we need the renderer to send a new frame for update
4026 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4027 static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4030 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4031 else m_projectMonitor->render->sendFrameUpdate();
4035 void MainWindow::slotOpenStopmotion()
4037 if (m_stopmotion == NULL) {
4038 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4039 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4040 for (int i = 0; i < m_scopesList.count(); i++) {
4041 // Check if we need the renderer to send a new frame for update
4042 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4043 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4044 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4047 m_stopmotion->show();
4050 void MainWindow::slotDeleteClip(const QString &id)
4052 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4053 for (int i = 0; i < list.size(); ++i) {
4054 list.at(i)->disableClipId(id);
4056 m_projectList->slotDeleteClip(id);
4059 #include "mainwindow.moc"