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 "vectorscope.h"
58 #include "rgbparade.h"
59 #include "histogram.h"
60 #include "audiospectrum.h"
62 #include <KApplication>
66 #include <KActionCollection>
67 #include <KActionCategory>
68 #include <KStandardAction>
69 #include <KShortcutsDialog>
70 #include <KFileDialog>
71 #include <KMessageBox>
73 #include <KIO/NetAccess>
76 #include <KConfigDialog>
77 #include <KXMLGUIFactory>
79 #include <kstandarddirs.h>
80 #include <KUrlRequesterDialog>
81 #include <KTemporaryFile>
83 #include <KActionMenu>
86 #include <ktogglefullscreenaction.h>
88 #include <KNotification>
89 #include <KNotifyConfigWidget>
90 #if KDE_IS_VERSION(4,3,80)
91 #include <knewstuff3/downloaddialog.h>
92 #include <knewstuff3/knewstuffaction.h>
94 #include <knewstuff2/engine.h>
95 #include <knewstuff2/ui/knewstuffaction.h>
97 #endif /* KDE_IS_VERSION(4,3,80) */
99 #include <KColorScheme>
100 #include <KProgressDialog>
102 #include <QTextStream>
106 #include <QInputDialog>
107 #include <QDesktopWidget>
112 static const char version[] = VERSION;
114 static const int ID_TIMELINE_POS = 0;
121 EffectsList MainWindow::videoEffects;
122 EffectsList MainWindow::audioEffects;
123 EffectsList MainWindow::customEffects;
124 EffectsList MainWindow::transitions;
126 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
127 KXmlGuiWindow(parent),
128 m_activeDocument(NULL),
129 m_activeTimeline(NULL),
130 m_renderWidget(NULL),
131 #ifndef NO_JOGSHUTTLE
133 #endif /* NO_JOGSHUTTLE */
134 m_findActivated(false),
138 // Create DBus interface
139 new MainWindowAdaptor(this);
140 QDBusConnection dbus = QDBusConnection::sessionBus();
141 dbus.registerObject("/MainWindow", this);
143 setlocale(LC_NUMERIC, "POSIX");
144 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
145 setFont(KGlobalSettings::toolBarFont());
146 parseProfiles(MltPath);
147 m_commandStack = new QUndoGroup;
148 setDockNestingEnabled(true);
149 m_timelineArea = new KTabWidget(this);
150 m_timelineArea->setTabReorderingEnabled(true);
151 m_timelineArea->setTabBarHidden(true);
152 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
153 m_timelineArea->setMinimumHeight(200);
155 QToolButton *closeTabButton = new QToolButton;
156 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
157 closeTabButton->setIcon(KIcon("tab-close"));
158 closeTabButton->adjustSize();
159 closeTabButton->setToolTip(i18n("Close the current tab"));
160 m_timelineArea->setCornerWidget(closeTabButton);
161 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
163 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
164 m_findTimer.setSingleShot(true);
166 // FIXME: the next call returns a newly allocated object, which leaks
167 initEffects::parseEffectFiles();
168 //initEffects::parseCustomEffectsFile();
170 m_monitorManager = new MonitorManager();
172 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
173 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
178 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
179 m_projectListDock->setObjectName("project_tree");
180 m_projectList = new ProjectList();
181 m_projectListDock->setWidget(m_projectList);
182 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
184 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
185 m_clipMonitorDock->setObjectName("clip_monitor");
186 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
187 m_clipMonitorDock->setWidget(m_clipMonitor);
188 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
190 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
191 m_projectMonitorDock->setObjectName("project_monitor");
192 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
193 m_projectMonitorDock->setWidget(m_projectMonitor);
194 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
197 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
198 m_recMonitorDock->setObjectName("record_monitor");
199 m_recMonitor = new RecMonitor("record");
200 m_recMonitorDock->setWidget(m_recMonitor);
201 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
202 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
203 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
206 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
207 m_notesDock->setObjectName("notes_widget");
208 m_notesWidget = new KTextEdit();
209 m_notesWidget->setTabChangesFocus(true);
210 #if KDE_IS_VERSION(4,4,0)
211 m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
213 m_notesDock->setWidget(m_notesWidget);
214 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
216 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
217 m_effectStackDock->setObjectName("effect_stack");
218 m_effectStack = new EffectStackView(m_projectMonitor);
219 m_effectStackDock->setWidget(m_effectStack);
220 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
222 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
223 m_transitionConfigDock->setObjectName("transition");
224 m_transitionConfig = new TransitionSettings(m_projectMonitor);
225 m_transitionConfigDock->setWidget(m_transitionConfig);
226 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
228 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
229 m_effectListDock->setObjectName("effect_list");
230 m_effectList = new EffectsListView();
231 m_effectListDock->setWidget(m_effectList);
232 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
234 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
235 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
236 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
237 m_vectorscopeDock->setWidget(m_vectorscope);
238 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
239 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
240 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
241 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
242 m_scopesList.append(m_vectorscopeDock);
244 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
245 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
246 m_waveformDock->setObjectName(m_waveform->widgetName());
247 m_waveformDock->setWidget(m_waveform);
248 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
249 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
250 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
251 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
252 m_scopesList.append(m_waveformDock);
254 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
255 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
256 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
257 m_RGBParadeDock->setWidget(m_RGBParade);
258 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
259 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
260 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
261 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
262 m_scopesList.append(m_RGBParadeDock);
264 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
265 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
266 m_histogramDock->setObjectName(m_histogram->widgetName());
267 m_histogramDock->setWidget(m_histogram);
268 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
269 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
270 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
271 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
272 m_scopesList.append(m_histogramDock);
275 m_audiosignal = new AudioSignal;
276 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
277 m_audiosignalDock->setObjectName("audiosignal");
278 m_audiosignalDock->setWidget(m_audiosignal);
279 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
280 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
281 if (m_projectMonitor) {
282 connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
285 connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
287 //connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
288 //connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
290 m_audioSpectrum = new AudioSpectrum(m_projectMonitor, m_clipMonitor);
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);
295 if (m_projectMonitor) {
296 connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
297 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
300 connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
301 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
304 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
305 m_undoViewDock->setObjectName("undo_history");
306 m_undoView = new QUndoView();
307 m_undoView->setCleanIcon(KIcon("edit-clear"));
308 m_undoView->setEmptyLabel(i18n("Clean"));
309 m_undoViewDock->setWidget(m_undoView);
310 m_undoView->setGroup(m_commandStack);
311 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
313 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
314 //overviewDock->setObjectName("project_overview");
315 //m_overView = new CustomTrackView(NULL, NULL, this);
316 //overviewDock->setWidget(m_overView);
317 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
322 /// Tabify Widgets ///
323 tabifyDockWidget(m_projectListDock, m_effectStackDock);
324 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
325 tabifyDockWidget(m_projectListDock, m_notesDock);
328 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
330 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
333 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
334 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
335 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
336 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
337 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
340 setCentralWidget(m_timelineArea);
343 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
344 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
346 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
347 m_fileRevert->setEnabled(false);
349 // Prepare layout actions
350 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
351 for (int i = 1; i < 5; i++) {
352 KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
353 load->setData("_" + QString::number(i));
354 layoutActions->addAction("load_layout" + QString::number(i), load);
355 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
356 save->setData("_" + QString::number(i));
357 layoutActions->addAction("save_layout" + QString::number(i), save);
361 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
362 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
363 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
364 action->setShortcut(Qt::Key_Space);
365 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
366 m_stopmotion_actions->addAction("stopmotion_capture", action);
367 action = new KAction(i18n("Switch live / captured frame"), this);
368 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
369 m_stopmotion_actions->addAction("stopmotion_switch", action);
370 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
371 action->setCheckable(true);
372 action->setChecked(false);
373 m_stopmotion_actions->addAction("stopmotion_overlay", action);
377 // Find QDockWidget tab bars and show / hide widget title bars on right click
378 QList <QTabBar *> tabs = findChildren<QTabBar *>();
379 for (int i = 0; i < tabs.count(); i++) {
380 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
381 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
384 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
385 guiFactory()->addClient(sp);*/
388 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
390 connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
391 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
393 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
396 // Load layout names from config file
401 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
403 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
404 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
406 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
407 clipInTimeline->setIcon(KIcon("go-jump"));
408 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
409 static_cast<QMenu*>(factory()->container("transcoders", this)),
412 // build themes menus
413 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
414 QActionGroup *themegroup = new QActionGroup(this);
415 themegroup->setExclusive(true);
416 action = new KAction(i18n("Default"), this);
417 action->setCheckable(true);
418 themegroup->addAction(action);
419 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
421 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
423 for (int i = 0; i < schemeFiles.size(); ++i) {
425 const QString filename = schemeFiles.at(i);
426 const QFileInfo info(filename);
429 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
430 QIcon icon = createSchemePreviewIcon(config);
431 KConfigGroup group(config, "General");
432 const QString name = group.readEntry("Name", info.baseName());
433 action = new KAction(name, this);
434 action->setData(filename);
435 action->setIcon(icon);
436 action->setCheckable(true);
437 themegroup->addAction(action);
438 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
441 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
442 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
443 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
446 action = new QAction(fi.fileName(), this);
447 action->setData(*it);
448 action->setCheckable(true);
449 themegroup->addAction(action);
450 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
452 themesMenu->addActions(themegroup->actions());
453 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
455 // Setup and fill effects and transitions menus.
456 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
457 for (int i = 0; i < videoEffects.count(); ++i)
458 m_videoEffectsMenu->addAction(m_videoEffects[i]);
459 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
460 for (int i = 0; i < audioEffects.count(); ++i)
461 m_audioEffectsMenu->addAction(m_audioEffects[i]);
462 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
463 if (customEffects.isEmpty())
464 m_customEffectsMenu->setEnabled(false);
466 m_customEffectsMenu->setEnabled(true);
467 for (int i = 0; i < customEffects.count(); ++i)
468 m_customEffectsMenu->addAction(m_customEffects[i]);
469 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
470 for (int i = 0; i < transitions.count(); ++i)
471 m_transitionsMenu->addAction(m_transitions[i]);
473 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
474 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
475 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
476 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
478 QMenu *newEffect = new QMenu(this);
479 newEffect->addMenu(m_videoEffectsMenu);
480 newEffect->addMenu(m_audioEffectsMenu);
481 newEffect->addMenu(m_customEffectsMenu);
482 m_effectStack->setMenu(newEffect);
484 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
485 const QList<QAction *> viewActions = createPopupMenu()->actions();
486 viewMenu->insertActions(NULL, viewActions);
488 m_timelineContextMenu = new QMenu(this);
489 m_timelineContextClipMenu = new QMenu(this);
490 m_timelineContextTransitionMenu = new QMenu(this);
492 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
493 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
494 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
496 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
497 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
498 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
499 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
500 m_timelineContextClipMenu->addSeparator();
501 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
502 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
503 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
504 m_timelineContextClipMenu->addSeparator();
505 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
506 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
507 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
508 m_timelineContextClipMenu->addSeparator();
510 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
511 m_timelineContextClipMenu->addMenu(markersMenu);
512 m_timelineContextClipMenu->addSeparator();
513 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
514 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
515 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
516 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
518 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
519 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
520 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
522 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
524 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
525 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
526 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
527 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
528 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
529 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
530 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
532 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
533 slotConnectMonitors();
535 // Open or create a file. Command line argument passed in Url has
536 // precedence, then "openlastproject", then just a plain empty file.
537 // If opening Url fails, openlastproject will _not_ be used.
538 if (!Url.isEmpty()) {
539 // delay loading so that the window shows up
541 QTimer::singleShot(500, this, SLOT(openFile()));
542 } else if (KdenliveSettings::openlastproject()) {
543 QTimer::singleShot(500, this, SLOT(openLastFile()));
544 } else { //if (m_timelineArea->count() == 0) {
548 if (!clipsToLoad.isEmpty() && m_activeDocument) {
549 QStringList list = clipsToLoad.split(',');
551 foreach(QString path, list) {
552 kDebug() << QDir::current().absoluteFilePath(path);
553 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
555 m_projectList->slotAddClip(urls);
558 #ifndef NO_JOGSHUTTLE
559 activateShuttleDevice();
560 #endif /* NO_JOGSHUTTLE */
561 m_projectListDock->raise();
563 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
564 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
567 MainWindow::~MainWindow()
572 m_effectStack->slotClipItemSelected(NULL, 0);
573 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
575 if (m_projectMonitor) m_projectMonitor->stop();
576 if (m_clipMonitor) m_clipMonitor->stop();
578 delete m_activeTimeline;
579 delete m_effectStack;
580 delete m_transitionConfig;
581 delete m_activeDocument;
582 delete m_projectMonitor;
583 delete m_clipMonitor;
584 delete m_shortcutRemoveFocus;
585 Mlt::Factory::close();
588 void MainWindow::queryQuit()
596 bool MainWindow::queryClose()
598 if (m_renderWidget) {
599 int waitingJobs = m_renderWidget->waitingJobsCount();
600 if (waitingJobs > 0) {
601 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")))) {
602 case KMessageBox::Yes :
603 // create script with waiting jobs and start it
604 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
606 case KMessageBox::No :
607 // Don't do anything, jobs will be deleted
615 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
616 // warn the user to save if document is modified and we have clips in our project list
617 if (m_activeDocument && m_activeDocument->isModified() &&
618 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
619 !m_projectList->documentClipList().isEmpty())) {
623 if (m_activeDocument->url().fileName().isEmpty())
624 message = i18n("Save changes to document?");
626 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
627 switch (KMessageBox::warningYesNoCancel(this, message)) {
628 case KMessageBox::Yes :
629 // save document here. If saving fails, return false;
631 case KMessageBox::No :
632 // User does not want to save the changes, clear recovery files
633 m_activeDocument->m_autosave->resize(0);
642 void MainWindow::loadPlugins()
644 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
645 populateMenus(plugin);
648 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
650 filters << "libkdenlive*";
651 foreach(const QString & folder, directories) {
652 kDebug() << "Parsing plugin folder: " << folder;
653 QDir pluginsDir(folder);
654 foreach(const QString & fileName,
655 pluginsDir.entryList(filters, QDir::Files)) {
657 * Avoid loading the same plugin twice when there is more than one
660 if (!m_pluginFileNames.contains(fileName)) {
661 kDebug() << "Found plugin: " << fileName;
662 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
663 QObject *plugin = loader.instance();
665 populateMenus(plugin);
666 m_pluginFileNames += fileName;
668 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
674 void MainWindow::populateMenus(QObject *plugin)
676 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
677 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
679 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
683 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
684 QMenu *menu, const char *member,
685 QActionGroup *actionGroup)
687 kDebug() << "// ADD to MENU" << texts;
688 foreach(const QString & text, texts) {
689 QAction *action = new QAction(text, plugin);
690 action->setData(text);
691 connect(action, SIGNAL(triggered()), this, member);
692 menu->addAction(action);
695 action->setCheckable(true);
696 actionGroup->addAction(action);
701 void MainWindow::aboutPlugins()
703 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
708 void MainWindow::generateClip()
710 QAction *action = qobject_cast<QAction *>(sender());
711 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
713 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
714 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
715 if (!clipUrl.isEmpty()) {
716 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
720 void MainWindow::saveProperties(KConfigGroup &config)
722 // save properties here,used by session management
724 KMainWindow::saveProperties(config);
728 void MainWindow::readProperties(const KConfigGroup &config)
730 // read properties here,used by session management
731 KMainWindow::readProperties(config);
732 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
733 openFile(KUrl(Lastproject));
736 void MainWindow::slotReloadEffects()
738 m_customEffectsMenu->clear();
739 initEffects::parseCustomEffectsFile();
741 QStringList effectInfo;
742 QMap<QString, QStringList> effectsList;
743 for (int ix = 0; ix < customEffects.count(); ix++) {
744 effectInfo = customEffects.effectIdInfo(ix);
745 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
747 if (effectsList.isEmpty())
748 m_customEffectsMenu->setEnabled(false);
750 m_customEffectsMenu->setEnabled(true);
752 foreach(const QStringList & value, effectsList) {
753 action = new QAction(value.at(0), this);
754 action->setData(value);
755 m_customEffectsMenu->addAction(action);
757 m_effectList->reloadEffectList();
760 #ifndef NO_JOGSHUTTLE
761 void MainWindow::activateShuttleDevice()
765 if (KdenliveSettings::enableshuttle() == false) return;
766 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
767 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
768 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
769 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
770 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
771 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
774 void MainWindow::slotShuttleButton(int code)
778 slotShuttleAction(KdenliveSettings::shuttle1());
781 slotShuttleAction(KdenliveSettings::shuttle2());
784 slotShuttleAction(KdenliveSettings::shuttle3());
787 slotShuttleAction(KdenliveSettings::shuttle4());
790 slotShuttleAction(KdenliveSettings::shuttle5());
795 void MainWindow::slotShuttleAction(int code)
801 m_monitorManager->slotPlay();
804 m_monitorManager->slotPlay();
808 #endif /* NO_JOGSHUTTLE */
810 void MainWindow::configureNotifications()
812 KNotifyConfigWidget::configure(this);
815 void MainWindow::slotFullScreen()
817 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
820 void MainWindow::slotAddEffect(const QDomElement effect)
822 if (!m_activeDocument) return;
823 if (effect.isNull()) {
824 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
827 QDomElement effectToAdd = effect.cloneNode().toElement();
829 int ix = m_effectStack->isTrackMode(&ok);
830 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
831 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
834 void MainWindow::slotRaiseMonitor(bool clipMonitor)
836 if (clipMonitor) m_clipMonitorDock->raise();
837 else m_projectMonitorDock->raise();
840 void MainWindow::slotUpdateClip(const QString &id)
842 if (!m_activeDocument) return;
843 m_activeTimeline->projectView()->slotUpdateClip(id);
846 void MainWindow::slotConnectMonitors()
848 m_projectList->setRenderer(m_projectMonitor->render);
849 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
850 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
851 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
852 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
853 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
854 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
855 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)));
857 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
859 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
861 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
862 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
864 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
866 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
867 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
870 void MainWindow::slotAdjustClipMonitor()
872 m_clipMonitorDock->updateGeometry();
873 m_clipMonitorDock->adjustSize();
874 m_clipMonitor->resetSize();
877 void MainWindow::slotAdjustProjectMonitor()
879 m_projectMonitorDock->updateGeometry();
880 m_projectMonitorDock->adjustSize();
881 m_projectMonitor->resetSize();
884 void MainWindow::setupActions()
887 KActionCollection* collection = actionCollection();
888 m_timecodeFormat = new KComboBox(this);
889 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
890 m_timecodeFormat->addItem(i18n("Frames"));
891 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
892 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
894 m_statusProgressBar = new QProgressBar(this);
895 m_statusProgressBar->setMinimum(0);
896 m_statusProgressBar->setMaximum(100);
897 m_statusProgressBar->setMaximumWidth(150);
898 m_statusProgressBar->setVisible(false);
900 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
901 toolbar->setMovable(false);
902 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
903 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
904 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
905 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
906 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
907 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());
908 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
910 //create edit mode buttons
911 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
912 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
913 toolbar->addAction(m_normalEditTool);
914 m_normalEditTool->setCheckable(true);
915 m_normalEditTool->setChecked(true);
917 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
918 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
919 toolbar->addAction(m_overwriteEditTool);
920 m_overwriteEditTool->setCheckable(true);
921 m_overwriteEditTool->setChecked(false);
923 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
924 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
925 toolbar->addAction(m_insertEditTool);
926 m_insertEditTool->setCheckable(true);
927 m_insertEditTool->setChecked(false);
928 // not implemented yet
929 m_insertEditTool->setEnabled(false);
931 QActionGroup *editGroup = new QActionGroup(this);
932 editGroup->addAction(m_normalEditTool);
933 editGroup->addAction(m_overwriteEditTool);
934 editGroup->addAction(m_insertEditTool);
935 editGroup->setExclusive(true);
936 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
937 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
939 toolbar->addSeparator();
941 // create tools buttons
942 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
943 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
944 toolbar->addAction(m_buttonSelectTool);
945 m_buttonSelectTool->setCheckable(true);
946 m_buttonSelectTool->setChecked(true);
948 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
949 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
950 toolbar->addAction(m_buttonRazorTool);
951 m_buttonRazorTool->setCheckable(true);
952 m_buttonRazorTool->setChecked(false);
954 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
955 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
956 toolbar->addAction(m_buttonSpacerTool);
957 m_buttonSpacerTool->setCheckable(true);
958 m_buttonSpacerTool->setChecked(false);
960 QActionGroup *toolGroup = new QActionGroup(this);
961 toolGroup->addAction(m_buttonSelectTool);
962 toolGroup->addAction(m_buttonRazorTool);
963 toolGroup->addAction(m_buttonSpacerTool);
964 toolGroup->setExclusive(true);
965 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
967 QWidget * actionWidget;
968 int max = toolbar->iconSizeDefault() + 2;
969 actionWidget = toolbar->widgetForAction(m_normalEditTool);
970 actionWidget->setMaximumWidth(max);
971 actionWidget->setMaximumHeight(max - 4);
973 actionWidget = toolbar->widgetForAction(m_insertEditTool);
974 actionWidget->setMaximumWidth(max);
975 actionWidget->setMaximumHeight(max - 4);
977 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
978 actionWidget->setMaximumWidth(max);
979 actionWidget->setMaximumHeight(max - 4);
981 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
982 actionWidget->setMaximumWidth(max);
983 actionWidget->setMaximumHeight(max - 4);
985 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
986 actionWidget->setMaximumWidth(max);
987 actionWidget->setMaximumHeight(max - 4);
989 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
990 actionWidget->setMaximumWidth(max);
991 actionWidget->setMaximumHeight(max - 4);
993 toolbar->setStyleSheet(style1);
994 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
996 toolbar->addSeparator();
997 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
998 toolbar->addAction(m_buttonFitZoom);
999 m_buttonFitZoom->setCheckable(false);
1001 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1002 toolbar->addAction(m_zoomOut);
1003 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1005 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1006 m_zoomSlider->setMaximum(13);
1007 m_zoomSlider->setPageStep(1);
1008 m_zoomSlider->setInvertedAppearance(true);
1010 m_zoomSlider->setMaximumWidth(150);
1011 m_zoomSlider->setMinimumWidth(100);
1012 toolbar->addWidget(m_zoomSlider);
1014 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1015 toolbar->addAction(m_zoomIn);
1016 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1018 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1019 actionWidget->setMaximumWidth(max);
1020 actionWidget->setMaximumHeight(max - 4);
1021 actionWidget->setStyleSheet(styleBorderless);
1023 actionWidget = toolbar->widgetForAction(m_zoomIn);
1024 actionWidget->setMaximumWidth(max);
1025 actionWidget->setMaximumHeight(max - 4);
1026 actionWidget->setStyleSheet(styleBorderless);
1028 actionWidget = toolbar->widgetForAction(m_zoomOut);
1029 actionWidget->setMaximumWidth(max);
1030 actionWidget->setMaximumHeight(max - 4);
1031 actionWidget->setStyleSheet(styleBorderless);
1033 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1034 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1035 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1036 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1037 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1039 toolbar->addSeparator();
1041 //create automatic audio split button
1042 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1043 toolbar->addAction(m_buttonAutomaticSplitAudio);
1044 m_buttonAutomaticSplitAudio->setCheckable(true);
1045 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1046 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1048 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1049 toolbar->addAction(m_buttonVideoThumbs);
1050 m_buttonVideoThumbs->setCheckable(true);
1051 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1052 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1054 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1055 toolbar->addAction(m_buttonAudioThumbs);
1056 m_buttonAudioThumbs->setCheckable(true);
1057 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1058 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1060 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1061 toolbar->addAction(m_buttonShowMarkers);
1062 m_buttonShowMarkers->setCheckable(true);
1063 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1064 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1066 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1067 toolbar->addAction(m_buttonSnap);
1068 m_buttonSnap->setCheckable(true);
1069 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1070 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1072 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1073 actionWidget->setMaximumWidth(max);
1074 actionWidget->setMaximumHeight(max - 4);
1076 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1077 actionWidget->setMaximumWidth(max);
1078 actionWidget->setMaximumHeight(max - 4);
1080 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1081 actionWidget->setMaximumWidth(max);
1082 actionWidget->setMaximumHeight(max - 4);
1084 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1085 actionWidget->setMaximumWidth(max);
1086 actionWidget->setMaximumHeight(max - 4);
1088 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1089 actionWidget->setMaximumWidth(max);
1090 actionWidget->setMaximumHeight(max - 4);
1092 m_messageLabel = new StatusBarMessageLabel(this);
1093 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1095 statusBar()->addWidget(m_messageLabel, 10);
1096 statusBar()->addWidget(m_statusProgressBar, 0);
1097 statusBar()->addPermanentWidget(toolbar);
1098 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1099 statusBar()->addPermanentWidget(m_timecodeFormat);
1100 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1102 collection->addAction("normal_mode", m_normalEditTool);
1103 collection->addAction("overwrite_mode", m_overwriteEditTool);
1104 collection->addAction("insert_mode", m_insertEditTool);
1105 collection->addAction("select_tool", m_buttonSelectTool);
1106 collection->addAction("razor_tool", m_buttonRazorTool);
1107 collection->addAction("spacer_tool", m_buttonSpacerTool);
1109 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1110 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1111 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1112 collection->addAction("show_markers", m_buttonShowMarkers);
1113 collection->addAction("snap", m_buttonSnap);
1114 collection->addAction("zoom_fit", m_buttonFitZoom);
1115 collection->addAction("zoom_in", m_zoomIn);
1116 collection->addAction("zoom_out", m_zoomOut);
1118 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1119 collection->addAction("project_find", m_projectSearch);
1120 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1121 m_projectSearch->setShortcut(Qt::Key_Slash);
1123 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1124 collection->addAction("project_find_next", m_projectSearchNext);
1125 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1126 m_projectSearchNext->setShortcut(Qt::Key_F3);
1127 m_projectSearchNext->setEnabled(false);
1129 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1130 collection->addAction("manage_profiles", profilesAction);
1131 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1133 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1134 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1135 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1136 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1138 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1139 collection->addAction("run_wizard", wizAction);
1140 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1142 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1143 collection->addAction("project_settings", projectAction);
1144 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1146 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1147 collection->addAction("project_render", projectRender);
1148 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1149 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1151 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1152 collection->addAction("project_clean", projectClean);
1153 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1155 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1156 collection->addAction("project_adjust_profile", projectAdjust);
1157 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1159 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1160 KShortcut playShortcut;
1161 playShortcut.setPrimary(Qt::Key_Space);
1162 playShortcut.setAlternate(Qt::Key_K);
1163 monitorPlay->setShortcut(playShortcut);
1164 collection->addAction("monitor_play", monitorPlay);
1165 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1167 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1168 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1169 collection->addAction("monitor_play_zone", m_playZone);
1170 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1172 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1173 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1174 collection->addAction("monitor_loop_zone", m_loopZone);
1175 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1177 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1178 m_loopClip->setEnabled(false);
1179 collection->addAction("monitor_loop_clip", m_loopClip);
1180 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1182 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1183 collection->addAction("dvd_wizard", dvdWizard);
1184 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1186 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1187 collection->addAction("transcode_clip", transcodeClip);
1188 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1190 KAction *markIn = collection->addAction("mark_in");
1191 markIn->setText(i18n("Set Zone In"));
1192 markIn->setShortcut(Qt::Key_I);
1193 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1195 KAction *markOut = collection->addAction("mark_out");
1196 markOut->setText(i18n("Set Zone Out"));
1197 markOut->setShortcut(Qt::Key_O);
1198 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1200 KAction *switchMon = collection->addAction("switch_monitor");
1201 switchMon->setText(i18n("Switch monitor"));
1202 switchMon->setShortcut(Qt::Key_T);
1203 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1205 KAction *fullMon = collection->addAction("monitor_fullscreen");
1206 fullMon->setText(i18n("Switch monitor fullscreen"));
1207 fullMon->setIcon(KIcon("view-fullscreen"));
1208 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1210 KAction *insertTree = collection->addAction("insert_project_tree");
1211 insertTree->setText(i18n("Insert zone in project tree"));
1212 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1213 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1215 KAction *insertTimeline = collection->addAction("insert_timeline");
1216 insertTimeline->setText(i18n("Insert zone in timeline"));
1217 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1218 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1220 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1221 collection->addAction("resize_timeline_clip_start", resizeStart);
1222 resizeStart->setShortcut(Qt::Key_1);
1223 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1225 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1226 collection->addAction("resize_timeline_clip_end", resizeEnd);
1227 resizeEnd->setShortcut(Qt::Key_2);
1228 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1230 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1231 monitorSeekBackward->setShortcut(Qt::Key_J);
1232 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1233 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1235 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1236 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1237 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1238 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1240 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1241 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1242 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1243 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1245 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1246 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1247 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1248 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1250 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1251 monitorSeekForward->setShortcut(Qt::Key_L);
1252 collection->addAction("monitor_seek_forward", monitorSeekForward);
1253 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1255 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1256 clipStart->setShortcut(Qt::Key_Home);
1257 collection->addAction("seek_clip_start", clipStart);
1258 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1260 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1261 clipEnd->setShortcut(Qt::Key_End);
1262 collection->addAction("seek_clip_end", clipEnd);
1263 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1265 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1266 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1267 collection->addAction("seek_zone_start", zoneStart);
1268 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1270 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1271 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1272 collection->addAction("seek_zone_end", zoneEnd);
1273 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1275 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1276 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1277 collection->addAction("seek_start", projectStart);
1278 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1280 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1281 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1282 collection->addAction("seek_end", projectEnd);
1283 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1285 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1286 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1287 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1288 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1290 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1291 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1292 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1293 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1295 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1296 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1297 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1298 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1300 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1301 deleteItem->setShortcut(Qt::Key_Delete);
1302 collection->addAction("delete_timeline_clip", deleteItem);
1303 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1305 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1306 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1307 editTimelineClipSpeed->setData("change_speed");
1308 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1310 KAction *stickTransition = collection->addAction("auto_transition");
1311 stickTransition->setData(QString("auto"));
1312 stickTransition->setCheckable(true);
1313 stickTransition->setEnabled(false);
1314 stickTransition->setText(i18n("Automatic Transition"));
1315 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1317 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1318 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1319 collection->addAction("group_clip", groupClip);
1320 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1322 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1323 collection->addAction("ungroup_clip", ungroupClip);
1324 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1325 ungroupClip->setData("ungroup_clip");
1326 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1328 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1329 collection->addAction("edit_item_duration", editItemDuration);
1330 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1332 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1333 collection->addAction("clip_in_project_tree", clipInProjectTree);
1334 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1336 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1337 collection->addAction("clip_to_project_tree", clipToProjectTree);
1338 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1340 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1341 insertOvertwrite->setShortcut(Qt::Key_V);
1342 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1343 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1345 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1346 selectTimelineClip->setShortcut(Qt::Key_Plus);
1347 collection->addAction("select_timeline_clip", selectTimelineClip);
1348 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1350 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1351 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1352 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1353 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1355 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1356 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1357 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1358 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1360 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1361 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1362 collection->addAction("select_timeline_transition", selectTimelineTransition);
1363 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1365 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1366 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1367 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1368 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1370 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1371 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1372 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1373 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1375 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1376 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1377 collection->addAction("cut_timeline_clip", cutTimelineClip);
1378 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1380 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1381 collection->addAction("add_clip_marker", addClipMarker);
1382 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1384 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1385 collection->addAction("delete_clip_marker", deleteClipMarker);
1386 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1388 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1389 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1390 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1392 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1393 collection->addAction("edit_clip_marker", editClipMarker);
1394 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1396 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1397 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1398 collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1399 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1401 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1402 collection->addAction("split_audio", splitAudio);
1403 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1405 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1406 collection->addAction("clip_audio_only", audioOnly);
1407 audioOnly->setData("clip_audio_only");
1408 audioOnly->setCheckable(true);
1410 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1411 collection->addAction("clip_video_only", videoOnly);
1412 videoOnly->setData("clip_video_only");
1413 videoOnly->setCheckable(true);
1415 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1416 collection->addAction("clip_audio_and_video", audioAndVideo);
1417 audioAndVideo->setData("clip_audio_and_video");
1418 audioAndVideo->setCheckable(true);
1420 m_clipTypeGroup = new QActionGroup(this);
1421 m_clipTypeGroup->addAction(audioOnly);
1422 m_clipTypeGroup->addAction(videoOnly);
1423 m_clipTypeGroup->addAction(audioAndVideo);
1424 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1425 m_clipTypeGroup->setEnabled(false);
1427 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1428 collection->addAction("insert_space", insertSpace);
1429 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1431 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1432 collection->addAction("delete_space", removeSpace);
1433 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1435 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1436 collection->addAction("insert_track", insertTrack);
1437 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1439 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1440 collection->addAction("delete_track", deleteTrack);
1441 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1443 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1444 collection->addAction("config_tracks", configTracks);
1445 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1447 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1448 collection->addAction("add_guide", addGuide);
1449 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1451 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1452 collection->addAction("delete_guide", delGuide);
1453 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1455 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1456 collection->addAction("edit_guide", editGuide);
1457 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1459 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1460 collection->addAction("delete_all_guides", delAllGuides);
1461 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1463 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1464 collection->addAction("paste_effects", pasteEffects);
1465 pasteEffects->setData("paste_effects");
1466 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1468 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1469 collection->addAction("show_timeline", showTimeline);
1470 showTimeline->setCheckable(true);
1471 showTimeline->setChecked(true);
1472 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1474 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1475 collection->addAction("show_titlebars", showTitleBar);
1476 showTitleBar->setCheckable(true);
1477 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1478 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1479 slotShowTitleBars(KdenliveSettings::showtitlebars());
1482 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1484 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1485 collection->addAction("maximize_current", maxCurrent);
1486 maxCurrent->setCheckable(true);
1487 maxCurrent->setChecked(false);
1488 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1490 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1491 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1492 KStandardAction::open(this, SLOT(openFile()), collection);
1493 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1494 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1495 KStandardAction::openNew(this, SLOT(newFile()), collection);
1496 // TODO: make the following connection to slotEditKeys work
1497 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1498 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1499 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1500 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1501 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1502 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1504 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1505 undo->setEnabled(false);
1506 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1508 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1509 redo->setEnabled(false);
1510 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1513 //TODO: Add status tooltip to actions ?
1514 connect(collection, SIGNAL(actionHovered(QAction*)),
1515 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1518 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1519 collection->addAction("add_clip", addClip);
1520 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1522 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1523 collection->addAction("add_color_clip", addColorClip);
1524 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1526 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1527 collection->addAction("add_slide_clip", addSlideClip);
1528 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1530 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1531 collection->addAction("add_text_clip", addTitleClip);
1532 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1534 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1535 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1536 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1538 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1539 collection->addAction("add_folder", addFolderButton);
1540 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1542 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1543 collection->addAction("clip_properties", clipProperties);
1544 clipProperties->setData("clip_properties");
1545 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1546 clipProperties->setEnabled(false);
1548 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1549 collection->addAction("edit_clip", openClip);
1550 openClip->setData("edit_clip");
1551 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1552 openClip->setEnabled(false);
1554 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1555 collection->addAction("delete_clip", deleteClip);
1556 deleteClip->setData("delete_clip");
1557 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1558 deleteClip->setEnabled(false);
1560 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1561 collection->addAction("reload_clip", reloadClip);
1562 reloadClip->setData("reload_clip");
1563 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1564 reloadClip->setEnabled(false);
1566 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1567 collection->addAction("stopmotion", stopMotion);
1568 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1570 QMenu *addClips = new QMenu();
1571 addClips->addAction(addClip);
1572 addClips->addAction(addColorClip);
1573 addClips->addAction(addSlideClip);
1574 addClips->addAction(addTitleClip);
1575 addClips->addAction(addTitleTemplateClip);
1576 addClips->addAction(addFolderButton);
1578 addClips->addAction(reloadClip);
1579 addClips->addAction(clipProperties);
1580 addClips->addAction(openClip);
1581 addClips->addAction(deleteClip);
1582 m_projectList->setupMenu(addClips, addClip);
1584 // Setup effects and transitions actions.
1585 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1586 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1587 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1588 m_videoEffects = new KAction*[videoEffects.count()];
1589 for (int i = 0; i < videoEffects.count(); ++i) {
1590 QStringList effectInfo = videoEffects.effectIdInfo(i);
1591 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1592 m_videoEffects[i]->setData(effectInfo);
1593 m_videoEffects[i]->setIconVisibleInMenu(false);
1594 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1596 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1597 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1598 m_audioEffects = new KAction*[audioEffects.count()];
1599 for (int i = 0; i < audioEffects.count(); ++i) {
1600 QStringList effectInfo = audioEffects.effectIdInfo(i);
1601 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1602 m_audioEffects[i]->setData(effectInfo);
1603 m_audioEffects[i]->setIconVisibleInMenu(false);
1604 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1606 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1607 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1608 m_customEffects = new KAction*[customEffects.count()];
1609 for (int i = 0; i < customEffects.count(); ++i) {
1610 QStringList effectInfo = customEffects.effectIdInfo(i);
1611 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1612 m_customEffects[i]->setData(effectInfo);
1613 m_customEffects[i]->setIconVisibleInMenu(false);
1614 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1616 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1617 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1618 m_transitions = new KAction*[transitions.count()];
1619 for (int i = 0; i < transitions.count(); i++) {
1620 QStringList effectInfo = transitions.effectIdInfo(i);
1621 m_transitions[i] = new KAction(effectInfo.at(0), this);
1622 m_transitions[i]->setData(effectInfo);
1623 m_transitions[i]->setIconVisibleInMenu(false);
1624 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1626 m_effectsActionCollection->readSettings();
1628 //connect(collection, SIGNAL( clearStatusText() ),
1629 //statusBar(), SLOT( clear() ) );
1632 void MainWindow::slotDisplayActionMessage(QAction *a)
1634 statusBar()->showMessage(a->data().toString(), 3000);
1637 void MainWindow::loadLayouts()
1639 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1640 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1641 if (loadLayout == NULL || saveLayout == NULL) return;
1642 KSharedConfigPtr config = KGlobal::config();
1643 KConfigGroup layoutGroup(config, "Layouts");
1644 QStringList entries = layoutGroup.keyList();
1645 QList<QAction *> loadActions = loadLayout->actions();
1646 QList<QAction *> saveActions = saveLayout->actions();
1647 for (int i = 1; i < 5; i++) {
1648 // Rename the layouts actions
1649 foreach(const QString & key, entries) {
1650 if (key.endsWith(QString("_%1").arg(i))) {
1651 // Found previously saved layout
1652 QString layoutName = key.section("_", 0, -2);
1653 for (int j = 0; j < loadActions.count(); j++) {
1654 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1655 loadActions[j]->setText(layoutName);
1656 loadActions[j]->setData(key);
1660 for (int j = 0; j < saveActions.count(); j++) {
1661 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1662 saveActions[j]->setText(layoutName);
1663 saveActions[j]->setData(key);
1672 void MainWindow::slotLoadLayout(QAction *action)
1674 if (!action) return;
1675 QString layoutId = action->data().toString();
1676 if (layoutId.isEmpty()) return;
1677 KSharedConfigPtr config = KGlobal::config();
1678 KConfigGroup layouts(config, "Layouts");
1679 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1680 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1681 //restoreGeometry(geom);
1682 restoreState(state);
1685 void MainWindow::slotSaveLayout(QAction *action)
1687 QString originallayoutName = action->data().toString();
1688 int layoutId = originallayoutName.section('_', -1).toInt();
1690 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1691 if (layoutName.isEmpty()) return;
1692 KSharedConfigPtr config = KGlobal::config();
1693 KConfigGroup layouts(config, "Layouts");
1694 layouts.deleteEntry(originallayoutName);
1696 QByteArray st = saveState();
1697 layoutName.append("_" + QString::number(layoutId));
1698 layouts.writeEntry(layoutName, st.toBase64());
1702 void MainWindow::saveOptions()
1704 KdenliveSettings::self()->writeConfig();
1705 KSharedConfigPtr config = KGlobal::config();
1706 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1707 KConfigGroup treecolumns(config, "Project Tree");
1708 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1712 void MainWindow::readOptions()
1714 KSharedConfigPtr config = KGlobal::config();
1715 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1716 KConfigGroup initialGroup(config, "version");
1717 bool upgrade = false;
1718 if (initialGroup.exists()) {
1719 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1723 if (initialGroup.readEntry("version") == "0.7") {
1724 //Add new settings from 0.7.1
1725 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1726 QString path = QDir::homePath() + "/kdenlive";
1727 if (KStandardDirs::makeDir(path) == false) {
1728 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1729 } else KdenliveSettings::setDefaultprojectfolder(path);
1735 if (!initialGroup.exists() || upgrade) {
1736 // this is our first run, show Wizard
1737 Wizard *w = new Wizard(upgrade, this);
1738 if (w->exec() == QDialog::Accepted && w->isOk()) {
1739 w->adjustSettings();
1740 initialGroup.writeEntry("version", version);
1746 KConfigGroup treecolumns(config, "Project Tree");
1747 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1748 if (!state.isEmpty())
1749 m_projectList->setHeaderInfo(state);
1752 void MainWindow::slotRunWizard()
1754 Wizard *w = new Wizard(false, this);
1755 if (w->exec() == QDialog::Accepted && w->isOk()) {
1756 w->adjustSettings();
1761 void MainWindow::newFile(bool showProjectSettings, bool force)
1763 if (!m_timelineArea->isEnabled() && !force)
1765 m_fileRevert->setEnabled(false);
1766 QString profileName = KdenliveSettings::default_profile();
1767 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1768 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1769 if (!showProjectSettings) {
1770 if (!KdenliveSettings::activatetabs())
1771 if (!closeCurrentDocument())
1774 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1775 if (w->exec() != QDialog::Accepted)
1777 if (!KdenliveSettings::activatetabs())
1778 if (!closeCurrentDocument())
1780 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1781 slotSwitchVideoThumbs();
1782 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1783 slotSwitchAudioThumbs();
1784 profileName = w->selectedProfile();
1785 projectFolder = w->selectedFolder();
1786 projectTracks = w->tracks();
1789 m_timelineArea->setEnabled(true);
1790 m_projectList->setEnabled(true);
1791 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1792 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1794 TrackView *trackView = new TrackView(doc, &ok, this);
1795 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1798 //m_timelineArea->setEnabled(false);
1799 //m_projectList->setEnabled(false);
1803 if (m_timelineArea->count() == 1) {
1804 connectDocumentInfo(doc);
1805 connectDocument(trackView, doc);
1807 m_timelineArea->setTabBarHidden(false);
1808 m_monitorManager->activateMonitor("clip");
1809 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1812 void MainWindow::activateDocument()
1814 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1815 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1816 KdenliveDoc *currentDoc = currentTab->document();
1817 connectDocumentInfo(currentDoc);
1818 connectDocument(currentTab, currentDoc);
1821 bool MainWindow::closeCurrentDocument(bool saveChanges)
1823 QWidget *w = m_timelineArea->currentWidget();
1824 if (!w) return true;
1825 // closing current document
1826 int ix = m_timelineArea->currentIndex() + 1;
1827 if (ix == m_timelineArea->count()) ix = 0;
1828 m_timelineArea->setCurrentIndex(ix);
1829 TrackView *tabToClose = (TrackView *) w;
1830 KdenliveDoc *docToClose = tabToClose->document();
1831 if (docToClose && docToClose->isModified() && saveChanges) {
1833 if (m_activeDocument->url().fileName().isEmpty())
1834 message = i18n("Save changes to document?");
1836 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1837 switch (KMessageBox::warningYesNoCancel(this, message)) {
1838 case KMessageBox::Yes :
1839 // save document here. If saving fails, return false;
1840 if (saveFile() == false) return false;
1842 case KMessageBox::Cancel :
1849 m_clipMonitor->slotSetXml(NULL);
1850 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1851 if (m_timelineArea->count() == 1) {
1852 m_timelineArea->setTabBarHidden(true);
1853 m_closeAction->setEnabled(false);
1855 if (docToClose == m_activeDocument) {
1856 delete m_activeDocument;
1857 m_activeDocument = NULL;
1858 m_effectStack->clear();
1859 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1863 if (w == m_activeTimeline) {
1864 delete m_activeTimeline;
1865 m_activeTimeline = NULL;
1872 bool MainWindow::saveFileAs(const QString &outputFileName)
1874 QString currentSceneList;
1875 m_monitorManager->stopActiveMonitor();
1877 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
1880 // Save timeline thumbnails
1881 m_activeTimeline->projectView()->saveThumbnails();
1882 m_activeDocument->setUrl(KUrl(outputFileName));
1883 if (m_activeDocument->m_autosave == NULL) {
1884 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1885 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1886 setCaption(m_activeDocument->description());
1887 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1888 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1889 m_activeDocument->setModified(false);
1890 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1891 m_fileRevert->setEnabled(true);
1895 bool MainWindow::saveFileAs()
1897 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1898 if (outputFile.isEmpty()) {
1901 if (QFile::exists(outputFile)) {
1902 // Show the file dialog again if the user does not want to overwrite the file
1903 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1904 return saveFileAs();
1906 return saveFileAs(outputFile);
1909 bool MainWindow::saveFile()
1911 if (!m_activeDocument) return true;
1912 if (m_activeDocument->url().isEmpty()) {
1913 return saveFileAs();
1915 bool result = saveFileAs(m_activeDocument->url().path());
1916 m_activeDocument->m_autosave->resize(0);
1921 void MainWindow::openFile()
1923 if (!m_startUrl.isEmpty()) {
1924 openFile(m_startUrl);
1925 m_startUrl = KUrl();
1928 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1929 if (url.isEmpty()) return;
1930 m_fileOpenRecent->addUrl(url);
1934 void MainWindow::openLastFile()
1936 KSharedConfigPtr config = KGlobal::config();
1937 KUrl::List urls = m_fileOpenRecent->urls();
1938 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1939 if (urls.isEmpty()) newFile(false);
1940 else openFile(urls.last());
1943 void MainWindow::openFile(const KUrl &url)
1945 // Check if the document is already opened
1946 const int ct = m_timelineArea->count();
1947 bool isOpened = false;
1949 for (i = 0; i < ct; i++) {
1950 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1951 KdenliveDoc *doc = tab->document();
1952 if (doc->url() == url) {
1958 m_timelineArea->setCurrentIndex(i);
1962 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1964 // Check for backup file
1965 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1966 if (!staleFiles.isEmpty()) {
1967 if (KMessageBox::questionYesNo(this,
1968 i18n("Auto-saved files exist. Do you want to recover them now?"),
1969 i18n("File Recovery"),
1970 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1971 recoverFiles(staleFiles);
1974 // remove the stale files
1975 foreach(KAutoSaveFile * stale, staleFiles) {
1976 stale->open(QIODevice::ReadWrite);
1981 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1982 m_messageLabel->repaint();
1983 doOpenFile(url, NULL);
1986 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1988 if (!m_timelineArea->isEnabled()) return;
1989 m_fileRevert->setEnabled(true);
1991 // Recreate stopmotion widget on document change
1993 delete m_stopmotion;
1994 m_stopmotion = NULL;
1997 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
1998 progressDialog.setAllowCancel(false);
1999 progressDialog.progressBar()->setMaximum(4);
2000 progressDialog.show();
2001 progressDialog.progressBar()->setValue(0);
2002 qApp->processEvents();
2004 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2006 progressDialog.progressBar()->setValue(1);
2007 progressDialog.progressBar()->setMaximum(4);
2008 progressDialog.setLabelText(i18n("Loading project"));
2009 qApp->processEvents();
2011 if (stale == NULL) {
2012 stale = new KAutoSaveFile(url, doc);
2013 doc->m_autosave = stale;
2015 doc->m_autosave = stale;
2016 doc->setUrl(stale->managedFile());
2017 doc->setModified(true);
2018 stale->setParent(doc);
2020 connectDocumentInfo(doc);
2022 progressDialog.progressBar()->setValue(2);
2023 qApp->processEvents();
2026 TrackView *trackView = new TrackView(doc, &ok, this);
2028 progressDialog.progressBar()->setValue(3);
2029 qApp->processEvents();
2031 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2033 m_timelineArea->setEnabled(false);
2034 m_projectList->setEnabled(false);
2035 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2036 slotGotProgressInfo(QString(), -1);
2037 newFile(false, true);
2040 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2041 trackView->setDuration(trackView->duration());
2042 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2044 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2045 slotGotProgressInfo(QString(), -1);
2046 m_projectMonitor->adjustRulerSize(trackView->duration());
2047 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2048 m_clipMonitor->refreshMonitor(true);
2050 progressDialog.progressBar()->setValue(4);
2053 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2055 foreach(KAutoSaveFile * stale, staleFiles) {
2056 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2057 // show an error message; we could not steal the lockfile
2058 // maybe another application got to the file before us?
2062 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2063 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2064 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2065 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2069 void MainWindow::parseProfiles(const QString &mltPath)
2071 //KdenliveSettings::setDefaulttmpfolder();
2072 if (!mltPath.isEmpty()) {
2073 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2074 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2077 if (KdenliveSettings::mltpath().isEmpty())
2078 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2080 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2081 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2082 if (!QFile::exists(meltPath))
2083 meltPath = KStandardDirs::findExe("melt");
2084 KdenliveSettings::setRendererpath(meltPath);
2087 if (KdenliveSettings::rendererpath().isEmpty()) {
2088 // Cannot find the MLT melt renderer, ask for location
2089 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2090 if (getUrl->exec() == QDialog::Rejected) {
2093 KUrl rendererPath = getUrl->selectedUrl();
2095 if (rendererPath.isEmpty()) ::exit(0);
2096 KdenliveSettings::setRendererpath(rendererPath.path());
2099 QStringList profilesFilter;
2100 profilesFilter << "*";
2101 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2102 if (profilesList.isEmpty()) {
2103 // Cannot find MLT path, try finding melt
2104 QString profilePath = KdenliveSettings::rendererpath();
2105 if (!profilePath.isEmpty()) {
2106 profilePath = profilePath.section('/', 0, -3);
2107 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2108 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2110 if (profilesList.isEmpty()) {
2111 // Cannot find the MLT profiles, ask for location
2112 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2113 getUrl->fileDialog()->setMode(KFile::Directory);
2114 if (getUrl->exec() == QDialog::Rejected) {
2117 KUrl mltPath = getUrl->selectedUrl();
2119 if (mltPath.isEmpty()) ::exit(0);
2120 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2121 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2125 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2127 // Parse again MLT profiles to build a list of available video formats
2128 if (profilesList.isEmpty()) parseProfiles();
2132 void MainWindow::slotEditProfiles()
2134 ProfilesDialog *w = new ProfilesDialog;
2135 if (w->exec() == QDialog::Accepted) {
2136 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2137 if (d) d->checkProfile();
2142 void MainWindow::slotDetectAudioDriver()
2144 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2145 leading to no audio output, see bug #934 */
2147 //decide which audio driver is really best, in some cases SDL is wrong
2148 if (KdenliveSettings::audiodrivername().isEmpty()) {
2150 KProcess readProcess;
2151 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2152 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2153 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2154 readProcess.setProgram("pactl", QStringList() << "stat");
2155 readProcess.execute(2000); // Kill it after 2 seconds
2157 QString result = QString(readProcess.readAllStandardOutput());
2158 kDebug() << "// / / / / / READING PACTL: ";
2160 if (!result.isEmpty()) {
2162 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2166 KdenliveSettings::setAutoaudiodrivername(driver);
2170 void MainWindow::slotEditProjectSettings()
2172 QPoint p = m_activeDocument->getTracksCount();
2173 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2175 if (w->exec() == QDialog::Accepted) {
2176 QString profile = w->selectedProfile();
2177 m_activeDocument->setProjectFolder(w->selectedFolder());
2179 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2181 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2182 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2183 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2184 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2189 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2191 double dar = m_activeDocument->dar();
2193 // Recreate the stopmotion widget if profile changes
2195 delete m_stopmotion;
2196 m_stopmotion = NULL;
2199 // Deselect current effect / transition
2200 m_effectStack->slotClipItemSelected(NULL, 0);
2201 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2202 m_clipMonitor->slotSetXml(NULL);
2203 bool updateFps = m_activeDocument->setProfilePath(profile);
2204 KdenliveSettings::setCurrent_profile(profile);
2205 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2206 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2208 m_activeDocument->clipManager()->clearUnusedProducers();
2209 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2210 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2211 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2212 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2213 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2214 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2215 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2216 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2217 if (updateFps) m_activeTimeline->updateProjectFps();
2218 m_activeDocument->setModified(true);
2219 m_commandStack->activeStack()->clear();
2220 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2221 slotUpdateMousePosition(0);
2222 // We need to desactivate & reactivate monitors to get a refresh
2223 //m_monitorManager->switchMonitors();
2227 void MainWindow::slotRenderProject()
2229 if (!m_renderWidget) {
2230 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2231 m_renderWidget = new RenderWidget(projectfolder, this);
2232 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2233 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2234 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2235 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2236 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2237 if (m_activeDocument) {
2238 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2239 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2240 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2241 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2244 slotCheckRenderStatus();
2245 m_renderWidget->show();
2246 m_renderWidget->showNormal();
2248 // What are the following lines supposed to do?
2249 //m_activeTimeline->tracksNumber();
2250 //m_renderWidget->enableAudio(false);
2251 //m_renderWidget->export_audio;
2254 void MainWindow::slotCheckRenderStatus()
2256 // Make sure there are no missing clips
2258 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2261 void MainWindow::setRenderingProgress(const QString &url, int progress)
2264 m_renderWidget->setRenderJob(url, progress);
2267 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2270 m_renderWidget->setRenderStatus(url, status, error);
2273 void MainWindow::slotCleanProject()
2275 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2276 m_projectList->cleanup();
2279 void MainWindow::slotUpdateMousePosition(int pos)
2281 if (m_activeDocument)
2282 switch (m_timecodeFormat->currentIndex()) {
2284 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2287 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2291 void MainWindow::slotUpdateDocumentState(bool modified)
2293 if (!m_activeDocument) return;
2294 setCaption(m_activeDocument->description(), modified);
2295 m_saveAction->setEnabled(modified);
2297 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2298 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2300 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2301 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2305 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2307 if (m_activeDocument) {
2308 if (m_activeDocument == doc) return;
2309 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2311 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2314 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2316 //m_projectMonitor->stop();
2317 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2318 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2319 if (m_activeDocument) {
2320 if (m_activeDocument == doc) return;
2321 if (m_activeTimeline) {
2322 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2323 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2324 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2325 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2326 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2327 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2328 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2329 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2331 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2333 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2334 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2335 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2336 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2337 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2338 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2339 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2340 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2341 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2342 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2343 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2344 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2345 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2346 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2347 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2348 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2349 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2350 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2351 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2352 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2353 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2354 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2355 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2356 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2357 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2358 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2359 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2360 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2361 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2362 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2363 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2364 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2365 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2366 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2367 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2368 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2369 m_effectStack->clear();
2371 //m_activeDocument->setRenderer(NULL);
2372 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2373 disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2374 m_clipMonitor->stop();
2376 KdenliveSettings::setCurrent_profile(doc->profilePath());
2377 KdenliveSettings::setProject_fps(doc->fps());
2378 m_monitorManager->resetProfiles(doc->timecode());
2379 m_projectList->setDocument(doc);
2380 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2381 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2382 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2383 connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2384 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2386 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2387 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2388 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2390 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2393 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2394 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2395 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2396 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2397 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2398 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2399 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2400 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2401 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2402 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2403 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2404 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2405 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2406 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2408 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2409 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2410 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2411 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2412 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2414 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2415 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2416 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2417 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2419 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2420 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2421 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2422 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2424 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2425 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2426 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2427 m_zoomSlider->setValue(doc->zoom().x());
2428 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2429 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2430 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2431 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2433 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2434 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2436 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2437 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2439 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2440 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2441 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2442 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2443 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2444 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2445 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2446 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2447 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2448 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2449 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2451 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2452 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2453 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2454 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2455 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2458 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2459 m_activeTimeline = trackView;
2460 if (m_renderWidget) {
2461 slotCheckRenderStatus();
2462 m_renderWidget->setProfile(doc->mltProfile());
2463 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2464 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2465 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2467 //doc->setRenderer(m_projectMonitor->render);
2468 m_commandStack->setActiveStack(doc->commandStack());
2469 KdenliveSettings::setProject_display_ratio(doc->dar());
2470 //doc->clipManager()->checkAudioThumbs();
2472 //m_overView->setScene(trackView->projectScene());
2473 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2474 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2476 setCaption(doc->description(), doc->isModified());
2477 m_saveAction->setEnabled(doc->isModified());
2478 m_normalEditTool->setChecked(true);
2479 m_activeDocument = doc;
2480 m_activeTimeline->updateProjectFps();
2481 m_activeDocument->checkProjectClips();
2483 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2485 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2486 slotUpdateMousePosition(0);
2487 // set tool to select tool
2488 m_buttonSelectTool->setChecked(true);
2491 void MainWindow::slotZoneMoved(int start, int end)
2493 m_activeDocument->setZone(start, end);
2494 m_projectMonitor->slotZoneMoved(start, end);
2497 void MainWindow::slotGuidesUpdated()
2500 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2503 void MainWindow::slotEditKeys()
2505 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2506 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2507 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2511 void MainWindow::slotPreferences(int page, int option)
2514 * An instance of your dialog could be already created and could be
2515 * cached, in which case you want to display the cached dialog
2516 * instead of creating another one
2518 if (m_stopmotion) m_stopmotion->slotLive(false);
2519 if (KConfigDialog::showDialog("settings")) {
2520 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2521 if (page != -1) d->showPage(page, option);
2525 // KConfigDialog didn't find an instance of this dialog, so lets
2527 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2528 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2529 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2530 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2532 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2535 if (page != -1) dialog->showPage(page, option);
2538 void MainWindow::slotUpdateCaptureFolder()
2542 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2543 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2547 void MainWindow::updateConfiguration()
2549 //TODO: we should apply settings to all projects, not only the current one
2550 if (m_activeTimeline) {
2551 m_activeTimeline->refresh();
2552 m_activeTimeline->projectView()->checkAutoScroll();
2553 m_activeTimeline->projectView()->checkTrackHeight();
2554 if (m_activeDocument)
2555 m_activeDocument->clipManager()->checkAudioThumbs();
2557 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2558 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2559 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2560 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2562 // Update list of transcoding profiles
2564 #ifndef NO_JOGSHUTTLE
2565 activateShuttleDevice();
2566 #endif /* NO_JOGSHUTTLE */
2570 void MainWindow::slotSwitchSplitAudio()
2572 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2573 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2576 void MainWindow::slotSwitchVideoThumbs()
2578 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2579 if (m_activeTimeline)
2580 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2581 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2584 void MainWindow::slotSwitchAudioThumbs()
2586 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2587 if (m_activeTimeline) {
2588 m_activeTimeline->refresh();
2589 m_activeTimeline->projectView()->checkAutoScroll();
2590 if (m_activeDocument)
2591 m_activeDocument->clipManager()->checkAudioThumbs();
2593 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2596 void MainWindow::slotSwitchMarkersComments()
2598 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2599 if (m_activeTimeline)
2600 m_activeTimeline->refresh();
2601 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2604 void MainWindow::slotSwitchSnap()
2606 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2607 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2611 void MainWindow::slotDeleteItem()
2613 if (QApplication::focusWidget() &&
2614 QApplication::focusWidget()->parentWidget() &&
2615 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2616 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2617 m_projectList->slotRemoveClip();
2620 QWidget *widget = QApplication::focusWidget();
2622 if (widget == m_effectStackDock) {
2623 m_effectStack->slotItemDel();
2626 widget = widget->parentWidget();
2629 // effect stack has no focus
2630 if (m_activeTimeline)
2631 m_activeTimeline->projectView()->deleteSelectedClips();
2635 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2637 if (m_clipMonitor->isActive())
2638 m_clipMonitor->checkOverlay();
2639 m_clipMonitor->updateMarkers(clip);
2642 void MainWindow::slotAddClipMarker()
2644 DocClipBase *clip = NULL;
2646 if (m_projectMonitor->isActive()) {
2647 if (m_activeTimeline) {
2648 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2650 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2651 clip = item->baseClip();
2655 clip = m_clipMonitor->activeClip();
2656 pos = m_clipMonitor->position();
2659 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2662 QString id = clip->getId();
2663 CommentedTime marker(pos, i18n("Marker"));
2664 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2665 if (d.exec() == QDialog::Accepted)
2666 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2669 void MainWindow::slotDeleteClipMarker()
2671 DocClipBase *clip = NULL;
2673 if (m_projectMonitor->isActive()) {
2674 if (m_activeTimeline) {
2675 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2677 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2678 clip = item->baseClip();
2682 clip = m_clipMonitor->activeClip();
2683 pos = m_clipMonitor->position();
2686 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2690 QString id = clip->getId();
2691 QString comment = clip->markerComment(pos);
2692 if (comment.isEmpty()) {
2693 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2696 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2699 void MainWindow::slotDeleteAllClipMarkers()
2701 DocClipBase *clip = NULL;
2702 if (m_projectMonitor->isActive()) {
2703 if (m_activeTimeline) {
2704 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2706 clip = item->baseClip();
2710 clip = m_clipMonitor->activeClip();
2713 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2716 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2719 void MainWindow::slotEditClipMarker()
2721 DocClipBase *clip = NULL;
2723 if (m_projectMonitor->isActive()) {
2724 if (m_activeTimeline) {
2725 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2727 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2728 clip = item->baseClip();
2732 clip = m_clipMonitor->activeClip();
2733 pos = m_clipMonitor->position();
2736 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2740 QString id = clip->getId();
2741 QString oldcomment = clip->markerComment(pos);
2742 if (oldcomment.isEmpty()) {
2743 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2747 CommentedTime marker(pos, oldcomment);
2748 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2749 if (d.exec() == QDialog::Accepted) {
2750 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2751 if (d.newMarker().time() != pos) {
2752 // remove old marker
2753 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2758 void MainWindow::slotAddMarkerGuideQuickly()
2760 if (!m_activeTimeline || !m_activeDocument)
2763 if (m_clipMonitor->isActive()) {
2764 DocClipBase *clip = m_clipMonitor->activeClip();
2765 GenTime pos = m_clipMonitor->position();
2768 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2772 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2774 m_activeTimeline->projectView()->slotAddGuide(false);
2778 void MainWindow::slotAddGuide()
2780 if (m_activeTimeline)
2781 m_activeTimeline->projectView()->slotAddGuide();
2784 void MainWindow::slotInsertSpace()
2786 if (m_activeTimeline)
2787 m_activeTimeline->projectView()->slotInsertSpace();
2790 void MainWindow::slotRemoveSpace()
2792 if (m_activeTimeline)
2793 m_activeTimeline->projectView()->slotRemoveSpace();
2796 void MainWindow::slotInsertTrack(int ix)
2798 m_projectMonitor->activateMonitor();
2799 if (m_activeTimeline)
2800 m_activeTimeline->projectView()->slotInsertTrack(ix);
2801 if (m_activeDocument)
2802 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2805 void MainWindow::slotDeleteTrack(int ix)
2807 m_projectMonitor->activateMonitor();
2808 if (m_activeTimeline)
2809 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2810 if (m_activeDocument)
2811 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2814 void MainWindow::slotConfigTrack(int ix)
2816 m_projectMonitor->activateMonitor();
2817 if (m_activeTimeline)
2818 m_activeTimeline->projectView()->slotConfigTracks(ix);
2819 if (m_activeDocument)
2820 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2823 void MainWindow::slotEditGuide()
2825 if (m_activeTimeline)
2826 m_activeTimeline->projectView()->slotEditGuide();
2829 void MainWindow::slotDeleteGuide()
2831 if (m_activeTimeline)
2832 m_activeTimeline->projectView()->slotDeleteGuide();
2835 void MainWindow::slotDeleteAllGuides()
2837 if (m_activeTimeline)
2838 m_activeTimeline->projectView()->slotDeleteAllGuides();
2841 void MainWindow::slotCutTimelineClip()
2843 if (m_activeTimeline)
2844 m_activeTimeline->projectView()->cutSelectedClips();
2847 void MainWindow::slotInsertClipOverwrite()
2849 if (m_activeTimeline) {
2850 QStringList data = m_clipMonitor->getZoneInfo();
2851 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2855 void MainWindow::slotSelectTimelineClip()
2857 if (m_activeTimeline)
2858 m_activeTimeline->projectView()->selectClip(true);
2861 void MainWindow::slotSelectTimelineTransition()
2863 if (m_activeTimeline)
2864 m_activeTimeline->projectView()->selectTransition(true);
2867 void MainWindow::slotDeselectTimelineClip()
2869 if (m_activeTimeline)
2870 m_activeTimeline->projectView()->selectClip(false, true);
2873 void MainWindow::slotDeselectTimelineTransition()
2875 if (m_activeTimeline)
2876 m_activeTimeline->projectView()->selectTransition(false, true);
2879 void MainWindow::slotSelectAddTimelineClip()
2881 if (m_activeTimeline)
2882 m_activeTimeline->projectView()->selectClip(true, true);
2885 void MainWindow::slotSelectAddTimelineTransition()
2887 if (m_activeTimeline)
2888 m_activeTimeline->projectView()->selectTransition(true, true);
2891 void MainWindow::slotGroupClips()
2893 if (m_activeTimeline)
2894 m_activeTimeline->projectView()->groupClips();
2897 void MainWindow::slotUnGroupClips()
2899 if (m_activeTimeline)
2900 m_activeTimeline->projectView()->groupClips(false);
2903 void MainWindow::slotEditItemDuration()
2905 if (m_activeTimeline)
2906 m_activeTimeline->projectView()->editItemDuration();
2909 void MainWindow::slotAddProjectClip(KUrl url)
2911 if (m_activeDocument)
2912 m_activeDocument->slotAddClipFile(url, QString());
2915 void MainWindow::slotAddTransition(QAction *result)
2917 if (!result) return;
2918 QStringList info = result->data().toStringList();
2919 if (info.isEmpty()) return;
2920 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2921 if (m_activeTimeline && !transition.isNull()) {
2922 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2926 void MainWindow::slotAddVideoEffect(QAction *result)
2928 if (!result) return;
2929 QStringList info = result->data().toStringList();
2930 if (info.isEmpty()) return;
2931 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2932 slotAddEffect(effect);
2935 void MainWindow::slotAddAudioEffect(QAction *result)
2937 if (!result) return;
2938 QStringList info = result->data().toStringList();
2939 if (info.isEmpty()) return;
2940 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2941 slotAddEffect(effect);
2944 void MainWindow::slotAddCustomEffect(QAction *result)
2946 if (!result) return;
2947 QStringList info = result->data().toStringList();
2948 if (info.isEmpty()) return;
2949 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2950 slotAddEffect(effect);
2953 void MainWindow::slotZoomIn()
2955 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2956 slotShowZoomSliderToolTip();
2959 void MainWindow::slotZoomOut()
2961 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2962 slotShowZoomSliderToolTip();
2965 void MainWindow::slotFitZoom()
2967 if (m_activeTimeline)
2968 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2971 void MainWindow::slotSetZoom(int value)
2973 value = qMax(m_zoomSlider->minimum(), value);
2974 value = qMin(m_zoomSlider->maximum(), value);
2976 if (m_activeTimeline)
2977 m_activeTimeline->slotChangeZoom(value);
2979 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2980 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2981 slotUpdateZoomSliderToolTip(value);
2983 m_zoomSlider->blockSignals(true);
2984 m_zoomSlider->setValue(value);
2985 m_zoomSlider->blockSignals(false);
2988 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2990 if (zoomlevel != -1)
2991 slotUpdateZoomSliderToolTip(zoomlevel);
2993 QPoint global = m_zoomSlider->rect().topLeft();
2994 global.ry() += m_zoomSlider->height() / 2;
2995 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2996 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2999 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3001 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3004 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3006 m_statusProgressBar->setValue(progress);
3007 if (progress >= 0) {
3008 if (!message.isEmpty())
3009 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3010 m_statusProgressBar->setVisible(true);
3011 } else if (progress == -2) {
3012 if (!message.isEmpty())
3013 m_messageLabel->setMessage(message, ErrorMessage);
3014 m_statusProgressBar->setVisible(false);
3016 m_messageLabel->setMessage(QString(), DefaultMessage);
3017 m_statusProgressBar->setVisible(false);
3021 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3023 if (clip->clipType() == TEXT) {
3024 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3025 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3026 // template text clip
3028 // Get the list of existing templates
3030 filter << "*.kdenlivetitle";
3031 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3033 QDialog *dia = new QDialog(this);
3034 Ui::TemplateClip_UI dia_ui;
3035 dia_ui.setupUi(dia);
3037 const QString templatePath = clip->getProperty("resource");
3038 for (int i = 0; i < templateFiles.size(); ++i) {
3039 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3040 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3042 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3043 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3044 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3045 //warning: setting base directory doesn't work??
3046 KUrl startDir(titlepath);
3047 dia_ui.template_list->fileDialog()->setUrl(startDir);
3048 dia_ui.description->setText(clip->getProperty("description"));
3049 if (dia->exec() == QDialog::Accepted) {
3050 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3051 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3053 QMap <QString, QString> newprops;
3055 if (KUrl(textTemplate).path() != templatePath) {
3056 // The template was changed
3057 newprops.insert("resource", textTemplate);
3060 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3061 newprops.insert("description", dia_ui.description->toPlainText());
3064 QString newtemplate = newprops.value("xmltemplate");
3065 if (newtemplate.isEmpty()) newtemplate = templatePath;
3067 // template modified we need to update xmldata
3068 QString description = newprops.value("description");
3069 if (description.isEmpty()) description = clip->getProperty("description");
3070 else newprops.insert("templatetext", description);
3071 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3072 if (!newprops.isEmpty()) {
3073 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3074 m_activeDocument->commandStack()->push(command);
3080 QString path = clip->getProperty("resource");
3081 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3083 doc.setContent(clip->getProperty("xmldata"));
3084 dia_ui->setXml(doc);
3085 if (dia_ui->exec() == QDialog::Accepted) {
3086 QMap <QString, QString> newprops;
3087 newprops.insert("xmldata", dia_ui->xml().toString());
3088 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3089 // duration changed, we need to update duration
3090 newprops.insert("out", QString::number(dia_ui->outPoint()));
3092 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3093 m_activeDocument->commandStack()->push(command);
3094 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3095 m_activeDocument->setModified(true);
3099 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3103 // any type of clip but a title
3104 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3105 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3106 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)));
3111 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3113 if (newprops.isEmpty()) return;
3114 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3115 m_activeDocument->commandStack()->push(command);
3116 m_activeDocument->setModified();
3119 // update clip occurences in timeline
3120 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3125 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3127 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3128 if (dia.exec() == QDialog::Accepted) {
3129 QUndoCommand *command = new QUndoCommand();
3130 command->setText(i18n("Edit clips"));
3131 for (int i = 0; i < cliplist.count(); i++) {
3132 DocClipBase *clip = cliplist.at(i);
3133 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3135 m_activeDocument->commandStack()->push(command);
3136 for (int i = 0; i < cliplist.count(); i++)
3137 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3141 void MainWindow::customEvent(QEvent* e)
3143 if (e->type() == QEvent::User)
3144 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3146 void MainWindow::slotActivateEffectStackView()
3148 m_effectStack->raiseWindow(m_effectStackDock);
3151 void MainWindow::slotActivateTransitionView(Transition *t)
3154 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3157 void MainWindow::slotSnapRewind()
3159 if (m_projectMonitor->isActive()) {
3160 if (m_activeTimeline)
3161 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3163 m_clipMonitor->slotSeekToPreviousSnap();
3167 void MainWindow::slotSnapForward()
3169 if (m_projectMonitor->isActive()) {
3170 if (m_activeTimeline)
3171 m_activeTimeline->projectView()->slotSeekToNextSnap();
3173 m_clipMonitor->slotSeekToNextSnap();
3177 void MainWindow::slotClipStart()
3179 if (m_projectMonitor->isActive()) {
3180 if (m_activeTimeline)
3181 m_activeTimeline->projectView()->clipStart();
3185 void MainWindow::slotClipEnd()
3187 if (m_projectMonitor->isActive()) {
3188 if (m_activeTimeline)
3189 m_activeTimeline->projectView()->clipEnd();
3193 void MainWindow::slotZoneStart()
3195 if (m_projectMonitor->isActive())
3196 m_projectMonitor->slotZoneStart();
3198 m_clipMonitor->slotZoneStart();
3201 void MainWindow::slotZoneEnd()
3203 if (m_projectMonitor->isActive())
3204 m_projectMonitor->slotZoneEnd();
3206 m_clipMonitor->slotZoneEnd();
3209 void MainWindow::slotChangeTool(QAction * action)
3211 if (action == m_buttonSelectTool)
3212 slotSetTool(SELECTTOOL);
3213 else if (action == m_buttonRazorTool)
3214 slotSetTool(RAZORTOOL);
3215 else if (action == m_buttonSpacerTool)
3216 slotSetTool(SPACERTOOL);
3219 void MainWindow::slotChangeEdit(QAction * action)
3221 if (!m_activeTimeline)
3224 if (action == m_overwriteEditTool)
3225 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3226 else if (action == m_insertEditTool)
3227 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3229 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3232 void MainWindow::slotSetTool(PROJECTTOOL tool)
3234 if (m_activeDocument && m_activeTimeline) {
3235 //m_activeDocument->setTool(tool);
3239 message = i18n("Ctrl + click to use spacer on current track only");
3242 message = i18n("Click on a clip to cut it");
3245 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3248 m_messageLabel->setMessage(message, InformationMessage);
3249 m_activeTimeline->projectView()->setTool(tool);
3253 void MainWindow::slotCopy()
3255 if (m_activeDocument && m_activeTimeline)
3256 m_activeTimeline->projectView()->copyClip();
3259 void MainWindow::slotPaste()
3261 if (m_activeDocument && m_activeTimeline)
3262 m_activeTimeline->projectView()->pasteClip();
3265 void MainWindow::slotPasteEffects()
3267 if (m_activeDocument && m_activeTimeline)
3268 m_activeTimeline->projectView()->pasteClipEffects();
3271 void MainWindow::slotFind()
3273 if (!m_activeDocument || !m_activeTimeline) return;
3274 m_projectSearch->setEnabled(false);
3275 m_findActivated = true;
3276 m_findString.clear();
3277 m_activeTimeline->projectView()->initSearchStrings();
3278 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3279 m_findTimer.start(5000);
3280 qApp->installEventFilter(this);
3283 void MainWindow::slotFindNext()
3285 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3286 statusBar()->showMessage(i18n("Found: %1", m_findString));
3288 statusBar()->showMessage(i18n("Reached end of project"));
3289 m_findTimer.start(4000);
3292 void MainWindow::findAhead()
3294 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3295 m_projectSearchNext->setEnabled(true);
3296 statusBar()->showMessage(i18n("Found: %1", m_findString));
3298 m_projectSearchNext->setEnabled(false);
3299 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3303 void MainWindow::findTimeout()
3305 m_projectSearchNext->setEnabled(false);
3306 m_findActivated = false;
3307 m_findString.clear();
3308 statusBar()->showMessage(i18n("Find stopped"), 3000);
3309 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3310 m_projectSearch->setEnabled(true);
3311 removeEventFilter(this);
3314 void MainWindow::slotClipInTimeline(const QString &clipId)
3316 if (m_activeTimeline && m_activeDocument) {
3317 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3319 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3320 inTimelineMenu->clear();
3322 QList <QAction *> actionList;
3324 for (int i = 0; i < matching.count(); ++i) {
3325 QString track = QString::number(matching.at(i).track);
3326 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3328 QAction *a = new QAction(track + ": " + start, this);
3329 a->setData(QStringList() << track << start);
3330 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3331 while (j < actionList.count()) {
3332 if (actionList.at(j)->text() > a->text()) break;
3335 actionList.insert(j, a);
3337 inTimelineMenu->addActions(actionList);
3339 if (matching.empty())
3340 inTimelineMenu->setEnabled(false);
3342 inTimelineMenu->setEnabled(true);
3346 void MainWindow::slotClipInProjectTree()
3348 if (m_activeTimeline) {
3349 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3350 if (clipIds.isEmpty())
3352 m_projectListDock->raise();
3353 for (int i = 0; i < clipIds.count(); i++)
3354 m_projectList->selectItemById(clipIds.at(i));
3355 if (m_projectMonitor->isActive())
3356 slotSwitchMonitors();
3360 /*void MainWindow::slotClipToProjectTree()
3362 if (m_activeTimeline) {
3363 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3364 if (clips.isEmpty()) return;
3365 for (int i = 0; i < clips.count(); i++) {
3366 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3368 //m_projectList->selectItemById(clipIds.at(i));
3372 void MainWindow::slotSelectClipInTimeline()
3374 if (m_activeTimeline) {
3375 QAction *action = qobject_cast<QAction *>(sender());
3376 QStringList data = action->data().toStringList();
3377 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3381 void MainWindow::keyPressEvent(QKeyEvent *ke)
3383 if (m_findActivated) {
3384 if (ke->key() == Qt::Key_Backspace) {
3385 m_findString = m_findString.left(m_findString.length() - 1);
3387 if (!m_findString.isEmpty())
3392 m_findTimer.start(4000);
3395 } else if (ke->key() == Qt::Key_Escape) {
3399 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3400 m_findString += ke->text();
3404 m_findTimer.start(4000);
3409 KXmlGuiWindow::keyPressEvent(ke);
3414 /** Gets called when the window gets hidden */
3415 void MainWindow::hideEvent(QHideEvent */*event*/)
3417 if (isMinimized() && m_monitorManager)
3418 m_monitorManager->stopActiveMonitor();
3421 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3423 if (m_findActivated) {
3424 if (event->type() == QEvent::ShortcutOverride) {
3425 QKeyEvent* ke = (QKeyEvent*) event;
3426 if (ke->text().trimmed().isEmpty()) return false;
3433 // pass the event on to the parent class
3434 return QMainWindow::eventFilter(obj, event);
3439 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3441 KDialog *dialog = new KDialog(this);
3442 dialog->setCaption("Save clip zone");
3443 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3445 QWidget *widget = new QWidget(dialog);
3446 dialog->setMainWidget(widget);
3448 QVBoxLayout *vbox = new QVBoxLayout(widget);
3449 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3450 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3451 path.append("untitled.mlt");
3452 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3453 url->setFilter("video/mlt-playlist");
3454 QLabel *label2 = new QLabel(i18n("Description:"), this);
3455 KLineEdit *edit = new KLineEdit(this);
3456 vbox->addWidget(label1);
3457 vbox->addWidget(url);
3458 vbox->addWidget(label2);
3459 vbox->addWidget(edit);
3460 if (dialog->exec() == QDialog::Accepted)
3461 render->saveZone(url->url(), edit->text(), zone);
3465 void MainWindow::slotSetInPoint()
3467 if (m_clipMonitor->isActive())
3468 m_clipMonitor->slotSetZoneStart();
3470 m_projectMonitor->slotSetZoneStart();
3471 //else m_activeTimeline->projectView()->setInPoint();
3474 void MainWindow::slotSetOutPoint()
3476 if (m_clipMonitor->isActive())
3477 m_clipMonitor->slotSetZoneEnd();
3479 m_projectMonitor->slotSetZoneEnd();
3480 // else m_activeTimeline->projectView()->setOutPoint();
3483 void MainWindow::slotResizeItemStart()
3485 if (m_activeTimeline)
3486 m_activeTimeline->projectView()->setInPoint();
3489 void MainWindow::slotResizeItemEnd()
3491 if (m_activeTimeline)
3492 m_activeTimeline->projectView()->setOutPoint();
3495 int MainWindow::getNewStuff(const QString &configFile)
3497 KNS3::Entry::List entries;
3498 #if KDE_IS_VERSION(4,3,80)
3499 KNS3::DownloadDialog dialog(configFile);
3501 entries = dialog.changedEntries();
3502 foreach(const KNS3::Entry & entry, entries) {
3503 if (entry.status() == KNS3::Entry::Installed)
3504 kDebug() << "// Installed files: " << entry.installedFiles();
3507 KNS::Engine engine(0);
3508 if (engine.init(configFile))
3509 entries = engine.downloadDialogModal(this);
3510 foreach(KNS::Entry * entry, entries) {
3511 if (entry->status() == KNS::Entry::Installed)
3512 kDebug() << "// Installed files: " << entry->installedFiles();
3514 #endif /* KDE_IS_VERSION(4,3,80) */
3515 return entries.size();
3518 void MainWindow::slotGetNewTitleStuff()
3520 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3521 TitleWidget::refreshTitleTemplates();
3524 void MainWindow::slotGetNewLumaStuff()
3526 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3527 initEffects::refreshLumas();
3528 m_activeTimeline->projectView()->reloadTransitionLumas();
3532 void MainWindow::slotGetNewRenderStuff()
3534 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3536 m_renderWidget->reloadProfiles();
3539 void MainWindow::slotGetNewMltProfileStuff()
3541 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3542 // update the list of profiles in settings dialog
3543 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3549 void MainWindow::slotAutoTransition()
3551 if (m_activeTimeline)
3552 m_activeTimeline->projectView()->autoTransition();
3555 void MainWindow::slotSplitAudio()
3557 if (m_activeTimeline)
3558 m_activeTimeline->projectView()->splitAudio();
3561 void MainWindow::slotUpdateClipType(QAction *action)
3563 if (m_activeTimeline) {
3564 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3565 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3566 else m_activeTimeline->projectView()->setAudioAndVideo();
3570 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3572 // We must stop the monitors since we create a new on in the dvd wizard
3573 m_clipMonitor->stop();
3574 m_projectMonitor->stop();
3575 DvdWizard w(url, profile, this);
3577 m_projectMonitor->start();
3580 void MainWindow::slotShowTimeline(bool show)
3582 if (show == false) {
3583 m_timelineState = saveState();
3584 centralWidget()->setHidden(true);
3586 centralWidget()->setHidden(false);
3587 restoreState(m_timelineState);
3591 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3593 //TODO: is there a way to maximize current widget?
3596 m_timelineState = saveState();
3597 QWidget *par = focusWidget()->parentWidget();
3598 while (par->parentWidget() && par->parentWidget() != this)
3599 par = par->parentWidget();
3600 kDebug() << "CURRENT WIDGET: " << par->objectName();
3603 //centralWidget()->setHidden(false);
3604 //restoreState(m_timelineState);
3608 void MainWindow::loadTranscoders()
3610 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3613 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3614 KConfigGroup transConfig(config, "Transcoding");
3616 QMap< QString, QString > profiles = transConfig.entryMap();
3617 QMapIterator<QString, QString> i(profiles);
3618 while (i.hasNext()) {
3620 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3621 QAction *a = transMenu->addAction(i.key());
3623 if (data.count() > 1)
3624 a->setToolTip(data.at(1));
3625 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3629 void MainWindow::slotTranscode(KUrl::List urls)
3634 if (urls.isEmpty()) {
3635 QAction *action = qobject_cast<QAction *>(sender());
3636 QStringList data = action->data().toStringList();
3637 params = data.at(0);
3638 if (data.count() > 1) desc = data.at(1);
3639 if (data.count() > 2) condition = data.at(2);
3640 urls << m_projectList->getConditionalUrls(condition);
3641 urls.removeAll(KUrl());
3643 if (urls.isEmpty()) {
3644 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3647 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3648 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3650 //QProcess::startDetached("ffmpeg", parameters);
3653 void MainWindow::slotTranscodeClip()
3655 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3656 if (urls.isEmpty()) return;
3657 slotTranscode(urls);
3660 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3662 if (m_activeDocument == NULL) return;
3663 QMapIterator<QString, QString> i(props);
3664 while (i.hasNext()) {
3666 m_activeDocument->setDocumentProperty(i.key(), i.value());
3668 m_activeDocument->setModified(true);
3672 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3674 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3676 QString playlistPath;
3679 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3680 QString path = m_renderWidget->getFreeScriptName();
3681 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3682 if (!ok || scriptPath.isEmpty()) return;
3683 scriptPath.prepend(scriptsFolder);
3684 QFile f(scriptPath);
3686 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3689 playlistPath = scriptPath + ".mlt";
3690 m_projectMonitor->saveSceneList(playlistPath);
3692 KTemporaryFile temp;
3693 temp.setAutoRemove(false);
3694 temp.setSuffix(".mlt");
3696 playlistPath = temp.fileName();
3697 m_projectMonitor->saveSceneList(playlistPath);
3700 if (!chapterFile.isEmpty()) {
3703 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3705 in = m_activeTimeline->inPoint();
3706 out = m_activeTimeline->outPoint();
3709 QDomElement chapters = doc.createElement("chapters");
3710 chapters.setAttribute("fps", m_activeDocument->fps());
3711 doc.appendChild(chapters);
3713 QDomElement guidesxml = m_activeDocument->guidesXml();
3714 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3715 for (int i = 0; i < nodes.count(); i++) {
3716 QDomElement e = nodes.item(i).toElement();
3718 QString comment = e.attribute("comment");
3719 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3720 if (time >= in && time < out) {
3721 if (zoneOnly) time = time - in;
3722 QDomElement chapter = doc.createElement("chapter");
3723 chapters.appendChild(chapter);
3724 chapter.setAttribute("title", comment);
3725 chapter.setAttribute("time", time);
3729 if (chapters.childNodes().count() > 0) {
3730 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3731 // Always insert a guide in pos 0
3732 QDomElement chapter = doc.createElement("chapter");
3733 chapters.insertBefore(chapter, QDomNode());
3734 chapter.setAttribute("title", i18n("Start"));
3735 chapter.setAttribute("time", "0");
3737 // save chapters file
3738 QFile file(chapterFile);
3739 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3740 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3742 file.write(doc.toString().toUtf8());
3743 if (file.error() != QFile::NoError) {
3744 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3751 if (m_renderWidget->automaticAudioExport()) {
3752 exportAudio = m_activeTimeline->checkProjectAudio();
3753 } else exportAudio = m_renderWidget->selectedAudioExport();
3754 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3757 void MainWindow::slotUpdateTimecodeFormat(int ix)
3759 KdenliveSettings::setFrametimecode(ix == 1);
3760 m_clipMonitor->updateTimecodeFormat();
3761 m_projectMonitor->updateTimecodeFormat();
3762 m_transitionConfig->updateTimecodeFormat();
3763 m_effectStack->updateTimecodeFormat();
3764 //m_activeTimeline->projectView()->clearSelection();
3765 m_activeTimeline->updateRuler();
3768 void MainWindow::slotRemoveFocus()
3770 statusBar()->setFocus();
3771 statusBar()->clearFocus();
3774 void MainWindow::slotRevert()
3776 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;
3777 KUrl url = m_activeDocument->url();
3778 if (closeCurrentDocument(false))
3779 doOpenFile(url, NULL);
3783 void MainWindow::slotShutdown()
3785 if (m_activeDocument) m_activeDocument->setModified(false);
3787 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3788 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3789 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3790 smserver.call("logout", 1, 2, 2);
3791 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3792 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3793 smserver.call("Shutdown");
3797 void MainWindow::slotUpdateTrackInfo()
3799 if (m_activeDocument)
3800 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3803 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3805 // Load the theme file
3807 if (action == NULL) theme = themename;
3808 else theme = action->data().toString();
3809 KdenliveSettings::setColortheme(theme);
3810 // Make palette for all widgets.
3812 if (theme.isEmpty())
3813 plt = QApplication::desktop()->palette();
3815 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3816 plt = KGlobalSettings::createApplicationPalette(config);
3819 kapp->setPalette(plt);
3820 const QObjectList children = statusBar()->children();
3822 foreach(QObject * child, children) {
3823 if (child->isWidgetType())
3824 ((QWidget*)child)->setPalette(plt);
3825 const QObjectList subchildren = child->children();
3826 foreach(QObject * subchild, subchildren) {
3827 if (subchild->isWidgetType())
3828 ((QWidget*)subchild)->setPalette(plt);
3831 if (m_activeTimeline) {
3832 m_activeTimeline->projectView()->updatePalette();
3837 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3839 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3840 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3841 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3842 const QSize bitsSize(24, 2);
3843 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3844 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3846 QPixmap pixmap(23, 16);
3847 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3849 KConfigGroup group(config, "WM");
3850 QPainter p(&pixmap);
3851 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3852 p.fillRect(1, 1, 7, 7, windowScheme.background());
3853 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3855 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3856 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3857 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3859 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3860 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3862 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3863 p.fillRect(1, 8, 7, 7, viewScheme.background());
3864 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3866 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3867 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3868 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3870 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3871 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3877 void MainWindow::slotSwitchMonitors()
3879 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3880 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3881 else m_projectList->focusTree();
3884 void MainWindow::slotSwitchFullscreen()
3886 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3887 else m_clipMonitor->slotSwitchFullScreen();
3890 void MainWindow::slotInsertZoneToTree()
3892 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3893 QStringList info = m_clipMonitor->getZoneInfo();
3894 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3897 void MainWindow::slotInsertZoneToTimeline()
3899 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3900 QStringList info = m_clipMonitor->getZoneInfo();
3901 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3905 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3907 if (m_activeDocument && m_activeTimeline) {
3908 if (!ids.isEmpty()) {
3909 for (int i = 0; i < ids.size(); ++i) {
3910 m_activeTimeline->slotDeleteClip(ids.at(i));
3912 m_activeDocument->clipManager()->slotDeleteClips(ids);
3914 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3915 m_activeDocument->setModified(true);
3919 void MainWindow::slotShowTitleBars(bool show)
3921 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
3922 for (int i = 0; i < docks.count(); i++) {
3923 QDockWidget* dock = docks.at(i);
3925 dock->setTitleBarWidget(0);
3927 if (!dock->isFloating()) {
3928 dock->setTitleBarWidget(new QWidget);
3932 KdenliveSettings::setShowtitlebars(show);
3935 void MainWindow::slotSwitchTitles()
3937 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3940 QString MainWindow::getMimeType()
3942 QString mimetype = "application/x-kdenlive";
3943 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3944 if (!mime) mimetype = "*.kdenlive";
3948 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3951 m_projectMonitor->render->sendFrameForAnalysis = true;
3954 for (int i = 0; i < m_scopesList.count(); i++) {
3955 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3962 m_projectMonitor->render->sendFrameForAnalysis = false;
3966 void MainWindow::slotUpdateScopeFrameRequest()
3968 // We need a delay to make sure widgets are hidden after a close event for example
3969 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3972 void MainWindow::slotDoUpdateScopeFrameRequest()
3975 bool request = false;
3976 for (int i = 0; i < m_scopesList.count(); i++) {
3977 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3978 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
3984 if (!m_projectMonitor->effectSceneDisplayed())
3985 m_projectMonitor->render->sendFrameForAnalysis = false;
3986 m_clipMonitor->render->sendFrameForAnalysis = false;
3988 m_projectMonitor->render->sendFrameForAnalysis = true;
3989 m_clipMonitor->render->sendFrameForAnalysis = true;
3993 void MainWindow::slotUpdateColorScopes()
3995 bool request = false;
3996 for (int i = 0; i < m_scopesList.count(); i++) {
3997 // Check if we need the renderer to send a new frame for update
3998 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
3999 static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4002 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4003 else m_projectMonitor->render->sendFrameUpdate();
4007 void MainWindow::slotOpenStopmotion()
4009 if (m_stopmotion == NULL) {
4010 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4011 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4012 for (int i = 0; i < m_scopesList.count(); i++) {
4013 // Check if we need the renderer to send a new frame for update
4014 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4015 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4016 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4019 m_stopmotion->show();
4022 void MainWindow::slotDeleteClip(const QString &id)
4024 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4025 for (int i = 0; i < list.size(); ++i) {
4026 list.at(i)->disableClipId(id);
4028 m_projectList->slotDeleteClip(id);
4031 #include "mainwindow.moc"