1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
42 #include "audiosignal.h"
44 #include "jogshuttle.h"
45 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
47 #endif /* NO_JOGSHUTTLE */
48 #include "clipproperties.h"
50 #include "editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "kdenlive-config.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audiospectrum.h"
63 #include "spectrogram.h"
64 #include "archivewidget.h"
66 #include <KApplication>
70 #include <KActionCollection>
71 #include <KActionCategory>
72 #include <KStandardAction>
73 #include <KShortcutsDialog>
74 #include <KFileDialog>
75 #include <KMessageBox>
77 #include <KIO/NetAccess>
80 #include <KConfigDialog>
81 #include <KXMLGUIFactory>
83 #include <kstandarddirs.h>
84 #include <KUrlRequesterDialog>
85 #include <KTemporaryFile>
87 #include <KActionMenu>
90 #include <ktogglefullscreenaction.h>
92 #include <KNotification>
93 #include <KNotifyConfigWidget>
94 #if KDE_IS_VERSION(4,3,80)
95 #include <knewstuff3/downloaddialog.h>
96 #include <knewstuff3/knewstuffaction.h>
98 #include <knewstuff2/engine.h>
99 #include <knewstuff2/ui/knewstuffaction.h>
101 #endif /* KDE_IS_VERSION(4,3,80) */
103 #include <KColorScheme>
104 #include <KProgressDialog>
106 #include <QTextStream>
110 #include <QInputDialog>
111 #include <QDesktopWidget>
116 // Uncomment for deeper debugging
117 //#define DEBUG_MAINW
123 static const char version[] = VERSION;
125 static const int ID_TIMELINE_POS = 0;
131 Q_DECLARE_METATYPE(QVector<int16_t>)
133 EffectsList MainWindow::videoEffects;
134 EffectsList MainWindow::audioEffects;
135 EffectsList MainWindow::customEffects;
136 EffectsList MainWindow::transitions;
138 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
139 KXmlGuiWindow(parent),
140 m_activeDocument(NULL),
141 m_activeTimeline(NULL),
143 m_renderWidget(NULL),
144 #ifndef NO_JOGSHUTTLE
147 #endif /* NO_JOGSHUTTLE */
148 m_findActivated(false),
151 qRegisterMetaType<QVector<int16_t> > ();
152 // Create DBus interface
153 new MainWindowAdaptor(this);
154 QDBusConnection dbus = QDBusConnection::sessionBus();
155 dbus.registerObject("/MainWindow", this);
157 setlocale(LC_NUMERIC, "POSIX");
158 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
159 setFont(KGlobalSettings::toolBarFont());
160 parseProfiles(MltPath);
161 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
162 m_commandStack = new QUndoGroup;
163 setDockNestingEnabled(true);
164 m_timelineArea = new KTabWidget(this);
165 m_timelineArea->setTabReorderingEnabled(true);
166 m_timelineArea->setTabBarHidden(true);
167 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
168 m_timelineArea->setMinimumHeight(200);
170 QToolButton *closeTabButton = new QToolButton;
171 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
172 closeTabButton->setIcon(KIcon("tab-close"));
173 closeTabButton->adjustSize();
174 closeTabButton->setToolTip(i18n("Close the current tab"));
175 m_timelineArea->setCornerWidget(closeTabButton);
176 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
178 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
179 m_findTimer.setSingleShot(true);
181 // FIXME: the next call returns a newly allocated object, which leaks
182 initEffects::parseEffectFiles();
183 //initEffects::parseCustomEffectsFile();
185 m_monitorManager = new MonitorManager();
187 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
188 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
193 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
194 m_projectListDock->setObjectName("project_tree");
195 m_projectList = new ProjectList();
196 m_projectListDock->setWidget(m_projectList);
197 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
199 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
200 m_clipMonitorDock->setObjectName("clip_monitor");
201 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
202 m_clipMonitorDock->setWidget(m_clipMonitor);
204 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
205 m_projectMonitorDock->setObjectName("project_monitor");
206 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
207 m_projectMonitorDock->setWidget(m_projectMonitor);
210 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
211 m_recMonitorDock->setObjectName("record_monitor");
212 m_recMonitor = new RecMonitor("record", m_monitorManager);
213 m_recMonitorDock->setWidget(m_recMonitor);
214 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
215 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
217 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
219 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
220 m_notesDock->setObjectName("notes_widget");
221 m_notesWidget = new NotesWidget();
222 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
223 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
225 m_notesWidget->setTabChangesFocus(true);
226 #if KDE_IS_VERSION(4,4,0)
227 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
229 m_notesDock->setWidget(m_notesWidget);
230 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
232 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
233 m_effectStackDock->setObjectName("effect_stack");
234 m_effectStack = new EffectStackView(m_projectMonitor);
235 m_effectStackDock->setWidget(m_effectStack);
236 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
238 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
239 m_transitionConfigDock->setObjectName("transition");
240 m_transitionConfig = new TransitionSettings(m_projectMonitor);
241 m_transitionConfigDock->setWidget(m_transitionConfig);
242 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
244 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
245 m_effectListDock->setObjectName("effect_list");
246 m_effectList = new EffectsListView();
247 m_effectListDock->setWidget(m_effectList);
248 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
250 m_vectorscope = new Vectorscope(m_monitorManager);
251 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
252 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
253 m_vectorscopeDock->setWidget(m_vectorscope);
254 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
255 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
256 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
257 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
258 m_gfxScopesList.append(m_vectorscopeDock);
260 m_waveform = new Waveform(m_monitorManager);
261 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
262 m_waveformDock->setObjectName(m_waveform->widgetName());
263 m_waveformDock->setWidget(m_waveform);
264 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
265 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
266 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
267 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
268 m_gfxScopesList.append(m_waveformDock);
270 m_RGBParade = new RGBParade(m_monitorManager);
271 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
272 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
273 m_RGBParadeDock->setWidget(m_RGBParade);
274 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
275 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
276 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
277 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
278 m_gfxScopesList.append(m_RGBParadeDock);
280 m_histogram = new Histogram(m_monitorManager);
281 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
282 m_histogramDock->setObjectName(m_histogram->widgetName());
283 m_histogramDock->setWidget(m_histogram);
284 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
285 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
286 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
287 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
288 m_gfxScopesList.append(m_histogramDock);
291 m_audiosignal = new AudioSignal;
292 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
293 m_audiosignalDock->setObjectName("audiosignal");
294 m_audiosignalDock->setWidget(m_audiosignal);
295 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
296 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
297 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
299 m_audioSpectrum = new AudioSpectrum();
300 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
301 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
302 m_audioSpectrumDock->setWidget(m_audioSpectrum);
303 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
304 m_audioScopesList.append(m_audioSpectrum);
305 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
306 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
308 m_spectrogram = new Spectrogram();
309 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
310 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
311 m_spectrogramDock->setWidget(m_spectrogram);
312 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
313 m_audioScopesList.append(m_spectrogram);
314 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
315 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
317 // Connect the audio signal to the audio scope slots
319 if (m_projectMonitor) {
320 qDebug() << "project monitor connected";
321 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
322 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
323 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
324 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
325 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
326 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
329 qDebug() << "clip monitor connected";
330 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
331 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
332 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
333 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
334 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
335 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
337 // Ensure connections were set up correctly
342 // Add monitors here to keep them at the right of the window
343 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
344 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
346 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
349 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
350 m_undoViewDock->setObjectName("undo_history");
351 m_undoView = new QUndoView();
352 m_undoView->setCleanIcon(KIcon("edit-clear"));
353 m_undoView->setEmptyLabel(i18n("Clean"));
354 m_undoViewDock->setWidget(m_undoView);
355 m_undoView->setGroup(m_commandStack);
356 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
362 // Close non-general docks for the initial layout
363 // only show important ones
364 m_histogramDock->close();
365 m_RGBParadeDock->close();
366 m_waveformDock->close();
367 m_vectorscopeDock->close();
369 m_audioSpectrumDock->close();
370 m_spectrogramDock->close();
371 m_audiosignalDock->close();
373 m_undoViewDock->close();
377 /// Tabify Widgets ///
378 tabifyDockWidget(m_effectListDock, m_effectStackDock);
379 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
380 tabifyDockWidget(m_projectListDock, m_notesDock);
382 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
384 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
390 setCentralWidget(m_timelineArea);
393 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
395 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
396 m_fileRevert->setEnabled(false);
398 // Prepare layout actions
399 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
400 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
401 for (int i = 1; i < 5; i++) {
402 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
403 load->setData("_" + QString::number(i));
404 layoutActions->addAction("load_layout" + QString::number(i), load);
405 m_loadLayout->addAction(load);
406 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
407 save->setData("_" + QString::number(i));
408 layoutActions->addAction("save_layout" + QString::number(i), save);
410 layoutActions->addAction("load_layouts", m_loadLayout);
411 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
414 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
415 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
416 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
417 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
418 m_stopmotion_actions->addAction("stopmotion_capture", action);
419 action = new KAction(i18n("Switch live / captured frame"), this);
420 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
421 m_stopmotion_actions->addAction("stopmotion_switch", action);
422 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
423 action->setCheckable(true);
424 action->setChecked(false);
425 m_stopmotion_actions->addAction("stopmotion_overlay", action);
427 // Build effects menu
428 m_effectsMenu = new QMenu(i18n("Add Effect"));
429 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
430 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
431 m_effectsActionCollection->readSettings();
435 // Find QDockWidget tab bars and show / hide widget title bars on right click
436 QList <QTabBar *> tabs = findChildren<QTabBar *>();
437 for (int i = 0; i < tabs.count(); i++) {
438 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
439 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
442 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
443 guiFactory()->addClient(sp);*/
445 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
447 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
450 // Load layout names from config file
456 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
457 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
459 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
460 clipInTimeline->setIcon(KIcon("go-jump"));
461 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
462 static_cast<QMenu*>(factory()->container("transcoders", this)),
465 // build themes menus
466 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
467 QActionGroup *themegroup = new QActionGroup(this);
468 themegroup->setExclusive(true);
469 action = new KAction(i18n("Default"), this);
470 action->setCheckable(true);
471 themegroup->addAction(action);
472 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
474 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
476 for (int i = 0; i < schemeFiles.size(); ++i) {
478 const QString filename = schemeFiles.at(i);
479 const QFileInfo info(filename);
482 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
483 QIcon icon = createSchemePreviewIcon(config);
484 KConfigGroup group(config, "General");
485 const QString name = group.readEntry("Name", info.baseName());
486 action = new KAction(name, this);
487 action->setData(filename);
488 action->setIcon(icon);
489 action->setCheckable(true);
490 themegroup->addAction(action);
491 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
494 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
495 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
496 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
499 action = new QAction(fi.fileName(), this);
500 action->setData(*it);
501 action->setCheckable(true);
502 themegroup->addAction(action);
503 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
505 themesMenu->addActions(themegroup->actions());
506 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
508 // Setup and fill effects and transitions menus.
511 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
512 m->addActions(m_effectsMenu->actions());
515 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
516 for (int i = 0; i < transitions.count(); ++i)
517 m_transitionsMenu->addAction(m_transitions[i]);
519 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
520 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
521 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
523 m_effectStack->setMenu(m_effectsMenu);
525 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
526 const QList<QAction *> viewActions = createPopupMenu()->actions();
527 viewMenu->insertActions(NULL, viewActions);
529 m_timelineContextMenu = new QMenu(this);
530 m_timelineContextClipMenu = new QMenu(this);
531 m_timelineContextTransitionMenu = new QMenu(this);
533 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
534 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
535 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
537 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
538 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
539 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
540 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
541 m_timelineContextClipMenu->addSeparator();
542 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
543 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
544 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
545 m_timelineContextClipMenu->addSeparator();
546 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
547 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
548 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
549 m_timelineContextClipMenu->addSeparator();
551 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
552 m_timelineContextClipMenu->addMenu(markersMenu);
553 m_timelineContextClipMenu->addSeparator();
554 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
555 m_timelineContextClipMenu->addMenu(m_effectsMenu);
557 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
558 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
559 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
561 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
563 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
564 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
565 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
566 connect(m_monitorManager, SIGNAL(raiseMonitor(AbstractMonitor *)), this, SLOT(slotRaiseMonitor(AbstractMonitor *)));
567 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
568 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
569 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
570 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
572 slotConnectMonitors();
574 // Open or create a file. Command line argument passed in Url has
575 // precedence, then "openlastproject", then just a plain empty file.
576 // If opening Url fails, openlastproject will _not_ be used.
577 if (!Url.isEmpty()) {
578 // delay loading so that the window shows up
580 QTimer::singleShot(500, this, SLOT(openFile()));
581 } else if (KdenliveSettings::openlastproject()) {
582 QTimer::singleShot(500, this, SLOT(openLastFile()));
583 } else { //if (m_timelineArea->count() == 0) {
587 if (!clipsToLoad.isEmpty() && m_activeDocument) {
588 QStringList list = clipsToLoad.split(',');
590 foreach(QString path, list) {
591 kDebug() << QDir::current().absoluteFilePath(path);
592 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
594 m_projectList->slotAddClip(urls);
597 #ifndef NO_JOGSHUTTLE
598 activateShuttleDevice();
599 #endif /* NO_JOGSHUTTLE */
600 m_projectListDock->raise();
602 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
603 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
606 MainWindow::~MainWindow()
611 m_effectStack->slotClipItemSelected(NULL, 0);
612 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
614 if (m_projectMonitor) m_projectMonitor->stop();
615 if (m_clipMonitor) m_clipMonitor->stop();
617 delete m_activeTimeline;
618 delete m_effectStack;
619 delete m_transitionConfig;
620 delete m_activeDocument;
621 delete m_projectMonitor;
622 delete m_clipMonitor;
623 delete m_shortcutRemoveFocus;
624 delete[] m_transitions;
625 Mlt::Factory::close();
629 bool MainWindow::queryClose()
631 if (m_renderWidget) {
632 int waitingJobs = m_renderWidget->waitingJobsCount();
633 if (waitingJobs > 0) {
634 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")))) {
635 case KMessageBox::Yes :
636 // create script with waiting jobs and start it
637 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
639 case KMessageBox::No :
640 // Don't do anything, jobs will be deleted
648 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
649 // warn the user to save if document is modified and we have clips in our project list
650 if (m_activeDocument && m_activeDocument->isModified() &&
651 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
652 !m_projectList->documentClipList().isEmpty())) {
656 if (m_activeDocument->url().fileName().isEmpty())
657 message = i18n("Save changes to document?");
659 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
660 switch (KMessageBox::warningYesNoCancel(this, message)) {
661 case KMessageBox::Yes :
662 // save document here. If saving fails, return false;
664 case KMessageBox::No :
665 // User does not want to save the changes, clear recovery files
666 m_activeDocument->m_autosave->resize(0);
675 void MainWindow::loadPlugins()
677 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
678 populateMenus(plugin);
681 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
683 filters << "libkdenlive*";
684 foreach(const QString & folder, directories) {
685 kDebug() << "Parsing plugin folder: " << folder;
686 QDir pluginsDir(folder);
687 foreach(const QString & fileName,
688 pluginsDir.entryList(filters, QDir::Files)) {
690 * Avoid loading the same plugin twice when there is more than one
693 if (!m_pluginFileNames.contains(fileName)) {
694 kDebug() << "Found plugin: " << fileName;
695 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
696 QObject *plugin = loader.instance();
698 populateMenus(plugin);
699 m_pluginFileNames += fileName;
701 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
707 void MainWindow::populateMenus(QObject *plugin)
709 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
710 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
712 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
716 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
717 QMenu *menu, const char *member,
718 QActionGroup *actionGroup)
720 kDebug() << "// ADD to MENU" << texts;
721 foreach(const QString & text, texts) {
722 QAction *action = new QAction(text, plugin);
723 action->setData(text);
724 connect(action, SIGNAL(triggered()), this, member);
725 menu->addAction(action);
728 action->setCheckable(true);
729 actionGroup->addAction(action);
734 void MainWindow::aboutPlugins()
736 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
741 void MainWindow::generateClip()
743 QAction *action = qobject_cast<QAction *>(sender());
744 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
746 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
747 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
748 if (!clipUrl.isEmpty()) {
749 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
753 void MainWindow::saveProperties(KConfigGroup &config)
755 // save properties here,used by session management
757 KMainWindow::saveProperties(config);
761 void MainWindow::readProperties(const KConfigGroup &config)
763 // read properties here,used by session management
764 KMainWindow::readProperties(config);
765 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
766 openFile(KUrl(Lastproject));
769 void MainWindow::slotReloadEffects()
771 initEffects::parseCustomEffectsFile();
772 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
775 #ifndef NO_JOGSHUTTLE
776 void MainWindow::activateShuttleDevice()
782 if (KdenliveSettings::enableshuttle() == false) return;
784 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
785 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
787 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
788 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
789 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
790 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
791 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
793 #endif /* NO_JOGSHUTTLE */
795 void MainWindow::slotDoAction(const QString& action_name)
797 QAction* action = actionCollection()->action(action_name);
799 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
805 void MainWindow::configureNotifications()
807 KNotifyConfigWidget::configure(this);
810 void MainWindow::slotFullScreen()
812 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
815 void MainWindow::slotAddEffect(const QDomElement effect)
817 if (!m_activeDocument) return;
818 if (effect.isNull()) {
819 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
822 QDomElement effectToAdd = effect.cloneNode().toElement();
824 int ix = m_effectStack->isTrackMode(&ok);
825 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
826 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
829 void MainWindow::slotRaiseMonitor(AbstractMonitor *monitor)
831 if (monitor == m_clipMonitor) m_clipMonitorDock->raise();
832 else if (monitor == m_projectMonitor) m_projectMonitorDock->raise();
835 void MainWindow::slotUpdateClip(const QString &id)
837 if (!m_activeDocument) return;
838 m_activeTimeline->projectView()->slotUpdateClip(id);
841 void MainWindow::slotConnectMonitors()
843 m_projectList->setRenderer(m_projectMonitor->render);
844 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
845 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
846 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
847 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
848 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool, bool)));
849 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
850 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)));
852 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
853 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
855 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
857 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
858 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
860 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
862 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
863 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
866 void MainWindow::slotAdjustClipMonitor()
868 m_clipMonitorDock->updateGeometry();
869 m_clipMonitorDock->adjustSize();
870 m_clipMonitor->resetSize();
873 void MainWindow::slotAdjustProjectMonitor()
875 m_projectMonitorDock->updateGeometry();
876 m_projectMonitorDock->adjustSize();
877 m_projectMonitor->resetSize();
881 class NameGrabbingKActionCollection {
883 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
884 : m_collection(collection), m_action_names(action_names) {
885 m_action_names.clear();
887 KAction* addAction(const QString& action_name) {
888 m_action_names << action_name;
889 return m_collection->addAction(action_name);
891 void addAction(const QString& action_name, QAction* action) {
892 m_action_names << action_name;
893 m_collection->addAction(action_name, action);
895 operator KActionCollection*() { return m_collection; }
896 const QStringList& actionNames() const { return m_action_names; }
898 KActionCollection* m_collection;
899 QStringList& m_action_names;
902 void MainWindow::setupActions()
905 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
906 m_timecodeFormat = new KComboBox(this);
907 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
908 m_timecodeFormat->addItem(i18n("Frames"));
909 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
910 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
912 m_statusProgressBar = new QProgressBar(this);
913 m_statusProgressBar->setMinimum(0);
914 m_statusProgressBar->setMaximum(100);
915 m_statusProgressBar->setMaximumWidth(150);
916 m_statusProgressBar->setVisible(false);
918 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
919 toolbar->setMovable(false);
920 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
921 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
922 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
923 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
924 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
925 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());
926 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
928 //create edit mode buttons
929 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
930 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
931 toolbar->addAction(m_normalEditTool);
932 m_normalEditTool->setCheckable(true);
933 m_normalEditTool->setChecked(true);
935 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
936 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
937 toolbar->addAction(m_overwriteEditTool);
938 m_overwriteEditTool->setCheckable(true);
939 m_overwriteEditTool->setChecked(false);
941 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
942 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
943 toolbar->addAction(m_insertEditTool);
944 m_insertEditTool->setCheckable(true);
945 m_insertEditTool->setChecked(false);
946 // not implemented yet
947 m_insertEditTool->setEnabled(false);
949 QActionGroup *editGroup = new QActionGroup(this);
950 editGroup->addAction(m_normalEditTool);
951 editGroup->addAction(m_overwriteEditTool);
952 editGroup->addAction(m_insertEditTool);
953 editGroup->setExclusive(true);
954 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
955 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
957 toolbar->addSeparator();
959 // create tools buttons
960 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
961 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
962 toolbar->addAction(m_buttonSelectTool);
963 m_buttonSelectTool->setCheckable(true);
964 m_buttonSelectTool->setChecked(true);
966 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
967 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
968 toolbar->addAction(m_buttonRazorTool);
969 m_buttonRazorTool->setCheckable(true);
970 m_buttonRazorTool->setChecked(false);
972 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
973 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
974 toolbar->addAction(m_buttonSpacerTool);
975 m_buttonSpacerTool->setCheckable(true);
976 m_buttonSpacerTool->setChecked(false);
978 QActionGroup *toolGroup = new QActionGroup(this);
979 toolGroup->addAction(m_buttonSelectTool);
980 toolGroup->addAction(m_buttonRazorTool);
981 toolGroup->addAction(m_buttonSpacerTool);
982 toolGroup->setExclusive(true);
983 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
985 QWidget * actionWidget;
986 int max = toolbar->iconSizeDefault() + 2;
987 actionWidget = toolbar->widgetForAction(m_normalEditTool);
988 actionWidget->setMaximumWidth(max);
989 actionWidget->setMaximumHeight(max - 4);
991 actionWidget = toolbar->widgetForAction(m_insertEditTool);
992 actionWidget->setMaximumWidth(max);
993 actionWidget->setMaximumHeight(max - 4);
995 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
999 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1000 actionWidget->setMaximumWidth(max);
1001 actionWidget->setMaximumHeight(max - 4);
1003 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1004 actionWidget->setMaximumWidth(max);
1005 actionWidget->setMaximumHeight(max - 4);
1007 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1008 actionWidget->setMaximumWidth(max);
1009 actionWidget->setMaximumHeight(max - 4);
1011 toolbar->setStyleSheet(style1);
1012 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1014 toolbar->addSeparator();
1015 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1016 toolbar->addAction(m_buttonFitZoom);
1017 m_buttonFitZoom->setCheckable(false);
1019 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1020 toolbar->addAction(m_zoomOut);
1021 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1023 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1024 m_zoomSlider->setMaximum(13);
1025 m_zoomSlider->setPageStep(1);
1026 m_zoomSlider->setInvertedAppearance(true);
1028 m_zoomSlider->setMaximumWidth(150);
1029 m_zoomSlider->setMinimumWidth(100);
1030 toolbar->addWidget(m_zoomSlider);
1032 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1033 toolbar->addAction(m_zoomIn);
1034 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1036 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1037 actionWidget->setMaximumWidth(max);
1038 actionWidget->setMaximumHeight(max - 4);
1039 actionWidget->setStyleSheet(styleBorderless);
1041 actionWidget = toolbar->widgetForAction(m_zoomIn);
1042 actionWidget->setMaximumWidth(max);
1043 actionWidget->setMaximumHeight(max - 4);
1044 actionWidget->setStyleSheet(styleBorderless);
1046 actionWidget = toolbar->widgetForAction(m_zoomOut);
1047 actionWidget->setMaximumWidth(max);
1048 actionWidget->setMaximumHeight(max - 4);
1049 actionWidget->setStyleSheet(styleBorderless);
1051 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1052 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1053 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1054 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1055 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1057 toolbar->addSeparator();
1059 //create automatic audio split button
1060 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1061 toolbar->addAction(m_buttonAutomaticSplitAudio);
1062 m_buttonAutomaticSplitAudio->setCheckable(true);
1063 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1064 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1066 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1067 toolbar->addAction(m_buttonVideoThumbs);
1068 m_buttonVideoThumbs->setCheckable(true);
1069 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1070 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1072 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1073 toolbar->addAction(m_buttonAudioThumbs);
1074 m_buttonAudioThumbs->setCheckable(true);
1075 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1076 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1078 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1079 toolbar->addAction(m_buttonShowMarkers);
1080 m_buttonShowMarkers->setCheckable(true);
1081 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1082 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1084 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1085 toolbar->addAction(m_buttonSnap);
1086 m_buttonSnap->setCheckable(true);
1087 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1088 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1090 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1091 actionWidget->setMaximumWidth(max);
1092 actionWidget->setMaximumHeight(max - 4);
1094 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1095 actionWidget->setMaximumWidth(max);
1096 actionWidget->setMaximumHeight(max - 4);
1098 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1099 actionWidget->setMaximumWidth(max);
1100 actionWidget->setMaximumHeight(max - 4);
1102 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1103 actionWidget->setMaximumWidth(max);
1104 actionWidget->setMaximumHeight(max - 4);
1106 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1107 actionWidget->setMaximumWidth(max);
1108 actionWidget->setMaximumHeight(max - 4);
1110 m_messageLabel = new StatusBarMessageLabel(this);
1111 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1113 statusBar()->addWidget(m_messageLabel, 10);
1114 statusBar()->addWidget(m_statusProgressBar, 0);
1115 statusBar()->addPermanentWidget(toolbar);
1116 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1117 statusBar()->addPermanentWidget(m_timecodeFormat);
1118 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1120 collection.addAction("normal_mode", m_normalEditTool);
1121 collection.addAction("overwrite_mode", m_overwriteEditTool);
1122 collection.addAction("insert_mode", m_insertEditTool);
1123 collection.addAction("select_tool", m_buttonSelectTool);
1124 collection.addAction("razor_tool", m_buttonRazorTool);
1125 collection.addAction("spacer_tool", m_buttonSpacerTool);
1127 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1128 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1129 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1130 collection.addAction("show_markers", m_buttonShowMarkers);
1131 collection.addAction("snap", m_buttonSnap);
1132 collection.addAction("zoom_fit", m_buttonFitZoom);
1133 collection.addAction("zoom_in", m_zoomIn);
1134 collection.addAction("zoom_out", m_zoomOut);
1136 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1137 collection.addAction("project_find", m_projectSearch);
1138 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1139 m_projectSearch->setShortcut(Qt::Key_Slash);
1141 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1142 collection.addAction("project_find_next", m_projectSearchNext);
1143 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1144 m_projectSearchNext->setShortcut(Qt::Key_F3);
1145 m_projectSearchNext->setEnabled(false);
1147 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1148 collection.addAction("manage_profiles", profilesAction);
1149 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1151 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1152 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1153 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1154 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1156 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1157 collection.addAction("run_wizard", wizAction);
1158 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1160 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1161 collection.addAction("project_settings", projectAction);
1162 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1164 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1165 collection.addAction("project_render", projectRender);
1166 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1167 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1169 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1170 collection.addAction("project_clean", projectClean);
1171 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1173 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1174 collection.addAction("project_adjust_profile", projectAdjust);
1175 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1177 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1178 KShortcut playShortcut;
1179 playShortcut.setPrimary(Qt::Key_Space);
1180 playShortcut.setAlternate(Qt::Key_K);
1181 monitorPlay->setShortcut(playShortcut);
1182 collection.addAction("monitor_play", monitorPlay);
1183 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1185 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1186 collection.addAction("monitor_pause", monitorPause);
1187 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1189 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1190 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1191 collection.addAction("monitor_play_zone", m_playZone);
1192 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1194 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1195 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1196 collection.addAction("monitor_loop_zone", m_loopZone);
1197 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1199 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1200 m_loopClip->setEnabled(false);
1201 collection.addAction("monitor_loop_clip", m_loopClip);
1202 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1204 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1205 collection.addAction("dvd_wizard", dvdWizard);
1206 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1208 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1209 collection.addAction("transcode_clip", transcodeClip);
1210 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1212 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1213 collection.addAction("archive_project", archiveProject);
1214 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1217 KAction *markIn = collection.addAction("mark_in");
1218 markIn->setText(i18n("Set Zone In"));
1219 markIn->setShortcut(Qt::Key_I);
1220 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1222 KAction *markOut = collection.addAction("mark_out");
1223 markOut->setText(i18n("Set Zone Out"));
1224 markOut->setShortcut(Qt::Key_O);
1225 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1227 KAction *switchMon = collection.addAction("switch_monitor");
1228 switchMon->setText(i18n("Switch monitor"));
1229 switchMon->setShortcut(Qt::Key_T);
1230 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1232 KAction *fullMon = collection.addAction("monitor_fullscreen");
1233 fullMon->setText(i18n("Switch monitor fullscreen"));
1234 fullMon->setIcon(KIcon("view-fullscreen"));
1235 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1237 KAction *insertTree = collection.addAction("insert_project_tree");
1238 insertTree->setText(i18n("Insert zone in project tree"));
1239 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1240 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1242 KAction *insertTimeline = collection.addAction("insert_timeline");
1243 insertTimeline->setText(i18n("Insert zone in timeline"));
1244 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1245 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1247 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1248 collection.addAction("resize_timeline_clip_start", resizeStart);
1249 resizeStart->setShortcut(Qt::Key_1);
1250 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1252 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1253 collection.addAction("resize_timeline_clip_end", resizeEnd);
1254 resizeEnd->setShortcut(Qt::Key_2);
1255 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1257 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1258 monitorSeekBackward->setShortcut(Qt::Key_J);
1259 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1260 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1262 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1263 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1264 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1265 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1267 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1268 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1269 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1270 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1272 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1273 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1274 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1275 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1277 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1278 monitorSeekForward->setShortcut(Qt::Key_L);
1279 collection.addAction("monitor_seek_forward", monitorSeekForward);
1280 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1282 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1283 clipStart->setShortcut(Qt::Key_Home);
1284 collection.addAction("seek_clip_start", clipStart);
1285 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1287 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1288 clipEnd->setShortcut(Qt::Key_End);
1289 collection.addAction("seek_clip_end", clipEnd);
1290 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1292 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1293 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1294 collection.addAction("seek_zone_start", zoneStart);
1295 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1297 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1298 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1299 collection.addAction("seek_zone_end", zoneEnd);
1300 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1302 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1303 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1304 collection.addAction("seek_start", projectStart);
1305 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1307 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1308 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1309 collection.addAction("seek_end", projectEnd);
1310 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1312 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1313 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1314 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1315 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1317 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1318 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1319 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1320 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1322 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1323 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1324 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1325 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1327 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1328 deleteItem->setShortcut(Qt::Key_Delete);
1329 collection.addAction("delete_timeline_clip", deleteItem);
1330 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1332 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1333 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1334 editTimelineClipSpeed->setData("change_speed");
1335 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1337 KAction *stickTransition = collection.addAction("auto_transition");
1338 stickTransition->setData(QString("auto"));
1339 stickTransition->setCheckable(true);
1340 stickTransition->setEnabled(false);
1341 stickTransition->setText(i18n("Automatic Transition"));
1342 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1344 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1345 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1346 collection.addAction("group_clip", groupClip);
1347 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1349 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1350 collection.addAction("ungroup_clip", ungroupClip);
1351 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1352 ungroupClip->setData("ungroup_clip");
1353 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1355 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1356 collection.addAction("edit_item_duration", editItemDuration);
1357 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1359 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1360 collection.addAction("clip_in_project_tree", clipInProjectTree);
1361 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1363 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1364 collection.addAction("clip_to_project_tree", clipToProjectTree);
1365 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1367 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1368 insertOvertwrite->setShortcut(Qt::Key_V);
1369 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1370 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1372 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1373 selectTimelineClip->setShortcut(Qt::Key_Plus);
1374 collection.addAction("select_timeline_clip", selectTimelineClip);
1375 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1377 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1378 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1379 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1380 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1382 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1383 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1384 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1385 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1387 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1388 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1389 collection.addAction("select_timeline_transition", selectTimelineTransition);
1390 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1392 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1393 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1394 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1395 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1397 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1398 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1399 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1400 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1402 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1403 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1404 collection.addAction("cut_timeline_clip", cutTimelineClip);
1405 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1407 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1408 collection.addAction("add_clip_marker", addClipMarker);
1409 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1411 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1412 collection.addAction("delete_clip_marker", deleteClipMarker);
1413 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1415 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1416 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1417 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1419 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1420 editClipMarker->setData(QString("edit_marker"));
1421 collection.addAction("edit_clip_marker", editClipMarker);
1422 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1424 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1425 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1426 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1427 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1429 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1430 collection.addAction("split_audio", splitAudio);
1431 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1433 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1434 collection.addAction("clip_audio_only", audioOnly);
1435 audioOnly->setData("clip_audio_only");
1436 audioOnly->setCheckable(true);
1438 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1439 collection.addAction("clip_video_only", videoOnly);
1440 videoOnly->setData("clip_video_only");
1441 videoOnly->setCheckable(true);
1443 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1444 collection.addAction("clip_audio_and_video", audioAndVideo);
1445 audioAndVideo->setData("clip_audio_and_video");
1446 audioAndVideo->setCheckable(true);
1448 m_clipTypeGroup = new QActionGroup(this);
1449 m_clipTypeGroup->addAction(audioOnly);
1450 m_clipTypeGroup->addAction(videoOnly);
1451 m_clipTypeGroup->addAction(audioAndVideo);
1452 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1453 m_clipTypeGroup->setEnabled(false);
1455 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1456 collection.addAction("insert_space", insertSpace);
1457 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1459 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1460 collection.addAction("delete_space", removeSpace);
1461 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1463 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1464 collection.addAction("insert_track", insertTrack);
1465 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1467 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1468 collection.addAction("delete_track", deleteTrack);
1469 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1471 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1472 collection.addAction("config_tracks", configTracks);
1473 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1475 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1476 collection.addAction("add_guide", addGuide);
1477 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1479 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1480 collection.addAction("delete_guide", delGuide);
1481 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1483 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1484 collection.addAction("edit_guide", editGuide);
1485 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1487 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1488 collection.addAction("delete_all_guides", delAllGuides);
1489 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1491 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1492 collection.addAction("paste_effects", pasteEffects);
1493 pasteEffects->setData("paste_effects");
1494 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1496 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1497 collection.addAction("show_timeline", showTimeline);
1498 showTimeline->setCheckable(true);
1499 showTimeline->setChecked(true);
1500 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1502 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1503 collection.addAction("show_titlebars", showTitleBar);
1504 showTitleBar->setCheckable(true);
1505 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1506 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1507 slotShowTitleBars(KdenliveSettings::showtitlebars());
1510 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1512 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1513 collection.addAction("maximize_current", maxCurrent);
1514 maxCurrent->setCheckable(true);
1515 maxCurrent->setChecked(false);
1516 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1518 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1519 KStandardAction::quit(this, SLOT(close()), collection);
1520 KStandardAction::open(this, SLOT(openFile()), collection);
1521 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1522 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1523 KStandardAction::openNew(this, SLOT(newFile()), collection);
1524 // TODO: make the following connection to slotEditKeys work
1525 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1526 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1527 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1528 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1529 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1530 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1532 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1533 undo->setEnabled(false);
1534 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1536 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1537 redo->setEnabled(false);
1538 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1541 //TODO: Add status tooltip to actions ?
1542 connect(collection, SIGNAL(actionHovered(QAction*)),
1543 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1546 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1547 collection.addAction("add_clip", addClip);
1548 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1550 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1551 collection.addAction("add_color_clip", addColorClip);
1552 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1554 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1555 collection.addAction("add_slide_clip", addSlideClip);
1556 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1558 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1559 collection.addAction("add_text_clip", addTitleClip);
1560 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1562 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1563 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1564 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1566 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1567 collection.addAction("add_folder", addFolderButton);
1568 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1570 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1571 collection.addAction("clip_properties", clipProperties);
1572 clipProperties->setData("clip_properties");
1573 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1574 clipProperties->setEnabled(false);
1576 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1577 collection.addAction("edit_clip", openClip);
1578 openClip->setData("edit_clip");
1579 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1580 openClip->setEnabled(false);
1582 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1583 collection.addAction("delete_clip", deleteClip);
1584 deleteClip->setData("delete_clip");
1585 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1586 deleteClip->setEnabled(false);
1588 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1589 collection.addAction("reload_clip", reloadClip);
1590 reloadClip->setData("reload_clip");
1591 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1592 reloadClip->setEnabled(false);
1594 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1595 collection.addAction("stopmotion", stopMotion);
1596 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1598 QMenu *addClips = new QMenu();
1599 addClips->addAction(addClip);
1600 addClips->addAction(addColorClip);
1601 addClips->addAction(addSlideClip);
1602 addClips->addAction(addTitleClip);
1603 addClips->addAction(addTitleTemplateClip);
1604 addClips->addAction(addFolderButton);
1606 addClips->addAction(reloadClip);
1607 addClips->addAction(clipProperties);
1608 addClips->addAction(openClip);
1609 addClips->addAction(deleteClip);
1610 m_projectList->setupMenu(addClips, addClip);
1612 // Setup effects and transitions actions.
1613 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1614 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1615 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1616 m_transitions = new KAction*[transitions.count()];
1617 for (int i = 0; i < transitions.count(); i++) {
1618 QStringList effectInfo = transitions.effectIdInfo(i);
1619 m_transitions[i] = new KAction(effectInfo.at(0), this);
1620 m_transitions[i]->setData(effectInfo);
1621 m_transitions[i]->setIconVisibleInMenu(false);
1622 QString id = effectInfo.at(2);
1623 if (id.isEmpty()) id = effectInfo.at(1);
1624 transitionActions->addAction("transition_" + id, m_transitions[i]);
1626 //m_effectsActionCollection->readSettings();
1628 //connect(collection, SIGNAL( clearStatusText() ),
1629 //statusBar(), SLOT( clear() ) );
1632 void MainWindow::slotDisplayActionMessage(QAction *a)
1634 statusBar()->showMessage(a->data().toString(), 3000);
1637 void MainWindow::loadLayouts()
1639 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1640 if (m_loadLayout == NULL || saveLayout == NULL) return;
1641 KSharedConfigPtr config = KGlobal::config();
1642 KConfigGroup layoutGroup(config, "Layouts");
1643 QStringList entries = layoutGroup.keyList();
1644 QList<QAction *> loadActions = m_loadLayout->actions();
1645 QList<QAction *> saveActions = saveLayout->actions();
1646 for (int i = 1; i < 5; i++) {
1647 // Rename the layouts actions
1648 foreach(const QString & key, entries) {
1649 if (key.endsWith(QString("_%1").arg(i))) {
1650 // Found previously saved layout
1651 QString layoutName = key.section("_", 0, -2);
1652 for (int j = 0; j < loadActions.count(); j++) {
1653 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1654 loadActions[j]->setText(layoutName);
1655 loadActions[j]->setData(key);
1659 for (int j = 0; j < saveActions.count(); j++) {
1660 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1661 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1662 saveActions[j]->setData(key);
1671 void MainWindow::slotLoadLayout(QAction *action)
1673 if (!action) return;
1674 QString layoutId = action->data().toString();
1675 if (layoutId.isEmpty()) return;
1676 KSharedConfigPtr config = KGlobal::config();
1677 KConfigGroup layouts(config, "Layouts");
1678 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1679 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1680 //restoreGeometry(geom);
1681 restoreState(state);
1684 void MainWindow::slotSaveLayout(QAction *action)
1686 QString originallayoutName = action->data().toString();
1687 int layoutId = originallayoutName.section('_', -1).toInt();
1689 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1690 if (layoutName.isEmpty()) return;
1691 KSharedConfigPtr config = KGlobal::config();
1692 KConfigGroup layouts(config, "Layouts");
1693 layouts.deleteEntry(originallayoutName);
1695 QByteArray st = saveState();
1696 layoutName.append("_" + QString::number(layoutId));
1697 layouts.writeEntry(layoutName, st.toBase64());
1701 void MainWindow::saveOptions()
1703 KdenliveSettings::self()->writeConfig();
1704 KSharedConfigPtr config = KGlobal::config();
1705 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1706 KConfigGroup treecolumns(config, "Project Tree");
1707 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1711 void MainWindow::readOptions()
1713 KSharedConfigPtr config = KGlobal::config();
1714 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1715 KConfigGroup initialGroup(config, "version");
1716 bool upgrade = false;
1717 if (initialGroup.exists()) {
1718 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1722 if (initialGroup.readEntry("version") == "0.7") {
1723 //Add new settings from 0.7.1
1724 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1725 QString path = QDir::homePath() + "/kdenlive";
1726 if (KStandardDirs::makeDir(path) == false) {
1727 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1728 } else KdenliveSettings::setDefaultprojectfolder(path);
1734 if (!initialGroup.exists() || upgrade) {
1735 // this is our first run, show Wizard
1736 Wizard *w = new Wizard(upgrade, this);
1737 if (w->exec() == QDialog::Accepted && w->isOk()) {
1738 w->adjustSettings();
1739 initialGroup.writeEntry("version", version);
1745 KConfigGroup treecolumns(config, "Project Tree");
1746 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1747 if (!state.isEmpty())
1748 m_projectList->setHeaderInfo(state);
1751 void MainWindow::slotRunWizard()
1753 Wizard *w = new Wizard(false, this);
1754 if (w->exec() == QDialog::Accepted && w->isOk()) {
1755 w->adjustSettings();
1760 void MainWindow::newFile(bool showProjectSettings, bool force)
1762 if (!m_timelineArea->isEnabled() && !force)
1764 m_fileRevert->setEnabled(false);
1765 QString profileName = KdenliveSettings::default_profile();
1766 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1767 QMap <QString, QString> documentProperties;
1768 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1769 if (!showProjectSettings) {
1770 // set up default properties
1771 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1772 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1773 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1774 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1775 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1776 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1777 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1778 if (!KdenliveSettings::activatetabs())
1779 if (!closeCurrentDocument())
1782 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1783 if (w->exec() != QDialog::Accepted)
1785 if (!KdenliveSettings::activatetabs())
1786 if (!closeCurrentDocument())
1788 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1789 slotSwitchVideoThumbs();
1790 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1791 slotSwitchAudioThumbs();
1792 profileName = w->selectedProfile();
1793 projectFolder = w->selectedFolder();
1794 projectTracks = w->tracks();
1795 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1796 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1797 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1798 documentProperties.insert("proxyparams", w->proxyParams());
1799 documentProperties.insert("proxyextension", w->proxyExtension());
1800 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1801 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1804 m_timelineArea->setEnabled(true);
1805 m_projectList->setEnabled(true);
1807 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1808 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1810 TrackView *trackView = new TrackView(doc, &ok, this);
1811 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1814 //m_timelineArea->setEnabled(false);
1815 //m_projectList->setEnabled(false);
1819 if (m_timelineArea->count() == 1) {
1820 connectDocumentInfo(doc);
1821 connectDocument(trackView, doc);
1823 m_timelineArea->setTabBarHidden(false);
1824 m_monitorManager->activateMonitor("clip");
1825 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1828 void MainWindow::activateDocument()
1830 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1831 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1832 KdenliveDoc *currentDoc = currentTab->document();
1833 connectDocumentInfo(currentDoc);
1834 connectDocument(currentTab, currentDoc);
1837 bool MainWindow::closeCurrentDocument(bool saveChanges)
1839 QWidget *w = m_timelineArea->currentWidget();
1840 if (!w) return true;
1841 // closing current document
1842 int ix = m_timelineArea->currentIndex() + 1;
1843 if (ix == m_timelineArea->count()) ix = 0;
1844 m_timelineArea->setCurrentIndex(ix);
1845 TrackView *tabToClose = (TrackView *) w;
1846 KdenliveDoc *docToClose = tabToClose->document();
1847 if (docToClose && docToClose->isModified() && saveChanges) {
1849 if (m_activeDocument->url().fileName().isEmpty())
1850 message = i18n("Save changes to document?");
1852 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1853 switch (KMessageBox::warningYesNoCancel(this, message)) {
1854 case KMessageBox::Yes :
1855 // save document here. If saving fails, return false;
1856 if (saveFile() == false) return false;
1858 case KMessageBox::Cancel :
1865 m_clipMonitor->slotSetXml(NULL);
1866 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1867 if (m_timelineArea->count() == 1) {
1868 m_timelineArea->setTabBarHidden(true);
1869 m_closeAction->setEnabled(false);
1871 if (docToClose == m_activeDocument) {
1872 delete m_activeDocument;
1873 m_activeDocument = NULL;
1874 m_effectStack->clear();
1875 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1879 if (w == m_activeTimeline) {
1880 delete m_activeTimeline;
1881 m_activeTimeline = NULL;
1888 bool MainWindow::saveFileAs(const QString &outputFileName)
1890 QString currentSceneList;
1891 m_monitorManager->stopActiveMonitor();
1893 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1896 // Save timeline thumbnails
1897 m_activeTimeline->projectView()->saveThumbnails();
1898 m_activeDocument->setUrl(KUrl(outputFileName));
1899 if (m_activeDocument->m_autosave == NULL) {
1900 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1901 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1902 setCaption(m_activeDocument->description());
1903 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1904 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1905 m_activeDocument->setModified(false);
1906 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1907 m_fileRevert->setEnabled(true);
1911 bool MainWindow::saveFileAs()
1913 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1914 if (outputFile.isEmpty()) {
1917 if (QFile::exists(outputFile)) {
1918 // Show the file dialog again if the user does not want to overwrite the file
1919 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1920 return saveFileAs();
1922 return saveFileAs(outputFile);
1925 bool MainWindow::saveFile()
1927 if (!m_activeDocument) return true;
1928 if (m_activeDocument->url().isEmpty()) {
1929 return saveFileAs();
1931 bool result = saveFileAs(m_activeDocument->url().path());
1932 m_activeDocument->m_autosave->resize(0);
1937 void MainWindow::openFile()
1939 if (!m_startUrl.isEmpty()) {
1940 openFile(m_startUrl);
1941 m_startUrl = KUrl();
1944 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1945 if (url.isEmpty()) return;
1946 m_fileOpenRecent->addUrl(url);
1950 void MainWindow::openLastFile()
1952 KSharedConfigPtr config = KGlobal::config();
1953 KUrl::List urls = m_fileOpenRecent->urls();
1954 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1955 if (urls.isEmpty()) newFile(false);
1956 else openFile(urls.last());
1959 void MainWindow::openFile(const KUrl &url)
1961 // Make sure the url is a Kdenlive project file
1962 KMimeType::Ptr mime = KMimeType::findByUrl(url);
1963 if (mime.data()->is("application/x-compressed-tar")) {
1964 // Opening a compressed project file, we need to process it
1965 kDebug()<<"Opening archive, processing";
1966 ArchiveWidget *ar = new ArchiveWidget(url);
1967 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
1972 // Check if the document is already opened
1973 const int ct = m_timelineArea->count();
1974 bool isOpened = false;
1976 for (i = 0; i < ct; i++) {
1977 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1978 KdenliveDoc *doc = tab->document();
1979 if (doc->url() == url) {
1985 m_timelineArea->setCurrentIndex(i);
1989 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1991 // Check for backup file
1992 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1993 if (!staleFiles.isEmpty()) {
1994 if (KMessageBox::questionYesNo(this,
1995 i18n("Auto-saved files exist. Do you want to recover them now?"),
1996 i18n("File Recovery"),
1997 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1998 recoverFiles(staleFiles);
2001 // remove the stale files
2002 foreach(KAutoSaveFile * stale, staleFiles) {
2003 stale->open(QIODevice::ReadWrite);
2008 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2009 m_messageLabel->repaint();
2010 doOpenFile(url, NULL);
2013 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2015 if (!m_timelineArea->isEnabled()) return;
2016 m_fileRevert->setEnabled(true);
2018 // Recreate stopmotion widget on document change
2020 delete m_stopmotion;
2021 m_stopmotion = NULL;
2024 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2025 progressDialog.setAllowCancel(false);
2026 progressDialog.progressBar()->setMaximum(4);
2027 progressDialog.show();
2028 progressDialog.progressBar()->setValue(0);
2029 qApp->processEvents();
2031 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2033 progressDialog.progressBar()->setValue(1);
2034 progressDialog.progressBar()->setMaximum(4);
2035 progressDialog.setLabelText(i18n("Loading project"));
2036 qApp->processEvents();
2038 if (stale == NULL) {
2039 stale = new KAutoSaveFile(url, doc);
2040 doc->m_autosave = stale;
2042 doc->m_autosave = stale;
2043 doc->setUrl(stale->managedFile());
2044 doc->setModified(true);
2045 stale->setParent(doc);
2047 connectDocumentInfo(doc);
2049 progressDialog.progressBar()->setValue(2);
2050 qApp->processEvents();
2053 TrackView *trackView = new TrackView(doc, &ok, this);
2055 progressDialog.progressBar()->setValue(3);
2056 qApp->processEvents();
2058 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2060 m_timelineArea->setEnabled(false);
2061 m_projectList->setEnabled(false);
2062 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2063 slotGotProgressInfo(QString(), -1);
2064 newFile(false, true);
2067 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2068 trackView->setDuration(trackView->duration());
2069 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2071 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2072 slotGotProgressInfo(QString(), -1);
2073 m_projectMonitor->adjustRulerSize(trackView->duration());
2074 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2075 m_clipMonitor->refreshMonitor(true);
2077 progressDialog.progressBar()->setValue(4);
2080 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2082 foreach(KAutoSaveFile * stale, staleFiles) {
2083 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2084 // show an error message; we could not steal the lockfile
2085 // maybe another application got to the file before us?
2089 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2090 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2091 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2092 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2096 void MainWindow::parseProfiles(const QString &mltPath)
2098 //KdenliveSettings::setDefaulttmpfolder();
2099 if (!mltPath.isEmpty()) {
2100 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2101 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2104 if (KdenliveSettings::mltpath().isEmpty())
2105 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2107 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2108 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2109 if (!QFile::exists(meltPath))
2110 meltPath = KStandardDirs::findExe("melt");
2111 KdenliveSettings::setRendererpath(meltPath);
2114 if (KdenliveSettings::rendererpath().isEmpty()) {
2115 // Cannot find the MLT melt renderer, ask for location
2116 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2117 if (getUrl->exec() == QDialog::Rejected) {
2120 KUrl rendererPath = getUrl->selectedUrl();
2122 if (rendererPath.isEmpty()) ::exit(0);
2123 KdenliveSettings::setRendererpath(rendererPath.path());
2126 QStringList profilesFilter;
2127 profilesFilter << "*";
2128 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2129 if (profilesList.isEmpty()) {
2130 // Cannot find MLT path, try finding melt
2131 QString profilePath = KdenliveSettings::rendererpath();
2132 if (!profilePath.isEmpty()) {
2133 profilePath = profilePath.section('/', 0, -3);
2134 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2135 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2137 if (profilesList.isEmpty()) {
2138 // Cannot find the MLT profiles, ask for location
2139 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2140 getUrl->fileDialog()->setMode(KFile::Directory);
2141 if (getUrl->exec() == QDialog::Rejected) {
2144 KUrl mltPath = getUrl->selectedUrl();
2146 if (mltPath.isEmpty()) ::exit(0);
2147 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2148 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2152 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2154 // Parse again MLT profiles to build a list of available video formats
2155 if (profilesList.isEmpty()) parseProfiles();
2159 void MainWindow::slotEditProfiles()
2161 ProfilesDialog *w = new ProfilesDialog;
2162 if (w->exec() == QDialog::Accepted) {
2163 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2164 if (d) d->checkProfile();
2169 void MainWindow::slotDetectAudioDriver()
2171 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2172 leading to no audio output, see bug #934 */
2174 //decide which audio driver is really best, in some cases SDL is wrong
2175 if (KdenliveSettings::audiodrivername().isEmpty()) {
2177 KProcess readProcess;
2178 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2179 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2180 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2181 readProcess.setProgram("pactl", QStringList() << "stat");
2182 readProcess.execute(2000); // Kill it after 2 seconds
2184 QString result = QString(readProcess.readAllStandardOutput());
2185 kDebug() << "// / / / / / READING PACTL: ";
2187 if (!result.isEmpty()) {
2189 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2193 KdenliveSettings::setAutoaudiodrivername(driver);
2197 void MainWindow::slotEditProjectSettings()
2199 QPoint p = m_activeDocument->getTracksCount();
2200 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2202 if (w->exec() == QDialog::Accepted) {
2203 QString profile = w->selectedProfile();
2204 m_activeDocument->setProjectFolder(w->selectedFolder());
2206 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2208 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2209 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2210 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2211 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2212 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2213 m_activeDocument->setModified();
2214 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2215 if (m_activeDocument->clipManager()->clipsCount() > 0 && KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) == KMessageBox::Yes) {
2216 //TODO: rebuild all proxies
2217 //m_projectList->rebuildProxies();
2220 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2221 m_activeDocument->setModified();
2222 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2224 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2225 m_activeDocument->setModified();
2226 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2228 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2229 m_activeDocument->setModified();
2230 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2232 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2233 m_activeDocument->setModified();
2234 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2236 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2237 m_activeDocument->setModified();
2238 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2240 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2241 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2242 m_activeDocument->setModified();
2243 slotUpdateProxySettings();
2249 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2251 // Recreate the stopmotion widget if profile changes
2253 delete m_stopmotion;
2254 m_stopmotion = NULL;
2257 // Deselect current effect / transition
2258 m_effectStack->slotClipItemSelected(NULL, 0);
2259 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2260 m_clipMonitor->slotSetXml(NULL);
2261 bool updateFps = m_activeDocument->setProfilePath(profile);
2262 KdenliveSettings::setCurrent_profile(profile);
2263 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2264 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2266 m_activeDocument->clipManager()->clearUnusedProducers();
2267 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2268 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2269 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2270 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2271 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2272 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2273 if (updateFps) m_activeTimeline->updateProjectFps();
2274 m_activeDocument->setModified(true);
2275 m_commandStack->activeStack()->clear();
2276 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2277 slotUpdateMousePosition(0);
2278 // We need to desactivate & reactivate monitors to get a refresh
2279 //m_monitorManager->switchMonitors();
2283 void MainWindow::slotRenderProject()
2285 if (!m_renderWidget) {
2286 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2287 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2288 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2289 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2290 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2291 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2292 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2293 if (m_activeDocument) {
2294 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2295 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2296 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2297 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2300 slotCheckRenderStatus();
2301 m_renderWidget->show();
2302 m_renderWidget->showNormal();
2304 // What are the following lines supposed to do?
2305 //m_activeTimeline->tracksNumber();
2306 //m_renderWidget->enableAudio(false);
2307 //m_renderWidget->export_audio;
2310 void MainWindow::slotCheckRenderStatus()
2312 // Make sure there are no missing clips
2314 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2317 void MainWindow::setRenderingProgress(const QString &url, int progress)
2320 m_renderWidget->setRenderJob(url, progress);
2323 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2326 m_renderWidget->setRenderStatus(url, status, error);
2329 void MainWindow::slotCleanProject()
2331 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2332 m_projectList->cleanup();
2335 void MainWindow::slotUpdateMousePosition(int pos)
2337 if (m_activeDocument)
2338 switch (m_timecodeFormat->currentIndex()) {
2340 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2343 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2347 void MainWindow::slotUpdateDocumentState(bool modified)
2349 if (!m_activeDocument) return;
2350 setCaption(m_activeDocument->description(), modified);
2351 m_saveAction->setEnabled(modified);
2353 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2354 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2356 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2357 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2361 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2363 if (m_activeDocument) {
2364 if (m_activeDocument == doc) return;
2365 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2367 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2370 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2372 //m_projectMonitor->stop();
2373 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2374 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2375 if (m_activeDocument) {
2376 if (m_activeDocument == doc) return;
2377 if (m_activeTimeline) {
2378 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2379 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2380 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2381 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2382 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2383 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2384 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2385 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2387 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool)), m_activeDocument, SLOT(checkProjectClips(bool)));
2389 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2390 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2391 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2392 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2393 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2394 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2395 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2396 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2397 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2398 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2399 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2400 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2401 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2402 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2403 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2404 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2405 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2406 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2407 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2408 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2409 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2410 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2411 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2412 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2413 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2414 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2415 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2416 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2417 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2418 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2419 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2420 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2421 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2422 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2423 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2424 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2425 m_effectStack->clear();
2427 //m_activeDocument->setRenderer(NULL);
2428 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2429 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2430 m_clipMonitor->stop();
2432 KdenliveSettings::setCurrent_profile(doc->profilePath());
2433 KdenliveSettings::setProject_fps(doc->fps());
2434 m_monitorManager->resetProfiles(doc->timecode());
2435 m_projectList->setDocument(doc);
2436 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2437 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2438 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2439 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2440 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2441 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2443 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2444 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2445 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2447 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2450 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2451 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2452 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2453 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2454 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2455 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2456 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2457 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2458 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2459 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2460 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2461 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2462 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2463 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool)), doc, SLOT(checkProjectClips(bool)));
2465 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2466 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2467 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2468 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2469 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2471 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2472 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2473 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2475 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2476 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2477 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2478 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2480 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2481 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2482 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2483 m_zoomSlider->setValue(doc->zoom().x());
2484 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2485 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2486 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2487 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2489 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2490 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2492 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2493 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2495 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2496 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2497 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2498 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2499 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2500 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2501 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2502 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2503 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2504 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2505 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2507 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2508 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2509 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2510 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2511 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2514 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2515 m_activeTimeline = trackView;
2516 if (m_renderWidget) {
2517 slotCheckRenderStatus();
2518 m_renderWidget->setProfile(doc->mltProfile());
2519 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2520 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2521 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2523 //doc->setRenderer(m_projectMonitor->render);
2524 m_commandStack->setActiveStack(doc->commandStack());
2525 KdenliveSettings::setProject_display_ratio(doc->dar());
2526 //doc->clipManager()->checkAudioThumbs();
2528 //m_overView->setScene(trackView->projectScene());
2529 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2530 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2532 setCaption(doc->description(), doc->isModified());
2533 m_saveAction->setEnabled(doc->isModified());
2534 m_normalEditTool->setChecked(true);
2535 m_activeDocument = doc;
2536 m_activeTimeline->updateProjectFps();
2537 m_activeDocument->checkProjectClips();
2539 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2541 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2542 slotUpdateMousePosition(0);
2543 // set tool to select tool
2544 m_buttonSelectTool->setChecked(true);
2547 void MainWindow::slotZoneMoved(int start, int end)
2549 m_activeDocument->setZone(start, end);
2550 m_projectMonitor->slotZoneMoved(start, end);
2553 void MainWindow::slotGuidesUpdated()
2556 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2559 void MainWindow::slotEditKeys()
2561 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2562 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2563 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2567 void MainWindow::slotPreferences(int page, int option)
2570 * An instance of your dialog could be already created and could be
2571 * cached, in which case you want to display the cached dialog
2572 * instead of creating another one
2574 if (m_stopmotion) m_stopmotion->slotLive(false);
2575 if (KConfigDialog::showDialog("settings")) {
2576 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2577 if (page != -1) d->showPage(page, option);
2581 // KConfigDialog didn't find an instance of this dialog, so lets
2584 // Get the mappable actions in localized form
2585 QMap<QString, QString> actions;
2586 KActionCollection* collection = actionCollection();
2587 foreach (const QString& action_name, m_action_names) {
2588 actions[collection->action(action_name)->text()] = action_name;
2591 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2592 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2593 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2595 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2598 if (page != -1) dialog->showPage(page, option);
2601 void MainWindow::slotUpdateCaptureFolder()
2605 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2606 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2610 void MainWindow::updateConfiguration()
2612 //TODO: we should apply settings to all projects, not only the current one
2613 if (m_activeTimeline) {
2614 m_activeTimeline->refresh();
2615 m_activeTimeline->projectView()->checkAutoScroll();
2616 m_activeTimeline->projectView()->checkTrackHeight();
2617 if (m_activeDocument)
2618 m_activeDocument->clipManager()->checkAudioThumbs();
2620 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2621 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2622 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2623 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2625 // Update list of transcoding profiles
2627 #ifndef NO_JOGSHUTTLE
2628 activateShuttleDevice();
2629 #endif /* NO_JOGSHUTTLE */
2633 void MainWindow::slotSwitchSplitAudio()
2635 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2636 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2639 void MainWindow::slotSwitchVideoThumbs()
2641 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2642 if (m_activeTimeline)
2643 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2644 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2647 void MainWindow::slotSwitchAudioThumbs()
2649 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2650 if (m_activeTimeline) {
2651 m_activeTimeline->refresh();
2652 m_activeTimeline->projectView()->checkAutoScroll();
2653 if (m_activeDocument)
2654 m_activeDocument->clipManager()->checkAudioThumbs();
2656 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2659 void MainWindow::slotSwitchMarkersComments()
2661 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2662 if (m_activeTimeline)
2663 m_activeTimeline->refresh();
2664 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2667 void MainWindow::slotSwitchSnap()
2669 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2670 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2674 void MainWindow::slotDeleteItem()
2676 if (QApplication::focusWidget() &&
2677 QApplication::focusWidget()->parentWidget() &&
2678 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2679 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2680 m_projectList->slotRemoveClip();
2683 QWidget *widget = QApplication::focusWidget();
2685 if (widget == m_effectStackDock) {
2686 m_effectStack->slotItemDel();
2689 widget = widget->parentWidget();
2692 // effect stack has no focus
2693 if (m_activeTimeline)
2694 m_activeTimeline->projectView()->deleteSelectedClips();
2698 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2700 if (m_clipMonitor->isActive())
2701 m_clipMonitor->checkOverlay();
2702 m_clipMonitor->updateMarkers(clip);
2705 void MainWindow::slotAddClipMarker()
2707 DocClipBase *clip = NULL;
2709 if (m_projectMonitor->isActive()) {
2710 if (m_activeTimeline) {
2711 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2713 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2714 clip = item->baseClip();
2718 clip = m_clipMonitor->activeClip();
2719 pos = m_clipMonitor->position();
2722 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2725 QString id = clip->getId();
2726 CommentedTime marker(pos, i18n("Marker"));
2727 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2728 if (d.exec() == QDialog::Accepted)
2729 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2732 void MainWindow::slotDeleteClipMarker()
2734 DocClipBase *clip = NULL;
2736 if (m_projectMonitor->isActive()) {
2737 if (m_activeTimeline) {
2738 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2740 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2741 clip = item->baseClip();
2745 clip = m_clipMonitor->activeClip();
2746 pos = m_clipMonitor->position();
2749 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2753 QString id = clip->getId();
2754 QString comment = clip->markerComment(pos);
2755 if (comment.isEmpty()) {
2756 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2759 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2762 void MainWindow::slotDeleteAllClipMarkers()
2764 DocClipBase *clip = NULL;
2765 if (m_projectMonitor->isActive()) {
2766 if (m_activeTimeline) {
2767 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2769 clip = item->baseClip();
2773 clip = m_clipMonitor->activeClip();
2776 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2779 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2782 void MainWindow::slotEditClipMarker()
2784 DocClipBase *clip = NULL;
2786 if (m_projectMonitor->isActive()) {
2787 if (m_activeTimeline) {
2788 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2790 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2791 clip = item->baseClip();
2795 clip = m_clipMonitor->activeClip();
2796 pos = m_clipMonitor->position();
2799 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2803 QString id = clip->getId();
2804 QString oldcomment = clip->markerComment(pos);
2805 if (oldcomment.isEmpty()) {
2806 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2810 CommentedTime marker(pos, oldcomment);
2811 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2812 if (d.exec() == QDialog::Accepted) {
2813 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2814 if (d.newMarker().time() != pos) {
2815 // remove old marker
2816 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2821 void MainWindow::slotAddMarkerGuideQuickly()
2823 if (!m_activeTimeline || !m_activeDocument)
2826 if (m_clipMonitor->isActive()) {
2827 DocClipBase *clip = m_clipMonitor->activeClip();
2828 GenTime pos = m_clipMonitor->position();
2831 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2835 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2837 m_activeTimeline->projectView()->slotAddGuide(false);
2841 void MainWindow::slotAddGuide()
2843 if (m_activeTimeline)
2844 m_activeTimeline->projectView()->slotAddGuide();
2847 void MainWindow::slotInsertSpace()
2849 if (m_activeTimeline)
2850 m_activeTimeline->projectView()->slotInsertSpace();
2853 void MainWindow::slotRemoveSpace()
2855 if (m_activeTimeline)
2856 m_activeTimeline->projectView()->slotRemoveSpace();
2859 void MainWindow::slotInsertTrack(int ix)
2861 m_projectMonitor->activateMonitor();
2862 if (m_activeTimeline)
2863 m_activeTimeline->projectView()->slotInsertTrack(ix);
2864 if (m_activeDocument)
2865 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2868 void MainWindow::slotDeleteTrack(int ix)
2870 m_projectMonitor->activateMonitor();
2871 if (m_activeTimeline)
2872 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2873 if (m_activeDocument)
2874 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2877 void MainWindow::slotConfigTrack(int ix)
2879 m_projectMonitor->activateMonitor();
2880 if (m_activeTimeline)
2881 m_activeTimeline->projectView()->slotConfigTracks(ix);
2882 if (m_activeDocument)
2883 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2886 void MainWindow::slotEditGuide()
2888 if (m_activeTimeline)
2889 m_activeTimeline->projectView()->slotEditGuide();
2892 void MainWindow::slotDeleteGuide()
2894 if (m_activeTimeline)
2895 m_activeTimeline->projectView()->slotDeleteGuide();
2898 void MainWindow::slotDeleteAllGuides()
2900 if (m_activeTimeline)
2901 m_activeTimeline->projectView()->slotDeleteAllGuides();
2904 void MainWindow::slotCutTimelineClip()
2906 if (m_activeTimeline)
2907 m_activeTimeline->projectView()->cutSelectedClips();
2910 void MainWindow::slotInsertClipOverwrite()
2912 if (m_activeTimeline) {
2913 QStringList data = m_clipMonitor->getZoneInfo();
2914 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2918 void MainWindow::slotSelectTimelineClip()
2920 if (m_activeTimeline)
2921 m_activeTimeline->projectView()->selectClip(true);
2924 void MainWindow::slotSelectTimelineTransition()
2926 if (m_activeTimeline)
2927 m_activeTimeline->projectView()->selectTransition(true);
2930 void MainWindow::slotDeselectTimelineClip()
2932 if (m_activeTimeline)
2933 m_activeTimeline->projectView()->selectClip(false, true);
2936 void MainWindow::slotDeselectTimelineTransition()
2938 if (m_activeTimeline)
2939 m_activeTimeline->projectView()->selectTransition(false, true);
2942 void MainWindow::slotSelectAddTimelineClip()
2944 if (m_activeTimeline)
2945 m_activeTimeline->projectView()->selectClip(true, true);
2948 void MainWindow::slotSelectAddTimelineTransition()
2950 if (m_activeTimeline)
2951 m_activeTimeline->projectView()->selectTransition(true, true);
2954 void MainWindow::slotGroupClips()
2956 if (m_activeTimeline)
2957 m_activeTimeline->projectView()->groupClips();
2960 void MainWindow::slotUnGroupClips()
2962 if (m_activeTimeline)
2963 m_activeTimeline->projectView()->groupClips(false);
2966 void MainWindow::slotEditItemDuration()
2968 if (m_activeTimeline)
2969 m_activeTimeline->projectView()->editItemDuration();
2972 void MainWindow::slotAddProjectClip(KUrl url)
2974 if (m_activeDocument)
2975 m_activeDocument->slotAddClipFile(url, QString());
2978 void MainWindow::slotAddTransition(QAction *result)
2980 if (!result) return;
2981 QStringList info = result->data().toStringList();
2982 if (info.isEmpty()) return;
2983 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2984 if (m_activeTimeline && !transition.isNull()) {
2985 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2989 void MainWindow::slotAddVideoEffect(QAction *result)
2991 if (!result) return;
2992 const int EFFECT_VIDEO = 1;
2993 const int EFFECT_AUDIO = 2;
2994 QStringList info = result->data().toStringList();
2996 if (info.isEmpty() || info.size() < 3) return;
2997 QDomElement effect ;
2998 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
2999 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3000 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3001 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3003 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3004 if (!effect.isNull()) slotAddEffect(effect);
3005 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3009 void MainWindow::slotZoomIn()
3011 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3012 slotShowZoomSliderToolTip();
3015 void MainWindow::slotZoomOut()
3017 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3018 slotShowZoomSliderToolTip();
3021 void MainWindow::slotFitZoom()
3023 if (m_activeTimeline)
3024 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3027 void MainWindow::slotSetZoom(int value)
3029 value = qMax(m_zoomSlider->minimum(), value);
3030 value = qMin(m_zoomSlider->maximum(), value);
3032 if (m_activeTimeline)
3033 m_activeTimeline->slotChangeZoom(value);
3035 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3036 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3037 slotUpdateZoomSliderToolTip(value);
3039 m_zoomSlider->blockSignals(true);
3040 m_zoomSlider->setValue(value);
3041 m_zoomSlider->blockSignals(false);
3044 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3046 if (zoomlevel != -1)
3047 slotUpdateZoomSliderToolTip(zoomlevel);
3049 QPoint global = m_zoomSlider->rect().topLeft();
3050 global.ry() += m_zoomSlider->height() / 2;
3051 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3052 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3055 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3057 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3060 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3062 m_statusProgressBar->setValue(progress);
3063 if (progress >= 0) {
3064 if (!message.isEmpty())
3065 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3066 m_statusProgressBar->setVisible(true);
3067 } else if (progress == -2) {
3068 if (!message.isEmpty())
3069 m_messageLabel->setMessage(message, ErrorMessage);
3070 m_statusProgressBar->setVisible(false);
3072 m_messageLabel->setMessage(QString(), DefaultMessage);
3073 m_statusProgressBar->setVisible(false);
3077 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3079 if (clip->clipType() == TEXT) {
3080 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3081 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3082 // template text clip
3084 // Get the list of existing templates
3086 filter << "*.kdenlivetitle";
3087 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3089 QDialog *dia = new QDialog(this);
3090 Ui::TemplateClip_UI dia_ui;
3091 dia_ui.setupUi(dia);
3093 const QString templatePath = clip->getProperty("resource");
3094 for (int i = 0; i < templateFiles.size(); ++i) {
3095 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3096 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3098 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3099 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3100 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3101 //warning: setting base directory doesn't work??
3102 KUrl startDir(titlepath);
3103 dia_ui.template_list->fileDialog()->setUrl(startDir);
3104 dia_ui.description->setText(clip->getProperty("description"));
3105 if (dia->exec() == QDialog::Accepted) {
3106 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3107 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3109 QMap <QString, QString> newprops;
3111 if (KUrl(textTemplate).path() != templatePath) {
3112 // The template was changed
3113 newprops.insert("resource", textTemplate);
3116 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3117 newprops.insert("description", dia_ui.description->toPlainText());
3120 QString newtemplate = newprops.value("xmltemplate");
3121 if (newtemplate.isEmpty()) newtemplate = templatePath;
3123 // template modified we need to update xmldata
3124 QString description = newprops.value("description");
3125 if (description.isEmpty()) description = clip->getProperty("description");
3126 else newprops.insert("templatetext", description);
3127 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3128 if (!newprops.isEmpty()) {
3129 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3130 m_activeDocument->commandStack()->push(command);
3136 QString path = clip->getProperty("resource");
3137 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3139 doc.setContent(clip->getProperty("xmldata"));
3140 dia_ui->setXml(doc);
3141 if (dia_ui->exec() == QDialog::Accepted) {
3142 QMap <QString, QString> newprops;
3143 newprops.insert("xmldata", dia_ui->xml().toString());
3144 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3145 // duration changed, we need to update duration
3146 newprops.insert("out", QString::number(dia_ui->outPoint()));
3147 int currentLength = QString(clip->producerProperty("length")).toInt();
3148 if (currentLength <= dia_ui->outPoint())
3149 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3150 else newprops.insert("length", clip->producerProperty("length"));
3152 if (!path.isEmpty()) {
3153 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3154 if (KMessageBox::questionYesNo(this, i18n("You are editing an external title clip (%1). Do you want to save your changes to the title file or save the changes for this project only?", path), i18n("Save Title"), KGuiItem(i18n("Save to title file")), KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
3155 // save to external file
3156 dia_ui->saveTitle(path);
3157 } else newprops.insert("resource", QString());
3159 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3160 m_activeDocument->commandStack()->push(command);
3161 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3162 m_activeDocument->setModified(true);
3166 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3170 // any type of clip but a title
3171 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3172 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3173 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)));
3178 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3180 if (newprops.isEmpty()) return;
3181 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3182 m_activeDocument->commandStack()->push(command);
3183 m_activeDocument->setModified();
3186 // update clip occurences in timeline
3187 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3192 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3194 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3195 if (dia.exec() == QDialog::Accepted) {
3196 QUndoCommand *command = new QUndoCommand();
3197 command->setText(i18n("Edit clips"));
3198 QMap <QString, QString> newImageProps = dia.properties();
3199 // Transparency setting applies only for images
3200 QMap <QString, QString> newProps = newImageProps;
3201 newProps.remove("transparency");
3203 for (int i = 0; i < cliplist.count(); i++) {
3204 DocClipBase *clip = cliplist.at(i);
3205 if (clip->clipType() == IMAGE)
3206 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3208 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3210 m_activeDocument->commandStack()->push(command);
3211 for (int i = 0; i < cliplist.count(); i++)
3212 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3216 void MainWindow::customEvent(QEvent* e)
3218 if (e->type() == QEvent::User)
3219 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3221 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3227 m_effectStack->raiseWindow(m_effectStackDock);
3230 void MainWindow::slotActivateTransitionView(Transition *t)
3233 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3236 void MainWindow::slotSnapRewind()
3238 if (m_projectMonitor->isActive()) {
3239 if (m_activeTimeline)
3240 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3242 m_clipMonitor->slotSeekToPreviousSnap();
3246 void MainWindow::slotSnapForward()
3248 if (m_projectMonitor->isActive()) {
3249 if (m_activeTimeline)
3250 m_activeTimeline->projectView()->slotSeekToNextSnap();
3252 m_clipMonitor->slotSeekToNextSnap();
3256 void MainWindow::slotClipStart()
3258 if (m_projectMonitor->isActive()) {
3259 if (m_activeTimeline)
3260 m_activeTimeline->projectView()->clipStart();
3264 void MainWindow::slotClipEnd()
3266 if (m_projectMonitor->isActive()) {
3267 if (m_activeTimeline)
3268 m_activeTimeline->projectView()->clipEnd();
3272 void MainWindow::slotZoneStart()
3274 if (m_projectMonitor->isActive())
3275 m_projectMonitor->slotZoneStart();
3277 m_clipMonitor->slotZoneStart();
3280 void MainWindow::slotZoneEnd()
3282 if (m_projectMonitor->isActive())
3283 m_projectMonitor->slotZoneEnd();
3285 m_clipMonitor->slotZoneEnd();
3288 void MainWindow::slotChangeTool(QAction * action)
3290 if (action == m_buttonSelectTool)
3291 slotSetTool(SELECTTOOL);
3292 else if (action == m_buttonRazorTool)
3293 slotSetTool(RAZORTOOL);
3294 else if (action == m_buttonSpacerTool)
3295 slotSetTool(SPACERTOOL);
3298 void MainWindow::slotChangeEdit(QAction * action)
3300 if (!m_activeTimeline)
3303 if (action == m_overwriteEditTool)
3304 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3305 else if (action == m_insertEditTool)
3306 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3308 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3311 void MainWindow::slotSetTool(PROJECTTOOL tool)
3313 if (m_activeDocument && m_activeTimeline) {
3314 //m_activeDocument->setTool(tool);
3318 message = i18n("Ctrl + click to use spacer on current track only");
3321 message = i18n("Click on a clip to cut it");
3324 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3327 m_messageLabel->setMessage(message, InformationMessage);
3328 m_activeTimeline->projectView()->setTool(tool);
3332 void MainWindow::slotCopy()
3334 if (m_activeDocument && m_activeTimeline)
3335 m_activeTimeline->projectView()->copyClip();
3338 void MainWindow::slotPaste()
3340 if (m_activeDocument && m_activeTimeline)
3341 m_activeTimeline->projectView()->pasteClip();
3344 void MainWindow::slotPasteEffects()
3346 if (m_activeDocument && m_activeTimeline)
3347 m_activeTimeline->projectView()->pasteClipEffects();
3350 void MainWindow::slotFind()
3352 if (!m_activeDocument || !m_activeTimeline) return;
3353 m_projectSearch->setEnabled(false);
3354 m_findActivated = true;
3355 m_findString.clear();
3356 m_activeTimeline->projectView()->initSearchStrings();
3357 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3358 m_findTimer.start(5000);
3359 qApp->installEventFilter(this);
3362 void MainWindow::slotFindNext()
3364 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3365 statusBar()->showMessage(i18n("Found: %1", m_findString));
3367 statusBar()->showMessage(i18n("Reached end of project"));
3368 m_findTimer.start(4000);
3371 void MainWindow::findAhead()
3373 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3374 m_projectSearchNext->setEnabled(true);
3375 statusBar()->showMessage(i18n("Found: %1", m_findString));
3377 m_projectSearchNext->setEnabled(false);
3378 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3382 void MainWindow::findTimeout()
3384 m_projectSearchNext->setEnabled(false);
3385 m_findActivated = false;
3386 m_findString.clear();
3387 statusBar()->showMessage(i18n("Find stopped"), 3000);
3388 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3389 m_projectSearch->setEnabled(true);
3390 removeEventFilter(this);
3393 void MainWindow::slotClipInTimeline(const QString &clipId)
3395 if (m_activeTimeline && m_activeDocument) {
3396 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3398 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3399 inTimelineMenu->clear();
3401 QList <QAction *> actionList;
3403 for (int i = 0; i < matching.count(); ++i) {
3404 QString track = QString::number(matching.at(i).track);
3405 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3407 QAction *a = new QAction(track + ": " + start, this);
3408 a->setData(QStringList() << track << start);
3409 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3410 while (j < actionList.count()) {
3411 if (actionList.at(j)->text() > a->text()) break;
3414 actionList.insert(j, a);
3416 inTimelineMenu->addActions(actionList);
3418 if (matching.empty())
3419 inTimelineMenu->setEnabled(false);
3421 inTimelineMenu->setEnabled(true);
3425 void MainWindow::slotClipInProjectTree()
3427 if (m_activeTimeline) {
3428 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3429 if (clipIds.isEmpty())
3431 m_projectListDock->raise();
3432 for (int i = 0; i < clipIds.count(); i++)
3433 m_projectList->selectItemById(clipIds.at(i));
3434 if (m_projectMonitor->isActive())
3435 slotSwitchMonitors();
3439 /*void MainWindow::slotClipToProjectTree()
3441 if (m_activeTimeline) {
3442 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3443 if (clips.isEmpty()) return;
3444 for (int i = 0; i < clips.count(); i++) {
3445 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3447 //m_projectList->selectItemById(clipIds.at(i));
3451 void MainWindow::slotSelectClipInTimeline()
3453 if (m_activeTimeline) {
3454 QAction *action = qobject_cast<QAction *>(sender());
3455 QStringList data = action->data().toStringList();
3456 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3460 void MainWindow::keyPressEvent(QKeyEvent *ke)
3462 if (m_findActivated) {
3463 if (ke->key() == Qt::Key_Backspace) {
3464 m_findString = m_findString.left(m_findString.length() - 1);
3466 if (!m_findString.isEmpty())
3471 m_findTimer.start(4000);
3474 } else if (ke->key() == Qt::Key_Escape) {
3478 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3479 m_findString += ke->text();
3483 m_findTimer.start(4000);
3488 KXmlGuiWindow::keyPressEvent(ke);
3493 /** Gets called when the window gets hidden */
3494 void MainWindow::hideEvent(QHideEvent */*event*/)
3496 if (isMinimized() && m_monitorManager)
3497 m_monitorManager->stopActiveMonitor();
3500 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3502 if (m_findActivated) {
3503 if (event->type() == QEvent::ShortcutOverride) {
3504 QKeyEvent* ke = (QKeyEvent*) event;
3505 if (ke->text().trimmed().isEmpty()) return false;
3512 // pass the event on to the parent class
3513 return QMainWindow::eventFilter(obj, event);
3518 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3520 KDialog *dialog = new KDialog(this);
3521 dialog->setCaption("Save clip zone");
3522 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3524 QWidget *widget = new QWidget(dialog);
3525 dialog->setMainWidget(widget);
3527 QVBoxLayout *vbox = new QVBoxLayout(widget);
3528 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3529 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3530 path.append("untitled.mlt");
3531 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3532 url->setFilter("video/mlt-playlist");
3533 QLabel *label2 = new QLabel(i18n("Description:"), this);
3534 KLineEdit *edit = new KLineEdit(this);
3535 vbox->addWidget(label1);
3536 vbox->addWidget(url);
3537 vbox->addWidget(label2);
3538 vbox->addWidget(edit);
3539 if (dialog->exec() == QDialog::Accepted)
3540 render->saveZone(url->url(), edit->text(), zone);
3544 void MainWindow::slotSetInPoint()
3546 if (m_clipMonitor->isActive())
3547 m_clipMonitor->slotSetZoneStart();
3549 m_projectMonitor->slotSetZoneStart();
3550 //else m_activeTimeline->projectView()->setInPoint();
3553 void MainWindow::slotSetOutPoint()
3555 if (m_clipMonitor->isActive())
3556 m_clipMonitor->slotSetZoneEnd();
3558 m_projectMonitor->slotSetZoneEnd();
3559 // else m_activeTimeline->projectView()->setOutPoint();
3562 void MainWindow::slotResizeItemStart()
3564 if (m_activeTimeline)
3565 m_activeTimeline->projectView()->setInPoint();
3568 void MainWindow::slotResizeItemEnd()
3570 if (m_activeTimeline)
3571 m_activeTimeline->projectView()->setOutPoint();
3574 int MainWindow::getNewStuff(const QString &configFile)
3576 KNS3::Entry::List entries;
3577 #if KDE_IS_VERSION(4,3,80)
3578 KNS3::DownloadDialog dialog(configFile);
3580 entries = dialog.changedEntries();
3581 foreach(const KNS3::Entry & entry, entries) {
3582 if (entry.status() == KNS3::Entry::Installed)
3583 kDebug() << "// Installed files: " << entry.installedFiles();
3586 KNS::Engine engine(0);
3587 if (engine.init(configFile))
3588 entries = engine.downloadDialogModal(this);
3589 foreach(KNS::Entry * entry, entries) {
3590 if (entry->status() == KNS::Entry::Installed)
3591 kDebug() << "// Installed files: " << entry->installedFiles();
3593 #endif /* KDE_IS_VERSION(4,3,80) */
3594 return entries.size();
3597 void MainWindow::slotGetNewTitleStuff()
3599 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3600 TitleWidget::refreshTitleTemplates();
3603 void MainWindow::slotGetNewLumaStuff()
3605 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3606 initEffects::refreshLumas();
3607 m_activeTimeline->projectView()->reloadTransitionLumas();
3611 void MainWindow::slotGetNewRenderStuff()
3613 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3615 m_renderWidget->reloadProfiles();
3618 void MainWindow::slotGetNewMltProfileStuff()
3620 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3621 // update the list of profiles in settings dialog
3622 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3628 void MainWindow::slotAutoTransition()
3630 if (m_activeTimeline)
3631 m_activeTimeline->projectView()->autoTransition();
3634 void MainWindow::slotSplitAudio()
3636 if (m_activeTimeline)
3637 m_activeTimeline->projectView()->splitAudio();
3640 void MainWindow::slotUpdateClipType(QAction *action)
3642 if (m_activeTimeline) {
3643 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3644 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3645 else m_activeTimeline->projectView()->setAudioAndVideo();
3649 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3651 // We must stop the monitors since we create a new on in the dvd wizard
3652 m_clipMonitor->stop();
3653 m_projectMonitor->stop();
3654 DvdWizard w(url, profile, this);
3656 m_projectMonitor->start();
3659 void MainWindow::slotShowTimeline(bool show)
3661 if (show == false) {
3662 m_timelineState = saveState();
3663 centralWidget()->setHidden(true);
3665 centralWidget()->setHidden(false);
3666 restoreState(m_timelineState);
3670 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3672 //TODO: is there a way to maximize current widget?
3675 m_timelineState = saveState();
3676 QWidget *par = focusWidget()->parentWidget();
3677 while (par->parentWidget() && par->parentWidget() != this)
3678 par = par->parentWidget();
3679 kDebug() << "CURRENT WIDGET: " << par->objectName();
3682 //centralWidget()->setHidden(false);
3683 //restoreState(m_timelineState);
3687 void MainWindow::loadTranscoders()
3689 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3692 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3693 KConfigGroup transConfig(config, "Transcoding");
3695 QMap< QString, QString > profiles = transConfig.entryMap();
3696 QMapIterator<QString, QString> i(profiles);
3697 while (i.hasNext()) {
3699 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3700 QAction *a = transMenu->addAction(i.key());
3702 if (data.count() > 1)
3703 a->setToolTip(data.at(1));
3704 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3708 void MainWindow::slotTranscode(KUrl::List urls)
3713 if (urls.isEmpty()) {
3714 QAction *action = qobject_cast<QAction *>(sender());
3715 QStringList data = action->data().toStringList();
3716 params = data.at(0);
3717 if (data.count() > 1) desc = data.at(1);
3718 if (data.count() > 2) condition = data.at(2);
3719 urls << m_projectList->getConditionalUrls(condition);
3720 urls.removeAll(KUrl());
3722 if (urls.isEmpty()) {
3723 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3726 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3727 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3729 //QProcess::startDetached("ffmpeg", parameters);
3732 void MainWindow::slotTranscodeClip()
3734 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3735 if (urls.isEmpty()) return;
3736 slotTranscode(urls);
3739 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3741 if (m_activeDocument == NULL) return;
3742 QMapIterator<QString, QString> i(props);
3743 while (i.hasNext()) {
3745 m_activeDocument->setDocumentProperty(i.key(), i.value());
3747 m_activeDocument->setModified(true);
3751 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3753 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3755 QString playlistPath;
3758 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3759 QString path = m_renderWidget->getFreeScriptName();
3760 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3761 if (!ok || scriptPath.isEmpty()) return;
3762 scriptPath.prepend(scriptsFolder);
3763 QFile f(scriptPath);
3765 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3768 playlistPath = scriptPath + ".mlt";
3770 KTemporaryFile temp;
3771 temp.setAutoRemove(false);
3772 temp.setSuffix(".mlt");
3774 playlistPath = temp.fileName();
3776 QString playlistContent = m_projectMonitor->sceneList();
3777 if (!chapterFile.isEmpty()) {
3780 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3782 in = m_activeTimeline->inPoint();
3783 out = m_activeTimeline->outPoint();
3786 QDomElement chapters = doc.createElement("chapters");
3787 chapters.setAttribute("fps", m_activeDocument->fps());
3788 doc.appendChild(chapters);
3790 QDomElement guidesxml = m_activeDocument->guidesXml();
3791 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3792 for (int i = 0; i < nodes.count(); i++) {
3793 QDomElement e = nodes.item(i).toElement();
3795 QString comment = e.attribute("comment");
3796 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3797 if (time >= in && time < out) {
3798 if (zoneOnly) time = time - in;
3799 QDomElement chapter = doc.createElement("chapter");
3800 chapters.appendChild(chapter);
3801 chapter.setAttribute("title", comment);
3802 chapter.setAttribute("time", time);
3806 if (chapters.childNodes().count() > 0) {
3807 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3808 // Always insert a guide in pos 0
3809 QDomElement chapter = doc.createElement("chapter");
3810 chapters.insertBefore(chapter, QDomNode());
3811 chapter.setAttribute("title", i18n("Start"));
3812 chapter.setAttribute("time", "0");
3814 // save chapters file
3815 QFile file(chapterFile);
3816 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3817 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3819 file.write(doc.toString().toUtf8());
3820 if (file.error() != QFile::NoError) {
3821 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3828 if (m_renderWidget->automaticAudioExport()) {
3829 exportAudio = m_activeTimeline->checkProjectAudio();
3830 } else exportAudio = m_renderWidget->selectedAudioExport();
3832 // Do we want proxy rendering
3833 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3835 doc.setContent(playlistContent);
3836 QString root = doc.documentElement().attribute("root");
3838 // replace proxy clips with originals
3839 QMap <QString, QString> proxies = m_projectList->getProxies();
3841 QDomNodeList producers = doc.elementsByTagName("producer");
3842 QString producerResource;
3844 for (uint n = 0; n < producers.length(); n++) {
3845 QDomElement e = producers.item(n).toElement();
3846 producerResource = EffectsList::property(e, "resource");
3847 if (producerResource.isEmpty()) continue;
3848 if (!producerResource.startsWith("/")) {
3849 producerResource.prepend(root + "/");
3851 if (producerResource.contains('?')) {
3852 // slowmotion producer
3853 suffix = "?" + producerResource.section('?', 1);
3854 producerResource = producerResource.section('?', 0, 0);
3856 else suffix.clear();
3857 if (!producerResource.isEmpty()) {
3858 if (proxies.contains(producerResource)) {
3859 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3860 // We need to delete the "aspect_ratio" property because proxy clips
3861 // sometimes have different ratio than original clips
3862 EffectsList::removeProperty(e, "aspect_ratio");
3867 /*QMapIterator<QString, QString> i(proxies);
3868 while (i.hasNext()) {
3870 // Replace all keys with their values (proxy path with original path)
3871 QString key = i.key();
3872 playlistContent.replace(key, i.value());
3873 if (!root.isEmpty() && key.startsWith(root)) {
3874 // in case the resource path in MLT playlist is relative
3875 key.remove(0, root.count() + 1);
3876 playlistContent.replace(key, i.value());
3879 playlistContent = doc.toString();
3882 // Do save scenelist
3883 QFile file(playlistPath);
3884 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3885 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3888 file.write(playlistContent.toUtf8());
3889 if (file.error() != QFile::NoError) {
3890 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3895 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3898 void MainWindow::slotUpdateTimecodeFormat(int ix)
3900 KdenliveSettings::setFrametimecode(ix == 1);
3901 m_clipMonitor->updateTimecodeFormat();
3902 m_projectMonitor->updateTimecodeFormat();
3903 m_transitionConfig->updateTimecodeFormat();
3904 m_effectStack->updateTimecodeFormat();
3905 //m_activeTimeline->projectView()->clearSelection();
3906 m_activeTimeline->updateRuler();
3909 void MainWindow::slotRemoveFocus()
3911 statusBar()->setFocus();
3912 statusBar()->clearFocus();
3915 void MainWindow::slotRevert()
3917 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;
3918 KUrl url = m_activeDocument->url();
3919 if (closeCurrentDocument(false))
3920 doOpenFile(url, NULL);
3924 void MainWindow::slotShutdown()
3926 if (m_activeDocument) m_activeDocument->setModified(false);
3928 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3929 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3930 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3931 smserver.call("logout", 1, 2, 2);
3932 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3933 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3934 smserver.call("Shutdown");
3938 void MainWindow::slotUpdateTrackInfo()
3940 if (m_activeDocument)
3941 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3944 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3946 // Load the theme file
3948 if (action == NULL) theme = themename;
3949 else theme = action->data().toString();
3950 KdenliveSettings::setColortheme(theme);
3951 // Make palette for all widgets.
3952 QPalette plt = kapp->palette();
3953 if (theme.isEmpty()) {
3954 plt = QApplication::desktop()->palette();
3956 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3958 #if KDE_IS_VERSION(4,6,3)
3959 plt = KGlobalSettings::createNewApplicationPalette(config);
3961 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
3962 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
3963 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
3964 QPalette::Disabled };
3965 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
3966 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
3968 for ( int i = 0; i < 3 ; i++ ) {
3969 QPalette::ColorGroup state = states[i];
3970 KColorScheme schemeView(state, KColorScheme::View, config);
3971 KColorScheme schemeWindow(state, KColorScheme::Window, config);
3972 KColorScheme schemeButton(state, KColorScheme::Button, config);
3973 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
3975 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
3976 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
3977 plt.setBrush( state, QPalette::Base, schemeView.background() );
3978 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
3979 plt.setBrush( state, QPalette::Button, schemeButton.background() );
3980 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
3981 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
3982 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
3983 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
3984 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
3986 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
3987 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
3988 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
3989 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
3990 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
3992 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
3993 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
3994 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
3999 kapp->setPalette(plt);
4000 const QObjectList children = statusBar()->children();
4002 foreach(QObject * child, children) {
4003 if (child->isWidgetType())
4004 ((QWidget*)child)->setPalette(plt);
4005 const QObjectList subchildren = child->children();
4006 foreach(QObject * subchild, subchildren) {
4007 if (subchild->isWidgetType())
4008 ((QWidget*)subchild)->setPalette(plt);
4011 if (m_activeTimeline) {
4012 m_activeTimeline->projectView()->updatePalette();
4017 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4019 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4020 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4021 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4022 const QSize bitsSize(24, 2);
4023 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4024 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4026 QPixmap pixmap(23, 16);
4027 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4029 KConfigGroup group(config, "WM");
4030 QPainter p(&pixmap);
4031 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4032 p.fillRect(1, 1, 7, 7, windowScheme.background());
4033 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4035 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4036 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4037 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4039 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4040 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4042 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4043 p.fillRect(1, 8, 7, 7, viewScheme.background());
4044 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4046 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4047 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4048 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4050 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4051 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4057 void MainWindow::slotSwitchMonitors()
4059 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4060 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4061 else m_projectList->focusTree();
4064 void MainWindow::slotSwitchFullscreen()
4066 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4067 else m_clipMonitor->slotSwitchFullScreen();
4070 void MainWindow::slotInsertZoneToTree()
4072 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4073 QStringList info = m_clipMonitor->getZoneInfo();
4074 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4077 void MainWindow::slotInsertZoneToTimeline()
4079 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4080 QStringList info = m_clipMonitor->getZoneInfo();
4081 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4085 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4087 if (m_activeDocument && m_activeTimeline) {
4088 if (!ids.isEmpty()) {
4089 for (int i = 0; i < ids.size(); ++i) {
4090 m_activeTimeline->slotDeleteClip(ids.at(i));
4092 m_activeDocument->clipManager()->slotDeleteClips(ids);
4094 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4095 m_activeDocument->setModified(true);
4099 void MainWindow::slotShowTitleBars(bool show)
4101 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4102 for (int i = 0; i < docks.count(); i++) {
4103 QDockWidget* dock = docks.at(i);
4105 dock->setTitleBarWidget(0);
4107 if (!dock->isFloating()) {
4108 dock->setTitleBarWidget(new QWidget);
4112 KdenliveSettings::setShowtitlebars(show);
4115 void MainWindow::slotSwitchTitles()
4117 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4120 QString MainWindow::getMimeType(bool open)
4122 QString mimetype = "application/x-kdenlive";
4123 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4125 mimetype = "*.kdenlive";
4126 if (open) mimetype.append(" *.tar.gz");
4128 else if (open) mimetype.append(" application/x-compressed-tar");
4132 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4135 m_projectMonitor->render->sendFrameForAnalysis = true;
4138 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4139 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4146 qDebug() << "Any scope accepting new frames? " << request;
4149 m_projectMonitor->render->sendFrameForAnalysis = false;
4153 void MainWindow::slotUpdateGfxScopeFrameRequest()
4155 // We need a delay to make sure widgets are hidden after a close event for example
4156 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4159 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4162 bool request = false;
4163 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4164 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4165 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4171 if (!m_projectMonitor->effectSceneDisplayed()) {
4172 m_projectMonitor->render->sendFrameForAnalysis = false;
4174 m_clipMonitor->render->sendFrameForAnalysis = false;
4176 m_recMonitor->analyseFrames(false);
4178 m_projectMonitor->render->sendFrameForAnalysis = true;
4179 m_clipMonitor->render->sendFrameForAnalysis = true;
4181 m_recMonitor->analyseFrames(true);
4185 void MainWindow::slotUpdateAudioScopeFrameRequest()
4187 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4190 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4192 bool request = false;
4193 for (int i = 0; i < m_audioScopesList.count(); i++) {
4194 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4195 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4200 // Handle audio signal separately (no common interface)
4201 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4202 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4206 qDebug() << "Scopes Requesting Audio data: " << request;
4208 KdenliveSettings::setMonitor_audio(request);
4209 m_monitorManager->slotUpdateAudioMonitoring();
4212 void MainWindow::slotUpdateColorScopes()
4214 bool request = false;
4215 kDebug()<<"// UPDATE SCOPES";
4216 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4217 // Check if we need the renderer to send a new frame for update
4218 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4219 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4222 m_monitorManager->activeRenderer()->sendFrameUpdate();
4226 void MainWindow::slotClearColorScopes()
4228 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4229 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4233 void MainWindow::slotOpenStopmotion()
4235 if (m_stopmotion == NULL) {
4236 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4237 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4238 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4239 // Check if we need the renderer to send a new frame for update
4240 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4241 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4242 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4245 m_stopmotion->show();
4248 void MainWindow::slotDeleteClip(const QString &id)
4250 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4251 for (int i = 0; i < list.size(); ++i) {
4252 list.at(i)->disableClipId(id);
4254 m_projectList->slotDeleteClip(id);
4257 void MainWindow::slotUpdateProxySettings()
4259 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4260 if (KdenliveSettings::enableproxy())
4261 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4262 m_projectList->updateProxyConfig();
4265 void MainWindow::slotInsertNotesTimecode()
4267 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4268 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4269 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4272 void MainWindow::slotArchiveProject()
4274 QList <DocClipBase*> list = m_projectList->documentClipList();
4275 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4276 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4281 #include "mainwindow.moc"