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 static const char version[] = VERSION;
117 static const int ID_TIMELINE_POS = 0;
123 Q_DECLARE_METATYPE(QVector<int16_t>)
125 EffectsList MainWindow::videoEffects;
126 EffectsList MainWindow::audioEffects;
127 EffectsList MainWindow::customEffects;
128 EffectsList MainWindow::transitions;
130 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
131 KXmlGuiWindow(parent),
132 m_activeDocument(NULL),
133 m_activeTimeline(NULL),
134 m_renderWidget(NULL),
135 #ifndef NO_JOGSHUTTLE
138 #endif /* NO_JOGSHUTTLE */
139 m_findActivated(false),
142 qRegisterMetaType<QVector<int16_t> > ();
143 // Create DBus interface
144 new MainWindowAdaptor(this);
145 QDBusConnection dbus = QDBusConnection::sessionBus();
146 dbus.registerObject("/MainWindow", this);
148 setlocale(LC_NUMERIC, "POSIX");
149 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
150 setFont(KGlobalSettings::toolBarFont());
151 parseProfiles(MltPath);
152 m_commandStack = new QUndoGroup;
153 setDockNestingEnabled(true);
154 m_timelineArea = new KTabWidget(this);
155 m_timelineArea->setTabReorderingEnabled(true);
156 m_timelineArea->setTabBarHidden(true);
157 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
158 m_timelineArea->setMinimumHeight(200);
160 QToolButton *closeTabButton = new QToolButton;
161 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
162 closeTabButton->setIcon(KIcon("tab-close"));
163 closeTabButton->adjustSize();
164 closeTabButton->setToolTip(i18n("Close the current tab"));
165 m_timelineArea->setCornerWidget(closeTabButton);
166 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
168 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
169 m_findTimer.setSingleShot(true);
171 // FIXME: the next call returns a newly allocated object, which leaks
172 initEffects::parseEffectFiles();
173 //initEffects::parseCustomEffectsFile();
175 m_monitorManager = new MonitorManager();
177 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
178 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
183 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
184 m_projectListDock->setObjectName("project_tree");
185 m_projectList = new ProjectList();
186 m_projectListDock->setWidget(m_projectList);
187 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
189 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
190 m_clipMonitorDock->setObjectName("clip_monitor");
191 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
192 m_clipMonitorDock->setWidget(m_clipMonitor);
193 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
195 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
196 m_projectMonitorDock->setObjectName("project_monitor");
197 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
198 m_projectMonitorDock->setWidget(m_projectMonitor);
199 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
202 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
203 m_recMonitorDock->setObjectName("record_monitor");
204 m_recMonitor = new RecMonitor("record");
205 m_recMonitorDock->setWidget(m_recMonitor);
206 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
207 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
208 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
211 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
212 m_notesDock->setObjectName("notes_widget");
213 m_notesWidget = new KTextEdit();
214 m_notesWidget->setTabChangesFocus(true);
215 #if KDE_IS_VERSION(4,4,0)
216 m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
218 m_notesDock->setWidget(m_notesWidget);
219 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
221 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
222 m_effectStackDock->setObjectName("effect_stack");
223 m_effectStack = new EffectStackView(m_projectMonitor);
224 m_effectStackDock->setWidget(m_effectStack);
225 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
227 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
228 m_transitionConfigDock->setObjectName("transition");
229 m_transitionConfig = new TransitionSettings(m_projectMonitor);
230 m_transitionConfigDock->setWidget(m_transitionConfig);
231 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
233 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
234 m_effectListDock->setObjectName("effect_list");
235 m_effectList = new EffectsListView();
236 m_effectListDock->setWidget(m_effectList);
237 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
239 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
240 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
241 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
242 m_vectorscopeDock->setWidget(m_vectorscope);
243 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
244 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
245 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
246 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
247 m_scopesList.append(m_vectorscopeDock);
249 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
250 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
251 m_waveformDock->setObjectName(m_waveform->widgetName());
252 m_waveformDock->setWidget(m_waveform);
253 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
254 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
255 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
256 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
257 m_scopesList.append(m_waveformDock);
259 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
260 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
261 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
262 m_RGBParadeDock->setWidget(m_RGBParade);
263 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
264 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
265 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
266 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
267 m_scopesList.append(m_RGBParadeDock);
269 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
270 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
271 m_histogramDock->setObjectName(m_histogram->widgetName());
272 m_histogramDock->setWidget(m_histogram);
273 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
274 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
275 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
276 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
277 m_scopesList.append(m_histogramDock);
280 m_audiosignal = new AudioSignal;
281 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
282 m_audiosignalDock->setObjectName("audiosignal");
283 m_audiosignalDock->setWidget(m_audiosignal);
284 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
285 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
286 /*if (m_projectMonitor) {
287 connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
290 connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
293 m_audioSpectrum = new AudioSpectrum();
294 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
295 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
296 m_audioSpectrumDock->setWidget(m_audioSpectrum);
297 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
299 m_spectrogram = new Spectrogram();
300 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
301 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
302 m_spectrogramDock->setWidget(m_spectrogram);
303 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
305 // Connect the audio signal to the audio scope slots
307 if (m_projectMonitor) {
308 qDebug() << "project monitor connected";
309 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
310 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
311 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
312 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
313 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
314 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
317 qDebug() << "clip monitor connected";
318 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
319 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
320 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
321 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
322 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
323 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
325 // Ensure connections were set up correctly
328 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
329 m_undoViewDock->setObjectName("undo_history");
330 m_undoView = new QUndoView();
331 m_undoView->setCleanIcon(KIcon("edit-clear"));
332 m_undoView->setEmptyLabel(i18n("Clean"));
333 m_undoViewDock->setWidget(m_undoView);
334 m_undoView->setGroup(m_commandStack);
335 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
337 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
338 //overviewDock->setObjectName("project_overview");
339 //m_overView = new CustomTrackView(NULL, NULL, this);
340 //overviewDock->setWidget(m_overView);
341 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
346 /// Tabify Widgets ///
347 tabifyDockWidget(m_projectListDock, m_effectStackDock);
348 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
349 tabifyDockWidget(m_projectListDock, m_notesDock);
352 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
354 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
357 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
358 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
359 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
360 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
361 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
364 setCentralWidget(m_timelineArea);
367 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
368 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
370 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
371 m_fileRevert->setEnabled(false);
373 // Prepare layout actions
374 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
375 for (int i = 1; i < 5; i++) {
376 KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
377 load->setData("_" + QString::number(i));
378 layoutActions->addAction("load_layout" + QString::number(i), load);
379 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
380 save->setData("_" + QString::number(i));
381 layoutActions->addAction("save_layout" + QString::number(i), save);
385 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
386 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
387 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
388 action->setShortcut(Qt::Key_Space);
389 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
390 m_stopmotion_actions->addAction("stopmotion_capture", action);
391 action = new KAction(i18n("Switch live / captured frame"), this);
392 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
393 m_stopmotion_actions->addAction("stopmotion_switch", action);
394 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
395 action->setCheckable(true);
396 action->setChecked(false);
397 m_stopmotion_actions->addAction("stopmotion_overlay", action);
401 // Find QDockWidget tab bars and show / hide widget title bars on right click
402 QList <QTabBar *> tabs = findChildren<QTabBar *>();
403 for (int i = 0; i < tabs.count(); i++) {
404 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
405 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
408 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
409 guiFactory()->addClient(sp);*/
412 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
414 connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
415 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
417 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
420 // Load layout names from config file
425 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
427 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
428 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
430 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
431 clipInTimeline->setIcon(KIcon("go-jump"));
432 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
433 static_cast<QMenu*>(factory()->container("transcoders", this)),
436 // build themes menus
437 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
438 QActionGroup *themegroup = new QActionGroup(this);
439 themegroup->setExclusive(true);
440 action = new KAction(i18n("Default"), this);
441 action->setCheckable(true);
442 themegroup->addAction(action);
443 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
445 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
447 for (int i = 0; i < schemeFiles.size(); ++i) {
449 const QString filename = schemeFiles.at(i);
450 const QFileInfo info(filename);
453 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
454 QIcon icon = createSchemePreviewIcon(config);
455 KConfigGroup group(config, "General");
456 const QString name = group.readEntry("Name", info.baseName());
457 action = new KAction(name, this);
458 action->setData(filename);
459 action->setIcon(icon);
460 action->setCheckable(true);
461 themegroup->addAction(action);
462 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
465 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
466 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
467 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
470 action = new QAction(fi.fileName(), this);
471 action->setData(*it);
472 action->setCheckable(true);
473 themegroup->addAction(action);
474 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
476 themesMenu->addActions(themegroup->actions());
477 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
479 // Setup and fill effects and transitions menus.
480 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
481 for (int i = 0; i < videoEffects.count(); ++i)
482 m_videoEffectsMenu->addAction(m_videoEffects[i]);
483 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
484 for (int i = 0; i < audioEffects.count(); ++i)
485 m_audioEffectsMenu->addAction(m_audioEffects[i]);
486 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
487 if (customEffects.isEmpty())
488 m_customEffectsMenu->setEnabled(false);
490 m_customEffectsMenu->setEnabled(true);
491 for (int i = 0; i < customEffects.count(); ++i)
492 m_customEffectsMenu->addAction(m_customEffects[i]);
493 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
494 for (int i = 0; i < transitions.count(); ++i)
495 m_transitionsMenu->addAction(m_transitions[i]);
497 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
498 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
499 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
500 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
502 QMenu *newEffect = new QMenu(this);
503 newEffect->addMenu(m_videoEffectsMenu);
504 newEffect->addMenu(m_audioEffectsMenu);
505 newEffect->addMenu(m_customEffectsMenu);
506 m_effectStack->setMenu(newEffect);
508 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
509 const QList<QAction *> viewActions = createPopupMenu()->actions();
510 viewMenu->insertActions(NULL, viewActions);
512 m_timelineContextMenu = new QMenu(this);
513 m_timelineContextClipMenu = new QMenu(this);
514 m_timelineContextTransitionMenu = new QMenu(this);
516 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
517 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
518 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
520 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
521 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
522 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
523 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
524 m_timelineContextClipMenu->addSeparator();
525 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
526 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
527 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
528 m_timelineContextClipMenu->addSeparator();
529 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
530 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
531 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
532 m_timelineContextClipMenu->addSeparator();
534 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
535 m_timelineContextClipMenu->addMenu(markersMenu);
536 m_timelineContextClipMenu->addSeparator();
537 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
538 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
539 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
540 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
542 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
543 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
544 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
546 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
548 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
549 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
550 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
551 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
552 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
553 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
554 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
556 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
557 slotConnectMonitors();
559 // Open or create a file. Command line argument passed in Url has
560 // precedence, then "openlastproject", then just a plain empty file.
561 // If opening Url fails, openlastproject will _not_ be used.
562 if (!Url.isEmpty()) {
563 // delay loading so that the window shows up
565 QTimer::singleShot(500, this, SLOT(openFile()));
566 } else if (KdenliveSettings::openlastproject()) {
567 QTimer::singleShot(500, this, SLOT(openLastFile()));
568 } else { //if (m_timelineArea->count() == 0) {
572 if (!clipsToLoad.isEmpty() && m_activeDocument) {
573 QStringList list = clipsToLoad.split(',');
575 foreach(QString path, list) {
576 kDebug() << QDir::current().absoluteFilePath(path);
577 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
579 m_projectList->slotAddClip(urls);
582 #ifndef NO_JOGSHUTTLE
583 activateShuttleDevice();
584 #endif /* NO_JOGSHUTTLE */
585 m_projectListDock->raise();
587 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
588 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
591 MainWindow::~MainWindow()
596 m_effectStack->slotClipItemSelected(NULL, 0);
597 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
599 if (m_projectMonitor) m_projectMonitor->stop();
600 if (m_clipMonitor) m_clipMonitor->stop();
602 delete m_activeTimeline;
603 delete m_effectStack;
604 delete m_transitionConfig;
605 delete m_activeDocument;
606 delete m_projectMonitor;
607 delete m_clipMonitor;
608 delete m_shortcutRemoveFocus;
609 Mlt::Factory::close();
612 void MainWindow::queryQuit()
620 bool MainWindow::queryClose()
622 if (m_renderWidget) {
623 int waitingJobs = m_renderWidget->waitingJobsCount();
624 if (waitingJobs > 0) {
625 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")))) {
626 case KMessageBox::Yes :
627 // create script with waiting jobs and start it
628 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
630 case KMessageBox::No :
631 // Don't do anything, jobs will be deleted
639 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
640 // warn the user to save if document is modified and we have clips in our project list
641 if (m_activeDocument && m_activeDocument->isModified() &&
642 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
643 !m_projectList->documentClipList().isEmpty())) {
647 if (m_activeDocument->url().fileName().isEmpty())
648 message = i18n("Save changes to document?");
650 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
651 switch (KMessageBox::warningYesNoCancel(this, message)) {
652 case KMessageBox::Yes :
653 // save document here. If saving fails, return false;
655 case KMessageBox::No :
656 // User does not want to save the changes, clear recovery files
657 m_activeDocument->m_autosave->resize(0);
666 void MainWindow::loadPlugins()
668 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
669 populateMenus(plugin);
672 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
674 filters << "libkdenlive*";
675 foreach(const QString & folder, directories) {
676 kDebug() << "Parsing plugin folder: " << folder;
677 QDir pluginsDir(folder);
678 foreach(const QString & fileName,
679 pluginsDir.entryList(filters, QDir::Files)) {
681 * Avoid loading the same plugin twice when there is more than one
684 if (!m_pluginFileNames.contains(fileName)) {
685 kDebug() << "Found plugin: " << fileName;
686 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
687 QObject *plugin = loader.instance();
689 populateMenus(plugin);
690 m_pluginFileNames += fileName;
692 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
698 void MainWindow::populateMenus(QObject *plugin)
700 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
701 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
703 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
707 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
708 QMenu *menu, const char *member,
709 QActionGroup *actionGroup)
711 kDebug() << "// ADD to MENU" << texts;
712 foreach(const QString & text, texts) {
713 QAction *action = new QAction(text, plugin);
714 action->setData(text);
715 connect(action, SIGNAL(triggered()), this, member);
716 menu->addAction(action);
719 action->setCheckable(true);
720 actionGroup->addAction(action);
725 void MainWindow::aboutPlugins()
727 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
732 void MainWindow::generateClip()
734 QAction *action = qobject_cast<QAction *>(sender());
735 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
737 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
738 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
739 if (!clipUrl.isEmpty()) {
740 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
744 void MainWindow::saveProperties(KConfigGroup &config)
746 // save properties here,used by session management
748 KMainWindow::saveProperties(config);
752 void MainWindow::readProperties(const KConfigGroup &config)
754 // read properties here,used by session management
755 KMainWindow::readProperties(config);
756 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
757 openFile(KUrl(Lastproject));
760 void MainWindow::slotReloadEffects()
762 m_customEffectsMenu->clear();
763 initEffects::parseCustomEffectsFile();
765 QStringList effectInfo;
766 QMap<QString, QStringList> effectsList;
767 for (int ix = 0; ix < customEffects.count(); ix++) {
768 effectInfo = customEffects.effectIdInfo(ix);
769 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
771 if (effectsList.isEmpty())
772 m_customEffectsMenu->setEnabled(false);
774 m_customEffectsMenu->setEnabled(true);
776 foreach(const QStringList & value, effectsList) {
777 action = new QAction(value.at(0), this);
778 action->setData(value);
779 m_customEffectsMenu->addAction(action);
781 m_effectList->reloadEffectList();
784 #ifndef NO_JOGSHUTTLE
785 void MainWindow::activateShuttleDevice()
791 if (KdenliveSettings::enableshuttle() == false) return;
793 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
794 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
796 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
797 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
798 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
799 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
800 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
802 #endif /* NO_JOGSHUTTLE */
804 void MainWindow::slotDoAction(const QString& action_name)
806 QAction* action = actionCollection()->action(action_name);
808 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
814 void MainWindow::configureNotifications()
816 KNotifyConfigWidget::configure(this);
819 void MainWindow::slotFullScreen()
821 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
824 void MainWindow::slotAddEffect(const QDomElement effect)
826 if (!m_activeDocument) return;
827 if (effect.isNull()) {
828 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
831 QDomElement effectToAdd = effect.cloneNode().toElement();
833 int ix = m_effectStack->isTrackMode(&ok);
834 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
835 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
838 void MainWindow::slotRaiseMonitor(bool clipMonitor)
840 if (clipMonitor) m_clipMonitorDock->raise();
841 else m_projectMonitorDock->raise();
844 void MainWindow::slotUpdateClip(const QString &id)
846 if (!m_activeDocument) return;
847 m_activeTimeline->projectView()->slotUpdateClip(id);
850 void MainWindow::slotConnectMonitors()
852 m_projectList->setRenderer(m_projectMonitor->render);
853 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
854 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
855 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
856 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
857 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
858 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
859 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
861 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
863 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
865 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
866 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
868 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
870 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
871 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
874 void MainWindow::slotAdjustClipMonitor()
876 m_clipMonitorDock->updateGeometry();
877 m_clipMonitorDock->adjustSize();
878 m_clipMonitor->resetSize();
881 void MainWindow::slotAdjustProjectMonitor()
883 m_projectMonitorDock->updateGeometry();
884 m_projectMonitorDock->adjustSize();
885 m_projectMonitor->resetSize();
889 class NameGrabbingKActionCollection {
891 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
892 : m_collection(collection), m_action_names(action_names) {
893 m_action_names.clear();
895 KAction* addAction(const QString& action_name) {
896 m_action_names << action_name;
897 return m_collection->addAction(action_name);
899 void addAction(const QString& action_name, QAction* action) {
900 m_action_names << action_name;
901 m_collection->addAction(action_name, action);
903 operator KActionCollection*() { return m_collection; }
904 const QStringList& actionNames() const { return m_action_names; }
906 KActionCollection* m_collection;
907 QStringList& m_action_names;
910 void MainWindow::setupActions()
913 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
914 m_timecodeFormat = new KComboBox(this);
915 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
916 m_timecodeFormat->addItem(i18n("Frames"));
917 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
918 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
920 m_statusProgressBar = new QProgressBar(this);
921 m_statusProgressBar->setMinimum(0);
922 m_statusProgressBar->setMaximum(100);
923 m_statusProgressBar->setMaximumWidth(150);
924 m_statusProgressBar->setVisible(false);
926 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
927 toolbar->setMovable(false);
928 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
929 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
930 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
931 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
932 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
933 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());
934 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
936 //create edit mode buttons
937 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
938 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
939 toolbar->addAction(m_normalEditTool);
940 m_normalEditTool->setCheckable(true);
941 m_normalEditTool->setChecked(true);
943 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
944 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
945 toolbar->addAction(m_overwriteEditTool);
946 m_overwriteEditTool->setCheckable(true);
947 m_overwriteEditTool->setChecked(false);
949 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
950 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
951 toolbar->addAction(m_insertEditTool);
952 m_insertEditTool->setCheckable(true);
953 m_insertEditTool->setChecked(false);
954 // not implemented yet
955 m_insertEditTool->setEnabled(false);
957 QActionGroup *editGroup = new QActionGroup(this);
958 editGroup->addAction(m_normalEditTool);
959 editGroup->addAction(m_overwriteEditTool);
960 editGroup->addAction(m_insertEditTool);
961 editGroup->setExclusive(true);
962 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
963 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
965 toolbar->addSeparator();
967 // create tools buttons
968 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
969 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
970 toolbar->addAction(m_buttonSelectTool);
971 m_buttonSelectTool->setCheckable(true);
972 m_buttonSelectTool->setChecked(true);
974 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
975 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
976 toolbar->addAction(m_buttonRazorTool);
977 m_buttonRazorTool->setCheckable(true);
978 m_buttonRazorTool->setChecked(false);
980 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
981 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
982 toolbar->addAction(m_buttonSpacerTool);
983 m_buttonSpacerTool->setCheckable(true);
984 m_buttonSpacerTool->setChecked(false);
986 QActionGroup *toolGroup = new QActionGroup(this);
987 toolGroup->addAction(m_buttonSelectTool);
988 toolGroup->addAction(m_buttonRazorTool);
989 toolGroup->addAction(m_buttonSpacerTool);
990 toolGroup->setExclusive(true);
991 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
993 QWidget * actionWidget;
994 int max = toolbar->iconSizeDefault() + 2;
995 actionWidget = toolbar->widgetForAction(m_normalEditTool);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
999 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1000 actionWidget->setMaximumWidth(max);
1001 actionWidget->setMaximumHeight(max - 4);
1003 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1004 actionWidget->setMaximumWidth(max);
1005 actionWidget->setMaximumHeight(max - 4);
1007 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1008 actionWidget->setMaximumWidth(max);
1009 actionWidget->setMaximumHeight(max - 4);
1011 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1012 actionWidget->setMaximumWidth(max);
1013 actionWidget->setMaximumHeight(max - 4);
1015 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1016 actionWidget->setMaximumWidth(max);
1017 actionWidget->setMaximumHeight(max - 4);
1019 toolbar->setStyleSheet(style1);
1020 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1022 toolbar->addSeparator();
1023 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1024 toolbar->addAction(m_buttonFitZoom);
1025 m_buttonFitZoom->setCheckable(false);
1027 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1028 toolbar->addAction(m_zoomOut);
1029 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1031 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1032 m_zoomSlider->setMaximum(13);
1033 m_zoomSlider->setPageStep(1);
1034 m_zoomSlider->setInvertedAppearance(true);
1036 m_zoomSlider->setMaximumWidth(150);
1037 m_zoomSlider->setMinimumWidth(100);
1038 toolbar->addWidget(m_zoomSlider);
1040 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1041 toolbar->addAction(m_zoomIn);
1042 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1044 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1045 actionWidget->setMaximumWidth(max);
1046 actionWidget->setMaximumHeight(max - 4);
1047 actionWidget->setStyleSheet(styleBorderless);
1049 actionWidget = toolbar->widgetForAction(m_zoomIn);
1050 actionWidget->setMaximumWidth(max);
1051 actionWidget->setMaximumHeight(max - 4);
1052 actionWidget->setStyleSheet(styleBorderless);
1054 actionWidget = toolbar->widgetForAction(m_zoomOut);
1055 actionWidget->setMaximumWidth(max);
1056 actionWidget->setMaximumHeight(max - 4);
1057 actionWidget->setStyleSheet(styleBorderless);
1059 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1060 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1061 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1062 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1063 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1065 toolbar->addSeparator();
1067 //create automatic audio split button
1068 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1069 toolbar->addAction(m_buttonAutomaticSplitAudio);
1070 m_buttonAutomaticSplitAudio->setCheckable(true);
1071 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1072 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1074 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1075 toolbar->addAction(m_buttonVideoThumbs);
1076 m_buttonVideoThumbs->setCheckable(true);
1077 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1078 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1080 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1081 toolbar->addAction(m_buttonAudioThumbs);
1082 m_buttonAudioThumbs->setCheckable(true);
1083 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1084 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1086 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1087 toolbar->addAction(m_buttonShowMarkers);
1088 m_buttonShowMarkers->setCheckable(true);
1089 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1090 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1092 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1093 toolbar->addAction(m_buttonSnap);
1094 m_buttonSnap->setCheckable(true);
1095 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1096 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1098 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1099 actionWidget->setMaximumWidth(max);
1100 actionWidget->setMaximumHeight(max - 4);
1102 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1103 actionWidget->setMaximumWidth(max);
1104 actionWidget->setMaximumHeight(max - 4);
1106 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1107 actionWidget->setMaximumWidth(max);
1108 actionWidget->setMaximumHeight(max - 4);
1110 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1111 actionWidget->setMaximumWidth(max);
1112 actionWidget->setMaximumHeight(max - 4);
1114 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1115 actionWidget->setMaximumWidth(max);
1116 actionWidget->setMaximumHeight(max - 4);
1118 m_messageLabel = new StatusBarMessageLabel(this);
1119 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1121 statusBar()->addWidget(m_messageLabel, 10);
1122 statusBar()->addWidget(m_statusProgressBar, 0);
1123 statusBar()->addPermanentWidget(toolbar);
1124 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1125 statusBar()->addPermanentWidget(m_timecodeFormat);
1126 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1128 collection.addAction("normal_mode", m_normalEditTool);
1129 collection.addAction("overwrite_mode", m_overwriteEditTool);
1130 collection.addAction("insert_mode", m_insertEditTool);
1131 collection.addAction("select_tool", m_buttonSelectTool);
1132 collection.addAction("razor_tool", m_buttonRazorTool);
1133 collection.addAction("spacer_tool", m_buttonSpacerTool);
1135 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1136 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1137 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1138 collection.addAction("show_markers", m_buttonShowMarkers);
1139 collection.addAction("snap", m_buttonSnap);
1140 collection.addAction("zoom_fit", m_buttonFitZoom);
1141 collection.addAction("zoom_in", m_zoomIn);
1142 collection.addAction("zoom_out", m_zoomOut);
1144 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1145 collection.addAction("project_find", m_projectSearch);
1146 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1147 m_projectSearch->setShortcut(Qt::Key_Slash);
1149 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1150 collection.addAction("project_find_next", m_projectSearchNext);
1151 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1152 m_projectSearchNext->setShortcut(Qt::Key_F3);
1153 m_projectSearchNext->setEnabled(false);
1155 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1156 collection.addAction("manage_profiles", profilesAction);
1157 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1159 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1160 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1161 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1162 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1164 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1165 collection.addAction("run_wizard", wizAction);
1166 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1168 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1169 collection.addAction("project_settings", projectAction);
1170 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1172 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1173 collection.addAction("project_render", projectRender);
1174 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1175 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1177 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1178 collection.addAction("project_clean", projectClean);
1179 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1181 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1182 collection.addAction("project_adjust_profile", projectAdjust);
1183 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1185 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1186 KShortcut playShortcut;
1187 playShortcut.setPrimary(Qt::Key_Space);
1188 playShortcut.setAlternate(Qt::Key_K);
1189 monitorPlay->setShortcut(playShortcut);
1190 collection.addAction("monitor_play", monitorPlay);
1191 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1193 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1194 collection.addAction("monitor_pause", monitorPause);
1195 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1197 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1198 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1199 collection.addAction("monitor_play_zone", m_playZone);
1200 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1202 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1203 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1204 collection.addAction("monitor_loop_zone", m_loopZone);
1205 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1207 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1208 m_loopClip->setEnabled(false);
1209 collection.addAction("monitor_loop_clip", m_loopClip);
1210 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1212 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1213 collection.addAction("dvd_wizard", dvdWizard);
1214 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1216 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1217 collection.addAction("transcode_clip", transcodeClip);
1218 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1220 KAction *markIn = collection.addAction("mark_in");
1221 markIn->setText(i18n("Set Zone In"));
1222 markIn->setShortcut(Qt::Key_I);
1223 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1225 KAction *markOut = collection.addAction("mark_out");
1226 markOut->setText(i18n("Set Zone Out"));
1227 markOut->setShortcut(Qt::Key_O);
1228 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1230 KAction *switchMon = collection.addAction("switch_monitor");
1231 switchMon->setText(i18n("Switch monitor"));
1232 switchMon->setShortcut(Qt::Key_T);
1233 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1235 KAction *fullMon = collection.addAction("monitor_fullscreen");
1236 fullMon->setText(i18n("Switch monitor fullscreen"));
1237 fullMon->setIcon(KIcon("view-fullscreen"));
1238 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1240 KAction *insertTree = collection.addAction("insert_project_tree");
1241 insertTree->setText(i18n("Insert zone in project tree"));
1242 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1243 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1245 KAction *insertTimeline = collection.addAction("insert_timeline");
1246 insertTimeline->setText(i18n("Insert zone in timeline"));
1247 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1248 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1250 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1251 collection.addAction("resize_timeline_clip_start", resizeStart);
1252 resizeStart->setShortcut(Qt::Key_1);
1253 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1255 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1256 collection.addAction("resize_timeline_clip_end", resizeEnd);
1257 resizeEnd->setShortcut(Qt::Key_2);
1258 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1260 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1261 monitorSeekBackward->setShortcut(Qt::Key_J);
1262 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1263 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1265 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1266 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1267 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1268 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1270 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1271 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1272 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1273 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1275 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1276 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1277 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1278 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1280 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1281 monitorSeekForward->setShortcut(Qt::Key_L);
1282 collection.addAction("monitor_seek_forward", monitorSeekForward);
1283 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1285 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1286 clipStart->setShortcut(Qt::Key_Home);
1287 collection.addAction("seek_clip_start", clipStart);
1288 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1290 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1291 clipEnd->setShortcut(Qt::Key_End);
1292 collection.addAction("seek_clip_end", clipEnd);
1293 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1295 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1296 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1297 collection.addAction("seek_zone_start", zoneStart);
1298 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1300 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1301 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1302 collection.addAction("seek_zone_end", zoneEnd);
1303 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1305 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1306 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1307 collection.addAction("seek_start", projectStart);
1308 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1310 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1311 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1312 collection.addAction("seek_end", projectEnd);
1313 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1315 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1316 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1317 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1318 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1320 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1321 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1322 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1323 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1325 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1326 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1327 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1328 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1330 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1331 deleteItem->setShortcut(Qt::Key_Delete);
1332 collection.addAction("delete_timeline_clip", deleteItem);
1333 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1335 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1336 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1337 editTimelineClipSpeed->setData("change_speed");
1338 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1340 KAction *stickTransition = collection.addAction("auto_transition");
1341 stickTransition->setData(QString("auto"));
1342 stickTransition->setCheckable(true);
1343 stickTransition->setEnabled(false);
1344 stickTransition->setText(i18n("Automatic Transition"));
1345 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1347 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1348 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1349 collection.addAction("group_clip", groupClip);
1350 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1352 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1353 collection.addAction("ungroup_clip", ungroupClip);
1354 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1355 ungroupClip->setData("ungroup_clip");
1356 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1358 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1359 collection.addAction("edit_item_duration", editItemDuration);
1360 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1362 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1363 collection.addAction("clip_in_project_tree", clipInProjectTree);
1364 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1366 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1367 collection.addAction("clip_to_project_tree", clipToProjectTree);
1368 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1370 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1371 insertOvertwrite->setShortcut(Qt::Key_V);
1372 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1373 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1375 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1376 selectTimelineClip->setShortcut(Qt::Key_Plus);
1377 collection.addAction("select_timeline_clip", selectTimelineClip);
1378 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1380 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1381 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1382 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1383 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1385 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1386 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1387 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1388 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1390 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1391 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1392 collection.addAction("select_timeline_transition", selectTimelineTransition);
1393 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1395 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1396 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1397 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1398 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1400 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1401 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1402 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1403 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1405 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1406 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1407 collection.addAction("cut_timeline_clip", cutTimelineClip);
1408 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1410 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1411 collection.addAction("add_clip_marker", addClipMarker);
1412 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1414 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1415 collection.addAction("delete_clip_marker", deleteClipMarker);
1416 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1418 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1419 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1420 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1422 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1423 collection.addAction("edit_clip_marker", editClipMarker);
1424 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1426 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1427 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1428 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1429 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1431 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1432 collection.addAction("split_audio", splitAudio);
1433 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1435 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1436 collection.addAction("clip_audio_only", audioOnly);
1437 audioOnly->setData("clip_audio_only");
1438 audioOnly->setCheckable(true);
1440 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1441 collection.addAction("clip_video_only", videoOnly);
1442 videoOnly->setData("clip_video_only");
1443 videoOnly->setCheckable(true);
1445 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1446 collection.addAction("clip_audio_and_video", audioAndVideo);
1447 audioAndVideo->setData("clip_audio_and_video");
1448 audioAndVideo->setCheckable(true);
1450 m_clipTypeGroup = new QActionGroup(this);
1451 m_clipTypeGroup->addAction(audioOnly);
1452 m_clipTypeGroup->addAction(videoOnly);
1453 m_clipTypeGroup->addAction(audioAndVideo);
1454 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1455 m_clipTypeGroup->setEnabled(false);
1457 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1458 collection.addAction("insert_space", insertSpace);
1459 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1461 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1462 collection.addAction("delete_space", removeSpace);
1463 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1465 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1466 collection.addAction("insert_track", insertTrack);
1467 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1469 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1470 collection.addAction("delete_track", deleteTrack);
1471 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1473 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1474 collection.addAction("config_tracks", configTracks);
1475 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1477 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1478 collection.addAction("add_guide", addGuide);
1479 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1481 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1482 collection.addAction("delete_guide", delGuide);
1483 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1485 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1486 collection.addAction("edit_guide", editGuide);
1487 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1489 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1490 collection.addAction("delete_all_guides", delAllGuides);
1491 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1493 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1494 collection.addAction("paste_effects", pasteEffects);
1495 pasteEffects->setData("paste_effects");
1496 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1498 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1499 collection.addAction("show_timeline", showTimeline);
1500 showTimeline->setCheckable(true);
1501 showTimeline->setChecked(true);
1502 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1504 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1505 collection.addAction("show_titlebars", showTitleBar);
1506 showTitleBar->setCheckable(true);
1507 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1508 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1509 slotShowTitleBars(KdenliveSettings::showtitlebars());
1512 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1514 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1515 collection.addAction("maximize_current", maxCurrent);
1516 maxCurrent->setCheckable(true);
1517 maxCurrent->setChecked(false);
1518 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1520 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1521 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1522 KStandardAction::open(this, SLOT(openFile()), collection);
1523 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1524 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1525 KStandardAction::openNew(this, SLOT(newFile()), collection);
1526 // TODO: make the following connection to slotEditKeys work
1527 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1528 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1529 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1530 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1531 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1532 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1534 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1535 undo->setEnabled(false);
1536 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1538 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1539 redo->setEnabled(false);
1540 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1543 //TODO: Add status tooltip to actions ?
1544 connect(collection, SIGNAL(actionHovered(QAction*)),
1545 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1548 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1549 collection.addAction("add_clip", addClip);
1550 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1552 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1553 collection.addAction("add_color_clip", addColorClip);
1554 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1556 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1557 collection.addAction("add_slide_clip", addSlideClip);
1558 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1560 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1561 collection.addAction("add_text_clip", addTitleClip);
1562 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1564 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1565 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1566 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1568 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1569 collection.addAction("add_folder", addFolderButton);
1570 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1572 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1573 collection.addAction("clip_properties", clipProperties);
1574 clipProperties->setData("clip_properties");
1575 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1576 clipProperties->setEnabled(false);
1578 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1579 collection.addAction("edit_clip", openClip);
1580 openClip->setData("edit_clip");
1581 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1582 openClip->setEnabled(false);
1584 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1585 collection.addAction("delete_clip", deleteClip);
1586 deleteClip->setData("delete_clip");
1587 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1588 deleteClip->setEnabled(false);
1590 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1591 collection.addAction("reload_clip", reloadClip);
1592 reloadClip->setData("reload_clip");
1593 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1594 reloadClip->setEnabled(false);
1596 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1597 collection.addAction("stopmotion", stopMotion);
1598 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1600 QMenu *addClips = new QMenu();
1601 addClips->addAction(addClip);
1602 addClips->addAction(addColorClip);
1603 addClips->addAction(addSlideClip);
1604 addClips->addAction(addTitleClip);
1605 addClips->addAction(addTitleTemplateClip);
1606 addClips->addAction(addFolderButton);
1608 addClips->addAction(reloadClip);
1609 addClips->addAction(clipProperties);
1610 addClips->addAction(openClip);
1611 addClips->addAction(deleteClip);
1612 m_projectList->setupMenu(addClips, addClip);
1614 // Setup effects and transitions actions.
1615 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1616 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1617 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1618 m_videoEffects = new KAction*[videoEffects.count()];
1619 for (int i = 0; i < videoEffects.count(); ++i) {
1620 QStringList effectInfo = videoEffects.effectIdInfo(i);
1621 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1622 m_videoEffects[i]->setData(effectInfo);
1623 m_videoEffects[i]->setIconVisibleInMenu(false);
1624 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1626 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1627 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1628 m_audioEffects = new KAction*[audioEffects.count()];
1629 for (int i = 0; i < audioEffects.count(); ++i) {
1630 QStringList effectInfo = audioEffects.effectIdInfo(i);
1631 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1632 m_audioEffects[i]->setData(effectInfo);
1633 m_audioEffects[i]->setIconVisibleInMenu(false);
1634 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1636 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1637 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1638 m_customEffects = new KAction*[customEffects.count()];
1639 for (int i = 0; i < customEffects.count(); ++i) {
1640 QStringList effectInfo = customEffects.effectIdInfo(i);
1641 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1642 m_customEffects[i]->setData(effectInfo);
1643 m_customEffects[i]->setIconVisibleInMenu(false);
1644 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1646 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1647 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1648 m_transitions = new KAction*[transitions.count()];
1649 for (int i = 0; i < transitions.count(); i++) {
1650 QStringList effectInfo = transitions.effectIdInfo(i);
1651 m_transitions[i] = new KAction(effectInfo.at(0), this);
1652 m_transitions[i]->setData(effectInfo);
1653 m_transitions[i]->setIconVisibleInMenu(false);
1654 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1656 m_effectsActionCollection->readSettings();
1658 //connect(collection, SIGNAL( clearStatusText() ),
1659 //statusBar(), SLOT( clear() ) );
1662 void MainWindow::slotDisplayActionMessage(QAction *a)
1664 statusBar()->showMessage(a->data().toString(), 3000);
1667 void MainWindow::loadLayouts()
1669 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1670 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1671 if (loadLayout == NULL || saveLayout == NULL) return;
1672 KSharedConfigPtr config = KGlobal::config();
1673 KConfigGroup layoutGroup(config, "Layouts");
1674 QStringList entries = layoutGroup.keyList();
1675 QList<QAction *> loadActions = loadLayout->actions();
1676 QList<QAction *> saveActions = saveLayout->actions();
1677 for (int i = 1; i < 5; i++) {
1678 // Rename the layouts actions
1679 foreach(const QString & key, entries) {
1680 if (key.endsWith(QString("_%1").arg(i))) {
1681 // Found previously saved layout
1682 QString layoutName = key.section("_", 0, -2);
1683 for (int j = 0; j < loadActions.count(); j++) {
1684 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1685 loadActions[j]->setText(layoutName);
1686 loadActions[j]->setData(key);
1690 for (int j = 0; j < saveActions.count(); j++) {
1691 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1692 saveActions[j]->setText(layoutName);
1693 saveActions[j]->setData(key);
1702 void MainWindow::slotLoadLayout(QAction *action)
1704 if (!action) return;
1705 QString layoutId = action->data().toString();
1706 if (layoutId.isEmpty()) return;
1707 KSharedConfigPtr config = KGlobal::config();
1708 KConfigGroup layouts(config, "Layouts");
1709 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1710 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1711 //restoreGeometry(geom);
1712 restoreState(state);
1715 void MainWindow::slotSaveLayout(QAction *action)
1717 QString originallayoutName = action->data().toString();
1718 int layoutId = originallayoutName.section('_', -1).toInt();
1720 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1721 if (layoutName.isEmpty()) return;
1722 KSharedConfigPtr config = KGlobal::config();
1723 KConfigGroup layouts(config, "Layouts");
1724 layouts.deleteEntry(originallayoutName);
1726 QByteArray st = saveState();
1727 layoutName.append("_" + QString::number(layoutId));
1728 layouts.writeEntry(layoutName, st.toBase64());
1732 void MainWindow::saveOptions()
1734 KdenliveSettings::self()->writeConfig();
1735 KSharedConfigPtr config = KGlobal::config();
1736 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1737 KConfigGroup treecolumns(config, "Project Tree");
1738 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1742 void MainWindow::readOptions()
1744 KSharedConfigPtr config = KGlobal::config();
1745 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1746 KConfigGroup initialGroup(config, "version");
1747 bool upgrade = false;
1748 if (initialGroup.exists()) {
1749 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1753 if (initialGroup.readEntry("version") == "0.7") {
1754 //Add new settings from 0.7.1
1755 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1756 QString path = QDir::homePath() + "/kdenlive";
1757 if (KStandardDirs::makeDir(path) == false) {
1758 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1759 } else KdenliveSettings::setDefaultprojectfolder(path);
1765 if (!initialGroup.exists() || upgrade) {
1766 // this is our first run, show Wizard
1767 Wizard *w = new Wizard(upgrade, this);
1768 if (w->exec() == QDialog::Accepted && w->isOk()) {
1769 w->adjustSettings();
1770 initialGroup.writeEntry("version", version);
1776 KConfigGroup treecolumns(config, "Project Tree");
1777 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1778 if (!state.isEmpty())
1779 m_projectList->setHeaderInfo(state);
1782 void MainWindow::slotRunWizard()
1784 Wizard *w = new Wizard(false, this);
1785 if (w->exec() == QDialog::Accepted && w->isOk()) {
1786 w->adjustSettings();
1791 void MainWindow::newFile(bool showProjectSettings, bool force)
1793 if (!m_timelineArea->isEnabled() && !force)
1795 m_fileRevert->setEnabled(false);
1796 QString profileName = KdenliveSettings::default_profile();
1797 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1798 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1799 if (!showProjectSettings) {
1800 if (!KdenliveSettings::activatetabs())
1801 if (!closeCurrentDocument())
1804 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1805 if (w->exec() != QDialog::Accepted)
1807 if (!KdenliveSettings::activatetabs())
1808 if (!closeCurrentDocument())
1810 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1811 slotSwitchVideoThumbs();
1812 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1813 slotSwitchAudioThumbs();
1814 profileName = w->selectedProfile();
1815 projectFolder = w->selectedFolder();
1816 projectTracks = w->tracks();
1819 m_timelineArea->setEnabled(true);
1820 m_projectList->setEnabled(true);
1821 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1822 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1824 TrackView *trackView = new TrackView(doc, &ok, this);
1825 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1828 //m_timelineArea->setEnabled(false);
1829 //m_projectList->setEnabled(false);
1833 if (m_timelineArea->count() == 1) {
1834 connectDocumentInfo(doc);
1835 connectDocument(trackView, doc);
1837 m_timelineArea->setTabBarHidden(false);
1838 m_monitorManager->activateMonitor("clip");
1839 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1842 void MainWindow::activateDocument()
1844 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1845 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1846 KdenliveDoc *currentDoc = currentTab->document();
1847 connectDocumentInfo(currentDoc);
1848 connectDocument(currentTab, currentDoc);
1851 bool MainWindow::closeCurrentDocument(bool saveChanges)
1853 QWidget *w = m_timelineArea->currentWidget();
1854 if (!w) return true;
1855 // closing current document
1856 int ix = m_timelineArea->currentIndex() + 1;
1857 if (ix == m_timelineArea->count()) ix = 0;
1858 m_timelineArea->setCurrentIndex(ix);
1859 TrackView *tabToClose = (TrackView *) w;
1860 KdenliveDoc *docToClose = tabToClose->document();
1861 if (docToClose && docToClose->isModified() && saveChanges) {
1863 if (m_activeDocument->url().fileName().isEmpty())
1864 message = i18n("Save changes to document?");
1866 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1867 switch (KMessageBox::warningYesNoCancel(this, message)) {
1868 case KMessageBox::Yes :
1869 // save document here. If saving fails, return false;
1870 if (saveFile() == false) return false;
1872 case KMessageBox::Cancel :
1879 m_clipMonitor->slotSetXml(NULL);
1880 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1881 if (m_timelineArea->count() == 1) {
1882 m_timelineArea->setTabBarHidden(true);
1883 m_closeAction->setEnabled(false);
1885 if (docToClose == m_activeDocument) {
1886 delete m_activeDocument;
1887 m_activeDocument = NULL;
1888 m_effectStack->clear();
1889 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1893 if (w == m_activeTimeline) {
1894 delete m_activeTimeline;
1895 m_activeTimeline = NULL;
1902 bool MainWindow::saveFileAs(const QString &outputFileName)
1904 QString currentSceneList;
1905 m_monitorManager->stopActiveMonitor();
1907 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
1910 // Save timeline thumbnails
1911 m_activeTimeline->projectView()->saveThumbnails();
1912 m_activeDocument->setUrl(KUrl(outputFileName));
1913 if (m_activeDocument->m_autosave == NULL) {
1914 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1915 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1916 setCaption(m_activeDocument->description());
1917 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1918 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1919 m_activeDocument->setModified(false);
1920 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1921 m_fileRevert->setEnabled(true);
1925 bool MainWindow::saveFileAs()
1927 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1928 if (outputFile.isEmpty()) {
1931 if (QFile::exists(outputFile)) {
1932 // Show the file dialog again if the user does not want to overwrite the file
1933 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1934 return saveFileAs();
1936 return saveFileAs(outputFile);
1939 bool MainWindow::saveFile()
1941 if (!m_activeDocument) return true;
1942 if (m_activeDocument->url().isEmpty()) {
1943 return saveFileAs();
1945 bool result = saveFileAs(m_activeDocument->url().path());
1946 m_activeDocument->m_autosave->resize(0);
1951 void MainWindow::openFile()
1953 if (!m_startUrl.isEmpty()) {
1954 openFile(m_startUrl);
1955 m_startUrl = KUrl();
1958 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1959 if (url.isEmpty()) return;
1960 m_fileOpenRecent->addUrl(url);
1964 void MainWindow::openLastFile()
1966 KSharedConfigPtr config = KGlobal::config();
1967 KUrl::List urls = m_fileOpenRecent->urls();
1968 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1969 if (urls.isEmpty()) newFile(false);
1970 else openFile(urls.last());
1973 void MainWindow::openFile(const KUrl &url)
1975 // Check if the document is already opened
1976 const int ct = m_timelineArea->count();
1977 bool isOpened = false;
1979 for (i = 0; i < ct; i++) {
1980 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1981 KdenliveDoc *doc = tab->document();
1982 if (doc->url() == url) {
1988 m_timelineArea->setCurrentIndex(i);
1992 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1994 // Check for backup file
1995 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1996 if (!staleFiles.isEmpty()) {
1997 if (KMessageBox::questionYesNo(this,
1998 i18n("Auto-saved files exist. Do you want to recover them now?"),
1999 i18n("File Recovery"),
2000 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2001 recoverFiles(staleFiles);
2004 // remove the stale files
2005 foreach(KAutoSaveFile * stale, staleFiles) {
2006 stale->open(QIODevice::ReadWrite);
2011 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2012 m_messageLabel->repaint();
2013 doOpenFile(url, NULL);
2016 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2018 if (!m_timelineArea->isEnabled()) return;
2019 m_fileRevert->setEnabled(true);
2021 // Recreate stopmotion widget on document change
2023 delete m_stopmotion;
2024 m_stopmotion = NULL;
2027 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2028 progressDialog.setAllowCancel(false);
2029 progressDialog.progressBar()->setMaximum(4);
2030 progressDialog.show();
2031 progressDialog.progressBar()->setValue(0);
2032 qApp->processEvents();
2034 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2036 progressDialog.progressBar()->setValue(1);
2037 progressDialog.progressBar()->setMaximum(4);
2038 progressDialog.setLabelText(i18n("Loading project"));
2039 qApp->processEvents();
2041 if (stale == NULL) {
2042 stale = new KAutoSaveFile(url, doc);
2043 doc->m_autosave = stale;
2045 doc->m_autosave = stale;
2046 doc->setUrl(stale->managedFile());
2047 doc->setModified(true);
2048 stale->setParent(doc);
2050 connectDocumentInfo(doc);
2052 progressDialog.progressBar()->setValue(2);
2053 qApp->processEvents();
2056 TrackView *trackView = new TrackView(doc, &ok, this);
2058 progressDialog.progressBar()->setValue(3);
2059 qApp->processEvents();
2061 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2063 m_timelineArea->setEnabled(false);
2064 m_projectList->setEnabled(false);
2065 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2066 slotGotProgressInfo(QString(), -1);
2067 newFile(false, true);
2070 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2071 trackView->setDuration(trackView->duration());
2072 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2074 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2075 slotGotProgressInfo(QString(), -1);
2076 m_projectMonitor->adjustRulerSize(trackView->duration());
2077 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2078 m_clipMonitor->refreshMonitor(true);
2080 progressDialog.progressBar()->setValue(4);
2083 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2085 foreach(KAutoSaveFile * stale, staleFiles) {
2086 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2087 // show an error message; we could not steal the lockfile
2088 // maybe another application got to the file before us?
2092 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2093 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2094 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2095 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2099 void MainWindow::parseProfiles(const QString &mltPath)
2101 //KdenliveSettings::setDefaulttmpfolder();
2102 if (!mltPath.isEmpty()) {
2103 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2104 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2107 if (KdenliveSettings::mltpath().isEmpty())
2108 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2110 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2111 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2112 if (!QFile::exists(meltPath))
2113 meltPath = KStandardDirs::findExe("melt");
2114 KdenliveSettings::setRendererpath(meltPath);
2117 if (KdenliveSettings::rendererpath().isEmpty()) {
2118 // Cannot find the MLT melt renderer, ask for location
2119 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2120 if (getUrl->exec() == QDialog::Rejected) {
2123 KUrl rendererPath = getUrl->selectedUrl();
2125 if (rendererPath.isEmpty()) ::exit(0);
2126 KdenliveSettings::setRendererpath(rendererPath.path());
2129 QStringList profilesFilter;
2130 profilesFilter << "*";
2131 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2132 if (profilesList.isEmpty()) {
2133 // Cannot find MLT path, try finding melt
2134 QString profilePath = KdenliveSettings::rendererpath();
2135 if (!profilePath.isEmpty()) {
2136 profilePath = profilePath.section('/', 0, -3);
2137 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2138 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2140 if (profilesList.isEmpty()) {
2141 // Cannot find the MLT profiles, ask for location
2142 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2143 getUrl->fileDialog()->setMode(KFile::Directory);
2144 if (getUrl->exec() == QDialog::Rejected) {
2147 KUrl mltPath = getUrl->selectedUrl();
2149 if (mltPath.isEmpty()) ::exit(0);
2150 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2151 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2155 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2157 // Parse again MLT profiles to build a list of available video formats
2158 if (profilesList.isEmpty()) parseProfiles();
2162 void MainWindow::slotEditProfiles()
2164 ProfilesDialog *w = new ProfilesDialog;
2165 if (w->exec() == QDialog::Accepted) {
2166 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2167 if (d) d->checkProfile();
2172 void MainWindow::slotDetectAudioDriver()
2174 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2175 leading to no audio output, see bug #934 */
2177 //decide which audio driver is really best, in some cases SDL is wrong
2178 if (KdenliveSettings::audiodrivername().isEmpty()) {
2180 KProcess readProcess;
2181 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2182 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2183 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2184 readProcess.setProgram("pactl", QStringList() << "stat");
2185 readProcess.execute(2000); // Kill it after 2 seconds
2187 QString result = QString(readProcess.readAllStandardOutput());
2188 kDebug() << "// / / / / / READING PACTL: ";
2190 if (!result.isEmpty()) {
2192 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2196 KdenliveSettings::setAutoaudiodrivername(driver);
2200 void MainWindow::slotEditProjectSettings()
2202 QPoint p = m_activeDocument->getTracksCount();
2203 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2205 if (w->exec() == QDialog::Accepted) {
2206 QString profile = w->selectedProfile();
2207 m_activeDocument->setProjectFolder(w->selectedFolder());
2209 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2211 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2212 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2213 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2214 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2219 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2221 double dar = m_activeDocument->dar();
2223 // Recreate the stopmotion widget if profile changes
2225 delete m_stopmotion;
2226 m_stopmotion = NULL;
2229 // Deselect current effect / transition
2230 m_effectStack->slotClipItemSelected(NULL, 0);
2231 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2232 m_clipMonitor->slotSetXml(NULL);
2233 bool updateFps = m_activeDocument->setProfilePath(profile);
2234 KdenliveSettings::setCurrent_profile(profile);
2235 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2236 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2238 m_activeDocument->clipManager()->clearUnusedProducers();
2239 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2240 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2241 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2242 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2243 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2244 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2245 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2246 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2247 if (updateFps) m_activeTimeline->updateProjectFps();
2248 m_activeDocument->setModified(true);
2249 m_commandStack->activeStack()->clear();
2250 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2251 slotUpdateMousePosition(0);
2252 // We need to desactivate & reactivate monitors to get a refresh
2253 //m_monitorManager->switchMonitors();
2257 void MainWindow::slotRenderProject()
2259 if (!m_renderWidget) {
2260 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2261 m_renderWidget = new RenderWidget(projectfolder, this);
2262 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2263 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2264 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2265 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2266 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2267 if (m_activeDocument) {
2268 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2269 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2270 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2271 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2274 slotCheckRenderStatus();
2275 m_renderWidget->show();
2276 m_renderWidget->showNormal();
2278 // What are the following lines supposed to do?
2279 //m_activeTimeline->tracksNumber();
2280 //m_renderWidget->enableAudio(false);
2281 //m_renderWidget->export_audio;
2284 void MainWindow::slotCheckRenderStatus()
2286 // Make sure there are no missing clips
2288 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2291 void MainWindow::setRenderingProgress(const QString &url, int progress)
2294 m_renderWidget->setRenderJob(url, progress);
2297 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2300 m_renderWidget->setRenderStatus(url, status, error);
2303 void MainWindow::slotCleanProject()
2305 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2306 m_projectList->cleanup();
2309 void MainWindow::slotUpdateMousePosition(int pos)
2311 if (m_activeDocument)
2312 switch (m_timecodeFormat->currentIndex()) {
2314 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2317 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2321 void MainWindow::slotUpdateDocumentState(bool modified)
2323 if (!m_activeDocument) return;
2324 setCaption(m_activeDocument->description(), modified);
2325 m_saveAction->setEnabled(modified);
2327 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2328 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2330 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2331 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2335 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2337 if (m_activeDocument) {
2338 if (m_activeDocument == doc) return;
2339 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2341 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2344 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2346 //m_projectMonitor->stop();
2347 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2348 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2349 if (m_activeDocument) {
2350 if (m_activeDocument == doc) return;
2351 if (m_activeTimeline) {
2352 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2353 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2354 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2355 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2356 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2357 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2358 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2359 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2361 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2363 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2364 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2365 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2366 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2367 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2368 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2369 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2370 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2371 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2372 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2373 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2374 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2375 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2376 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2377 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2378 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2379 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2380 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2381 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2382 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2383 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2384 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2385 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2386 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2387 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2388 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2389 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2390 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2391 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2392 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2393 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2394 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2395 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2396 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2397 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2398 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2399 m_effectStack->clear();
2401 //m_activeDocument->setRenderer(NULL);
2402 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2403 disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2404 m_clipMonitor->stop();
2406 KdenliveSettings::setCurrent_profile(doc->profilePath());
2407 KdenliveSettings::setProject_fps(doc->fps());
2408 m_monitorManager->resetProfiles(doc->timecode());
2409 m_projectList->setDocument(doc);
2410 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2411 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2412 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2413 connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2414 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2416 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2417 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2418 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2420 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2423 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2424 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2425 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2426 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2427 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2428 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2429 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2430 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2431 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2432 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2433 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2434 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2435 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2436 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2438 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2439 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2440 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2441 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2442 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2444 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2445 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2446 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2447 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2449 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2450 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2451 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2452 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2454 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2455 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2456 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2457 m_zoomSlider->setValue(doc->zoom().x());
2458 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2459 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2460 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2461 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2463 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2464 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2466 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2467 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2469 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2470 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2471 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2472 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2473 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2474 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2475 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2476 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2477 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2478 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2479 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2481 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2482 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2483 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2484 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2485 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2488 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2489 m_activeTimeline = trackView;
2490 if (m_renderWidget) {
2491 slotCheckRenderStatus();
2492 m_renderWidget->setProfile(doc->mltProfile());
2493 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2494 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2495 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2497 //doc->setRenderer(m_projectMonitor->render);
2498 m_commandStack->setActiveStack(doc->commandStack());
2499 KdenliveSettings::setProject_display_ratio(doc->dar());
2500 //doc->clipManager()->checkAudioThumbs();
2502 //m_overView->setScene(trackView->projectScene());
2503 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2504 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2506 setCaption(doc->description(), doc->isModified());
2507 m_saveAction->setEnabled(doc->isModified());
2508 m_normalEditTool->setChecked(true);
2509 m_activeDocument = doc;
2510 m_activeTimeline->updateProjectFps();
2511 m_activeDocument->checkProjectClips();
2513 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2515 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2516 slotUpdateMousePosition(0);
2517 // set tool to select tool
2518 m_buttonSelectTool->setChecked(true);
2521 void MainWindow::slotZoneMoved(int start, int end)
2523 m_activeDocument->setZone(start, end);
2524 m_projectMonitor->slotZoneMoved(start, end);
2527 void MainWindow::slotGuidesUpdated()
2530 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2533 void MainWindow::slotEditKeys()
2535 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2536 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2537 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2541 void MainWindow::slotPreferences(int page, int option)
2544 * An instance of your dialog could be already created and could be
2545 * cached, in which case you want to display the cached dialog
2546 * instead of creating another one
2548 if (m_stopmotion) m_stopmotion->slotLive(false);
2549 if (KConfigDialog::showDialog("settings")) {
2550 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2551 if (page != -1) d->showPage(page, option);
2555 // KConfigDialog didn't find an instance of this dialog, so lets
2558 // Get the mappable actions in localized form
2559 QMap<QString, QString> actions;
2560 KActionCollection* collection = actionCollection();
2561 foreach (const QString& action_name, m_action_names) {
2562 actions[collection->action(action_name)->text()] = action_name;
2565 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2566 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2567 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2568 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2570 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2573 if (page != -1) dialog->showPage(page, option);
2576 void MainWindow::slotUpdateCaptureFolder()
2580 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2581 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2585 void MainWindow::updateConfiguration()
2587 //TODO: we should apply settings to all projects, not only the current one
2588 if (m_activeTimeline) {
2589 m_activeTimeline->refresh();
2590 m_activeTimeline->projectView()->checkAutoScroll();
2591 m_activeTimeline->projectView()->checkTrackHeight();
2592 if (m_activeDocument)
2593 m_activeDocument->clipManager()->checkAudioThumbs();
2595 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2596 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2597 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2598 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2600 // Update list of transcoding profiles
2602 #ifndef NO_JOGSHUTTLE
2603 activateShuttleDevice();
2604 #endif /* NO_JOGSHUTTLE */
2608 void MainWindow::slotSwitchSplitAudio()
2610 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2611 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2614 void MainWindow::slotSwitchVideoThumbs()
2616 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2617 if (m_activeTimeline)
2618 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2619 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2622 void MainWindow::slotSwitchAudioThumbs()
2624 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2625 if (m_activeTimeline) {
2626 m_activeTimeline->refresh();
2627 m_activeTimeline->projectView()->checkAutoScroll();
2628 if (m_activeDocument)
2629 m_activeDocument->clipManager()->checkAudioThumbs();
2631 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2634 void MainWindow::slotSwitchMarkersComments()
2636 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2637 if (m_activeTimeline)
2638 m_activeTimeline->refresh();
2639 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2642 void MainWindow::slotSwitchSnap()
2644 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2645 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2649 void MainWindow::slotDeleteItem()
2651 if (QApplication::focusWidget() &&
2652 QApplication::focusWidget()->parentWidget() &&
2653 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2654 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2655 m_projectList->slotRemoveClip();
2658 QWidget *widget = QApplication::focusWidget();
2660 if (widget == m_effectStackDock) {
2661 m_effectStack->slotItemDel();
2664 widget = widget->parentWidget();
2667 // effect stack has no focus
2668 if (m_activeTimeline)
2669 m_activeTimeline->projectView()->deleteSelectedClips();
2673 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2675 if (m_clipMonitor->isActive())
2676 m_clipMonitor->checkOverlay();
2677 m_clipMonitor->updateMarkers(clip);
2680 void MainWindow::slotAddClipMarker()
2682 DocClipBase *clip = NULL;
2684 if (m_projectMonitor->isActive()) {
2685 if (m_activeTimeline) {
2686 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2688 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2689 clip = item->baseClip();
2693 clip = m_clipMonitor->activeClip();
2694 pos = m_clipMonitor->position();
2697 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2700 QString id = clip->getId();
2701 CommentedTime marker(pos, i18n("Marker"));
2702 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2703 if (d.exec() == QDialog::Accepted)
2704 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2707 void MainWindow::slotDeleteClipMarker()
2709 DocClipBase *clip = NULL;
2711 if (m_projectMonitor->isActive()) {
2712 if (m_activeTimeline) {
2713 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2715 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2716 clip = item->baseClip();
2720 clip = m_clipMonitor->activeClip();
2721 pos = m_clipMonitor->position();
2724 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2728 QString id = clip->getId();
2729 QString comment = clip->markerComment(pos);
2730 if (comment.isEmpty()) {
2731 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2734 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2737 void MainWindow::slotDeleteAllClipMarkers()
2739 DocClipBase *clip = NULL;
2740 if (m_projectMonitor->isActive()) {
2741 if (m_activeTimeline) {
2742 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2744 clip = item->baseClip();
2748 clip = m_clipMonitor->activeClip();
2751 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2754 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2757 void MainWindow::slotEditClipMarker()
2759 DocClipBase *clip = NULL;
2761 if (m_projectMonitor->isActive()) {
2762 if (m_activeTimeline) {
2763 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2765 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2766 clip = item->baseClip();
2770 clip = m_clipMonitor->activeClip();
2771 pos = m_clipMonitor->position();
2774 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2778 QString id = clip->getId();
2779 QString oldcomment = clip->markerComment(pos);
2780 if (oldcomment.isEmpty()) {
2781 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2785 CommentedTime marker(pos, oldcomment);
2786 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2787 if (d.exec() == QDialog::Accepted) {
2788 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2789 if (d.newMarker().time() != pos) {
2790 // remove old marker
2791 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2796 void MainWindow::slotAddMarkerGuideQuickly()
2798 if (!m_activeTimeline || !m_activeDocument)
2801 if (m_clipMonitor->isActive()) {
2802 DocClipBase *clip = m_clipMonitor->activeClip();
2803 GenTime pos = m_clipMonitor->position();
2806 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2810 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2812 m_activeTimeline->projectView()->slotAddGuide(false);
2816 void MainWindow::slotAddGuide()
2818 if (m_activeTimeline)
2819 m_activeTimeline->projectView()->slotAddGuide();
2822 void MainWindow::slotInsertSpace()
2824 if (m_activeTimeline)
2825 m_activeTimeline->projectView()->slotInsertSpace();
2828 void MainWindow::slotRemoveSpace()
2830 if (m_activeTimeline)
2831 m_activeTimeline->projectView()->slotRemoveSpace();
2834 void MainWindow::slotInsertTrack(int ix)
2836 m_projectMonitor->activateMonitor();
2837 if (m_activeTimeline)
2838 m_activeTimeline->projectView()->slotInsertTrack(ix);
2839 if (m_activeDocument)
2840 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2843 void MainWindow::slotDeleteTrack(int ix)
2845 m_projectMonitor->activateMonitor();
2846 if (m_activeTimeline)
2847 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2848 if (m_activeDocument)
2849 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2852 void MainWindow::slotConfigTrack(int ix)
2854 m_projectMonitor->activateMonitor();
2855 if (m_activeTimeline)
2856 m_activeTimeline->projectView()->slotConfigTracks(ix);
2857 if (m_activeDocument)
2858 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2861 void MainWindow::slotEditGuide()
2863 if (m_activeTimeline)
2864 m_activeTimeline->projectView()->slotEditGuide();
2867 void MainWindow::slotDeleteGuide()
2869 if (m_activeTimeline)
2870 m_activeTimeline->projectView()->slotDeleteGuide();
2873 void MainWindow::slotDeleteAllGuides()
2875 if (m_activeTimeline)
2876 m_activeTimeline->projectView()->slotDeleteAllGuides();
2879 void MainWindow::slotCutTimelineClip()
2881 if (m_activeTimeline)
2882 m_activeTimeline->projectView()->cutSelectedClips();
2885 void MainWindow::slotInsertClipOverwrite()
2887 if (m_activeTimeline) {
2888 QStringList data = m_clipMonitor->getZoneInfo();
2889 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2893 void MainWindow::slotSelectTimelineClip()
2895 if (m_activeTimeline)
2896 m_activeTimeline->projectView()->selectClip(true);
2899 void MainWindow::slotSelectTimelineTransition()
2901 if (m_activeTimeline)
2902 m_activeTimeline->projectView()->selectTransition(true);
2905 void MainWindow::slotDeselectTimelineClip()
2907 if (m_activeTimeline)
2908 m_activeTimeline->projectView()->selectClip(false, true);
2911 void MainWindow::slotDeselectTimelineTransition()
2913 if (m_activeTimeline)
2914 m_activeTimeline->projectView()->selectTransition(false, true);
2917 void MainWindow::slotSelectAddTimelineClip()
2919 if (m_activeTimeline)
2920 m_activeTimeline->projectView()->selectClip(true, true);
2923 void MainWindow::slotSelectAddTimelineTransition()
2925 if (m_activeTimeline)
2926 m_activeTimeline->projectView()->selectTransition(true, true);
2929 void MainWindow::slotGroupClips()
2931 if (m_activeTimeline)
2932 m_activeTimeline->projectView()->groupClips();
2935 void MainWindow::slotUnGroupClips()
2937 if (m_activeTimeline)
2938 m_activeTimeline->projectView()->groupClips(false);
2941 void MainWindow::slotEditItemDuration()
2943 if (m_activeTimeline)
2944 m_activeTimeline->projectView()->editItemDuration();
2947 void MainWindow::slotAddProjectClip(KUrl url)
2949 if (m_activeDocument)
2950 m_activeDocument->slotAddClipFile(url, QString());
2953 void MainWindow::slotAddTransition(QAction *result)
2955 if (!result) return;
2956 QStringList info = result->data().toStringList();
2957 if (info.isEmpty()) return;
2958 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2959 if (m_activeTimeline && !transition.isNull()) {
2960 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2964 void MainWindow::slotAddVideoEffect(QAction *result)
2966 if (!result) return;
2967 QStringList info = result->data().toStringList();
2968 if (info.isEmpty()) return;
2969 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2970 slotAddEffect(effect);
2973 void MainWindow::slotAddAudioEffect(QAction *result)
2975 if (!result) return;
2976 QStringList info = result->data().toStringList();
2977 if (info.isEmpty()) return;
2978 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2979 slotAddEffect(effect);
2982 void MainWindow::slotAddCustomEffect(QAction *result)
2984 if (!result) return;
2985 QStringList info = result->data().toStringList();
2986 if (info.isEmpty()) return;
2987 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2988 slotAddEffect(effect);
2991 void MainWindow::slotZoomIn()
2993 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2994 slotShowZoomSliderToolTip();
2997 void MainWindow::slotZoomOut()
2999 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3000 slotShowZoomSliderToolTip();
3003 void MainWindow::slotFitZoom()
3005 if (m_activeTimeline)
3006 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3009 void MainWindow::slotSetZoom(int value)
3011 value = qMax(m_zoomSlider->minimum(), value);
3012 value = qMin(m_zoomSlider->maximum(), value);
3014 if (m_activeTimeline)
3015 m_activeTimeline->slotChangeZoom(value);
3017 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3018 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3019 slotUpdateZoomSliderToolTip(value);
3021 m_zoomSlider->blockSignals(true);
3022 m_zoomSlider->setValue(value);
3023 m_zoomSlider->blockSignals(false);
3026 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3028 if (zoomlevel != -1)
3029 slotUpdateZoomSliderToolTip(zoomlevel);
3031 QPoint global = m_zoomSlider->rect().topLeft();
3032 global.ry() += m_zoomSlider->height() / 2;
3033 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3034 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3037 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3039 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3042 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3044 m_statusProgressBar->setValue(progress);
3045 if (progress >= 0) {
3046 if (!message.isEmpty())
3047 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3048 m_statusProgressBar->setVisible(true);
3049 } else if (progress == -2) {
3050 if (!message.isEmpty())
3051 m_messageLabel->setMessage(message, ErrorMessage);
3052 m_statusProgressBar->setVisible(false);
3054 m_messageLabel->setMessage(QString(), DefaultMessage);
3055 m_statusProgressBar->setVisible(false);
3059 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3061 if (clip->clipType() == TEXT) {
3062 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3063 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3064 // template text clip
3066 // Get the list of existing templates
3068 filter << "*.kdenlivetitle";
3069 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3071 QDialog *dia = new QDialog(this);
3072 Ui::TemplateClip_UI dia_ui;
3073 dia_ui.setupUi(dia);
3075 const QString templatePath = clip->getProperty("resource");
3076 for (int i = 0; i < templateFiles.size(); ++i) {
3077 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3078 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3080 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3081 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3082 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3083 //warning: setting base directory doesn't work??
3084 KUrl startDir(titlepath);
3085 dia_ui.template_list->fileDialog()->setUrl(startDir);
3086 dia_ui.description->setText(clip->getProperty("description"));
3087 if (dia->exec() == QDialog::Accepted) {
3088 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3089 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3091 QMap <QString, QString> newprops;
3093 if (KUrl(textTemplate).path() != templatePath) {
3094 // The template was changed
3095 newprops.insert("resource", textTemplate);
3098 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3099 newprops.insert("description", dia_ui.description->toPlainText());
3102 QString newtemplate = newprops.value("xmltemplate");
3103 if (newtemplate.isEmpty()) newtemplate = templatePath;
3105 // template modified we need to update xmldata
3106 QString description = newprops.value("description");
3107 if (description.isEmpty()) description = clip->getProperty("description");
3108 else newprops.insert("templatetext", description);
3109 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3110 if (!newprops.isEmpty()) {
3111 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3112 m_activeDocument->commandStack()->push(command);
3118 QString path = clip->getProperty("resource");
3119 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3121 doc.setContent(clip->getProperty("xmldata"));
3122 dia_ui->setXml(doc);
3123 if (dia_ui->exec() == QDialog::Accepted) {
3124 QMap <QString, QString> newprops;
3125 newprops.insert("xmldata", dia_ui->xml().toString());
3126 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3127 // duration changed, we need to update duration
3128 newprops.insert("out", QString::number(dia_ui->outPoint()));
3130 if (!path.isEmpty()) {
3131 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3132 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) {
3133 // save to external file
3134 dia_ui->saveTitle(path);
3135 } else newprops.insert("resource", QString());
3137 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3138 m_activeDocument->commandStack()->push(command);
3139 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3140 m_activeDocument->setModified(true);
3144 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3148 // any type of clip but a title
3149 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3150 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3151 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)));
3156 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3158 if (newprops.isEmpty()) return;
3159 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3160 m_activeDocument->commandStack()->push(command);
3161 m_activeDocument->setModified();
3164 // update clip occurences in timeline
3165 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3170 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3172 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3173 if (dia.exec() == QDialog::Accepted) {
3174 QUndoCommand *command = new QUndoCommand();
3175 command->setText(i18n("Edit clips"));
3176 for (int i = 0; i < cliplist.count(); i++) {
3177 DocClipBase *clip = cliplist.at(i);
3178 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3180 m_activeDocument->commandStack()->push(command);
3181 for (int i = 0; i < cliplist.count(); i++)
3182 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3186 void MainWindow::customEvent(QEvent* e)
3188 if (e->type() == QEvent::User)
3189 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3191 void MainWindow::slotActivateEffectStackView()
3193 m_effectStack->raiseWindow(m_effectStackDock);
3196 void MainWindow::slotActivateTransitionView(Transition *t)
3199 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3202 void MainWindow::slotSnapRewind()
3204 if (m_projectMonitor->isActive()) {
3205 if (m_activeTimeline)
3206 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3208 m_clipMonitor->slotSeekToPreviousSnap();
3212 void MainWindow::slotSnapForward()
3214 if (m_projectMonitor->isActive()) {
3215 if (m_activeTimeline)
3216 m_activeTimeline->projectView()->slotSeekToNextSnap();
3218 m_clipMonitor->slotSeekToNextSnap();
3222 void MainWindow::slotClipStart()
3224 if (m_projectMonitor->isActive()) {
3225 if (m_activeTimeline)
3226 m_activeTimeline->projectView()->clipStart();
3230 void MainWindow::slotClipEnd()
3232 if (m_projectMonitor->isActive()) {
3233 if (m_activeTimeline)
3234 m_activeTimeline->projectView()->clipEnd();
3238 void MainWindow::slotZoneStart()
3240 if (m_projectMonitor->isActive())
3241 m_projectMonitor->slotZoneStart();
3243 m_clipMonitor->slotZoneStart();
3246 void MainWindow::slotZoneEnd()
3248 if (m_projectMonitor->isActive())
3249 m_projectMonitor->slotZoneEnd();
3251 m_clipMonitor->slotZoneEnd();
3254 void MainWindow::slotChangeTool(QAction * action)
3256 if (action == m_buttonSelectTool)
3257 slotSetTool(SELECTTOOL);
3258 else if (action == m_buttonRazorTool)
3259 slotSetTool(RAZORTOOL);
3260 else if (action == m_buttonSpacerTool)
3261 slotSetTool(SPACERTOOL);
3264 void MainWindow::slotChangeEdit(QAction * action)
3266 if (!m_activeTimeline)
3269 if (action == m_overwriteEditTool)
3270 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3271 else if (action == m_insertEditTool)
3272 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3274 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3277 void MainWindow::slotSetTool(PROJECTTOOL tool)
3279 if (m_activeDocument && m_activeTimeline) {
3280 //m_activeDocument->setTool(tool);
3284 message = i18n("Ctrl + click to use spacer on current track only");
3287 message = i18n("Click on a clip to cut it");
3290 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3293 m_messageLabel->setMessage(message, InformationMessage);
3294 m_activeTimeline->projectView()->setTool(tool);
3298 void MainWindow::slotCopy()
3300 if (m_activeDocument && m_activeTimeline)
3301 m_activeTimeline->projectView()->copyClip();
3304 void MainWindow::slotPaste()
3306 if (m_activeDocument && m_activeTimeline)
3307 m_activeTimeline->projectView()->pasteClip();
3310 void MainWindow::slotPasteEffects()
3312 if (m_activeDocument && m_activeTimeline)
3313 m_activeTimeline->projectView()->pasteClipEffects();
3316 void MainWindow::slotFind()
3318 if (!m_activeDocument || !m_activeTimeline) return;
3319 m_projectSearch->setEnabled(false);
3320 m_findActivated = true;
3321 m_findString.clear();
3322 m_activeTimeline->projectView()->initSearchStrings();
3323 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3324 m_findTimer.start(5000);
3325 qApp->installEventFilter(this);
3328 void MainWindow::slotFindNext()
3330 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3331 statusBar()->showMessage(i18n("Found: %1", m_findString));
3333 statusBar()->showMessage(i18n("Reached end of project"));
3334 m_findTimer.start(4000);
3337 void MainWindow::findAhead()
3339 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3340 m_projectSearchNext->setEnabled(true);
3341 statusBar()->showMessage(i18n("Found: %1", m_findString));
3343 m_projectSearchNext->setEnabled(false);
3344 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3348 void MainWindow::findTimeout()
3350 m_projectSearchNext->setEnabled(false);
3351 m_findActivated = false;
3352 m_findString.clear();
3353 statusBar()->showMessage(i18n("Find stopped"), 3000);
3354 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3355 m_projectSearch->setEnabled(true);
3356 removeEventFilter(this);
3359 void MainWindow::slotClipInTimeline(const QString &clipId)
3361 if (m_activeTimeline && m_activeDocument) {
3362 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3364 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3365 inTimelineMenu->clear();
3367 QList <QAction *> actionList;
3369 for (int i = 0; i < matching.count(); ++i) {
3370 QString track = QString::number(matching.at(i).track);
3371 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3373 QAction *a = new QAction(track + ": " + start, this);
3374 a->setData(QStringList() << track << start);
3375 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3376 while (j < actionList.count()) {
3377 if (actionList.at(j)->text() > a->text()) break;
3380 actionList.insert(j, a);
3382 inTimelineMenu->addActions(actionList);
3384 if (matching.empty())
3385 inTimelineMenu->setEnabled(false);
3387 inTimelineMenu->setEnabled(true);
3391 void MainWindow::slotClipInProjectTree()
3393 if (m_activeTimeline) {
3394 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3395 if (clipIds.isEmpty())
3397 m_projectListDock->raise();
3398 for (int i = 0; i < clipIds.count(); i++)
3399 m_projectList->selectItemById(clipIds.at(i));
3400 if (m_projectMonitor->isActive())
3401 slotSwitchMonitors();
3405 /*void MainWindow::slotClipToProjectTree()
3407 if (m_activeTimeline) {
3408 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3409 if (clips.isEmpty()) return;
3410 for (int i = 0; i < clips.count(); i++) {
3411 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3413 //m_projectList->selectItemById(clipIds.at(i));
3417 void MainWindow::slotSelectClipInTimeline()
3419 if (m_activeTimeline) {
3420 QAction *action = qobject_cast<QAction *>(sender());
3421 QStringList data = action->data().toStringList();
3422 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3426 void MainWindow::keyPressEvent(QKeyEvent *ke)
3428 if (m_findActivated) {
3429 if (ke->key() == Qt::Key_Backspace) {
3430 m_findString = m_findString.left(m_findString.length() - 1);
3432 if (!m_findString.isEmpty())
3437 m_findTimer.start(4000);
3440 } else if (ke->key() == Qt::Key_Escape) {
3444 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3445 m_findString += ke->text();
3449 m_findTimer.start(4000);
3454 KXmlGuiWindow::keyPressEvent(ke);
3459 /** Gets called when the window gets hidden */
3460 void MainWindow::hideEvent(QHideEvent */*event*/)
3462 if (isMinimized() && m_monitorManager)
3463 m_monitorManager->stopActiveMonitor();
3466 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3468 if (m_findActivated) {
3469 if (event->type() == QEvent::ShortcutOverride) {
3470 QKeyEvent* ke = (QKeyEvent*) event;
3471 if (ke->text().trimmed().isEmpty()) return false;
3478 // pass the event on to the parent class
3479 return QMainWindow::eventFilter(obj, event);
3484 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3486 KDialog *dialog = new KDialog(this);
3487 dialog->setCaption("Save clip zone");
3488 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3490 QWidget *widget = new QWidget(dialog);
3491 dialog->setMainWidget(widget);
3493 QVBoxLayout *vbox = new QVBoxLayout(widget);
3494 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3495 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3496 path.append("untitled.mlt");
3497 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3498 url->setFilter("video/mlt-playlist");
3499 QLabel *label2 = new QLabel(i18n("Description:"), this);
3500 KLineEdit *edit = new KLineEdit(this);
3501 vbox->addWidget(label1);
3502 vbox->addWidget(url);
3503 vbox->addWidget(label2);
3504 vbox->addWidget(edit);
3505 if (dialog->exec() == QDialog::Accepted)
3506 render->saveZone(url->url(), edit->text(), zone);
3510 void MainWindow::slotSetInPoint()
3512 if (m_clipMonitor->isActive())
3513 m_clipMonitor->slotSetZoneStart();
3515 m_projectMonitor->slotSetZoneStart();
3516 //else m_activeTimeline->projectView()->setInPoint();
3519 void MainWindow::slotSetOutPoint()
3521 if (m_clipMonitor->isActive())
3522 m_clipMonitor->slotSetZoneEnd();
3524 m_projectMonitor->slotSetZoneEnd();
3525 // else m_activeTimeline->projectView()->setOutPoint();
3528 void MainWindow::slotResizeItemStart()
3530 if (m_activeTimeline)
3531 m_activeTimeline->projectView()->setInPoint();
3534 void MainWindow::slotResizeItemEnd()
3536 if (m_activeTimeline)
3537 m_activeTimeline->projectView()->setOutPoint();
3540 int MainWindow::getNewStuff(const QString &configFile)
3542 KNS3::Entry::List entries;
3543 #if KDE_IS_VERSION(4,3,80)
3544 KNS3::DownloadDialog dialog(configFile);
3546 entries = dialog.changedEntries();
3547 foreach(const KNS3::Entry & entry, entries) {
3548 if (entry.status() == KNS3::Entry::Installed)
3549 kDebug() << "// Installed files: " << entry.installedFiles();
3552 KNS::Engine engine(0);
3553 if (engine.init(configFile))
3554 entries = engine.downloadDialogModal(this);
3555 foreach(KNS::Entry * entry, entries) {
3556 if (entry->status() == KNS::Entry::Installed)
3557 kDebug() << "// Installed files: " << entry->installedFiles();
3559 #endif /* KDE_IS_VERSION(4,3,80) */
3560 return entries.size();
3563 void MainWindow::slotGetNewTitleStuff()
3565 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3566 TitleWidget::refreshTitleTemplates();
3569 void MainWindow::slotGetNewLumaStuff()
3571 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3572 initEffects::refreshLumas();
3573 m_activeTimeline->projectView()->reloadTransitionLumas();
3577 void MainWindow::slotGetNewRenderStuff()
3579 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3581 m_renderWidget->reloadProfiles();
3584 void MainWindow::slotGetNewMltProfileStuff()
3586 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3587 // update the list of profiles in settings dialog
3588 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3594 void MainWindow::slotAutoTransition()
3596 if (m_activeTimeline)
3597 m_activeTimeline->projectView()->autoTransition();
3600 void MainWindow::slotSplitAudio()
3602 if (m_activeTimeline)
3603 m_activeTimeline->projectView()->splitAudio();
3606 void MainWindow::slotUpdateClipType(QAction *action)
3608 if (m_activeTimeline) {
3609 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3610 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3611 else m_activeTimeline->projectView()->setAudioAndVideo();
3615 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3617 // We must stop the monitors since we create a new on in the dvd wizard
3618 m_clipMonitor->stop();
3619 m_projectMonitor->stop();
3620 DvdWizard w(url, profile, this);
3622 m_projectMonitor->start();
3625 void MainWindow::slotShowTimeline(bool show)
3627 if (show == false) {
3628 m_timelineState = saveState();
3629 centralWidget()->setHidden(true);
3631 centralWidget()->setHidden(false);
3632 restoreState(m_timelineState);
3636 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3638 //TODO: is there a way to maximize current widget?
3641 m_timelineState = saveState();
3642 QWidget *par = focusWidget()->parentWidget();
3643 while (par->parentWidget() && par->parentWidget() != this)
3644 par = par->parentWidget();
3645 kDebug() << "CURRENT WIDGET: " << par->objectName();
3648 //centralWidget()->setHidden(false);
3649 //restoreState(m_timelineState);
3653 void MainWindow::loadTranscoders()
3655 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3658 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3659 KConfigGroup transConfig(config, "Transcoding");
3661 QMap< QString, QString > profiles = transConfig.entryMap();
3662 QMapIterator<QString, QString> i(profiles);
3663 while (i.hasNext()) {
3665 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3666 QAction *a = transMenu->addAction(i.key());
3668 if (data.count() > 1)
3669 a->setToolTip(data.at(1));
3670 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3674 void MainWindow::slotTranscode(KUrl::List urls)
3679 if (urls.isEmpty()) {
3680 QAction *action = qobject_cast<QAction *>(sender());
3681 QStringList data = action->data().toStringList();
3682 params = data.at(0);
3683 if (data.count() > 1) desc = data.at(1);
3684 if (data.count() > 2) condition = data.at(2);
3685 urls << m_projectList->getConditionalUrls(condition);
3686 urls.removeAll(KUrl());
3688 if (urls.isEmpty()) {
3689 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3692 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3693 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3695 //QProcess::startDetached("ffmpeg", parameters);
3698 void MainWindow::slotTranscodeClip()
3700 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3701 if (urls.isEmpty()) return;
3702 slotTranscode(urls);
3705 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3707 if (m_activeDocument == NULL) return;
3708 QMapIterator<QString, QString> i(props);
3709 while (i.hasNext()) {
3711 m_activeDocument->setDocumentProperty(i.key(), i.value());
3713 m_activeDocument->setModified(true);
3717 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3719 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3721 QString playlistPath;
3724 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3725 QString path = m_renderWidget->getFreeScriptName();
3726 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3727 if (!ok || scriptPath.isEmpty()) return;
3728 scriptPath.prepend(scriptsFolder);
3729 QFile f(scriptPath);
3731 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3734 playlistPath = scriptPath + ".mlt";
3735 m_projectMonitor->saveSceneList(playlistPath);
3737 KTemporaryFile temp;
3738 temp.setAutoRemove(false);
3739 temp.setSuffix(".mlt");
3741 playlistPath = temp.fileName();
3742 m_projectMonitor->saveSceneList(playlistPath);
3745 if (!chapterFile.isEmpty()) {
3748 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3750 in = m_activeTimeline->inPoint();
3751 out = m_activeTimeline->outPoint();
3754 QDomElement chapters = doc.createElement("chapters");
3755 chapters.setAttribute("fps", m_activeDocument->fps());
3756 doc.appendChild(chapters);
3758 QDomElement guidesxml = m_activeDocument->guidesXml();
3759 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3760 for (int i = 0; i < nodes.count(); i++) {
3761 QDomElement e = nodes.item(i).toElement();
3763 QString comment = e.attribute("comment");
3764 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3765 if (time >= in && time < out) {
3766 if (zoneOnly) time = time - in;
3767 QDomElement chapter = doc.createElement("chapter");
3768 chapters.appendChild(chapter);
3769 chapter.setAttribute("title", comment);
3770 chapter.setAttribute("time", time);
3774 if (chapters.childNodes().count() > 0) {
3775 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3776 // Always insert a guide in pos 0
3777 QDomElement chapter = doc.createElement("chapter");
3778 chapters.insertBefore(chapter, QDomNode());
3779 chapter.setAttribute("title", i18n("Start"));
3780 chapter.setAttribute("time", "0");
3782 // save chapters file
3783 QFile file(chapterFile);
3784 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3785 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3787 file.write(doc.toString().toUtf8());
3788 if (file.error() != QFile::NoError) {
3789 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3796 if (m_renderWidget->automaticAudioExport()) {
3797 exportAudio = m_activeTimeline->checkProjectAudio();
3798 } else exportAudio = m_renderWidget->selectedAudioExport();
3799 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3802 void MainWindow::slotUpdateTimecodeFormat(int ix)
3804 KdenliveSettings::setFrametimecode(ix == 1);
3805 m_clipMonitor->updateTimecodeFormat();
3806 m_projectMonitor->updateTimecodeFormat();
3807 m_transitionConfig->updateTimecodeFormat();
3808 m_effectStack->updateTimecodeFormat();
3809 //m_activeTimeline->projectView()->clearSelection();
3810 m_activeTimeline->updateRuler();
3813 void MainWindow::slotRemoveFocus()
3815 statusBar()->setFocus();
3816 statusBar()->clearFocus();
3819 void MainWindow::slotRevert()
3821 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;
3822 KUrl url = m_activeDocument->url();
3823 if (closeCurrentDocument(false))
3824 doOpenFile(url, NULL);
3828 void MainWindow::slotShutdown()
3830 if (m_activeDocument) m_activeDocument->setModified(false);
3832 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3833 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3834 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3835 smserver.call("logout", 1, 2, 2);
3836 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3837 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3838 smserver.call("Shutdown");
3842 void MainWindow::slotUpdateTrackInfo()
3844 if (m_activeDocument)
3845 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3848 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3850 // Load the theme file
3852 if (action == NULL) theme = themename;
3853 else theme = action->data().toString();
3854 KdenliveSettings::setColortheme(theme);
3855 // Make palette for all widgets.
3857 if (theme.isEmpty())
3858 plt = QApplication::desktop()->palette();
3860 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3861 plt = KGlobalSettings::createApplicationPalette(config);
3864 kapp->setPalette(plt);
3865 const QObjectList children = statusBar()->children();
3867 foreach(QObject * child, children) {
3868 if (child->isWidgetType())
3869 ((QWidget*)child)->setPalette(plt);
3870 const QObjectList subchildren = child->children();
3871 foreach(QObject * subchild, subchildren) {
3872 if (subchild->isWidgetType())
3873 ((QWidget*)subchild)->setPalette(plt);
3876 if (m_activeTimeline) {
3877 m_activeTimeline->projectView()->updatePalette();
3882 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3884 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3885 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3886 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3887 const QSize bitsSize(24, 2);
3888 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3889 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3891 QPixmap pixmap(23, 16);
3892 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3894 KConfigGroup group(config, "WM");
3895 QPainter p(&pixmap);
3896 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3897 p.fillRect(1, 1, 7, 7, windowScheme.background());
3898 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3900 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3901 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3902 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3904 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3905 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3907 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3908 p.fillRect(1, 8, 7, 7, viewScheme.background());
3909 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3911 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3912 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3913 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3915 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3916 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3922 void MainWindow::slotSwitchMonitors()
3924 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3925 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3926 else m_projectList->focusTree();
3929 void MainWindow::slotSwitchFullscreen()
3931 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
3932 else m_clipMonitor->slotSwitchFullScreen();
3935 void MainWindow::slotInsertZoneToTree()
3937 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3938 QStringList info = m_clipMonitor->getZoneInfo();
3939 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3942 void MainWindow::slotInsertZoneToTimeline()
3944 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3945 QStringList info = m_clipMonitor->getZoneInfo();
3946 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3950 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3952 if (m_activeDocument && m_activeTimeline) {
3953 if (!ids.isEmpty()) {
3954 for (int i = 0; i < ids.size(); ++i) {
3955 m_activeTimeline->slotDeleteClip(ids.at(i));
3957 m_activeDocument->clipManager()->slotDeleteClips(ids);
3959 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3960 m_activeDocument->setModified(true);
3964 void MainWindow::slotShowTitleBars(bool show)
3966 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
3967 for (int i = 0; i < docks.count(); i++) {
3968 QDockWidget* dock = docks.at(i);
3970 dock->setTitleBarWidget(0);
3972 if (!dock->isFloating()) {
3973 dock->setTitleBarWidget(new QWidget);
3977 KdenliveSettings::setShowtitlebars(show);
3980 void MainWindow::slotSwitchTitles()
3982 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3985 QString MainWindow::getMimeType()
3987 QString mimetype = "application/x-kdenlive";
3988 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3989 if (!mime) mimetype = "*.kdenlive";
3993 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3996 m_projectMonitor->render->sendFrameForAnalysis = true;
3999 for (int i = 0; i < m_scopesList.count(); i++) {
4000 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
4007 m_projectMonitor->render->sendFrameForAnalysis = false;
4011 void MainWindow::slotUpdateScopeFrameRequest()
4013 // We need a delay to make sure widgets are hidden after a close event for example
4014 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
4017 void MainWindow::slotDoUpdateScopeFrameRequest()
4020 bool request = false;
4021 for (int i = 0; i < m_scopesList.count(); i++) {
4022 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
4023 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
4029 if (!m_projectMonitor->effectSceneDisplayed())
4030 m_projectMonitor->render->sendFrameForAnalysis = false;
4031 m_clipMonitor->render->sendFrameForAnalysis = false;
4033 m_projectMonitor->render->sendFrameForAnalysis = true;
4034 m_clipMonitor->render->sendFrameForAnalysis = true;
4038 void MainWindow::slotUpdateColorScopes()
4040 bool request = false;
4041 for (int i = 0; i < m_scopesList.count(); i++) {
4042 // Check if we need the renderer to send a new frame for update
4043 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4044 static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4047 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4048 else m_projectMonitor->render->sendFrameUpdate();
4052 void MainWindow::slotOpenStopmotion()
4054 if (m_stopmotion == NULL) {
4055 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4056 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4057 for (int i = 0; i < m_scopesList.count(); i++) {
4058 // Check if we need the renderer to send a new frame for update
4059 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4060 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4061 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4064 m_stopmotion->show();
4067 void MainWindow::slotDeleteClip(const QString &id)
4069 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4070 for (int i = 0; i < list.size(); ++i) {
4071 list.at(i)->disableClipId(id);
4073 m_projectList->slotDeleteClip(id);
4076 #include "mainwindow.moc"