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"
61 #include <KApplication>
65 #include <KActionCollection>
66 #include <KActionCategory>
67 #include <KStandardAction>
68 #include <KShortcutsDialog>
69 #include <KFileDialog>
70 #include <KMessageBox>
72 #include <KIO/NetAccess>
75 #include <KConfigDialog>
76 #include <KXMLGUIFactory>
78 #include <kstandarddirs.h>
79 #include <KUrlRequesterDialog>
80 #include <KTemporaryFile>
82 #include <KActionMenu>
85 #include <ktogglefullscreenaction.h>
87 #include <KNotification>
88 #include <KNotifyConfigWidget>
89 #if KDE_IS_VERSION(4,3,80)
90 #include <knewstuff3/downloaddialog.h>
91 #include <knewstuff3/knewstuffaction.h>
93 #include <knewstuff2/engine.h>
94 #include <knewstuff2/ui/knewstuffaction.h>
96 #endif /* KDE_IS_VERSION(4,3,80) */
98 #include <KColorScheme>
99 #include <KProgressDialog>
101 #include <QTextStream>
105 #include <QInputDialog>
106 #include <QDesktopWidget>
111 static const char version[] = VERSION;
113 static const int ID_TIMELINE_POS = 0;
120 EffectsList MainWindow::videoEffects;
121 EffectsList MainWindow::audioEffects;
122 EffectsList MainWindow::customEffects;
123 EffectsList MainWindow::transitions;
125 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
126 KXmlGuiWindow(parent),
127 m_activeDocument(NULL),
128 m_activeTimeline(NULL),
129 m_renderWidget(NULL),
130 #ifndef NO_JOGSHUTTLE
132 #endif /* NO_JOGSHUTTLE */
133 m_findActivated(false),
137 // Create DBus interface
138 new MainWindowAdaptor(this);
139 QDBusConnection dbus = QDBusConnection::sessionBus();
140 dbus.registerObject("/MainWindow", this);
142 setlocale(LC_NUMERIC, "POSIX");
143 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
144 setFont(KGlobalSettings::toolBarFont());
145 parseProfiles(MltPath);
146 m_commandStack = new QUndoGroup;
147 setDockNestingEnabled(true);
148 m_timelineArea = new KTabWidget(this);
149 m_timelineArea->setTabReorderingEnabled(true);
150 m_timelineArea->setTabBarHidden(true);
151 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
152 m_timelineArea->setMinimumHeight(200);
154 QToolButton *closeTabButton = new QToolButton;
155 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
156 closeTabButton->setIcon(KIcon("tab-close"));
157 closeTabButton->adjustSize();
158 closeTabButton->setToolTip(i18n("Close the current tab"));
159 m_timelineArea->setCornerWidget(closeTabButton);
160 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
162 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
163 m_findTimer.setSingleShot(true);
165 // FIXME: the next call returns a newly allocated object, which leaks
166 initEffects::parseEffectFiles();
167 //initEffects::parseCustomEffectsFile();
169 m_monitorManager = new MonitorManager();
171 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
172 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
177 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
178 m_projectListDock->setObjectName("project_tree");
179 m_projectList = new ProjectList();
180 m_projectListDock->setWidget(m_projectList);
181 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
183 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
184 m_clipMonitorDock->setObjectName("clip_monitor");
185 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
186 m_clipMonitorDock->setWidget(m_clipMonitor);
187 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
189 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
190 m_projectMonitorDock->setObjectName("project_monitor");
191 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
192 m_projectMonitorDock->setWidget(m_projectMonitor);
193 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
196 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
197 m_recMonitorDock->setObjectName("record_monitor");
198 m_recMonitor = new RecMonitor("record");
199 m_recMonitorDock->setWidget(m_recMonitor);
200 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
201 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
202 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
205 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
206 m_notesDock->setObjectName("notes_widget");
207 m_notesWidget = new KTextEdit();
208 m_notesWidget->setTabChangesFocus(true);
209 #if KDE_IS_VERSION(4,4,0)
210 m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
212 m_notesDock->setWidget(m_notesWidget);
213 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
215 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
216 m_effectStackDock->setObjectName("effect_stack");
217 m_effectStack = new EffectStackView(m_projectMonitor);
218 m_effectStackDock->setWidget(m_effectStack);
219 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
221 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
222 m_transitionConfigDock->setObjectName("transition");
223 m_transitionConfig = new TransitionSettings(m_projectMonitor);
224 m_transitionConfigDock->setWidget(m_transitionConfig);
225 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
227 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
228 m_effectListDock->setObjectName("effect_list");
229 m_effectList = new EffectsListView();
230 m_effectListDock->setWidget(m_effectList);
231 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
233 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
234 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
235 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
236 m_vectorscopeDock->setWidget(m_vectorscope);
237 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
238 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
239 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
240 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
241 m_scopesList.append(m_vectorscopeDock);
243 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
244 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
245 m_waveformDock->setObjectName(m_waveform->widgetName());
246 m_waveformDock->setWidget(m_waveform);
247 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
248 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
249 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
250 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
251 m_scopesList.append(m_waveformDock);
253 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
254 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
255 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
256 m_RGBParadeDock->setWidget(m_RGBParade);
257 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
258 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
259 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
260 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
261 m_scopesList.append(m_RGBParadeDock);
263 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
264 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
265 m_histogramDock->setObjectName(m_histogram->widgetName());
266 m_histogramDock->setWidget(m_histogram);
267 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
268 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
269 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
270 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
271 m_scopesList.append(m_histogramDock);
274 m_audiosignal = new AudioSignal;
275 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
276 m_audiosignalDock->setObjectName("audiosignal");
277 m_audiosignalDock->setWidget(m_audiosignal);
278 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
279 if (m_projectMonitor) {
280 connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
283 connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
285 //connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
286 //connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
288 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
289 m_undoViewDock->setObjectName("undo_history");
290 m_undoView = new QUndoView();
291 m_undoView->setCleanIcon(KIcon("edit-clear"));
292 m_undoView->setEmptyLabel(i18n("Clean"));
293 m_undoViewDock->setWidget(m_undoView);
294 m_undoView->setGroup(m_commandStack);
295 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
297 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
298 //overviewDock->setObjectName("project_overview");
299 //m_overView = new CustomTrackView(NULL, NULL, this);
300 //overviewDock->setWidget(m_overView);
301 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
306 /// Tabify Widgets ///
307 tabifyDockWidget(m_projectListDock, m_effectStackDock);
308 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
309 tabifyDockWidget(m_projectListDock, m_notesDock);
312 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
314 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
317 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
318 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
319 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
320 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
321 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
324 setCentralWidget(m_timelineArea);
327 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
328 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
330 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
331 m_fileRevert->setEnabled(false);
333 // Prepare layout actions
334 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
335 for (int i = 1; i < 5; i++) {
336 KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
337 load->setData("_" + QString::number(i));
338 layoutActions->addAction("load_layout" + QString::number(i), load);
339 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
340 save->setData("_" + QString::number(i));
341 layoutActions->addAction("save_layout" + QString::number(i), save);
345 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
346 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
347 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
348 action->setShortcut(Qt::Key_Space);
349 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
350 m_stopmotion_actions->addAction("stopmotion_capture", action);
351 action = new KAction(i18n("Switch live / captured frame"), this);
352 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
353 m_stopmotion_actions->addAction("stopmotion_switch", action);
354 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
355 action->setCheckable(true);
356 action->setChecked(false);
357 m_stopmotion_actions->addAction("stopmotion_overlay", action);
361 // Find QDockWidget tab bars and show / hide widget title bars on right click
362 QList <QTabBar *> tabs = findChildren<QTabBar *>();
363 for (int i = 0; i < tabs.count(); i++) {
364 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
365 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
368 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
369 guiFactory()->addClient(sp);*/
372 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
374 connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
375 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
377 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
380 // Load layout names from config file
385 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
387 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
388 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
390 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
391 clipInTimeline->setIcon(KIcon("go-jump"));
392 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
393 static_cast<QMenu*>(factory()->container("transcoders", this)),
396 // build themes menus
397 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
398 QActionGroup *themegroup = new QActionGroup(this);
399 themegroup->setExclusive(true);
400 action = new KAction(i18n("Default"), this);
401 action->setCheckable(true);
402 themegroup->addAction(action);
403 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
405 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
407 for (int i = 0; i < schemeFiles.size(); ++i) {
409 const QString filename = schemeFiles.at(i);
410 const QFileInfo info(filename);
413 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
414 QIcon icon = createSchemePreviewIcon(config);
415 KConfigGroup group(config, "General");
416 const QString name = group.readEntry("Name", info.baseName());
417 action = new KAction(name, this);
418 action->setData(filename);
419 action->setIcon(icon);
420 action->setCheckable(true);
421 themegroup->addAction(action);
422 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
425 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
426 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
427 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
430 action = new QAction(fi.fileName(), this);
431 action->setData(*it);
432 action->setCheckable(true);
433 themegroup->addAction(action);
434 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
436 themesMenu->addActions(themegroup->actions());
437 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
439 // Setup and fill effects and transitions menus.
440 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
441 for (int i = 0; i < videoEffects.count(); ++i)
442 m_videoEffectsMenu->addAction(m_videoEffects[i]);
443 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
444 for (int i = 0; i < audioEffects.count(); ++i)
445 m_audioEffectsMenu->addAction(m_audioEffects[i]);
446 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
447 if (customEffects.isEmpty())
448 m_customEffectsMenu->setEnabled(false);
450 m_customEffectsMenu->setEnabled(true);
451 for (int i = 0; i < customEffects.count(); ++i)
452 m_customEffectsMenu->addAction(m_customEffects[i]);
453 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
454 for (int i = 0; i < transitions.count(); ++i)
455 m_transitionsMenu->addAction(m_transitions[i]);
457 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
458 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
459 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
460 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
462 QMenu *newEffect = new QMenu(this);
463 newEffect->addMenu(m_videoEffectsMenu);
464 newEffect->addMenu(m_audioEffectsMenu);
465 newEffect->addMenu(m_customEffectsMenu);
466 m_effectStack->setMenu(newEffect);
468 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
469 const QList<QAction *> viewActions = createPopupMenu()->actions();
470 viewMenu->insertActions(NULL, viewActions);
472 m_timelineContextMenu = new QMenu(this);
473 m_timelineContextClipMenu = new QMenu(this);
474 m_timelineContextTransitionMenu = new QMenu(this);
476 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
477 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
478 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
480 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
481 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
482 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
483 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
484 m_timelineContextClipMenu->addSeparator();
485 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
486 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
487 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
488 m_timelineContextClipMenu->addSeparator();
489 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
490 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
491 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
492 m_timelineContextClipMenu->addSeparator();
494 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
495 m_timelineContextClipMenu->addMenu(markersMenu);
496 m_timelineContextClipMenu->addSeparator();
497 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
498 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
499 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
500 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
502 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
503 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
504 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
506 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
508 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
509 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
510 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
511 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
512 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
513 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
514 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
516 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
517 slotConnectMonitors();
519 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
520 KdenliveSettings::setDropbframes(false);
522 // Open or create a file. Command line argument passed in Url has
523 // precedence, then "openlastproject", then just a plain empty file.
524 // If opening Url fails, openlastproject will _not_ be used.
525 if (!Url.isEmpty()) {
526 // delay loading so that the window shows up
528 QTimer::singleShot(500, this, SLOT(openFile()));
529 } else if (KdenliveSettings::openlastproject()) {
530 QTimer::singleShot(500, this, SLOT(openLastFile()));
531 } else { //if (m_timelineArea->count() == 0) {
535 if (!clipsToLoad.isEmpty() && m_activeDocument) {
536 QStringList list = clipsToLoad.split(',');
538 foreach(QString path, list) {
539 kDebug() << QDir::current().absoluteFilePath(path);
540 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
542 m_projectList->slotAddClip(urls);
545 #ifndef NO_JOGSHUTTLE
546 activateShuttleDevice();
547 #endif /* NO_JOGSHUTTLE */
548 m_projectListDock->raise();
550 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
551 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
554 MainWindow::~MainWindow()
559 m_effectStack->slotClipItemSelected(NULL, 0);
560 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
562 if (m_projectMonitor) m_projectMonitor->stop();
563 if (m_clipMonitor) m_clipMonitor->stop();
565 delete m_activeTimeline;
566 delete m_effectStack;
567 delete m_transitionConfig;
568 delete m_activeDocument;
569 delete m_projectMonitor;
570 delete m_clipMonitor;
571 delete m_shortcutRemoveFocus;
572 Mlt::Factory::close();
575 void MainWindow::queryQuit()
583 bool MainWindow::queryClose()
585 if (m_renderWidget) {
586 int waitingJobs = m_renderWidget->waitingJobsCount();
587 if (waitingJobs > 0) {
588 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")))) {
589 case KMessageBox::Yes :
590 // create script with waiting jobs and start it
591 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
593 case KMessageBox::No :
594 // Don't do anything, jobs will be deleted
602 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
603 // warn the user to save if document is modified and we have clips in our project list
604 if (m_activeDocument && m_activeDocument->isModified() &&
605 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
606 !m_projectList->documentClipList().isEmpty())) {
610 if (m_activeDocument->url().fileName().isEmpty())
611 message = i18n("Save changes to document?");
613 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
614 switch (KMessageBox::warningYesNoCancel(this, message)) {
615 case KMessageBox::Yes :
616 // save document here. If saving fails, return false;
618 case KMessageBox::No :
619 // User does not want to save the changes, clear recovery files
620 m_activeDocument->m_autosave->resize(0);
629 void MainWindow::loadPlugins()
631 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
632 populateMenus(plugin);
635 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
637 filters << "libkdenlive*";
638 foreach(const QString & folder, directories) {
639 kDebug() << "Parsing plugin folder: " << folder;
640 QDir pluginsDir(folder);
641 foreach(const QString & fileName,
642 pluginsDir.entryList(filters, QDir::Files)) {
644 * Avoid loading the same plugin twice when there is more than one
647 if (!m_pluginFileNames.contains(fileName)) {
648 kDebug() << "Found plugin: " << fileName;
649 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
650 QObject *plugin = loader.instance();
652 populateMenus(plugin);
653 m_pluginFileNames += fileName;
655 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
661 void MainWindow::populateMenus(QObject *plugin)
663 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
664 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
666 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
670 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
671 QMenu *menu, const char *member,
672 QActionGroup *actionGroup)
674 kDebug() << "// ADD to MENU" << texts;
675 foreach(const QString & text, texts) {
676 QAction *action = new QAction(text, plugin);
677 action->setData(text);
678 connect(action, SIGNAL(triggered()), this, member);
679 menu->addAction(action);
682 action->setCheckable(true);
683 actionGroup->addAction(action);
688 void MainWindow::aboutPlugins()
690 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
695 void MainWindow::generateClip()
697 QAction *action = qobject_cast<QAction *>(sender());
698 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
700 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
701 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
702 if (!clipUrl.isEmpty()) {
703 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
707 void MainWindow::saveProperties(KConfigGroup &config)
709 // save properties here,used by session management
711 KMainWindow::saveProperties(config);
715 void MainWindow::readProperties(const KConfigGroup &config)
717 // read properties here,used by session management
718 KMainWindow::readProperties(config);
719 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
720 openFile(KUrl(Lastproject));
723 void MainWindow::slotReloadEffects()
725 m_customEffectsMenu->clear();
726 initEffects::parseCustomEffectsFile();
728 QStringList effectInfo;
729 QMap<QString, QStringList> effectsList;
730 for (int ix = 0; ix < customEffects.count(); ix++) {
731 effectInfo = customEffects.effectIdInfo(ix);
732 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
734 if (effectsList.isEmpty())
735 m_customEffectsMenu->setEnabled(false);
737 m_customEffectsMenu->setEnabled(true);
739 foreach(const QStringList & value, effectsList) {
740 action = new QAction(value.at(0), this);
741 action->setData(value);
742 m_customEffectsMenu->addAction(action);
744 m_effectList->reloadEffectList();
747 #ifndef NO_JOGSHUTTLE
748 void MainWindow::activateShuttleDevice()
752 if (KdenliveSettings::enableshuttle() == false) return;
753 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
754 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
755 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
756 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
757 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
758 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
759 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
762 void MainWindow::slotShuttleButton(int code)
766 slotShuttleAction(KdenliveSettings::shuttle1());
769 slotShuttleAction(KdenliveSettings::shuttle2());
772 slotShuttleAction(KdenliveSettings::shuttle3());
775 slotShuttleAction(KdenliveSettings::shuttle4());
778 slotShuttleAction(KdenliveSettings::shuttle5());
783 void MainWindow::slotShuttleAction(int code)
789 m_monitorManager->slotPlay();
792 m_monitorManager->slotPlay();
796 #endif /* NO_JOGSHUTTLE */
798 void MainWindow::configureNotifications()
800 KNotifyConfigWidget::configure(this);
803 void MainWindow::slotFullScreen()
805 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
808 void MainWindow::slotAddEffect(const QDomElement effect)
810 if (!m_activeDocument) return;
811 if (effect.isNull()) {
812 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
815 QDomElement effectToAdd = effect.cloneNode().toElement();
817 int ix = m_effectStack->isTrackMode(&ok);
818 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
819 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
822 void MainWindow::slotRaiseMonitor(bool clipMonitor)
824 if (clipMonitor) m_clipMonitorDock->raise();
825 else m_projectMonitorDock->raise();
828 void MainWindow::slotUpdateClip(const QString &id)
830 if (!m_activeDocument) return;
831 m_activeTimeline->projectView()->slotUpdateClip(id);
834 void MainWindow::slotConnectMonitors()
836 m_projectList->setRenderer(m_projectMonitor->render);
837 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
838 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
839 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
840 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
841 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
842 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
843 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)));
845 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
847 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
849 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
850 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
852 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
854 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
855 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
858 void MainWindow::slotAdjustClipMonitor()
860 m_clipMonitorDock->updateGeometry();
861 m_clipMonitorDock->adjustSize();
862 m_clipMonitor->resetSize();
865 void MainWindow::slotAdjustProjectMonitor()
867 m_projectMonitorDock->updateGeometry();
868 m_projectMonitorDock->adjustSize();
869 m_projectMonitor->resetSize();
872 void MainWindow::setupActions()
875 KActionCollection* collection = actionCollection();
876 m_timecodeFormat = new KComboBox(this);
877 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
878 m_timecodeFormat->addItem(i18n("Frames"));
879 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
880 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
882 m_statusProgressBar = new QProgressBar(this);
883 m_statusProgressBar->setMinimum(0);
884 m_statusProgressBar->setMaximum(100);
885 m_statusProgressBar->setMaximumWidth(150);
886 m_statusProgressBar->setVisible(false);
888 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
889 toolbar->setMovable(false);
890 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
891 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
892 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
893 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
894 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
895 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());
896 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
898 //create edit mode buttons
899 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
900 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
901 toolbar->addAction(m_normalEditTool);
902 m_normalEditTool->setCheckable(true);
903 m_normalEditTool->setChecked(true);
905 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
906 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
907 toolbar->addAction(m_overwriteEditTool);
908 m_overwriteEditTool->setCheckable(true);
909 m_overwriteEditTool->setChecked(false);
911 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
912 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
913 toolbar->addAction(m_insertEditTool);
914 m_insertEditTool->setCheckable(true);
915 m_insertEditTool->setChecked(false);
916 // not implemented yet
917 m_insertEditTool->setEnabled(false);
919 QActionGroup *editGroup = new QActionGroup(this);
920 editGroup->addAction(m_normalEditTool);
921 editGroup->addAction(m_overwriteEditTool);
922 editGroup->addAction(m_insertEditTool);
923 editGroup->setExclusive(true);
924 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
925 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
927 toolbar->addSeparator();
929 // create tools buttons
930 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
931 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
932 toolbar->addAction(m_buttonSelectTool);
933 m_buttonSelectTool->setCheckable(true);
934 m_buttonSelectTool->setChecked(true);
936 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
937 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
938 toolbar->addAction(m_buttonRazorTool);
939 m_buttonRazorTool->setCheckable(true);
940 m_buttonRazorTool->setChecked(false);
942 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
943 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
944 toolbar->addAction(m_buttonSpacerTool);
945 m_buttonSpacerTool->setCheckable(true);
946 m_buttonSpacerTool->setChecked(false);
948 QActionGroup *toolGroup = new QActionGroup(this);
949 toolGroup->addAction(m_buttonSelectTool);
950 toolGroup->addAction(m_buttonRazorTool);
951 toolGroup->addAction(m_buttonSpacerTool);
952 toolGroup->setExclusive(true);
953 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
955 QWidget * actionWidget;
956 int max = toolbar->iconSizeDefault() + 2;
957 actionWidget = toolbar->widgetForAction(m_normalEditTool);
958 actionWidget->setMaximumWidth(max);
959 actionWidget->setMaximumHeight(max - 4);
961 actionWidget = toolbar->widgetForAction(m_insertEditTool);
962 actionWidget->setMaximumWidth(max);
963 actionWidget->setMaximumHeight(max - 4);
965 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
966 actionWidget->setMaximumWidth(max);
967 actionWidget->setMaximumHeight(max - 4);
969 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
970 actionWidget->setMaximumWidth(max);
971 actionWidget->setMaximumHeight(max - 4);
973 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
974 actionWidget->setMaximumWidth(max);
975 actionWidget->setMaximumHeight(max - 4);
977 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
978 actionWidget->setMaximumWidth(max);
979 actionWidget->setMaximumHeight(max - 4);
981 toolbar->setStyleSheet(style1);
982 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
984 toolbar->addSeparator();
985 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
986 toolbar->addAction(m_buttonFitZoom);
987 m_buttonFitZoom->setCheckable(false);
989 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
990 toolbar->addAction(m_zoomOut);
991 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
993 m_zoomSlider = new QSlider(Qt::Horizontal, this);
994 m_zoomSlider->setMaximum(13);
995 m_zoomSlider->setPageStep(1);
996 m_zoomSlider->setInvertedAppearance(true);
998 m_zoomSlider->setMaximumWidth(150);
999 m_zoomSlider->setMinimumWidth(100);
1000 toolbar->addWidget(m_zoomSlider);
1002 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1003 toolbar->addAction(m_zoomIn);
1004 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1006 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1007 actionWidget->setMaximumWidth(max);
1008 actionWidget->setMaximumHeight(max - 4);
1009 actionWidget->setStyleSheet(styleBorderless);
1011 actionWidget = toolbar->widgetForAction(m_zoomIn);
1012 actionWidget->setMaximumWidth(max);
1013 actionWidget->setMaximumHeight(max - 4);
1014 actionWidget->setStyleSheet(styleBorderless);
1016 actionWidget = toolbar->widgetForAction(m_zoomOut);
1017 actionWidget->setMaximumWidth(max);
1018 actionWidget->setMaximumHeight(max - 4);
1019 actionWidget->setStyleSheet(styleBorderless);
1021 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1022 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1023 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1024 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1025 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1027 toolbar->addSeparator();
1029 //create automatic audio split button
1030 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1031 toolbar->addAction(m_buttonAutomaticSplitAudio);
1032 m_buttonAutomaticSplitAudio->setCheckable(true);
1033 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1034 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1036 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1037 toolbar->addAction(m_buttonVideoThumbs);
1038 m_buttonVideoThumbs->setCheckable(true);
1039 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1040 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1042 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1043 toolbar->addAction(m_buttonAudioThumbs);
1044 m_buttonAudioThumbs->setCheckable(true);
1045 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1046 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1048 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1049 toolbar->addAction(m_buttonShowMarkers);
1050 m_buttonShowMarkers->setCheckable(true);
1051 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1052 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1054 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1055 toolbar->addAction(m_buttonSnap);
1056 m_buttonSnap->setCheckable(true);
1057 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1058 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1060 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1061 actionWidget->setMaximumWidth(max);
1062 actionWidget->setMaximumHeight(max - 4);
1064 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1065 actionWidget->setMaximumWidth(max);
1066 actionWidget->setMaximumHeight(max - 4);
1068 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1069 actionWidget->setMaximumWidth(max);
1070 actionWidget->setMaximumHeight(max - 4);
1072 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1073 actionWidget->setMaximumWidth(max);
1074 actionWidget->setMaximumHeight(max - 4);
1076 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1077 actionWidget->setMaximumWidth(max);
1078 actionWidget->setMaximumHeight(max - 4);
1080 m_messageLabel = new StatusBarMessageLabel(this);
1081 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1083 statusBar()->addWidget(m_messageLabel, 10);
1084 statusBar()->addWidget(m_statusProgressBar, 0);
1085 statusBar()->addPermanentWidget(toolbar);
1086 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1087 statusBar()->addPermanentWidget(m_timecodeFormat);
1088 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1090 collection->addAction("normal_mode", m_normalEditTool);
1091 collection->addAction("overwrite_mode", m_overwriteEditTool);
1092 collection->addAction("insert_mode", m_insertEditTool);
1093 collection->addAction("select_tool", m_buttonSelectTool);
1094 collection->addAction("razor_tool", m_buttonRazorTool);
1095 collection->addAction("spacer_tool", m_buttonSpacerTool);
1097 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1098 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1099 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1100 collection->addAction("show_markers", m_buttonShowMarkers);
1101 collection->addAction("snap", m_buttonSnap);
1102 collection->addAction("zoom_fit", m_buttonFitZoom);
1103 collection->addAction("zoom_in", m_zoomIn);
1104 collection->addAction("zoom_out", m_zoomOut);
1106 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1107 collection->addAction("project_find", m_projectSearch);
1108 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1109 m_projectSearch->setShortcut(Qt::Key_Slash);
1111 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1112 collection->addAction("project_find_next", m_projectSearchNext);
1113 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1114 m_projectSearchNext->setShortcut(Qt::Key_F3);
1115 m_projectSearchNext->setEnabled(false);
1117 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1118 collection->addAction("manage_profiles", profilesAction);
1119 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1121 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1122 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1123 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1124 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1126 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1127 collection->addAction("run_wizard", wizAction);
1128 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1130 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1131 collection->addAction("project_settings", projectAction);
1132 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1134 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1135 collection->addAction("project_render", projectRender);
1136 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1137 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1139 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1140 collection->addAction("project_clean", projectClean);
1141 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1143 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1144 collection->addAction("project_adjust_profile", projectAdjust);
1145 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1147 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1148 KShortcut playShortcut;
1149 playShortcut.setPrimary(Qt::Key_Space);
1150 playShortcut.setAlternate(Qt::Key_K);
1151 monitorPlay->setShortcut(playShortcut);
1152 collection->addAction("monitor_play", monitorPlay);
1153 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1155 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1156 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1157 collection->addAction("monitor_play_zone", m_playZone);
1158 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1160 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1161 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1162 collection->addAction("monitor_loop_zone", m_loopZone);
1163 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1165 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1166 m_loopClip->setEnabled(false);
1167 collection->addAction("monitor_loop_clip", m_loopClip);
1168 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1170 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1171 collection->addAction("dvd_wizard", dvdWizard);
1172 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1174 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1175 collection->addAction("transcode_clip", transcodeClip);
1176 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1178 KAction *markIn = collection->addAction("mark_in");
1179 markIn->setText(i18n("Set Zone In"));
1180 markIn->setShortcut(Qt::Key_I);
1181 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1183 KAction *markOut = collection->addAction("mark_out");
1184 markOut->setText(i18n("Set Zone Out"));
1185 markOut->setShortcut(Qt::Key_O);
1186 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1188 KAction *switchMon = collection->addAction("switch_monitor");
1189 switchMon->setText(i18n("Switch monitor"));
1190 switchMon->setShortcut(Qt::Key_T);
1191 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1193 KAction *fullMon = collection->addAction("monitor_fullscreen");
1194 fullMon->setText(i18n("Switch monitor fullscreen"));
1195 fullMon->setIcon(KIcon("view-fullscreen"));
1196 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1198 KAction *insertTree = collection->addAction("insert_project_tree");
1199 insertTree->setText(i18n("Insert zone in project tree"));
1200 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1201 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1203 KAction *insertTimeline = collection->addAction("insert_timeline");
1204 insertTimeline->setText(i18n("Insert zone in timeline"));
1205 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1206 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1208 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1209 collection->addAction("resize_timeline_clip_start", resizeStart);
1210 resizeStart->setShortcut(Qt::Key_1);
1211 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1213 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1214 collection->addAction("resize_timeline_clip_end", resizeEnd);
1215 resizeEnd->setShortcut(Qt::Key_2);
1216 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1218 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1219 monitorSeekBackward->setShortcut(Qt::Key_J);
1220 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1221 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1223 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1224 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1225 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1226 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1228 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1229 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1230 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1231 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1233 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1234 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1235 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1236 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1238 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1239 monitorSeekForward->setShortcut(Qt::Key_L);
1240 collection->addAction("monitor_seek_forward", monitorSeekForward);
1241 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1243 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1244 clipStart->setShortcut(Qt::Key_Home);
1245 collection->addAction("seek_clip_start", clipStart);
1246 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1248 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1249 clipEnd->setShortcut(Qt::Key_End);
1250 collection->addAction("seek_clip_end", clipEnd);
1251 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1253 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1254 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1255 collection->addAction("seek_zone_start", zoneStart);
1256 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1258 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1259 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1260 collection->addAction("seek_zone_end", zoneEnd);
1261 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1263 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1264 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1265 collection->addAction("seek_start", projectStart);
1266 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1268 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1269 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1270 collection->addAction("seek_end", projectEnd);
1271 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1273 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1274 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1275 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1276 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1278 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1279 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1280 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1281 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1283 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1284 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1285 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1286 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1288 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1289 deleteItem->setShortcut(Qt::Key_Delete);
1290 collection->addAction("delete_timeline_clip", deleteItem);
1291 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1293 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1294 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1295 editTimelineClipSpeed->setData("change_speed");
1296 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1298 KAction *stickTransition = collection->addAction("auto_transition");
1299 stickTransition->setData(QString("auto"));
1300 stickTransition->setCheckable(true);
1301 stickTransition->setEnabled(false);
1302 stickTransition->setText(i18n("Automatic Transition"));
1303 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1305 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1306 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1307 collection->addAction("group_clip", groupClip);
1308 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1310 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1311 collection->addAction("ungroup_clip", ungroupClip);
1312 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1313 ungroupClip->setData("ungroup_clip");
1314 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1316 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1317 collection->addAction("edit_item_duration", editItemDuration);
1318 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1320 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1321 collection->addAction("clip_in_project_tree", clipInProjectTree);
1322 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1324 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1325 collection->addAction("clip_to_project_tree", clipToProjectTree);
1326 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1328 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1329 insertOvertwrite->setShortcut(Qt::Key_V);
1330 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1331 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1333 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1334 selectTimelineClip->setShortcut(Qt::Key_Plus);
1335 collection->addAction("select_timeline_clip", selectTimelineClip);
1336 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1338 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1339 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1340 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1341 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1343 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1344 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1345 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1346 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1348 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1349 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1350 collection->addAction("select_timeline_transition", selectTimelineTransition);
1351 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1353 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1354 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1355 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1356 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1358 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1359 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1360 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1361 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1363 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1364 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1365 collection->addAction("cut_timeline_clip", cutTimelineClip);
1366 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1368 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1369 collection->addAction("add_clip_marker", addClipMarker);
1370 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1372 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1373 collection->addAction("delete_clip_marker", deleteClipMarker);
1374 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1376 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1377 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1378 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1380 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1381 collection->addAction("edit_clip_marker", editClipMarker);
1382 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1384 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1385 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1386 collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1387 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1389 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1390 collection->addAction("split_audio", splitAudio);
1391 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1393 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1394 collection->addAction("clip_audio_only", audioOnly);
1395 audioOnly->setData("clip_audio_only");
1396 audioOnly->setCheckable(true);
1398 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1399 collection->addAction("clip_video_only", videoOnly);
1400 videoOnly->setData("clip_video_only");
1401 videoOnly->setCheckable(true);
1403 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1404 collection->addAction("clip_audio_and_video", audioAndVideo);
1405 audioAndVideo->setData("clip_audio_and_video");
1406 audioAndVideo->setCheckable(true);
1408 m_clipTypeGroup = new QActionGroup(this);
1409 m_clipTypeGroup->addAction(audioOnly);
1410 m_clipTypeGroup->addAction(videoOnly);
1411 m_clipTypeGroup->addAction(audioAndVideo);
1412 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1413 m_clipTypeGroup->setEnabled(false);
1415 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1416 collection->addAction("insert_space", insertSpace);
1417 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1419 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1420 collection->addAction("delete_space", removeSpace);
1421 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1423 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1424 collection->addAction("insert_track", insertTrack);
1425 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1427 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1428 collection->addAction("delete_track", deleteTrack);
1429 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1431 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1432 collection->addAction("config_tracks", configTracks);
1433 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1435 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1436 collection->addAction("add_guide", addGuide);
1437 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1439 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1440 collection->addAction("delete_guide", delGuide);
1441 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1443 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1444 collection->addAction("edit_guide", editGuide);
1445 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1447 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1448 collection->addAction("delete_all_guides", delAllGuides);
1449 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1451 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1452 collection->addAction("paste_effects", pasteEffects);
1453 pasteEffects->setData("paste_effects");
1454 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1456 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1457 collection->addAction("show_timeline", showTimeline);
1458 showTimeline->setCheckable(true);
1459 showTimeline->setChecked(true);
1460 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1462 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1463 collection->addAction("show_titlebars", showTitleBar);
1464 showTitleBar->setCheckable(true);
1465 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1466 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1467 slotShowTitleBars(KdenliveSettings::showtitlebars());
1470 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1472 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1473 collection->addAction("maximize_current", maxCurrent);
1474 maxCurrent->setCheckable(true);
1475 maxCurrent->setChecked(false);
1476 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1478 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1479 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1480 KStandardAction::open(this, SLOT(openFile()), collection);
1481 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1482 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1483 KStandardAction::openNew(this, SLOT(newFile()), collection);
1484 // TODO: make the following connection to slotEditKeys work
1485 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1486 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1487 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1488 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1489 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1490 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1492 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1493 undo->setEnabled(false);
1494 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1496 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1497 redo->setEnabled(false);
1498 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1501 //TODO: Add status tooltip to actions ?
1502 connect(collection, SIGNAL(actionHovered(QAction*)),
1503 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1506 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1507 collection->addAction("add_clip", addClip);
1508 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1510 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1511 collection->addAction("add_color_clip", addColorClip);
1512 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1514 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1515 collection->addAction("add_slide_clip", addSlideClip);
1516 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1518 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1519 collection->addAction("add_text_clip", addTitleClip);
1520 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1522 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1523 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1524 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1526 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1527 collection->addAction("add_folder", addFolderButton);
1528 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1530 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1531 collection->addAction("clip_properties", clipProperties);
1532 clipProperties->setData("clip_properties");
1533 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1534 clipProperties->setEnabled(false);
1536 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1537 collection->addAction("edit_clip", openClip);
1538 openClip->setData("edit_clip");
1539 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1540 openClip->setEnabled(false);
1542 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1543 collection->addAction("delete_clip", deleteClip);
1544 deleteClip->setData("delete_clip");
1545 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1546 deleteClip->setEnabled(false);
1548 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1549 collection->addAction("reload_clip", reloadClip);
1550 reloadClip->setData("reload_clip");
1551 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1552 reloadClip->setEnabled(false);
1554 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1555 collection->addAction("stopmotion", stopMotion);
1556 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1558 QMenu *addClips = new QMenu();
1559 addClips->addAction(addClip);
1560 addClips->addAction(addColorClip);
1561 addClips->addAction(addSlideClip);
1562 addClips->addAction(addTitleClip);
1563 addClips->addAction(addTitleTemplateClip);
1564 addClips->addAction(addFolderButton);
1566 addClips->addAction(reloadClip);
1567 addClips->addAction(clipProperties);
1568 addClips->addAction(openClip);
1569 addClips->addAction(deleteClip);
1570 m_projectList->setupMenu(addClips, addClip);
1572 // Setup effects and transitions actions.
1573 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1574 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1575 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1576 m_videoEffects = new KAction*[videoEffects.count()];
1577 for (int i = 0; i < videoEffects.count(); ++i) {
1578 QStringList effectInfo = videoEffects.effectIdInfo(i);
1579 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1580 m_videoEffects[i]->setData(effectInfo);
1581 m_videoEffects[i]->setIconVisibleInMenu(false);
1582 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1584 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1585 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1586 m_audioEffects = new KAction*[audioEffects.count()];
1587 for (int i = 0; i < audioEffects.count(); ++i) {
1588 QStringList effectInfo = audioEffects.effectIdInfo(i);
1589 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1590 m_audioEffects[i]->setData(effectInfo);
1591 m_audioEffects[i]->setIconVisibleInMenu(false);
1592 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1594 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1595 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1596 m_customEffects = new KAction*[customEffects.count()];
1597 for (int i = 0; i < customEffects.count(); ++i) {
1598 QStringList effectInfo = customEffects.effectIdInfo(i);
1599 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1600 m_customEffects[i]->setData(effectInfo);
1601 m_customEffects[i]->setIconVisibleInMenu(false);
1602 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1604 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1605 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1606 m_transitions = new KAction*[transitions.count()];
1607 for (int i = 0; i < transitions.count(); i++) {
1608 QStringList effectInfo = transitions.effectIdInfo(i);
1609 m_transitions[i] = new KAction(effectInfo.at(0), this);
1610 m_transitions[i]->setData(effectInfo);
1611 m_transitions[i]->setIconVisibleInMenu(false);
1612 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1614 m_effectsActionCollection->readSettings();
1616 //connect(collection, SIGNAL( clearStatusText() ),
1617 //statusBar(), SLOT( clear() ) );
1620 void MainWindow::slotDisplayActionMessage(QAction *a)
1622 statusBar()->showMessage(a->data().toString(), 3000);
1625 void MainWindow::loadLayouts()
1627 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1628 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1629 if (loadLayout == NULL || saveLayout == NULL) return;
1630 KSharedConfigPtr config = KGlobal::config();
1631 KConfigGroup layoutGroup(config, "Layouts");
1632 QStringList entries = layoutGroup.keyList();
1633 QList<QAction *> loadActions = loadLayout->actions();
1634 QList<QAction *> saveActions = saveLayout->actions();
1635 for (int i = 1; i < 5; i++) {
1636 // Rename the layouts actions
1637 foreach(const QString & key, entries) {
1638 if (key.endsWith(QString("_%1").arg(i))) {
1639 // Found previously saved layout
1640 QString layoutName = key.section("_", 0, -2);
1641 for (int j = 0; j < loadActions.count(); j++) {
1642 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1643 loadActions[j]->setText(layoutName);
1644 loadActions[j]->setData(key);
1648 for (int j = 0; j < saveActions.count(); j++) {
1649 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1650 saveActions[j]->setText(layoutName);
1651 saveActions[j]->setData(key);
1660 void MainWindow::slotLoadLayout(QAction *action)
1662 if (!action) return;
1663 QString layoutId = action->data().toString();
1664 if (layoutId.isEmpty()) return;
1665 KSharedConfigPtr config = KGlobal::config();
1666 KConfigGroup layouts(config, "Layouts");
1667 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1668 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1669 //restoreGeometry(geom);
1670 restoreState(state);
1673 void MainWindow::slotSaveLayout(QAction *action)
1675 QString originallayoutName = action->data().toString();
1676 int layoutId = originallayoutName.section('_', -1).toInt();
1678 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1679 if (layoutName.isEmpty()) return;
1680 KSharedConfigPtr config = KGlobal::config();
1681 KConfigGroup layouts(config, "Layouts");
1682 layouts.deleteEntry(originallayoutName);
1684 QByteArray st = saveState();
1685 layoutName.append("_" + QString::number(layoutId));
1686 layouts.writeEntry(layoutName, st.toBase64());
1690 void MainWindow::saveOptions()
1692 KdenliveSettings::self()->writeConfig();
1693 KSharedConfigPtr config = KGlobal::config();
1694 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1695 KConfigGroup treecolumns(config, "Project Tree");
1696 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1700 void MainWindow::readOptions()
1702 KSharedConfigPtr config = KGlobal::config();
1703 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1704 KConfigGroup initialGroup(config, "version");
1705 bool upgrade = false;
1706 if (initialGroup.exists()) {
1707 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1711 if (initialGroup.readEntry("version") == "0.7") {
1712 //Add new settings from 0.7.1
1713 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1714 QString path = QDir::homePath() + "/kdenlive";
1715 if (KStandardDirs::makeDir(path) == false) {
1716 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1717 } else KdenliveSettings::setDefaultprojectfolder(path);
1723 if (!initialGroup.exists() || upgrade) {
1724 // this is our first run, show Wizard
1725 Wizard *w = new Wizard(upgrade, this);
1726 if (w->exec() == QDialog::Accepted && w->isOk()) {
1727 w->adjustSettings();
1728 initialGroup.writeEntry("version", version);
1734 KConfigGroup treecolumns(config, "Project Tree");
1735 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1736 if (!state.isEmpty())
1737 m_projectList->setHeaderInfo(state);
1740 void MainWindow::slotRunWizard()
1742 Wizard *w = new Wizard(false, this);
1743 if (w->exec() == QDialog::Accepted && w->isOk()) {
1744 w->adjustSettings();
1749 void MainWindow::newFile(bool showProjectSettings, bool force)
1751 if (!m_timelineArea->isEnabled() && !force)
1753 m_fileRevert->setEnabled(false);
1754 QString profileName = KdenliveSettings::default_profile();
1755 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1756 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1757 if (!showProjectSettings) {
1758 if (!KdenliveSettings::activatetabs())
1759 if (!closeCurrentDocument())
1762 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1763 if (w->exec() != QDialog::Accepted)
1765 if (!KdenliveSettings::activatetabs())
1766 if (!closeCurrentDocument())
1768 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1769 slotSwitchVideoThumbs();
1770 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1771 slotSwitchAudioThumbs();
1772 profileName = w->selectedProfile();
1773 projectFolder = w->selectedFolder();
1774 projectTracks = w->tracks();
1777 m_timelineArea->setEnabled(true);
1778 m_projectList->setEnabled(true);
1779 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1780 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1782 TrackView *trackView = new TrackView(doc, &ok, this);
1783 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1786 //m_timelineArea->setEnabled(false);
1787 //m_projectList->setEnabled(false);
1791 if (m_timelineArea->count() == 1) {
1792 connectDocumentInfo(doc);
1793 connectDocument(trackView, doc);
1795 m_timelineArea->setTabBarHidden(false);
1796 m_monitorManager->activateMonitor("clip");
1797 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1800 void MainWindow::activateDocument()
1802 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1803 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1804 KdenliveDoc *currentDoc = currentTab->document();
1805 connectDocumentInfo(currentDoc);
1806 connectDocument(currentTab, currentDoc);
1809 bool MainWindow::closeCurrentDocument(bool saveChanges)
1811 QWidget *w = m_timelineArea->currentWidget();
1812 if (!w) return true;
1813 // closing current document
1814 int ix = m_timelineArea->currentIndex() + 1;
1815 if (ix == m_timelineArea->count()) ix = 0;
1816 m_timelineArea->setCurrentIndex(ix);
1817 TrackView *tabToClose = (TrackView *) w;
1818 KdenliveDoc *docToClose = tabToClose->document();
1819 if (docToClose && docToClose->isModified() && saveChanges) {
1821 if (m_activeDocument->url().fileName().isEmpty())
1822 message = i18n("Save changes to document?");
1824 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1825 switch (KMessageBox::warningYesNoCancel(this, message)) {
1826 case KMessageBox::Yes :
1827 // save document here. If saving fails, return false;
1828 if (saveFile() == false) return false;
1830 case KMessageBox::Cancel :
1837 m_clipMonitor->slotSetXml(NULL);
1838 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1839 if (m_timelineArea->count() == 1) {
1840 m_timelineArea->setTabBarHidden(true);
1841 m_closeAction->setEnabled(false);
1843 if (docToClose == m_activeDocument) {
1844 delete m_activeDocument;
1845 m_activeDocument = NULL;
1846 m_effectStack->clear();
1847 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1851 if (w == m_activeTimeline) {
1852 delete m_activeTimeline;
1853 m_activeTimeline = NULL;
1860 bool MainWindow::saveFileAs(const QString &outputFileName)
1862 QString currentSceneList;
1863 m_monitorManager->stopActiveMonitor();
1864 if (KdenliveSettings::dropbframes()) {
1865 KdenliveSettings::setDropbframes(false);
1866 m_activeDocument->clipManager()->updatePreviewSettings();
1867 currentSceneList = m_projectMonitor->sceneList();
1868 KdenliveSettings::setDropbframes(true);
1869 m_activeDocument->clipManager()->updatePreviewSettings();
1870 } else currentSceneList = m_projectMonitor->sceneList();
1872 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1875 // Save timeline thumbnails
1876 m_activeTimeline->projectView()->saveThumbnails();
1877 m_activeDocument->setUrl(KUrl(outputFileName));
1878 if (m_activeDocument->m_autosave == NULL) {
1879 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1880 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1881 setCaption(m_activeDocument->description());
1882 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1883 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1884 m_activeDocument->setModified(false);
1885 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1886 m_fileRevert->setEnabled(true);
1890 bool MainWindow::saveFileAs()
1892 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1893 if (outputFile.isEmpty()) {
1896 if (QFile::exists(outputFile)) {
1897 // Show the file dialog again if the user does not want to overwrite the file
1898 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1899 return saveFileAs();
1901 return saveFileAs(outputFile);
1904 bool MainWindow::saveFile()
1906 if (!m_activeDocument) return true;
1907 if (m_activeDocument->url().isEmpty()) {
1908 return saveFileAs();
1910 bool result = saveFileAs(m_activeDocument->url().path());
1911 m_activeDocument->m_autosave->resize(0);
1916 void MainWindow::openFile()
1918 if (!m_startUrl.isEmpty()) {
1919 openFile(m_startUrl);
1920 m_startUrl = KUrl();
1923 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1924 if (url.isEmpty()) return;
1925 m_fileOpenRecent->addUrl(url);
1929 void MainWindow::openLastFile()
1931 KSharedConfigPtr config = KGlobal::config();
1932 KUrl::List urls = m_fileOpenRecent->urls();
1933 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1934 if (urls.isEmpty()) newFile(false);
1935 else openFile(urls.last());
1938 void MainWindow::openFile(const KUrl &url)
1940 // Check if the document is already opened
1941 const int ct = m_timelineArea->count();
1942 bool isOpened = false;
1944 for (i = 0; i < ct; i++) {
1945 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1946 KdenliveDoc *doc = tab->document();
1947 if (doc->url() == url) {
1953 m_timelineArea->setCurrentIndex(i);
1957 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1959 // Check for backup file
1960 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1961 if (!staleFiles.isEmpty()) {
1962 if (KMessageBox::questionYesNo(this,
1963 i18n("Auto-saved files exist. Do you want to recover them now?"),
1964 i18n("File Recovery"),
1965 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1966 recoverFiles(staleFiles);
1969 // remove the stale files
1970 foreach(KAutoSaveFile * stale, staleFiles) {
1971 stale->open(QIODevice::ReadWrite);
1976 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1977 m_messageLabel->repaint();
1978 doOpenFile(url, NULL);
1981 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1983 if (!m_timelineArea->isEnabled()) return;
1984 m_fileRevert->setEnabled(true);
1986 // Recreate stopmotion widget on document change
1988 delete m_stopmotion;
1989 m_stopmotion = NULL;
1992 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
1993 progressDialog.setAllowCancel(false);
1994 progressDialog.progressBar()->setMaximum(4);
1995 progressDialog.show();
1996 progressDialog.progressBar()->setValue(0);
1997 qApp->processEvents();
1999 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2001 progressDialog.progressBar()->setValue(1);
2002 progressDialog.progressBar()->setMaximum(4);
2003 progressDialog.setLabelText(i18n("Loading project"));
2004 qApp->processEvents();
2006 if (stale == NULL) {
2007 stale = new KAutoSaveFile(url, doc);
2008 doc->m_autosave = stale;
2010 doc->m_autosave = stale;
2011 doc->setUrl(stale->managedFile());
2012 doc->setModified(true);
2013 stale->setParent(doc);
2015 connectDocumentInfo(doc);
2017 progressDialog.progressBar()->setValue(2);
2018 qApp->processEvents();
2021 TrackView *trackView = new TrackView(doc, &ok, this);
2023 progressDialog.progressBar()->setValue(3);
2024 qApp->processEvents();
2026 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2028 m_timelineArea->setEnabled(false);
2029 m_projectList->setEnabled(false);
2030 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2031 slotGotProgressInfo(QString(), -1);
2032 newFile(false, true);
2035 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2036 trackView->setDuration(trackView->duration());
2037 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2039 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2040 slotGotProgressInfo(QString(), -1);
2041 m_projectMonitor->adjustRulerSize(trackView->duration());
2042 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2043 m_clipMonitor->refreshMonitor(true);
2045 progressDialog.progressBar()->setValue(4);
2048 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2050 foreach(KAutoSaveFile * stale, staleFiles) {
2051 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2052 // show an error message; we could not steal the lockfile
2053 // maybe another application got to the file before us?
2057 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2058 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2059 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2060 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2064 void MainWindow::parseProfiles(const QString &mltPath)
2066 //KdenliveSettings::setDefaulttmpfolder();
2067 if (!mltPath.isEmpty()) {
2068 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2069 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2072 if (KdenliveSettings::mltpath().isEmpty())
2073 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2075 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2076 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2077 if (!QFile::exists(meltPath))
2078 meltPath = KStandardDirs::findExe("melt");
2079 KdenliveSettings::setRendererpath(meltPath);
2082 if (KdenliveSettings::rendererpath().isEmpty()) {
2083 // Cannot find the MLT melt renderer, ask for location
2084 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2085 if (getUrl->exec() == QDialog::Rejected) {
2088 KUrl rendererPath = getUrl->selectedUrl();
2090 if (rendererPath.isEmpty()) ::exit(0);
2091 KdenliveSettings::setRendererpath(rendererPath.path());
2094 QStringList profilesFilter;
2095 profilesFilter << "*";
2096 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2097 if (profilesList.isEmpty()) {
2098 // Cannot find MLT path, try finding melt
2099 QString profilePath = KdenliveSettings::rendererpath();
2100 if (!profilePath.isEmpty()) {
2101 profilePath = profilePath.section('/', 0, -3);
2102 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2103 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2105 if (profilesList.isEmpty()) {
2106 // Cannot find the MLT profiles, ask for location
2107 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2108 getUrl->fileDialog()->setMode(KFile::Directory);
2109 if (getUrl->exec() == QDialog::Rejected) {
2112 KUrl mltPath = getUrl->selectedUrl();
2114 if (mltPath.isEmpty()) ::exit(0);
2115 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2116 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2120 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2122 // Parse again MLT profiles to build a list of available video formats
2123 if (profilesList.isEmpty()) parseProfiles();
2127 void MainWindow::slotEditProfiles()
2129 ProfilesDialog *w = new ProfilesDialog;
2130 if (w->exec() == QDialog::Accepted) {
2131 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2132 if (d) d->checkProfile();
2137 void MainWindow::slotDetectAudioDriver()
2139 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2140 leading to no audio output, see bug #934 */
2142 //decide which audio driver is really best, in some cases SDL is wrong
2143 if (KdenliveSettings::audiodrivername().isEmpty()) {
2145 KProcess readProcess;
2146 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2147 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2148 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2149 readProcess.setProgram("pactl", QStringList() << "stat");
2150 readProcess.execute(2000); // Kill it after 2 seconds
2152 QString result = QString(readProcess.readAllStandardOutput());
2153 kDebug() << "// / / / / / READING PACTL: ";
2155 if (!result.isEmpty()) {
2157 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2161 KdenliveSettings::setAutoaudiodrivername(driver);
2165 void MainWindow::slotEditProjectSettings()
2167 QPoint p = m_activeDocument->getTracksCount();
2168 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2170 if (w->exec() == QDialog::Accepted) {
2171 QString profile = w->selectedProfile();
2172 m_activeDocument->setProjectFolder(w->selectedFolder());
2174 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2176 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2177 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2178 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2179 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2184 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2186 double dar = m_activeDocument->dar();
2188 // Recreate the stopmotion widget if profile changes
2190 delete m_stopmotion;
2191 m_stopmotion = NULL;
2194 // Deselect current effect / transition
2195 m_effectStack->slotClipItemSelected(NULL, 0);
2196 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2197 m_clipMonitor->slotSetXml(NULL);
2198 bool updateFps = m_activeDocument->setProfilePath(profile);
2199 KdenliveSettings::setCurrent_profile(profile);
2200 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2201 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2203 m_activeDocument->clipManager()->clearUnusedProducers();
2204 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2205 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2206 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2207 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2208 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2209 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2210 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2211 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2212 if (updateFps) m_activeTimeline->updateProjectFps();
2213 m_activeDocument->setModified(true);
2214 m_commandStack->activeStack()->clear();
2215 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2216 slotUpdateMousePosition(0);
2217 // We need to desactivate & reactivate monitors to get a refresh
2218 //m_monitorManager->switchMonitors();
2222 void MainWindow::slotRenderProject()
2224 if (!m_renderWidget) {
2225 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2226 m_renderWidget = new RenderWidget(projectfolder, this);
2227 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2228 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2229 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2230 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2231 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2232 if (m_activeDocument) {
2233 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2234 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2235 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2236 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2239 slotCheckRenderStatus();
2240 m_renderWidget->show();
2241 m_renderWidget->showNormal();
2243 // What are the following lines supposed to do?
2244 //m_activeTimeline->tracksNumber();
2245 //m_renderWidget->enableAudio(false);
2246 //m_renderWidget->export_audio;
2249 void MainWindow::slotCheckRenderStatus()
2251 // Make sure there are no missing clips
2253 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2256 void MainWindow::setRenderingProgress(const QString &url, int progress)
2259 m_renderWidget->setRenderJob(url, progress);
2262 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2265 m_renderWidget->setRenderStatus(url, status, error);
2268 void MainWindow::slotCleanProject()
2270 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2271 m_projectList->cleanup();
2274 void MainWindow::slotUpdateMousePosition(int pos)
2276 if (m_activeDocument)
2277 switch (m_timecodeFormat->currentIndex()) {
2279 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2282 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2286 void MainWindow::slotUpdateDocumentState(bool modified)
2288 if (!m_activeDocument) return;
2289 setCaption(m_activeDocument->description(), modified);
2290 m_saveAction->setEnabled(modified);
2292 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2293 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2295 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2296 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2300 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2302 if (m_activeDocument) {
2303 if (m_activeDocument == doc) return;
2304 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2306 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2309 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2311 //m_projectMonitor->stop();
2312 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2313 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2314 if (m_activeDocument) {
2315 if (m_activeDocument == doc) return;
2316 if (m_activeTimeline) {
2317 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2318 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2319 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2320 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2321 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2322 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2323 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2324 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2326 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2328 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2329 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2330 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2331 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2332 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2333 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2334 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2335 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2336 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2337 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2338 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2339 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2340 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2341 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2342 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2343 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2344 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2345 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2346 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2347 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2348 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2349 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2350 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2351 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2352 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2353 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2354 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2355 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2356 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2357 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2358 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2359 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2360 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2361 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2362 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2363 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2364 m_effectStack->clear();
2366 //m_activeDocument->setRenderer(NULL);
2367 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2368 disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2369 m_clipMonitor->stop();
2371 KdenliveSettings::setCurrent_profile(doc->profilePath());
2372 KdenliveSettings::setProject_fps(doc->fps());
2373 m_monitorManager->resetProfiles(doc->timecode());
2374 m_projectList->setDocument(doc);
2375 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2376 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2377 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2378 connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2379 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2381 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2382 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2383 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2385 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2388 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2389 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2390 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2391 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2392 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2393 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2394 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2395 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2396 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2397 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2398 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2399 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2400 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2401 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2403 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2404 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2405 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2406 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2407 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2409 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2410 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2411 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2412 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2414 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2415 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2416 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2417 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2419 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2420 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2421 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2422 m_zoomSlider->setValue(doc->zoom().x());
2423 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2424 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2425 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2426 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2428 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2429 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2431 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2432 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2434 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2435 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2436 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2437 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2438 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2439 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2440 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2441 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2442 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2443 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2444 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2446 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2447 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2448 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2449 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2450 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2453 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2454 m_activeTimeline = trackView;
2455 if (m_renderWidget) {
2456 slotCheckRenderStatus();
2457 m_renderWidget->setProfile(doc->mltProfile());
2458 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2459 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2460 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2462 //doc->setRenderer(m_projectMonitor->render);
2463 m_commandStack->setActiveStack(doc->commandStack());
2464 KdenliveSettings::setProject_display_ratio(doc->dar());
2465 //doc->clipManager()->checkAudioThumbs();
2467 //m_overView->setScene(trackView->projectScene());
2468 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2469 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2471 setCaption(doc->description(), doc->isModified());
2472 m_saveAction->setEnabled(doc->isModified());
2473 m_normalEditTool->setChecked(true);
2474 m_activeDocument = doc;
2475 m_activeTimeline->updateProjectFps();
2476 m_activeDocument->checkProjectClips();
2478 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2480 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2481 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2482 slotUpdateMousePosition(0);
2483 // set tool to select tool
2484 m_buttonSelectTool->setChecked(true);
2487 void MainWindow::slotZoneMoved(int start, int end)
2489 m_activeDocument->setZone(start, end);
2490 m_projectMonitor->slotZoneMoved(start, end);
2493 void MainWindow::slotGuidesUpdated()
2496 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2499 void MainWindow::slotEditKeys()
2501 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2502 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2503 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2507 void MainWindow::slotPreferences(int page, int option)
2510 * An instance of your dialog could be already created and could be
2511 * cached, in which case you want to display the cached dialog
2512 * instead of creating another one
2514 if (m_stopmotion) m_stopmotion->slotLive(false);
2515 if (KConfigDialog::showDialog("settings")) {
2516 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2517 if (page != -1) d->showPage(page, option);
2521 // KConfigDialog didn't find an instance of this dialog, so lets
2523 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2524 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2525 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2526 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2527 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2529 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2531 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2533 if (page != -1) dialog->showPage(page, option);
2536 void MainWindow::slotUpdateCaptureFolder()
2540 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2541 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2545 void MainWindow::slotUpdatePreviewSettings()
2547 if (m_activeDocument) {
2548 m_clipMonitor->slotSetXml(NULL);
2549 m_activeDocument->updatePreviewSettings();
2553 void MainWindow::updateConfiguration()
2555 //TODO: we should apply settings to all projects, not only the current one
2556 if (m_activeTimeline) {
2557 m_activeTimeline->refresh();
2558 m_activeTimeline->projectView()->checkAutoScroll();
2559 m_activeTimeline->projectView()->checkTrackHeight();
2560 if (m_activeDocument)
2561 m_activeDocument->clipManager()->checkAudioThumbs();
2563 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2564 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2565 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2566 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2568 // Update list of transcoding profiles
2570 #ifndef NO_JOGSHUTTLE
2571 activateShuttleDevice();
2572 #endif /* NO_JOGSHUTTLE */
2576 void MainWindow::slotSwitchSplitAudio()
2578 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2579 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2582 void MainWindow::slotSwitchVideoThumbs()
2584 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2585 if (m_activeTimeline)
2586 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2587 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2590 void MainWindow::slotSwitchAudioThumbs()
2592 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2593 if (m_activeTimeline) {
2594 m_activeTimeline->refresh();
2595 m_activeTimeline->projectView()->checkAutoScroll();
2596 if (m_activeDocument)
2597 m_activeDocument->clipManager()->checkAudioThumbs();
2599 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2602 void MainWindow::slotSwitchMarkersComments()
2604 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2605 if (m_activeTimeline)
2606 m_activeTimeline->refresh();
2607 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2610 void MainWindow::slotSwitchSnap()
2612 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2613 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2617 void MainWindow::slotDeleteItem()
2619 if (QApplication::focusWidget() &&
2620 QApplication::focusWidget()->parentWidget() &&
2621 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2622 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2623 m_projectList->slotRemoveClip();
2626 QWidget *widget = QApplication::focusWidget();
2628 if (widget == m_effectStackDock) {
2629 m_effectStack->slotItemDel();
2632 widget = widget->parentWidget();
2635 // effect stack has no focus
2636 if (m_activeTimeline)
2637 m_activeTimeline->projectView()->deleteSelectedClips();
2641 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2643 if (m_clipMonitor->isActive())
2644 m_clipMonitor->checkOverlay();
2645 m_clipMonitor->updateMarkers(clip);
2648 void MainWindow::slotAddClipMarker()
2650 DocClipBase *clip = NULL;
2652 if (m_projectMonitor->isActive()) {
2653 if (m_activeTimeline) {
2654 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2656 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2657 clip = item->baseClip();
2661 clip = m_clipMonitor->activeClip();
2662 pos = m_clipMonitor->position();
2665 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2668 QString id = clip->getId();
2669 CommentedTime marker(pos, i18n("Marker"));
2670 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2671 if (d.exec() == QDialog::Accepted)
2672 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2675 void MainWindow::slotDeleteClipMarker()
2677 DocClipBase *clip = NULL;
2679 if (m_projectMonitor->isActive()) {
2680 if (m_activeTimeline) {
2681 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2683 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2684 clip = item->baseClip();
2688 clip = m_clipMonitor->activeClip();
2689 pos = m_clipMonitor->position();
2692 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2696 QString id = clip->getId();
2697 QString comment = clip->markerComment(pos);
2698 if (comment.isEmpty()) {
2699 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2702 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2705 void MainWindow::slotDeleteAllClipMarkers()
2707 DocClipBase *clip = NULL;
2708 if (m_projectMonitor->isActive()) {
2709 if (m_activeTimeline) {
2710 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2712 clip = item->baseClip();
2716 clip = m_clipMonitor->activeClip();
2719 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2722 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2725 void MainWindow::slotEditClipMarker()
2727 DocClipBase *clip = NULL;
2729 if (m_projectMonitor->isActive()) {
2730 if (m_activeTimeline) {
2731 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2733 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2734 clip = item->baseClip();
2738 clip = m_clipMonitor->activeClip();
2739 pos = m_clipMonitor->position();
2742 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2746 QString id = clip->getId();
2747 QString oldcomment = clip->markerComment(pos);
2748 if (oldcomment.isEmpty()) {
2749 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2753 CommentedTime marker(pos, oldcomment);
2754 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2755 if (d.exec() == QDialog::Accepted) {
2756 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2757 if (d.newMarker().time() != pos) {
2758 // remove old marker
2759 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2764 void MainWindow::slotAddMarkerGuideQuickly()
2766 if (!m_activeTimeline || !m_activeDocument)
2769 if (m_clipMonitor->isActive()) {
2770 DocClipBase *clip = m_clipMonitor->activeClip();
2771 GenTime pos = m_clipMonitor->position();
2774 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2778 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2780 m_activeTimeline->projectView()->slotAddGuide(false);
2784 void MainWindow::slotAddGuide()
2786 if (m_activeTimeline)
2787 m_activeTimeline->projectView()->slotAddGuide();
2790 void MainWindow::slotInsertSpace()
2792 if (m_activeTimeline)
2793 m_activeTimeline->projectView()->slotInsertSpace();
2796 void MainWindow::slotRemoveSpace()
2798 if (m_activeTimeline)
2799 m_activeTimeline->projectView()->slotRemoveSpace();
2802 void MainWindow::slotInsertTrack(int ix)
2804 m_projectMonitor->activateMonitor();
2805 if (m_activeTimeline)
2806 m_activeTimeline->projectView()->slotInsertTrack(ix);
2807 if (m_activeDocument)
2808 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2811 void MainWindow::slotDeleteTrack(int ix)
2813 m_projectMonitor->activateMonitor();
2814 if (m_activeTimeline)
2815 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2816 if (m_activeDocument)
2817 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2820 void MainWindow::slotConfigTrack(int ix)
2822 m_projectMonitor->activateMonitor();
2823 if (m_activeTimeline)
2824 m_activeTimeline->projectView()->slotConfigTracks(ix);
2825 if (m_activeDocument)
2826 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2829 void MainWindow::slotEditGuide()
2831 if (m_activeTimeline)
2832 m_activeTimeline->projectView()->slotEditGuide();
2835 void MainWindow::slotDeleteGuide()
2837 if (m_activeTimeline)
2838 m_activeTimeline->projectView()->slotDeleteGuide();
2841 void MainWindow::slotDeleteAllGuides()
2843 if (m_activeTimeline)
2844 m_activeTimeline->projectView()->slotDeleteAllGuides();
2847 void MainWindow::slotCutTimelineClip()
2849 if (m_activeTimeline)
2850 m_activeTimeline->projectView()->cutSelectedClips();
2853 void MainWindow::slotInsertClipOverwrite()
2855 if (m_activeTimeline) {
2856 QStringList data = m_clipMonitor->getZoneInfo();
2857 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2861 void MainWindow::slotSelectTimelineClip()
2863 if (m_activeTimeline)
2864 m_activeTimeline->projectView()->selectClip(true);
2867 void MainWindow::slotSelectTimelineTransition()
2869 if (m_activeTimeline)
2870 m_activeTimeline->projectView()->selectTransition(true);
2873 void MainWindow::slotDeselectTimelineClip()
2875 if (m_activeTimeline)
2876 m_activeTimeline->projectView()->selectClip(false, true);
2879 void MainWindow::slotDeselectTimelineTransition()
2881 if (m_activeTimeline)
2882 m_activeTimeline->projectView()->selectTransition(false, true);
2885 void MainWindow::slotSelectAddTimelineClip()
2887 if (m_activeTimeline)
2888 m_activeTimeline->projectView()->selectClip(true, true);
2891 void MainWindow::slotSelectAddTimelineTransition()
2893 if (m_activeTimeline)
2894 m_activeTimeline->projectView()->selectTransition(true, true);
2897 void MainWindow::slotGroupClips()
2899 if (m_activeTimeline)
2900 m_activeTimeline->projectView()->groupClips();
2903 void MainWindow::slotUnGroupClips()
2905 if (m_activeTimeline)
2906 m_activeTimeline->projectView()->groupClips(false);
2909 void MainWindow::slotEditItemDuration()
2911 if (m_activeTimeline)
2912 m_activeTimeline->projectView()->editItemDuration();
2915 void MainWindow::slotAddProjectClip(KUrl url)
2917 if (m_activeDocument)
2918 m_activeDocument->slotAddClipFile(url, QString());
2921 void MainWindow::slotAddTransition(QAction *result)
2923 if (!result) return;
2924 QStringList info = result->data().toStringList();
2925 if (info.isEmpty()) return;
2926 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2927 if (m_activeTimeline && !transition.isNull()) {
2928 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2932 void MainWindow::slotAddVideoEffect(QAction *result)
2934 if (!result) return;
2935 QStringList info = result->data().toStringList();
2936 if (info.isEmpty()) return;
2937 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2938 slotAddEffect(effect);
2941 void MainWindow::slotAddAudioEffect(QAction *result)
2943 if (!result) return;
2944 QStringList info = result->data().toStringList();
2945 if (info.isEmpty()) return;
2946 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2947 slotAddEffect(effect);
2950 void MainWindow::slotAddCustomEffect(QAction *result)
2952 if (!result) return;
2953 QStringList info = result->data().toStringList();
2954 if (info.isEmpty()) return;
2955 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2956 slotAddEffect(effect);
2959 void MainWindow::slotZoomIn()
2961 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2962 slotShowZoomSliderToolTip();
2965 void MainWindow::slotZoomOut()
2967 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2968 slotShowZoomSliderToolTip();
2971 void MainWindow::slotFitZoom()
2973 if (m_activeTimeline)
2974 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2977 void MainWindow::slotSetZoom(int value)
2979 value = qMax(m_zoomSlider->minimum(), value);
2980 value = qMin(m_zoomSlider->maximum(), value);
2982 if (m_activeTimeline)
2983 m_activeTimeline->slotChangeZoom(value);
2985 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2986 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2987 slotUpdateZoomSliderToolTip(value);
2989 m_zoomSlider->blockSignals(true);
2990 m_zoomSlider->setValue(value);
2991 m_zoomSlider->blockSignals(false);
2994 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2996 if (zoomlevel != -1)
2997 slotUpdateZoomSliderToolTip(zoomlevel);
2999 QPoint global = m_zoomSlider->rect().topLeft();
3000 global.ry() += m_zoomSlider->height() / 2;
3001 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3002 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3005 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3007 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3010 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3012 m_statusProgressBar->setValue(progress);
3013 if (progress >= 0) {
3014 if (!message.isEmpty())
3015 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3016 m_statusProgressBar->setVisible(true);
3017 } else if (progress == -2) {
3018 if (!message.isEmpty())
3019 m_messageLabel->setMessage(message, ErrorMessage);
3020 m_statusProgressBar->setVisible(false);
3022 m_messageLabel->setMessage(QString(), DefaultMessage);
3023 m_statusProgressBar->setVisible(false);
3027 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3029 if (clip->clipType() == TEXT) {
3030 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3031 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3032 // template text clip
3034 // Get the list of existing templates
3036 filter << "*.kdenlivetitle";
3037 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3039 QDialog *dia = new QDialog(this);
3040 Ui::TemplateClip_UI dia_ui;
3041 dia_ui.setupUi(dia);
3043 const QString templatePath = clip->getProperty("resource");
3044 for (int i = 0; i < templateFiles.size(); ++i) {
3045 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3046 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3048 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3049 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3050 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3051 //warning: setting base directory doesn't work??
3052 KUrl startDir(titlepath);
3053 dia_ui.template_list->fileDialog()->setUrl(startDir);
3054 dia_ui.description->setText(clip->getProperty("description"));
3055 if (dia->exec() == QDialog::Accepted) {
3056 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3057 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3059 QMap <QString, QString> newprops;
3061 if (KUrl(textTemplate).path() != templatePath) {
3062 // The template was changed
3063 newprops.insert("resource", textTemplate);
3066 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3067 newprops.insert("description", dia_ui.description->toPlainText());
3070 QString newtemplate = newprops.value("xmltemplate");
3071 if (newtemplate.isEmpty()) newtemplate = templatePath;
3073 // template modified we need to update xmldata
3074 QString description = newprops.value("description");
3075 if (description.isEmpty()) description = clip->getProperty("description");
3076 else newprops.insert("templatetext", description);
3077 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3078 if (!newprops.isEmpty()) {
3079 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3080 m_activeDocument->commandStack()->push(command);
3086 QString path = clip->getProperty("resource");
3087 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3089 doc.setContent(clip->getProperty("xmldata"));
3090 dia_ui->setXml(doc);
3091 if (dia_ui->exec() == QDialog::Accepted) {
3092 QMap <QString, QString> newprops;
3093 newprops.insert("xmldata", dia_ui->xml().toString());
3094 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3095 // duration changed, we need to update duration
3096 newprops.insert("out", QString::number(dia_ui->outPoint()));
3098 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3099 m_activeDocument->commandStack()->push(command);
3100 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3101 m_activeDocument->setModified(true);
3105 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3109 // any type of clip but a title
3110 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3111 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3112 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)));
3117 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3119 if (newprops.isEmpty()) return;
3120 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3121 m_activeDocument->commandStack()->push(command);
3122 m_activeDocument->setModified();
3125 // update clip occurences in timeline
3126 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3131 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3133 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3134 if (dia.exec() == QDialog::Accepted) {
3135 QUndoCommand *command = new QUndoCommand();
3136 command->setText(i18n("Edit clips"));
3137 for (int i = 0; i < cliplist.count(); i++) {
3138 DocClipBase *clip = cliplist.at(i);
3139 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3141 m_activeDocument->commandStack()->push(command);
3142 for (int i = 0; i < cliplist.count(); i++)
3143 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3147 void MainWindow::customEvent(QEvent* e)
3149 if (e->type() == QEvent::User)
3150 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3152 void MainWindow::slotActivateEffectStackView()
3154 m_effectStack->raiseWindow(m_effectStackDock);
3157 void MainWindow::slotActivateTransitionView(Transition *t)
3160 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3163 void MainWindow::slotSnapRewind()
3165 if (m_projectMonitor->isActive()) {
3166 if (m_activeTimeline)
3167 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3169 m_clipMonitor->slotSeekToPreviousSnap();
3173 void MainWindow::slotSnapForward()
3175 if (m_projectMonitor->isActive()) {
3176 if (m_activeTimeline)
3177 m_activeTimeline->projectView()->slotSeekToNextSnap();
3179 m_clipMonitor->slotSeekToNextSnap();
3183 void MainWindow::slotClipStart()
3185 if (m_projectMonitor->isActive()) {
3186 if (m_activeTimeline)
3187 m_activeTimeline->projectView()->clipStart();
3191 void MainWindow::slotClipEnd()
3193 if (m_projectMonitor->isActive()) {
3194 if (m_activeTimeline)
3195 m_activeTimeline->projectView()->clipEnd();
3199 void MainWindow::slotZoneStart()
3201 if (m_projectMonitor->isActive())
3202 m_projectMonitor->slotZoneStart();
3204 m_clipMonitor->slotZoneStart();
3207 void MainWindow::slotZoneEnd()
3209 if (m_projectMonitor->isActive())
3210 m_projectMonitor->slotZoneEnd();
3212 m_clipMonitor->slotZoneEnd();
3215 void MainWindow::slotChangeTool(QAction * action)
3217 if (action == m_buttonSelectTool)
3218 slotSetTool(SELECTTOOL);
3219 else if (action == m_buttonRazorTool)
3220 slotSetTool(RAZORTOOL);
3221 else if (action == m_buttonSpacerTool)
3222 slotSetTool(SPACERTOOL);
3225 void MainWindow::slotChangeEdit(QAction * action)
3227 if (!m_activeTimeline)
3230 if (action == m_overwriteEditTool)
3231 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3232 else if (action == m_insertEditTool)
3233 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3235 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3238 void MainWindow::slotSetTool(PROJECTTOOL tool)
3240 if (m_activeDocument && m_activeTimeline) {
3241 //m_activeDocument->setTool(tool);
3245 message = i18n("Ctrl + click to use spacer on current track only");
3248 message = i18n("Click on a clip to cut it");
3251 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3254 m_messageLabel->setMessage(message, InformationMessage);
3255 m_activeTimeline->projectView()->setTool(tool);
3259 void MainWindow::slotCopy()
3261 if (m_activeDocument && m_activeTimeline)
3262 m_activeTimeline->projectView()->copyClip();
3265 void MainWindow::slotPaste()
3267 if (m_activeDocument && m_activeTimeline)
3268 m_activeTimeline->projectView()->pasteClip();
3271 void MainWindow::slotPasteEffects()
3273 if (m_activeDocument && m_activeTimeline)
3274 m_activeTimeline->projectView()->pasteClipEffects();
3277 void MainWindow::slotFind()
3279 if (!m_activeDocument || !m_activeTimeline) return;
3280 m_projectSearch->setEnabled(false);
3281 m_findActivated = true;
3282 m_findString.clear();
3283 m_activeTimeline->projectView()->initSearchStrings();
3284 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3285 m_findTimer.start(5000);
3286 qApp->installEventFilter(this);
3289 void MainWindow::slotFindNext()
3291 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3292 statusBar()->showMessage(i18n("Found: %1", m_findString));
3294 statusBar()->showMessage(i18n("Reached end of project"));
3295 m_findTimer.start(4000);
3298 void MainWindow::findAhead()
3300 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3301 m_projectSearchNext->setEnabled(true);
3302 statusBar()->showMessage(i18n("Found: %1", m_findString));
3304 m_projectSearchNext->setEnabled(false);
3305 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3309 void MainWindow::findTimeout()
3311 m_projectSearchNext->setEnabled(false);
3312 m_findActivated = false;
3313 m_findString.clear();
3314 statusBar()->showMessage(i18n("Find stopped"), 3000);
3315 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3316 m_projectSearch->setEnabled(true);
3317 removeEventFilter(this);
3320 void MainWindow::slotClipInTimeline(const QString &clipId)
3322 if (m_activeTimeline && m_activeDocument) {
3323 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3325 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3326 inTimelineMenu->clear();
3328 QList <QAction *> actionList;
3330 for (int i = 0; i < matching.count(); ++i) {
3331 QString track = QString::number(matching.at(i).track);
3332 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3334 QAction *a = new QAction(track + ": " + start, this);
3335 a->setData(QStringList() << track << start);
3336 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3337 while (j < actionList.count()) {
3338 if (actionList.at(j)->text() > a->text()) break;
3341 actionList.insert(j, a);
3343 inTimelineMenu->addActions(actionList);
3345 if (matching.empty())
3346 inTimelineMenu->setEnabled(false);
3348 inTimelineMenu->setEnabled(true);
3352 void MainWindow::slotClipInProjectTree()
3354 if (m_activeTimeline) {
3355 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3356 if (clipIds.isEmpty())
3358 m_projectListDock->raise();
3359 for (int i = 0; i < clipIds.count(); i++)
3360 m_projectList->selectItemById(clipIds.at(i));
3361 if (m_projectMonitor->isActive())
3362 slotSwitchMonitors();
3366 /*void MainWindow::slotClipToProjectTree()
3368 if (m_activeTimeline) {
3369 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3370 if (clips.isEmpty()) return;
3371 for (int i = 0; i < clips.count(); i++) {
3372 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3374 //m_projectList->selectItemById(clipIds.at(i));
3378 void MainWindow::slotSelectClipInTimeline()
3380 if (m_activeTimeline) {
3381 QAction *action = qobject_cast<QAction *>(sender());
3382 QStringList data = action->data().toStringList();
3383 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3387 void MainWindow::keyPressEvent(QKeyEvent *ke)
3389 if (m_findActivated) {
3390 if (ke->key() == Qt::Key_Backspace) {
3391 m_findString = m_findString.left(m_findString.length() - 1);
3393 if (!m_findString.isEmpty())
3398 m_findTimer.start(4000);
3401 } else if (ke->key() == Qt::Key_Escape) {
3405 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3406 m_findString += ke->text();
3410 m_findTimer.start(4000);
3415 KXmlGuiWindow::keyPressEvent(ke);
3420 /** Gets called when the window gets hidden */
3421 void MainWindow::hideEvent(QHideEvent */*event*/)
3423 if (isMinimized() && m_monitorManager)
3424 m_monitorManager->stopActiveMonitor();
3427 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3429 if (m_findActivated) {
3430 if (event->type() == QEvent::ShortcutOverride) {
3431 QKeyEvent* ke = (QKeyEvent*) event;
3432 if (ke->text().trimmed().isEmpty()) return false;
3439 // pass the event on to the parent class
3440 return QMainWindow::eventFilter(obj, event);
3445 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3447 KDialog *dialog = new KDialog(this);
3448 dialog->setCaption("Save clip zone");
3449 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3451 QWidget *widget = new QWidget(dialog);
3452 dialog->setMainWidget(widget);
3454 QVBoxLayout *vbox = new QVBoxLayout(widget);
3455 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3456 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3457 path.append("untitled.mlt");
3458 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3459 url->setFilter("video/mlt-playlist");
3460 QLabel *label2 = new QLabel(i18n("Description:"), this);
3461 KLineEdit *edit = new KLineEdit(this);
3462 vbox->addWidget(label1);
3463 vbox->addWidget(url);
3464 vbox->addWidget(label2);
3465 vbox->addWidget(edit);
3466 if (dialog->exec() == QDialog::Accepted)
3467 render->saveZone(url->url(), edit->text(), zone);
3471 void MainWindow::slotSetInPoint()
3473 if (m_clipMonitor->isActive())
3474 m_clipMonitor->slotSetZoneStart();
3476 m_projectMonitor->slotSetZoneStart();
3477 //else m_activeTimeline->projectView()->setInPoint();
3480 void MainWindow::slotSetOutPoint()
3482 if (m_clipMonitor->isActive())
3483 m_clipMonitor->slotSetZoneEnd();
3485 m_projectMonitor->slotSetZoneEnd();
3486 // else m_activeTimeline->projectView()->setOutPoint();
3489 void MainWindow::slotResizeItemStart()
3491 if (m_activeTimeline)
3492 m_activeTimeline->projectView()->setInPoint();
3495 void MainWindow::slotResizeItemEnd()
3497 if (m_activeTimeline)
3498 m_activeTimeline->projectView()->setOutPoint();
3501 int MainWindow::getNewStuff(const QString &configFile)
3503 KNS3::Entry::List entries;
3504 #if KDE_IS_VERSION(4,3,80)
3505 KNS3::DownloadDialog dialog(configFile);
3507 entries = dialog.changedEntries();
3508 foreach(const KNS3::Entry & entry, entries) {
3509 if (entry.status() == KNS3::Entry::Installed)
3510 kDebug() << "// Installed files: " << entry.installedFiles();
3513 KNS::Engine engine(0);
3514 if (engine.init(configFile))
3515 entries = engine.downloadDialogModal(this);
3516 foreach(KNS::Entry * entry, entries) {
3517 if (entry->status() == KNS::Entry::Installed)
3518 kDebug() << "// Installed files: " << entry->installedFiles();
3520 #endif /* KDE_IS_VERSION(4,3,80) */
3521 return entries.size();
3524 void MainWindow::slotGetNewTitleStuff()
3526 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3527 TitleWidget::refreshTitleTemplates();
3530 void MainWindow::slotGetNewLumaStuff()
3532 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3533 initEffects::refreshLumas();
3534 m_activeTimeline->projectView()->reloadTransitionLumas();
3538 void MainWindow::slotGetNewRenderStuff()
3540 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3542 m_renderWidget->reloadProfiles();
3545 void MainWindow::slotGetNewMltProfileStuff()
3547 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3548 // update the list of profiles in settings dialog
3549 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3555 void MainWindow::slotAutoTransition()
3557 if (m_activeTimeline)
3558 m_activeTimeline->projectView()->autoTransition();
3561 void MainWindow::slotSplitAudio()
3563 if (m_activeTimeline)
3564 m_activeTimeline->projectView()->splitAudio();
3567 void MainWindow::slotUpdateClipType(QAction *action)
3569 if (m_activeTimeline) {
3570 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3571 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3572 else m_activeTimeline->projectView()->setAudioAndVideo();
3576 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3578 // We must stop the monitors since we create a new on in the dvd wizard
3579 m_clipMonitor->stop();
3580 m_projectMonitor->stop();
3581 DvdWizard w(url, profile, this);
3583 m_projectMonitor->start();
3586 void MainWindow::slotShowTimeline(bool show)
3588 if (show == false) {
3589 m_timelineState = saveState();
3590 centralWidget()->setHidden(true);
3592 centralWidget()->setHidden(false);
3593 restoreState(m_timelineState);
3597 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3599 //TODO: is there a way to maximize current widget?
3602 m_timelineState = saveState();
3603 QWidget *par = focusWidget()->parentWidget();
3604 while (par->parentWidget() && par->parentWidget() != this)
3605 par = par->parentWidget();
3606 kDebug() << "CURRENT WIDGET: " << par->objectName();
3609 //centralWidget()->setHidden(false);
3610 //restoreState(m_timelineState);
3614 void MainWindow::loadTranscoders()
3616 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3619 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3620 KConfigGroup transConfig(config, "Transcoding");
3622 QMap< QString, QString > profiles = transConfig.entryMap();
3623 QMapIterator<QString, QString> i(profiles);
3624 while (i.hasNext()) {
3626 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3627 QAction *a = transMenu->addAction(i.key());
3629 if (data.count() > 1)
3630 a->setToolTip(data.at(1));
3631 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3635 void MainWindow::slotTranscode(KUrl::List urls)
3640 if (urls.isEmpty()) {
3641 QAction *action = qobject_cast<QAction *>(sender());
3642 QStringList data = action->data().toStringList();
3643 params = data.at(0);
3644 if (data.count() > 1) desc = data.at(1);
3645 if (data.count() > 2) condition = data.at(2);
3646 urls << m_projectList->getConditionalUrls(condition);
3647 urls.removeAll(KUrl());
3649 if (urls.isEmpty()) {
3650 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3653 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3654 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3656 //QProcess::startDetached("ffmpeg", parameters);
3659 void MainWindow::slotTranscodeClip()
3661 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3662 if (urls.isEmpty()) return;
3663 slotTranscode(urls);
3666 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3668 if (m_activeDocument == NULL) return;
3669 QMapIterator<QString, QString> i(props);
3670 while (i.hasNext()) {
3672 m_activeDocument->setDocumentProperty(i.key(), i.value());
3674 m_activeDocument->setModified(true);
3678 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3680 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3682 QString playlistPath;
3685 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3686 QString path = m_renderWidget->getFreeScriptName();
3687 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3688 if (!ok || scriptPath.isEmpty()) return;
3689 scriptPath.prepend(scriptsFolder);
3690 QFile f(scriptPath);
3692 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3695 playlistPath = scriptPath + ".mlt";
3696 m_projectMonitor->saveSceneList(playlistPath);
3698 KTemporaryFile temp;
3699 temp.setAutoRemove(false);
3700 temp.setSuffix(".mlt");
3702 playlistPath = temp.fileName();
3703 m_projectMonitor->saveSceneList(playlistPath);
3706 if (!chapterFile.isEmpty()) {
3709 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3711 in = m_activeTimeline->inPoint();
3712 out = m_activeTimeline->outPoint();
3715 QDomElement chapters = doc.createElement("chapters");
3716 chapters.setAttribute("fps", m_activeDocument->fps());
3717 doc.appendChild(chapters);
3719 QDomElement guidesxml = m_activeDocument->guidesXml();
3720 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3721 for (int i = 0; i < nodes.count(); i++) {
3722 QDomElement e = nodes.item(i).toElement();
3724 QString comment = e.attribute("comment");
3725 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3726 if (time >= in && time < out) {
3727 if (zoneOnly) time = time - in;
3728 QDomElement chapter = doc.createElement("chapter");
3729 chapters.appendChild(chapter);
3730 chapter.setAttribute("title", comment);
3731 chapter.setAttribute("time", time);
3735 if (chapters.childNodes().count() > 0) {
3736 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3737 // Always insert a guide in pos 0
3738 QDomElement chapter = doc.createElement("chapter");
3739 chapters.insertBefore(chapter, QDomNode());
3740 chapter.setAttribute("title", i18n("Start"));
3741 chapter.setAttribute("time", "0");
3743 // save chapters file
3744 QFile file(chapterFile);
3745 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3746 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3748 file.write(doc.toString().toUtf8());
3749 if (file.error() != QFile::NoError) {
3750 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3757 if (m_renderWidget->automaticAudioExport()) {
3758 exportAudio = m_activeTimeline->checkProjectAudio();
3759 } else exportAudio = m_renderWidget->selectedAudioExport();
3760 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3763 void MainWindow::slotUpdateTimecodeFormat(int ix)
3765 KdenliveSettings::setFrametimecode(ix == 1);
3766 m_clipMonitor->updateTimecodeFormat();
3767 m_projectMonitor->updateTimecodeFormat();
3768 m_transitionConfig->updateTimecodeFormat();
3769 m_effectStack->updateTimecodeFormat();
3770 //m_activeTimeline->projectView()->clearSelection();
3771 m_activeTimeline->updateRuler();
3774 void MainWindow::slotRemoveFocus()
3776 statusBar()->setFocus();
3777 statusBar()->clearFocus();
3780 void MainWindow::slotRevert()
3782 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;
3783 KUrl url = m_activeDocument->url();
3784 if (closeCurrentDocument(false))
3785 doOpenFile(url, NULL);
3789 void MainWindow::slotShutdown()
3791 if (m_activeDocument) m_activeDocument->setModified(false);
3793 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3794 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3795 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3796 smserver.call("logout", 1, 2, 2);
3797 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3798 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3799 smserver.call("Shutdown");
3803 void MainWindow::slotUpdateTrackInfo()
3805 if (m_activeDocument)
3806 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3809 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3811 // Load the theme file
3813 if (action == NULL) theme = themename;
3814 else theme = action->data().toString();
3815 KdenliveSettings::setColortheme(theme);
3816 // Make palette for all widgets.
3818 if (theme.isEmpty())
3819 plt = QApplication::desktop()->palette();
3821 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3822 plt = KGlobalSettings::createApplicationPalette(config);
3825 kapp->setPalette(plt);
3826 const QObjectList children = statusBar()->children();
3828 foreach(QObject * child, children) {
3829 if (child->isWidgetType())
3830 ((QWidget*)child)->setPalette(plt);
3831 const QObjectList subchildren = child->children();
3832 foreach(QObject * subchild, subchildren) {
3833 if (subchild->isWidgetType())
3834 ((QWidget*)subchild)->setPalette(plt);
3837 if (m_activeTimeline) {
3838 m_activeTimeline->projectView()->updatePalette();
3843 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3845 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3846 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3847 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3848 const QSize bitsSize(24, 2);
3849 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3850 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3852 QPixmap pixmap(23, 16);
3853 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3855 KConfigGroup group(config, "WM");
3856 QPainter p(&pixmap);
3857 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3858 p.fillRect(1, 1, 7, 7, windowScheme.background());
3859 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3861 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3862 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3863 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3865 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3866 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3868 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3869 p.fillRect(1, 8, 7, 7, viewScheme.background());
3870 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3872 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3873 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3874 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3876 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3877 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3883 void MainWindow::slotSwitchMonitors()
3885 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3886 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3887 else m_projectList->focusTree();
3890 void MainWindow::slotSwitchFullscreen()
3892 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3893 else m_clipMonitor->slotSwitchFullScreen();
3896 void MainWindow::slotInsertZoneToTree()
3898 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3899 QStringList info = m_clipMonitor->getZoneInfo();
3900 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3903 void MainWindow::slotInsertZoneToTimeline()
3905 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3906 QStringList info = m_clipMonitor->getZoneInfo();
3907 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3911 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3913 if (m_activeDocument && m_activeTimeline) {
3914 if (!ids.isEmpty()) {
3915 for (int i = 0; i < ids.size(); ++i) {
3916 m_activeTimeline->slotDeleteClip(ids.at(i));
3918 m_activeDocument->clipManager()->slotDeleteClips(ids);
3920 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3921 m_activeDocument->setModified(true);
3925 void MainWindow::slotShowTitleBars(bool show)
3927 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
3928 for (int i = 0; i < docks.count(); i++) {
3929 QDockWidget* dock = docks.at(i);
3931 dock->setTitleBarWidget(0);
3933 if (!dock->isFloating()) {
3934 dock->setTitleBarWidget(new QWidget);
3938 KdenliveSettings::setShowtitlebars(show);
3941 void MainWindow::slotSwitchTitles()
3943 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3946 QString MainWindow::getMimeType()
3948 QString mimetype = "application/x-kdenlive";
3949 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3950 if (!mime) mimetype = "*.kdenlive";
3954 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3957 m_projectMonitor->render->sendFrameForAnalysis = true;
3960 for (int i = 0; i < m_scopesList.count(); i++) {
3961 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3968 m_projectMonitor->render->sendFrameForAnalysis = false;
3972 void MainWindow::slotUpdateScopeFrameRequest()
3974 // We need a delay to make sure widgets are hidden after a close event for example
3975 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3978 void MainWindow::slotDoUpdateScopeFrameRequest()
3981 bool request = false;
3982 for (int i = 0; i < m_scopesList.count(); i++) {
3983 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3984 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
3990 if (!m_projectMonitor->effectSceneDisplayed())
3991 m_projectMonitor->render->sendFrameForAnalysis = false;
3992 m_clipMonitor->render->sendFrameForAnalysis = false;
3994 m_projectMonitor->render->sendFrameForAnalysis = true;
3995 m_clipMonitor->render->sendFrameForAnalysis = true;
3999 void MainWindow::slotUpdateColorScopes()
4001 bool request = false;
4002 for (int i = 0; i < m_scopesList.count(); i++) {
4003 // Check if we need the renderer to send a new frame for update
4004 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4005 static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4008 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4009 else m_projectMonitor->render->sendFrameUpdate();
4013 void MainWindow::slotOpenStopmotion()
4015 if (m_stopmotion == NULL) {
4016 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4017 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
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"