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"
65 #include <KApplication>
69 #include <KActionCollection>
70 #include <KActionCategory>
71 #include <KStandardAction>
72 #include <KShortcutsDialog>
73 #include <KFileDialog>
74 #include <KMessageBox>
76 #include <KIO/NetAccess>
79 #include <KConfigDialog>
80 #include <KXMLGUIFactory>
82 #include <kstandarddirs.h>
83 #include <KUrlRequesterDialog>
84 #include <KTemporaryFile>
86 #include <KActionMenu>
89 #include <ktogglefullscreenaction.h>
91 #include <KNotification>
92 #include <KNotifyConfigWidget>
93 #if KDE_IS_VERSION(4,3,80)
94 #include <knewstuff3/downloaddialog.h>
95 #include <knewstuff3/knewstuffaction.h>
97 #include <knewstuff2/engine.h>
98 #include <knewstuff2/ui/knewstuffaction.h>
100 #endif /* KDE_IS_VERSION(4,3,80) */
102 #include <KColorScheme>
103 #include <KProgressDialog>
105 #include <QTextStream>
109 #include <QInputDialog>
110 #include <QDesktopWidget>
115 // Uncomment for deeper debugging
116 //#define DEBUG_MAINW
122 static const char version[] = VERSION;
124 static const int ID_TIMELINE_POS = 0;
130 Q_DECLARE_METATYPE(QVector<int16_t>)
132 EffectsList MainWindow::videoEffects;
133 EffectsList MainWindow::audioEffects;
134 EffectsList MainWindow::customEffects;
135 EffectsList MainWindow::transitions;
137 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
138 KXmlGuiWindow(parent),
139 m_activeDocument(NULL),
140 m_activeTimeline(NULL),
141 m_renderWidget(NULL),
142 #ifndef NO_JOGSHUTTLE
145 #endif /* NO_JOGSHUTTLE */
146 m_findActivated(false),
149 qRegisterMetaType<QVector<int16_t> > ();
150 // Create DBus interface
151 new MainWindowAdaptor(this);
152 QDBusConnection dbus = QDBusConnection::sessionBus();
153 dbus.registerObject("/MainWindow", this);
155 setlocale(LC_NUMERIC, "POSIX");
156 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
157 setFont(KGlobalSettings::toolBarFont());
158 parseProfiles(MltPath);
159 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
160 m_commandStack = new QUndoGroup;
161 setDockNestingEnabled(true);
162 m_timelineArea = new KTabWidget(this);
163 m_timelineArea->setTabReorderingEnabled(true);
164 m_timelineArea->setTabBarHidden(true);
165 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
166 m_timelineArea->setMinimumHeight(200);
168 QToolButton *closeTabButton = new QToolButton;
169 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
170 closeTabButton->setIcon(KIcon("tab-close"));
171 closeTabButton->adjustSize();
172 closeTabButton->setToolTip(i18n("Close the current tab"));
173 m_timelineArea->setCornerWidget(closeTabButton);
174 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
176 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
177 m_findTimer.setSingleShot(true);
179 // FIXME: the next call returns a newly allocated object, which leaks
180 initEffects::parseEffectFiles();
181 //initEffects::parseCustomEffectsFile();
183 m_monitorManager = new MonitorManager();
185 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
186 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
191 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
192 m_projectListDock->setObjectName("project_tree");
193 m_projectList = new ProjectList();
194 m_projectListDock->setWidget(m_projectList);
195 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
197 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
198 m_clipMonitorDock->setObjectName("clip_monitor");
199 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
200 m_clipMonitorDock->setWidget(m_clipMonitor);
202 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
203 m_projectMonitorDock->setObjectName("project_monitor");
204 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
205 m_projectMonitorDock->setWidget(m_projectMonitor);
208 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
209 m_recMonitorDock->setObjectName("record_monitor");
210 m_recMonitor = new RecMonitor("record");
211 m_recMonitorDock->setWidget(m_recMonitor);
212 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
213 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
216 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
217 m_notesDock->setObjectName("notes_widget");
218 m_notesWidget = new KTextEdit();
219 m_notesWidget->setTabChangesFocus(true);
220 #if KDE_IS_VERSION(4,4,0)
221 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
223 m_notesDock->setWidget(m_notesWidget);
224 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
226 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
227 m_effectStackDock->setObjectName("effect_stack");
228 m_effectStack = new EffectStackView(m_projectMonitor);
229 m_effectStackDock->setWidget(m_effectStack);
230 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
232 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
233 m_transitionConfigDock->setObjectName("transition");
234 m_transitionConfig = new TransitionSettings(m_projectMonitor);
235 m_transitionConfigDock->setWidget(m_transitionConfig);
236 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
238 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
239 m_effectListDock->setObjectName("effect_list");
240 m_effectList = new EffectsListView();
241 m_effectListDock->setWidget(m_effectList);
242 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
244 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
245 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
246 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
247 m_vectorscopeDock->setWidget(m_vectorscope);
248 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
249 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
250 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
251 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
252 m_gfxScopesList.append(m_vectorscopeDock);
254 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
255 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
256 m_waveformDock->setObjectName(m_waveform->widgetName());
257 m_waveformDock->setWidget(m_waveform);
258 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
259 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
260 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
261 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
262 m_gfxScopesList.append(m_waveformDock);
264 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
265 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
266 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
267 m_RGBParadeDock->setWidget(m_RGBParade);
268 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
269 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
270 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
271 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
272 m_gfxScopesList.append(m_RGBParadeDock);
274 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
275 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
276 m_histogramDock->setObjectName(m_histogram->widgetName());
277 m_histogramDock->setWidget(m_histogram);
278 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
279 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
280 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
281 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
282 m_gfxScopesList.append(m_histogramDock);
285 m_audiosignal = new AudioSignal;
286 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
287 m_audiosignalDock->setObjectName("audiosignal");
288 m_audiosignalDock->setWidget(m_audiosignal);
289 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
290 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
291 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
293 m_audioSpectrum = new AudioSpectrum();
294 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
295 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
296 m_audioSpectrumDock->setWidget(m_audioSpectrum);
297 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
298 m_audioScopesList.append(m_audioSpectrum);
299 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
300 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
302 m_spectrogram = new Spectrogram();
303 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
304 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
305 m_spectrogramDock->setWidget(m_spectrogram);
306 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
307 m_audioScopesList.append(m_spectrogram);
308 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
309 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
311 // Connect the audio signal to the audio scope slots
313 if (m_projectMonitor) {
314 qDebug() << "project monitor connected";
315 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
316 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
317 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
318 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
319 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
320 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
323 qDebug() << "clip monitor connected";
324 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
325 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
326 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
327 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
328 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
329 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
331 // Ensure connections were set up correctly
336 // Add monitors here to keep them at the right of the window
337 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
338 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
340 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
343 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
344 m_undoViewDock->setObjectName("undo_history");
345 m_undoView = new QUndoView();
346 m_undoView->setCleanIcon(KIcon("edit-clear"));
347 m_undoView->setEmptyLabel(i18n("Clean"));
348 m_undoViewDock->setWidget(m_undoView);
349 m_undoView->setGroup(m_commandStack);
350 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
356 // Close non-general docks for the initial layout
357 // only show important ones
358 m_histogramDock->close();
359 m_RGBParadeDock->close();
360 m_waveformDock->close();
361 m_vectorscopeDock->close();
363 m_audioSpectrumDock->close();
364 m_spectrogramDock->close();
365 m_audiosignalDock->close();
367 m_undoViewDock->close();
371 /// Tabify Widgets ///
372 tabifyDockWidget(m_effectListDock, m_effectStackDock);
373 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
374 tabifyDockWidget(m_projectListDock, m_notesDock);
376 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
378 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
384 setCentralWidget(m_timelineArea);
387 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
389 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
390 m_fileRevert->setEnabled(false);
392 // Prepare layout actions
393 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
394 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
395 for (int i = 1; i < 5; i++) {
396 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
397 load->setData("_" + QString::number(i));
398 layoutActions->addAction("load_layout" + QString::number(i), load);
399 m_loadLayout->addAction(load);
400 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
401 save->setData("_" + QString::number(i));
402 layoutActions->addAction("save_layout" + QString::number(i), save);
404 layoutActions->addAction("load_layouts", m_loadLayout);
405 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
408 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
409 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
410 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
411 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
412 m_stopmotion_actions->addAction("stopmotion_capture", action);
413 action = new KAction(i18n("Switch live / captured frame"), this);
414 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
415 m_stopmotion_actions->addAction("stopmotion_switch", action);
416 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
417 action->setCheckable(true);
418 action->setChecked(false);
419 m_stopmotion_actions->addAction("stopmotion_overlay", action);
421 // Build effects menu
422 m_effectsMenu = new QMenu(i18n("Add Effect"));
423 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
424 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
425 m_effectsActionCollection->readSettings();
430 // Find QDockWidget tab bars and show / hide widget title bars on right click
431 QList <QTabBar *> tabs = findChildren<QTabBar *>();
432 for (int i = 0; i < tabs.count(); i++) {
433 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
434 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
437 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
438 guiFactory()->addClient(sp);*/
440 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
442 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
445 // Load layout names from config file
450 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
452 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
453 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
455 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
456 clipInTimeline->setIcon(KIcon("go-jump"));
457 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
458 static_cast<QMenu*>(factory()->container("transcoders", this)),
461 // build themes menus
462 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
463 QActionGroup *themegroup = new QActionGroup(this);
464 themegroup->setExclusive(true);
465 action = new KAction(i18n("Default"), this);
466 action->setCheckable(true);
467 themegroup->addAction(action);
468 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
470 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
472 for (int i = 0; i < schemeFiles.size(); ++i) {
474 const QString filename = schemeFiles.at(i);
475 const QFileInfo info(filename);
478 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
479 QIcon icon = createSchemePreviewIcon(config);
480 KConfigGroup group(config, "General");
481 const QString name = group.readEntry("Name", info.baseName());
482 action = new KAction(name, this);
483 action->setData(filename);
484 action->setIcon(icon);
485 action->setCheckable(true);
486 themegroup->addAction(action);
487 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
490 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
491 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
492 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
495 action = new QAction(fi.fileName(), this);
496 action->setData(*it);
497 action->setCheckable(true);
498 themegroup->addAction(action);
499 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
501 themesMenu->addActions(themegroup->actions());
502 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
504 // Setup and fill effects and transitions menus.
507 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
511 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
512 for (int i = 0; i < transitions.count(); ++i)
513 m_transitionsMenu->addAction(m_transitions[i]);
515 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
516 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
518 m_effectStack->setMenu(m_effectsMenu);
520 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
521 const QList<QAction *> viewActions = createPopupMenu()->actions();
522 viewMenu->insertActions(NULL, viewActions);
524 m_timelineContextMenu = new QMenu(this);
525 m_timelineContextClipMenu = new QMenu(this);
526 m_timelineContextTransitionMenu = new QMenu(this);
528 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
529 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
530 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
532 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
533 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
534 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
535 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
536 m_timelineContextClipMenu->addSeparator();
537 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
538 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
539 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
540 m_timelineContextClipMenu->addSeparator();
541 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
542 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
543 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
544 m_timelineContextClipMenu->addSeparator();
546 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
547 m_timelineContextClipMenu->addMenu(markersMenu);
548 m_timelineContextClipMenu->addSeparator();
549 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
550 m_timelineContextClipMenu->addMenu(m_effectsMenu);
552 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
553 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
554 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
556 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
558 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
559 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
560 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
561 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
562 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
563 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
564 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
566 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
567 slotConnectMonitors();
569 // Open or create a file. Command line argument passed in Url has
570 // precedence, then "openlastproject", then just a plain empty file.
571 // If opening Url fails, openlastproject will _not_ be used.
572 if (!Url.isEmpty()) {
573 // delay loading so that the window shows up
575 QTimer::singleShot(500, this, SLOT(openFile()));
576 } else if (KdenliveSettings::openlastproject()) {
577 QTimer::singleShot(500, this, SLOT(openLastFile()));
578 } else { //if (m_timelineArea->count() == 0) {
582 if (!clipsToLoad.isEmpty() && m_activeDocument) {
583 QStringList list = clipsToLoad.split(',');
585 foreach(QString path, list) {
586 kDebug() << QDir::current().absoluteFilePath(path);
587 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
589 m_projectList->slotAddClip(urls);
592 #ifndef NO_JOGSHUTTLE
593 activateShuttleDevice();
594 #endif /* NO_JOGSHUTTLE */
595 m_projectListDock->raise();
597 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
598 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
601 MainWindow::~MainWindow()
606 m_effectStack->slotClipItemSelected(NULL, 0);
607 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
609 if (m_projectMonitor) m_projectMonitor->stop();
610 if (m_clipMonitor) m_clipMonitor->stop();
612 delete m_activeTimeline;
613 delete m_effectStack;
614 delete m_transitionConfig;
615 delete m_activeDocument;
616 delete m_projectMonitor;
617 delete m_clipMonitor;
618 delete m_shortcutRemoveFocus;
619 delete[] m_transitions;
620 Mlt::Factory::close();
624 bool MainWindow::queryClose()
626 if (m_renderWidget) {
627 int waitingJobs = m_renderWidget->waitingJobsCount();
628 if (waitingJobs > 0) {
629 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")))) {
630 case KMessageBox::Yes :
631 // create script with waiting jobs and start it
632 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
634 case KMessageBox::No :
635 // Don't do anything, jobs will be deleted
643 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
644 // warn the user to save if document is modified and we have clips in our project list
645 if (m_activeDocument && m_activeDocument->isModified() &&
646 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
647 !m_projectList->documentClipList().isEmpty())) {
651 if (m_activeDocument->url().fileName().isEmpty())
652 message = i18n("Save changes to document?");
654 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
655 switch (KMessageBox::warningYesNoCancel(this, message)) {
656 case KMessageBox::Yes :
657 // save document here. If saving fails, return false;
659 case KMessageBox::No :
660 // User does not want to save the changes, clear recovery files
661 m_activeDocument->m_autosave->resize(0);
670 void MainWindow::loadPlugins()
672 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
673 populateMenus(plugin);
676 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
678 filters << "libkdenlive*";
679 foreach(const QString & folder, directories) {
680 kDebug() << "Parsing plugin folder: " << folder;
681 QDir pluginsDir(folder);
682 foreach(const QString & fileName,
683 pluginsDir.entryList(filters, QDir::Files)) {
685 * Avoid loading the same plugin twice when there is more than one
688 if (!m_pluginFileNames.contains(fileName)) {
689 kDebug() << "Found plugin: " << fileName;
690 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
691 QObject *plugin = loader.instance();
693 populateMenus(plugin);
694 m_pluginFileNames += fileName;
696 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
702 void MainWindow::populateMenus(QObject *plugin)
704 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
705 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
707 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
711 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
712 QMenu *menu, const char *member,
713 QActionGroup *actionGroup)
715 kDebug() << "// ADD to MENU" << texts;
716 foreach(const QString & text, texts) {
717 QAction *action = new QAction(text, plugin);
718 action->setData(text);
719 connect(action, SIGNAL(triggered()), this, member);
720 menu->addAction(action);
723 action->setCheckable(true);
724 actionGroup->addAction(action);
729 void MainWindow::aboutPlugins()
731 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
736 void MainWindow::generateClip()
738 QAction *action = qobject_cast<QAction *>(sender());
739 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
741 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
742 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
743 if (!clipUrl.isEmpty()) {
744 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
748 void MainWindow::saveProperties(KConfigGroup &config)
750 // save properties here,used by session management
752 KMainWindow::saveProperties(config);
756 void MainWindow::readProperties(const KConfigGroup &config)
758 // read properties here,used by session management
759 KMainWindow::readProperties(config);
760 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
761 openFile(KUrl(Lastproject));
764 void MainWindow::slotReloadEffects()
766 initEffects::parseCustomEffectsFile();
767 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
770 #ifndef NO_JOGSHUTTLE
771 void MainWindow::activateShuttleDevice()
777 if (KdenliveSettings::enableshuttle() == false) return;
779 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
780 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
782 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
783 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
784 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
785 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
786 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
788 #endif /* NO_JOGSHUTTLE */
790 void MainWindow::slotDoAction(const QString& action_name)
792 QAction* action = actionCollection()->action(action_name);
794 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
800 void MainWindow::configureNotifications()
802 KNotifyConfigWidget::configure(this);
805 void MainWindow::slotFullScreen()
807 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
810 void MainWindow::slotAddEffect(const QDomElement effect)
812 if (!m_activeDocument) return;
813 if (effect.isNull()) {
814 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
817 QDomElement effectToAdd = effect.cloneNode().toElement();
819 int ix = m_effectStack->isTrackMode(&ok);
820 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
821 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
824 void MainWindow::slotRaiseMonitor(bool clipMonitor)
826 if (clipMonitor) m_clipMonitorDock->raise();
827 else m_projectMonitorDock->raise();
830 void MainWindow::slotUpdateClip(const QString &id)
832 if (!m_activeDocument) return;
833 m_activeTimeline->projectView()->slotUpdateClip(id);
836 void MainWindow::slotConnectMonitors()
838 m_projectList->setRenderer(m_projectMonitor->render);
839 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
840 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
841 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
842 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
843 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool, bool)));
844 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
845 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)));
847 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
848 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &)));
850 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
852 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
853 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
855 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
857 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
858 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
861 void MainWindow::slotAdjustClipMonitor()
863 m_clipMonitorDock->updateGeometry();
864 m_clipMonitorDock->adjustSize();
865 m_clipMonitor->resetSize();
868 void MainWindow::slotAdjustProjectMonitor()
870 m_projectMonitorDock->updateGeometry();
871 m_projectMonitorDock->adjustSize();
872 m_projectMonitor->resetSize();
876 class NameGrabbingKActionCollection {
878 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
879 : m_collection(collection), m_action_names(action_names) {
880 m_action_names.clear();
882 KAction* addAction(const QString& action_name) {
883 m_action_names << action_name;
884 return m_collection->addAction(action_name);
886 void addAction(const QString& action_name, QAction* action) {
887 m_action_names << action_name;
888 m_collection->addAction(action_name, action);
890 operator KActionCollection*() { return m_collection; }
891 const QStringList& actionNames() const { return m_action_names; }
893 KActionCollection* m_collection;
894 QStringList& m_action_names;
897 void MainWindow::setupActions()
900 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
901 m_timecodeFormat = new KComboBox(this);
902 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
903 m_timecodeFormat->addItem(i18n("Frames"));
904 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
905 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
907 m_statusProgressBar = new QProgressBar(this);
908 m_statusProgressBar->setMinimum(0);
909 m_statusProgressBar->setMaximum(100);
910 m_statusProgressBar->setMaximumWidth(150);
911 m_statusProgressBar->setVisible(false);
913 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
914 toolbar->setMovable(false);
915 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
916 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
917 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
918 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
919 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
920 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());
921 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
923 //create edit mode buttons
924 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
925 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
926 toolbar->addAction(m_normalEditTool);
927 m_normalEditTool->setCheckable(true);
928 m_normalEditTool->setChecked(true);
930 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
931 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
932 toolbar->addAction(m_overwriteEditTool);
933 m_overwriteEditTool->setCheckable(true);
934 m_overwriteEditTool->setChecked(false);
936 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
937 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
938 toolbar->addAction(m_insertEditTool);
939 m_insertEditTool->setCheckable(true);
940 m_insertEditTool->setChecked(false);
941 // not implemented yet
942 m_insertEditTool->setEnabled(false);
944 QActionGroup *editGroup = new QActionGroup(this);
945 editGroup->addAction(m_normalEditTool);
946 editGroup->addAction(m_overwriteEditTool);
947 editGroup->addAction(m_insertEditTool);
948 editGroup->setExclusive(true);
949 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
950 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
952 toolbar->addSeparator();
954 // create tools buttons
955 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
956 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
957 toolbar->addAction(m_buttonSelectTool);
958 m_buttonSelectTool->setCheckable(true);
959 m_buttonSelectTool->setChecked(true);
961 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
962 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
963 toolbar->addAction(m_buttonRazorTool);
964 m_buttonRazorTool->setCheckable(true);
965 m_buttonRazorTool->setChecked(false);
967 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
968 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
969 toolbar->addAction(m_buttonSpacerTool);
970 m_buttonSpacerTool->setCheckable(true);
971 m_buttonSpacerTool->setChecked(false);
973 QActionGroup *toolGroup = new QActionGroup(this);
974 toolGroup->addAction(m_buttonSelectTool);
975 toolGroup->addAction(m_buttonRazorTool);
976 toolGroup->addAction(m_buttonSpacerTool);
977 toolGroup->setExclusive(true);
978 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
980 QWidget * actionWidget;
981 int max = toolbar->iconSizeDefault() + 2;
982 actionWidget = toolbar->widgetForAction(m_normalEditTool);
983 actionWidget->setMaximumWidth(max);
984 actionWidget->setMaximumHeight(max - 4);
986 actionWidget = toolbar->widgetForAction(m_insertEditTool);
987 actionWidget->setMaximumWidth(max);
988 actionWidget->setMaximumHeight(max - 4);
990 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
991 actionWidget->setMaximumWidth(max);
992 actionWidget->setMaximumHeight(max - 4);
994 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
995 actionWidget->setMaximumWidth(max);
996 actionWidget->setMaximumHeight(max - 4);
998 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
999 actionWidget->setMaximumWidth(max);
1000 actionWidget->setMaximumHeight(max - 4);
1002 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1003 actionWidget->setMaximumWidth(max);
1004 actionWidget->setMaximumHeight(max - 4);
1006 toolbar->setStyleSheet(style1);
1007 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1009 toolbar->addSeparator();
1010 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1011 toolbar->addAction(m_buttonFitZoom);
1012 m_buttonFitZoom->setCheckable(false);
1014 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1015 toolbar->addAction(m_zoomOut);
1016 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1018 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1019 m_zoomSlider->setMaximum(13);
1020 m_zoomSlider->setPageStep(1);
1021 m_zoomSlider->setInvertedAppearance(true);
1023 m_zoomSlider->setMaximumWidth(150);
1024 m_zoomSlider->setMinimumWidth(100);
1025 toolbar->addWidget(m_zoomSlider);
1027 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1028 toolbar->addAction(m_zoomIn);
1029 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1031 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1032 actionWidget->setMaximumWidth(max);
1033 actionWidget->setMaximumHeight(max - 4);
1034 actionWidget->setStyleSheet(styleBorderless);
1036 actionWidget = toolbar->widgetForAction(m_zoomIn);
1037 actionWidget->setMaximumWidth(max);
1038 actionWidget->setMaximumHeight(max - 4);
1039 actionWidget->setStyleSheet(styleBorderless);
1041 actionWidget = toolbar->widgetForAction(m_zoomOut);
1042 actionWidget->setMaximumWidth(max);
1043 actionWidget->setMaximumHeight(max - 4);
1044 actionWidget->setStyleSheet(styleBorderless);
1046 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1047 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1048 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1049 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1050 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1052 toolbar->addSeparator();
1054 //create automatic audio split button
1055 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1056 toolbar->addAction(m_buttonAutomaticSplitAudio);
1057 m_buttonAutomaticSplitAudio->setCheckable(true);
1058 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1059 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1061 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1062 toolbar->addAction(m_buttonVideoThumbs);
1063 m_buttonVideoThumbs->setCheckable(true);
1064 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1065 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1067 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1068 toolbar->addAction(m_buttonAudioThumbs);
1069 m_buttonAudioThumbs->setCheckable(true);
1070 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1071 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1073 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1074 toolbar->addAction(m_buttonShowMarkers);
1075 m_buttonShowMarkers->setCheckable(true);
1076 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1077 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1079 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1080 toolbar->addAction(m_buttonSnap);
1081 m_buttonSnap->setCheckable(true);
1082 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1083 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1085 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1086 actionWidget->setMaximumWidth(max);
1087 actionWidget->setMaximumHeight(max - 4);
1089 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1090 actionWidget->setMaximumWidth(max);
1091 actionWidget->setMaximumHeight(max - 4);
1093 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1094 actionWidget->setMaximumWidth(max);
1095 actionWidget->setMaximumHeight(max - 4);
1097 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1098 actionWidget->setMaximumWidth(max);
1099 actionWidget->setMaximumHeight(max - 4);
1101 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1102 actionWidget->setMaximumWidth(max);
1103 actionWidget->setMaximumHeight(max - 4);
1105 m_messageLabel = new StatusBarMessageLabel(this);
1106 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1108 statusBar()->addWidget(m_messageLabel, 10);
1109 statusBar()->addWidget(m_statusProgressBar, 0);
1110 statusBar()->addPermanentWidget(toolbar);
1111 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1112 statusBar()->addPermanentWidget(m_timecodeFormat);
1113 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1115 collection.addAction("normal_mode", m_normalEditTool);
1116 collection.addAction("overwrite_mode", m_overwriteEditTool);
1117 collection.addAction("insert_mode", m_insertEditTool);
1118 collection.addAction("select_tool", m_buttonSelectTool);
1119 collection.addAction("razor_tool", m_buttonRazorTool);
1120 collection.addAction("spacer_tool", m_buttonSpacerTool);
1122 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1123 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1124 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1125 collection.addAction("show_markers", m_buttonShowMarkers);
1126 collection.addAction("snap", m_buttonSnap);
1127 collection.addAction("zoom_fit", m_buttonFitZoom);
1128 collection.addAction("zoom_in", m_zoomIn);
1129 collection.addAction("zoom_out", m_zoomOut);
1131 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1132 collection.addAction("project_find", m_projectSearch);
1133 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1134 m_projectSearch->setShortcut(Qt::Key_Slash);
1136 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1137 collection.addAction("project_find_next", m_projectSearchNext);
1138 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1139 m_projectSearchNext->setShortcut(Qt::Key_F3);
1140 m_projectSearchNext->setEnabled(false);
1142 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1143 collection.addAction("manage_profiles", profilesAction);
1144 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1146 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1147 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1148 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1149 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1151 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1152 collection.addAction("run_wizard", wizAction);
1153 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1155 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1156 collection.addAction("project_settings", projectAction);
1157 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1159 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1160 collection.addAction("project_render", projectRender);
1161 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1162 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1164 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1165 collection.addAction("project_clean", projectClean);
1166 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1168 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1169 collection.addAction("project_adjust_profile", projectAdjust);
1170 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1172 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1173 KShortcut playShortcut;
1174 playShortcut.setPrimary(Qt::Key_Space);
1175 playShortcut.setAlternate(Qt::Key_K);
1176 monitorPlay->setShortcut(playShortcut);
1177 collection.addAction("monitor_play", monitorPlay);
1178 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1180 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1181 collection.addAction("monitor_pause", monitorPause);
1182 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1184 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1185 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1186 collection.addAction("monitor_play_zone", m_playZone);
1187 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1189 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1190 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1191 collection.addAction("monitor_loop_zone", m_loopZone);
1192 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1194 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1195 m_loopClip->setEnabled(false);
1196 collection.addAction("monitor_loop_clip", m_loopClip);
1197 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1199 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1200 collection.addAction("dvd_wizard", dvdWizard);
1201 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1203 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1204 collection.addAction("transcode_clip", transcodeClip);
1205 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1207 KAction *markIn = collection.addAction("mark_in");
1208 markIn->setText(i18n("Set Zone In"));
1209 markIn->setShortcut(Qt::Key_I);
1210 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1212 KAction *markOut = collection.addAction("mark_out");
1213 markOut->setText(i18n("Set Zone Out"));
1214 markOut->setShortcut(Qt::Key_O);
1215 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1217 KAction *switchMon = collection.addAction("switch_monitor");
1218 switchMon->setText(i18n("Switch monitor"));
1219 switchMon->setShortcut(Qt::Key_T);
1220 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1222 KAction *fullMon = collection.addAction("monitor_fullscreen");
1223 fullMon->setText(i18n("Switch monitor fullscreen"));
1224 fullMon->setIcon(KIcon("view-fullscreen"));
1225 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1227 KAction *insertTree = collection.addAction("insert_project_tree");
1228 insertTree->setText(i18n("Insert zone in project tree"));
1229 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1230 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1232 KAction *insertTimeline = collection.addAction("insert_timeline");
1233 insertTimeline->setText(i18n("Insert zone in timeline"));
1234 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1235 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1237 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1238 collection.addAction("resize_timeline_clip_start", resizeStart);
1239 resizeStart->setShortcut(Qt::Key_1);
1240 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1242 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1243 collection.addAction("resize_timeline_clip_end", resizeEnd);
1244 resizeEnd->setShortcut(Qt::Key_2);
1245 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1247 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1248 monitorSeekBackward->setShortcut(Qt::Key_J);
1249 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1250 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1252 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1253 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1254 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1255 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1257 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1258 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1259 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1260 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1262 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1263 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1264 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1265 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1267 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1268 monitorSeekForward->setShortcut(Qt::Key_L);
1269 collection.addAction("monitor_seek_forward", monitorSeekForward);
1270 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1272 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1273 clipStart->setShortcut(Qt::Key_Home);
1274 collection.addAction("seek_clip_start", clipStart);
1275 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1277 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1278 clipEnd->setShortcut(Qt::Key_End);
1279 collection.addAction("seek_clip_end", clipEnd);
1280 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1282 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1283 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1284 collection.addAction("seek_zone_start", zoneStart);
1285 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1287 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1288 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1289 collection.addAction("seek_zone_end", zoneEnd);
1290 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1292 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1293 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1294 collection.addAction("seek_start", projectStart);
1295 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1297 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1298 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1299 collection.addAction("seek_end", projectEnd);
1300 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1302 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1303 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1304 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1305 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1307 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1308 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1309 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1310 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1312 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1313 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1314 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1315 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1317 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1318 deleteItem->setShortcut(Qt::Key_Delete);
1319 collection.addAction("delete_timeline_clip", deleteItem);
1320 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1322 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1323 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1324 editTimelineClipSpeed->setData("change_speed");
1325 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1327 KAction *stickTransition = collection.addAction("auto_transition");
1328 stickTransition->setData(QString("auto"));
1329 stickTransition->setCheckable(true);
1330 stickTransition->setEnabled(false);
1331 stickTransition->setText(i18n("Automatic Transition"));
1332 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1334 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1335 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1336 collection.addAction("group_clip", groupClip);
1337 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1339 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1340 collection.addAction("ungroup_clip", ungroupClip);
1341 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1342 ungroupClip->setData("ungroup_clip");
1343 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1345 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1346 collection.addAction("edit_item_duration", editItemDuration);
1347 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1349 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1350 collection.addAction("clip_in_project_tree", clipInProjectTree);
1351 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1353 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1354 collection.addAction("clip_to_project_tree", clipToProjectTree);
1355 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1357 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1358 insertOvertwrite->setShortcut(Qt::Key_V);
1359 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1360 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1362 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1363 selectTimelineClip->setShortcut(Qt::Key_Plus);
1364 collection.addAction("select_timeline_clip", selectTimelineClip);
1365 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1367 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1368 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1369 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1370 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1372 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1373 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1374 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1375 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1377 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1378 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1379 collection.addAction("select_timeline_transition", selectTimelineTransition);
1380 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1382 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1383 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1384 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1385 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1387 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1388 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1389 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1390 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1392 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1393 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1394 collection.addAction("cut_timeline_clip", cutTimelineClip);
1395 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1397 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1398 collection.addAction("add_clip_marker", addClipMarker);
1399 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1401 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1402 collection.addAction("delete_clip_marker", deleteClipMarker);
1403 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1405 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1406 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1407 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1409 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1410 editClipMarker->setData(QString("edit_marker"));
1411 collection.addAction("edit_clip_marker", editClipMarker);
1412 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1414 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1415 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1416 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1417 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1419 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1420 collection.addAction("split_audio", splitAudio);
1421 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1423 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1424 collection.addAction("clip_audio_only", audioOnly);
1425 audioOnly->setData("clip_audio_only");
1426 audioOnly->setCheckable(true);
1428 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1429 collection.addAction("clip_video_only", videoOnly);
1430 videoOnly->setData("clip_video_only");
1431 videoOnly->setCheckable(true);
1433 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1434 collection.addAction("clip_audio_and_video", audioAndVideo);
1435 audioAndVideo->setData("clip_audio_and_video");
1436 audioAndVideo->setCheckable(true);
1438 m_clipTypeGroup = new QActionGroup(this);
1439 m_clipTypeGroup->addAction(audioOnly);
1440 m_clipTypeGroup->addAction(videoOnly);
1441 m_clipTypeGroup->addAction(audioAndVideo);
1442 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1443 m_clipTypeGroup->setEnabled(false);
1445 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1446 collection.addAction("insert_space", insertSpace);
1447 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1449 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1450 collection.addAction("delete_space", removeSpace);
1451 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1453 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1454 collection.addAction("insert_track", insertTrack);
1455 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1457 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1458 collection.addAction("delete_track", deleteTrack);
1459 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1461 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1462 collection.addAction("config_tracks", configTracks);
1463 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1465 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1466 collection.addAction("add_guide", addGuide);
1467 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1469 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1470 collection.addAction("delete_guide", delGuide);
1471 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1473 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1474 collection.addAction("edit_guide", editGuide);
1475 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1477 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1478 collection.addAction("delete_all_guides", delAllGuides);
1479 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1481 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1482 collection.addAction("paste_effects", pasteEffects);
1483 pasteEffects->setData("paste_effects");
1484 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1486 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1487 collection.addAction("show_timeline", showTimeline);
1488 showTimeline->setCheckable(true);
1489 showTimeline->setChecked(true);
1490 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1492 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1493 collection.addAction("show_titlebars", showTitleBar);
1494 showTitleBar->setCheckable(true);
1495 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1496 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1497 slotShowTitleBars(KdenliveSettings::showtitlebars());
1500 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1502 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1503 collection.addAction("maximize_current", maxCurrent);
1504 maxCurrent->setCheckable(true);
1505 maxCurrent->setChecked(false);
1506 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1508 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1509 KStandardAction::quit(this, SLOT(close()), collection);
1510 KStandardAction::open(this, SLOT(openFile()), collection);
1511 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1512 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1513 KStandardAction::openNew(this, SLOT(newFile()), collection);
1514 // TODO: make the following connection to slotEditKeys work
1515 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1516 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1517 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1518 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1519 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1520 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1522 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1523 undo->setEnabled(false);
1524 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1526 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1527 redo->setEnabled(false);
1528 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1531 //TODO: Add status tooltip to actions ?
1532 connect(collection, SIGNAL(actionHovered(QAction*)),
1533 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1536 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1537 collection.addAction("add_clip", addClip);
1538 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1540 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1541 collection.addAction("add_color_clip", addColorClip);
1542 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1544 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1545 collection.addAction("add_slide_clip", addSlideClip);
1546 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1548 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1549 collection.addAction("add_text_clip", addTitleClip);
1550 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1552 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1553 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1554 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1556 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1557 collection.addAction("add_folder", addFolderButton);
1558 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1560 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1561 collection.addAction("clip_properties", clipProperties);
1562 clipProperties->setData("clip_properties");
1563 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1564 clipProperties->setEnabled(false);
1566 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1567 collection.addAction("edit_clip", openClip);
1568 openClip->setData("edit_clip");
1569 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1570 openClip->setEnabled(false);
1572 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1573 collection.addAction("delete_clip", deleteClip);
1574 deleteClip->setData("delete_clip");
1575 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1576 deleteClip->setEnabled(false);
1578 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1579 collection.addAction("reload_clip", reloadClip);
1580 reloadClip->setData("reload_clip");
1581 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1582 reloadClip->setEnabled(false);
1584 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1585 collection.addAction("stopmotion", stopMotion);
1586 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1588 QMenu *addClips = new QMenu();
1589 addClips->addAction(addClip);
1590 addClips->addAction(addColorClip);
1591 addClips->addAction(addSlideClip);
1592 addClips->addAction(addTitleClip);
1593 addClips->addAction(addTitleTemplateClip);
1594 addClips->addAction(addFolderButton);
1596 addClips->addAction(reloadClip);
1597 addClips->addAction(clipProperties);
1598 addClips->addAction(openClip);
1599 addClips->addAction(deleteClip);
1600 m_projectList->setupMenu(addClips, addClip);
1602 // Setup effects and transitions actions.
1603 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1604 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1605 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1606 m_transitions = new KAction*[transitions.count()];
1607 for (int i = 0; i < transitions.count(); i++) {
1608 QStringList effectInfo = transitions.effectIdInfo(i);
1609 m_transitions[i] = new KAction(effectInfo.at(0), this);
1610 m_transitions[i]->setData(effectInfo);
1611 m_transitions[i]->setIconVisibleInMenu(false);
1612 QString id = effectInfo.at(2);
1613 if (id.isEmpty()) id = effectInfo.at(1);
1614 transitionActions->addAction("transition_" + id, m_transitions[i]);
1616 //m_effectsActionCollection->readSettings();
1618 //connect(collection, SIGNAL( clearStatusText() ),
1619 //statusBar(), SLOT( clear() ) );
1622 void MainWindow::slotDisplayActionMessage(QAction *a)
1624 statusBar()->showMessage(a->data().toString(), 3000);
1627 void MainWindow::loadLayouts()
1629 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1630 if (m_loadLayout == NULL || saveLayout == NULL) return;
1631 KSharedConfigPtr config = KGlobal::config();
1632 KConfigGroup layoutGroup(config, "Layouts");
1633 QStringList entries = layoutGroup.keyList();
1634 QList<QAction *> loadActions = m_loadLayout->actions();
1635 QList<QAction *> saveActions = saveLayout->actions();
1636 for (int i = 1; i < 5; i++) {
1637 // Rename the layouts actions
1638 foreach(const QString & key, entries) {
1639 if (key.endsWith(QString("_%1").arg(i))) {
1640 // Found previously saved layout
1641 QString layoutName = key.section("_", 0, -2);
1642 for (int j = 0; j < loadActions.count(); j++) {
1643 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1644 loadActions[j]->setText(layoutName);
1645 loadActions[j]->setData(key);
1649 for (int j = 0; j < saveActions.count(); j++) {
1650 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1651 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1652 saveActions[j]->setData(key);
1661 void MainWindow::slotLoadLayout(QAction *action)
1663 if (!action) return;
1664 QString layoutId = action->data().toString();
1665 if (layoutId.isEmpty()) return;
1666 KSharedConfigPtr config = KGlobal::config();
1667 KConfigGroup layouts(config, "Layouts");
1668 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1669 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1670 //restoreGeometry(geom);
1671 restoreState(state);
1674 void MainWindow::slotSaveLayout(QAction *action)
1676 QString originallayoutName = action->data().toString();
1677 int layoutId = originallayoutName.section('_', -1).toInt();
1679 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1680 if (layoutName.isEmpty()) return;
1681 KSharedConfigPtr config = KGlobal::config();
1682 KConfigGroup layouts(config, "Layouts");
1683 layouts.deleteEntry(originallayoutName);
1685 QByteArray st = saveState();
1686 layoutName.append("_" + QString::number(layoutId));
1687 layouts.writeEntry(layoutName, st.toBase64());
1691 void MainWindow::saveOptions()
1693 KdenliveSettings::self()->writeConfig();
1694 KSharedConfigPtr config = KGlobal::config();
1695 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1696 KConfigGroup treecolumns(config, "Project Tree");
1697 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1701 void MainWindow::readOptions()
1703 KSharedConfigPtr config = KGlobal::config();
1704 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1705 KConfigGroup initialGroup(config, "version");
1706 bool upgrade = false;
1707 if (initialGroup.exists()) {
1708 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1712 if (initialGroup.readEntry("version") == "0.7") {
1713 //Add new settings from 0.7.1
1714 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1715 QString path = QDir::homePath() + "/kdenlive";
1716 if (KStandardDirs::makeDir(path) == false) {
1717 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1718 } else KdenliveSettings::setDefaultprojectfolder(path);
1724 if (!initialGroup.exists() || upgrade) {
1725 // this is our first run, show Wizard
1726 Wizard *w = new Wizard(upgrade, this);
1727 if (w->exec() == QDialog::Accepted && w->isOk()) {
1728 w->adjustSettings();
1729 initialGroup.writeEntry("version", version);
1735 KConfigGroup treecolumns(config, "Project Tree");
1736 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1737 if (!state.isEmpty())
1738 m_projectList->setHeaderInfo(state);
1741 void MainWindow::slotRunWizard()
1743 Wizard *w = new Wizard(false, this);
1744 if (w->exec() == QDialog::Accepted && w->isOk()) {
1745 w->adjustSettings();
1750 void MainWindow::newFile(bool showProjectSettings, bool force)
1752 if (!m_timelineArea->isEnabled() && !force)
1754 m_fileRevert->setEnabled(false);
1755 QString profileName = KdenliveSettings::default_profile();
1756 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1757 QMap <QString, QString> documentProperties;
1758 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1759 if (!showProjectSettings) {
1760 // set up default properties
1761 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1762 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1763 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1764 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1765 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1766 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1767 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1768 if (!KdenliveSettings::activatetabs())
1769 if (!closeCurrentDocument())
1772 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1773 if (w->exec() != QDialog::Accepted)
1775 if (!KdenliveSettings::activatetabs())
1776 if (!closeCurrentDocument())
1778 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1779 slotSwitchVideoThumbs();
1780 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1781 slotSwitchAudioThumbs();
1782 profileName = w->selectedProfile();
1783 projectFolder = w->selectedFolder();
1784 projectTracks = w->tracks();
1785 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1786 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1787 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1788 documentProperties.insert("proxyparams", w->proxyParams());
1789 documentProperties.insert("proxyextension", w->proxyExtension());
1790 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1791 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1794 m_timelineArea->setEnabled(true);
1795 m_projectList->setEnabled(true);
1797 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1798 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1800 TrackView *trackView = new TrackView(doc, &ok, this);
1801 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1804 //m_timelineArea->setEnabled(false);
1805 //m_projectList->setEnabled(false);
1809 if (m_timelineArea->count() == 1) {
1810 connectDocumentInfo(doc);
1811 connectDocument(trackView, doc);
1813 m_timelineArea->setTabBarHidden(false);
1814 m_monitorManager->activateMonitor("clip");
1815 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1818 void MainWindow::activateDocument()
1820 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1821 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1822 KdenliveDoc *currentDoc = currentTab->document();
1823 connectDocumentInfo(currentDoc);
1824 connectDocument(currentTab, currentDoc);
1827 bool MainWindow::closeCurrentDocument(bool saveChanges)
1829 QWidget *w = m_timelineArea->currentWidget();
1830 if (!w) return true;
1831 // closing current document
1832 int ix = m_timelineArea->currentIndex() + 1;
1833 if (ix == m_timelineArea->count()) ix = 0;
1834 m_timelineArea->setCurrentIndex(ix);
1835 TrackView *tabToClose = (TrackView *) w;
1836 KdenliveDoc *docToClose = tabToClose->document();
1837 if (docToClose && docToClose->isModified() && saveChanges) {
1839 if (m_activeDocument->url().fileName().isEmpty())
1840 message = i18n("Save changes to document?");
1842 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1843 switch (KMessageBox::warningYesNoCancel(this, message)) {
1844 case KMessageBox::Yes :
1845 // save document here. If saving fails, return false;
1846 if (saveFile() == false) return false;
1848 case KMessageBox::Cancel :
1855 m_clipMonitor->slotSetXml(NULL);
1856 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1857 if (m_timelineArea->count() == 1) {
1858 m_timelineArea->setTabBarHidden(true);
1859 m_closeAction->setEnabled(false);
1861 if (docToClose == m_activeDocument) {
1862 delete m_activeDocument;
1863 m_activeDocument = NULL;
1864 m_effectStack->clear();
1865 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1869 if (w == m_activeTimeline) {
1870 delete m_activeTimeline;
1871 m_activeTimeline = NULL;
1878 bool MainWindow::saveFileAs(const QString &outputFileName)
1880 QString currentSceneList;
1881 m_monitorManager->stopActiveMonitor();
1883 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1886 // Save timeline thumbnails
1887 m_activeTimeline->projectView()->saveThumbnails();
1888 m_activeDocument->setUrl(KUrl(outputFileName));
1889 if (m_activeDocument->m_autosave == NULL) {
1890 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1891 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1892 setCaption(m_activeDocument->description());
1893 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1894 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1895 m_activeDocument->setModified(false);
1896 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1897 m_fileRevert->setEnabled(true);
1901 bool MainWindow::saveFileAs()
1903 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1904 if (outputFile.isEmpty()) {
1907 if (QFile::exists(outputFile)) {
1908 // Show the file dialog again if the user does not want to overwrite the file
1909 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1910 return saveFileAs();
1912 return saveFileAs(outputFile);
1915 bool MainWindow::saveFile()
1917 if (!m_activeDocument) return true;
1918 if (m_activeDocument->url().isEmpty()) {
1919 return saveFileAs();
1921 bool result = saveFileAs(m_activeDocument->url().path());
1922 m_activeDocument->m_autosave->resize(0);
1927 void MainWindow::openFile()
1929 if (!m_startUrl.isEmpty()) {
1930 openFile(m_startUrl);
1931 m_startUrl = KUrl();
1934 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1935 if (url.isEmpty()) return;
1936 m_fileOpenRecent->addUrl(url);
1940 void MainWindow::openLastFile()
1942 KSharedConfigPtr config = KGlobal::config();
1943 KUrl::List urls = m_fileOpenRecent->urls();
1944 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1945 if (urls.isEmpty()) newFile(false);
1946 else openFile(urls.last());
1949 void MainWindow::openFile(const KUrl &url)
1951 // Check if the document is already opened
1952 const int ct = m_timelineArea->count();
1953 bool isOpened = false;
1955 for (i = 0; i < ct; i++) {
1956 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1957 KdenliveDoc *doc = tab->document();
1958 if (doc->url() == url) {
1964 m_timelineArea->setCurrentIndex(i);
1968 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1970 // Check for backup file
1971 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1972 if (!staleFiles.isEmpty()) {
1973 if (KMessageBox::questionYesNo(this,
1974 i18n("Auto-saved files exist. Do you want to recover them now?"),
1975 i18n("File Recovery"),
1976 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1977 recoverFiles(staleFiles);
1980 // remove the stale files
1981 foreach(KAutoSaveFile * stale, staleFiles) {
1982 stale->open(QIODevice::ReadWrite);
1987 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1988 m_messageLabel->repaint();
1989 doOpenFile(url, NULL);
1992 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1994 if (!m_timelineArea->isEnabled()) return;
1995 m_fileRevert->setEnabled(true);
1997 // Recreate stopmotion widget on document change
1999 delete m_stopmotion;
2000 m_stopmotion = NULL;
2003 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2004 progressDialog.setAllowCancel(false);
2005 progressDialog.progressBar()->setMaximum(4);
2006 progressDialog.show();
2007 progressDialog.progressBar()->setValue(0);
2008 qApp->processEvents();
2010 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);
2012 progressDialog.progressBar()->setValue(1);
2013 progressDialog.progressBar()->setMaximum(4);
2014 progressDialog.setLabelText(i18n("Loading project"));
2015 qApp->processEvents();
2017 if (stale == NULL) {
2018 stale = new KAutoSaveFile(url, doc);
2019 doc->m_autosave = stale;
2021 doc->m_autosave = stale;
2022 doc->setUrl(stale->managedFile());
2023 doc->setModified(true);
2024 stale->setParent(doc);
2026 connectDocumentInfo(doc);
2028 progressDialog.progressBar()->setValue(2);
2029 qApp->processEvents();
2032 TrackView *trackView = new TrackView(doc, &ok, this);
2034 progressDialog.progressBar()->setValue(3);
2035 qApp->processEvents();
2037 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2039 m_timelineArea->setEnabled(false);
2040 m_projectList->setEnabled(false);
2041 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2042 slotGotProgressInfo(QString(), -1);
2043 newFile(false, true);
2046 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2047 trackView->setDuration(trackView->duration());
2048 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2050 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2051 slotGotProgressInfo(QString(), -1);
2052 m_projectMonitor->adjustRulerSize(trackView->duration());
2053 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2054 m_clipMonitor->refreshMonitor(true);
2056 progressDialog.progressBar()->setValue(4);
2059 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2061 foreach(KAutoSaveFile * stale, staleFiles) {
2062 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2063 // show an error message; we could not steal the lockfile
2064 // maybe another application got to the file before us?
2068 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2069 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2070 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2071 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2075 void MainWindow::parseProfiles(const QString &mltPath)
2077 //KdenliveSettings::setDefaulttmpfolder();
2078 if (!mltPath.isEmpty()) {
2079 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2080 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2083 if (KdenliveSettings::mltpath().isEmpty())
2084 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2086 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2087 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2088 if (!QFile::exists(meltPath))
2089 meltPath = KStandardDirs::findExe("melt");
2090 KdenliveSettings::setRendererpath(meltPath);
2093 if (KdenliveSettings::rendererpath().isEmpty()) {
2094 // Cannot find the MLT melt renderer, ask for location
2095 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2096 if (getUrl->exec() == QDialog::Rejected) {
2099 KUrl rendererPath = getUrl->selectedUrl();
2101 if (rendererPath.isEmpty()) ::exit(0);
2102 KdenliveSettings::setRendererpath(rendererPath.path());
2105 QStringList profilesFilter;
2106 profilesFilter << "*";
2107 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2108 if (profilesList.isEmpty()) {
2109 // Cannot find MLT path, try finding melt
2110 QString profilePath = KdenliveSettings::rendererpath();
2111 if (!profilePath.isEmpty()) {
2112 profilePath = profilePath.section('/', 0, -3);
2113 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2114 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2116 if (profilesList.isEmpty()) {
2117 // Cannot find the MLT profiles, ask for location
2118 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2119 getUrl->fileDialog()->setMode(KFile::Directory);
2120 if (getUrl->exec() == QDialog::Rejected) {
2123 KUrl mltPath = getUrl->selectedUrl();
2125 if (mltPath.isEmpty()) ::exit(0);
2126 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2127 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2131 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2133 // Parse again MLT profiles to build a list of available video formats
2134 if (profilesList.isEmpty()) parseProfiles();
2138 void MainWindow::slotEditProfiles()
2140 ProfilesDialog *w = new ProfilesDialog;
2141 if (w->exec() == QDialog::Accepted) {
2142 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2143 if (d) d->checkProfile();
2148 void MainWindow::slotDetectAudioDriver()
2150 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2151 leading to no audio output, see bug #934 */
2153 //decide which audio driver is really best, in some cases SDL is wrong
2154 if (KdenliveSettings::audiodrivername().isEmpty()) {
2156 KProcess readProcess;
2157 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2158 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2159 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2160 readProcess.setProgram("pactl", QStringList() << "stat");
2161 readProcess.execute(2000); // Kill it after 2 seconds
2163 QString result = QString(readProcess.readAllStandardOutput());
2164 kDebug() << "// / / / / / READING PACTL: ";
2166 if (!result.isEmpty()) {
2168 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2172 KdenliveSettings::setAutoaudiodrivername(driver);
2176 void MainWindow::slotEditProjectSettings()
2178 QPoint p = m_activeDocument->getTracksCount();
2179 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2181 if (w->exec() == QDialog::Accepted) {
2182 QString profile = w->selectedProfile();
2183 m_activeDocument->setProjectFolder(w->selectedFolder());
2185 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2187 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2188 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2189 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2190 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2191 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2192 m_activeDocument->setModified();
2193 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2194 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) {
2195 //TODO: rebuild all proxies
2196 //m_projectList->rebuildProxies();
2199 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2200 m_activeDocument->setModified();
2201 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2203 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2204 m_activeDocument->setModified();
2205 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2207 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2208 m_activeDocument->setModified();
2209 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2211 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2212 m_activeDocument->setModified();
2213 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2215 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2216 m_activeDocument->setModified();
2217 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2219 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2220 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2221 m_activeDocument->setModified();
2222 slotUpdateProxySettings();
2228 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2230 double dar = m_activeDocument->dar();
2232 // Recreate the stopmotion widget if profile changes
2234 delete m_stopmotion;
2235 m_stopmotion = NULL;
2238 // Deselect current effect / transition
2239 m_effectStack->slotClipItemSelected(NULL, 0);
2240 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2241 m_clipMonitor->slotSetXml(NULL);
2242 bool updateFps = m_activeDocument->setProfilePath(profile);
2243 KdenliveSettings::setCurrent_profile(profile);
2244 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2245 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2247 m_activeDocument->clipManager()->clearUnusedProducers();
2248 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2249 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2250 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2251 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2252 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2253 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2254 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2255 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2256 if (updateFps) m_activeTimeline->updateProjectFps();
2257 m_activeDocument->setModified(true);
2258 m_commandStack->activeStack()->clear();
2259 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2260 slotUpdateMousePosition(0);
2261 // We need to desactivate & reactivate monitors to get a refresh
2262 //m_monitorManager->switchMonitors();
2266 void MainWindow::slotRenderProject()
2268 if (!m_renderWidget) {
2269 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2270 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2271 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2272 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2273 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2274 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2275 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2276 if (m_activeDocument) {
2277 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2278 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2279 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2280 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2283 slotCheckRenderStatus();
2284 m_renderWidget->show();
2285 m_renderWidget->showNormal();
2287 // What are the following lines supposed to do?
2288 //m_activeTimeline->tracksNumber();
2289 //m_renderWidget->enableAudio(false);
2290 //m_renderWidget->export_audio;
2293 void MainWindow::slotCheckRenderStatus()
2295 // Make sure there are no missing clips
2297 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2300 void MainWindow::setRenderingProgress(const QString &url, int progress)
2303 m_renderWidget->setRenderJob(url, progress);
2306 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2309 m_renderWidget->setRenderStatus(url, status, error);
2312 void MainWindow::slotCleanProject()
2314 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2315 m_projectList->cleanup();
2318 void MainWindow::slotUpdateMousePosition(int pos)
2320 if (m_activeDocument)
2321 switch (m_timecodeFormat->currentIndex()) {
2323 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2326 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2330 void MainWindow::slotUpdateDocumentState(bool modified)
2332 if (!m_activeDocument) return;
2333 setCaption(m_activeDocument->description(), modified);
2334 m_saveAction->setEnabled(modified);
2336 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2337 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2339 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2340 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2344 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2346 if (m_activeDocument) {
2347 if (m_activeDocument == doc) return;
2348 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2350 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2353 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2355 //m_projectMonitor->stop();
2356 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2357 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2358 if (m_activeDocument) {
2359 if (m_activeDocument == doc) return;
2360 if (m_activeTimeline) {
2361 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2362 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2363 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2364 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2365 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2366 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2367 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2368 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2370 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2372 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2373 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2374 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2375 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2376 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2377 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2378 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2379 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2380 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2381 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2382 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2383 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2384 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2385 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2386 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2387 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2388 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2389 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2390 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2391 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2392 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2393 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2394 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2395 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2396 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2397 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2398 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2399 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2400 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2401 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2402 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2403 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2404 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2405 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2406 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2407 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2408 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2409 m_effectStack->clear();
2411 //m_activeDocument->setRenderer(NULL);
2412 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2413 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2414 m_clipMonitor->stop();
2416 KdenliveSettings::setCurrent_profile(doc->profilePath());
2417 KdenliveSettings::setProject_fps(doc->fps());
2418 m_monitorManager->resetProfiles(doc->timecode());
2419 m_projectList->setDocument(doc);
2420 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2421 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2422 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2423 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2424 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2425 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2427 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2428 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2429 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2431 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2434 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2435 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2436 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2437 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2438 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2439 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2440 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2441 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2442 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2443 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2444 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2445 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2446 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2447 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2449 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2450 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2451 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2452 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2453 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2455 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2456 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2457 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2458 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2460 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2461 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2462 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2463 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2465 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2466 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2467 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2468 m_zoomSlider->setValue(doc->zoom().x());
2469 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2470 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2471 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2472 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2474 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2475 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2477 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2478 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2480 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2481 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2482 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2483 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2484 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2485 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2486 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2487 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2488 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2489 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2490 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2492 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2493 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2494 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2495 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2496 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2499 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2500 m_activeTimeline = trackView;
2501 if (m_renderWidget) {
2502 slotCheckRenderStatus();
2503 m_renderWidget->setProfile(doc->mltProfile());
2504 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2505 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2506 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2508 //doc->setRenderer(m_projectMonitor->render);
2509 m_commandStack->setActiveStack(doc->commandStack());
2510 KdenliveSettings::setProject_display_ratio(doc->dar());
2511 //doc->clipManager()->checkAudioThumbs();
2513 //m_overView->setScene(trackView->projectScene());
2514 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2515 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2517 setCaption(doc->description(), doc->isModified());
2518 m_saveAction->setEnabled(doc->isModified());
2519 m_normalEditTool->setChecked(true);
2520 m_activeDocument = doc;
2521 m_activeTimeline->updateProjectFps();
2522 m_activeDocument->checkProjectClips();
2524 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2526 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2527 slotUpdateMousePosition(0);
2528 // set tool to select tool
2529 m_buttonSelectTool->setChecked(true);
2532 void MainWindow::slotZoneMoved(int start, int end)
2534 m_activeDocument->setZone(start, end);
2535 m_projectMonitor->slotZoneMoved(start, end);
2538 void MainWindow::slotGuidesUpdated()
2541 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2544 void MainWindow::slotEditKeys()
2546 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2547 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2548 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2552 void MainWindow::slotPreferences(int page, int option)
2555 * An instance of your dialog could be already created and could be
2556 * cached, in which case you want to display the cached dialog
2557 * instead of creating another one
2559 if (m_stopmotion) m_stopmotion->slotLive(false);
2560 if (KConfigDialog::showDialog("settings")) {
2561 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2562 if (page != -1) d->showPage(page, option);
2566 // KConfigDialog didn't find an instance of this dialog, so lets
2569 // Get the mappable actions in localized form
2570 QMap<QString, QString> actions;
2571 KActionCollection* collection = actionCollection();
2572 foreach (const QString& action_name, m_action_names) {
2573 actions[collection->action(action_name)->text()] = action_name;
2576 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2577 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2578 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2580 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2583 if (page != -1) dialog->showPage(page, option);
2586 void MainWindow::slotUpdateCaptureFolder()
2590 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2591 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2595 void MainWindow::updateConfiguration()
2597 //TODO: we should apply settings to all projects, not only the current one
2598 if (m_activeTimeline) {
2599 m_activeTimeline->refresh();
2600 m_activeTimeline->projectView()->checkAutoScroll();
2601 m_activeTimeline->projectView()->checkTrackHeight();
2602 if (m_activeDocument)
2603 m_activeDocument->clipManager()->checkAudioThumbs();
2605 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2606 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2607 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2608 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2610 // Update list of transcoding profiles
2612 #ifndef NO_JOGSHUTTLE
2613 activateShuttleDevice();
2614 #endif /* NO_JOGSHUTTLE */
2618 void MainWindow::slotSwitchSplitAudio()
2620 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2621 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2624 void MainWindow::slotSwitchVideoThumbs()
2626 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2627 if (m_activeTimeline)
2628 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2629 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2632 void MainWindow::slotSwitchAudioThumbs()
2634 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2635 if (m_activeTimeline) {
2636 m_activeTimeline->refresh();
2637 m_activeTimeline->projectView()->checkAutoScroll();
2638 if (m_activeDocument)
2639 m_activeDocument->clipManager()->checkAudioThumbs();
2641 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2644 void MainWindow::slotSwitchMarkersComments()
2646 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2647 if (m_activeTimeline)
2648 m_activeTimeline->refresh();
2649 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2652 void MainWindow::slotSwitchSnap()
2654 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2655 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2659 void MainWindow::slotDeleteItem()
2661 if (QApplication::focusWidget() &&
2662 QApplication::focusWidget()->parentWidget() &&
2663 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2664 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2665 m_projectList->slotRemoveClip();
2668 QWidget *widget = QApplication::focusWidget();
2670 if (widget == m_effectStackDock) {
2671 m_effectStack->slotItemDel();
2674 widget = widget->parentWidget();
2677 // effect stack has no focus
2678 if (m_activeTimeline)
2679 m_activeTimeline->projectView()->deleteSelectedClips();
2683 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2685 if (m_clipMonitor->isActive())
2686 m_clipMonitor->checkOverlay();
2687 m_clipMonitor->updateMarkers(clip);
2690 void MainWindow::slotAddClipMarker()
2692 DocClipBase *clip = NULL;
2694 if (m_projectMonitor->isActive()) {
2695 if (m_activeTimeline) {
2696 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2698 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2699 clip = item->baseClip();
2703 clip = m_clipMonitor->activeClip();
2704 pos = m_clipMonitor->position();
2707 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2710 QString id = clip->getId();
2711 CommentedTime marker(pos, i18n("Marker"));
2712 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2713 if (d.exec() == QDialog::Accepted)
2714 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2717 void MainWindow::slotDeleteClipMarker()
2719 DocClipBase *clip = NULL;
2721 if (m_projectMonitor->isActive()) {
2722 if (m_activeTimeline) {
2723 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2725 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2726 clip = item->baseClip();
2730 clip = m_clipMonitor->activeClip();
2731 pos = m_clipMonitor->position();
2734 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2738 QString id = clip->getId();
2739 QString comment = clip->markerComment(pos);
2740 if (comment.isEmpty()) {
2741 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2744 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2747 void MainWindow::slotDeleteAllClipMarkers()
2749 DocClipBase *clip = NULL;
2750 if (m_projectMonitor->isActive()) {
2751 if (m_activeTimeline) {
2752 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2754 clip = item->baseClip();
2758 clip = m_clipMonitor->activeClip();
2761 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2764 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2767 void MainWindow::slotEditClipMarker()
2769 DocClipBase *clip = NULL;
2771 if (m_projectMonitor->isActive()) {
2772 if (m_activeTimeline) {
2773 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2775 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2776 clip = item->baseClip();
2780 clip = m_clipMonitor->activeClip();
2781 pos = m_clipMonitor->position();
2784 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2788 QString id = clip->getId();
2789 QString oldcomment = clip->markerComment(pos);
2790 if (oldcomment.isEmpty()) {
2791 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2795 CommentedTime marker(pos, oldcomment);
2796 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2797 if (d.exec() == QDialog::Accepted) {
2798 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2799 if (d.newMarker().time() != pos) {
2800 // remove old marker
2801 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2806 void MainWindow::slotAddMarkerGuideQuickly()
2808 if (!m_activeTimeline || !m_activeDocument)
2811 if (m_clipMonitor->isActive()) {
2812 DocClipBase *clip = m_clipMonitor->activeClip();
2813 GenTime pos = m_clipMonitor->position();
2816 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2820 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2822 m_activeTimeline->projectView()->slotAddGuide(false);
2826 void MainWindow::slotAddGuide()
2828 if (m_activeTimeline)
2829 m_activeTimeline->projectView()->slotAddGuide();
2832 void MainWindow::slotInsertSpace()
2834 if (m_activeTimeline)
2835 m_activeTimeline->projectView()->slotInsertSpace();
2838 void MainWindow::slotRemoveSpace()
2840 if (m_activeTimeline)
2841 m_activeTimeline->projectView()->slotRemoveSpace();
2844 void MainWindow::slotInsertTrack(int ix)
2846 m_projectMonitor->activateMonitor();
2847 if (m_activeTimeline)
2848 m_activeTimeline->projectView()->slotInsertTrack(ix);
2849 if (m_activeDocument)
2850 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2853 void MainWindow::slotDeleteTrack(int ix)
2855 m_projectMonitor->activateMonitor();
2856 if (m_activeTimeline)
2857 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2858 if (m_activeDocument)
2859 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2862 void MainWindow::slotConfigTrack(int ix)
2864 m_projectMonitor->activateMonitor();
2865 if (m_activeTimeline)
2866 m_activeTimeline->projectView()->slotConfigTracks(ix);
2867 if (m_activeDocument)
2868 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2871 void MainWindow::slotEditGuide()
2873 if (m_activeTimeline)
2874 m_activeTimeline->projectView()->slotEditGuide();
2877 void MainWindow::slotDeleteGuide()
2879 if (m_activeTimeline)
2880 m_activeTimeline->projectView()->slotDeleteGuide();
2883 void MainWindow::slotDeleteAllGuides()
2885 if (m_activeTimeline)
2886 m_activeTimeline->projectView()->slotDeleteAllGuides();
2889 void MainWindow::slotCutTimelineClip()
2891 if (m_activeTimeline)
2892 m_activeTimeline->projectView()->cutSelectedClips();
2895 void MainWindow::slotInsertClipOverwrite()
2897 if (m_activeTimeline) {
2898 QStringList data = m_clipMonitor->getZoneInfo();
2899 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2903 void MainWindow::slotSelectTimelineClip()
2905 if (m_activeTimeline)
2906 m_activeTimeline->projectView()->selectClip(true);
2909 void MainWindow::slotSelectTimelineTransition()
2911 if (m_activeTimeline)
2912 m_activeTimeline->projectView()->selectTransition(true);
2915 void MainWindow::slotDeselectTimelineClip()
2917 if (m_activeTimeline)
2918 m_activeTimeline->projectView()->selectClip(false, true);
2921 void MainWindow::slotDeselectTimelineTransition()
2923 if (m_activeTimeline)
2924 m_activeTimeline->projectView()->selectTransition(false, true);
2927 void MainWindow::slotSelectAddTimelineClip()
2929 if (m_activeTimeline)
2930 m_activeTimeline->projectView()->selectClip(true, true);
2933 void MainWindow::slotSelectAddTimelineTransition()
2935 if (m_activeTimeline)
2936 m_activeTimeline->projectView()->selectTransition(true, true);
2939 void MainWindow::slotGroupClips()
2941 if (m_activeTimeline)
2942 m_activeTimeline->projectView()->groupClips();
2945 void MainWindow::slotUnGroupClips()
2947 if (m_activeTimeline)
2948 m_activeTimeline->projectView()->groupClips(false);
2951 void MainWindow::slotEditItemDuration()
2953 if (m_activeTimeline)
2954 m_activeTimeline->projectView()->editItemDuration();
2957 void MainWindow::slotAddProjectClip(KUrl url)
2959 if (m_activeDocument)
2960 m_activeDocument->slotAddClipFile(url, QString());
2963 void MainWindow::slotAddTransition(QAction *result)
2965 if (!result) return;
2966 QStringList info = result->data().toStringList();
2967 if (info.isEmpty()) return;
2968 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2969 if (m_activeTimeline && !transition.isNull()) {
2970 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2974 void MainWindow::slotAddVideoEffect(QAction *result)
2976 if (!result) return;
2977 const int EFFECT_VIDEO = 1;
2978 const int EFFECT_AUDIO = 2;
2979 QStringList info = result->data().toStringList();
2981 if (info.isEmpty() || info.size() < 3) return;
2982 QDomElement effect ;
2983 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
2984 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
2985 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
2986 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
2988 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
2989 if (!effect.isNull()) slotAddEffect(effect);
2990 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
2993 void MainWindow::slotAddAudioEffect(QAction *result)
2995 if (!result) return;
2996 QStringList info = result->data().toStringList();
2997 if (info.isEmpty()) return;
2998 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2999 slotAddEffect(effect);
3002 void MainWindow::slotAddCustomEffect(QAction *result)
3004 if (!result) return;
3005 QStringList info = result->data().toStringList();
3006 if (info.isEmpty()) return;
3007 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
3008 slotAddEffect(effect);
3011 void MainWindow::slotZoomIn()
3013 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3014 slotShowZoomSliderToolTip();
3017 void MainWindow::slotZoomOut()
3019 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3020 slotShowZoomSliderToolTip();
3023 void MainWindow::slotFitZoom()
3025 if (m_activeTimeline)
3026 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3029 void MainWindow::slotSetZoom(int value)
3031 value = qMax(m_zoomSlider->minimum(), value);
3032 value = qMin(m_zoomSlider->maximum(), value);
3034 if (m_activeTimeline)
3035 m_activeTimeline->slotChangeZoom(value);
3037 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3038 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3039 slotUpdateZoomSliderToolTip(value);
3041 m_zoomSlider->blockSignals(true);
3042 m_zoomSlider->setValue(value);
3043 m_zoomSlider->blockSignals(false);
3046 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3048 if (zoomlevel != -1)
3049 slotUpdateZoomSliderToolTip(zoomlevel);
3051 QPoint global = m_zoomSlider->rect().topLeft();
3052 global.ry() += m_zoomSlider->height() / 2;
3053 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3054 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3057 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3059 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3062 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3064 m_statusProgressBar->setValue(progress);
3065 if (progress >= 0) {
3066 if (!message.isEmpty())
3067 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3068 m_statusProgressBar->setVisible(true);
3069 } else if (progress == -2) {
3070 if (!message.isEmpty())
3071 m_messageLabel->setMessage(message, ErrorMessage);
3072 m_statusProgressBar->setVisible(false);
3074 m_messageLabel->setMessage(QString(), DefaultMessage);
3075 m_statusProgressBar->setVisible(false);
3079 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3081 if (clip->clipType() == TEXT) {
3082 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3083 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3084 // template text clip
3086 // Get the list of existing templates
3088 filter << "*.kdenlivetitle";
3089 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3091 QDialog *dia = new QDialog(this);
3092 Ui::TemplateClip_UI dia_ui;
3093 dia_ui.setupUi(dia);
3095 const QString templatePath = clip->getProperty("resource");
3096 for (int i = 0; i < templateFiles.size(); ++i) {
3097 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3098 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3100 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3101 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3102 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3103 //warning: setting base directory doesn't work??
3104 KUrl startDir(titlepath);
3105 dia_ui.template_list->fileDialog()->setUrl(startDir);
3106 dia_ui.description->setText(clip->getProperty("description"));
3107 if (dia->exec() == QDialog::Accepted) {
3108 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3109 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3111 QMap <QString, QString> newprops;
3113 if (KUrl(textTemplate).path() != templatePath) {
3114 // The template was changed
3115 newprops.insert("resource", textTemplate);
3118 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3119 newprops.insert("description", dia_ui.description->toPlainText());
3122 QString newtemplate = newprops.value("xmltemplate");
3123 if (newtemplate.isEmpty()) newtemplate = templatePath;
3125 // template modified we need to update xmldata
3126 QString description = newprops.value("description");
3127 if (description.isEmpty()) description = clip->getProperty("description");
3128 else newprops.insert("templatetext", description);
3129 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3130 if (!newprops.isEmpty()) {
3131 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3132 m_activeDocument->commandStack()->push(command);
3138 QString path = clip->getProperty("resource");
3139 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3141 doc.setContent(clip->getProperty("xmldata"));
3142 dia_ui->setXml(doc);
3143 if (dia_ui->exec() == QDialog::Accepted) {
3144 QMap <QString, QString> newprops;
3145 newprops.insert("xmldata", dia_ui->xml().toString());
3146 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3147 // duration changed, we need to update duration
3148 newprops.insert("out", QString::number(dia_ui->outPoint()));
3149 int currentLength = QString(clip->producerProperty("length")).toInt();
3150 if (currentLength <= dia_ui->outPoint())
3151 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3152 else newprops.insert("length", clip->producerProperty("length"));
3154 if (!path.isEmpty()) {
3155 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3156 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) {
3157 // save to external file
3158 dia_ui->saveTitle(path);
3159 } else newprops.insert("resource", QString());
3161 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3162 m_activeDocument->commandStack()->push(command);
3163 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3164 m_activeDocument->setModified(true);
3168 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3172 // any type of clip but a title
3173 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3174 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3175 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)));
3180 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3182 if (newprops.isEmpty()) return;
3183 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3184 m_activeDocument->commandStack()->push(command);
3185 m_activeDocument->setModified();
3188 // update clip occurences in timeline
3189 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3194 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3196 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3197 if (dia.exec() == QDialog::Accepted) {
3198 QUndoCommand *command = new QUndoCommand();
3199 command->setText(i18n("Edit clips"));
3200 QMap <QString, QString> newImageProps = dia.properties();
3201 // Transparency setting applies only for images
3202 QMap <QString, QString> newProps = newImageProps;
3203 newProps.remove("transparency");
3205 for (int i = 0; i < cliplist.count(); i++) {
3206 DocClipBase *clip = cliplist.at(i);
3207 if (clip->clipType() == IMAGE)
3208 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3210 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3212 m_activeDocument->commandStack()->push(command);
3213 for (int i = 0; i < cliplist.count(); i++)
3214 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3218 void MainWindow::customEvent(QEvent* e)
3220 if (e->type() == QEvent::User)
3221 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3223 void MainWindow::slotActivateEffectStackView()
3225 m_effectStack->raiseWindow(m_effectStackDock);
3228 void MainWindow::slotActivateTransitionView(Transition *t)
3231 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3234 void MainWindow::slotSnapRewind()
3236 if (m_projectMonitor->isActive()) {
3237 if (m_activeTimeline)
3238 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3240 m_clipMonitor->slotSeekToPreviousSnap();
3244 void MainWindow::slotSnapForward()
3246 if (m_projectMonitor->isActive()) {
3247 if (m_activeTimeline)
3248 m_activeTimeline->projectView()->slotSeekToNextSnap();
3250 m_clipMonitor->slotSeekToNextSnap();
3254 void MainWindow::slotClipStart()
3256 if (m_projectMonitor->isActive()) {
3257 if (m_activeTimeline)
3258 m_activeTimeline->projectView()->clipStart();
3262 void MainWindow::slotClipEnd()
3264 if (m_projectMonitor->isActive()) {
3265 if (m_activeTimeline)
3266 m_activeTimeline->projectView()->clipEnd();
3270 void MainWindow::slotZoneStart()
3272 if (m_projectMonitor->isActive())
3273 m_projectMonitor->slotZoneStart();
3275 m_clipMonitor->slotZoneStart();
3278 void MainWindow::slotZoneEnd()
3280 if (m_projectMonitor->isActive())
3281 m_projectMonitor->slotZoneEnd();
3283 m_clipMonitor->slotZoneEnd();
3286 void MainWindow::slotChangeTool(QAction * action)
3288 if (action == m_buttonSelectTool)
3289 slotSetTool(SELECTTOOL);
3290 else if (action == m_buttonRazorTool)
3291 slotSetTool(RAZORTOOL);
3292 else if (action == m_buttonSpacerTool)
3293 slotSetTool(SPACERTOOL);
3296 void MainWindow::slotChangeEdit(QAction * action)
3298 if (!m_activeTimeline)
3301 if (action == m_overwriteEditTool)
3302 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3303 else if (action == m_insertEditTool)
3304 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3306 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3309 void MainWindow::slotSetTool(PROJECTTOOL tool)
3311 if (m_activeDocument && m_activeTimeline) {
3312 //m_activeDocument->setTool(tool);
3316 message = i18n("Ctrl + click to use spacer on current track only");
3319 message = i18n("Click on a clip to cut it");
3322 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3325 m_messageLabel->setMessage(message, InformationMessage);
3326 m_activeTimeline->projectView()->setTool(tool);
3330 void MainWindow::slotCopy()
3332 if (m_activeDocument && m_activeTimeline)
3333 m_activeTimeline->projectView()->copyClip();
3336 void MainWindow::slotPaste()
3338 if (m_activeDocument && m_activeTimeline)
3339 m_activeTimeline->projectView()->pasteClip();
3342 void MainWindow::slotPasteEffects()
3344 if (m_activeDocument && m_activeTimeline)
3345 m_activeTimeline->projectView()->pasteClipEffects();
3348 void MainWindow::slotFind()
3350 if (!m_activeDocument || !m_activeTimeline) return;
3351 m_projectSearch->setEnabled(false);
3352 m_findActivated = true;
3353 m_findString.clear();
3354 m_activeTimeline->projectView()->initSearchStrings();
3355 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3356 m_findTimer.start(5000);
3357 qApp->installEventFilter(this);
3360 void MainWindow::slotFindNext()
3362 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3363 statusBar()->showMessage(i18n("Found: %1", m_findString));
3365 statusBar()->showMessage(i18n("Reached end of project"));
3366 m_findTimer.start(4000);
3369 void MainWindow::findAhead()
3371 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3372 m_projectSearchNext->setEnabled(true);
3373 statusBar()->showMessage(i18n("Found: %1", m_findString));
3375 m_projectSearchNext->setEnabled(false);
3376 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3380 void MainWindow::findTimeout()
3382 m_projectSearchNext->setEnabled(false);
3383 m_findActivated = false;
3384 m_findString.clear();
3385 statusBar()->showMessage(i18n("Find stopped"), 3000);
3386 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3387 m_projectSearch->setEnabled(true);
3388 removeEventFilter(this);
3391 void MainWindow::slotClipInTimeline(const QString &clipId)
3393 if (m_activeTimeline && m_activeDocument) {
3394 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3396 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3397 inTimelineMenu->clear();
3399 QList <QAction *> actionList;
3401 for (int i = 0; i < matching.count(); ++i) {
3402 QString track = QString::number(matching.at(i).track);
3403 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3405 QAction *a = new QAction(track + ": " + start, this);
3406 a->setData(QStringList() << track << start);
3407 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3408 while (j < actionList.count()) {
3409 if (actionList.at(j)->text() > a->text()) break;
3412 actionList.insert(j, a);
3414 inTimelineMenu->addActions(actionList);
3416 if (matching.empty())
3417 inTimelineMenu->setEnabled(false);
3419 inTimelineMenu->setEnabled(true);
3423 void MainWindow::slotClipInProjectTree()
3425 if (m_activeTimeline) {
3426 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3427 if (clipIds.isEmpty())
3429 m_projectListDock->raise();
3430 for (int i = 0; i < clipIds.count(); i++)
3431 m_projectList->selectItemById(clipIds.at(i));
3432 if (m_projectMonitor->isActive())
3433 slotSwitchMonitors();
3437 /*void MainWindow::slotClipToProjectTree()
3439 if (m_activeTimeline) {
3440 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3441 if (clips.isEmpty()) return;
3442 for (int i = 0; i < clips.count(); i++) {
3443 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3445 //m_projectList->selectItemById(clipIds.at(i));
3449 void MainWindow::slotSelectClipInTimeline()
3451 if (m_activeTimeline) {
3452 QAction *action = qobject_cast<QAction *>(sender());
3453 QStringList data = action->data().toStringList();
3454 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3458 void MainWindow::keyPressEvent(QKeyEvent *ke)
3460 if (m_findActivated) {
3461 if (ke->key() == Qt::Key_Backspace) {
3462 m_findString = m_findString.left(m_findString.length() - 1);
3464 if (!m_findString.isEmpty())
3469 m_findTimer.start(4000);
3472 } else if (ke->key() == Qt::Key_Escape) {
3476 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3477 m_findString += ke->text();
3481 m_findTimer.start(4000);
3486 KXmlGuiWindow::keyPressEvent(ke);
3491 /** Gets called when the window gets hidden */
3492 void MainWindow::hideEvent(QHideEvent */*event*/)
3494 if (isMinimized() && m_monitorManager)
3495 m_monitorManager->stopActiveMonitor();
3498 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3500 if (m_findActivated) {
3501 if (event->type() == QEvent::ShortcutOverride) {
3502 QKeyEvent* ke = (QKeyEvent*) event;
3503 if (ke->text().trimmed().isEmpty()) return false;
3510 // pass the event on to the parent class
3511 return QMainWindow::eventFilter(obj, event);
3516 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3518 KDialog *dialog = new KDialog(this);
3519 dialog->setCaption("Save clip zone");
3520 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3522 QWidget *widget = new QWidget(dialog);
3523 dialog->setMainWidget(widget);
3525 QVBoxLayout *vbox = new QVBoxLayout(widget);
3526 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3527 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3528 path.append("untitled.mlt");
3529 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3530 url->setFilter("video/mlt-playlist");
3531 QLabel *label2 = new QLabel(i18n("Description:"), this);
3532 KLineEdit *edit = new KLineEdit(this);
3533 vbox->addWidget(label1);
3534 vbox->addWidget(url);
3535 vbox->addWidget(label2);
3536 vbox->addWidget(edit);
3537 if (dialog->exec() == QDialog::Accepted)
3538 render->saveZone(url->url(), edit->text(), zone);
3542 void MainWindow::slotSetInPoint()
3544 if (m_clipMonitor->isActive())
3545 m_clipMonitor->slotSetZoneStart();
3547 m_projectMonitor->slotSetZoneStart();
3548 //else m_activeTimeline->projectView()->setInPoint();
3551 void MainWindow::slotSetOutPoint()
3553 if (m_clipMonitor->isActive())
3554 m_clipMonitor->slotSetZoneEnd();
3556 m_projectMonitor->slotSetZoneEnd();
3557 // else m_activeTimeline->projectView()->setOutPoint();
3560 void MainWindow::slotResizeItemStart()
3562 if (m_activeTimeline)
3563 m_activeTimeline->projectView()->setInPoint();
3566 void MainWindow::slotResizeItemEnd()
3568 if (m_activeTimeline)
3569 m_activeTimeline->projectView()->setOutPoint();
3572 int MainWindow::getNewStuff(const QString &configFile)
3574 KNS3::Entry::List entries;
3575 #if KDE_IS_VERSION(4,3,80)
3576 KNS3::DownloadDialog dialog(configFile);
3578 entries = dialog.changedEntries();
3579 foreach(const KNS3::Entry & entry, entries) {
3580 if (entry.status() == KNS3::Entry::Installed)
3581 kDebug() << "// Installed files: " << entry.installedFiles();
3584 KNS::Engine engine(0);
3585 if (engine.init(configFile))
3586 entries = engine.downloadDialogModal(this);
3587 foreach(KNS::Entry * entry, entries) {
3588 if (entry->status() == KNS::Entry::Installed)
3589 kDebug() << "// Installed files: " << entry->installedFiles();
3591 #endif /* KDE_IS_VERSION(4,3,80) */
3592 return entries.size();
3595 void MainWindow::slotGetNewTitleStuff()
3597 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3598 TitleWidget::refreshTitleTemplates();
3601 void MainWindow::slotGetNewLumaStuff()
3603 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3604 initEffects::refreshLumas();
3605 m_activeTimeline->projectView()->reloadTransitionLumas();
3609 void MainWindow::slotGetNewRenderStuff()
3611 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3613 m_renderWidget->reloadProfiles();
3616 void MainWindow::slotGetNewMltProfileStuff()
3618 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3619 // update the list of profiles in settings dialog
3620 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3626 void MainWindow::slotAutoTransition()
3628 if (m_activeTimeline)
3629 m_activeTimeline->projectView()->autoTransition();
3632 void MainWindow::slotSplitAudio()
3634 if (m_activeTimeline)
3635 m_activeTimeline->projectView()->splitAudio();
3638 void MainWindow::slotUpdateClipType(QAction *action)
3640 if (m_activeTimeline) {
3641 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3642 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3643 else m_activeTimeline->projectView()->setAudioAndVideo();
3647 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3649 // We must stop the monitors since we create a new on in the dvd wizard
3650 m_clipMonitor->stop();
3651 m_projectMonitor->stop();
3652 DvdWizard w(url, profile, this);
3654 m_projectMonitor->start();
3657 void MainWindow::slotShowTimeline(bool show)
3659 if (show == false) {
3660 m_timelineState = saveState();
3661 centralWidget()->setHidden(true);
3663 centralWidget()->setHidden(false);
3664 restoreState(m_timelineState);
3668 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3670 //TODO: is there a way to maximize current widget?
3673 m_timelineState = saveState();
3674 QWidget *par = focusWidget()->parentWidget();
3675 while (par->parentWidget() && par->parentWidget() != this)
3676 par = par->parentWidget();
3677 kDebug() << "CURRENT WIDGET: " << par->objectName();
3680 //centralWidget()->setHidden(false);
3681 //restoreState(m_timelineState);
3685 void MainWindow::loadTranscoders()
3687 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3690 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3691 KConfigGroup transConfig(config, "Transcoding");
3693 QMap< QString, QString > profiles = transConfig.entryMap();
3694 QMapIterator<QString, QString> i(profiles);
3695 while (i.hasNext()) {
3697 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3698 QAction *a = transMenu->addAction(i.key());
3700 if (data.count() > 1)
3701 a->setToolTip(data.at(1));
3702 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3706 void MainWindow::slotTranscode(KUrl::List urls)
3711 if (urls.isEmpty()) {
3712 QAction *action = qobject_cast<QAction *>(sender());
3713 QStringList data = action->data().toStringList();
3714 params = data.at(0);
3715 if (data.count() > 1) desc = data.at(1);
3716 if (data.count() > 2) condition = data.at(2);
3717 urls << m_projectList->getConditionalUrls(condition);
3718 urls.removeAll(KUrl());
3720 if (urls.isEmpty()) {
3721 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3724 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3725 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3727 //QProcess::startDetached("ffmpeg", parameters);
3730 void MainWindow::slotTranscodeClip()
3732 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3733 if (urls.isEmpty()) return;
3734 slotTranscode(urls);
3737 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3739 if (m_activeDocument == NULL) return;
3740 QMapIterator<QString, QString> i(props);
3741 while (i.hasNext()) {
3743 m_activeDocument->setDocumentProperty(i.key(), i.value());
3745 m_activeDocument->setModified(true);
3749 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3751 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3753 QString playlistPath;
3756 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3757 QString path = m_renderWidget->getFreeScriptName();
3758 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3759 if (!ok || scriptPath.isEmpty()) return;
3760 scriptPath.prepend(scriptsFolder);
3761 QFile f(scriptPath);
3763 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3766 playlistPath = scriptPath + ".mlt";
3768 KTemporaryFile temp;
3769 temp.setAutoRemove(false);
3770 temp.setSuffix(".mlt");
3772 playlistPath = temp.fileName();
3774 QString playlistContent = m_projectMonitor->sceneList();
3775 if (!chapterFile.isEmpty()) {
3778 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3780 in = m_activeTimeline->inPoint();
3781 out = m_activeTimeline->outPoint();
3784 QDomElement chapters = doc.createElement("chapters");
3785 chapters.setAttribute("fps", m_activeDocument->fps());
3786 doc.appendChild(chapters);
3788 QDomElement guidesxml = m_activeDocument->guidesXml();
3789 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3790 for (int i = 0; i < nodes.count(); i++) {
3791 QDomElement e = nodes.item(i).toElement();
3793 QString comment = e.attribute("comment");
3794 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3795 if (time >= in && time < out) {
3796 if (zoneOnly) time = time - in;
3797 QDomElement chapter = doc.createElement("chapter");
3798 chapters.appendChild(chapter);
3799 chapter.setAttribute("title", comment);
3800 chapter.setAttribute("time", time);
3804 if (chapters.childNodes().count() > 0) {
3805 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3806 // Always insert a guide in pos 0
3807 QDomElement chapter = doc.createElement("chapter");
3808 chapters.insertBefore(chapter, QDomNode());
3809 chapter.setAttribute("title", i18n("Start"));
3810 chapter.setAttribute("time", "0");
3812 // save chapters file
3813 QFile file(chapterFile);
3814 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3815 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3817 file.write(doc.toString().toUtf8());
3818 if (file.error() != QFile::NoError) {
3819 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3826 if (m_renderWidget->automaticAudioExport()) {
3827 exportAudio = m_activeTimeline->checkProjectAudio();
3828 } else exportAudio = m_renderWidget->selectedAudioExport();
3830 // Do we want proxy rendering
3831 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3833 doc.setContent(playlistContent);
3834 QString root = doc.documentElement().attribute("root");
3836 // replace proxy clips with originals
3837 QMap <QString, QString> proxies = m_projectList->getProxies();
3838 QMapIterator<QString, QString> i(proxies);
3839 while (i.hasNext()) {
3841 // Replace all keys with their values (proxy path with original path)
3842 QString key = i.key();
3843 playlistContent.replace(key, i.value());
3844 if (!root.isEmpty() && key.startsWith(root)) {
3845 // in case ther resource path in MLT playlist is relative
3846 key.remove(0, root.count() + 1);
3847 playlistContent.replace(key, i.value());
3852 // Do save scenelist
3853 QFile file(playlistPath);
3854 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3855 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3858 file.write(playlistContent.toUtf8());
3859 if (file.error() != QFile::NoError) {
3860 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3865 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3868 void MainWindow::slotUpdateTimecodeFormat(int ix)
3870 KdenliveSettings::setFrametimecode(ix == 1);
3871 m_clipMonitor->updateTimecodeFormat();
3872 m_projectMonitor->updateTimecodeFormat();
3873 m_transitionConfig->updateTimecodeFormat();
3874 m_effectStack->updateTimecodeFormat();
3875 //m_activeTimeline->projectView()->clearSelection();
3876 m_activeTimeline->updateRuler();
3879 void MainWindow::slotRemoveFocus()
3881 statusBar()->setFocus();
3882 statusBar()->clearFocus();
3885 void MainWindow::slotRevert()
3887 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;
3888 KUrl url = m_activeDocument->url();
3889 if (closeCurrentDocument(false))
3890 doOpenFile(url, NULL);
3894 void MainWindow::slotShutdown()
3896 if (m_activeDocument) m_activeDocument->setModified(false);
3898 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3899 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3900 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3901 smserver.call("logout", 1, 2, 2);
3902 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3903 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3904 smserver.call("Shutdown");
3908 void MainWindow::slotUpdateTrackInfo()
3910 if (m_activeDocument)
3911 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3914 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3916 // Load the theme file
3918 if (action == NULL) theme = themename;
3919 else theme = action->data().toString();
3920 KdenliveSettings::setColortheme(theme);
3921 // Make palette for all widgets.
3923 if (theme.isEmpty()) {
3924 plt = QApplication::desktop()->palette();
3926 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3927 plt = KGlobalSettings::createApplicationPalette(config);
3930 kapp->setPalette(plt);
3931 const QObjectList children = statusBar()->children();
3933 foreach(QObject * child, children) {
3934 if (child->isWidgetType())
3935 ((QWidget*)child)->setPalette(plt);
3936 const QObjectList subchildren = child->children();
3937 foreach(QObject * subchild, subchildren) {
3938 if (subchild->isWidgetType())
3939 ((QWidget*)subchild)->setPalette(plt);
3942 if (m_activeTimeline) {
3943 m_activeTimeline->projectView()->updatePalette();
3948 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3950 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3951 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3952 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3953 const QSize bitsSize(24, 2);
3954 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3955 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3957 QPixmap pixmap(23, 16);
3958 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3960 KConfigGroup group(config, "WM");
3961 QPainter p(&pixmap);
3962 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3963 p.fillRect(1, 1, 7, 7, windowScheme.background());
3964 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3966 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3967 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3968 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3970 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3971 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3973 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3974 p.fillRect(1, 8, 7, 7, viewScheme.background());
3975 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3977 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3978 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3979 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3981 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3982 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3988 void MainWindow::slotSwitchMonitors()
3990 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3991 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3992 else m_projectList->focusTree();
3995 void MainWindow::slotSwitchFullscreen()
3997 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3998 else m_clipMonitor->slotSwitchFullScreen();
4001 void MainWindow::slotInsertZoneToTree()
4003 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4004 QStringList info = m_clipMonitor->getZoneInfo();
4005 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4008 void MainWindow::slotInsertZoneToTimeline()
4010 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4011 QStringList info = m_clipMonitor->getZoneInfo();
4012 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4016 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4018 if (m_activeDocument && m_activeTimeline) {
4019 if (!ids.isEmpty()) {
4020 for (int i = 0; i < ids.size(); ++i) {
4021 m_activeTimeline->slotDeleteClip(ids.at(i));
4023 m_activeDocument->clipManager()->slotDeleteClips(ids);
4025 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4026 m_activeDocument->setModified(true);
4030 void MainWindow::slotShowTitleBars(bool show)
4032 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4033 for (int i = 0; i < docks.count(); i++) {
4034 QDockWidget* dock = docks.at(i);
4036 dock->setTitleBarWidget(0);
4038 if (!dock->isFloating()) {
4039 dock->setTitleBarWidget(new QWidget);
4043 KdenliveSettings::setShowtitlebars(show);
4046 void MainWindow::slotSwitchTitles()
4048 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4051 QString MainWindow::getMimeType()
4053 QString mimetype = "application/x-kdenlive";
4054 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4055 if (!mime) mimetype = "*.kdenlive";
4059 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4062 m_projectMonitor->render->sendFrameForAnalysis = true;
4065 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4066 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4073 qDebug() << "Any scope accepting new frames? " << request;
4076 m_projectMonitor->render->sendFrameForAnalysis = false;
4080 void MainWindow::slotUpdateGfxScopeFrameRequest()
4082 // We need a delay to make sure widgets are hidden after a close event for example
4083 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4086 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4089 bool request = false;
4090 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4091 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4092 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4098 if (!m_projectMonitor->effectSceneDisplayed()) {
4099 m_projectMonitor->render->sendFrameForAnalysis = false;
4101 m_clipMonitor->render->sendFrameForAnalysis = false;
4103 m_projectMonitor->render->sendFrameForAnalysis = true;
4104 m_clipMonitor->render->sendFrameForAnalysis = true;
4108 void MainWindow::slotUpdateAudioScopeFrameRequest()
4110 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4113 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4115 bool request = false;
4116 for (int i = 0; i < m_audioScopesList.count(); i++) {
4117 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4118 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4123 // Handle audio signal separately (no common interface)
4124 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4125 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4129 qDebug() << "Scopes Requesting Audio data: " << request;
4131 KdenliveSettings::setMonitor_audio(request);
4132 m_monitorManager->slotUpdateAudioMonitoring();
4135 void MainWindow::slotUpdateColorScopes()
4137 bool request = false;
4138 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4139 // Check if we need the renderer to send a new frame for update
4140 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4141 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4144 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4145 else m_projectMonitor->render->sendFrameUpdate();
4149 void MainWindow::slotOpenStopmotion()
4151 if (m_stopmotion == NULL) {
4152 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4153 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4154 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4155 // Check if we need the renderer to send a new frame for update
4156 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4157 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4158 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4161 m_stopmotion->show();
4164 void MainWindow::slotDeleteClip(const QString &id)
4166 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4167 for (int i = 0; i < list.size(); ++i) {
4168 list.at(i)->disableClipId(id);
4170 m_projectList->slotDeleteClip(id);
4173 void MainWindow::slotUpdateProxySettings()
4175 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4176 if (KdenliveSettings::enableproxy())
4177 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4178 m_projectList->updateProxyConfig();
4181 #include "mainwindow.moc"