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);
201 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
203 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
204 m_projectMonitorDock->setObjectName("project_monitor");
205 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
206 m_projectMonitorDock->setWidget(m_projectMonitor);
207 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
210 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
211 m_recMonitorDock->setObjectName("record_monitor");
212 m_recMonitor = new RecMonitor("record");
213 m_recMonitorDock->setWidget(m_recMonitor);
214 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
215 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
216 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
219 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
220 m_notesDock->setObjectName("notes_widget");
221 m_notesWidget = new KTextEdit();
222 m_notesWidget->setTabChangesFocus(true);
223 #if KDE_IS_VERSION(4,4,0)
224 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
226 m_notesDock->setWidget(m_notesWidget);
227 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
229 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
230 m_effectStackDock->setObjectName("effect_stack");
231 m_effectStack = new EffectStackView(m_projectMonitor);
232 m_effectStackDock->setWidget(m_effectStack);
233 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
235 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
236 m_transitionConfigDock->setObjectName("transition");
237 m_transitionConfig = new TransitionSettings(m_projectMonitor);
238 m_transitionConfigDock->setWidget(m_transitionConfig);
239 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
241 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
242 m_effectListDock->setObjectName("effect_list");
243 m_effectList = new EffectsListView();
244 m_effectListDock->setWidget(m_effectList);
245 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
247 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
248 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
249 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
250 m_vectorscopeDock->setWidget(m_vectorscope);
251 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
252 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
253 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
254 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
255 m_gfxScopesList.append(m_vectorscopeDock);
257 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
258 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
259 m_waveformDock->setObjectName(m_waveform->widgetName());
260 m_waveformDock->setWidget(m_waveform);
261 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
262 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
263 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
264 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
265 m_gfxScopesList.append(m_waveformDock);
267 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
268 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
269 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
270 m_RGBParadeDock->setWidget(m_RGBParade);
271 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
272 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
273 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
274 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
275 m_gfxScopesList.append(m_RGBParadeDock);
277 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
278 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
279 m_histogramDock->setObjectName(m_histogram->widgetName());
280 m_histogramDock->setWidget(m_histogram);
281 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
282 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
283 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
284 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
285 m_gfxScopesList.append(m_histogramDock);
288 m_audiosignal = new AudioSignal;
289 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
290 m_audiosignalDock->setObjectName("audiosignal");
291 m_audiosignalDock->setWidget(m_audiosignal);
292 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
293 // connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
294 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
295 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
297 m_audioSpectrum = new AudioSpectrum();
298 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
299 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
300 m_audioSpectrumDock->setWidget(m_audioSpectrum);
301 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
302 m_audioScopesList.append(m_audioSpectrum);
303 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
304 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
306 m_spectrogram = new Spectrogram();
307 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
308 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
309 m_spectrogramDock->setWidget(m_spectrogram);
310 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
311 m_audioScopesList.append(m_spectrogram);
312 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
313 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
315 // Connect the audio signal to the audio scope slots
317 if (m_projectMonitor) {
318 qDebug() << "project monitor connected";
319 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
320 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
321 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
322 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
323 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
324 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
327 qDebug() << "clip monitor connected";
328 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
329 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
330 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
331 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
332 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
333 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
335 // Ensure connections were set up correctly
338 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
339 m_undoViewDock->setObjectName("undo_history");
340 m_undoView = new QUndoView();
341 m_undoView->setCleanIcon(KIcon("edit-clear"));
342 m_undoView->setEmptyLabel(i18n("Clean"));
343 m_undoViewDock->setWidget(m_undoView);
344 m_undoView->setGroup(m_commandStack);
345 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
347 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
348 //overviewDock->setObjectName("project_overview");
349 //m_overView = new CustomTrackView(NULL, NULL, this);
350 //overviewDock->setWidget(m_overView);
351 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
356 /// Tabify Widgets ///
357 tabifyDockWidget(m_projectListDock, m_effectStackDock);
358 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
359 tabifyDockWidget(m_projectListDock, m_notesDock);
362 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
364 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
367 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
368 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
369 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
370 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
371 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
373 tabifyDockWidget(m_vectorscopeDock, m_spectrogramDock);
374 tabifyDockWidget(m_vectorscopeDock, m_audioSpectrumDock);
377 setCentralWidget(m_timelineArea);
380 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
382 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
383 m_fileRevert->setEnabled(false);
385 // Prepare layout actions
386 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
387 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
388 for (int i = 1; i < 5; i++) {
389 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
390 load->setData("_" + QString::number(i));
391 layoutActions->addAction("load_layout" + QString::number(i), load);
392 m_loadLayout->addAction(load);
393 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
394 save->setData("_" + QString::number(i));
395 layoutActions->addAction("save_layout" + QString::number(i), save);
397 layoutActions->addAction("load_layouts", m_loadLayout);
398 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
401 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
402 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
403 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
404 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
405 m_stopmotion_actions->addAction("stopmotion_capture", action);
406 action = new KAction(i18n("Switch live / captured frame"), this);
407 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
408 m_stopmotion_actions->addAction("stopmotion_switch", action);
409 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
410 action->setCheckable(true);
411 action->setChecked(false);
412 m_stopmotion_actions->addAction("stopmotion_overlay", action);
414 // Build effects menu
415 m_effectsMenu = new QMenu(i18n("Add Effect"));
416 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
417 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
418 m_effectsActionCollection->readSettings();
423 // Find QDockWidget tab bars and show / hide widget title bars on right click
424 QList <QTabBar *> tabs = findChildren<QTabBar *>();
425 for (int i = 0; i < tabs.count(); i++) {
426 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
427 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
430 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
431 guiFactory()->addClient(sp);*/
433 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
435 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
438 // Load layout names from config file
443 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
445 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
446 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
448 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
449 clipInTimeline->setIcon(KIcon("go-jump"));
450 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
451 static_cast<QMenu*>(factory()->container("transcoders", this)),
454 // build themes menus
455 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
456 QActionGroup *themegroup = new QActionGroup(this);
457 themegroup->setExclusive(true);
458 action = new KAction(i18n("Default"), this);
459 action->setCheckable(true);
460 themegroup->addAction(action);
461 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
463 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
465 for (int i = 0; i < schemeFiles.size(); ++i) {
467 const QString filename = schemeFiles.at(i);
468 const QFileInfo info(filename);
471 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
472 QIcon icon = createSchemePreviewIcon(config);
473 KConfigGroup group(config, "General");
474 const QString name = group.readEntry("Name", info.baseName());
475 action = new KAction(name, this);
476 action->setData(filename);
477 action->setIcon(icon);
478 action->setCheckable(true);
479 themegroup->addAction(action);
480 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
483 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
484 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
485 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
488 action = new QAction(fi.fileName(), this);
489 action->setData(*it);
490 action->setCheckable(true);
491 themegroup->addAction(action);
492 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
494 themesMenu->addActions(themegroup->actions());
495 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
497 // Setup and fill effects and transitions menus.
500 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
504 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
505 for (int i = 0; i < transitions.count(); ++i)
506 m_transitionsMenu->addAction(m_transitions[i]);
508 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
509 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
511 m_effectStack->setMenu(m_effectsMenu);
513 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
514 const QList<QAction *> viewActions = createPopupMenu()->actions();
515 viewMenu->insertActions(NULL, viewActions);
517 m_timelineContextMenu = new QMenu(this);
518 m_timelineContextClipMenu = new QMenu(this);
519 m_timelineContextTransitionMenu = new QMenu(this);
521 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
522 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
523 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
525 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
526 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
527 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
528 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
529 m_timelineContextClipMenu->addSeparator();
530 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
531 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
532 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
533 m_timelineContextClipMenu->addSeparator();
534 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
535 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
536 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
537 m_timelineContextClipMenu->addSeparator();
539 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
540 m_timelineContextClipMenu->addMenu(markersMenu);
541 m_timelineContextClipMenu->addSeparator();
542 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
543 m_timelineContextClipMenu->addMenu(m_effectsMenu);
545 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
546 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
547 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
549 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
551 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
552 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
553 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
554 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
555 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
556 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
557 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
559 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
560 slotConnectMonitors();
562 // Open or create a file. Command line argument passed in Url has
563 // precedence, then "openlastproject", then just a plain empty file.
564 // If opening Url fails, openlastproject will _not_ be used.
565 if (!Url.isEmpty()) {
566 // delay loading so that the window shows up
568 QTimer::singleShot(500, this, SLOT(openFile()));
569 } else if (KdenliveSettings::openlastproject()) {
570 QTimer::singleShot(500, this, SLOT(openLastFile()));
571 } else { //if (m_timelineArea->count() == 0) {
575 if (!clipsToLoad.isEmpty() && m_activeDocument) {
576 QStringList list = clipsToLoad.split(',');
578 foreach(QString path, list) {
579 kDebug() << QDir::current().absoluteFilePath(path);
580 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
582 m_projectList->slotAddClip(urls);
585 #ifndef NO_JOGSHUTTLE
586 activateShuttleDevice();
587 #endif /* NO_JOGSHUTTLE */
588 m_projectListDock->raise();
590 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
591 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
594 MainWindow::~MainWindow()
599 m_effectStack->slotClipItemSelected(NULL, 0);
600 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
602 if (m_projectMonitor) m_projectMonitor->stop();
603 if (m_clipMonitor) m_clipMonitor->stop();
605 delete m_activeTimeline;
606 delete m_effectStack;
607 delete m_transitionConfig;
608 delete m_activeDocument;
609 delete m_projectMonitor;
610 delete m_clipMonitor;
611 delete m_shortcutRemoveFocus;
612 Mlt::Factory::close();
616 bool MainWindow::queryClose()
618 if (m_renderWidget) {
619 int waitingJobs = m_renderWidget->waitingJobsCount();
620 if (waitingJobs > 0) {
621 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")))) {
622 case KMessageBox::Yes :
623 // create script with waiting jobs and start it
624 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
626 case KMessageBox::No :
627 // Don't do anything, jobs will be deleted
635 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
636 // warn the user to save if document is modified and we have clips in our project list
637 if (m_activeDocument && m_activeDocument->isModified() &&
638 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
639 !m_projectList->documentClipList().isEmpty())) {
643 if (m_activeDocument->url().fileName().isEmpty())
644 message = i18n("Save changes to document?");
646 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
647 switch (KMessageBox::warningYesNoCancel(this, message)) {
648 case KMessageBox::Yes :
649 // save document here. If saving fails, return false;
651 case KMessageBox::No :
652 // User does not want to save the changes, clear recovery files
653 m_activeDocument->m_autosave->resize(0);
662 void MainWindow::loadPlugins()
664 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
665 populateMenus(plugin);
668 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
670 filters << "libkdenlive*";
671 foreach(const QString & folder, directories) {
672 kDebug() << "Parsing plugin folder: " << folder;
673 QDir pluginsDir(folder);
674 foreach(const QString & fileName,
675 pluginsDir.entryList(filters, QDir::Files)) {
677 * Avoid loading the same plugin twice when there is more than one
680 if (!m_pluginFileNames.contains(fileName)) {
681 kDebug() << "Found plugin: " << fileName;
682 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
683 QObject *plugin = loader.instance();
685 populateMenus(plugin);
686 m_pluginFileNames += fileName;
688 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
694 void MainWindow::populateMenus(QObject *plugin)
696 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
697 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
699 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
703 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
704 QMenu *menu, const char *member,
705 QActionGroup *actionGroup)
707 kDebug() << "// ADD to MENU" << texts;
708 foreach(const QString & text, texts) {
709 QAction *action = new QAction(text, plugin);
710 action->setData(text);
711 connect(action, SIGNAL(triggered()), this, member);
712 menu->addAction(action);
715 action->setCheckable(true);
716 actionGroup->addAction(action);
721 void MainWindow::aboutPlugins()
723 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
728 void MainWindow::generateClip()
730 QAction *action = qobject_cast<QAction *>(sender());
731 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
733 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
734 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
735 if (!clipUrl.isEmpty()) {
736 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
740 void MainWindow::saveProperties(KConfigGroup &config)
742 // save properties here,used by session management
744 KMainWindow::saveProperties(config);
748 void MainWindow::readProperties(const KConfigGroup &config)
750 // read properties here,used by session management
751 KMainWindow::readProperties(config);
752 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
753 openFile(KUrl(Lastproject));
756 void MainWindow::slotReloadEffects()
758 initEffects::parseCustomEffectsFile();
759 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
762 #ifndef NO_JOGSHUTTLE
763 void MainWindow::activateShuttleDevice()
769 if (KdenliveSettings::enableshuttle() == false) return;
771 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
772 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
774 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
775 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
776 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
777 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
778 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
780 #endif /* NO_JOGSHUTTLE */
782 void MainWindow::slotDoAction(const QString& action_name)
784 QAction* action = actionCollection()->action(action_name);
786 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
792 void MainWindow::configureNotifications()
794 KNotifyConfigWidget::configure(this);
797 void MainWindow::slotFullScreen()
799 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
802 void MainWindow::slotAddEffect(const QDomElement effect)
804 if (!m_activeDocument) return;
805 if (effect.isNull()) {
806 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
809 QDomElement effectToAdd = effect.cloneNode().toElement();
811 int ix = m_effectStack->isTrackMode(&ok);
812 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
813 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
816 void MainWindow::slotRaiseMonitor(bool clipMonitor)
818 if (clipMonitor) m_clipMonitorDock->raise();
819 else m_projectMonitorDock->raise();
822 void MainWindow::slotUpdateClip(const QString &id)
824 if (!m_activeDocument) return;
825 m_activeTimeline->projectView()->slotUpdateClip(id);
828 void MainWindow::slotConnectMonitors()
830 m_projectList->setRenderer(m_projectMonitor->render);
831 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
832 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
833 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
834 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
835 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool, bool)));
836 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
837 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)));
839 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
840 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &)));
842 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
844 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
845 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
847 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
849 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
850 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
853 void MainWindow::slotAdjustClipMonitor()
855 m_clipMonitorDock->updateGeometry();
856 m_clipMonitorDock->adjustSize();
857 m_clipMonitor->resetSize();
860 void MainWindow::slotAdjustProjectMonitor()
862 m_projectMonitorDock->updateGeometry();
863 m_projectMonitorDock->adjustSize();
864 m_projectMonitor->resetSize();
868 class NameGrabbingKActionCollection {
870 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
871 : m_collection(collection), m_action_names(action_names) {
872 m_action_names.clear();
874 KAction* addAction(const QString& action_name) {
875 m_action_names << action_name;
876 return m_collection->addAction(action_name);
878 void addAction(const QString& action_name, QAction* action) {
879 m_action_names << action_name;
880 m_collection->addAction(action_name, action);
882 operator KActionCollection*() { return m_collection; }
883 const QStringList& actionNames() const { return m_action_names; }
885 KActionCollection* m_collection;
886 QStringList& m_action_names;
889 void MainWindow::setupActions()
892 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
893 m_timecodeFormat = new KComboBox(this);
894 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
895 m_timecodeFormat->addItem(i18n("Frames"));
896 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
897 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
899 m_statusProgressBar = new QProgressBar(this);
900 m_statusProgressBar->setMinimum(0);
901 m_statusProgressBar->setMaximum(100);
902 m_statusProgressBar->setMaximumWidth(150);
903 m_statusProgressBar->setVisible(false);
905 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
906 toolbar->setMovable(false);
907 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
908 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
909 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
910 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
911 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
912 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());
913 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
915 //create edit mode buttons
916 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
917 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
918 toolbar->addAction(m_normalEditTool);
919 m_normalEditTool->setCheckable(true);
920 m_normalEditTool->setChecked(true);
922 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
923 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
924 toolbar->addAction(m_overwriteEditTool);
925 m_overwriteEditTool->setCheckable(true);
926 m_overwriteEditTool->setChecked(false);
928 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
929 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
930 toolbar->addAction(m_insertEditTool);
931 m_insertEditTool->setCheckable(true);
932 m_insertEditTool->setChecked(false);
933 // not implemented yet
934 m_insertEditTool->setEnabled(false);
936 QActionGroup *editGroup = new QActionGroup(this);
937 editGroup->addAction(m_normalEditTool);
938 editGroup->addAction(m_overwriteEditTool);
939 editGroup->addAction(m_insertEditTool);
940 editGroup->setExclusive(true);
941 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
942 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
944 toolbar->addSeparator();
946 // create tools buttons
947 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
948 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
949 toolbar->addAction(m_buttonSelectTool);
950 m_buttonSelectTool->setCheckable(true);
951 m_buttonSelectTool->setChecked(true);
953 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
954 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
955 toolbar->addAction(m_buttonRazorTool);
956 m_buttonRazorTool->setCheckable(true);
957 m_buttonRazorTool->setChecked(false);
959 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
960 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
961 toolbar->addAction(m_buttonSpacerTool);
962 m_buttonSpacerTool->setCheckable(true);
963 m_buttonSpacerTool->setChecked(false);
965 QActionGroup *toolGroup = new QActionGroup(this);
966 toolGroup->addAction(m_buttonSelectTool);
967 toolGroup->addAction(m_buttonRazorTool);
968 toolGroup->addAction(m_buttonSpacerTool);
969 toolGroup->setExclusive(true);
970 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
972 QWidget * actionWidget;
973 int max = toolbar->iconSizeDefault() + 2;
974 actionWidget = toolbar->widgetForAction(m_normalEditTool);
975 actionWidget->setMaximumWidth(max);
976 actionWidget->setMaximumHeight(max - 4);
978 actionWidget = toolbar->widgetForAction(m_insertEditTool);
979 actionWidget->setMaximumWidth(max);
980 actionWidget->setMaximumHeight(max - 4);
982 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
983 actionWidget->setMaximumWidth(max);
984 actionWidget->setMaximumHeight(max - 4);
986 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
987 actionWidget->setMaximumWidth(max);
988 actionWidget->setMaximumHeight(max - 4);
990 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
991 actionWidget->setMaximumWidth(max);
992 actionWidget->setMaximumHeight(max - 4);
994 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
995 actionWidget->setMaximumWidth(max);
996 actionWidget->setMaximumHeight(max - 4);
998 toolbar->setStyleSheet(style1);
999 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1001 toolbar->addSeparator();
1002 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1003 toolbar->addAction(m_buttonFitZoom);
1004 m_buttonFitZoom->setCheckable(false);
1006 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1007 toolbar->addAction(m_zoomOut);
1008 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1010 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1011 m_zoomSlider->setMaximum(13);
1012 m_zoomSlider->setPageStep(1);
1013 m_zoomSlider->setInvertedAppearance(true);
1015 m_zoomSlider->setMaximumWidth(150);
1016 m_zoomSlider->setMinimumWidth(100);
1017 toolbar->addWidget(m_zoomSlider);
1019 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1020 toolbar->addAction(m_zoomIn);
1021 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1023 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1024 actionWidget->setMaximumWidth(max);
1025 actionWidget->setMaximumHeight(max - 4);
1026 actionWidget->setStyleSheet(styleBorderless);
1028 actionWidget = toolbar->widgetForAction(m_zoomIn);
1029 actionWidget->setMaximumWidth(max);
1030 actionWidget->setMaximumHeight(max - 4);
1031 actionWidget->setStyleSheet(styleBorderless);
1033 actionWidget = toolbar->widgetForAction(m_zoomOut);
1034 actionWidget->setMaximumWidth(max);
1035 actionWidget->setMaximumHeight(max - 4);
1036 actionWidget->setStyleSheet(styleBorderless);
1038 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1039 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1040 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1041 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1042 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1044 toolbar->addSeparator();
1046 //create automatic audio split button
1047 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1048 toolbar->addAction(m_buttonAutomaticSplitAudio);
1049 m_buttonAutomaticSplitAudio->setCheckable(true);
1050 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1051 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1053 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1054 toolbar->addAction(m_buttonVideoThumbs);
1055 m_buttonVideoThumbs->setCheckable(true);
1056 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1057 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1059 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1060 toolbar->addAction(m_buttonAudioThumbs);
1061 m_buttonAudioThumbs->setCheckable(true);
1062 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1063 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1065 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1066 toolbar->addAction(m_buttonShowMarkers);
1067 m_buttonShowMarkers->setCheckable(true);
1068 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1069 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1071 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1072 toolbar->addAction(m_buttonSnap);
1073 m_buttonSnap->setCheckable(true);
1074 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1075 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1077 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1078 actionWidget->setMaximumWidth(max);
1079 actionWidget->setMaximumHeight(max - 4);
1081 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1082 actionWidget->setMaximumWidth(max);
1083 actionWidget->setMaximumHeight(max - 4);
1085 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1086 actionWidget->setMaximumWidth(max);
1087 actionWidget->setMaximumHeight(max - 4);
1089 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1090 actionWidget->setMaximumWidth(max);
1091 actionWidget->setMaximumHeight(max - 4);
1093 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1094 actionWidget->setMaximumWidth(max);
1095 actionWidget->setMaximumHeight(max - 4);
1097 m_messageLabel = new StatusBarMessageLabel(this);
1098 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1100 statusBar()->addWidget(m_messageLabel, 10);
1101 statusBar()->addWidget(m_statusProgressBar, 0);
1102 statusBar()->addPermanentWidget(toolbar);
1103 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1104 statusBar()->addPermanentWidget(m_timecodeFormat);
1105 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1107 collection.addAction("normal_mode", m_normalEditTool);
1108 collection.addAction("overwrite_mode", m_overwriteEditTool);
1109 collection.addAction("insert_mode", m_insertEditTool);
1110 collection.addAction("select_tool", m_buttonSelectTool);
1111 collection.addAction("razor_tool", m_buttonRazorTool);
1112 collection.addAction("spacer_tool", m_buttonSpacerTool);
1114 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1115 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1116 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1117 collection.addAction("show_markers", m_buttonShowMarkers);
1118 collection.addAction("snap", m_buttonSnap);
1119 collection.addAction("zoom_fit", m_buttonFitZoom);
1120 collection.addAction("zoom_in", m_zoomIn);
1121 collection.addAction("zoom_out", m_zoomOut);
1123 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1124 collection.addAction("project_find", m_projectSearch);
1125 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1126 m_projectSearch->setShortcut(Qt::Key_Slash);
1128 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1129 collection.addAction("project_find_next", m_projectSearchNext);
1130 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1131 m_projectSearchNext->setShortcut(Qt::Key_F3);
1132 m_projectSearchNext->setEnabled(false);
1134 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1135 collection.addAction("manage_profiles", profilesAction);
1136 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1138 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1139 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1140 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1141 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1143 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1144 collection.addAction("run_wizard", wizAction);
1145 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1147 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1148 collection.addAction("project_settings", projectAction);
1149 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1151 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1152 collection.addAction("project_render", projectRender);
1153 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1154 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1156 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1157 collection.addAction("project_clean", projectClean);
1158 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1160 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1161 collection.addAction("project_adjust_profile", projectAdjust);
1162 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1164 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1165 KShortcut playShortcut;
1166 playShortcut.setPrimary(Qt::Key_Space);
1167 playShortcut.setAlternate(Qt::Key_K);
1168 monitorPlay->setShortcut(playShortcut);
1169 collection.addAction("monitor_play", monitorPlay);
1170 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1172 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1173 collection.addAction("monitor_pause", monitorPause);
1174 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1176 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1177 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1178 collection.addAction("monitor_play_zone", m_playZone);
1179 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1181 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1182 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1183 collection.addAction("monitor_loop_zone", m_loopZone);
1184 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1186 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1187 m_loopClip->setEnabled(false);
1188 collection.addAction("monitor_loop_clip", m_loopClip);
1189 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1191 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1192 collection.addAction("dvd_wizard", dvdWizard);
1193 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1195 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1196 collection.addAction("transcode_clip", transcodeClip);
1197 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1199 KAction *markIn = collection.addAction("mark_in");
1200 markIn->setText(i18n("Set Zone In"));
1201 markIn->setShortcut(Qt::Key_I);
1202 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1204 KAction *markOut = collection.addAction("mark_out");
1205 markOut->setText(i18n("Set Zone Out"));
1206 markOut->setShortcut(Qt::Key_O);
1207 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1209 KAction *switchMon = collection.addAction("switch_monitor");
1210 switchMon->setText(i18n("Switch monitor"));
1211 switchMon->setShortcut(Qt::Key_T);
1212 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1214 KAction *fullMon = collection.addAction("monitor_fullscreen");
1215 fullMon->setText(i18n("Switch monitor fullscreen"));
1216 fullMon->setIcon(KIcon("view-fullscreen"));
1217 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1219 KAction *insertTree = collection.addAction("insert_project_tree");
1220 insertTree->setText(i18n("Insert zone in project tree"));
1221 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1222 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1224 KAction *insertTimeline = collection.addAction("insert_timeline");
1225 insertTimeline->setText(i18n("Insert zone in timeline"));
1226 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1227 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1229 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1230 collection.addAction("resize_timeline_clip_start", resizeStart);
1231 resizeStart->setShortcut(Qt::Key_1);
1232 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1234 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1235 collection.addAction("resize_timeline_clip_end", resizeEnd);
1236 resizeEnd->setShortcut(Qt::Key_2);
1237 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1239 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1240 monitorSeekBackward->setShortcut(Qt::Key_J);
1241 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1242 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1244 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1245 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1246 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1247 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1249 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1250 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1251 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1252 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1254 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1255 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1256 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1257 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1259 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1260 monitorSeekForward->setShortcut(Qt::Key_L);
1261 collection.addAction("monitor_seek_forward", monitorSeekForward);
1262 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1264 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1265 clipStart->setShortcut(Qt::Key_Home);
1266 collection.addAction("seek_clip_start", clipStart);
1267 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1269 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1270 clipEnd->setShortcut(Qt::Key_End);
1271 collection.addAction("seek_clip_end", clipEnd);
1272 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1274 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1275 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1276 collection.addAction("seek_zone_start", zoneStart);
1277 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1279 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1280 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1281 collection.addAction("seek_zone_end", zoneEnd);
1282 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1284 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1285 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1286 collection.addAction("seek_start", projectStart);
1287 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1289 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1290 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1291 collection.addAction("seek_end", projectEnd);
1292 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1294 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1295 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1296 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1297 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1299 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1300 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1301 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1302 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1304 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1305 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1306 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1307 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1309 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1310 deleteItem->setShortcut(Qt::Key_Delete);
1311 collection.addAction("delete_timeline_clip", deleteItem);
1312 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1314 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1315 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1316 editTimelineClipSpeed->setData("change_speed");
1317 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1319 KAction *stickTransition = collection.addAction("auto_transition");
1320 stickTransition->setData(QString("auto"));
1321 stickTransition->setCheckable(true);
1322 stickTransition->setEnabled(false);
1323 stickTransition->setText(i18n("Automatic Transition"));
1324 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1326 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1327 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1328 collection.addAction("group_clip", groupClip);
1329 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1331 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1332 collection.addAction("ungroup_clip", ungroupClip);
1333 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1334 ungroupClip->setData("ungroup_clip");
1335 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1337 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1338 collection.addAction("edit_item_duration", editItemDuration);
1339 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1341 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1342 collection.addAction("clip_in_project_tree", clipInProjectTree);
1343 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1345 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1346 collection.addAction("clip_to_project_tree", clipToProjectTree);
1347 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1349 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1350 insertOvertwrite->setShortcut(Qt::Key_V);
1351 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1352 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1354 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1355 selectTimelineClip->setShortcut(Qt::Key_Plus);
1356 collection.addAction("select_timeline_clip", selectTimelineClip);
1357 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1359 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1360 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1361 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1362 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1364 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1365 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1366 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1367 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1369 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1370 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1371 collection.addAction("select_timeline_transition", selectTimelineTransition);
1372 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1374 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1375 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1376 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1377 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1379 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1380 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1381 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1382 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1384 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1385 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1386 collection.addAction("cut_timeline_clip", cutTimelineClip);
1387 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1389 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1390 collection.addAction("add_clip_marker", addClipMarker);
1391 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1393 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1394 collection.addAction("delete_clip_marker", deleteClipMarker);
1395 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1397 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1398 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1399 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1401 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1402 editClipMarker->setData(QString("edit_marker"));
1403 collection.addAction("edit_clip_marker", editClipMarker);
1404 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1406 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1407 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1408 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1409 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1411 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1412 collection.addAction("split_audio", splitAudio);
1413 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1415 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1416 collection.addAction("clip_audio_only", audioOnly);
1417 audioOnly->setData("clip_audio_only");
1418 audioOnly->setCheckable(true);
1420 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1421 collection.addAction("clip_video_only", videoOnly);
1422 videoOnly->setData("clip_video_only");
1423 videoOnly->setCheckable(true);
1425 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1426 collection.addAction("clip_audio_and_video", audioAndVideo);
1427 audioAndVideo->setData("clip_audio_and_video");
1428 audioAndVideo->setCheckable(true);
1430 m_clipTypeGroup = new QActionGroup(this);
1431 m_clipTypeGroup->addAction(audioOnly);
1432 m_clipTypeGroup->addAction(videoOnly);
1433 m_clipTypeGroup->addAction(audioAndVideo);
1434 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1435 m_clipTypeGroup->setEnabled(false);
1437 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1438 collection.addAction("insert_space", insertSpace);
1439 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1441 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1442 collection.addAction("delete_space", removeSpace);
1443 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1445 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1446 collection.addAction("insert_track", insertTrack);
1447 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1449 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1450 collection.addAction("delete_track", deleteTrack);
1451 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1453 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1454 collection.addAction("config_tracks", configTracks);
1455 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1457 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1458 collection.addAction("add_guide", addGuide);
1459 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1461 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1462 collection.addAction("delete_guide", delGuide);
1463 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1465 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1466 collection.addAction("edit_guide", editGuide);
1467 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1469 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1470 collection.addAction("delete_all_guides", delAllGuides);
1471 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1473 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1474 collection.addAction("paste_effects", pasteEffects);
1475 pasteEffects->setData("paste_effects");
1476 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1478 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1479 collection.addAction("show_timeline", showTimeline);
1480 showTimeline->setCheckable(true);
1481 showTimeline->setChecked(true);
1482 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1484 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1485 collection.addAction("show_titlebars", showTitleBar);
1486 showTitleBar->setCheckable(true);
1487 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1488 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1489 slotShowTitleBars(KdenliveSettings::showtitlebars());
1492 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1494 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1495 collection.addAction("maximize_current", maxCurrent);
1496 maxCurrent->setCheckable(true);
1497 maxCurrent->setChecked(false);
1498 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1500 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1501 KStandardAction::quit(this, SLOT(close()), collection);
1502 KStandardAction::open(this, SLOT(openFile()), collection);
1503 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1504 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1505 KStandardAction::openNew(this, SLOT(newFile()), collection);
1506 // TODO: make the following connection to slotEditKeys work
1507 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1508 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1509 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1510 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1511 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1512 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1514 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1515 undo->setEnabled(false);
1516 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1518 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1519 redo->setEnabled(false);
1520 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1523 //TODO: Add status tooltip to actions ?
1524 connect(collection, SIGNAL(actionHovered(QAction*)),
1525 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1528 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1529 collection.addAction("add_clip", addClip);
1530 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1532 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1533 collection.addAction("add_color_clip", addColorClip);
1534 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1536 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1537 collection.addAction("add_slide_clip", addSlideClip);
1538 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1540 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1541 collection.addAction("add_text_clip", addTitleClip);
1542 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1544 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1545 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1546 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1548 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1549 collection.addAction("add_folder", addFolderButton);
1550 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1552 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1553 collection.addAction("clip_properties", clipProperties);
1554 clipProperties->setData("clip_properties");
1555 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1556 clipProperties->setEnabled(false);
1558 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1559 collection.addAction("edit_clip", openClip);
1560 openClip->setData("edit_clip");
1561 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1562 openClip->setEnabled(false);
1564 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1565 collection.addAction("delete_clip", deleteClip);
1566 deleteClip->setData("delete_clip");
1567 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1568 deleteClip->setEnabled(false);
1570 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1571 collection.addAction("reload_clip", reloadClip);
1572 reloadClip->setData("reload_clip");
1573 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1574 reloadClip->setEnabled(false);
1576 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1577 collection.addAction("stopmotion", stopMotion);
1578 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1580 QMenu *addClips = new QMenu();
1581 addClips->addAction(addClip);
1582 addClips->addAction(addColorClip);
1583 addClips->addAction(addSlideClip);
1584 addClips->addAction(addTitleClip);
1585 addClips->addAction(addTitleTemplateClip);
1586 addClips->addAction(addFolderButton);
1588 addClips->addAction(reloadClip);
1589 addClips->addAction(clipProperties);
1590 addClips->addAction(openClip);
1591 addClips->addAction(deleteClip);
1592 m_projectList->setupMenu(addClips, addClip);
1594 // Setup effects and transitions actions.
1595 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1596 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1597 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1598 m_transitions = new KAction*[transitions.count()];
1599 for (int i = 0; i < transitions.count(); i++) {
1600 QStringList effectInfo = transitions.effectIdInfo(i);
1601 m_transitions[i] = new KAction(effectInfo.at(0), this);
1602 m_transitions[i]->setData(effectInfo);
1603 m_transitions[i]->setIconVisibleInMenu(false);
1604 QString id = effectInfo.at(2);
1605 if (id.isEmpty()) id = effectInfo.at(1);
1606 transitionActions->addAction("transition_" + id, m_transitions[i]);
1608 //m_effectsActionCollection->readSettings();
1610 //connect(collection, SIGNAL( clearStatusText() ),
1611 //statusBar(), SLOT( clear() ) );
1614 void MainWindow::slotDisplayActionMessage(QAction *a)
1616 statusBar()->showMessage(a->data().toString(), 3000);
1619 void MainWindow::loadLayouts()
1621 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1622 if (m_loadLayout == NULL || saveLayout == NULL) return;
1623 KSharedConfigPtr config = KGlobal::config();
1624 KConfigGroup layoutGroup(config, "Layouts");
1625 QStringList entries = layoutGroup.keyList();
1626 QList<QAction *> loadActions = m_loadLayout->actions();
1627 QList<QAction *> saveActions = saveLayout->actions();
1628 for (int i = 1; i < 5; i++) {
1629 // Rename the layouts actions
1630 foreach(const QString & key, entries) {
1631 if (key.endsWith(QString("_%1").arg(i))) {
1632 // Found previously saved layout
1633 QString layoutName = key.section("_", 0, -2);
1634 for (int j = 0; j < loadActions.count(); j++) {
1635 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1636 loadActions[j]->setText(layoutName);
1637 loadActions[j]->setData(key);
1641 for (int j = 0; j < saveActions.count(); j++) {
1642 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1643 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1644 saveActions[j]->setData(key);
1653 void MainWindow::slotLoadLayout(QAction *action)
1655 if (!action) return;
1656 QString layoutId = action->data().toString();
1657 if (layoutId.isEmpty()) return;
1658 KSharedConfigPtr config = KGlobal::config();
1659 KConfigGroup layouts(config, "Layouts");
1660 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1661 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1662 //restoreGeometry(geom);
1663 restoreState(state);
1666 void MainWindow::slotSaveLayout(QAction *action)
1668 QString originallayoutName = action->data().toString();
1669 int layoutId = originallayoutName.section('_', -1).toInt();
1671 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1672 if (layoutName.isEmpty()) return;
1673 KSharedConfigPtr config = KGlobal::config();
1674 KConfigGroup layouts(config, "Layouts");
1675 layouts.deleteEntry(originallayoutName);
1677 QByteArray st = saveState();
1678 layoutName.append("_" + QString::number(layoutId));
1679 layouts.writeEntry(layoutName, st.toBase64());
1683 void MainWindow::saveOptions()
1685 KdenliveSettings::self()->writeConfig();
1686 KSharedConfigPtr config = KGlobal::config();
1687 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1688 KConfigGroup treecolumns(config, "Project Tree");
1689 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1693 void MainWindow::readOptions()
1695 KSharedConfigPtr config = KGlobal::config();
1696 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1697 KConfigGroup initialGroup(config, "version");
1698 bool upgrade = false;
1699 if (initialGroup.exists()) {
1700 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1704 if (initialGroup.readEntry("version") == "0.7") {
1705 //Add new settings from 0.7.1
1706 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1707 QString path = QDir::homePath() + "/kdenlive";
1708 if (KStandardDirs::makeDir(path) == false) {
1709 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1710 } else KdenliveSettings::setDefaultprojectfolder(path);
1716 if (!initialGroup.exists() || upgrade) {
1717 // this is our first run, show Wizard
1718 Wizard *w = new Wizard(upgrade, this);
1719 if (w->exec() == QDialog::Accepted && w->isOk()) {
1720 w->adjustSettings();
1721 initialGroup.writeEntry("version", version);
1727 KConfigGroup treecolumns(config, "Project Tree");
1728 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1729 if (!state.isEmpty())
1730 m_projectList->setHeaderInfo(state);
1733 void MainWindow::slotRunWizard()
1735 Wizard *w = new Wizard(false, this);
1736 if (w->exec() == QDialog::Accepted && w->isOk()) {
1737 w->adjustSettings();
1742 void MainWindow::newFile(bool showProjectSettings, bool force)
1744 if (!m_timelineArea->isEnabled() && !force)
1746 m_fileRevert->setEnabled(false);
1747 QString profileName = KdenliveSettings::default_profile();
1748 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1749 QMap <QString, QString> documentProperties;
1750 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1751 if (!showProjectSettings) {
1752 // set up default properties
1753 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1754 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1755 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1756 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1757 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1758 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1759 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1760 if (!KdenliveSettings::activatetabs())
1761 if (!closeCurrentDocument())
1764 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1765 if (w->exec() != QDialog::Accepted)
1767 if (!KdenliveSettings::activatetabs())
1768 if (!closeCurrentDocument())
1770 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1771 slotSwitchVideoThumbs();
1772 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1773 slotSwitchAudioThumbs();
1774 profileName = w->selectedProfile();
1775 projectFolder = w->selectedFolder();
1776 projectTracks = w->tracks();
1777 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1778 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1779 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1780 documentProperties.insert("proxyparams", w->proxyParams());
1781 documentProperties.insert("proxyextension", w->proxyExtension());
1782 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1783 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1786 m_timelineArea->setEnabled(true);
1787 m_projectList->setEnabled(true);
1789 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1790 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1792 TrackView *trackView = new TrackView(doc, &ok, this);
1793 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1796 //m_timelineArea->setEnabled(false);
1797 //m_projectList->setEnabled(false);
1801 if (m_timelineArea->count() == 1) {
1802 connectDocumentInfo(doc);
1803 connectDocument(trackView, doc);
1805 m_timelineArea->setTabBarHidden(false);
1806 m_monitorManager->activateMonitor("clip");
1807 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1810 void MainWindow::activateDocument()
1812 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1813 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1814 KdenliveDoc *currentDoc = currentTab->document();
1815 connectDocumentInfo(currentDoc);
1816 connectDocument(currentTab, currentDoc);
1819 bool MainWindow::closeCurrentDocument(bool saveChanges)
1821 QWidget *w = m_timelineArea->currentWidget();
1822 if (!w) return true;
1823 // closing current document
1824 int ix = m_timelineArea->currentIndex() + 1;
1825 if (ix == m_timelineArea->count()) ix = 0;
1826 m_timelineArea->setCurrentIndex(ix);
1827 TrackView *tabToClose = (TrackView *) w;
1828 KdenliveDoc *docToClose = tabToClose->document();
1829 if (docToClose && docToClose->isModified() && saveChanges) {
1831 if (m_activeDocument->url().fileName().isEmpty())
1832 message = i18n("Save changes to document?");
1834 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1835 switch (KMessageBox::warningYesNoCancel(this, message)) {
1836 case KMessageBox::Yes :
1837 // save document here. If saving fails, return false;
1838 if (saveFile() == false) return false;
1840 case KMessageBox::Cancel :
1847 m_clipMonitor->slotSetXml(NULL);
1848 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1849 if (m_timelineArea->count() == 1) {
1850 m_timelineArea->setTabBarHidden(true);
1851 m_closeAction->setEnabled(false);
1853 if (docToClose == m_activeDocument) {
1854 delete m_activeDocument;
1855 m_activeDocument = NULL;
1856 m_effectStack->clear();
1857 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1861 if (w == m_activeTimeline) {
1862 delete m_activeTimeline;
1863 m_activeTimeline = NULL;
1870 bool MainWindow::saveFileAs(const QString &outputFileName)
1872 QString currentSceneList;
1873 m_monitorManager->stopActiveMonitor();
1875 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1878 // Save timeline thumbnails
1879 m_activeTimeline->projectView()->saveThumbnails();
1880 m_activeDocument->setUrl(KUrl(outputFileName));
1881 if (m_activeDocument->m_autosave == NULL) {
1882 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1883 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1884 setCaption(m_activeDocument->description());
1885 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1886 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1887 m_activeDocument->setModified(false);
1888 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1889 m_fileRevert->setEnabled(true);
1893 bool MainWindow::saveFileAs()
1895 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1896 if (outputFile.isEmpty()) {
1899 if (QFile::exists(outputFile)) {
1900 // Show the file dialog again if the user does not want to overwrite the file
1901 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1902 return saveFileAs();
1904 return saveFileAs(outputFile);
1907 bool MainWindow::saveFile()
1909 if (!m_activeDocument) return true;
1910 if (m_activeDocument->url().isEmpty()) {
1911 return saveFileAs();
1913 bool result = saveFileAs(m_activeDocument->url().path());
1914 m_activeDocument->m_autosave->resize(0);
1919 void MainWindow::openFile()
1921 if (!m_startUrl.isEmpty()) {
1922 openFile(m_startUrl);
1923 m_startUrl = KUrl();
1926 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1927 if (url.isEmpty()) return;
1928 m_fileOpenRecent->addUrl(url);
1932 void MainWindow::openLastFile()
1934 KSharedConfigPtr config = KGlobal::config();
1935 KUrl::List urls = m_fileOpenRecent->urls();
1936 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1937 if (urls.isEmpty()) newFile(false);
1938 else openFile(urls.last());
1941 void MainWindow::openFile(const KUrl &url)
1943 // Check if the document is already opened
1944 const int ct = m_timelineArea->count();
1945 bool isOpened = false;
1947 for (i = 0; i < ct; i++) {
1948 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1949 KdenliveDoc *doc = tab->document();
1950 if (doc->url() == url) {
1956 m_timelineArea->setCurrentIndex(i);
1960 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1962 // Check for backup file
1963 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1964 if (!staleFiles.isEmpty()) {
1965 if (KMessageBox::questionYesNo(this,
1966 i18n("Auto-saved files exist. Do you want to recover them now?"),
1967 i18n("File Recovery"),
1968 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1969 recoverFiles(staleFiles);
1972 // remove the stale files
1973 foreach(KAutoSaveFile * stale, staleFiles) {
1974 stale->open(QIODevice::ReadWrite);
1979 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1980 m_messageLabel->repaint();
1981 doOpenFile(url, NULL);
1984 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1986 if (!m_timelineArea->isEnabled()) return;
1987 m_fileRevert->setEnabled(true);
1989 // Recreate stopmotion widget on document change
1991 delete m_stopmotion;
1992 m_stopmotion = NULL;
1995 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
1996 progressDialog.setAllowCancel(false);
1997 progressDialog.progressBar()->setMaximum(4);
1998 progressDialog.show();
1999 progressDialog.progressBar()->setValue(0);
2000 qApp->processEvents();
2002 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);
2004 progressDialog.progressBar()->setValue(1);
2005 progressDialog.progressBar()->setMaximum(4);
2006 progressDialog.setLabelText(i18n("Loading project"));
2007 qApp->processEvents();
2009 if (stale == NULL) {
2010 stale = new KAutoSaveFile(url, doc);
2011 doc->m_autosave = stale;
2013 doc->m_autosave = stale;
2014 doc->setUrl(stale->managedFile());
2015 doc->setModified(true);
2016 stale->setParent(doc);
2018 connectDocumentInfo(doc);
2020 progressDialog.progressBar()->setValue(2);
2021 qApp->processEvents();
2024 TrackView *trackView = new TrackView(doc, &ok, this);
2026 progressDialog.progressBar()->setValue(3);
2027 qApp->processEvents();
2029 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2031 m_timelineArea->setEnabled(false);
2032 m_projectList->setEnabled(false);
2033 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2034 slotGotProgressInfo(QString(), -1);
2035 newFile(false, true);
2038 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2039 trackView->setDuration(trackView->duration());
2040 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2042 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2043 slotGotProgressInfo(QString(), -1);
2044 m_projectMonitor->adjustRulerSize(trackView->duration());
2045 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2046 m_clipMonitor->refreshMonitor(true);
2048 progressDialog.progressBar()->setValue(4);
2051 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2053 foreach(KAutoSaveFile * stale, staleFiles) {
2054 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2055 // show an error message; we could not steal the lockfile
2056 // maybe another application got to the file before us?
2060 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2061 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2062 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2063 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2067 void MainWindow::parseProfiles(const QString &mltPath)
2069 //KdenliveSettings::setDefaulttmpfolder();
2070 if (!mltPath.isEmpty()) {
2071 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2072 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2075 if (KdenliveSettings::mltpath().isEmpty())
2076 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2078 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2079 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2080 if (!QFile::exists(meltPath))
2081 meltPath = KStandardDirs::findExe("melt");
2082 KdenliveSettings::setRendererpath(meltPath);
2085 if (KdenliveSettings::rendererpath().isEmpty()) {
2086 // Cannot find the MLT melt renderer, ask for location
2087 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2088 if (getUrl->exec() == QDialog::Rejected) {
2091 KUrl rendererPath = getUrl->selectedUrl();
2093 if (rendererPath.isEmpty()) ::exit(0);
2094 KdenliveSettings::setRendererpath(rendererPath.path());
2097 QStringList profilesFilter;
2098 profilesFilter << "*";
2099 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2100 if (profilesList.isEmpty()) {
2101 // Cannot find MLT path, try finding melt
2102 QString profilePath = KdenliveSettings::rendererpath();
2103 if (!profilePath.isEmpty()) {
2104 profilePath = profilePath.section('/', 0, -3);
2105 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2106 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2108 if (profilesList.isEmpty()) {
2109 // Cannot find the MLT profiles, ask for location
2110 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2111 getUrl->fileDialog()->setMode(KFile::Directory);
2112 if (getUrl->exec() == QDialog::Rejected) {
2115 KUrl mltPath = getUrl->selectedUrl();
2117 if (mltPath.isEmpty()) ::exit(0);
2118 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2119 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2123 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2125 // Parse again MLT profiles to build a list of available video formats
2126 if (profilesList.isEmpty()) parseProfiles();
2130 void MainWindow::slotEditProfiles()
2132 ProfilesDialog *w = new ProfilesDialog;
2133 if (w->exec() == QDialog::Accepted) {
2134 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2135 if (d) d->checkProfile();
2140 void MainWindow::slotDetectAudioDriver()
2142 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2143 leading to no audio output, see bug #934 */
2145 //decide which audio driver is really best, in some cases SDL is wrong
2146 if (KdenliveSettings::audiodrivername().isEmpty()) {
2148 KProcess readProcess;
2149 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2150 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2151 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2152 readProcess.setProgram("pactl", QStringList() << "stat");
2153 readProcess.execute(2000); // Kill it after 2 seconds
2155 QString result = QString(readProcess.readAllStandardOutput());
2156 kDebug() << "// / / / / / READING PACTL: ";
2158 if (!result.isEmpty()) {
2160 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2164 KdenliveSettings::setAutoaudiodrivername(driver);
2168 void MainWindow::slotEditProjectSettings()
2170 QPoint p = m_activeDocument->getTracksCount();
2171 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2173 if (w->exec() == QDialog::Accepted) {
2174 QString profile = w->selectedProfile();
2175 m_activeDocument->setProjectFolder(w->selectedFolder());
2177 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2179 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2180 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2181 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2182 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2183 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2184 m_activeDocument->setModified();
2185 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2186 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) {
2187 //TODO: rebuild all proxies
2188 //m_activeDocument->rebuildAllProxies();
2191 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2192 m_activeDocument->setModified();
2193 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2195 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2196 m_activeDocument->setModified();
2197 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2199 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2200 m_activeDocument->setModified();
2201 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2203 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2204 m_activeDocument->setModified();
2205 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2207 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2208 m_activeDocument->setModified();
2209 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2211 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2212 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2213 m_activeDocument->setModified();
2214 slotUpdateProxySettings();
2220 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2222 double dar = m_activeDocument->dar();
2224 // Recreate the stopmotion widget if profile changes
2226 delete m_stopmotion;
2227 m_stopmotion = NULL;
2230 // Deselect current effect / transition
2231 m_effectStack->slotClipItemSelected(NULL, 0);
2232 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2233 m_clipMonitor->slotSetXml(NULL);
2234 bool updateFps = m_activeDocument->setProfilePath(profile);
2235 KdenliveSettings::setCurrent_profile(profile);
2236 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2237 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2239 m_activeDocument->clipManager()->clearUnusedProducers();
2240 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2241 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2242 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2243 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2244 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2245 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2246 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2247 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2248 if (updateFps) m_activeTimeline->updateProjectFps();
2249 m_activeDocument->setModified(true);
2250 m_commandStack->activeStack()->clear();
2251 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2252 slotUpdateMousePosition(0);
2253 // We need to desactivate & reactivate monitors to get a refresh
2254 //m_monitorManager->switchMonitors();
2258 void MainWindow::slotRenderProject()
2260 if (!m_renderWidget) {
2261 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2262 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2263 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2264 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2265 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2266 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2267 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2268 if (m_activeDocument) {
2269 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2270 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2271 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2272 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2275 slotCheckRenderStatus();
2276 m_renderWidget->show();
2277 m_renderWidget->showNormal();
2279 // What are the following lines supposed to do?
2280 //m_activeTimeline->tracksNumber();
2281 //m_renderWidget->enableAudio(false);
2282 //m_renderWidget->export_audio;
2285 void MainWindow::slotCheckRenderStatus()
2287 // Make sure there are no missing clips
2289 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2292 void MainWindow::setRenderingProgress(const QString &url, int progress)
2295 m_renderWidget->setRenderJob(url, progress);
2298 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2301 m_renderWidget->setRenderStatus(url, status, error);
2304 void MainWindow::slotCleanProject()
2306 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2307 m_projectList->cleanup();
2310 void MainWindow::slotUpdateMousePosition(int pos)
2312 if (m_activeDocument)
2313 switch (m_timecodeFormat->currentIndex()) {
2315 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2318 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2322 void MainWindow::slotUpdateDocumentState(bool modified)
2324 if (!m_activeDocument) return;
2325 setCaption(m_activeDocument->description(), modified);
2326 m_saveAction->setEnabled(modified);
2328 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2329 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2331 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2332 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2336 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2338 if (m_activeDocument) {
2339 if (m_activeDocument == doc) return;
2340 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2342 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2345 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2347 //m_projectMonitor->stop();
2348 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2349 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2350 if (m_activeDocument) {
2351 if (m_activeDocument == doc) return;
2352 if (m_activeTimeline) {
2353 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2354 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2355 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2356 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2357 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2358 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2359 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2360 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2362 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2364 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2365 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2366 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2367 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2368 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2369 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2370 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2371 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2372 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2373 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2374 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2375 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2376 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2377 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2378 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2379 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2380 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2381 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2382 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2383 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2384 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2385 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2386 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2387 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2388 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2389 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2390 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2391 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2392 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2393 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2394 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2395 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2396 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2397 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2398 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2399 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2400 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2401 m_effectStack->clear();
2403 //m_activeDocument->setRenderer(NULL);
2404 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2405 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2406 m_clipMonitor->stop();
2408 KdenliveSettings::setCurrent_profile(doc->profilePath());
2409 KdenliveSettings::setProject_fps(doc->fps());
2410 m_monitorManager->resetProfiles(doc->timecode());
2411 m_projectList->setDocument(doc);
2412 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2413 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2414 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2415 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2416 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2417 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2419 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2420 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2421 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2423 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2426 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2427 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2428 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2429 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2430 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2431 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2432 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2433 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2434 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2435 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2436 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2437 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2438 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2439 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2441 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2442 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2443 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2444 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2445 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2447 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2448 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2449 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2450 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2452 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2453 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2454 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2455 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2457 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2458 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2459 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2460 m_zoomSlider->setValue(doc->zoom().x());
2461 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2462 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2463 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2464 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2466 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2467 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2469 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2470 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2472 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2473 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2474 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2475 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2476 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2477 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2478 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2479 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2480 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2481 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2482 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2484 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2485 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2486 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2487 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2488 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2491 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2492 m_activeTimeline = trackView;
2493 if (m_renderWidget) {
2494 slotCheckRenderStatus();
2495 m_renderWidget->setProfile(doc->mltProfile());
2496 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2497 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2498 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2500 //doc->setRenderer(m_projectMonitor->render);
2501 m_commandStack->setActiveStack(doc->commandStack());
2502 KdenliveSettings::setProject_display_ratio(doc->dar());
2503 //doc->clipManager()->checkAudioThumbs();
2505 //m_overView->setScene(trackView->projectScene());
2506 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2507 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2509 setCaption(doc->description(), doc->isModified());
2510 m_saveAction->setEnabled(doc->isModified());
2511 m_normalEditTool->setChecked(true);
2512 m_activeDocument = doc;
2513 m_activeTimeline->updateProjectFps();
2514 m_activeDocument->checkProjectClips();
2516 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2518 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2519 slotUpdateMousePosition(0);
2520 // set tool to select tool
2521 m_buttonSelectTool->setChecked(true);
2524 void MainWindow::slotZoneMoved(int start, int end)
2526 m_activeDocument->setZone(start, end);
2527 m_projectMonitor->slotZoneMoved(start, end);
2530 void MainWindow::slotGuidesUpdated()
2533 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2536 void MainWindow::slotEditKeys()
2538 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2539 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2540 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2544 void MainWindow::slotPreferences(int page, int option)
2547 * An instance of your dialog could be already created and could be
2548 * cached, in which case you want to display the cached dialog
2549 * instead of creating another one
2551 if (m_stopmotion) m_stopmotion->slotLive(false);
2552 if (KConfigDialog::showDialog("settings")) {
2553 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2554 if (page != -1) d->showPage(page, option);
2558 // KConfigDialog didn't find an instance of this dialog, so lets
2561 // Get the mappable actions in localized form
2562 QMap<QString, QString> actions;
2563 KActionCollection* collection = actionCollection();
2564 foreach (const QString& action_name, m_action_names) {
2565 actions[collection->action(action_name)->text()] = action_name;
2568 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2569 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2570 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2572 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2575 if (page != -1) dialog->showPage(page, option);
2578 void MainWindow::slotUpdateCaptureFolder()
2582 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2583 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2587 void MainWindow::updateConfiguration()
2589 //TODO: we should apply settings to all projects, not only the current one
2590 if (m_activeTimeline) {
2591 m_activeTimeline->refresh();
2592 m_activeTimeline->projectView()->checkAutoScroll();
2593 m_activeTimeline->projectView()->checkTrackHeight();
2594 if (m_activeDocument)
2595 m_activeDocument->clipManager()->checkAudioThumbs();
2597 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2598 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2599 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2600 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2602 // Update list of transcoding profiles
2604 #ifndef NO_JOGSHUTTLE
2605 activateShuttleDevice();
2606 #endif /* NO_JOGSHUTTLE */
2610 void MainWindow::slotSwitchSplitAudio()
2612 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2613 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2616 void MainWindow::slotSwitchVideoThumbs()
2618 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2619 if (m_activeTimeline)
2620 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2621 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2624 void MainWindow::slotSwitchAudioThumbs()
2626 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2627 if (m_activeTimeline) {
2628 m_activeTimeline->refresh();
2629 m_activeTimeline->projectView()->checkAutoScroll();
2630 if (m_activeDocument)
2631 m_activeDocument->clipManager()->checkAudioThumbs();
2633 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2636 void MainWindow::slotSwitchMarkersComments()
2638 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2639 if (m_activeTimeline)
2640 m_activeTimeline->refresh();
2641 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2644 void MainWindow::slotSwitchSnap()
2646 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2647 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2651 void MainWindow::slotDeleteItem()
2653 if (QApplication::focusWidget() &&
2654 QApplication::focusWidget()->parentWidget() &&
2655 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2656 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2657 m_projectList->slotRemoveClip();
2660 QWidget *widget = QApplication::focusWidget();
2662 if (widget == m_effectStackDock) {
2663 m_effectStack->slotItemDel();
2666 widget = widget->parentWidget();
2669 // effect stack has no focus
2670 if (m_activeTimeline)
2671 m_activeTimeline->projectView()->deleteSelectedClips();
2675 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2677 if (m_clipMonitor->isActive())
2678 m_clipMonitor->checkOverlay();
2679 m_clipMonitor->updateMarkers(clip);
2682 void MainWindow::slotAddClipMarker()
2684 DocClipBase *clip = NULL;
2686 if (m_projectMonitor->isActive()) {
2687 if (m_activeTimeline) {
2688 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2690 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2691 clip = item->baseClip();
2695 clip = m_clipMonitor->activeClip();
2696 pos = m_clipMonitor->position();
2699 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2702 QString id = clip->getId();
2703 CommentedTime marker(pos, i18n("Marker"));
2704 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2705 if (d.exec() == QDialog::Accepted)
2706 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2709 void MainWindow::slotDeleteClipMarker()
2711 DocClipBase *clip = NULL;
2713 if (m_projectMonitor->isActive()) {
2714 if (m_activeTimeline) {
2715 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2717 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2718 clip = item->baseClip();
2722 clip = m_clipMonitor->activeClip();
2723 pos = m_clipMonitor->position();
2726 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2730 QString id = clip->getId();
2731 QString comment = clip->markerComment(pos);
2732 if (comment.isEmpty()) {
2733 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2736 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2739 void MainWindow::slotDeleteAllClipMarkers()
2741 DocClipBase *clip = NULL;
2742 if (m_projectMonitor->isActive()) {
2743 if (m_activeTimeline) {
2744 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2746 clip = item->baseClip();
2750 clip = m_clipMonitor->activeClip();
2753 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2756 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2759 void MainWindow::slotEditClipMarker()
2761 DocClipBase *clip = NULL;
2763 if (m_projectMonitor->isActive()) {
2764 if (m_activeTimeline) {
2765 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2767 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2768 clip = item->baseClip();
2772 clip = m_clipMonitor->activeClip();
2773 pos = m_clipMonitor->position();
2776 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2780 QString id = clip->getId();
2781 QString oldcomment = clip->markerComment(pos);
2782 if (oldcomment.isEmpty()) {
2783 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2787 CommentedTime marker(pos, oldcomment);
2788 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2789 if (d.exec() == QDialog::Accepted) {
2790 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2791 if (d.newMarker().time() != pos) {
2792 // remove old marker
2793 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2798 void MainWindow::slotAddMarkerGuideQuickly()
2800 if (!m_activeTimeline || !m_activeDocument)
2803 if (m_clipMonitor->isActive()) {
2804 DocClipBase *clip = m_clipMonitor->activeClip();
2805 GenTime pos = m_clipMonitor->position();
2808 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2812 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2814 m_activeTimeline->projectView()->slotAddGuide(false);
2818 void MainWindow::slotAddGuide()
2820 if (m_activeTimeline)
2821 m_activeTimeline->projectView()->slotAddGuide();
2824 void MainWindow::slotInsertSpace()
2826 if (m_activeTimeline)
2827 m_activeTimeline->projectView()->slotInsertSpace();
2830 void MainWindow::slotRemoveSpace()
2832 if (m_activeTimeline)
2833 m_activeTimeline->projectView()->slotRemoveSpace();
2836 void MainWindow::slotInsertTrack(int ix)
2838 m_projectMonitor->activateMonitor();
2839 if (m_activeTimeline)
2840 m_activeTimeline->projectView()->slotInsertTrack(ix);
2841 if (m_activeDocument)
2842 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2845 void MainWindow::slotDeleteTrack(int ix)
2847 m_projectMonitor->activateMonitor();
2848 if (m_activeTimeline)
2849 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2850 if (m_activeDocument)
2851 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2854 void MainWindow::slotConfigTrack(int ix)
2856 m_projectMonitor->activateMonitor();
2857 if (m_activeTimeline)
2858 m_activeTimeline->projectView()->slotConfigTracks(ix);
2859 if (m_activeDocument)
2860 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2863 void MainWindow::slotEditGuide()
2865 if (m_activeTimeline)
2866 m_activeTimeline->projectView()->slotEditGuide();
2869 void MainWindow::slotDeleteGuide()
2871 if (m_activeTimeline)
2872 m_activeTimeline->projectView()->slotDeleteGuide();
2875 void MainWindow::slotDeleteAllGuides()
2877 if (m_activeTimeline)
2878 m_activeTimeline->projectView()->slotDeleteAllGuides();
2881 void MainWindow::slotCutTimelineClip()
2883 if (m_activeTimeline)
2884 m_activeTimeline->projectView()->cutSelectedClips();
2887 void MainWindow::slotInsertClipOverwrite()
2889 if (m_activeTimeline) {
2890 QStringList data = m_clipMonitor->getZoneInfo();
2891 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2895 void MainWindow::slotSelectTimelineClip()
2897 if (m_activeTimeline)
2898 m_activeTimeline->projectView()->selectClip(true);
2901 void MainWindow::slotSelectTimelineTransition()
2903 if (m_activeTimeline)
2904 m_activeTimeline->projectView()->selectTransition(true);
2907 void MainWindow::slotDeselectTimelineClip()
2909 if (m_activeTimeline)
2910 m_activeTimeline->projectView()->selectClip(false, true);
2913 void MainWindow::slotDeselectTimelineTransition()
2915 if (m_activeTimeline)
2916 m_activeTimeline->projectView()->selectTransition(false, true);
2919 void MainWindow::slotSelectAddTimelineClip()
2921 if (m_activeTimeline)
2922 m_activeTimeline->projectView()->selectClip(true, true);
2925 void MainWindow::slotSelectAddTimelineTransition()
2927 if (m_activeTimeline)
2928 m_activeTimeline->projectView()->selectTransition(true, true);
2931 void MainWindow::slotGroupClips()
2933 if (m_activeTimeline)
2934 m_activeTimeline->projectView()->groupClips();
2937 void MainWindow::slotUnGroupClips()
2939 if (m_activeTimeline)
2940 m_activeTimeline->projectView()->groupClips(false);
2943 void MainWindow::slotEditItemDuration()
2945 if (m_activeTimeline)
2946 m_activeTimeline->projectView()->editItemDuration();
2949 void MainWindow::slotAddProjectClip(KUrl url)
2951 if (m_activeDocument)
2952 m_activeDocument->slotAddClipFile(url, QString());
2955 void MainWindow::slotAddTransition(QAction *result)
2957 if (!result) return;
2958 QStringList info = result->data().toStringList();
2959 if (info.isEmpty()) return;
2960 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2961 if (m_activeTimeline && !transition.isNull()) {
2962 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2966 void MainWindow::slotAddVideoEffect(QAction *result)
2968 if (!result) return;
2969 const int EFFECT_VIDEO = 1;
2970 const int EFFECT_AUDIO = 2;
2971 QStringList info = result->data().toStringList();
2973 if (info.isEmpty() || info.size() < 3) return;
2974 QDomElement effect ;
2975 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
2976 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
2977 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
2978 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
2980 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
2981 if (!effect.isNull()) slotAddEffect(effect);
2982 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
2985 void MainWindow::slotAddAudioEffect(QAction *result)
2987 if (!result) return;
2988 QStringList info = result->data().toStringList();
2989 if (info.isEmpty()) return;
2990 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2991 slotAddEffect(effect);
2994 void MainWindow::slotAddCustomEffect(QAction *result)
2996 if (!result) return;
2997 QStringList info = result->data().toStringList();
2998 if (info.isEmpty()) return;
2999 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
3000 slotAddEffect(effect);
3003 void MainWindow::slotZoomIn()
3005 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3006 slotShowZoomSliderToolTip();
3009 void MainWindow::slotZoomOut()
3011 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3012 slotShowZoomSliderToolTip();
3015 void MainWindow::slotFitZoom()
3017 if (m_activeTimeline)
3018 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3021 void MainWindow::slotSetZoom(int value)
3023 value = qMax(m_zoomSlider->minimum(), value);
3024 value = qMin(m_zoomSlider->maximum(), value);
3026 if (m_activeTimeline)
3027 m_activeTimeline->slotChangeZoom(value);
3029 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3030 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3031 slotUpdateZoomSliderToolTip(value);
3033 m_zoomSlider->blockSignals(true);
3034 m_zoomSlider->setValue(value);
3035 m_zoomSlider->blockSignals(false);
3038 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3040 if (zoomlevel != -1)
3041 slotUpdateZoomSliderToolTip(zoomlevel);
3043 QPoint global = m_zoomSlider->rect().topLeft();
3044 global.ry() += m_zoomSlider->height() / 2;
3045 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3046 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3049 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3051 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3054 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3056 m_statusProgressBar->setValue(progress);
3057 if (progress >= 0) {
3058 if (!message.isEmpty())
3059 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3060 m_statusProgressBar->setVisible(true);
3061 } else if (progress == -2) {
3062 if (!message.isEmpty())
3063 m_messageLabel->setMessage(message, ErrorMessage);
3064 m_statusProgressBar->setVisible(false);
3066 m_messageLabel->setMessage(QString(), DefaultMessage);
3067 m_statusProgressBar->setVisible(false);
3071 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3073 if (clip->clipType() == TEXT) {
3074 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3075 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3076 // template text clip
3078 // Get the list of existing templates
3080 filter << "*.kdenlivetitle";
3081 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3083 QDialog *dia = new QDialog(this);
3084 Ui::TemplateClip_UI dia_ui;
3085 dia_ui.setupUi(dia);
3087 const QString templatePath = clip->getProperty("resource");
3088 for (int i = 0; i < templateFiles.size(); ++i) {
3089 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3090 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3092 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3093 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3094 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3095 //warning: setting base directory doesn't work??
3096 KUrl startDir(titlepath);
3097 dia_ui.template_list->fileDialog()->setUrl(startDir);
3098 dia_ui.description->setText(clip->getProperty("description"));
3099 if (dia->exec() == QDialog::Accepted) {
3100 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3101 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3103 QMap <QString, QString> newprops;
3105 if (KUrl(textTemplate).path() != templatePath) {
3106 // The template was changed
3107 newprops.insert("resource", textTemplate);
3110 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3111 newprops.insert("description", dia_ui.description->toPlainText());
3114 QString newtemplate = newprops.value("xmltemplate");
3115 if (newtemplate.isEmpty()) newtemplate = templatePath;
3117 // template modified we need to update xmldata
3118 QString description = newprops.value("description");
3119 if (description.isEmpty()) description = clip->getProperty("description");
3120 else newprops.insert("templatetext", description);
3121 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3122 if (!newprops.isEmpty()) {
3123 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3124 m_activeDocument->commandStack()->push(command);
3130 QString path = clip->getProperty("resource");
3131 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3133 doc.setContent(clip->getProperty("xmldata"));
3134 dia_ui->setXml(doc);
3135 if (dia_ui->exec() == QDialog::Accepted) {
3136 QMap <QString, QString> newprops;
3137 newprops.insert("xmldata", dia_ui->xml().toString());
3138 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3139 // duration changed, we need to update duration
3140 newprops.insert("out", QString::number(dia_ui->outPoint()));
3141 int currentLength = QString(clip->producerProperty("length")).toInt();
3142 if (currentLength <= dia_ui->outPoint())
3143 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3144 else newprops.insert("length", clip->producerProperty("length"));
3146 if (!path.isEmpty()) {
3147 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3148 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) {
3149 // save to external file
3150 dia_ui->saveTitle(path);
3151 } else newprops.insert("resource", QString());
3153 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3154 m_activeDocument->commandStack()->push(command);
3155 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3156 m_activeDocument->setModified(true);
3160 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3164 // any type of clip but a title
3165 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3166 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3167 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)));
3172 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3174 if (newprops.isEmpty()) return;
3175 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3176 m_activeDocument->commandStack()->push(command);
3177 m_activeDocument->setModified();
3180 // update clip occurences in timeline
3181 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3186 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3188 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3189 if (dia.exec() == QDialog::Accepted) {
3190 QUndoCommand *command = new QUndoCommand();
3191 command->setText(i18n("Edit clips"));
3192 QMap <QString, QString> newImageProps = dia.properties();
3193 // Transparency setting applies only for images
3194 QMap <QString, QString> newProps = newImageProps;
3195 newProps.remove("transparency");
3197 for (int i = 0; i < cliplist.count(); i++) {
3198 DocClipBase *clip = cliplist.at(i);
3199 if (clip->clipType() == IMAGE)
3200 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3202 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3204 m_activeDocument->commandStack()->push(command);
3205 for (int i = 0; i < cliplist.count(); i++)
3206 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3210 void MainWindow::customEvent(QEvent* e)
3212 if (e->type() == QEvent::User)
3213 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3215 void MainWindow::slotActivateEffectStackView()
3217 m_effectStack->raiseWindow(m_effectStackDock);
3220 void MainWindow::slotActivateTransitionView(Transition *t)
3223 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3226 void MainWindow::slotSnapRewind()
3228 if (m_projectMonitor->isActive()) {
3229 if (m_activeTimeline)
3230 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3232 m_clipMonitor->slotSeekToPreviousSnap();
3236 void MainWindow::slotSnapForward()
3238 if (m_projectMonitor->isActive()) {
3239 if (m_activeTimeline)
3240 m_activeTimeline->projectView()->slotSeekToNextSnap();
3242 m_clipMonitor->slotSeekToNextSnap();
3246 void MainWindow::slotClipStart()
3248 if (m_projectMonitor->isActive()) {
3249 if (m_activeTimeline)
3250 m_activeTimeline->projectView()->clipStart();
3254 void MainWindow::slotClipEnd()
3256 if (m_projectMonitor->isActive()) {
3257 if (m_activeTimeline)
3258 m_activeTimeline->projectView()->clipEnd();
3262 void MainWindow::slotZoneStart()
3264 if (m_projectMonitor->isActive())
3265 m_projectMonitor->slotZoneStart();
3267 m_clipMonitor->slotZoneStart();
3270 void MainWindow::slotZoneEnd()
3272 if (m_projectMonitor->isActive())
3273 m_projectMonitor->slotZoneEnd();
3275 m_clipMonitor->slotZoneEnd();
3278 void MainWindow::slotChangeTool(QAction * action)
3280 if (action == m_buttonSelectTool)
3281 slotSetTool(SELECTTOOL);
3282 else if (action == m_buttonRazorTool)
3283 slotSetTool(RAZORTOOL);
3284 else if (action == m_buttonSpacerTool)
3285 slotSetTool(SPACERTOOL);
3288 void MainWindow::slotChangeEdit(QAction * action)
3290 if (!m_activeTimeline)
3293 if (action == m_overwriteEditTool)
3294 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3295 else if (action == m_insertEditTool)
3296 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3298 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3301 void MainWindow::slotSetTool(PROJECTTOOL tool)
3303 if (m_activeDocument && m_activeTimeline) {
3304 //m_activeDocument->setTool(tool);
3308 message = i18n("Ctrl + click to use spacer on current track only");
3311 message = i18n("Click on a clip to cut it");
3314 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3317 m_messageLabel->setMessage(message, InformationMessage);
3318 m_activeTimeline->projectView()->setTool(tool);
3322 void MainWindow::slotCopy()
3324 if (m_activeDocument && m_activeTimeline)
3325 m_activeTimeline->projectView()->copyClip();
3328 void MainWindow::slotPaste()
3330 if (m_activeDocument && m_activeTimeline)
3331 m_activeTimeline->projectView()->pasteClip();
3334 void MainWindow::slotPasteEffects()
3336 if (m_activeDocument && m_activeTimeline)
3337 m_activeTimeline->projectView()->pasteClipEffects();
3340 void MainWindow::slotFind()
3342 if (!m_activeDocument || !m_activeTimeline) return;
3343 m_projectSearch->setEnabled(false);
3344 m_findActivated = true;
3345 m_findString.clear();
3346 m_activeTimeline->projectView()->initSearchStrings();
3347 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3348 m_findTimer.start(5000);
3349 qApp->installEventFilter(this);
3352 void MainWindow::slotFindNext()
3354 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3355 statusBar()->showMessage(i18n("Found: %1", m_findString));
3357 statusBar()->showMessage(i18n("Reached end of project"));
3358 m_findTimer.start(4000);
3361 void MainWindow::findAhead()
3363 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3364 m_projectSearchNext->setEnabled(true);
3365 statusBar()->showMessage(i18n("Found: %1", m_findString));
3367 m_projectSearchNext->setEnabled(false);
3368 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3372 void MainWindow::findTimeout()
3374 m_projectSearchNext->setEnabled(false);
3375 m_findActivated = false;
3376 m_findString.clear();
3377 statusBar()->showMessage(i18n("Find stopped"), 3000);
3378 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3379 m_projectSearch->setEnabled(true);
3380 removeEventFilter(this);
3383 void MainWindow::slotClipInTimeline(const QString &clipId)
3385 if (m_activeTimeline && m_activeDocument) {
3386 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3388 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3389 inTimelineMenu->clear();
3391 QList <QAction *> actionList;
3393 for (int i = 0; i < matching.count(); ++i) {
3394 QString track = QString::number(matching.at(i).track);
3395 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3397 QAction *a = new QAction(track + ": " + start, this);
3398 a->setData(QStringList() << track << start);
3399 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3400 while (j < actionList.count()) {
3401 if (actionList.at(j)->text() > a->text()) break;
3404 actionList.insert(j, a);
3406 inTimelineMenu->addActions(actionList);
3408 if (matching.empty())
3409 inTimelineMenu->setEnabled(false);
3411 inTimelineMenu->setEnabled(true);
3415 void MainWindow::slotClipInProjectTree()
3417 if (m_activeTimeline) {
3418 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3419 if (clipIds.isEmpty())
3421 m_projectListDock->raise();
3422 for (int i = 0; i < clipIds.count(); i++)
3423 m_projectList->selectItemById(clipIds.at(i));
3424 if (m_projectMonitor->isActive())
3425 slotSwitchMonitors();
3429 /*void MainWindow::slotClipToProjectTree()
3431 if (m_activeTimeline) {
3432 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3433 if (clips.isEmpty()) return;
3434 for (int i = 0; i < clips.count(); i++) {
3435 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3437 //m_projectList->selectItemById(clipIds.at(i));
3441 void MainWindow::slotSelectClipInTimeline()
3443 if (m_activeTimeline) {
3444 QAction *action = qobject_cast<QAction *>(sender());
3445 QStringList data = action->data().toStringList();
3446 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3450 void MainWindow::keyPressEvent(QKeyEvent *ke)
3452 if (m_findActivated) {
3453 if (ke->key() == Qt::Key_Backspace) {
3454 m_findString = m_findString.left(m_findString.length() - 1);
3456 if (!m_findString.isEmpty())
3461 m_findTimer.start(4000);
3464 } else if (ke->key() == Qt::Key_Escape) {
3468 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3469 m_findString += ke->text();
3473 m_findTimer.start(4000);
3478 KXmlGuiWindow::keyPressEvent(ke);
3483 /** Gets called when the window gets hidden */
3484 void MainWindow::hideEvent(QHideEvent */*event*/)
3486 if (isMinimized() && m_monitorManager)
3487 m_monitorManager->stopActiveMonitor();
3490 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3492 if (m_findActivated) {
3493 if (event->type() == QEvent::ShortcutOverride) {
3494 QKeyEvent* ke = (QKeyEvent*) event;
3495 if (ke->text().trimmed().isEmpty()) return false;
3502 // pass the event on to the parent class
3503 return QMainWindow::eventFilter(obj, event);
3508 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3510 KDialog *dialog = new KDialog(this);
3511 dialog->setCaption("Save clip zone");
3512 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3514 QWidget *widget = new QWidget(dialog);
3515 dialog->setMainWidget(widget);
3517 QVBoxLayout *vbox = new QVBoxLayout(widget);
3518 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3519 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3520 path.append("untitled.mlt");
3521 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3522 url->setFilter("video/mlt-playlist");
3523 QLabel *label2 = new QLabel(i18n("Description:"), this);
3524 KLineEdit *edit = new KLineEdit(this);
3525 vbox->addWidget(label1);
3526 vbox->addWidget(url);
3527 vbox->addWidget(label2);
3528 vbox->addWidget(edit);
3529 if (dialog->exec() == QDialog::Accepted)
3530 render->saveZone(url->url(), edit->text(), zone);
3534 void MainWindow::slotSetInPoint()
3536 if (m_clipMonitor->isActive())
3537 m_clipMonitor->slotSetZoneStart();
3539 m_projectMonitor->slotSetZoneStart();
3540 //else m_activeTimeline->projectView()->setInPoint();
3543 void MainWindow::slotSetOutPoint()
3545 if (m_clipMonitor->isActive())
3546 m_clipMonitor->slotSetZoneEnd();
3548 m_projectMonitor->slotSetZoneEnd();
3549 // else m_activeTimeline->projectView()->setOutPoint();
3552 void MainWindow::slotResizeItemStart()
3554 if (m_activeTimeline)
3555 m_activeTimeline->projectView()->setInPoint();
3558 void MainWindow::slotResizeItemEnd()
3560 if (m_activeTimeline)
3561 m_activeTimeline->projectView()->setOutPoint();
3564 int MainWindow::getNewStuff(const QString &configFile)
3566 KNS3::Entry::List entries;
3567 #if KDE_IS_VERSION(4,3,80)
3568 KNS3::DownloadDialog dialog(configFile);
3570 entries = dialog.changedEntries();
3571 foreach(const KNS3::Entry & entry, entries) {
3572 if (entry.status() == KNS3::Entry::Installed)
3573 kDebug() << "// Installed files: " << entry.installedFiles();
3576 KNS::Engine engine(0);
3577 if (engine.init(configFile))
3578 entries = engine.downloadDialogModal(this);
3579 foreach(KNS::Entry * entry, entries) {
3580 if (entry->status() == KNS::Entry::Installed)
3581 kDebug() << "// Installed files: " << entry->installedFiles();
3583 #endif /* KDE_IS_VERSION(4,3,80) */
3584 return entries.size();
3587 void MainWindow::slotGetNewTitleStuff()
3589 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3590 TitleWidget::refreshTitleTemplates();
3593 void MainWindow::slotGetNewLumaStuff()
3595 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3596 initEffects::refreshLumas();
3597 m_activeTimeline->projectView()->reloadTransitionLumas();
3601 void MainWindow::slotGetNewRenderStuff()
3603 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3605 m_renderWidget->reloadProfiles();
3608 void MainWindow::slotGetNewMltProfileStuff()
3610 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3611 // update the list of profiles in settings dialog
3612 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3618 void MainWindow::slotAutoTransition()
3620 if (m_activeTimeline)
3621 m_activeTimeline->projectView()->autoTransition();
3624 void MainWindow::slotSplitAudio()
3626 if (m_activeTimeline)
3627 m_activeTimeline->projectView()->splitAudio();
3630 void MainWindow::slotUpdateClipType(QAction *action)
3632 if (m_activeTimeline) {
3633 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3634 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3635 else m_activeTimeline->projectView()->setAudioAndVideo();
3639 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3641 // We must stop the monitors since we create a new on in the dvd wizard
3642 m_clipMonitor->stop();
3643 m_projectMonitor->stop();
3644 DvdWizard w(url, profile, this);
3646 m_projectMonitor->start();
3649 void MainWindow::slotShowTimeline(bool show)
3651 if (show == false) {
3652 m_timelineState = saveState();
3653 centralWidget()->setHidden(true);
3655 centralWidget()->setHidden(false);
3656 restoreState(m_timelineState);
3660 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3662 //TODO: is there a way to maximize current widget?
3665 m_timelineState = saveState();
3666 QWidget *par = focusWidget()->parentWidget();
3667 while (par->parentWidget() && par->parentWidget() != this)
3668 par = par->parentWidget();
3669 kDebug() << "CURRENT WIDGET: " << par->objectName();
3672 //centralWidget()->setHidden(false);
3673 //restoreState(m_timelineState);
3677 void MainWindow::loadTranscoders()
3679 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3682 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3683 KConfigGroup transConfig(config, "Transcoding");
3685 QMap< QString, QString > profiles = transConfig.entryMap();
3686 QMapIterator<QString, QString> i(profiles);
3687 while (i.hasNext()) {
3689 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3690 QAction *a = transMenu->addAction(i.key());
3692 if (data.count() > 1)
3693 a->setToolTip(data.at(1));
3694 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3698 void MainWindow::slotTranscode(KUrl::List urls)
3703 if (urls.isEmpty()) {
3704 QAction *action = qobject_cast<QAction *>(sender());
3705 QStringList data = action->data().toStringList();
3706 params = data.at(0);
3707 if (data.count() > 1) desc = data.at(1);
3708 if (data.count() > 2) condition = data.at(2);
3709 urls << m_projectList->getConditionalUrls(condition);
3710 urls.removeAll(KUrl());
3712 if (urls.isEmpty()) {
3713 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3716 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3717 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3719 //QProcess::startDetached("ffmpeg", parameters);
3722 void MainWindow::slotTranscodeClip()
3724 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3725 if (urls.isEmpty()) return;
3726 slotTranscode(urls);
3729 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3731 if (m_activeDocument == NULL) return;
3732 QMapIterator<QString, QString> i(props);
3733 while (i.hasNext()) {
3735 m_activeDocument->setDocumentProperty(i.key(), i.value());
3737 m_activeDocument->setModified(true);
3741 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3743 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3745 QString playlistPath;
3748 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3749 QString path = m_renderWidget->getFreeScriptName();
3750 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3751 if (!ok || scriptPath.isEmpty()) return;
3752 scriptPath.prepend(scriptsFolder);
3753 QFile f(scriptPath);
3755 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3758 playlistPath = scriptPath + ".mlt";
3760 KTemporaryFile temp;
3761 temp.setAutoRemove(false);
3762 temp.setSuffix(".mlt");
3764 playlistPath = temp.fileName();
3766 QString playlistContent = m_projectMonitor->sceneList();
3767 if (!chapterFile.isEmpty()) {
3770 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3772 in = m_activeTimeline->inPoint();
3773 out = m_activeTimeline->outPoint();
3776 QDomElement chapters = doc.createElement("chapters");
3777 chapters.setAttribute("fps", m_activeDocument->fps());
3778 doc.appendChild(chapters);
3780 QDomElement guidesxml = m_activeDocument->guidesXml();
3781 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3782 for (int i = 0; i < nodes.count(); i++) {
3783 QDomElement e = nodes.item(i).toElement();
3785 QString comment = e.attribute("comment");
3786 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3787 if (time >= in && time < out) {
3788 if (zoneOnly) time = time - in;
3789 QDomElement chapter = doc.createElement("chapter");
3790 chapters.appendChild(chapter);
3791 chapter.setAttribute("title", comment);
3792 chapter.setAttribute("time", time);
3796 if (chapters.childNodes().count() > 0) {
3797 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3798 // Always insert a guide in pos 0
3799 QDomElement chapter = doc.createElement("chapter");
3800 chapters.insertBefore(chapter, QDomNode());
3801 chapter.setAttribute("title", i18n("Start"));
3802 chapter.setAttribute("time", "0");
3804 // save chapters file
3805 QFile file(chapterFile);
3806 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3807 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3809 file.write(doc.toString().toUtf8());
3810 if (file.error() != QFile::NoError) {
3811 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3818 if (m_renderWidget->automaticAudioExport()) {
3819 exportAudio = m_activeTimeline->checkProjectAudio();
3820 } else exportAudio = m_renderWidget->selectedAudioExport();
3822 // Do we want proxy rendering
3823 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3824 // replace proxy clips with originals
3825 QMap <QString, QString> proxies = m_projectList->getProxies();
3826 QMapIterator<QString, QString> i(proxies);
3827 while (i.hasNext()) {
3829 // Replace all keys with their values (proxy path with original path)
3830 playlistContent.replace(i.key(), i.value());
3834 // Do save scenelist
3835 QFile file(playlistPath);
3836 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3837 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3840 file.write(playlistContent.toUtf8());
3841 if (file.error() != QFile::NoError) {
3842 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3847 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3850 void MainWindow::slotUpdateTimecodeFormat(int ix)
3852 KdenliveSettings::setFrametimecode(ix == 1);
3853 m_clipMonitor->updateTimecodeFormat();
3854 m_projectMonitor->updateTimecodeFormat();
3855 m_transitionConfig->updateTimecodeFormat();
3856 m_effectStack->updateTimecodeFormat();
3857 //m_activeTimeline->projectView()->clearSelection();
3858 m_activeTimeline->updateRuler();
3861 void MainWindow::slotRemoveFocus()
3863 statusBar()->setFocus();
3864 statusBar()->clearFocus();
3867 void MainWindow::slotRevert()
3869 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;
3870 KUrl url = m_activeDocument->url();
3871 if (closeCurrentDocument(false))
3872 doOpenFile(url, NULL);
3876 void MainWindow::slotShutdown()
3878 if (m_activeDocument) m_activeDocument->setModified(false);
3880 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3881 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3882 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3883 smserver.call("logout", 1, 2, 2);
3884 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3885 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3886 smserver.call("Shutdown");
3890 void MainWindow::slotUpdateTrackInfo()
3892 if (m_activeDocument)
3893 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3896 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3898 // Load the theme file
3900 if (action == NULL) theme = themename;
3901 else theme = action->data().toString();
3902 KdenliveSettings::setColortheme(theme);
3903 // Make palette for all widgets.
3905 if (theme.isEmpty()) {
3906 plt = QApplication::desktop()->palette();
3908 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3909 plt = KGlobalSettings::createApplicationPalette(config);
3912 kapp->setPalette(plt);
3913 const QObjectList children = statusBar()->children();
3915 foreach(QObject * child, children) {
3916 if (child->isWidgetType())
3917 ((QWidget*)child)->setPalette(plt);
3918 const QObjectList subchildren = child->children();
3919 foreach(QObject * subchild, subchildren) {
3920 if (subchild->isWidgetType())
3921 ((QWidget*)subchild)->setPalette(plt);
3924 if (m_activeTimeline) {
3925 m_activeTimeline->projectView()->updatePalette();
3930 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3932 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3933 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3934 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3935 const QSize bitsSize(24, 2);
3936 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3937 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3939 QPixmap pixmap(23, 16);
3940 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3942 KConfigGroup group(config, "WM");
3943 QPainter p(&pixmap);
3944 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3945 p.fillRect(1, 1, 7, 7, windowScheme.background());
3946 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3948 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3949 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3950 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3952 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3953 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3955 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3956 p.fillRect(1, 8, 7, 7, viewScheme.background());
3957 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3959 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3960 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3961 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3963 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3964 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3970 void MainWindow::slotSwitchMonitors()
3972 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3973 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3974 else m_projectList->focusTree();
3977 void MainWindow::slotSwitchFullscreen()
3979 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3980 else m_clipMonitor->slotSwitchFullScreen();
3983 void MainWindow::slotInsertZoneToTree()
3985 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3986 QStringList info = m_clipMonitor->getZoneInfo();
3987 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3990 void MainWindow::slotInsertZoneToTimeline()
3992 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3993 QStringList info = m_clipMonitor->getZoneInfo();
3994 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3998 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4000 if (m_activeDocument && m_activeTimeline) {
4001 if (!ids.isEmpty()) {
4002 for (int i = 0; i < ids.size(); ++i) {
4003 m_activeTimeline->slotDeleteClip(ids.at(i));
4005 m_activeDocument->clipManager()->slotDeleteClips(ids);
4007 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4008 m_activeDocument->setModified(true);
4012 void MainWindow::slotShowTitleBars(bool show)
4014 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4015 for (int i = 0; i < docks.count(); i++) {
4016 QDockWidget* dock = docks.at(i);
4018 dock->setTitleBarWidget(0);
4020 if (!dock->isFloating()) {
4021 dock->setTitleBarWidget(new QWidget);
4025 KdenliveSettings::setShowtitlebars(show);
4028 void MainWindow::slotSwitchTitles()
4030 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4033 QString MainWindow::getMimeType()
4035 QString mimetype = "application/x-kdenlive";
4036 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4037 if (!mime) mimetype = "*.kdenlive";
4041 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4044 m_projectMonitor->render->sendFrameForAnalysis = true;
4047 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4048 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4055 qDebug() << "Any scope accepting new frames? " << request;
4058 m_projectMonitor->render->sendFrameForAnalysis = false;
4062 void MainWindow::slotUpdateGfxScopeFrameRequest()
4064 // We need a delay to make sure widgets are hidden after a close event for example
4065 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4068 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4071 bool request = false;
4072 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4073 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4074 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4080 if (!m_projectMonitor->effectSceneDisplayed()) {
4081 m_projectMonitor->render->sendFrameForAnalysis = false;
4083 m_clipMonitor->render->sendFrameForAnalysis = false;
4085 m_projectMonitor->render->sendFrameForAnalysis = true;
4086 m_clipMonitor->render->sendFrameForAnalysis = true;
4090 void MainWindow::slotUpdateAudioScopeFrameRequest()
4092 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4095 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4097 bool request = false;
4098 for (int i = 0; i < m_audioScopesList.count(); i++) {
4099 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4100 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4105 // Handle audio signal separately (no common interface)
4106 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4107 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4111 qDebug() << "Scopes Requesting Audio data: " << request;
4113 KdenliveSettings::setMonitor_audio(request);
4114 m_monitorManager->slotUpdateAudioMonitoring();
4117 void MainWindow::slotUpdateColorScopes()
4119 bool request = false;
4120 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4121 // Check if we need the renderer to send a new frame for update
4122 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4123 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4126 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4127 else m_projectMonitor->render->sendFrameUpdate();
4131 void MainWindow::slotOpenStopmotion()
4133 if (m_stopmotion == NULL) {
4134 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4135 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4136 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4137 // Check if we need the renderer to send a new frame for update
4138 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4139 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4140 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4143 m_stopmotion->show();
4146 void MainWindow::slotDeleteClip(const QString &id)
4148 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4149 for (int i = 0; i < list.size(); ++i) {
4150 list.at(i)->disableClipId(id);
4152 m_projectList->slotDeleteClip(id);
4155 void MainWindow::slotUpdateProxySettings()
4157 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4158 if (KdenliveSettings::enableproxy())
4159 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4160 m_projectList->updateProxyConfig();
4163 #include "mainwindow.moc"