1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
42 #include "audiosignal.h"
44 #include "jogshuttle.h"
45 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
47 #endif /* NO_JOGSHUTTLE */
48 #include "clipproperties.h"
50 #include "editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "kdenlive-config.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audiospectrum.h"
63 #include "spectrogram.h"
64 #include "archivewidget.h"
65 #include "databackup/backupwidget.h"
67 #include <KApplication>
71 #include <KActionCollection>
72 #include <KActionCategory>
73 #include <KStandardAction>
74 #include <KShortcutsDialog>
75 #include <KFileDialog>
76 #include <KMessageBox>
78 #include <KIO/NetAccess>
81 #include <KConfigDialog>
82 #include <KXMLGUIFactory>
84 #include <kstandarddirs.h>
85 #include <KUrlRequesterDialog>
86 #include <KTemporaryFile>
88 #include <KActionMenu>
90 #include <ktogglefullscreenaction.h>
92 #include <KNotification>
93 #include <KNotifyConfigWidget>
94 #if KDE_IS_VERSION(4,3,80)
95 #include <knewstuff3/downloaddialog.h>
96 #include <knewstuff3/knewstuffaction.h>
98 #include <knewstuff2/engine.h>
99 #include <knewstuff2/ui/knewstuffaction.h>
101 #endif /* KDE_IS_VERSION(4,3,80) */
103 #include <KColorScheme>
104 #include <KProgressDialog>
106 #include <QTextStream>
110 #include <QInputDialog>
111 #include <QDesktopWidget>
116 // Uncomment for deeper debugging
117 //#define DEBUG_MAINW
123 static const char version[] = VERSION;
125 static const int ID_TIMELINE_POS = 0;
131 Q_DECLARE_METATYPE(QVector<int16_t>)
134 EffectsList MainWindow::videoEffects;
135 EffectsList MainWindow::audioEffects;
136 EffectsList MainWindow::customEffects;
137 EffectsList MainWindow::transitions;
139 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
140 KXmlGuiWindow(parent),
141 m_activeDocument(NULL),
142 m_activeTimeline(NULL),
144 m_renderWidget(NULL),
145 #ifndef NO_JOGSHUTTLE
148 #endif /* NO_JOGSHUTTLE */
149 m_findActivated(false),
152 qRegisterMetaType<QVector<int16_t> > ();
153 qRegisterMetaType<stringMap> ("stringMap");
154 qRegisterMetaType<audioByteArray> ("audioByteArray");
157 QLocale systemLocale = QLocale();
158 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
159 QLocale::setDefault(systemLocale);
161 // Create DBus interface
162 new MainWindowAdaptor(this);
163 QDBusConnection dbus = QDBusConnection::sessionBus();
164 dbus.registerObject("/MainWindow", this);
166 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
167 setFont(KGlobalSettings::toolBarFont());
168 parseProfiles(MltPath);
169 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
170 m_commandStack = new QUndoGroup;
171 setDockNestingEnabled(true);
172 m_timelineArea = new KTabWidget(this);
173 m_timelineArea->setTabReorderingEnabled(true);
174 m_timelineArea->setTabBarHidden(true);
175 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
176 m_timelineArea->setMinimumHeight(200);
178 QToolButton *closeTabButton = new QToolButton;
179 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
180 closeTabButton->setIcon(KIcon("tab-close"));
181 closeTabButton->adjustSize();
182 closeTabButton->setToolTip(i18n("Close the current tab"));
183 m_timelineArea->setCornerWidget(closeTabButton);
184 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
186 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
187 m_findTimer.setSingleShot(true);
189 // FIXME: the next call returns a newly allocated object, which leaks
190 initEffects::parseEffectFiles();
191 //initEffects::parseCustomEffectsFile();
193 m_monitorManager = new MonitorManager();
195 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
196 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
201 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
202 m_projectListDock->setObjectName("project_tree");
203 m_projectList = new ProjectList();
204 m_projectListDock->setWidget(m_projectList);
205 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
207 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
208 m_clipMonitorDock->setObjectName("clip_monitor");
209 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
210 m_clipMonitorDock->setWidget(m_clipMonitor);
211 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint)));
212 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
214 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
215 m_projectMonitorDock->setObjectName("project_monitor");
216 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
217 m_projectMonitorDock->setWidget(m_projectMonitor);
220 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
221 m_recMonitorDock->setObjectName("record_monitor");
222 m_recMonitor = new RecMonitor("record", m_monitorManager);
223 m_recMonitorDock->setWidget(m_recMonitor);
224 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
225 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
226 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
228 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
230 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
231 m_notesDock->setObjectName("notes_widget");
232 m_notesWidget = new NotesWidget();
233 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
234 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
236 m_notesWidget->setTabChangesFocus(true);
237 #if KDE_IS_VERSION(4,4,0)
238 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
240 m_notesDock->setWidget(m_notesWidget);
241 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
243 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
244 m_effectStackDock->setObjectName("effect_stack");
245 m_effectStack = new EffectStackView(m_projectMonitor);
246 m_effectStackDock->setWidget(m_effectStack);
247 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
249 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
250 m_transitionConfigDock->setObjectName("transition");
251 m_transitionConfig = new TransitionSettings(m_projectMonitor);
252 m_transitionConfigDock->setWidget(m_transitionConfig);
253 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
255 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
256 m_effectListDock->setObjectName("effect_list");
257 m_effectList = new EffectsListView();
258 m_effectListDock->setWidget(m_effectList);
259 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
261 m_vectorscope = new Vectorscope(m_monitorManager);
262 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
263 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
264 m_vectorscopeDock->setWidget(m_vectorscope);
265 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
266 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
267 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
268 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
269 m_gfxScopesList.append(m_vectorscopeDock);
271 m_waveform = new Waveform(m_monitorManager);
272 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
273 m_waveformDock->setObjectName(m_waveform->widgetName());
274 m_waveformDock->setWidget(m_waveform);
275 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
276 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
277 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
278 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
279 m_gfxScopesList.append(m_waveformDock);
281 m_RGBParade = new RGBParade(m_monitorManager);
282 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
283 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
284 m_RGBParadeDock->setWidget(m_RGBParade);
285 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
286 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
287 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
288 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
289 m_gfxScopesList.append(m_RGBParadeDock);
291 m_histogram = new Histogram(m_monitorManager);
292 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
293 m_histogramDock->setObjectName(m_histogram->widgetName());
294 m_histogramDock->setWidget(m_histogram);
295 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
296 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
297 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
298 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
299 m_gfxScopesList.append(m_histogramDock);
302 m_audiosignal = new AudioSignal;
303 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
304 m_audiosignalDock->setObjectName("audiosignal");
305 m_audiosignalDock->setWidget(m_audiosignal);
306 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
307 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
308 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
310 m_audioSpectrum = new AudioSpectrum();
311 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
312 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
313 m_audioSpectrumDock->setWidget(m_audioSpectrum);
314 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
315 m_audioScopesList.append(m_audioSpectrum);
316 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
317 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
319 m_spectrogram = new Spectrogram();
320 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
321 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
322 m_spectrogramDock->setWidget(m_spectrogram);
323 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
324 m_audioScopesList.append(m_spectrogram);
325 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
326 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
328 // Connect the audio signal to the audio scope slots
330 if (m_projectMonitor) {
331 qDebug() << "project monitor connected";
332 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
333 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
334 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
335 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
336 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
337 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
340 qDebug() << "clip monitor connected";
341 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
342 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
343 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
344 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
345 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
346 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
348 // Ensure connections were set up correctly
353 // Add monitors here to keep them at the right of the window
354 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
355 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
357 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
360 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
361 m_undoViewDock->setObjectName("undo_history");
362 m_undoView = new QUndoView();
363 m_undoView->setCleanIcon(KIcon("edit-clear"));
364 m_undoView->setEmptyLabel(i18n("Clean"));
365 m_undoViewDock->setWidget(m_undoView);
366 m_undoView->setGroup(m_commandStack);
367 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
371 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
374 // Close non-general docks for the initial layout
375 // only show important ones
376 m_histogramDock->close();
377 m_RGBParadeDock->close();
378 m_waveformDock->close();
379 m_vectorscopeDock->close();
381 m_audioSpectrumDock->close();
382 m_spectrogramDock->close();
383 m_audiosignalDock->close();
385 m_undoViewDock->close();
389 /// Tabify Widgets ///
390 tabifyDockWidget(m_effectListDock, m_effectStackDock);
391 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
392 tabifyDockWidget(m_projectListDock, m_notesDock);
394 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
396 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
402 setCentralWidget(m_timelineArea);
405 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
407 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
408 m_fileRevert->setEnabled(false);
410 // Prepare layout actions
411 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
412 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
413 for (int i = 1; i < 5; i++) {
414 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
415 load->setData("_" + QString::number(i));
416 layoutActions->addAction("load_layout" + QString::number(i), load);
417 m_loadLayout->addAction(load);
418 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
419 save->setData("_" + QString::number(i));
420 layoutActions->addAction("save_layout" + QString::number(i), save);
422 layoutActions->addAction("load_layouts", m_loadLayout);
423 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
426 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
427 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
428 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
429 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
430 m_stopmotion_actions->addAction("stopmotion_capture", action);
431 action = new KAction(i18n("Switch live / captured frame"), this);
432 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
433 m_stopmotion_actions->addAction("stopmotion_switch", action);
434 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
435 action->setCheckable(true);
436 action->setChecked(false);
437 m_stopmotion_actions->addAction("stopmotion_overlay", action);
439 // Build effects menu
440 m_effectsMenu = new QMenu(i18n("Add Effect"));
441 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
442 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
443 m_effectsActionCollection->readSettings();
447 // Find QDockWidget tab bars and show / hide widget title bars on right click
448 QList <QTabBar *> tabs = findChildren<QTabBar *>();
449 for (int i = 0; i < tabs.count(); i++) {
450 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
451 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
454 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
455 guiFactory()->addClient(sp);*/
457 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
459 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
462 // Load layout names from config file
468 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
469 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
471 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
472 clipInTimeline->setIcon(KIcon("go-jump"));
473 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
474 static_cast<QMenu*>(factory()->container("transcoders", this)),
477 // build themes menus
478 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
479 QActionGroup *themegroup = new QActionGroup(this);
480 themegroup->setExclusive(true);
481 action = new KAction(i18n("Default"), this);
482 action->setCheckable(true);
483 themegroup->addAction(action);
484 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
486 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
488 for (int i = 0; i < schemeFiles.size(); ++i) {
490 const QString filename = schemeFiles.at(i);
491 const QFileInfo info(filename);
494 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
495 QIcon icon = createSchemePreviewIcon(config);
496 KConfigGroup group(config, "General");
497 const QString name = group.readEntry("Name", info.baseName());
498 action = new KAction(name, this);
499 action->setData(filename);
500 action->setIcon(icon);
501 action->setCheckable(true);
502 themegroup->addAction(action);
503 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
506 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
507 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
508 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
511 action = new QAction(fi.fileName(), this);
512 action->setData(*it);
513 action->setCheckable(true);
514 themegroup->addAction(action);
515 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
517 themesMenu->addActions(themegroup->actions());
518 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
520 // Setup and fill effects and transitions menus.
523 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
524 m->addActions(m_effectsMenu->actions());
527 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
528 for (int i = 0; i < transitions.count(); ++i)
529 m_transitionsMenu->addAction(m_transitions[i]);
531 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
532 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
533 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
535 m_effectStack->setMenu(m_effectsMenu);
537 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
538 const QList<QAction *> viewActions = createPopupMenu()->actions();
539 viewMenu->insertActions(NULL, viewActions);
541 m_timelineContextMenu = new QMenu(this);
542 m_timelineContextClipMenu = new QMenu(this);
543 m_timelineContextTransitionMenu = new QMenu(this);
545 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
546 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
547 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
549 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
550 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
551 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
552 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
553 m_timelineContextClipMenu->addSeparator();
554 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
555 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
556 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
557 m_timelineContextClipMenu->addSeparator();
558 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
559 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
560 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
561 m_timelineContextClipMenu->addSeparator();
563 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
564 m_timelineContextClipMenu->addMenu(markersMenu);
565 m_timelineContextClipMenu->addSeparator();
566 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
567 m_timelineContextClipMenu->addMenu(m_effectsMenu);
569 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
570 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
571 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
573 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
575 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
576 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
577 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
578 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
579 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
580 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
581 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
583 slotConnectMonitors();
585 // Open or create a file. Command line argument passed in Url has
586 // precedence, then "openlastproject", then just a plain empty file.
587 // If opening Url fails, openlastproject will _not_ be used.
588 if (!Url.isEmpty()) {
589 // delay loading so that the window shows up
591 QTimer::singleShot(500, this, SLOT(openFile()));
592 } else if (KdenliveSettings::openlastproject()) {
593 QTimer::singleShot(500, this, SLOT(openLastFile()));
594 } else { //if (m_timelineArea->count() == 0) {
598 if (!clipsToLoad.isEmpty() && m_activeDocument) {
599 QStringList list = clipsToLoad.split(',');
601 foreach(QString path, list) {
602 kDebug() << QDir::current().absoluteFilePath(path);
603 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
605 m_projectList->slotAddClip(urls);
608 #ifndef NO_JOGSHUTTLE
609 activateShuttleDevice();
610 #endif /* NO_JOGSHUTTLE */
611 m_projectListDock->raise();
613 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
614 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
617 MainWindow::~MainWindow()
622 m_effectStack->slotClipItemSelected(NULL, 0);
623 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
625 if (m_projectMonitor) m_projectMonitor->stop();
626 if (m_clipMonitor) m_clipMonitor->stop();
628 delete m_activeTimeline;
629 delete m_effectStack;
630 delete m_transitionConfig;
631 delete m_activeDocument;
632 delete m_projectMonitor;
633 delete m_clipMonitor;
634 delete m_shortcutRemoveFocus;
635 delete[] m_transitions;
636 Mlt::Factory::close();
640 bool MainWindow::queryClose()
642 if (m_renderWidget) {
643 int waitingJobs = m_renderWidget->waitingJobsCount();
644 if (waitingJobs > 0) {
645 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")))) {
646 case KMessageBox::Yes :
647 // create script with waiting jobs and start it
648 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
650 case KMessageBox::No :
651 // Don't do anything, jobs will be deleted
659 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
660 // warn the user to save if document is modified and we have clips in our project list
661 if (m_activeDocument && m_activeDocument->isModified() &&
662 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
663 !m_projectList->documentClipList().isEmpty())) {
667 if (m_activeDocument->url().fileName().isEmpty())
668 message = i18n("Save changes to document?");
670 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
671 switch (KMessageBox::warningYesNoCancel(this, message)) {
672 case KMessageBox::Yes :
673 // save document here. If saving fails, return false;
675 case KMessageBox::No :
676 // User does not want to save the changes, clear recovery files
677 m_activeDocument->m_autosave->resize(0);
686 void MainWindow::loadPlugins()
688 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
689 populateMenus(plugin);
692 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
694 filters << "libkdenlive*";
695 foreach(const QString & folder, directories) {
696 kDebug() << "Parsing plugin folder: " << folder;
697 QDir pluginsDir(folder);
698 foreach(const QString & fileName,
699 pluginsDir.entryList(filters, QDir::Files)) {
701 * Avoid loading the same plugin twice when there is more than one
704 if (!m_pluginFileNames.contains(fileName)) {
705 kDebug() << "Found plugin: " << fileName;
706 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
707 QObject *plugin = loader.instance();
709 populateMenus(plugin);
710 m_pluginFileNames += fileName;
712 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
718 void MainWindow::populateMenus(QObject *plugin)
720 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
721 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
723 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
727 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
728 QMenu *menu, const char *member,
729 QActionGroup *actionGroup)
731 kDebug() << "// ADD to MENU" << texts;
732 foreach(const QString & text, texts) {
733 QAction *action = new QAction(text, plugin);
734 action->setData(text);
735 connect(action, SIGNAL(triggered()), this, member);
736 menu->addAction(action);
739 action->setCheckable(true);
740 actionGroup->addAction(action);
745 void MainWindow::aboutPlugins()
747 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
752 void MainWindow::generateClip()
754 QAction *action = qobject_cast<QAction *>(sender());
755 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
757 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
758 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
759 if (!clipUrl.isEmpty()) {
760 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
764 void MainWindow::saveProperties(KConfigGroup &config)
766 // save properties here,used by session management
768 KMainWindow::saveProperties(config);
772 void MainWindow::readProperties(const KConfigGroup &config)
774 // read properties here,used by session management
775 KMainWindow::readProperties(config);
776 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
777 openFile(KUrl(Lastproject));
780 void MainWindow::slotReloadEffects()
782 initEffects::parseCustomEffectsFile();
783 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
786 #ifndef NO_JOGSHUTTLE
787 void MainWindow::activateShuttleDevice()
793 if (KdenliveSettings::enableshuttle() == false) return;
795 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
796 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
798 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
799 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
800 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
801 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
802 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
804 #endif /* NO_JOGSHUTTLE */
806 void MainWindow::slotDoAction(const QString& action_name)
808 QAction* action = actionCollection()->action(action_name);
810 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
816 void MainWindow::configureNotifications()
818 KNotifyConfigWidget::configure(this);
821 void MainWindow::slotFullScreen()
823 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
826 void MainWindow::slotAddEffect(const QDomElement effect)
828 if (!m_activeDocument) return;
829 if (effect.isNull()) {
830 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
833 QDomElement effectToAdd = effect.cloneNode().toElement();
835 int ix = m_effectStack->isTrackMode(&ok);
836 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
837 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
840 void MainWindow::slotUpdateClip(const QString &id)
842 if (!m_activeDocument) return;
843 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
845 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
846 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
847 Mlt::Producer *monitorProducer = clip->getCloneProducer();
848 m_clipMonitor->updateClipProducer(monitorProducer);
850 clip->cleanupProducers();
853 void MainWindow::slotConnectMonitors()
855 m_projectList->setRenderer(m_projectMonitor->render);
856 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
857 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
858 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
859 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
860 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
861 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)));
863 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
865 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
867 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
869 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
870 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
872 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
874 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
875 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
878 void MainWindow::slotAdjustClipMonitor()
880 m_clipMonitorDock->updateGeometry();
881 m_clipMonitorDock->adjustSize();
882 m_clipMonitor->resetSize();
885 void MainWindow::slotAdjustProjectMonitor()
887 m_projectMonitorDock->updateGeometry();
888 m_projectMonitorDock->adjustSize();
889 m_projectMonitor->resetSize();
893 class NameGrabbingKActionCollection {
895 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
896 : m_collection(collection), m_action_names(action_names) {
897 m_action_names.clear();
899 KAction* addAction(const QString& action_name) {
900 m_action_names << action_name;
901 return m_collection->addAction(action_name);
903 void addAction(const QString& action_name, QAction* action) {
904 m_action_names << action_name;
905 m_collection->addAction(action_name, action);
907 operator KActionCollection*() { return m_collection; }
908 const QStringList& actionNames() const { return m_action_names; }
910 KActionCollection* m_collection;
911 QStringList& m_action_names;
914 void MainWindow::setupActions()
917 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
918 m_timecodeFormat = new KComboBox(this);
919 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
920 m_timecodeFormat->addItem(i18n("Frames"));
921 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
922 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
924 m_statusProgressBar = new QProgressBar(this);
925 m_statusProgressBar->setMinimum(0);
926 m_statusProgressBar->setMaximum(100);
927 m_statusProgressBar->setMaximumWidth(150);
928 m_statusProgressBar->setVisible(false);
930 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
931 toolbar->setMovable(false);
932 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
933 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
934 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
935 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
936 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
937 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());
938 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
940 //create edit mode buttons
941 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
942 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
943 toolbar->addAction(m_normalEditTool);
944 m_normalEditTool->setCheckable(true);
945 m_normalEditTool->setChecked(true);
947 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
948 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
949 toolbar->addAction(m_overwriteEditTool);
950 m_overwriteEditTool->setCheckable(true);
951 m_overwriteEditTool->setChecked(false);
953 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
954 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
955 toolbar->addAction(m_insertEditTool);
956 m_insertEditTool->setCheckable(true);
957 m_insertEditTool->setChecked(false);
958 // not implemented yet
959 m_insertEditTool->setEnabled(false);
961 QActionGroup *editGroup = new QActionGroup(this);
962 editGroup->addAction(m_normalEditTool);
963 editGroup->addAction(m_overwriteEditTool);
964 editGroup->addAction(m_insertEditTool);
965 editGroup->setExclusive(true);
966 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
967 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
969 toolbar->addSeparator();
971 // create tools buttons
972 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
973 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
974 toolbar->addAction(m_buttonSelectTool);
975 m_buttonSelectTool->setCheckable(true);
976 m_buttonSelectTool->setChecked(true);
978 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
979 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
980 toolbar->addAction(m_buttonRazorTool);
981 m_buttonRazorTool->setCheckable(true);
982 m_buttonRazorTool->setChecked(false);
984 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
985 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
986 toolbar->addAction(m_buttonSpacerTool);
987 m_buttonSpacerTool->setCheckable(true);
988 m_buttonSpacerTool->setChecked(false);
990 QActionGroup *toolGroup = new QActionGroup(this);
991 toolGroup->addAction(m_buttonSelectTool);
992 toolGroup->addAction(m_buttonRazorTool);
993 toolGroup->addAction(m_buttonSpacerTool);
994 toolGroup->setExclusive(true);
995 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
997 QWidget * actionWidget;
998 int max = toolbar->iconSizeDefault() + 2;
999 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1000 actionWidget->setMaximumWidth(max);
1001 actionWidget->setMaximumHeight(max - 4);
1003 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1004 actionWidget->setMaximumWidth(max);
1005 actionWidget->setMaximumHeight(max - 4);
1007 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1008 actionWidget->setMaximumWidth(max);
1009 actionWidget->setMaximumHeight(max - 4);
1011 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1012 actionWidget->setMaximumWidth(max);
1013 actionWidget->setMaximumHeight(max - 4);
1015 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1016 actionWidget->setMaximumWidth(max);
1017 actionWidget->setMaximumHeight(max - 4);
1019 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1020 actionWidget->setMaximumWidth(max);
1021 actionWidget->setMaximumHeight(max - 4);
1023 toolbar->setStyleSheet(style1);
1024 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1026 toolbar->addSeparator();
1027 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1028 toolbar->addAction(m_buttonFitZoom);
1029 m_buttonFitZoom->setCheckable(false);
1031 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1032 toolbar->addAction(m_zoomOut);
1033 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1035 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1036 m_zoomSlider->setMaximum(13);
1037 m_zoomSlider->setPageStep(1);
1038 m_zoomSlider->setInvertedAppearance(true);
1040 m_zoomSlider->setMaximumWidth(150);
1041 m_zoomSlider->setMinimumWidth(100);
1042 toolbar->addWidget(m_zoomSlider);
1044 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1045 toolbar->addAction(m_zoomIn);
1046 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1048 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1049 actionWidget->setMaximumWidth(max);
1050 actionWidget->setMaximumHeight(max - 4);
1051 actionWidget->setStyleSheet(styleBorderless);
1053 actionWidget = toolbar->widgetForAction(m_zoomIn);
1054 actionWidget->setMaximumWidth(max);
1055 actionWidget->setMaximumHeight(max - 4);
1056 actionWidget->setStyleSheet(styleBorderless);
1058 actionWidget = toolbar->widgetForAction(m_zoomOut);
1059 actionWidget->setMaximumWidth(max);
1060 actionWidget->setMaximumHeight(max - 4);
1061 actionWidget->setStyleSheet(styleBorderless);
1063 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1064 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1065 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1066 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1067 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1069 toolbar->addSeparator();
1071 //create automatic audio split button
1072 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1073 toolbar->addAction(m_buttonAutomaticSplitAudio);
1074 m_buttonAutomaticSplitAudio->setCheckable(true);
1075 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1076 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1078 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1079 toolbar->addAction(m_buttonVideoThumbs);
1080 m_buttonVideoThumbs->setCheckable(true);
1081 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1082 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1084 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1085 toolbar->addAction(m_buttonAudioThumbs);
1086 m_buttonAudioThumbs->setCheckable(true);
1087 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1088 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1090 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1091 toolbar->addAction(m_buttonShowMarkers);
1092 m_buttonShowMarkers->setCheckable(true);
1093 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1094 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1096 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1097 toolbar->addAction(m_buttonSnap);
1098 m_buttonSnap->setCheckable(true);
1099 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1100 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1102 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1103 actionWidget->setMaximumWidth(max);
1104 actionWidget->setMaximumHeight(max - 4);
1106 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1107 actionWidget->setMaximumWidth(max);
1108 actionWidget->setMaximumHeight(max - 4);
1110 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1111 actionWidget->setMaximumWidth(max);
1112 actionWidget->setMaximumHeight(max - 4);
1114 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1115 actionWidget->setMaximumWidth(max);
1116 actionWidget->setMaximumHeight(max - 4);
1118 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1119 actionWidget->setMaximumWidth(max);
1120 actionWidget->setMaximumHeight(max - 4);
1122 m_messageLabel = new StatusBarMessageLabel(this);
1123 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1125 statusBar()->addWidget(m_messageLabel, 10);
1126 statusBar()->addWidget(m_statusProgressBar, 0);
1127 statusBar()->addPermanentWidget(toolbar);
1128 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1129 statusBar()->addPermanentWidget(m_timecodeFormat);
1130 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1132 collection.addAction("normal_mode", m_normalEditTool);
1133 collection.addAction("overwrite_mode", m_overwriteEditTool);
1134 collection.addAction("insert_mode", m_insertEditTool);
1135 collection.addAction("select_tool", m_buttonSelectTool);
1136 collection.addAction("razor_tool", m_buttonRazorTool);
1137 collection.addAction("spacer_tool", m_buttonSpacerTool);
1139 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1140 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1141 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1142 collection.addAction("show_markers", m_buttonShowMarkers);
1143 collection.addAction("snap", m_buttonSnap);
1144 collection.addAction("zoom_fit", m_buttonFitZoom);
1145 collection.addAction("zoom_in", m_zoomIn);
1146 collection.addAction("zoom_out", m_zoomOut);
1148 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1149 collection.addAction("project_find", m_projectSearch);
1150 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1151 m_projectSearch->setShortcut(Qt::Key_Slash);
1153 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1154 collection.addAction("project_find_next", m_projectSearchNext);
1155 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1156 m_projectSearchNext->setShortcut(Qt::Key_F3);
1157 m_projectSearchNext->setEnabled(false);
1159 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1160 collection.addAction("manage_profiles", profilesAction);
1161 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1163 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1164 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1165 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1166 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1168 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1169 collection.addAction("run_wizard", wizAction);
1170 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1172 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1173 collection.addAction("project_settings", projectAction);
1174 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1176 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1177 collection.addAction("open_backup", backupAction);
1178 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1180 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1181 collection.addAction("project_render", projectRender);
1182 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1183 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1185 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1186 collection.addAction("project_clean", projectClean);
1187 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1189 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1190 collection.addAction("project_adjust_profile", projectAdjust);
1191 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1193 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1194 KShortcut playShortcut;
1195 playShortcut.setPrimary(Qt::Key_Space);
1196 playShortcut.setAlternate(Qt::Key_K);
1197 monitorPlay->setShortcut(playShortcut);
1198 collection.addAction("monitor_play", monitorPlay);
1199 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1201 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1202 collection.addAction("monitor_pause", monitorPause);
1203 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1205 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1206 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1207 collection.addAction("monitor_play_zone", m_playZone);
1208 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1210 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1211 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1212 collection.addAction("monitor_loop_zone", m_loopZone);
1213 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1215 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1216 m_loopClip->setEnabled(false);
1217 collection.addAction("monitor_loop_clip", m_loopClip);
1218 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1220 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1221 collection.addAction("dvd_wizard", dvdWizard);
1222 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1224 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1225 collection.addAction("transcode_clip", transcodeClip);
1226 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1228 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1229 collection.addAction("archive_project", archiveProject);
1230 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1233 KAction *markIn = collection.addAction("mark_in");
1234 markIn->setText(i18n("Set Zone In"));
1235 markIn->setShortcut(Qt::Key_I);
1236 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1238 KAction *markOut = collection.addAction("mark_out");
1239 markOut->setText(i18n("Set Zone Out"));
1240 markOut->setShortcut(Qt::Key_O);
1241 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1243 KAction *switchMon = collection.addAction("switch_monitor");
1244 switchMon->setText(i18n("Switch monitor"));
1245 switchMon->setShortcut(Qt::Key_T);
1246 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1248 KAction *fullMon = collection.addAction("monitor_fullscreen");
1249 fullMon->setText(i18n("Switch monitor fullscreen"));
1250 fullMon->setIcon(KIcon("view-fullscreen"));
1251 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1253 KAction *insertTree = collection.addAction("insert_project_tree");
1254 insertTree->setText(i18n("Insert zone in project tree"));
1255 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1256 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1258 KAction *insertTimeline = collection.addAction("insert_timeline");
1259 insertTimeline->setText(i18n("Insert zone in timeline"));
1260 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1261 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1263 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1264 collection.addAction("resize_timeline_clip_start", resizeStart);
1265 resizeStart->setShortcut(Qt::Key_1);
1266 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1268 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1269 collection.addAction("resize_timeline_clip_end", resizeEnd);
1270 resizeEnd->setShortcut(Qt::Key_2);
1271 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1273 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1274 monitorSeekBackward->setShortcut(Qt::Key_J);
1275 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1276 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1278 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1279 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1280 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1281 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1283 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1284 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1285 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1286 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1288 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1289 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1290 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1291 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1293 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1294 monitorSeekForward->setShortcut(Qt::Key_L);
1295 collection.addAction("monitor_seek_forward", monitorSeekForward);
1296 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1298 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1299 clipStart->setShortcut(Qt::Key_Home);
1300 collection.addAction("seek_clip_start", clipStart);
1301 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1303 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1304 clipEnd->setShortcut(Qt::Key_End);
1305 collection.addAction("seek_clip_end", clipEnd);
1306 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1308 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1309 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1310 collection.addAction("seek_zone_start", zoneStart);
1311 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1313 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1314 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1315 collection.addAction("seek_zone_end", zoneEnd);
1316 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1318 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1319 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1320 collection.addAction("seek_start", projectStart);
1321 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1323 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1324 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1325 collection.addAction("seek_end", projectEnd);
1326 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1328 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1329 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1330 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1331 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1333 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1334 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1335 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1336 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1338 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1339 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1340 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1341 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1343 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1344 deleteItem->setShortcut(Qt::Key_Delete);
1345 collection.addAction("delete_timeline_clip", deleteItem);
1346 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1348 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1349 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1350 editTimelineClipSpeed->setData("change_speed");
1351 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1353 KAction *stickTransition = collection.addAction("auto_transition");
1354 stickTransition->setData(QString("auto"));
1355 stickTransition->setCheckable(true);
1356 stickTransition->setEnabled(false);
1357 stickTransition->setText(i18n("Automatic Transition"));
1358 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1360 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1361 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1362 collection.addAction("group_clip", groupClip);
1363 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1365 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1366 collection.addAction("ungroup_clip", ungroupClip);
1367 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1368 ungroupClip->setData("ungroup_clip");
1369 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1371 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1372 collection.addAction("edit_item_duration", editItemDuration);
1373 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1375 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1376 collection.addAction("clip_in_project_tree", clipInProjectTree);
1377 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1379 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1380 collection.addAction("clip_to_project_tree", clipToProjectTree);
1381 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1383 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1384 insertOvertwrite->setShortcut(Qt::Key_V);
1385 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1386 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1388 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1389 selectTimelineClip->setShortcut(Qt::Key_Plus);
1390 collection.addAction("select_timeline_clip", selectTimelineClip);
1391 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1393 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1394 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1395 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1396 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1398 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1399 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1400 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1401 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1403 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1404 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1405 collection.addAction("select_timeline_transition", selectTimelineTransition);
1406 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1408 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1409 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1410 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1411 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1413 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1414 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1415 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1416 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1418 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1419 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1420 collection.addAction("cut_timeline_clip", cutTimelineClip);
1421 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1423 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1424 collection.addAction("add_clip_marker", addClipMarker);
1425 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1427 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1428 collection.addAction("delete_clip_marker", deleteClipMarker);
1429 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1431 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1432 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1433 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1435 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1436 editClipMarker->setData(QString("edit_marker"));
1437 collection.addAction("edit_clip_marker", editClipMarker);
1438 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1440 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1441 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1442 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1443 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1445 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1446 collection.addAction("split_audio", splitAudio);
1447 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1449 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1450 collection.addAction("clip_audio_only", audioOnly);
1451 audioOnly->setData("clip_audio_only");
1452 audioOnly->setCheckable(true);
1454 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1455 collection.addAction("clip_video_only", videoOnly);
1456 videoOnly->setData("clip_video_only");
1457 videoOnly->setCheckable(true);
1459 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1460 collection.addAction("clip_audio_and_video", audioAndVideo);
1461 audioAndVideo->setData("clip_audio_and_video");
1462 audioAndVideo->setCheckable(true);
1464 m_clipTypeGroup = new QActionGroup(this);
1465 m_clipTypeGroup->addAction(audioOnly);
1466 m_clipTypeGroup->addAction(videoOnly);
1467 m_clipTypeGroup->addAction(audioAndVideo);
1468 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1469 m_clipTypeGroup->setEnabled(false);
1471 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1472 collection.addAction("insert_space", insertSpace);
1473 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1475 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1476 collection.addAction("delete_space", removeSpace);
1477 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1479 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1480 collection.addAction("insert_track", insertTrack);
1481 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1483 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1484 collection.addAction("delete_track", deleteTrack);
1485 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1487 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1488 collection.addAction("config_tracks", configTracks);
1489 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1491 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1492 collection.addAction("add_guide", addGuide);
1493 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1495 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1496 collection.addAction("delete_guide", delGuide);
1497 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1499 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1500 collection.addAction("edit_guide", editGuide);
1501 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1503 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1504 collection.addAction("delete_all_guides", delAllGuides);
1505 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1507 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1508 collection.addAction("paste_effects", pasteEffects);
1509 pasteEffects->setData("paste_effects");
1510 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1512 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1513 collection.addAction("show_timeline", showTimeline);
1514 showTimeline->setCheckable(true);
1515 showTimeline->setChecked(true);
1516 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1518 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1519 collection.addAction("show_titlebars", showTitleBar);
1520 showTitleBar->setCheckable(true);
1521 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1522 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1523 slotShowTitleBars(KdenliveSettings::showtitlebars());
1525 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1526 KStandardAction::quit(this, SLOT(close()), collection);
1527 KStandardAction::open(this, SLOT(openFile()), collection);
1528 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1529 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1530 KStandardAction::openNew(this, SLOT(newFile()), collection);
1531 // TODO: make the following connection to slotEditKeys work
1532 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1533 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1534 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1535 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1536 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1537 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1539 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1540 undo->setEnabled(false);
1541 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1543 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1544 redo->setEnabled(false);
1545 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1548 //TODO: Add status tooltip to actions ?
1549 connect(collection, SIGNAL(actionHovered(QAction*)),
1550 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1553 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1554 collection.addAction("add_clip", addClip);
1555 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1557 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1558 collection.addAction("add_color_clip", addColorClip);
1559 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1561 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1562 collection.addAction("add_slide_clip", addSlideClip);
1563 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1565 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1566 collection.addAction("add_text_clip", addTitleClip);
1567 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1569 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1570 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1571 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1573 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1574 collection.addAction("add_folder", addFolderButton);
1575 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1577 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1578 collection.addAction("clip_properties", clipProperties);
1579 clipProperties->setData("clip_properties");
1580 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1581 clipProperties->setEnabled(false);
1583 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1584 collection.addAction("edit_clip", openClip);
1585 openClip->setData("edit_clip");
1586 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1587 openClip->setEnabled(false);
1589 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1590 collection.addAction("delete_clip", deleteClip);
1591 deleteClip->setData("delete_clip");
1592 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1593 deleteClip->setEnabled(false);
1595 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1596 collection.addAction("reload_clip", reloadClip);
1597 reloadClip->setData("reload_clip");
1598 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1599 reloadClip->setEnabled(false);
1601 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1602 collection.addAction("proxy_clip", proxyClip);
1603 proxyClip->setData("proxy_clip");
1604 proxyClip->setCheckable(true);
1605 proxyClip->setChecked(false);
1606 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1608 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1609 collection.addAction("stopmotion", stopMotion);
1610 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1612 QMenu *addClips = new QMenu();
1613 addClips->addAction(addClip);
1614 addClips->addAction(addColorClip);
1615 addClips->addAction(addSlideClip);
1616 addClips->addAction(addTitleClip);
1617 addClips->addAction(addTitleTemplateClip);
1618 addClips->addAction(addFolderButton);
1620 addClips->addAction(reloadClip);
1621 addClips->addAction(proxyClip);
1622 addClips->addAction(clipProperties);
1623 addClips->addAction(openClip);
1624 addClips->addAction(deleteClip);
1625 m_projectList->setupMenu(addClips, addClip);
1627 // Setup effects and transitions actions.
1628 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1629 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1630 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1631 m_transitions = new KAction*[transitions.count()];
1632 for (int i = 0; i < transitions.count(); i++) {
1633 QStringList effectInfo = transitions.effectIdInfo(i);
1634 m_transitions[i] = new KAction(effectInfo.at(0), this);
1635 m_transitions[i]->setData(effectInfo);
1636 m_transitions[i]->setIconVisibleInMenu(false);
1637 QString id = effectInfo.at(2);
1638 if (id.isEmpty()) id = effectInfo.at(1);
1639 transitionActions->addAction("transition_" + id, m_transitions[i]);
1641 //m_effectsActionCollection->readSettings();
1645 void MainWindow::slotDisplayActionMessage(QAction *a)
1647 statusBar()->showMessage(a->data().toString(), 3000);
1650 void MainWindow::loadLayouts()
1652 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1653 if (m_loadLayout == NULL || saveLayout == NULL) return;
1654 KSharedConfigPtr config = KGlobal::config();
1655 KConfigGroup layoutGroup(config, "Layouts");
1656 QStringList entries = layoutGroup.keyList();
1657 QList<QAction *> loadActions = m_loadLayout->actions();
1658 QList<QAction *> saveActions = saveLayout->actions();
1659 for (int i = 1; i < 5; i++) {
1660 // Rename the layouts actions
1661 foreach(const QString & key, entries) {
1662 if (key.endsWith(QString("_%1").arg(i))) {
1663 // Found previously saved layout
1664 QString layoutName = key.section("_", 0, -2);
1665 for (int j = 0; j < loadActions.count(); j++) {
1666 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1667 loadActions[j]->setText(layoutName);
1668 loadActions[j]->setData(key);
1672 for (int j = 0; j < saveActions.count(); j++) {
1673 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1674 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1675 saveActions[j]->setData(key);
1684 void MainWindow::slotLoadLayout(QAction *action)
1686 if (!action) return;
1687 QString layoutId = action->data().toString();
1688 if (layoutId.isEmpty()) return;
1689 KSharedConfigPtr config = KGlobal::config();
1690 KConfigGroup layouts(config, "Layouts");
1691 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1692 restoreState(state);
1695 void MainWindow::slotSaveLayout(QAction *action)
1697 QString originallayoutName = action->data().toString();
1698 int layoutId = originallayoutName.section('_', -1).toInt();
1700 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1701 if (layoutName.isEmpty()) return;
1702 KSharedConfigPtr config = KGlobal::config();
1703 KConfigGroup layouts(config, "Layouts");
1704 layouts.deleteEntry(originallayoutName);
1706 QByteArray st = saveState();
1707 layoutName.append("_" + QString::number(layoutId));
1708 layouts.writeEntry(layoutName, st.toBase64());
1712 void MainWindow::saveOptions()
1714 KdenliveSettings::self()->writeConfig();
1715 KSharedConfigPtr config = KGlobal::config();
1716 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1717 KConfigGroup treecolumns(config, "Project Tree");
1718 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1722 void MainWindow::readOptions()
1724 KSharedConfigPtr config = KGlobal::config();
1725 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1726 KConfigGroup initialGroup(config, "version");
1727 bool upgrade = false;
1728 if (initialGroup.exists()) {
1729 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1733 if (initialGroup.readEntry("version") == "0.7") {
1734 //Add new settings from 0.7.1
1735 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1736 QString path = QDir::homePath() + "/kdenlive";
1737 if (KStandardDirs::makeDir(path) == false) {
1738 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1739 } else KdenliveSettings::setDefaultprojectfolder(path);
1745 if (!initialGroup.exists() || upgrade) {
1746 // this is our first run, show Wizard
1747 Wizard *w = new Wizard(upgrade, this);
1748 if (w->exec() == QDialog::Accepted && w->isOk()) {
1749 w->adjustSettings();
1750 initialGroup.writeEntry("version", version);
1756 KConfigGroup treecolumns(config, "Project Tree");
1757 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1758 if (!state.isEmpty())
1759 m_projectList->setHeaderInfo(state);
1762 void MainWindow::slotRunWizard()
1764 Wizard *w = new Wizard(false, this);
1765 if (w->exec() == QDialog::Accepted && w->isOk()) {
1766 w->adjustSettings();
1771 void MainWindow::newFile(bool showProjectSettings, bool force)
1773 if (!m_timelineArea->isEnabled() && !force)
1775 m_fileRevert->setEnabled(false);
1776 QString profileName = KdenliveSettings::default_profile();
1777 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1778 QMap <QString, QString> documentProperties;
1779 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1780 if (!showProjectSettings) {
1781 // set up default properties
1782 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1783 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1784 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1785 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1786 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1787 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1788 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1789 if (!KdenliveSettings::activatetabs())
1790 if (!closeCurrentDocument())
1793 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1794 if (w->exec() != QDialog::Accepted)
1796 if (!KdenliveSettings::activatetabs())
1797 if (!closeCurrentDocument())
1799 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1800 slotSwitchVideoThumbs();
1801 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1802 slotSwitchAudioThumbs();
1803 profileName = w->selectedProfile();
1804 projectFolder = w->selectedFolder();
1805 projectTracks = w->tracks();
1806 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1807 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1808 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1809 documentProperties.insert("proxyparams", w->proxyParams());
1810 documentProperties.insert("proxyextension", w->proxyExtension());
1811 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1812 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1815 m_timelineArea->setEnabled(true);
1816 m_projectList->setEnabled(true);
1818 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1819 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1821 TrackView *trackView = new TrackView(doc, &ok, this);
1822 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1825 //m_timelineArea->setEnabled(false);
1826 //m_projectList->setEnabled(false);
1830 if (m_timelineArea->count() == 1) {
1831 connectDocumentInfo(doc);
1832 connectDocument(trackView, doc);
1834 m_timelineArea->setTabBarHidden(false);
1835 m_monitorManager->activateMonitor("clip");
1836 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1839 void MainWindow::activateDocument()
1841 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1842 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1843 KdenliveDoc *currentDoc = currentTab->document();
1844 connectDocumentInfo(currentDoc);
1845 connectDocument(currentTab, currentDoc);
1848 bool MainWindow::closeCurrentDocument(bool saveChanges)
1850 QWidget *w = m_timelineArea->currentWidget();
1851 if (!w) return true;
1852 // closing current document
1853 int ix = m_timelineArea->currentIndex() + 1;
1854 if (ix == m_timelineArea->count()) ix = 0;
1855 m_timelineArea->setCurrentIndex(ix);
1856 TrackView *tabToClose = (TrackView *) w;
1857 KdenliveDoc *docToClose = tabToClose->document();
1858 if (docToClose && docToClose->isModified() && saveChanges) {
1860 if (m_activeDocument->url().fileName().isEmpty())
1861 message = i18n("Save changes to document?");
1863 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1864 switch (KMessageBox::warningYesNoCancel(this, message)) {
1865 case KMessageBox::Yes :
1866 // save document here. If saving fails, return false;
1867 if (saveFile() == false) return false;
1869 case KMessageBox::Cancel :
1876 m_clipMonitor->slotSetClipProducer(NULL);
1877 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1878 if (m_timelineArea->count() == 1) {
1879 m_timelineArea->setTabBarHidden(true);
1880 m_closeAction->setEnabled(false);
1882 if (docToClose == m_activeDocument) {
1883 delete m_activeDocument;
1884 m_activeDocument = NULL;
1885 m_effectStack->clear();
1886 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1890 if (w == m_activeTimeline) {
1891 delete m_activeTimeline;
1892 m_activeTimeline = NULL;
1899 bool MainWindow::saveFileAs(const QString &outputFileName)
1901 QString currentSceneList;
1902 m_monitorManager->stopActiveMonitor();
1904 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1907 // Save timeline thumbnails
1908 m_activeTimeline->projectView()->saveThumbnails();
1909 m_activeDocument->setUrl(KUrl(outputFileName));
1910 if (m_activeDocument->m_autosave == NULL) {
1911 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1912 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1913 setCaption(m_activeDocument->description());
1914 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1915 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1916 m_activeDocument->setModified(false);
1917 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1918 m_fileRevert->setEnabled(true);
1919 m_undoView->stack()->setClean();
1923 bool MainWindow::saveFileAs()
1925 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1926 if (outputFile.isEmpty()) {
1929 if (QFile::exists(outputFile)) {
1930 // Show the file dialog again if the user does not want to overwrite the file
1931 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1932 return saveFileAs();
1934 return saveFileAs(outputFile);
1937 bool MainWindow::saveFile()
1939 if (!m_activeDocument) return true;
1940 if (m_activeDocument->url().isEmpty()) {
1941 return saveFileAs();
1943 bool result = saveFileAs(m_activeDocument->url().path());
1944 m_activeDocument->m_autosave->resize(0);
1949 void MainWindow::openFile()
1951 if (!m_startUrl.isEmpty()) {
1952 openFile(m_startUrl);
1953 m_startUrl = KUrl();
1956 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1957 if (url.isEmpty()) return;
1958 m_fileOpenRecent->addUrl(url);
1962 void MainWindow::openLastFile()
1964 KSharedConfigPtr config = KGlobal::config();
1965 KUrl::List urls = m_fileOpenRecent->urls();
1966 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1967 if (urls.isEmpty()) newFile(false);
1968 else openFile(urls.last());
1971 void MainWindow::openFile(const KUrl &url)
1973 // Make sure the url is a Kdenlive project file
1974 KMimeType::Ptr mime = KMimeType::findByUrl(url);
1975 if (mime.data()->is("application/x-compressed-tar")) {
1976 // Opening a compressed project file, we need to process it
1977 kDebug()<<"Opening archive, processing";
1978 ArchiveWidget *ar = new ArchiveWidget(url);
1979 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
1983 if (!url.fileName().endsWith(".kdenlive")) {
1984 // This is not a Kdenlive project file, abort loading
1985 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
1989 // Check if the document is already opened
1990 const int ct = m_timelineArea->count();
1991 bool isOpened = false;
1993 for (i = 0; i < ct; i++) {
1994 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1995 KdenliveDoc *doc = tab->document();
1996 if (doc->url() == url) {
2002 m_timelineArea->setCurrentIndex(i);
2006 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2008 // Check for backup file
2009 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2010 if (!staleFiles.isEmpty()) {
2011 if (KMessageBox::questionYesNo(this,
2012 i18n("Auto-saved files exist. Do you want to recover them now?"),
2013 i18n("File Recovery"),
2014 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2015 recoverFiles(staleFiles);
2018 // remove the stale files
2019 foreach(KAutoSaveFile * stale, staleFiles) {
2020 stale->open(QIODevice::ReadWrite);
2025 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2026 m_messageLabel->repaint();
2027 doOpenFile(url, NULL);
2030 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2032 if (!m_timelineArea->isEnabled()) return;
2033 m_fileRevert->setEnabled(true);
2035 // Recreate stopmotion widget on document change
2037 delete m_stopmotion;
2038 m_stopmotion = NULL;
2042 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2043 progressDialog.setAllowCancel(false);
2044 progressDialog.progressBar()->setMaximum(4);
2045 progressDialog.show();
2046 progressDialog.progressBar()->setValue(0);
2047 qApp->processEvents();
2050 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
2052 progressDialog.progressBar()->setValue(1);
2053 progressDialog.progressBar()->setMaximum(4);
2054 progressDialog.setLabelText(i18n("Loading project"));
2055 qApp->processEvents();
2057 if (stale == NULL) {
2058 stale = new KAutoSaveFile(url, doc);
2059 doc->m_autosave = stale;
2061 doc->m_autosave = stale;
2062 doc->setUrl(stale->managedFile());
2063 doc->setModified(true);
2064 stale->setParent(doc);
2066 connectDocumentInfo(doc);
2068 progressDialog.progressBar()->setValue(2);
2069 qApp->processEvents();
2072 TrackView *trackView = new TrackView(doc, &ok, this);
2074 progressDialog.progressBar()->setValue(3);
2075 qApp->processEvents();
2077 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2079 m_timelineArea->setEnabled(false);
2080 m_projectList->setEnabled(false);
2081 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2082 slotGotProgressInfo(QString(), -1);
2083 newFile(false, true);
2086 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2087 trackView->setDuration(trackView->duration());
2088 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2090 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2091 slotGotProgressInfo(QString(), -1);
2092 m_projectMonitor->adjustRulerSize(trackView->duration());
2093 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2094 progressDialog.progressBar()->setValue(4);
2095 if (openBackup) slotOpenBackupDialog(url);
2098 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2100 foreach(KAutoSaveFile * stale, staleFiles) {
2101 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2102 // show an error message; we could not steal the lockfile
2103 // maybe another application got to the file before us?
2107 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2108 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2109 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2110 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2114 void MainWindow::parseProfiles(const QString &mltPath)
2116 //KdenliveSettings::setDefaulttmpfolder();
2117 if (!mltPath.isEmpty()) {
2118 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2119 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2122 if (KdenliveSettings::mltpath().isEmpty())
2123 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2125 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2126 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2127 if (!QFile::exists(meltPath))
2128 meltPath = KStandardDirs::findExe("melt");
2129 KdenliveSettings::setRendererpath(meltPath);
2132 if (KdenliveSettings::rendererpath().isEmpty()) {
2133 // Cannot find the MLT melt renderer, ask for location
2134 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2135 if (getUrl->exec() == QDialog::Rejected) {
2138 KUrl rendererPath = getUrl->selectedUrl();
2140 if (rendererPath.isEmpty()) ::exit(0);
2141 KdenliveSettings::setRendererpath(rendererPath.path());
2144 QStringList profilesFilter;
2145 profilesFilter << "*";
2146 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2147 if (profilesList.isEmpty()) {
2148 // Cannot find MLT path, try finding melt
2149 QString profilePath = KdenliveSettings::rendererpath();
2150 if (!profilePath.isEmpty()) {
2151 profilePath = profilePath.section('/', 0, -3);
2152 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2153 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2155 if (profilesList.isEmpty()) {
2156 // Cannot find the MLT profiles, ask for location
2157 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2158 getUrl->fileDialog()->setMode(KFile::Directory);
2159 if (getUrl->exec() == QDialog::Rejected) {
2162 KUrl mltPath = getUrl->selectedUrl();
2164 if (mltPath.isEmpty()) ::exit(0);
2165 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2166 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2170 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2172 // Parse again MLT profiles to build a list of available video formats
2173 if (profilesList.isEmpty()) parseProfiles();
2177 void MainWindow::slotEditProfiles()
2179 ProfilesDialog *w = new ProfilesDialog;
2180 if (w->exec() == QDialog::Accepted) {
2181 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2182 if (d) d->checkProfile();
2187 void MainWindow::slotDetectAudioDriver()
2189 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2190 leading to no audio output, see bug #934 */
2192 //decide which audio driver is really best, in some cases SDL is wrong
2193 if (KdenliveSettings::audiodrivername().isEmpty()) {
2195 KProcess readProcess;
2196 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2197 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2198 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2199 readProcess.setProgram("pactl", QStringList() << "stat");
2200 readProcess.execute(2000); // Kill it after 2 seconds
2202 QString result = QString(readProcess.readAllStandardOutput());
2203 kDebug() << "// / / / / / READING PACTL: ";
2205 if (!result.isEmpty()) {
2207 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2211 KdenliveSettings::setAutoaudiodrivername(driver);
2215 void MainWindow::slotEditProjectSettings()
2217 QPoint p = m_activeDocument->getTracksCount();
2218 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2219 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2221 if (w->exec() == QDialog::Accepted) {
2222 QString profile = w->selectedProfile();
2223 m_activeDocument->setProjectFolder(w->selectedFolder());
2225 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2227 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2228 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2229 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2230 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2231 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2232 m_activeDocument->setModified();
2233 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2234 if (m_activeDocument->clipManager()->clipsCount() > 0 && KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) == KMessageBox::Yes) {
2235 //TODO: rebuild all proxies
2236 //m_projectList->rebuildProxies();
2239 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2240 m_activeDocument->setModified();
2241 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2243 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2244 m_activeDocument->setModified();
2245 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2247 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2248 m_activeDocument->setModified();
2249 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2251 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2252 m_activeDocument->setModified();
2253 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2255 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2256 m_activeDocument->setModified();
2257 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2259 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2260 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2261 m_activeDocument->setModified();
2262 slotUpdateProxySettings();
2268 void MainWindow::slotDisableProxies()
2270 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2271 m_activeDocument->setModified();
2272 slotUpdateProxySettings();
2275 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2277 // Recreate the stopmotion widget if profile changes
2279 delete m_stopmotion;
2280 m_stopmotion = NULL;
2283 // Deselect current effect / transition
2284 m_effectStack->slotClipItemSelected(NULL, 0);
2285 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2286 m_clipMonitor->slotSetClipProducer(NULL);
2287 bool updateFps = m_activeDocument->setProfilePath(profile);
2288 KdenliveSettings::setCurrent_profile(profile);
2289 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2290 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2292 m_activeDocument->clipManager()->clearUnusedProducers();
2293 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2294 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2295 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2296 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2297 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2298 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2299 if (updateFps) m_activeTimeline->updateProjectFps();
2300 m_activeDocument->clipManager()->clearCache();
2301 m_activeTimeline->updateProfile();
2302 m_activeDocument->setModified(true);
2303 m_commandStack->activeStack()->clear();
2304 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2305 slotUpdateMousePosition(0);
2306 // We need to desactivate & reactivate monitors to get a refresh
2307 //m_monitorManager->switchMonitors();
2311 void MainWindow::slotRenderProject()
2313 if (!m_renderWidget) {
2314 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2315 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2316 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2317 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2318 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2319 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2320 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2321 if (m_activeDocument) {
2322 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2323 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2324 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2325 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2328 slotCheckRenderStatus();
2329 m_renderWidget->show();
2330 m_renderWidget->showNormal();
2332 // What are the following lines supposed to do?
2333 //m_activeTimeline->tracksNumber();
2334 //m_renderWidget->enableAudio(false);
2335 //m_renderWidget->export_audio;
2338 void MainWindow::slotCheckRenderStatus()
2340 // Make sure there are no missing clips
2342 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2345 void MainWindow::setRenderingProgress(const QString &url, int progress)
2348 m_renderWidget->setRenderJob(url, progress);
2351 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2354 m_renderWidget->setRenderStatus(url, status, error);
2357 void MainWindow::slotCleanProject()
2359 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2360 m_projectList->cleanup();
2363 void MainWindow::slotUpdateMousePosition(int pos)
2365 if (m_activeDocument)
2366 switch (m_timecodeFormat->currentIndex()) {
2368 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2371 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2375 void MainWindow::slotUpdateDocumentState(bool modified)
2377 if (!m_activeDocument) return;
2378 setCaption(m_activeDocument->description(), modified);
2379 m_saveAction->setEnabled(modified);
2381 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2382 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2384 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2385 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2389 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2391 if (m_activeDocument) {
2392 if (m_activeDocument == doc) return;
2393 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2395 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2398 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2400 //m_projectMonitor->stop();
2401 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2402 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2403 if (m_activeDocument) {
2404 if (m_activeDocument == doc) return;
2405 if (m_activeTimeline) {
2406 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2407 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2408 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2409 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2410 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2411 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2412 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2413 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2415 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2417 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2418 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2419 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2420 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2421 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2422 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2423 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2424 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2425 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2426 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2427 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2428 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2429 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2430 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2431 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2432 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2433 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2434 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2435 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2436 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2437 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2438 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2439 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2440 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2441 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2442 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2443 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2444 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2445 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2446 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2447 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2448 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2449 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2450 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2451 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&)), this, SLOT(slotUpdateClip(const QString &)));
2452 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2453 m_effectStack->clear();
2455 //m_activeDocument->setRenderer(NULL);
2456 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2457 m_clipMonitor->stop();
2459 KdenliveSettings::setCurrent_profile(doc->profilePath());
2460 KdenliveSettings::setProject_fps(doc->fps());
2461 m_monitorManager->resetProfiles(doc->timecode());
2462 m_projectList->setDocument(doc);
2463 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2464 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2465 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2466 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2467 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
2469 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2470 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2471 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2473 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2476 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2477 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2478 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2479 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2480 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2481 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2482 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2483 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2484 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2485 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2486 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2487 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2488 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2489 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2491 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2492 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2493 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2494 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2495 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2497 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2498 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2499 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2501 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2503 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2504 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2505 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2506 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2508 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2509 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2510 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2511 m_zoomSlider->setValue(doc->zoom().x());
2512 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2513 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2514 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2515 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2517 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2518 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2520 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2521 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2523 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2524 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2525 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2526 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2527 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2528 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2529 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2530 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2531 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2532 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2533 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2535 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2536 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2537 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2538 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
2539 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2540 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2543 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2544 m_activeTimeline = trackView;
2545 if (m_renderWidget) {
2546 slotCheckRenderStatus();
2547 m_renderWidget->setProfile(doc->mltProfile());
2548 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2549 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2550 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2552 //doc->setRenderer(m_projectMonitor->render);
2553 m_commandStack->setActiveStack(doc->commandStack());
2554 KdenliveSettings::setProject_display_ratio(doc->dar());
2555 //doc->clipManager()->checkAudioThumbs();
2557 //m_overView->setScene(trackView->projectScene());
2558 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2559 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2561 setCaption(doc->description(), doc->isModified());
2562 m_saveAction->setEnabled(doc->isModified());
2563 m_normalEditTool->setChecked(true);
2564 m_activeDocument = doc;
2565 m_activeTimeline->updateProjectFps();
2566 m_activeDocument->checkProjectClips();
2568 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2570 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2571 slotUpdateMousePosition(0);
2572 m_monitorManager->activateMonitor("clip");
2573 m_projectList->slotClipSelected();
2574 // set tool to select tool
2575 m_buttonSelectTool->setChecked(true);
2578 void MainWindow::slotZoneMoved(int start, int end)
2580 m_activeDocument->setZone(start, end);
2581 m_projectMonitor->slotZoneMoved(start, end);
2584 void MainWindow::slotGuidesUpdated()
2587 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2590 void MainWindow::slotEditKeys()
2592 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2593 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2594 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2598 void MainWindow::slotPreferences(int page, int option)
2601 * An instance of your dialog could be already created and could be
2602 * cached, in which case you want to display the cached dialog
2603 * instead of creating another one
2605 if (m_stopmotion) m_stopmotion->slotLive(false);
2606 if (KConfigDialog::showDialog("settings")) {
2607 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2608 if (page != -1) d->showPage(page, option);
2612 // KConfigDialog didn't find an instance of this dialog, so lets
2615 // Get the mappable actions in localized form
2616 QMap<QString, QString> actions;
2617 KActionCollection* collection = actionCollection();
2618 foreach (const QString& action_name, m_action_names) {
2619 actions[collection->action(action_name)->text()] = action_name;
2622 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2623 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2624 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2626 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2629 if (page != -1) dialog->showPage(page, option);
2632 void MainWindow::slotUpdateCaptureFolder()
2636 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2637 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2641 void MainWindow::updateConfiguration()
2643 //TODO: we should apply settings to all projects, not only the current one
2644 if (m_activeTimeline) {
2645 m_activeTimeline->refresh();
2646 m_activeTimeline->projectView()->checkAutoScroll();
2647 m_activeTimeline->checkTrackHeight();
2648 if (m_activeDocument)
2649 m_activeDocument->clipManager()->checkAudioThumbs();
2651 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2652 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2653 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2654 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2656 // Update list of transcoding profiles
2658 #ifndef NO_JOGSHUTTLE
2659 activateShuttleDevice();
2660 #endif /* NO_JOGSHUTTLE */
2664 void MainWindow::slotSwitchSplitAudio()
2666 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2667 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2670 void MainWindow::slotSwitchVideoThumbs()
2672 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2673 if (m_activeTimeline)
2674 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2675 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2678 void MainWindow::slotSwitchAudioThumbs()
2680 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2681 if (m_activeTimeline) {
2682 m_activeTimeline->refresh();
2683 m_activeTimeline->projectView()->checkAutoScroll();
2684 if (m_activeDocument)
2685 m_activeDocument->clipManager()->checkAudioThumbs();
2687 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2690 void MainWindow::slotSwitchMarkersComments()
2692 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2693 if (m_activeTimeline)
2694 m_activeTimeline->refresh();
2695 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2698 void MainWindow::slotSwitchSnap()
2700 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2701 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2705 void MainWindow::slotDeleteItem()
2707 if (QApplication::focusWidget() &&
2708 QApplication::focusWidget()->parentWidget() &&
2709 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2710 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2711 m_projectList->slotRemoveClip();
2714 QWidget *widget = QApplication::focusWidget();
2716 if (widget == m_effectStackDock) {
2717 m_effectStack->slotItemDel();
2720 widget = widget->parentWidget();
2723 // effect stack has no focus
2724 if (m_activeTimeline)
2725 m_activeTimeline->projectView()->deleteSelectedClips();
2729 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2731 if (m_clipMonitor->isActive())
2732 m_clipMonitor->checkOverlay();
2733 m_clipMonitor->updateMarkers(clip);
2736 void MainWindow::slotAddClipMarker()
2738 DocClipBase *clip = NULL;
2740 if (m_projectMonitor->isActive()) {
2741 if (m_activeTimeline) {
2742 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2744 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2745 clip = item->baseClip();
2749 clip = m_clipMonitor->activeClip();
2750 pos = m_clipMonitor->position();
2753 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2756 QString id = clip->getId();
2757 CommentedTime marker(pos, i18n("Marker"));
2758 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2759 if (d.exec() == QDialog::Accepted)
2760 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2763 void MainWindow::slotDeleteClipMarker()
2765 DocClipBase *clip = NULL;
2767 if (m_projectMonitor->isActive()) {
2768 if (m_activeTimeline) {
2769 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2771 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2772 clip = item->baseClip();
2776 clip = m_clipMonitor->activeClip();
2777 pos = m_clipMonitor->position();
2780 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2784 QString id = clip->getId();
2785 QString comment = clip->markerComment(pos);
2786 if (comment.isEmpty()) {
2787 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2790 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2793 void MainWindow::slotDeleteAllClipMarkers()
2795 DocClipBase *clip = NULL;
2796 if (m_projectMonitor->isActive()) {
2797 if (m_activeTimeline) {
2798 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2800 clip = item->baseClip();
2804 clip = m_clipMonitor->activeClip();
2807 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2810 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2813 void MainWindow::slotEditClipMarker()
2815 DocClipBase *clip = NULL;
2817 if (m_projectMonitor->isActive()) {
2818 if (m_activeTimeline) {
2819 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2821 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2822 clip = item->baseClip();
2826 clip = m_clipMonitor->activeClip();
2827 pos = m_clipMonitor->position();
2830 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2834 QString id = clip->getId();
2835 QString oldcomment = clip->markerComment(pos);
2836 if (oldcomment.isEmpty()) {
2837 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2841 CommentedTime marker(pos, oldcomment);
2842 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2843 if (d.exec() == QDialog::Accepted) {
2844 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2845 if (d.newMarker().time() != pos) {
2846 // remove old marker
2847 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2852 void MainWindow::slotAddMarkerGuideQuickly()
2854 if (!m_activeTimeline || !m_activeDocument)
2857 if (m_clipMonitor->isActive()) {
2858 DocClipBase *clip = m_clipMonitor->activeClip();
2859 GenTime pos = m_clipMonitor->position();
2862 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2866 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2868 m_activeTimeline->projectView()->slotAddGuide(false);
2872 void MainWindow::slotAddGuide()
2874 if (m_activeTimeline)
2875 m_activeTimeline->projectView()->slotAddGuide();
2878 void MainWindow::slotInsertSpace()
2880 if (m_activeTimeline)
2881 m_activeTimeline->projectView()->slotInsertSpace();
2884 void MainWindow::slotRemoveSpace()
2886 if (m_activeTimeline)
2887 m_activeTimeline->projectView()->slotRemoveSpace();
2890 void MainWindow::slotInsertTrack(int ix)
2892 m_projectMonitor->activateMonitor();
2893 if (m_activeTimeline)
2894 m_activeTimeline->projectView()->slotInsertTrack(ix);
2895 if (m_activeDocument)
2896 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2899 void MainWindow::slotDeleteTrack(int ix)
2901 m_projectMonitor->activateMonitor();
2902 if (m_activeTimeline)
2903 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2904 if (m_activeDocument)
2905 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2908 void MainWindow::slotConfigTrack(int ix)
2910 m_projectMonitor->activateMonitor();
2911 if (m_activeTimeline)
2912 m_activeTimeline->projectView()->slotConfigTracks(ix);
2913 if (m_activeDocument)
2914 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2917 void MainWindow::slotEditGuide()
2919 if (m_activeTimeline)
2920 m_activeTimeline->projectView()->slotEditGuide();
2923 void MainWindow::slotDeleteGuide()
2925 if (m_activeTimeline)
2926 m_activeTimeline->projectView()->slotDeleteGuide();
2929 void MainWindow::slotDeleteAllGuides()
2931 if (m_activeTimeline)
2932 m_activeTimeline->projectView()->slotDeleteAllGuides();
2935 void MainWindow::slotCutTimelineClip()
2937 if (m_activeTimeline)
2938 m_activeTimeline->projectView()->cutSelectedClips();
2941 void MainWindow::slotInsertClipOverwrite()
2943 if (m_activeTimeline) {
2944 QStringList data = m_clipMonitor->getZoneInfo();
2945 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2949 void MainWindow::slotSelectTimelineClip()
2951 if (m_activeTimeline)
2952 m_activeTimeline->projectView()->selectClip(true);
2955 void MainWindow::slotSelectTimelineTransition()
2957 if (m_activeTimeline)
2958 m_activeTimeline->projectView()->selectTransition(true);
2961 void MainWindow::slotDeselectTimelineClip()
2963 if (m_activeTimeline)
2964 m_activeTimeline->projectView()->selectClip(false, true);
2967 void MainWindow::slotDeselectTimelineTransition()
2969 if (m_activeTimeline)
2970 m_activeTimeline->projectView()->selectTransition(false, true);
2973 void MainWindow::slotSelectAddTimelineClip()
2975 if (m_activeTimeline)
2976 m_activeTimeline->projectView()->selectClip(true, true);
2979 void MainWindow::slotSelectAddTimelineTransition()
2981 if (m_activeTimeline)
2982 m_activeTimeline->projectView()->selectTransition(true, true);
2985 void MainWindow::slotGroupClips()
2987 if (m_activeTimeline)
2988 m_activeTimeline->projectView()->groupClips();
2991 void MainWindow::slotUnGroupClips()
2993 if (m_activeTimeline)
2994 m_activeTimeline->projectView()->groupClips(false);
2997 void MainWindow::slotEditItemDuration()
2999 if (m_activeTimeline)
3000 m_activeTimeline->projectView()->editItemDuration();
3003 void MainWindow::slotAddProjectClip(KUrl url)
3005 if (m_activeDocument)
3006 m_activeDocument->slotAddClipFile(url, QString());
3009 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3011 if (m_activeDocument)
3012 m_activeDocument->slotAddClipList(urls, QString());
3015 void MainWindow::slotAddTransition(QAction *result)
3017 if (!result) return;
3018 QStringList info = result->data().toStringList();
3019 if (info.isEmpty()) return;
3020 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3021 if (m_activeTimeline && !transition.isNull()) {
3022 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3026 void MainWindow::slotAddVideoEffect(QAction *result)
3028 if (!result) return;
3029 const int EFFECT_VIDEO = 1;
3030 const int EFFECT_AUDIO = 2;
3031 QStringList info = result->data().toStringList();
3033 if (info.isEmpty() || info.size() < 3) return;
3034 QDomElement effect ;
3035 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3036 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3037 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3038 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3040 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3041 if (!effect.isNull()) slotAddEffect(effect);
3042 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3046 void MainWindow::slotZoomIn()
3048 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3049 slotShowZoomSliderToolTip();
3052 void MainWindow::slotZoomOut()
3054 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3055 slotShowZoomSliderToolTip();
3058 void MainWindow::slotFitZoom()
3060 if (m_activeTimeline)
3061 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3064 void MainWindow::slotSetZoom(int value)
3066 value = qMax(m_zoomSlider->minimum(), value);
3067 value = qMin(m_zoomSlider->maximum(), value);
3069 if (m_activeTimeline)
3070 m_activeTimeline->slotChangeZoom(value);
3072 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3073 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3074 slotUpdateZoomSliderToolTip(value);
3076 m_zoomSlider->blockSignals(true);
3077 m_zoomSlider->setValue(value);
3078 m_zoomSlider->blockSignals(false);
3081 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3083 if (zoomlevel != -1)
3084 slotUpdateZoomSliderToolTip(zoomlevel);
3086 QPoint global = m_zoomSlider->rect().topLeft();
3087 global.ry() += m_zoomSlider->height() / 2;
3088 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3089 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3092 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3094 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3097 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3099 m_statusProgressBar->setValue(progress);
3100 if (progress >= 0) {
3101 if (!message.isEmpty())
3102 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3103 m_statusProgressBar->setVisible(true);
3104 } else if (progress == -2) {
3105 if (!message.isEmpty())
3106 m_messageLabel->setMessage(message, ErrorMessage);
3107 m_statusProgressBar->setVisible(false);
3109 m_messageLabel->setMessage(QString(), DefaultMessage);
3110 m_statusProgressBar->setVisible(false);
3114 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3116 if (clip->clipType() == TEXT) {
3117 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3118 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3119 // template text clip
3121 // Get the list of existing templates
3123 filter << "*.kdenlivetitle";
3124 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3126 QDialog *dia = new QDialog(this);
3127 Ui::TemplateClip_UI dia_ui;
3128 dia_ui.setupUi(dia);
3130 const QString templatePath = clip->getProperty("resource");
3131 for (int i = 0; i < templateFiles.size(); ++i) {
3132 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3133 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3135 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3136 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3137 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3138 //warning: setting base directory doesn't work??
3139 KUrl startDir(titlepath);
3140 dia_ui.template_list->fileDialog()->setUrl(startDir);
3141 dia_ui.description->setText(clip->getProperty("description"));
3142 if (dia->exec() == QDialog::Accepted) {
3143 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3144 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3146 QMap <QString, QString> newprops;
3148 if (KUrl(textTemplate).path() != templatePath) {
3149 // The template was changed
3150 newprops.insert("resource", textTemplate);
3153 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3154 newprops.insert("description", dia_ui.description->toPlainText());
3157 QString newtemplate = newprops.value("xmltemplate");
3158 if (newtemplate.isEmpty()) newtemplate = templatePath;
3160 // template modified we need to update xmldata
3161 QString description = newprops.value("description");
3162 if (description.isEmpty()) description = clip->getProperty("description");
3163 else newprops.insert("templatetext", description);
3164 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3165 if (!newprops.isEmpty()) {
3166 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3167 m_activeDocument->commandStack()->push(command);
3173 QString path = clip->getProperty("resource");
3174 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3176 doc.setContent(clip->getProperty("xmldata"));
3177 dia_ui->setXml(doc);
3178 if (dia_ui->exec() == QDialog::Accepted) {
3179 QMap <QString, QString> newprops;
3180 newprops.insert("xmldata", dia_ui->xml().toString());
3181 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3182 // duration changed, we need to update duration
3183 newprops.insert("out", QString::number(dia_ui->outPoint()));
3184 int currentLength = QString(clip->producerProperty("length")).toInt();
3185 if (currentLength <= dia_ui->outPoint())
3186 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3187 else newprops.insert("length", clip->producerProperty("length"));
3189 if (!path.isEmpty()) {
3190 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3191 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) {
3192 // save to external file
3193 dia_ui->saveTitle(path);
3194 } else newprops.insert("resource", QString());
3196 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3197 m_activeDocument->commandStack()->push(command);
3198 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3199 m_activeDocument->setModified(true);
3203 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3207 // any type of clip but a title
3208 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3209 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3210 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3211 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)));
3216 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3218 if (newprops.isEmpty()) return;
3219 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3220 m_activeDocument->commandStack()->push(command);
3221 m_activeDocument->setModified();
3224 // update clip occurences in timeline
3225 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3230 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3232 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3233 if (dia.exec() == QDialog::Accepted) {
3234 QUndoCommand *command = new QUndoCommand();
3235 command->setText(i18n("Edit clips"));
3236 QMap <QString, QString> newImageProps = dia.properties();
3237 // Transparency setting applies only for images
3238 QMap <QString, QString> newProps = newImageProps;
3239 newProps.remove("transparency");
3241 for (int i = 0; i < cliplist.count(); i++) {
3242 DocClipBase *clip = cliplist.at(i);
3243 if (clip->clipType() == IMAGE)
3244 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3246 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3248 m_activeDocument->commandStack()->push(command);
3249 for (int i = 0; i < cliplist.count(); i++)
3250 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3254 void MainWindow::customEvent(QEvent* e)
3256 if (e->type() == QEvent::User)
3257 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3259 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3265 m_effectStack->raiseWindow(m_effectStackDock);
3268 void MainWindow::slotActivateTransitionView(Transition *t)
3271 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3274 void MainWindow::slotSnapRewind()
3276 if (m_projectMonitor->isActive()) {
3277 if (m_activeTimeline)
3278 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3280 m_clipMonitor->slotSeekToPreviousSnap();
3284 void MainWindow::slotSnapForward()
3286 if (m_projectMonitor->isActive()) {
3287 if (m_activeTimeline)
3288 m_activeTimeline->projectView()->slotSeekToNextSnap();
3290 m_clipMonitor->slotSeekToNextSnap();
3294 void MainWindow::slotClipStart()
3296 if (m_projectMonitor->isActive()) {
3297 if (m_activeTimeline)
3298 m_activeTimeline->projectView()->clipStart();
3302 void MainWindow::slotClipEnd()
3304 if (m_projectMonitor->isActive()) {
3305 if (m_activeTimeline)
3306 m_activeTimeline->projectView()->clipEnd();
3310 void MainWindow::slotZoneStart()
3312 if (m_projectMonitor->isActive())
3313 m_projectMonitor->slotZoneStart();
3315 m_clipMonitor->slotZoneStart();
3318 void MainWindow::slotZoneEnd()
3320 if (m_projectMonitor->isActive())
3321 m_projectMonitor->slotZoneEnd();
3323 m_clipMonitor->slotZoneEnd();
3326 void MainWindow::slotChangeTool(QAction * action)
3328 if (action == m_buttonSelectTool)
3329 slotSetTool(SELECTTOOL);
3330 else if (action == m_buttonRazorTool)
3331 slotSetTool(RAZORTOOL);
3332 else if (action == m_buttonSpacerTool)
3333 slotSetTool(SPACERTOOL);
3336 void MainWindow::slotChangeEdit(QAction * action)
3338 if (!m_activeTimeline)
3341 if (action == m_overwriteEditTool)
3342 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3343 else if (action == m_insertEditTool)
3344 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3346 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3349 void MainWindow::slotSetTool(PROJECTTOOL tool)
3351 if (m_activeDocument && m_activeTimeline) {
3352 //m_activeDocument->setTool(tool);
3356 message = i18n("Ctrl + click to use spacer on current track only");
3359 message = i18n("Click on a clip to cut it");
3362 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3365 m_messageLabel->setMessage(message, InformationMessage);
3366 m_activeTimeline->projectView()->setTool(tool);
3370 void MainWindow::slotCopy()
3372 if (m_activeDocument && m_activeTimeline)
3373 m_activeTimeline->projectView()->copyClip();
3376 void MainWindow::slotPaste()
3378 if (m_activeDocument && m_activeTimeline)
3379 m_activeTimeline->projectView()->pasteClip();
3382 void MainWindow::slotPasteEffects()
3384 if (m_activeDocument && m_activeTimeline)
3385 m_activeTimeline->projectView()->pasteClipEffects();
3388 void MainWindow::slotFind()
3390 if (!m_activeDocument || !m_activeTimeline) return;
3391 m_projectSearch->setEnabled(false);
3392 m_findActivated = true;
3393 m_findString.clear();
3394 m_activeTimeline->projectView()->initSearchStrings();
3395 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3396 m_findTimer.start(5000);
3397 qApp->installEventFilter(this);
3400 void MainWindow::slotFindNext()
3402 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3403 statusBar()->showMessage(i18n("Found: %1", m_findString));
3405 statusBar()->showMessage(i18n("Reached end of project"));
3406 m_findTimer.start(4000);
3409 void MainWindow::findAhead()
3411 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3412 m_projectSearchNext->setEnabled(true);
3413 statusBar()->showMessage(i18n("Found: %1", m_findString));
3415 m_projectSearchNext->setEnabled(false);
3416 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3420 void MainWindow::findTimeout()
3422 m_projectSearchNext->setEnabled(false);
3423 m_findActivated = false;
3424 m_findString.clear();
3425 statusBar()->showMessage(i18n("Find stopped"), 3000);
3426 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3427 m_projectSearch->setEnabled(true);
3428 removeEventFilter(this);
3431 void MainWindow::slotClipInTimeline(const QString &clipId)
3433 if (m_activeTimeline && m_activeDocument) {
3434 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3436 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3437 inTimelineMenu->clear();
3439 QList <QAction *> actionList;
3441 for (int i = 0; i < matching.count(); ++i) {
3442 QString track = QString::number(matching.at(i).track);
3443 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3445 QAction *a = new QAction(track + ": " + start, this);
3446 a->setData(QStringList() << track << start);
3447 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3448 while (j < actionList.count()) {
3449 if (actionList.at(j)->text() > a->text()) break;
3452 actionList.insert(j, a);
3454 inTimelineMenu->addActions(actionList);
3456 if (matching.empty())
3457 inTimelineMenu->setEnabled(false);
3459 inTimelineMenu->setEnabled(true);
3463 void MainWindow::slotClipInProjectTree()
3465 if (m_activeTimeline) {
3466 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3467 if (clipIds.isEmpty())
3469 m_projectListDock->raise();
3470 for (int i = 0; i < clipIds.count(); i++)
3471 m_projectList->selectItemById(clipIds.at(i));
3472 if (m_projectMonitor->isActive())
3473 slotSwitchMonitors();
3477 /*void MainWindow::slotClipToProjectTree()
3479 if (m_activeTimeline) {
3480 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3481 if (clips.isEmpty()) return;
3482 for (int i = 0; i < clips.count(); i++) {
3483 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3485 //m_projectList->selectItemById(clipIds.at(i));
3489 void MainWindow::slotSelectClipInTimeline()
3491 if (m_activeTimeline) {
3492 QAction *action = qobject_cast<QAction *>(sender());
3493 QStringList data = action->data().toStringList();
3494 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3498 void MainWindow::keyPressEvent(QKeyEvent *ke)
3500 if (m_findActivated) {
3501 if (ke->key() == Qt::Key_Backspace) {
3502 m_findString = m_findString.left(m_findString.length() - 1);
3504 if (!m_findString.isEmpty())
3509 m_findTimer.start(4000);
3512 } else if (ke->key() == Qt::Key_Escape) {
3516 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3517 m_findString += ke->text();
3521 m_findTimer.start(4000);
3526 KXmlGuiWindow::keyPressEvent(ke);
3531 /** Gets called when the window gets hidden */
3532 void MainWindow::hideEvent(QHideEvent */*event*/)
3534 if (isMinimized() && m_monitorManager)
3535 m_monitorManager->stopActiveMonitor();
3538 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3540 if (m_findActivated) {
3541 if (event->type() == QEvent::ShortcutOverride) {
3542 QKeyEvent* ke = (QKeyEvent*) event;
3543 if (ke->text().trimmed().isEmpty()) return false;
3550 // pass the event on to the parent class
3551 return QMainWindow::eventFilter(obj, event);
3556 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3558 KDialog *dialog = new KDialog(this);
3559 dialog->setCaption("Save clip zone");
3560 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3562 QWidget *widget = new QWidget(dialog);
3563 dialog->setMainWidget(widget);
3565 QVBoxLayout *vbox = new QVBoxLayout(widget);
3566 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3567 if (path.isEmpty()) {
3568 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3569 if (baseClip == NULL) tmppath.append("untitled.mlt");
3571 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3573 path = KUrl(tmppath);
3575 KUrlRequester *url = new KUrlRequester(path, this);
3576 url->setFilter("video/mlt-playlist");
3577 QLabel *label2 = new QLabel(i18n("Description:"), this);
3578 KLineEdit *edit = new KLineEdit(this);
3579 vbox->addWidget(label1);
3580 vbox->addWidget(url);
3581 vbox->addWidget(label2);
3582 vbox->addWidget(edit);
3583 if (dialog->exec() == QDialog::Accepted) {
3584 if (QFile::exists(url->url().path())) {
3585 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3586 slotSaveZone(render, zone, baseClip, url->url());
3590 if (baseClip && !baseClip->fileURL().isEmpty()) {
3591 // create zone from clip url, so that we don't have problems with proxy clips
3593 #if QT_VERSION >= 0x040600
3594 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3595 env.remove("MLT_PROFILE");
3596 p.setProcessEnvironment(env);
3598 QStringList env = QProcess::systemEnvironment();
3599 env << "MLT_PROFILE='\0'";
3600 p.setEnvironment(env);
3602 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3603 if (!p.waitForStarted(3000)) {
3604 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3606 else if (!p.waitForFinished(5000)) {
3607 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3610 else render->saveZone(url->url(), edit->text(), zone);
3615 void MainWindow::slotSetInPoint()
3617 if (m_clipMonitor->isActive()) {
3618 m_clipMonitor->slotSetZoneStart();
3620 m_projectMonitor->slotSetZoneStart();
3624 void MainWindow::slotSetOutPoint()
3626 if (m_clipMonitor->isActive()) {
3627 m_clipMonitor->slotSetZoneEnd();
3629 m_projectMonitor->slotSetZoneEnd();
3633 void MainWindow::slotResizeItemStart()
3635 if (m_activeTimeline)
3636 m_activeTimeline->projectView()->setInPoint();
3639 void MainWindow::slotResizeItemEnd()
3641 if (m_activeTimeline)
3642 m_activeTimeline->projectView()->setOutPoint();
3645 int MainWindow::getNewStuff(const QString &configFile)
3647 KNS3::Entry::List entries;
3648 #if KDE_IS_VERSION(4,3,80)
3649 KNS3::DownloadDialog dialog(configFile);
3651 entries = dialog.changedEntries();
3652 foreach(const KNS3::Entry & entry, entries) {
3653 if (entry.status() == KNS3::Entry::Installed)
3654 kDebug() << "// Installed files: " << entry.installedFiles();
3657 KNS::Engine engine(0);
3658 if (engine.init(configFile))
3659 entries = engine.downloadDialogModal(this);
3660 foreach(KNS::Entry * entry, entries) {
3661 if (entry->status() == KNS::Entry::Installed)
3662 kDebug() << "// Installed files: " << entry->installedFiles();
3664 #endif /* KDE_IS_VERSION(4,3,80) */
3665 return entries.size();
3668 void MainWindow::slotGetNewTitleStuff()
3670 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3671 TitleWidget::refreshTitleTemplates();
3674 void MainWindow::slotGetNewLumaStuff()
3676 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3677 initEffects::refreshLumas();
3678 m_activeTimeline->projectView()->reloadTransitionLumas();
3682 void MainWindow::slotGetNewRenderStuff()
3684 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3686 m_renderWidget->reloadProfiles();
3689 void MainWindow::slotGetNewMltProfileStuff()
3691 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3692 // update the list of profiles in settings dialog
3693 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3699 void MainWindow::slotAutoTransition()
3701 if (m_activeTimeline)
3702 m_activeTimeline->projectView()->autoTransition();
3705 void MainWindow::slotSplitAudio()
3707 if (m_activeTimeline)
3708 m_activeTimeline->projectView()->splitAudio();
3711 void MainWindow::slotUpdateClipType(QAction *action)
3713 if (m_activeTimeline) {
3714 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3715 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3716 else m_activeTimeline->projectView()->setAudioAndVideo();
3720 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3722 // We must stop the monitors since we create a new on in the dvd wizard
3723 m_clipMonitor->stop();
3724 m_projectMonitor->stop();
3725 DvdWizard w(url, profile, this);
3727 m_projectMonitor->start();
3730 void MainWindow::slotShowTimeline(bool show)
3732 if (show == false) {
3733 m_timelineState = saveState();
3734 centralWidget()->setHidden(true);
3736 centralWidget()->setHidden(false);
3737 restoreState(m_timelineState);
3741 void MainWindow::slotMaximizeCurrent(bool)
3743 //TODO: is there a way to maximize current widget?
3745 m_timelineState = saveState();
3746 QWidget *par = focusWidget()->parentWidget();
3747 while (par->parentWidget() && par->parentWidget() != this)
3748 par = par->parentWidget();
3749 kDebug() << "CURRENT WIDGET: " << par->objectName();
3752 void MainWindow::loadTranscoders()
3754 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3757 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3758 KConfigGroup transConfig(config, "Transcoding");
3760 QMap< QString, QString > profiles = transConfig.entryMap();
3761 QMapIterator<QString, QString> i(profiles);
3762 while (i.hasNext()) {
3764 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3765 QAction *a = transMenu->addAction(i.key());
3767 if (data.count() > 1)
3768 a->setToolTip(data.at(1));
3769 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3773 void MainWindow::slotTranscode(KUrl::List urls)
3778 if (urls.isEmpty()) {
3779 QAction *action = qobject_cast<QAction *>(sender());
3780 QStringList data = action->data().toStringList();
3781 params = data.at(0);
3782 if (data.count() > 1) desc = data.at(1);
3783 if (data.count() > 2) condition = data.at(2);
3784 urls << m_projectList->getConditionalUrls(condition);
3785 urls.removeAll(KUrl());
3787 if (urls.isEmpty()) {
3788 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3791 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3792 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3794 //QProcess::startDetached("ffmpeg", parameters);
3797 void MainWindow::slotTranscodeClip()
3799 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3800 if (urls.isEmpty()) return;
3801 slotTranscode(urls);
3804 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3806 if (m_activeDocument == NULL) return;
3807 QMapIterator<QString, QString> i(props);
3808 while (i.hasNext()) {
3810 m_activeDocument->setDocumentProperty(i.key(), i.value());
3812 m_activeDocument->setModified(true);
3816 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3818 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3820 QString playlistPath;
3823 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3824 QString path = m_renderWidget->getFreeScriptName();
3825 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3826 if (!ok || scriptPath.isEmpty()) return;
3827 scriptPath.prepend(scriptsFolder);
3828 QFile f(scriptPath);
3830 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3833 playlistPath = scriptPath + ".mlt";
3835 KTemporaryFile temp;
3836 temp.setAutoRemove(false);
3837 temp.setSuffix(".mlt");
3839 playlistPath = temp.fileName();
3841 QString playlistContent = m_projectMonitor->sceneList();
3842 if (!chapterFile.isEmpty()) {
3845 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3847 in = m_activeTimeline->inPoint();
3848 out = m_activeTimeline->outPoint();
3851 QDomElement chapters = doc.createElement("chapters");
3852 chapters.setAttribute("fps", m_activeDocument->fps());
3853 doc.appendChild(chapters);
3855 QDomElement guidesxml = m_activeDocument->guidesXml();
3856 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3857 for (int i = 0; i < nodes.count(); i++) {
3858 QDomElement e = nodes.item(i).toElement();
3860 QString comment = e.attribute("comment");
3861 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3862 if (time >= in && time < out) {
3863 if (zoneOnly) time = time - in;
3864 QDomElement chapter = doc.createElement("chapter");
3865 chapters.appendChild(chapter);
3866 chapter.setAttribute("title", comment);
3867 chapter.setAttribute("time", time);
3871 if (chapters.childNodes().count() > 0) {
3872 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3873 // Always insert a guide in pos 0
3874 QDomElement chapter = doc.createElement("chapter");
3875 chapters.insertBefore(chapter, QDomNode());
3876 chapter.setAttribute("title", i18n("Start"));
3877 chapter.setAttribute("time", "0");
3879 // save chapters file
3880 QFile file(chapterFile);
3881 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3882 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3884 file.write(doc.toString().toUtf8());
3885 if (file.error() != QFile::NoError) {
3886 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3893 if (m_renderWidget->automaticAudioExport()) {
3894 exportAudio = m_activeTimeline->checkProjectAudio();
3895 } else exportAudio = m_renderWidget->selectedAudioExport();
3897 // Set playlist audio volume to 100%
3899 doc.setContent(playlistContent);
3900 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3901 if (!tractor.isNull()) {
3902 QDomNodeList props = tractor.elementsByTagName("property");
3903 for (int i = 0; i < props.count(); i++) {
3904 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3905 props.at(i).firstChild().setNodeValue("1");
3911 // Do we want proxy rendering
3912 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3913 QString root = doc.documentElement().attribute("root");
3915 // replace proxy clips with originals
3916 QMap <QString, QString> proxies = m_projectList->getProxies();
3918 QDomNodeList producers = doc.elementsByTagName("producer");
3919 QString producerResource;
3921 for (uint n = 0; n < producers.length(); n++) {
3922 QDomElement e = producers.item(n).toElement();
3923 producerResource = EffectsList::property(e, "resource");
3924 if (producerResource.isEmpty()) continue;
3925 if (!producerResource.startsWith("/")) {
3926 producerResource.prepend(root + "/");
3928 if (producerResource.contains('?')) {
3929 // slowmotion producer
3930 suffix = "?" + producerResource.section('?', 1);
3931 producerResource = producerResource.section('?', 0, 0);
3933 else suffix.clear();
3934 if (!producerResource.isEmpty()) {
3935 if (proxies.contains(producerResource)) {
3936 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3937 // We need to delete the "aspect_ratio" property because proxy clips
3938 // sometimes have different ratio than original clips
3939 EffectsList::removeProperty(e, "aspect_ratio");
3944 /*QMapIterator<QString, QString> i(proxies);
3945 while (i.hasNext()) {
3947 // Replace all keys with their values (proxy path with original path)
3948 QString key = i.key();
3949 playlistContent.replace(key, i.value());
3950 if (!root.isEmpty() && key.startsWith(root)) {
3951 // in case the resource path in MLT playlist is relative
3952 key.remove(0, root.count() + 1);
3953 playlistContent.replace(key, i.value());
3957 playlistContent = doc.toString();
3959 // Do save scenelist
3960 QFile file(playlistPath);
3961 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3962 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3965 file.write(playlistContent.toUtf8());
3966 if (file.error() != QFile::NoError) {
3967 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3972 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3975 void MainWindow::slotUpdateTimecodeFormat(int ix)
3977 KdenliveSettings::setFrametimecode(ix == 1);
3978 m_clipMonitor->updateTimecodeFormat();
3979 m_projectMonitor->updateTimecodeFormat();
3980 m_transitionConfig->updateTimecodeFormat();
3981 m_effectStack->updateTimecodeFormat();
3982 //m_activeTimeline->projectView()->clearSelection();
3983 m_activeTimeline->updateRuler();
3986 void MainWindow::slotRemoveFocus()
3988 statusBar()->setFocus();
3989 statusBar()->clearFocus();
3992 void MainWindow::slotRevert()
3994 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;
3995 KUrl url = m_activeDocument->url();
3996 if (closeCurrentDocument(false))
3997 doOpenFile(url, NULL);
4001 void MainWindow::slotShutdown()
4003 if (m_activeDocument) m_activeDocument->setModified(false);
4005 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4006 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4007 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4008 smserver.call("logout", 1, 2, 2);
4009 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4010 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4011 smserver.call("Shutdown");
4015 void MainWindow::slotUpdateTrackInfo()
4017 if (m_activeDocument)
4018 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4021 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4023 // Load the theme file
4025 if (action == NULL) theme = themename;
4026 else theme = action->data().toString();
4027 KdenliveSettings::setColortheme(theme);
4028 // Make palette for all widgets.
4029 QPalette plt = kapp->palette();
4030 if (theme.isEmpty()) {
4031 plt = QApplication::desktop()->palette();
4033 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4035 #if KDE_IS_VERSION(4,6,3)
4036 plt = KGlobalSettings::createNewApplicationPalette(config);
4038 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4039 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4040 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4041 QPalette::Disabled };
4042 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4043 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4045 for ( int i = 0; i < 3 ; i++ ) {
4046 QPalette::ColorGroup state = states[i];
4047 KColorScheme schemeView(state, KColorScheme::View, config);
4048 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4049 KColorScheme schemeButton(state, KColorScheme::Button, config);
4050 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4052 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4053 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4054 plt.setBrush( state, QPalette::Base, schemeView.background() );
4055 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4056 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4057 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4058 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4059 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4060 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4061 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4063 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4064 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4065 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4066 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4067 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4069 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4070 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4071 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4076 kapp->setPalette(plt);
4077 const QObjectList children = statusBar()->children();
4079 foreach(QObject * child, children) {
4080 if (child->isWidgetType())
4081 ((QWidget*)child)->setPalette(plt);
4082 const QObjectList subchildren = child->children();
4083 foreach(QObject * subchild, subchildren) {
4084 if (subchild->isWidgetType())
4085 ((QWidget*)subchild)->setPalette(plt);
4088 if (m_activeTimeline) {
4089 m_activeTimeline->projectView()->updatePalette();
4094 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4096 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4097 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4098 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4099 const QSize bitsSize(24, 2);
4100 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4101 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4103 QPixmap pixmap(23, 16);
4104 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4106 KConfigGroup group(config, "WM");
4107 QPainter p(&pixmap);
4108 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4109 p.fillRect(1, 1, 7, 7, windowScheme.background());
4110 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4112 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4113 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4114 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4116 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4117 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4119 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4120 p.fillRect(1, 8, 7, 7, viewScheme.background());
4121 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4123 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4124 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4125 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4127 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4128 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4134 void MainWindow::slotSwitchMonitors()
4136 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4137 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4138 else m_projectList->focusTree();
4141 void MainWindow::slotSwitchFullscreen()
4143 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4144 else m_clipMonitor->slotSwitchFullScreen();
4147 void MainWindow::slotInsertZoneToTree()
4149 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4150 QStringList info = m_clipMonitor->getZoneInfo();
4151 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4154 void MainWindow::slotInsertZoneToTimeline()
4156 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4157 QStringList info = m_clipMonitor->getZoneInfo();
4158 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4162 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4164 if (m_activeDocument && m_activeTimeline) {
4165 if (!ids.isEmpty()) {
4166 for (int i = 0; i < ids.size(); ++i) {
4167 m_activeTimeline->slotDeleteClip(ids.at(i));
4169 m_activeDocument->clipManager()->slotDeleteClips(ids);
4171 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4172 m_activeDocument->setModified(true);
4176 void MainWindow::slotShowTitleBars(bool show)
4178 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4179 for (int i = 0; i < docks.count(); i++) {
4180 QDockWidget* dock = docks.at(i);
4182 dock->setTitleBarWidget(0);
4184 if (!dock->isFloating()) {
4185 dock->setTitleBarWidget(new QWidget);
4189 KdenliveSettings::setShowtitlebars(show);
4192 void MainWindow::slotSwitchTitles()
4194 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4197 QString MainWindow::getMimeType(bool open)
4199 QString mimetype = "application/x-kdenlive";
4200 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4202 mimetype = "*.kdenlive";
4203 if (open) mimetype.append(" *.tar.gz");
4205 else if (open) mimetype.append(" application/x-compressed-tar");
4209 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4212 m_projectMonitor->render->sendFrameForAnalysis = true;
4215 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4216 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4223 qDebug() << "Any scope accepting new frames? " << request;
4226 m_projectMonitor->render->sendFrameForAnalysis = false;
4230 void MainWindow::slotUpdateGfxScopeFrameRequest()
4232 // We need a delay to make sure widgets are hidden after a close event for example
4233 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4236 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4239 bool request = false;
4240 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4241 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4242 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4248 if (!m_projectMonitor->effectSceneDisplayed()) {
4249 m_projectMonitor->render->sendFrameForAnalysis = false;
4251 m_clipMonitor->render->sendFrameForAnalysis = false;
4253 m_recMonitor->analyseFrames(false);
4255 m_projectMonitor->render->sendFrameForAnalysis = true;
4256 m_clipMonitor->render->sendFrameForAnalysis = true;
4258 m_recMonitor->analyseFrames(true);
4262 void MainWindow::slotUpdateAudioScopeFrameRequest()
4264 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4267 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4269 bool request = false;
4270 for (int i = 0; i < m_audioScopesList.count(); i++) {
4271 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4272 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4277 // Handle audio signal separately (no common interface)
4278 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4279 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4283 qDebug() << "Scopes Requesting Audio data: " << request;
4285 KdenliveSettings::setMonitor_audio(request);
4286 m_monitorManager->slotUpdateAudioMonitoring();
4289 void MainWindow::slotUpdateColorScopes()
4291 bool request = false;
4292 kDebug()<<"// UPDATE SCOPES";
4293 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4294 // Check if we need the renderer to send a new frame for update
4295 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4296 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4298 if (request && m_monitorManager->activeRenderer()) {
4299 m_monitorManager->activeRenderer()->sendFrameUpdate();
4303 void MainWindow::slotClearColorScopes()
4305 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4306 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4310 void MainWindow::slotOpenStopmotion()
4312 if (m_stopmotion == NULL) {
4313 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4314 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4315 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4316 // Check if we need the renderer to send a new frame for update
4317 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4318 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4319 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4322 m_stopmotion->show();
4325 void MainWindow::slotDeleteClip(const QString &id)
4327 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4328 for (int i = 0; i < list.size(); ++i) {
4329 list.at(i)->disableClipId(id);
4331 m_projectList->slotDeleteClip(id);
4334 void MainWindow::slotUpdateProxySettings()
4336 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4337 if (KdenliveSettings::enableproxy())
4338 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4339 m_projectList->updateProxyConfig();
4342 void MainWindow::slotInsertNotesTimecode()
4344 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4345 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4346 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4349 void MainWindow::slotArchiveProject()
4351 QList <DocClipBase*> list = m_projectList->documentClipList();
4352 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4353 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4358 void MainWindow::slotOpenBackupDialog(const KUrl url)
4363 kDebug()<<"// BACKUP URL: "<<url.path();
4364 if (!url.isEmpty()) {
4365 // we could not open the project file, guess where the backups are
4366 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4370 projectFolder = m_activeDocument->projectFolder();
4371 projectFile = m_activeDocument->url();
4372 projectId = m_activeDocument->getDocumentProperty("documentid");
4375 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4376 if (dia->exec() == QDialog::Accepted) {
4377 QString requestedBackup = dia->selectedFile();
4378 m_activeDocument->backupLastSavedVersion(projectFile.path());
4379 closeCurrentDocument(false);
4380 doOpenFile(KUrl(requestedBackup), NULL);
4381 m_activeDocument->setUrl(projectFile);
4382 m_activeDocument->setModified(true);
4383 setCaption(m_activeDocument->description());
4388 void MainWindow::slotElapsedTime()
4390 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4393 #include "mainwindow.moc"