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"
68 #include <KApplication>
72 #include <KActionCollection>
73 #include <KActionCategory>
74 #include <KStandardAction>
75 #include <KShortcutsDialog>
76 #include <KFileDialog>
77 #include <KMessageBox>
79 #include <KIO/NetAccess>
82 #include <KConfigDialog>
83 #include <KXMLGUIFactory>
85 #include <kstandarddirs.h>
86 #include <KUrlRequesterDialog>
87 #include <KTemporaryFile>
89 #include <KActionMenu>
91 #include <ktogglefullscreenaction.h>
93 #include <KNotification>
94 #include <KNotifyConfigWidget>
95 #include <knewstuff3/downloaddialog.h>
96 #include <knewstuff3/knewstuffaction.h>
98 #include <KColorScheme>
99 #include <KProgressDialog>
101 #include <QTextStream>
105 #include <QInputDialog>
106 #include <QDesktopWidget>
111 // Uncomment for deeper debugging
112 //#define DEBUG_MAINW
118 static const char version[] = VERSION;
120 static const int ID_TIMELINE_POS = 0;
126 Q_DECLARE_METATYPE(QVector<int16_t>)
129 EffectsList MainWindow::videoEffects;
130 EffectsList MainWindow::audioEffects;
131 EffectsList MainWindow::customEffects;
132 EffectsList MainWindow::transitions;
134 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
135 KXmlGuiWindow(parent),
136 m_activeDocument(NULL),
137 m_activeTimeline(NULL),
139 m_renderWidget(NULL),
140 #ifndef NO_JOGSHUTTLE
143 #endif /* NO_JOGSHUTTLE */
144 m_findActivated(false),
147 qRegisterMetaType<QVector<int16_t> > ();
148 qRegisterMetaType<stringMap> ("stringMap");
149 qRegisterMetaType<audioByteArray> ("audioByteArray");
152 QLocale systemLocale = QLocale();
153 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
154 QLocale::setDefault(systemLocale);
156 // Create DBus interface
157 new MainWindowAdaptor(this);
158 QDBusConnection dbus = QDBusConnection::sessionBus();
159 dbus.registerObject("/MainWindow", this);
161 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
162 setFont(KGlobalSettings::toolBarFont());
163 parseProfiles(MltPath);
164 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
165 m_commandStack = new QUndoGroup;
166 setDockNestingEnabled(true);
167 m_timelineArea = new KTabWidget(this);
168 m_timelineArea->setTabReorderingEnabled(true);
169 m_timelineArea->setTabBarHidden(true);
170 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
171 m_timelineArea->setMinimumHeight(200);
173 QToolButton *closeTabButton = new QToolButton;
174 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
175 closeTabButton->setIcon(KIcon("tab-close"));
176 closeTabButton->adjustSize();
177 closeTabButton->setToolTip(i18n("Close the current tab"));
178 m_timelineArea->setCornerWidget(closeTabButton);
179 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
181 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
182 m_findTimer.setSingleShot(true);
184 // FIXME: the next call returns a newly allocated object, which leaks
185 initEffects::parseEffectFiles();
186 //initEffects::parseCustomEffectsFile();
188 m_monitorManager = new MonitorManager();
190 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
191 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
196 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
197 m_projectListDock->setObjectName("project_tree");
198 m_projectList = new ProjectList();
199 m_projectListDock->setWidget(m_projectList);
200 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
202 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
203 m_clipMonitorDock->setObjectName("clip_monitor");
204 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
205 m_clipMonitorDock->setWidget(m_clipMonitor);
206 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint)));
207 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
209 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
210 m_projectMonitorDock->setObjectName("project_monitor");
211 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
212 m_projectMonitorDock->setWidget(m_projectMonitor);
215 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
216 m_recMonitorDock->setObjectName("record_monitor");
217 m_recMonitor = new RecMonitor("record", m_monitorManager);
218 m_recMonitorDock->setWidget(m_recMonitor);
219 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
220 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
221 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
223 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
225 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
226 m_notesDock->setObjectName("notes_widget");
227 m_notesWidget = new NotesWidget();
228 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
229 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
231 m_notesWidget->setTabChangesFocus(true);
232 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
233 m_notesDock->setWidget(m_notesWidget);
234 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
236 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
237 m_effectStackDock->setObjectName("effect_stack");
238 m_effectStack = new EffectStackView(m_projectMonitor);
239 m_effectStackDock->setWidget(m_effectStack);
240 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
242 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
243 m_transitionConfigDock->setObjectName("transition");
244 m_transitionConfig = new TransitionSettings(m_projectMonitor);
245 m_transitionConfigDock->setWidget(m_transitionConfig);
246 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
248 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
249 m_effectListDock->setObjectName("effect_list");
250 m_effectList = new EffectsListView();
251 m_effectListDock->setWidget(m_effectList);
252 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
254 m_vectorscope = new Vectorscope(m_monitorManager);
255 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
256 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
257 m_vectorscopeDock->setWidget(m_vectorscope);
258 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
259 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
260 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
261 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
262 m_gfxScopesList.append(m_vectorscopeDock);
264 m_waveform = new Waveform(m_monitorManager);
265 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
266 m_waveformDock->setObjectName(m_waveform->widgetName());
267 m_waveformDock->setWidget(m_waveform);
268 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
269 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
270 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
271 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
272 m_gfxScopesList.append(m_waveformDock);
274 m_RGBParade = new RGBParade(m_monitorManager);
275 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
276 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
277 m_RGBParadeDock->setWidget(m_RGBParade);
278 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
279 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
280 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
281 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
282 m_gfxScopesList.append(m_RGBParadeDock);
284 m_histogram = new Histogram(m_monitorManager);
285 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
286 m_histogramDock->setObjectName(m_histogram->widgetName());
287 m_histogramDock->setWidget(m_histogram);
288 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
289 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
290 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
291 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
292 m_gfxScopesList.append(m_histogramDock);
295 m_audiosignal = new AudioSignal;
296 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
297 m_audiosignalDock->setObjectName("audiosignal");
298 m_audiosignalDock->setWidget(m_audiosignal);
299 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
300 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
301 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
303 m_audioSpectrum = new AudioSpectrum();
304 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
305 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
306 m_audioSpectrumDock->setWidget(m_audioSpectrum);
307 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
308 m_audioScopesList.append(m_audioSpectrum);
309 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
310 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
312 m_spectrogram = new Spectrogram();
313 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
314 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
315 m_spectrogramDock->setWidget(m_spectrogram);
316 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
317 m_audioScopesList.append(m_spectrogram);
318 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
319 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
321 // Connect the audio signal to the audio scope slots
323 if (m_projectMonitor) {
324 qDebug() << "project monitor connected";
325 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
326 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
327 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
328 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
329 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
330 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
333 qDebug() << "clip monitor connected";
334 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
335 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
336 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
337 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
338 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
339 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
341 // Ensure connections were set up correctly
346 // Add monitors here to keep them at the right of the window
347 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
348 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
350 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
353 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
354 m_undoViewDock->setObjectName("undo_history");
355 m_undoView = new QUndoView();
356 m_undoView->setCleanIcon(KIcon("edit-clear"));
357 m_undoView->setEmptyLabel(i18n("Clean"));
358 m_undoViewDock->setWidget(m_undoView);
359 m_undoView->setGroup(m_commandStack);
360 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
364 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
367 // Close non-general docks for the initial layout
368 // only show important ones
369 m_histogramDock->close();
370 m_RGBParadeDock->close();
371 m_waveformDock->close();
372 m_vectorscopeDock->close();
374 m_audioSpectrumDock->close();
375 m_spectrogramDock->close();
376 m_audiosignalDock->close();
378 m_undoViewDock->close();
382 /// Tabify Widgets ///
383 tabifyDockWidget(m_effectListDock, m_effectStackDock);
384 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
385 tabifyDockWidget(m_projectListDock, m_notesDock);
387 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
389 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
395 setCentralWidget(m_timelineArea);
398 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
400 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
401 m_fileRevert->setEnabled(false);
403 // Prepare layout actions
404 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
405 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
406 for (int i = 1; i < 5; i++) {
407 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
408 load->setData("_" + QString::number(i));
409 layoutActions->addAction("load_layout" + QString::number(i), load);
410 m_loadLayout->addAction(load);
411 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
412 save->setData("_" + QString::number(i));
413 layoutActions->addAction("save_layout" + QString::number(i), save);
415 layoutActions->addAction("load_layouts", m_loadLayout);
416 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
419 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
420 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
421 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
422 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
423 m_stopmotion_actions->addAction("stopmotion_capture", action);
424 action = new KAction(i18n("Switch live / captured frame"), this);
425 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
426 m_stopmotion_actions->addAction("stopmotion_switch", action);
427 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
428 action->setCheckable(true);
429 action->setChecked(false);
430 m_stopmotion_actions->addAction("stopmotion_overlay", action);
432 // Build effects menu
433 m_effectsMenu = new QMenu(i18n("Add Effect"));
434 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
435 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
436 m_effectsActionCollection->readSettings();
440 // Find QDockWidget tab bars and show / hide widget title bars on right click
441 QList <QTabBar *> tabs = findChildren<QTabBar *>();
442 for (int i = 0; i < tabs.count(); i++) {
443 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
444 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
447 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
448 guiFactory()->addClient(sp);*/
450 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
452 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
455 // Load layout names from config file
461 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
462 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
464 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
465 clipInTimeline->setIcon(KIcon("go-jump"));
466 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
467 static_cast<QMenu*>(factory()->container("transcoders", this)),
470 // build themes menus
471 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
472 QActionGroup *themegroup = new QActionGroup(this);
473 themegroup->setExclusive(true);
474 action = new KAction(i18n("Default"), this);
475 action->setCheckable(true);
476 themegroup->addAction(action);
477 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
479 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
481 for (int i = 0; i < schemeFiles.size(); ++i) {
483 const QString filename = schemeFiles.at(i);
484 const QFileInfo info(filename);
487 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
488 QIcon icon = createSchemePreviewIcon(config);
489 KConfigGroup group(config, "General");
490 const QString name = group.readEntry("Name", info.baseName());
491 action = new KAction(name, this);
492 action->setData(filename);
493 action->setIcon(icon);
494 action->setCheckable(true);
495 themegroup->addAction(action);
496 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
499 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
500 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
501 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
504 action = new QAction(fi.fileName(), this);
505 action->setData(*it);
506 action->setCheckable(true);
507 themegroup->addAction(action);
508 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
510 themesMenu->addActions(themegroup->actions());
511 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
513 // Setup and fill effects and transitions menus.
516 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
517 m->addActions(m_effectsMenu->actions());
520 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
521 for (int i = 0; i < transitions.count(); ++i)
522 m_transitionsMenu->addAction(m_transitions[i]);
524 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
525 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
526 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
528 m_effectStack->setMenu(m_effectsMenu);
530 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
531 const QList<QAction *> viewActions = createPopupMenu()->actions();
532 viewMenu->insertActions(NULL, viewActions);
534 m_timelineContextMenu = new QMenu(this);
535 m_timelineContextClipMenu = new QMenu(this);
536 m_timelineContextTransitionMenu = new QMenu(this);
538 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
539 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
540 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
542 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
543 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
544 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
545 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
546 m_timelineContextClipMenu->addSeparator();
547 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
548 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
549 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
550 m_timelineContextClipMenu->addSeparator();
551 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
552 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
553 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
554 m_timelineContextClipMenu->addSeparator();
556 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
557 m_timelineContextClipMenu->addMenu(markersMenu);
558 m_timelineContextClipMenu->addSeparator();
559 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
560 m_timelineContextClipMenu->addMenu(m_effectsMenu);
562 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
563 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
564 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
566 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
568 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
569 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
570 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
571 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
572 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
573 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
574 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
576 slotConnectMonitors();
578 // Open or create a file. Command line argument passed in Url has
579 // precedence, then "openlastproject", then just a plain empty file.
580 // If opening Url fails, openlastproject will _not_ be used.
581 if (!Url.isEmpty()) {
582 // delay loading so that the window shows up
584 QTimer::singleShot(500, this, SLOT(openFile()));
585 } else if (KdenliveSettings::openlastproject()) {
586 QTimer::singleShot(500, this, SLOT(openLastFile()));
587 } else { //if (m_timelineArea->count() == 0) {
591 if (!clipsToLoad.isEmpty() && m_activeDocument) {
592 QStringList list = clipsToLoad.split(',');
594 foreach(QString path, list) {
595 kDebug() << QDir::current().absoluteFilePath(path);
596 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
598 m_projectList->slotAddClip(urls);
601 #ifndef NO_JOGSHUTTLE
602 activateShuttleDevice();
603 #endif /* NO_JOGSHUTTLE */
604 m_projectListDock->raise();
606 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
607 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
609 // Populate encoding profiles
610 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
611 if (KdenliveSettings::proxyparams().isEmpty()) {
612 KConfigGroup group(&conf, "proxy");
613 QMap< QString, QString > values = group.entryMap();
614 QMapIterator<QString, QString> i(values);
617 QString data = i.value();
618 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
619 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
622 if (KdenliveSettings::v4l_parameters().isEmpty()) {
623 KConfigGroup group(&conf, "video4linux");
624 QMap< QString, QString > values = group.entryMap();
625 QMapIterator<QString, QString> i(values);
628 QString data = i.value();
629 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
630 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
633 if (KdenliveSettings::decklink_parameters().isEmpty()) {
634 KConfigGroup group(&conf, "decklink");
635 QMap< QString, QString > values = group.entryMap();
636 QMapIterator<QString, QString> i(values);
639 QString data = i.value();
640 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
641 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
646 MainWindow::~MainWindow()
651 m_effectStack->slotClipItemSelected(NULL, 0);
652 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
654 if (m_projectMonitor) m_projectMonitor->stop();
655 if (m_clipMonitor) m_clipMonitor->stop();
657 delete m_activeTimeline;
658 delete m_effectStack;
659 delete m_transitionConfig;
660 delete m_activeDocument;
661 delete m_projectMonitor;
662 delete m_clipMonitor;
663 delete m_shortcutRemoveFocus;
664 delete[] m_transitions;
665 Mlt::Factory::close();
669 bool MainWindow::queryClose()
671 if (m_renderWidget) {
672 int waitingJobs = m_renderWidget->waitingJobsCount();
673 if (waitingJobs > 0) {
674 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")))) {
675 case KMessageBox::Yes :
676 // create script with waiting jobs and start it
677 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
679 case KMessageBox::No :
680 // Don't do anything, jobs will be deleted
688 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
689 // warn the user to save if document is modified and we have clips in our project list
690 if (m_activeDocument && m_activeDocument->isModified() &&
691 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
692 !m_projectList->documentClipList().isEmpty())) {
696 if (m_activeDocument->url().fileName().isEmpty())
697 message = i18n("Save changes to document?");
699 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
700 switch (KMessageBox::warningYesNoCancel(this, message)) {
701 case KMessageBox::Yes :
702 // save document here. If saving fails, return false;
704 case KMessageBox::No :
705 // User does not want to save the changes, clear recovery files
706 m_activeDocument->m_autosave->resize(0);
715 void MainWindow::loadPlugins()
717 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
718 populateMenus(plugin);
721 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
723 filters << "libkdenlive*";
724 foreach(const QString & folder, directories) {
725 kDebug() << "Parsing plugin folder: " << folder;
726 QDir pluginsDir(folder);
727 foreach(const QString & fileName,
728 pluginsDir.entryList(filters, QDir::Files)) {
730 * Avoid loading the same plugin twice when there is more than one
733 if (!m_pluginFileNames.contains(fileName)) {
734 kDebug() << "Found plugin: " << fileName;
735 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
736 QObject *plugin = loader.instance();
738 populateMenus(plugin);
739 m_pluginFileNames += fileName;
741 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
747 void MainWindow::populateMenus(QObject *plugin)
749 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
750 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
752 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
756 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
757 QMenu *menu, const char *member,
758 QActionGroup *actionGroup)
760 kDebug() << "// ADD to MENU" << texts;
761 foreach(const QString & text, texts) {
762 QAction *action = new QAction(text, plugin);
763 action->setData(text);
764 connect(action, SIGNAL(triggered()), this, member);
765 menu->addAction(action);
768 action->setCheckable(true);
769 actionGroup->addAction(action);
774 void MainWindow::aboutPlugins()
776 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
781 void MainWindow::generateClip()
783 QAction *action = qobject_cast<QAction *>(sender());
784 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
786 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
787 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
788 if (!clipUrl.isEmpty()) {
789 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
793 void MainWindow::saveProperties(KConfigGroup &config)
795 // save properties here,used by session management
797 KMainWindow::saveProperties(config);
801 void MainWindow::readProperties(const KConfigGroup &config)
803 // read properties here,used by session management
804 KMainWindow::readProperties(config);
805 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
806 openFile(KUrl(Lastproject));
809 void MainWindow::slotReloadEffects()
811 initEffects::parseCustomEffectsFile();
812 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
815 #ifndef NO_JOGSHUTTLE
816 void MainWindow::activateShuttleDevice()
822 if (KdenliveSettings::enableshuttle() == false) return;
824 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
825 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
827 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
828 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
829 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
830 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
831 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
833 #endif /* NO_JOGSHUTTLE */
835 void MainWindow::slotDoAction(const QString& action_name)
837 QAction* action = actionCollection()->action(action_name);
839 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
845 void MainWindow::configureNotifications()
847 KNotifyConfigWidget::configure(this);
850 void MainWindow::slotFullScreen()
852 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
855 void MainWindow::slotAddEffect(const QDomElement effect)
857 if (!m_activeDocument) return;
858 if (effect.isNull()) {
859 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
862 QDomElement effectToAdd = effect.cloneNode().toElement();
864 int ix = m_effectStack->isTrackMode(&ok);
865 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
866 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
869 void MainWindow::slotUpdateClip(const QString &id)
871 if (!m_activeDocument) return;
872 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
874 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
875 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
876 Mlt::Producer *monitorProducer = clip->getCloneProducer();
877 m_clipMonitor->updateClipProducer(monitorProducer);
879 clip->cleanupProducers();
882 void MainWindow::slotConnectMonitors()
884 m_projectList->setRenderer(m_projectMonitor->render);
885 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
886 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
887 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
888 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
889 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
890 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)));
892 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
894 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
896 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
898 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
899 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
901 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
903 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
904 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
907 void MainWindow::slotAdjustClipMonitor()
909 m_clipMonitorDock->updateGeometry();
910 m_clipMonitorDock->adjustSize();
911 m_clipMonitor->resetSize();
914 void MainWindow::slotAdjustProjectMonitor()
916 m_projectMonitorDock->updateGeometry();
917 m_projectMonitorDock->adjustSize();
918 m_projectMonitor->resetSize();
922 class NameGrabbingKActionCollection {
924 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
925 : m_collection(collection), m_action_names(action_names) {
926 m_action_names.clear();
928 KAction* addAction(const QString& action_name) {
929 m_action_names << action_name;
930 return m_collection->addAction(action_name);
932 void addAction(const QString& action_name, QAction* action) {
933 m_action_names << action_name;
934 m_collection->addAction(action_name, action);
936 operator KActionCollection*() { return m_collection; }
937 const QStringList& actionNames() const { return m_action_names; }
939 KActionCollection* m_collection;
940 QStringList& m_action_names;
943 void MainWindow::setupActions()
946 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
947 m_timecodeFormat = new KComboBox(this);
948 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
949 m_timecodeFormat->addItem(i18n("Frames"));
950 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
951 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
953 m_statusProgressBar = new QProgressBar(this);
954 m_statusProgressBar->setMinimum(0);
955 m_statusProgressBar->setMaximum(100);
956 m_statusProgressBar->setMaximumWidth(150);
957 m_statusProgressBar->setVisible(false);
959 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
960 toolbar->setMovable(false);
961 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
962 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
963 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
964 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
965 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
966 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());
967 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
969 //create edit mode buttons
970 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
971 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
972 toolbar->addAction(m_normalEditTool);
973 m_normalEditTool->setCheckable(true);
974 m_normalEditTool->setChecked(true);
976 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
977 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
978 toolbar->addAction(m_overwriteEditTool);
979 m_overwriteEditTool->setCheckable(true);
980 m_overwriteEditTool->setChecked(false);
982 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
983 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
984 toolbar->addAction(m_insertEditTool);
985 m_insertEditTool->setCheckable(true);
986 m_insertEditTool->setChecked(false);
987 // not implemented yet
988 m_insertEditTool->setEnabled(false);
990 QActionGroup *editGroup = new QActionGroup(this);
991 editGroup->addAction(m_normalEditTool);
992 editGroup->addAction(m_overwriteEditTool);
993 editGroup->addAction(m_insertEditTool);
994 editGroup->setExclusive(true);
995 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
996 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
998 toolbar->addSeparator();
1000 // create tools buttons
1001 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1002 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1003 toolbar->addAction(m_buttonSelectTool);
1004 m_buttonSelectTool->setCheckable(true);
1005 m_buttonSelectTool->setChecked(true);
1007 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1008 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1009 toolbar->addAction(m_buttonRazorTool);
1010 m_buttonRazorTool->setCheckable(true);
1011 m_buttonRazorTool->setChecked(false);
1013 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1014 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1015 toolbar->addAction(m_buttonSpacerTool);
1016 m_buttonSpacerTool->setCheckable(true);
1017 m_buttonSpacerTool->setChecked(false);
1019 QActionGroup *toolGroup = new QActionGroup(this);
1020 toolGroup->addAction(m_buttonSelectTool);
1021 toolGroup->addAction(m_buttonRazorTool);
1022 toolGroup->addAction(m_buttonSpacerTool);
1023 toolGroup->setExclusive(true);
1024 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1026 QWidget * actionWidget;
1027 int max = toolbar->iconSizeDefault() + 2;
1028 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1029 actionWidget->setMaximumWidth(max);
1030 actionWidget->setMaximumHeight(max - 4);
1032 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1033 actionWidget->setMaximumWidth(max);
1034 actionWidget->setMaximumHeight(max - 4);
1036 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1037 actionWidget->setMaximumWidth(max);
1038 actionWidget->setMaximumHeight(max - 4);
1040 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1041 actionWidget->setMaximumWidth(max);
1042 actionWidget->setMaximumHeight(max - 4);
1044 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1045 actionWidget->setMaximumWidth(max);
1046 actionWidget->setMaximumHeight(max - 4);
1048 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1049 actionWidget->setMaximumWidth(max);
1050 actionWidget->setMaximumHeight(max - 4);
1052 toolbar->setStyleSheet(style1);
1053 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1055 toolbar->addSeparator();
1056 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1057 toolbar->addAction(m_buttonFitZoom);
1058 m_buttonFitZoom->setCheckable(false);
1060 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1061 toolbar->addAction(m_zoomOut);
1062 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1064 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1065 m_zoomSlider->setMaximum(13);
1066 m_zoomSlider->setPageStep(1);
1067 m_zoomSlider->setInvertedAppearance(true);
1069 m_zoomSlider->setMaximumWidth(150);
1070 m_zoomSlider->setMinimumWidth(100);
1071 toolbar->addWidget(m_zoomSlider);
1073 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1074 toolbar->addAction(m_zoomIn);
1075 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1077 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1078 actionWidget->setMaximumWidth(max);
1079 actionWidget->setMaximumHeight(max - 4);
1080 actionWidget->setStyleSheet(styleBorderless);
1082 actionWidget = toolbar->widgetForAction(m_zoomIn);
1083 actionWidget->setMaximumWidth(max);
1084 actionWidget->setMaximumHeight(max - 4);
1085 actionWidget->setStyleSheet(styleBorderless);
1087 actionWidget = toolbar->widgetForAction(m_zoomOut);
1088 actionWidget->setMaximumWidth(max);
1089 actionWidget->setMaximumHeight(max - 4);
1090 actionWidget->setStyleSheet(styleBorderless);
1092 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1093 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1094 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1095 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1096 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1098 toolbar->addSeparator();
1100 //create automatic audio split button
1101 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1102 toolbar->addAction(m_buttonAutomaticSplitAudio);
1103 m_buttonAutomaticSplitAudio->setCheckable(true);
1104 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1105 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1107 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1108 toolbar->addAction(m_buttonVideoThumbs);
1109 m_buttonVideoThumbs->setCheckable(true);
1110 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1111 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1113 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1114 toolbar->addAction(m_buttonAudioThumbs);
1115 m_buttonAudioThumbs->setCheckable(true);
1116 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1117 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1119 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1120 toolbar->addAction(m_buttonShowMarkers);
1121 m_buttonShowMarkers->setCheckable(true);
1122 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1123 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1125 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1126 toolbar->addAction(m_buttonSnap);
1127 m_buttonSnap->setCheckable(true);
1128 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1129 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1131 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1132 actionWidget->setMaximumWidth(max);
1133 actionWidget->setMaximumHeight(max - 4);
1135 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1136 actionWidget->setMaximumWidth(max);
1137 actionWidget->setMaximumHeight(max - 4);
1139 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1140 actionWidget->setMaximumWidth(max);
1141 actionWidget->setMaximumHeight(max - 4);
1143 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1144 actionWidget->setMaximumWidth(max);
1145 actionWidget->setMaximumHeight(max - 4);
1147 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1148 actionWidget->setMaximumWidth(max);
1149 actionWidget->setMaximumHeight(max - 4);
1151 m_messageLabel = new StatusBarMessageLabel(this);
1152 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1154 statusBar()->addWidget(m_messageLabel, 10);
1155 statusBar()->addWidget(m_statusProgressBar, 0);
1156 statusBar()->addPermanentWidget(toolbar);
1157 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1158 statusBar()->addPermanentWidget(m_timecodeFormat);
1159 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1161 collection.addAction("normal_mode", m_normalEditTool);
1162 collection.addAction("overwrite_mode", m_overwriteEditTool);
1163 collection.addAction("insert_mode", m_insertEditTool);
1164 collection.addAction("select_tool", m_buttonSelectTool);
1165 collection.addAction("razor_tool", m_buttonRazorTool);
1166 collection.addAction("spacer_tool", m_buttonSpacerTool);
1168 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1169 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1170 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1171 collection.addAction("show_markers", m_buttonShowMarkers);
1172 collection.addAction("snap", m_buttonSnap);
1173 collection.addAction("zoom_fit", m_buttonFitZoom);
1174 collection.addAction("zoom_in", m_zoomIn);
1175 collection.addAction("zoom_out", m_zoomOut);
1177 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1178 collection.addAction("project_find", m_projectSearch);
1179 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1180 m_projectSearch->setShortcut(Qt::Key_Slash);
1182 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1183 collection.addAction("project_find_next", m_projectSearchNext);
1184 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1185 m_projectSearchNext->setShortcut(Qt::Key_F3);
1186 m_projectSearchNext->setEnabled(false);
1188 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1189 collection.addAction("manage_profiles", profilesAction);
1190 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1192 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1193 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1194 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1195 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1197 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1198 collection.addAction("run_wizard", wizAction);
1199 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1201 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1202 collection.addAction("project_settings", projectAction);
1203 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1205 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1206 collection.addAction("open_backup", backupAction);
1207 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1209 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1210 collection.addAction("project_render", projectRender);
1211 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1212 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1214 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1215 collection.addAction("project_clean", projectClean);
1216 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1218 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1219 collection.addAction("project_adjust_profile", projectAdjust);
1220 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1222 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1223 KShortcut playShortcut;
1224 playShortcut.setPrimary(Qt::Key_Space);
1225 playShortcut.setAlternate(Qt::Key_K);
1226 monitorPlay->setShortcut(playShortcut);
1227 collection.addAction("monitor_play", monitorPlay);
1228 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1230 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1231 collection.addAction("monitor_pause", monitorPause);
1232 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1234 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1235 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1236 collection.addAction("monitor_play_zone", m_playZone);
1237 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1239 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1240 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1241 collection.addAction("monitor_loop_zone", m_loopZone);
1242 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1244 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1245 m_loopClip->setEnabled(false);
1246 collection.addAction("monitor_loop_clip", m_loopClip);
1247 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1249 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1250 collection.addAction("dvd_wizard", dvdWizard);
1251 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1253 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1254 collection.addAction("transcode_clip", transcodeClip);
1255 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1257 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1258 collection.addAction("archive_project", archiveProject);
1259 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1262 KAction *markIn = collection.addAction("mark_in");
1263 markIn->setText(i18n("Set Zone In"));
1264 markIn->setShortcut(Qt::Key_I);
1265 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1267 KAction *markOut = collection.addAction("mark_out");
1268 markOut->setText(i18n("Set Zone Out"));
1269 markOut->setShortcut(Qt::Key_O);
1270 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1272 KAction *switchMon = collection.addAction("switch_monitor");
1273 switchMon->setText(i18n("Switch monitor"));
1274 switchMon->setShortcut(Qt::Key_T);
1275 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1277 KAction *fullMon = collection.addAction("monitor_fullscreen");
1278 fullMon->setText(i18n("Switch monitor fullscreen"));
1279 fullMon->setIcon(KIcon("view-fullscreen"));
1280 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1282 KAction *insertTree = collection.addAction("insert_project_tree");
1283 insertTree->setText(i18n("Insert zone in project tree"));
1284 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1285 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1287 KAction *insertTimeline = collection.addAction("insert_timeline");
1288 insertTimeline->setText(i18n("Insert zone in timeline"));
1289 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1290 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1292 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1293 collection.addAction("resize_timeline_clip_start", resizeStart);
1294 resizeStart->setShortcut(Qt::Key_1);
1295 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1297 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1298 collection.addAction("resize_timeline_clip_end", resizeEnd);
1299 resizeEnd->setShortcut(Qt::Key_2);
1300 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1302 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1303 monitorSeekBackward->setShortcut(Qt::Key_J);
1304 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1305 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1307 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1308 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1309 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1310 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1312 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1313 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1314 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1315 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1317 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1318 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1319 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1320 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1322 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1323 monitorSeekForward->setShortcut(Qt::Key_L);
1324 collection.addAction("monitor_seek_forward", monitorSeekForward);
1325 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1327 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1328 clipStart->setShortcut(Qt::Key_Home);
1329 collection.addAction("seek_clip_start", clipStart);
1330 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1332 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1333 clipEnd->setShortcut(Qt::Key_End);
1334 collection.addAction("seek_clip_end", clipEnd);
1335 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1337 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1338 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1339 collection.addAction("seek_zone_start", zoneStart);
1340 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1342 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1343 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1344 collection.addAction("seek_zone_end", zoneEnd);
1345 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1347 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1348 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1349 collection.addAction("seek_start", projectStart);
1350 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1352 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1353 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1354 collection.addAction("seek_end", projectEnd);
1355 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1357 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1358 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1359 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1360 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1362 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1363 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1364 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1365 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1367 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1368 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1369 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1370 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1372 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1373 deleteItem->setShortcut(Qt::Key_Delete);
1374 collection.addAction("delete_timeline_clip", deleteItem);
1375 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1377 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1378 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1379 editTimelineClipSpeed->setData("change_speed");
1380 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1382 KAction *stickTransition = collection.addAction("auto_transition");
1383 stickTransition->setData(QString("auto"));
1384 stickTransition->setCheckable(true);
1385 stickTransition->setEnabled(false);
1386 stickTransition->setText(i18n("Automatic Transition"));
1387 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1389 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1390 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1391 collection.addAction("group_clip", groupClip);
1392 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1394 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1395 collection.addAction("ungroup_clip", ungroupClip);
1396 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1397 ungroupClip->setData("ungroup_clip");
1398 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1400 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1401 collection.addAction("edit_item_duration", editItemDuration);
1402 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1404 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1405 collection.addAction("clip_in_project_tree", clipInProjectTree);
1406 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1408 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1409 collection.addAction("clip_to_project_tree", clipToProjectTree);
1410 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1412 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1413 insertOvertwrite->setShortcut(Qt::Key_V);
1414 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1415 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1417 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1418 selectTimelineClip->setShortcut(Qt::Key_Plus);
1419 collection.addAction("select_timeline_clip", selectTimelineClip);
1420 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1422 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1423 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1424 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1425 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1427 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1428 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1429 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1430 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1432 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1433 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1434 collection.addAction("select_timeline_transition", selectTimelineTransition);
1435 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1437 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1438 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1439 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1440 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1442 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1443 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1444 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1445 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1447 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1448 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1449 collection.addAction("cut_timeline_clip", cutTimelineClip);
1450 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1452 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1453 collection.addAction("add_clip_marker", addClipMarker);
1454 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1456 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1457 collection.addAction("delete_clip_marker", deleteClipMarker);
1458 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1460 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1461 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1462 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1464 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1465 editClipMarker->setData(QString("edit_marker"));
1466 collection.addAction("edit_clip_marker", editClipMarker);
1467 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1469 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1470 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1471 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1472 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1474 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1475 collection.addAction("split_audio", splitAudio);
1476 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1478 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1479 collection.addAction("clip_audio_only", audioOnly);
1480 audioOnly->setData("clip_audio_only");
1481 audioOnly->setCheckable(true);
1483 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1484 collection.addAction("clip_video_only", videoOnly);
1485 videoOnly->setData("clip_video_only");
1486 videoOnly->setCheckable(true);
1488 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1489 collection.addAction("clip_audio_and_video", audioAndVideo);
1490 audioAndVideo->setData("clip_audio_and_video");
1491 audioAndVideo->setCheckable(true);
1493 m_clipTypeGroup = new QActionGroup(this);
1494 m_clipTypeGroup->addAction(audioOnly);
1495 m_clipTypeGroup->addAction(videoOnly);
1496 m_clipTypeGroup->addAction(audioAndVideo);
1497 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1498 m_clipTypeGroup->setEnabled(false);
1500 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1501 collection.addAction("insert_space", insertSpace);
1502 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1504 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1505 collection.addAction("delete_space", removeSpace);
1506 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1508 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1509 collection.addAction("insert_track", insertTrack);
1510 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1512 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1513 collection.addAction("delete_track", deleteTrack);
1514 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1516 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1517 collection.addAction("config_tracks", configTracks);
1518 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1520 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1521 collection.addAction("add_guide", addGuide);
1522 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1524 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1525 collection.addAction("delete_guide", delGuide);
1526 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1528 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1529 collection.addAction("edit_guide", editGuide);
1530 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1532 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1533 collection.addAction("delete_all_guides", delAllGuides);
1534 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1536 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1537 collection.addAction("paste_effects", pasteEffects);
1538 pasteEffects->setData("paste_effects");
1539 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1541 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1542 collection.addAction("show_timeline", showTimeline);
1543 showTimeline->setCheckable(true);
1544 showTimeline->setChecked(true);
1545 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1547 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1548 collection.addAction("show_titlebars", showTitleBar);
1549 showTitleBar->setCheckable(true);
1550 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1551 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1552 slotShowTitleBars(KdenliveSettings::showtitlebars());
1554 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1555 KStandardAction::quit(this, SLOT(close()), collection);
1556 KStandardAction::open(this, SLOT(openFile()), collection);
1557 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1558 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1559 KStandardAction::openNew(this, SLOT(newFile()), collection);
1560 // TODO: make the following connection to slotEditKeys work
1561 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1562 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1563 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1564 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1565 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1566 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1568 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1569 undo->setEnabled(false);
1570 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1572 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1573 redo->setEnabled(false);
1574 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1577 //TODO: Add status tooltip to actions ?
1578 connect(collection, SIGNAL(actionHovered(QAction*)),
1579 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1582 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1583 collection.addAction("add_clip", addClip);
1584 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1586 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1587 collection.addAction("add_color_clip", addColorClip);
1588 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1590 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1591 collection.addAction("add_slide_clip", addSlideClip);
1592 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1594 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1595 collection.addAction("add_text_clip", addTitleClip);
1596 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1598 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1599 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1600 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1602 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1603 collection.addAction("add_folder", addFolderButton);
1604 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1606 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1607 collection.addAction("clip_properties", clipProperties);
1608 clipProperties->setData("clip_properties");
1609 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1610 clipProperties->setEnabled(false);
1612 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1613 collection.addAction("edit_clip", openClip);
1614 openClip->setData("edit_clip");
1615 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1616 openClip->setEnabled(false);
1618 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1619 collection.addAction("delete_clip", deleteClip);
1620 deleteClip->setData("delete_clip");
1621 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1622 deleteClip->setEnabled(false);
1624 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1625 collection.addAction("reload_clip", reloadClip);
1626 reloadClip->setData("reload_clip");
1627 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1628 reloadClip->setEnabled(false);
1630 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1631 collection.addAction("proxy_clip", proxyClip);
1632 proxyClip->setData("proxy_clip");
1633 proxyClip->setCheckable(true);
1634 proxyClip->setChecked(false);
1635 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1637 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1638 collection.addAction("stopmotion", stopMotion);
1639 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1641 QMenu *addClips = new QMenu();
1642 addClips->addAction(addClip);
1643 addClips->addAction(addColorClip);
1644 addClips->addAction(addSlideClip);
1645 addClips->addAction(addTitleClip);
1646 addClips->addAction(addTitleTemplateClip);
1647 addClips->addAction(addFolderButton);
1649 addClips->addAction(reloadClip);
1650 addClips->addAction(proxyClip);
1651 addClips->addAction(clipProperties);
1652 addClips->addAction(openClip);
1653 addClips->addAction(deleteClip);
1654 m_projectList->setupMenu(addClips, addClip);
1656 // Setup effects and transitions actions.
1657 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1658 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1659 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1660 m_transitions = new KAction*[transitions.count()];
1661 for (int i = 0; i < transitions.count(); i++) {
1662 QStringList effectInfo = transitions.effectIdInfo(i);
1663 m_transitions[i] = new KAction(effectInfo.at(0), this);
1664 m_transitions[i]->setData(effectInfo);
1665 m_transitions[i]->setIconVisibleInMenu(false);
1666 QString id = effectInfo.at(2);
1667 if (id.isEmpty()) id = effectInfo.at(1);
1668 transitionActions->addAction("transition_" + id, m_transitions[i]);
1670 //m_effectsActionCollection->readSettings();
1674 void MainWindow::slotDisplayActionMessage(QAction *a)
1676 statusBar()->showMessage(a->data().toString(), 3000);
1679 void MainWindow::loadLayouts()
1681 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1682 if (m_loadLayout == NULL || saveLayout == NULL) return;
1683 KSharedConfigPtr config = KGlobal::config();
1684 KConfigGroup layoutGroup(config, "Layouts");
1685 QStringList entries = layoutGroup.keyList();
1686 QList<QAction *> loadActions = m_loadLayout->actions();
1687 QList<QAction *> saveActions = saveLayout->actions();
1688 for (int i = 1; i < 5; i++) {
1689 // Rename the layouts actions
1690 foreach(const QString & key, entries) {
1691 if (key.endsWith(QString("_%1").arg(i))) {
1692 // Found previously saved layout
1693 QString layoutName = key.section("_", 0, -2);
1694 for (int j = 0; j < loadActions.count(); j++) {
1695 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1696 loadActions[j]->setText(layoutName);
1697 loadActions[j]->setData(key);
1701 for (int j = 0; j < saveActions.count(); j++) {
1702 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1703 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1704 saveActions[j]->setData(key);
1713 void MainWindow::slotLoadLayout(QAction *action)
1715 if (!action) return;
1716 QString layoutId = action->data().toString();
1717 if (layoutId.isEmpty()) return;
1718 KSharedConfigPtr config = KGlobal::config();
1719 KConfigGroup layouts(config, "Layouts");
1720 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1721 restoreState(state);
1724 void MainWindow::slotSaveLayout(QAction *action)
1726 QString originallayoutName = action->data().toString();
1727 int layoutId = originallayoutName.section('_', -1).toInt();
1729 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1730 if (layoutName.isEmpty()) return;
1731 KSharedConfigPtr config = KGlobal::config();
1732 KConfigGroup layouts(config, "Layouts");
1733 layouts.deleteEntry(originallayoutName);
1735 QByteArray st = saveState();
1736 layoutName.append("_" + QString::number(layoutId));
1737 layouts.writeEntry(layoutName, st.toBase64());
1741 void MainWindow::saveOptions()
1743 KdenliveSettings::self()->writeConfig();
1744 KSharedConfigPtr config = KGlobal::config();
1745 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1746 KConfigGroup treecolumns(config, "Project Tree");
1747 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1751 void MainWindow::readOptions()
1753 KSharedConfigPtr config = KGlobal::config();
1754 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1755 KConfigGroup initialGroup(config, "version");
1756 bool upgrade = false;
1757 if (initialGroup.exists()) {
1758 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1762 if (initialGroup.readEntry("version") == "0.7") {
1763 //Add new settings from 0.7.1
1764 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1765 QString path = QDir::homePath() + "/kdenlive";
1766 if (KStandardDirs::makeDir(path) == false) {
1767 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1768 } else KdenliveSettings::setDefaultprojectfolder(path);
1774 if (!initialGroup.exists() || upgrade) {
1775 // this is our first run, show Wizard
1776 Wizard *w = new Wizard(upgrade, this);
1777 if (w->exec() == QDialog::Accepted && w->isOk()) {
1778 w->adjustSettings();
1779 initialGroup.writeEntry("version", version);
1785 KConfigGroup treecolumns(config, "Project Tree");
1786 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1787 if (!state.isEmpty())
1788 m_projectList->setHeaderInfo(state);
1791 void MainWindow::slotRunWizard()
1793 Wizard *w = new Wizard(false, this);
1794 if (w->exec() == QDialog::Accepted && w->isOk()) {
1795 w->adjustSettings();
1800 void MainWindow::newFile(bool showProjectSettings, bool force)
1802 if (!m_timelineArea->isEnabled() && !force)
1804 m_fileRevert->setEnabled(false);
1805 QString profileName = KdenliveSettings::default_profile();
1806 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1807 QMap <QString, QString> documentProperties;
1808 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1809 if (!showProjectSettings) {
1810 if (!KdenliveSettings::activatetabs())
1811 if (!closeCurrentDocument())
1814 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1815 if (w->exec() != QDialog::Accepted)
1817 if (!KdenliveSettings::activatetabs())
1818 if (!closeCurrentDocument())
1820 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1821 slotSwitchVideoThumbs();
1822 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1823 slotSwitchAudioThumbs();
1824 profileName = w->selectedProfile();
1825 projectFolder = w->selectedFolder();
1826 projectTracks = w->tracks();
1827 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1828 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1829 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1830 documentProperties.insert("proxyparams", w->proxyParams());
1831 documentProperties.insert("proxyextension", w->proxyExtension());
1832 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1833 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1836 m_timelineArea->setEnabled(true);
1837 m_projectList->setEnabled(true);
1839 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1840 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1842 TrackView *trackView = new TrackView(doc, &ok, this);
1843 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1846 //m_timelineArea->setEnabled(false);
1847 //m_projectList->setEnabled(false);
1851 if (m_timelineArea->count() == 1) {
1852 connectDocumentInfo(doc);
1853 connectDocument(trackView, doc);
1855 m_timelineArea->setTabBarHidden(false);
1856 m_monitorManager->activateMonitor("clip");
1857 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1860 void MainWindow::activateDocument()
1862 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1863 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1864 KdenliveDoc *currentDoc = currentTab->document();
1865 connectDocumentInfo(currentDoc);
1866 connectDocument(currentTab, currentDoc);
1869 bool MainWindow::closeCurrentDocument(bool saveChanges)
1871 QWidget *w = m_timelineArea->currentWidget();
1872 if (!w) return true;
1873 // closing current document
1874 int ix = m_timelineArea->currentIndex() + 1;
1875 if (ix == m_timelineArea->count()) ix = 0;
1876 m_timelineArea->setCurrentIndex(ix);
1877 TrackView *tabToClose = (TrackView *) w;
1878 KdenliveDoc *docToClose = tabToClose->document();
1879 if (docToClose && docToClose->isModified() && saveChanges) {
1881 if (m_activeDocument->url().fileName().isEmpty())
1882 message = i18n("Save changes to document?");
1884 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1885 switch (KMessageBox::warningYesNoCancel(this, message)) {
1886 case KMessageBox::Yes :
1887 // save document here. If saving fails, return false;
1888 if (saveFile() == false) return false;
1890 case KMessageBox::Cancel :
1897 m_clipMonitor->slotSetClipProducer(NULL);
1898 m_projectList->slotResetProjectList();
1899 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1900 if (m_timelineArea->count() == 1) {
1901 m_timelineArea->setTabBarHidden(true);
1902 m_closeAction->setEnabled(false);
1904 if (docToClose == m_activeDocument) {
1905 delete m_activeDocument;
1906 m_activeDocument = NULL;
1907 m_effectStack->clear();
1908 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1912 if (w == m_activeTimeline) {
1913 delete m_activeTimeline;
1914 m_activeTimeline = NULL;
1921 bool MainWindow::saveFileAs(const QString &outputFileName)
1923 QString currentSceneList;
1924 m_monitorManager->stopActiveMonitor();
1926 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1929 // Save timeline thumbnails
1930 m_activeTimeline->projectView()->saveThumbnails();
1931 m_activeDocument->setUrl(KUrl(outputFileName));
1932 if (m_activeDocument->m_autosave == NULL) {
1933 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1934 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1935 setCaption(m_activeDocument->description());
1936 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1937 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1938 m_activeDocument->setModified(false);
1939 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1940 m_fileRevert->setEnabled(true);
1941 m_undoView->stack()->setClean();
1945 bool MainWindow::saveFileAs()
1947 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1948 if (outputFile.isEmpty()) {
1951 if (QFile::exists(outputFile)) {
1952 // Show the file dialog again if the user does not want to overwrite the file
1953 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1954 return saveFileAs();
1956 return saveFileAs(outputFile);
1959 bool MainWindow::saveFile()
1961 if (!m_activeDocument) return true;
1962 if (m_activeDocument->url().isEmpty()) {
1963 return saveFileAs();
1965 bool result = saveFileAs(m_activeDocument->url().path());
1966 m_activeDocument->m_autosave->resize(0);
1971 void MainWindow::openFile()
1973 if (!m_startUrl.isEmpty()) {
1974 openFile(m_startUrl);
1975 m_startUrl = KUrl();
1978 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1979 if (url.isEmpty()) return;
1980 m_fileOpenRecent->addUrl(url);
1984 void MainWindow::openLastFile()
1986 KSharedConfigPtr config = KGlobal::config();
1987 KUrl::List urls = m_fileOpenRecent->urls();
1988 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1989 if (urls.isEmpty()) newFile(false);
1990 else openFile(urls.last());
1993 void MainWindow::openFile(const KUrl &url)
1995 // Make sure the url is a Kdenlive project file
1996 KMimeType::Ptr mime = KMimeType::findByUrl(url);
1997 if (mime.data()->is("application/x-compressed-tar")) {
1998 // Opening a compressed project file, we need to process it
1999 kDebug()<<"Opening archive, processing";
2000 ArchiveWidget *ar = new ArchiveWidget(url);
2001 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2005 if (!url.fileName().endsWith(".kdenlive")) {
2006 // This is not a Kdenlive project file, abort loading
2007 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2011 // Check if the document is already opened
2012 const int ct = m_timelineArea->count();
2013 bool isOpened = false;
2015 for (i = 0; i < ct; i++) {
2016 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2017 KdenliveDoc *doc = tab->document();
2018 if (doc->url() == url) {
2024 m_timelineArea->setCurrentIndex(i);
2028 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2030 // Check for backup file
2031 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2032 if (!staleFiles.isEmpty()) {
2033 if (KMessageBox::questionYesNo(this,
2034 i18n("Auto-saved files exist. Do you want to recover them now?"),
2035 i18n("File Recovery"),
2036 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2037 recoverFiles(staleFiles);
2040 // remove the stale files
2041 foreach(KAutoSaveFile * stale, staleFiles) {
2042 stale->open(QIODevice::ReadWrite);
2047 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2048 m_messageLabel->repaint();
2049 doOpenFile(url, NULL);
2052 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2054 if (!m_timelineArea->isEnabled()) return;
2055 m_fileRevert->setEnabled(true);
2057 // Recreate stopmotion widget on document change
2059 delete m_stopmotion;
2060 m_stopmotion = NULL;
2064 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2065 progressDialog.setAllowCancel(false);
2066 progressDialog.progressBar()->setMaximum(4);
2067 progressDialog.show();
2068 progressDialog.progressBar()->setValue(0);
2069 qApp->processEvents();
2072 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);
2074 progressDialog.progressBar()->setValue(1);
2075 progressDialog.progressBar()->setMaximum(4);
2076 progressDialog.setLabelText(i18n("Loading project"));
2077 qApp->processEvents();
2079 if (stale == NULL) {
2080 stale = new KAutoSaveFile(url, doc);
2081 doc->m_autosave = stale;
2083 doc->m_autosave = stale;
2084 doc->setUrl(stale->managedFile());
2085 doc->setModified(true);
2086 stale->setParent(doc);
2088 connectDocumentInfo(doc);
2090 progressDialog.progressBar()->setValue(2);
2091 qApp->processEvents();
2094 TrackView *trackView = new TrackView(doc, &ok, this);
2095 connectDocument(trackView, doc);
2096 progressDialog.progressBar()->setValue(3);
2097 qApp->processEvents();
2099 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2101 m_timelineArea->setEnabled(false);
2102 m_projectList->setEnabled(false);
2103 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2104 slotGotProgressInfo(QString(), -1);
2105 newFile(false, true);
2108 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2109 trackView->setDuration(trackView->duration());
2110 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2112 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2113 slotGotProgressInfo(QString(), -1);
2114 m_projectMonitor->adjustRulerSize(trackView->duration());
2115 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2116 progressDialog.progressBar()->setValue(4);
2117 if (openBackup) slotOpenBackupDialog(url);
2120 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2122 foreach(KAutoSaveFile * stale, staleFiles) {
2123 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2124 // show an error message; we could not steal the lockfile
2125 // maybe another application got to the file before us?
2129 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2130 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2131 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2132 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2136 void MainWindow::parseProfiles(const QString &mltPath)
2138 //KdenliveSettings::setDefaulttmpfolder();
2139 if (!mltPath.isEmpty()) {
2140 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2141 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2144 if (KdenliveSettings::mltpath().isEmpty())
2145 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2147 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2148 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2149 if (!QFile::exists(meltPath))
2150 meltPath = KStandardDirs::findExe("melt");
2151 KdenliveSettings::setRendererpath(meltPath);
2154 if (KdenliveSettings::rendererpath().isEmpty()) {
2155 // Cannot find the MLT melt renderer, ask for location
2156 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2157 if (getUrl->exec() == QDialog::Rejected) {
2160 KUrl rendererPath = getUrl->selectedUrl();
2162 if (rendererPath.isEmpty()) ::exit(0);
2163 KdenliveSettings::setRendererpath(rendererPath.path());
2166 QStringList profilesFilter;
2167 profilesFilter << "*";
2168 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2169 if (profilesList.isEmpty()) {
2170 // Cannot find MLT path, try finding melt
2171 QString profilePath = KdenliveSettings::rendererpath();
2172 if (!profilePath.isEmpty()) {
2173 profilePath = profilePath.section('/', 0, -3);
2174 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2175 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2177 if (profilesList.isEmpty()) {
2178 // Cannot find the MLT profiles, ask for location
2179 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2180 getUrl->fileDialog()->setMode(KFile::Directory);
2181 if (getUrl->exec() == QDialog::Rejected) {
2184 KUrl mltPath = getUrl->selectedUrl();
2186 if (mltPath.isEmpty()) ::exit(0);
2187 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2188 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2192 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2194 // Parse again MLT profiles to build a list of available video formats
2195 if (profilesList.isEmpty()) parseProfiles();
2199 void MainWindow::slotEditProfiles()
2201 ProfilesDialog *w = new ProfilesDialog;
2202 if (w->exec() == QDialog::Accepted) {
2203 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2204 if (d) d->checkProfile();
2209 void MainWindow::slotDetectAudioDriver()
2211 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2212 leading to no audio output, see bug #934 */
2214 //decide which audio driver is really best, in some cases SDL is wrong
2215 if (KdenliveSettings::audiodrivername().isEmpty()) {
2217 KProcess readProcess;
2218 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2219 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2220 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2221 readProcess.setProgram("pactl", QStringList() << "stat");
2222 readProcess.execute(2000); // Kill it after 2 seconds
2224 QString result = QString(readProcess.readAllStandardOutput());
2225 kDebug() << "// / / / / / READING PACTL: ";
2227 if (!result.isEmpty()) {
2229 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2233 KdenliveSettings::setAutoaudiodrivername(driver);
2237 void MainWindow::slotEditProjectSettings()
2239 QPoint p = m_activeDocument->getTracksCount();
2240 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2241 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2243 if (w->exec() == QDialog::Accepted) {
2244 QString profile = w->selectedProfile();
2245 m_activeDocument->setProjectFolder(w->selectedFolder());
2247 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2249 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2250 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2251 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2252 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2253 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2254 m_activeDocument->setModified();
2255 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2256 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) {
2257 //TODO: rebuild all proxies
2258 //m_projectList->rebuildProxies();
2261 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2262 m_activeDocument->setModified();
2263 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2265 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2266 m_activeDocument->setModified();
2267 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2269 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2270 m_activeDocument->setModified();
2271 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2273 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2274 m_activeDocument->setModified();
2275 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2277 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2278 m_activeDocument->setModified();
2279 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2281 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2282 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2283 m_activeDocument->setModified();
2284 slotUpdateProxySettings();
2290 void MainWindow::slotDisableProxies()
2292 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2293 m_activeDocument->setModified();
2294 slotUpdateProxySettings();
2297 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2299 // Recreate the stopmotion widget if profile changes
2301 delete m_stopmotion;
2302 m_stopmotion = NULL;
2305 // Deselect current effect / transition
2306 m_effectStack->slotClipItemSelected(NULL, 0);
2307 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2308 m_clipMonitor->slotSetClipProducer(NULL);
2309 bool updateFps = m_activeDocument->setProfilePath(profile);
2310 KdenliveSettings::setCurrent_profile(profile);
2311 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2312 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2314 m_activeDocument->clipManager()->clearUnusedProducers();
2315 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2316 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2317 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2318 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2319 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2320 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2321 if (updateFps) m_activeTimeline->updateProjectFps();
2322 m_activeDocument->clipManager()->clearCache();
2323 m_activeTimeline->updateProfile();
2324 m_activeDocument->setModified(true);
2325 m_commandStack->activeStack()->clear();
2326 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2327 slotUpdateMousePosition(0);
2328 // We need to desactivate & reactivate monitors to get a refresh
2329 //m_monitorManager->switchMonitors();
2333 void MainWindow::slotRenderProject()
2335 if (!m_renderWidget) {
2336 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2337 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2338 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2339 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2340 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2341 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2342 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2343 if (m_activeDocument) {
2344 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2345 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2346 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2347 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2350 slotCheckRenderStatus();
2351 m_renderWidget->show();
2352 m_renderWidget->showNormal();
2354 // What are the following lines supposed to do?
2355 //m_activeTimeline->tracksNumber();
2356 //m_renderWidget->enableAudio(false);
2357 //m_renderWidget->export_audio;
2360 void MainWindow::slotCheckRenderStatus()
2362 // Make sure there are no missing clips
2364 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2367 void MainWindow::setRenderingProgress(const QString &url, int progress)
2370 m_renderWidget->setRenderJob(url, progress);
2373 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2376 m_renderWidget->setRenderStatus(url, status, error);
2379 void MainWindow::slotCleanProject()
2381 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2382 m_projectList->cleanup();
2385 void MainWindow::slotUpdateMousePosition(int pos)
2387 if (m_activeDocument)
2388 switch (m_timecodeFormat->currentIndex()) {
2390 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2393 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2397 void MainWindow::slotUpdateDocumentState(bool modified)
2399 if (!m_activeDocument) return;
2400 setCaption(m_activeDocument->description(), modified);
2401 m_saveAction->setEnabled(modified);
2403 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2404 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2406 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2407 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2411 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2413 if (m_activeDocument) {
2414 if (m_activeDocument == doc) return;
2415 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2417 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2420 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2422 //m_projectMonitor->stop();
2423 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2424 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2425 if (m_activeDocument) {
2426 if (m_activeDocument == doc) return;
2427 if (m_activeTimeline) {
2428 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2429 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2430 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2431 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2432 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2433 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2434 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2435 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2437 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2439 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2440 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2441 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2442 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2443 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2444 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2445 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2446 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2447 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2448 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2449 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2450 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2451 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2452 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2453 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2454 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2455 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2456 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2457 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2458 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2459 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2460 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2461 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2462 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2463 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2464 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2465 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2466 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2467 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2468 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2469 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2470 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2471 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2472 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2473 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&)), this, SLOT(slotUpdateClip(const QString &)));
2474 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2475 m_effectStack->clear();
2477 //m_activeDocument->setRenderer(NULL);
2478 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2479 m_clipMonitor->stop();
2481 KdenliveSettings::setCurrent_profile(doc->profilePath());
2482 KdenliveSettings::setProject_fps(doc->fps());
2483 m_monitorManager->resetProfiles(doc->timecode());
2484 m_clipMonitorDock->raise();
2485 m_projectList->setDocument(doc);
2486 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2487 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2488 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2489 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2490 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
2492 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2493 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2494 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2496 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2499 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2500 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2501 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2502 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2503 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2504 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2505 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2506 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2507 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2508 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2509 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2510 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2511 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2512 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2514 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2515 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2516 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2517 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2518 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2520 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2521 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2522 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2524 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2526 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2527 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2528 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2529 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2531 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2532 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2533 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2534 m_zoomSlider->setValue(doc->zoom().x());
2535 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2536 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2537 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2538 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2540 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2541 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2543 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2544 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2546 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2547 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2548 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2549 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2550 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2551 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2552 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2553 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2554 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2555 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2556 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2558 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2559 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2560 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2561 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
2562 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2563 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2566 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2567 m_activeTimeline = trackView;
2568 if (m_renderWidget) {
2569 slotCheckRenderStatus();
2570 m_renderWidget->setProfile(doc->mltProfile());
2571 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2572 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2573 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2575 //doc->setRenderer(m_projectMonitor->render);
2576 m_commandStack->setActiveStack(doc->commandStack());
2577 KdenliveSettings::setProject_display_ratio(doc->dar());
2578 //doc->clipManager()->checkAudioThumbs();
2580 //m_overView->setScene(trackView->projectScene());
2581 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2582 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2584 setCaption(doc->description(), doc->isModified());
2585 m_saveAction->setEnabled(doc->isModified());
2586 m_normalEditTool->setChecked(true);
2587 m_activeDocument = doc;
2588 m_activeTimeline->updateProjectFps();
2589 m_activeDocument->checkProjectClips();
2591 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2593 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2594 slotUpdateMousePosition(0);
2595 m_monitorManager->activateMonitor("clip");
2596 // set tool to select tool
2597 m_buttonSelectTool->setChecked(true);
2600 void MainWindow::slotZoneMoved(int start, int end)
2602 m_activeDocument->setZone(start, end);
2603 m_projectMonitor->slotZoneMoved(start, end);
2606 void MainWindow::slotGuidesUpdated()
2609 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2612 void MainWindow::slotEditKeys()
2614 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2615 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2616 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2620 void MainWindow::slotPreferences(int page, int option)
2623 * An instance of your dialog could be already created and could be
2624 * cached, in which case you want to display the cached dialog
2625 * instead of creating another one
2627 if (m_stopmotion) m_stopmotion->slotLive(false);
2628 if (KConfigDialog::showDialog("settings")) {
2629 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2630 if (page != -1) d->showPage(page, option);
2634 // KConfigDialog didn't find an instance of this dialog, so lets
2637 // Get the mappable actions in localized form
2638 QMap<QString, QString> actions;
2639 KActionCollection* collection = actionCollection();
2640 foreach (const QString& action_name, m_action_names) {
2641 actions[collection->action(action_name)->text()] = action_name;
2644 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2645 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2646 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2648 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2651 if (page != -1) dialog->showPage(page, option);
2654 void MainWindow::slotUpdateCaptureFolder()
2658 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2659 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2663 void MainWindow::updateConfiguration()
2665 //TODO: we should apply settings to all projects, not only the current one
2666 if (m_activeTimeline) {
2667 m_activeTimeline->refresh();
2668 m_activeTimeline->projectView()->checkAutoScroll();
2669 m_activeTimeline->checkTrackHeight();
2670 if (m_activeDocument)
2671 m_activeDocument->clipManager()->checkAudioThumbs();
2673 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2674 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2675 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2676 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2678 // Update list of transcoding profiles
2680 #ifndef NO_JOGSHUTTLE
2681 activateShuttleDevice();
2682 #endif /* NO_JOGSHUTTLE */
2686 void MainWindow::slotSwitchSplitAudio()
2688 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2689 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2692 void MainWindow::slotSwitchVideoThumbs()
2694 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2695 if (m_activeTimeline)
2696 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2697 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2700 void MainWindow::slotSwitchAudioThumbs()
2702 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2703 if (m_activeTimeline) {
2704 m_activeTimeline->refresh();
2705 m_activeTimeline->projectView()->checkAutoScroll();
2706 if (m_activeDocument)
2707 m_activeDocument->clipManager()->checkAudioThumbs();
2709 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2712 void MainWindow::slotSwitchMarkersComments()
2714 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2715 if (m_activeTimeline)
2716 m_activeTimeline->refresh();
2717 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2720 void MainWindow::slotSwitchSnap()
2722 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2723 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2727 void MainWindow::slotDeleteItem()
2729 if (QApplication::focusWidget() &&
2730 QApplication::focusWidget()->parentWidget() &&
2731 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2732 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2733 m_projectList->slotRemoveClip();
2736 QWidget *widget = QApplication::focusWidget();
2738 if (widget == m_effectStackDock) {
2739 m_effectStack->slotItemDel();
2742 widget = widget->parentWidget();
2745 // effect stack has no focus
2746 if (m_activeTimeline)
2747 m_activeTimeline->projectView()->deleteSelectedClips();
2751 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2753 if (m_clipMonitor->isActive())
2754 m_clipMonitor->checkOverlay();
2755 m_clipMonitor->updateMarkers(clip);
2758 void MainWindow::slotAddClipMarker()
2760 DocClipBase *clip = NULL;
2762 if (m_projectMonitor->isActive()) {
2763 if (m_activeTimeline) {
2764 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2766 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2767 clip = item->baseClip();
2771 clip = m_clipMonitor->activeClip();
2772 pos = m_clipMonitor->position();
2775 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2778 QString id = clip->getId();
2779 CommentedTime marker(pos, i18n("Marker"));
2780 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2781 if (d.exec() == QDialog::Accepted)
2782 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2785 void MainWindow::slotDeleteClipMarker()
2787 DocClipBase *clip = NULL;
2789 if (m_projectMonitor->isActive()) {
2790 if (m_activeTimeline) {
2791 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2793 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2794 clip = item->baseClip();
2798 clip = m_clipMonitor->activeClip();
2799 pos = m_clipMonitor->position();
2802 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2806 QString id = clip->getId();
2807 QString comment = clip->markerComment(pos);
2808 if (comment.isEmpty()) {
2809 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2812 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2815 void MainWindow::slotDeleteAllClipMarkers()
2817 DocClipBase *clip = NULL;
2818 if (m_projectMonitor->isActive()) {
2819 if (m_activeTimeline) {
2820 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2822 clip = item->baseClip();
2826 clip = m_clipMonitor->activeClip();
2829 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2832 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2835 void MainWindow::slotEditClipMarker()
2837 DocClipBase *clip = NULL;
2839 if (m_projectMonitor->isActive()) {
2840 if (m_activeTimeline) {
2841 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2843 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2844 clip = item->baseClip();
2848 clip = m_clipMonitor->activeClip();
2849 pos = m_clipMonitor->position();
2852 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2856 QString id = clip->getId();
2857 QString oldcomment = clip->markerComment(pos);
2858 if (oldcomment.isEmpty()) {
2859 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2863 CommentedTime marker(pos, oldcomment);
2864 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2865 if (d.exec() == QDialog::Accepted) {
2866 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2867 if (d.newMarker().time() != pos) {
2868 // remove old marker
2869 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2874 void MainWindow::slotAddMarkerGuideQuickly()
2876 if (!m_activeTimeline || !m_activeDocument)
2879 if (m_clipMonitor->isActive()) {
2880 DocClipBase *clip = m_clipMonitor->activeClip();
2881 GenTime pos = m_clipMonitor->position();
2884 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2888 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2890 m_activeTimeline->projectView()->slotAddGuide(false);
2894 void MainWindow::slotAddGuide()
2896 if (m_activeTimeline)
2897 m_activeTimeline->projectView()->slotAddGuide();
2900 void MainWindow::slotInsertSpace()
2902 if (m_activeTimeline)
2903 m_activeTimeline->projectView()->slotInsertSpace();
2906 void MainWindow::slotRemoveSpace()
2908 if (m_activeTimeline)
2909 m_activeTimeline->projectView()->slotRemoveSpace();
2912 void MainWindow::slotInsertTrack(int ix)
2914 m_projectMonitor->activateMonitor();
2915 if (m_activeTimeline)
2916 m_activeTimeline->projectView()->slotInsertTrack(ix);
2917 if (m_activeDocument)
2918 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2921 void MainWindow::slotDeleteTrack(int ix)
2923 m_projectMonitor->activateMonitor();
2924 if (m_activeTimeline)
2925 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2926 if (m_activeDocument)
2927 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2930 void MainWindow::slotConfigTrack(int ix)
2932 m_projectMonitor->activateMonitor();
2933 if (m_activeTimeline)
2934 m_activeTimeline->projectView()->slotConfigTracks(ix);
2935 if (m_activeDocument)
2936 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2939 void MainWindow::slotEditGuide()
2941 if (m_activeTimeline)
2942 m_activeTimeline->projectView()->slotEditGuide();
2945 void MainWindow::slotDeleteGuide()
2947 if (m_activeTimeline)
2948 m_activeTimeline->projectView()->slotDeleteGuide();
2951 void MainWindow::slotDeleteAllGuides()
2953 if (m_activeTimeline)
2954 m_activeTimeline->projectView()->slotDeleteAllGuides();
2957 void MainWindow::slotCutTimelineClip()
2959 if (m_activeTimeline)
2960 m_activeTimeline->projectView()->cutSelectedClips();
2963 void MainWindow::slotInsertClipOverwrite()
2965 if (m_activeTimeline) {
2966 QStringList data = m_clipMonitor->getZoneInfo();
2967 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2971 void MainWindow::slotSelectTimelineClip()
2973 if (m_activeTimeline)
2974 m_activeTimeline->projectView()->selectClip(true);
2977 void MainWindow::slotSelectTimelineTransition()
2979 if (m_activeTimeline)
2980 m_activeTimeline->projectView()->selectTransition(true);
2983 void MainWindow::slotDeselectTimelineClip()
2985 if (m_activeTimeline)
2986 m_activeTimeline->projectView()->selectClip(false, true);
2989 void MainWindow::slotDeselectTimelineTransition()
2991 if (m_activeTimeline)
2992 m_activeTimeline->projectView()->selectTransition(false, true);
2995 void MainWindow::slotSelectAddTimelineClip()
2997 if (m_activeTimeline)
2998 m_activeTimeline->projectView()->selectClip(true, true);
3001 void MainWindow::slotSelectAddTimelineTransition()
3003 if (m_activeTimeline)
3004 m_activeTimeline->projectView()->selectTransition(true, true);
3007 void MainWindow::slotGroupClips()
3009 if (m_activeTimeline)
3010 m_activeTimeline->projectView()->groupClips();
3013 void MainWindow::slotUnGroupClips()
3015 if (m_activeTimeline)
3016 m_activeTimeline->projectView()->groupClips(false);
3019 void MainWindow::slotEditItemDuration()
3021 if (m_activeTimeline)
3022 m_activeTimeline->projectView()->editItemDuration();
3025 void MainWindow::slotAddProjectClip(KUrl url)
3027 if (m_activeDocument)
3028 m_activeDocument->slotAddClipFile(url, QString());
3031 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3033 if (m_activeDocument)
3034 m_activeDocument->slotAddClipList(urls, QString());
3037 void MainWindow::slotAddTransition(QAction *result)
3039 if (!result) return;
3040 QStringList info = result->data().toStringList();
3041 if (info.isEmpty()) return;
3042 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3043 if (m_activeTimeline && !transition.isNull()) {
3044 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3048 void MainWindow::slotAddVideoEffect(QAction *result)
3050 if (!result) return;
3051 const int EFFECT_VIDEO = 1;
3052 const int EFFECT_AUDIO = 2;
3053 QStringList info = result->data().toStringList();
3055 if (info.isEmpty() || info.size() < 3) return;
3056 QDomElement effect ;
3057 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3058 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3059 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3060 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3062 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3063 if (!effect.isNull()) slotAddEffect(effect);
3064 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3068 void MainWindow::slotZoomIn()
3070 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3071 slotShowZoomSliderToolTip();
3074 void MainWindow::slotZoomOut()
3076 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3077 slotShowZoomSliderToolTip();
3080 void MainWindow::slotFitZoom()
3082 if (m_activeTimeline)
3083 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3086 void MainWindow::slotSetZoom(int value)
3088 value = qMax(m_zoomSlider->minimum(), value);
3089 value = qMin(m_zoomSlider->maximum(), value);
3091 if (m_activeTimeline)
3092 m_activeTimeline->slotChangeZoom(value);
3094 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3095 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3096 slotUpdateZoomSliderToolTip(value);
3098 m_zoomSlider->blockSignals(true);
3099 m_zoomSlider->setValue(value);
3100 m_zoomSlider->blockSignals(false);
3103 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3105 if (zoomlevel != -1)
3106 slotUpdateZoomSliderToolTip(zoomlevel);
3108 QPoint global = m_zoomSlider->rect().topLeft();
3109 global.ry() += m_zoomSlider->height() / 2;
3110 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3111 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3114 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3116 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3119 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3121 m_statusProgressBar->setValue(progress);
3122 if (progress >= 0) {
3123 if (!message.isEmpty())
3124 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3125 m_statusProgressBar->setVisible(true);
3126 } else if (progress == -2) {
3127 if (!message.isEmpty())
3128 m_messageLabel->setMessage(message, ErrorMessage);
3129 m_statusProgressBar->setVisible(false);
3131 m_messageLabel->setMessage(QString(), DefaultMessage);
3132 m_statusProgressBar->setVisible(false);
3136 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3138 if (clip->clipType() == TEXT) {
3139 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3140 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3141 // template text clip
3143 // Get the list of existing templates
3145 filter << "*.kdenlivetitle";
3146 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3148 QDialog *dia = new QDialog(this);
3149 Ui::TemplateClip_UI dia_ui;
3150 dia_ui.setupUi(dia);
3152 const QString templatePath = clip->getProperty("resource");
3153 for (int i = 0; i < templateFiles.size(); ++i) {
3154 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3155 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3157 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3158 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3159 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3160 //warning: setting base directory doesn't work??
3161 KUrl startDir(titlepath);
3162 dia_ui.template_list->fileDialog()->setUrl(startDir);
3163 dia_ui.description->setText(clip->getProperty("description"));
3164 if (dia->exec() == QDialog::Accepted) {
3165 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3166 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3168 QMap <QString, QString> newprops;
3170 if (KUrl(textTemplate).path() != templatePath) {
3171 // The template was changed
3172 newprops.insert("resource", textTemplate);
3175 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3176 newprops.insert("description", dia_ui.description->toPlainText());
3179 QString newtemplate = newprops.value("xmltemplate");
3180 if (newtemplate.isEmpty()) newtemplate = templatePath;
3182 // template modified we need to update xmldata
3183 QString description = newprops.value("description");
3184 if (description.isEmpty()) description = clip->getProperty("description");
3185 else newprops.insert("templatetext", description);
3186 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3187 if (!newprops.isEmpty()) {
3188 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3189 m_activeDocument->commandStack()->push(command);
3195 QString path = clip->getProperty("resource");
3196 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3198 doc.setContent(clip->getProperty("xmldata"));
3199 dia_ui->setXml(doc);
3200 if (dia_ui->exec() == QDialog::Accepted) {
3201 QMap <QString, QString> newprops;
3202 newprops.insert("xmldata", dia_ui->xml().toString());
3203 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3204 // duration changed, we need to update duration
3205 newprops.insert("out", QString::number(dia_ui->outPoint()));
3206 int currentLength = QString(clip->producerProperty("length")).toInt();
3207 if (currentLength <= dia_ui->outPoint())
3208 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3209 else newprops.insert("length", clip->producerProperty("length"));
3211 if (!path.isEmpty()) {
3212 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3213 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) {
3214 // save to external file
3215 dia_ui->saveTitle(path);
3216 } else newprops.insert("resource", QString());
3218 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3219 m_activeDocument->commandStack()->push(command);
3220 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3221 m_activeDocument->setModified(true);
3225 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3229 // any type of clip but a title
3230 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3231 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3232 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3233 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)));
3238 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3240 if (newprops.isEmpty()) return;
3241 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3242 m_activeDocument->commandStack()->push(command);
3243 m_activeDocument->setModified();
3246 // update clip occurences in timeline
3247 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3252 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3254 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3255 if (dia.exec() == QDialog::Accepted) {
3256 QUndoCommand *command = new QUndoCommand();
3257 command->setText(i18n("Edit clips"));
3258 QMap <QString, QString> newImageProps = dia.properties();
3259 // Transparency setting applies only for images
3260 QMap <QString, QString> newProps = newImageProps;
3261 newProps.remove("transparency");
3263 for (int i = 0; i < cliplist.count(); i++) {
3264 DocClipBase *clip = cliplist.at(i);
3265 if (clip->clipType() == IMAGE)
3266 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3268 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3270 m_activeDocument->commandStack()->push(command);
3271 for (int i = 0; i < cliplist.count(); i++)
3272 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3276 void MainWindow::customEvent(QEvent* e)
3278 if (e->type() == QEvent::User)
3279 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3281 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3287 m_effectStack->raiseWindow(m_effectStackDock);
3290 void MainWindow::slotActivateTransitionView(Transition *t)
3293 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3296 void MainWindow::slotSnapRewind()
3298 if (m_projectMonitor->isActive()) {
3299 if (m_activeTimeline)
3300 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3302 m_clipMonitor->slotSeekToPreviousSnap();
3306 void MainWindow::slotSnapForward()
3308 if (m_projectMonitor->isActive()) {
3309 if (m_activeTimeline)
3310 m_activeTimeline->projectView()->slotSeekToNextSnap();
3312 m_clipMonitor->slotSeekToNextSnap();
3316 void MainWindow::slotClipStart()
3318 if (m_projectMonitor->isActive()) {
3319 if (m_activeTimeline)
3320 m_activeTimeline->projectView()->clipStart();
3324 void MainWindow::slotClipEnd()
3326 if (m_projectMonitor->isActive()) {
3327 if (m_activeTimeline)
3328 m_activeTimeline->projectView()->clipEnd();
3332 void MainWindow::slotZoneStart()
3334 if (m_projectMonitor->isActive())
3335 m_projectMonitor->slotZoneStart();
3337 m_clipMonitor->slotZoneStart();
3340 void MainWindow::slotZoneEnd()
3342 if (m_projectMonitor->isActive())
3343 m_projectMonitor->slotZoneEnd();
3345 m_clipMonitor->slotZoneEnd();
3348 void MainWindow::slotChangeTool(QAction * action)
3350 if (action == m_buttonSelectTool)
3351 slotSetTool(SELECTTOOL);
3352 else if (action == m_buttonRazorTool)
3353 slotSetTool(RAZORTOOL);
3354 else if (action == m_buttonSpacerTool)
3355 slotSetTool(SPACERTOOL);
3358 void MainWindow::slotChangeEdit(QAction * action)
3360 if (!m_activeTimeline)
3363 if (action == m_overwriteEditTool)
3364 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3365 else if (action == m_insertEditTool)
3366 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3368 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3371 void MainWindow::slotSetTool(PROJECTTOOL tool)
3373 if (m_activeDocument && m_activeTimeline) {
3374 //m_activeDocument->setTool(tool);
3378 message = i18n("Ctrl + click to use spacer on current track only");
3381 message = i18n("Click on a clip to cut it");
3384 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3387 m_messageLabel->setMessage(message, InformationMessage);
3388 m_activeTimeline->projectView()->setTool(tool);
3392 void MainWindow::slotCopy()
3394 if (m_activeDocument && m_activeTimeline)
3395 m_activeTimeline->projectView()->copyClip();
3398 void MainWindow::slotPaste()
3400 if (m_activeDocument && m_activeTimeline)
3401 m_activeTimeline->projectView()->pasteClip();
3404 void MainWindow::slotPasteEffects()
3406 if (m_activeDocument && m_activeTimeline)
3407 m_activeTimeline->projectView()->pasteClipEffects();
3410 void MainWindow::slotFind()
3412 if (!m_activeDocument || !m_activeTimeline) return;
3413 m_projectSearch->setEnabled(false);
3414 m_findActivated = true;
3415 m_findString.clear();
3416 m_activeTimeline->projectView()->initSearchStrings();
3417 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3418 m_findTimer.start(5000);
3419 qApp->installEventFilter(this);
3422 void MainWindow::slotFindNext()
3424 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3425 statusBar()->showMessage(i18n("Found: %1", m_findString));
3427 statusBar()->showMessage(i18n("Reached end of project"));
3428 m_findTimer.start(4000);
3431 void MainWindow::findAhead()
3433 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3434 m_projectSearchNext->setEnabled(true);
3435 statusBar()->showMessage(i18n("Found: %1", m_findString));
3437 m_projectSearchNext->setEnabled(false);
3438 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3442 void MainWindow::findTimeout()
3444 m_projectSearchNext->setEnabled(false);
3445 m_findActivated = false;
3446 m_findString.clear();
3447 statusBar()->showMessage(i18n("Find stopped"), 3000);
3448 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3449 m_projectSearch->setEnabled(true);
3450 removeEventFilter(this);
3453 void MainWindow::slotClipInTimeline(const QString &clipId)
3455 if (m_activeTimeline && m_activeDocument) {
3456 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3458 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3459 inTimelineMenu->clear();
3461 QList <QAction *> actionList;
3463 for (int i = 0; i < matching.count(); ++i) {
3464 QString track = QString::number(matching.at(i).track);
3465 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3467 QAction *a = new QAction(track + ": " + start, this);
3468 a->setData(QStringList() << track << start);
3469 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3470 while (j < actionList.count()) {
3471 if (actionList.at(j)->text() > a->text()) break;
3474 actionList.insert(j, a);
3476 inTimelineMenu->addActions(actionList);
3478 if (matching.empty())
3479 inTimelineMenu->setEnabled(false);
3481 inTimelineMenu->setEnabled(true);
3485 void MainWindow::slotClipInProjectTree()
3487 if (m_activeTimeline) {
3488 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3489 if (clipIds.isEmpty())
3491 m_projectListDock->raise();
3492 for (int i = 0; i < clipIds.count(); i++)
3493 m_projectList->selectItemById(clipIds.at(i));
3494 if (m_projectMonitor->isActive())
3495 slotSwitchMonitors();
3499 /*void MainWindow::slotClipToProjectTree()
3501 if (m_activeTimeline) {
3502 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3503 if (clips.isEmpty()) return;
3504 for (int i = 0; i < clips.count(); i++) {
3505 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3507 //m_projectList->selectItemById(clipIds.at(i));
3511 void MainWindow::slotSelectClipInTimeline()
3513 if (m_activeTimeline) {
3514 QAction *action = qobject_cast<QAction *>(sender());
3515 QStringList data = action->data().toStringList();
3516 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3520 void MainWindow::keyPressEvent(QKeyEvent *ke)
3522 if (m_findActivated) {
3523 if (ke->key() == Qt::Key_Backspace) {
3524 m_findString = m_findString.left(m_findString.length() - 1);
3526 if (!m_findString.isEmpty())
3531 m_findTimer.start(4000);
3534 } else if (ke->key() == Qt::Key_Escape) {
3538 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3539 m_findString += ke->text();
3543 m_findTimer.start(4000);
3548 KXmlGuiWindow::keyPressEvent(ke);
3553 /** Gets called when the window gets hidden */
3554 void MainWindow::hideEvent(QHideEvent */*event*/)
3556 if (isMinimized() && m_monitorManager)
3557 m_monitorManager->stopActiveMonitor();
3560 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3562 if (m_findActivated) {
3563 if (event->type() == QEvent::ShortcutOverride) {
3564 QKeyEvent* ke = (QKeyEvent*) event;
3565 if (ke->text().trimmed().isEmpty()) return false;
3572 // pass the event on to the parent class
3573 return QMainWindow::eventFilter(obj, event);
3578 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3580 KDialog *dialog = new KDialog(this);
3581 dialog->setCaption("Save clip zone");
3582 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3584 QWidget *widget = new QWidget(dialog);
3585 dialog->setMainWidget(widget);
3587 QVBoxLayout *vbox = new QVBoxLayout(widget);
3588 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3589 if (path.isEmpty()) {
3590 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3591 if (baseClip == NULL) tmppath.append("untitled.mlt");
3593 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3595 path = KUrl(tmppath);
3597 KUrlRequester *url = new KUrlRequester(path, this);
3598 url->setFilter("video/mlt-playlist");
3599 QLabel *label2 = new QLabel(i18n("Description:"), this);
3600 KLineEdit *edit = new KLineEdit(this);
3601 vbox->addWidget(label1);
3602 vbox->addWidget(url);
3603 vbox->addWidget(label2);
3604 vbox->addWidget(edit);
3605 if (dialog->exec() == QDialog::Accepted) {
3606 if (QFile::exists(url->url().path())) {
3607 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3608 slotSaveZone(render, zone, baseClip, url->url());
3612 if (baseClip && !baseClip->fileURL().isEmpty()) {
3613 // create zone from clip url, so that we don't have problems with proxy clips
3615 #if QT_VERSION >= 0x040600
3616 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3617 env.remove("MLT_PROFILE");
3618 p.setProcessEnvironment(env);
3620 QStringList env = QProcess::systemEnvironment();
3621 env << "MLT_PROFILE='\0'";
3622 p.setEnvironment(env);
3624 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3625 if (!p.waitForStarted(3000)) {
3626 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3628 else if (!p.waitForFinished(5000)) {
3629 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3632 else render->saveZone(url->url(), edit->text(), zone);
3637 void MainWindow::slotSetInPoint()
3639 if (m_clipMonitor->isActive()) {
3640 m_clipMonitor->slotSetZoneStart();
3642 m_projectMonitor->slotSetZoneStart();
3646 void MainWindow::slotSetOutPoint()
3648 if (m_clipMonitor->isActive()) {
3649 m_clipMonitor->slotSetZoneEnd();
3651 m_projectMonitor->slotSetZoneEnd();
3655 void MainWindow::slotResizeItemStart()
3657 if (m_activeTimeline)
3658 m_activeTimeline->projectView()->setInPoint();
3661 void MainWindow::slotResizeItemEnd()
3663 if (m_activeTimeline)
3664 m_activeTimeline->projectView()->setOutPoint();
3667 int MainWindow::getNewStuff(const QString &configFile)
3669 KNS3::Entry::List entries;
3670 KNS3::DownloadDialog dialog(configFile);
3672 entries = dialog.changedEntries();
3673 foreach(const KNS3::Entry & entry, entries) {
3674 if (entry.status() == KNS3::Entry::Installed)
3675 kDebug() << "// Installed files: " << entry.installedFiles();
3677 return entries.size();
3680 void MainWindow::slotGetNewTitleStuff()
3682 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3683 TitleWidget::refreshTitleTemplates();
3686 void MainWindow::slotGetNewLumaStuff()
3688 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3689 initEffects::refreshLumas();
3690 m_activeTimeline->projectView()->reloadTransitionLumas();
3694 void MainWindow::slotGetNewRenderStuff()
3696 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3698 m_renderWidget->reloadProfiles();
3701 void MainWindow::slotGetNewMltProfileStuff()
3703 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3704 // update the list of profiles in settings dialog
3705 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3711 void MainWindow::slotAutoTransition()
3713 if (m_activeTimeline)
3714 m_activeTimeline->projectView()->autoTransition();
3717 void MainWindow::slotSplitAudio()
3719 if (m_activeTimeline)
3720 m_activeTimeline->projectView()->splitAudio();
3723 void MainWindow::slotUpdateClipType(QAction *action)
3725 if (m_activeTimeline) {
3726 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3727 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3728 else m_activeTimeline->projectView()->setAudioAndVideo();
3732 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3734 // We must stop the monitors since we create a new on in the dvd wizard
3735 m_clipMonitor->stop();
3736 m_projectMonitor->stop();
3737 DvdWizard w(url, profile, this);
3739 m_projectMonitor->start();
3742 void MainWindow::slotShowTimeline(bool show)
3744 if (show == false) {
3745 m_timelineState = saveState();
3746 centralWidget()->setHidden(true);
3748 centralWidget()->setHidden(false);
3749 restoreState(m_timelineState);
3753 void MainWindow::slotMaximizeCurrent(bool)
3755 //TODO: is there a way to maximize current widget?
3757 m_timelineState = saveState();
3758 QWidget *par = focusWidget()->parentWidget();
3759 while (par->parentWidget() && par->parentWidget() != this)
3760 par = par->parentWidget();
3761 kDebug() << "CURRENT WIDGET: " << par->objectName();
3764 void MainWindow::loadTranscoders()
3766 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3769 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3770 KConfigGroup transConfig(config, "Transcoding");
3772 QMap< QString, QString > profiles = transConfig.entryMap();
3773 QMapIterator<QString, QString> i(profiles);
3774 while (i.hasNext()) {
3776 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3777 QAction *a = transMenu->addAction(i.key());
3779 if (data.count() > 1)
3780 a->setToolTip(data.at(1));
3781 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3785 void MainWindow::slotTranscode(KUrl::List urls)
3790 if (urls.isEmpty()) {
3791 QAction *action = qobject_cast<QAction *>(sender());
3792 QStringList data = action->data().toStringList();
3793 params = data.at(0);
3794 if (data.count() > 1) desc = data.at(1);
3795 if (data.count() > 2) condition = data.at(2);
3796 urls << m_projectList->getConditionalUrls(condition);
3797 urls.removeAll(KUrl());
3799 if (urls.isEmpty()) {
3800 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3803 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3804 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3806 //QProcess::startDetached("ffmpeg", parameters);
3809 void MainWindow::slotTranscodeClip()
3811 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3812 if (urls.isEmpty()) return;
3813 slotTranscode(urls);
3816 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3818 if (m_activeDocument == NULL) return;
3819 QMapIterator<QString, QString> i(props);
3820 while (i.hasNext()) {
3822 m_activeDocument->setDocumentProperty(i.key(), i.value());
3824 m_activeDocument->setModified(true);
3828 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3830 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3832 QString playlistPath;
3835 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3836 QString path = m_renderWidget->getFreeScriptName();
3837 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3838 if (!ok || scriptPath.isEmpty()) return;
3839 scriptPath.prepend(scriptsFolder);
3840 QFile f(scriptPath);
3842 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3845 playlistPath = scriptPath + ".mlt";
3847 KTemporaryFile temp;
3848 temp.setAutoRemove(false);
3849 temp.setSuffix(".mlt");
3851 playlistPath = temp.fileName();
3853 QString playlistContent = m_projectMonitor->sceneList();
3854 if (!chapterFile.isEmpty()) {
3857 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3859 in = m_activeTimeline->inPoint();
3860 out = m_activeTimeline->outPoint();
3863 QDomElement chapters = doc.createElement("chapters");
3864 chapters.setAttribute("fps", m_activeDocument->fps());
3865 doc.appendChild(chapters);
3867 QDomElement guidesxml = m_activeDocument->guidesXml();
3868 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3869 for (int i = 0; i < nodes.count(); i++) {
3870 QDomElement e = nodes.item(i).toElement();
3872 QString comment = e.attribute("comment");
3873 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3874 if (time >= in && time < out) {
3875 if (zoneOnly) time = time - in;
3876 QDomElement chapter = doc.createElement("chapter");
3877 chapters.appendChild(chapter);
3878 chapter.setAttribute("title", comment);
3879 chapter.setAttribute("time", time);
3883 if (chapters.childNodes().count() > 0) {
3884 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3885 // Always insert a guide in pos 0
3886 QDomElement chapter = doc.createElement("chapter");
3887 chapters.insertBefore(chapter, QDomNode());
3888 chapter.setAttribute("title", i18n("Start"));
3889 chapter.setAttribute("time", "0");
3891 // save chapters file
3892 QFile file(chapterFile);
3893 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3894 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3896 file.write(doc.toString().toUtf8());
3897 if (file.error() != QFile::NoError) {
3898 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3905 if (m_renderWidget->automaticAudioExport()) {
3906 exportAudio = m_activeTimeline->checkProjectAudio();
3907 } else exportAudio = m_renderWidget->selectedAudioExport();
3909 // Set playlist audio volume to 100%
3911 doc.setContent(playlistContent);
3912 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3913 if (!tractor.isNull()) {
3914 QDomNodeList props = tractor.elementsByTagName("property");
3915 for (int i = 0; i < props.count(); i++) {
3916 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3917 props.at(i).firstChild().setNodeValue("1");
3923 // Do we want proxy rendering
3924 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3925 QString root = doc.documentElement().attribute("root");
3927 // replace proxy clips with originals
3928 QMap <QString, QString> proxies = m_projectList->getProxies();
3930 QDomNodeList producers = doc.elementsByTagName("producer");
3931 QString producerResource;
3933 for (uint n = 0; n < producers.length(); n++) {
3934 QDomElement e = producers.item(n).toElement();
3935 producerResource = EffectsList::property(e, "resource");
3936 if (producerResource.isEmpty()) continue;
3937 if (!producerResource.startsWith("/")) {
3938 producerResource.prepend(root + "/");
3940 if (producerResource.contains('?')) {
3941 // slowmotion producer
3942 suffix = "?" + producerResource.section('?', 1);
3943 producerResource = producerResource.section('?', 0, 0);
3945 else suffix.clear();
3946 if (!producerResource.isEmpty()) {
3947 if (proxies.contains(producerResource)) {
3948 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3949 // We need to delete the "aspect_ratio" property because proxy clips
3950 // sometimes have different ratio than original clips
3951 EffectsList::removeProperty(e, "aspect_ratio");
3952 EffectsList::removeMetaProperties(e);
3957 /*QMapIterator<QString, QString> i(proxies);
3958 while (i.hasNext()) {
3960 // Replace all keys with their values (proxy path with original path)
3961 QString key = i.key();
3962 playlistContent.replace(key, i.value());
3963 if (!root.isEmpty() && key.startsWith(root)) {
3964 // in case the resource path in MLT playlist is relative
3965 key.remove(0, root.count() + 1);
3966 playlistContent.replace(key, i.value());
3970 playlistContent = doc.toString();
3972 // Do save scenelist
3973 QFile file(playlistPath);
3974 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3975 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3978 file.write(playlistContent.toUtf8());
3979 if (file.error() != QFile::NoError) {
3980 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3985 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3988 void MainWindow::slotUpdateTimecodeFormat(int ix)
3990 KdenliveSettings::setFrametimecode(ix == 1);
3991 m_clipMonitor->updateTimecodeFormat();
3992 m_projectMonitor->updateTimecodeFormat();
3993 m_transitionConfig->updateTimecodeFormat();
3994 m_effectStack->updateTimecodeFormat();
3995 //m_activeTimeline->projectView()->clearSelection();
3996 m_activeTimeline->updateRuler();
3999 void MainWindow::slotRemoveFocus()
4001 statusBar()->setFocus();
4002 statusBar()->clearFocus();
4005 void MainWindow::slotRevert()
4007 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;
4008 KUrl url = m_activeDocument->url();
4009 if (closeCurrentDocument(false))
4010 doOpenFile(url, NULL);
4014 void MainWindow::slotShutdown()
4016 if (m_activeDocument) m_activeDocument->setModified(false);
4018 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4019 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4020 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4021 smserver.call("logout", 1, 2, 2);
4022 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4023 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4024 smserver.call("Shutdown");
4028 void MainWindow::slotUpdateTrackInfo()
4030 if (m_activeDocument)
4031 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4034 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4036 // Load the theme file
4038 if (action == NULL) theme = themename;
4039 else theme = action->data().toString();
4040 KdenliveSettings::setColortheme(theme);
4041 // Make palette for all widgets.
4042 QPalette plt = kapp->palette();
4043 if (theme.isEmpty()) {
4044 plt = QApplication::desktop()->palette();
4046 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4048 #if KDE_IS_VERSION(4,6,3)
4049 plt = KGlobalSettings::createNewApplicationPalette(config);
4051 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4052 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4053 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4054 QPalette::Disabled };
4055 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4056 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4058 for ( int i = 0; i < 3 ; i++ ) {
4059 QPalette::ColorGroup state = states[i];
4060 KColorScheme schemeView(state, KColorScheme::View, config);
4061 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4062 KColorScheme schemeButton(state, KColorScheme::Button, config);
4063 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4065 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4066 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4067 plt.setBrush( state, QPalette::Base, schemeView.background() );
4068 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4069 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4070 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4071 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4072 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4073 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4074 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4076 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4077 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4078 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4079 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4080 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4082 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4083 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4084 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4089 kapp->setPalette(plt);
4090 const QObjectList children = statusBar()->children();
4092 foreach(QObject * child, children) {
4093 if (child->isWidgetType())
4094 ((QWidget*)child)->setPalette(plt);
4095 const QObjectList subchildren = child->children();
4096 foreach(QObject * subchild, subchildren) {
4097 if (subchild->isWidgetType())
4098 ((QWidget*)subchild)->setPalette(plt);
4101 if (m_activeTimeline) {
4102 m_activeTimeline->projectView()->updatePalette();
4107 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4109 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4110 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4111 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4112 const QSize bitsSize(24, 2);
4113 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4114 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4116 QPixmap pixmap(23, 16);
4117 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4119 KConfigGroup group(config, "WM");
4120 QPainter p(&pixmap);
4121 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4122 p.fillRect(1, 1, 7, 7, windowScheme.background());
4123 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4125 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4126 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4127 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4129 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4130 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4132 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4133 p.fillRect(1, 8, 7, 7, viewScheme.background());
4134 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4136 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4137 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4138 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4140 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4141 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4147 void MainWindow::slotSwitchMonitors()
4149 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4150 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4151 else m_projectList->focusTree();
4154 void MainWindow::slotSwitchFullscreen()
4156 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4157 else m_clipMonitor->slotSwitchFullScreen();
4160 void MainWindow::slotInsertZoneToTree()
4162 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4163 QStringList info = m_clipMonitor->getZoneInfo();
4164 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4167 void MainWindow::slotInsertZoneToTimeline()
4169 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4170 QStringList info = m_clipMonitor->getZoneInfo();
4171 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4175 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4177 if (m_activeDocument && m_activeTimeline) {
4178 if (!ids.isEmpty()) {
4179 for (int i = 0; i < ids.size(); ++i) {
4180 m_activeTimeline->slotDeleteClip(ids.at(i));
4182 m_activeDocument->clipManager()->slotDeleteClips(ids);
4184 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4185 m_activeDocument->setModified(true);
4189 void MainWindow::slotShowTitleBars(bool show)
4191 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4192 for (int i = 0; i < docks.count(); i++) {
4193 QDockWidget* dock = docks.at(i);
4195 dock->setTitleBarWidget(0);
4197 if (!dock->isFloating()) {
4198 dock->setTitleBarWidget(new QWidget);
4202 KdenliveSettings::setShowtitlebars(show);
4205 void MainWindow::slotSwitchTitles()
4207 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4210 QString MainWindow::getMimeType(bool open)
4212 QString mimetype = "application/x-kdenlive";
4213 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4215 mimetype = "*.kdenlive";
4216 if (open) mimetype.append(" *.tar.gz");
4218 else if (open) mimetype.append(" application/x-compressed-tar");
4222 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4225 m_projectMonitor->render->sendFrameForAnalysis = true;
4228 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4229 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4236 qDebug() << "Any scope accepting new frames? " << request;
4239 m_projectMonitor->render->sendFrameForAnalysis = false;
4243 void MainWindow::slotUpdateGfxScopeFrameRequest()
4245 // We need a delay to make sure widgets are hidden after a close event for example
4246 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4249 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4252 bool request = false;
4253 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4254 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4255 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4261 if (!m_projectMonitor->effectSceneDisplayed()) {
4262 m_projectMonitor->render->sendFrameForAnalysis = false;
4264 m_clipMonitor->render->sendFrameForAnalysis = false;
4266 m_recMonitor->analyseFrames(false);
4268 m_projectMonitor->render->sendFrameForAnalysis = true;
4269 m_clipMonitor->render->sendFrameForAnalysis = true;
4271 m_recMonitor->analyseFrames(true);
4275 void MainWindow::slotUpdateAudioScopeFrameRequest()
4277 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4280 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4282 bool request = false;
4283 for (int i = 0; i < m_audioScopesList.count(); i++) {
4284 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4285 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4290 // Handle audio signal separately (no common interface)
4291 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4292 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4296 qDebug() << "Scopes Requesting Audio data: " << request;
4298 KdenliveSettings::setMonitor_audio(request);
4299 m_monitorManager->slotUpdateAudioMonitoring();
4302 void MainWindow::slotUpdateColorScopes()
4304 bool request = false;
4305 kDebug()<<"// UPDATE SCOPES";
4306 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4307 // Check if we need the renderer to send a new frame for update
4308 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4309 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4311 if (request && m_monitorManager->activeRenderer()) {
4312 m_monitorManager->activeRenderer()->sendFrameUpdate();
4316 void MainWindow::slotClearColorScopes()
4318 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4319 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4323 void MainWindow::slotOpenStopmotion()
4325 if (m_stopmotion == NULL) {
4326 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4327 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4328 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4329 // Check if we need the renderer to send a new frame for update
4330 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4331 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4332 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4335 m_stopmotion->show();
4338 void MainWindow::slotDeleteClip(const QString &id)
4340 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4341 for (int i = 0; i < list.size(); ++i) {
4342 list.at(i)->disableClipId(id);
4344 m_projectList->slotDeleteClip(id);
4347 void MainWindow::slotUpdateProxySettings()
4349 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4350 if (KdenliveSettings::enableproxy())
4351 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4352 m_projectList->updateProxyConfig();
4355 void MainWindow::slotInsertNotesTimecode()
4357 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4358 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4359 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4362 void MainWindow::slotArchiveProject()
4364 QList <DocClipBase*> list = m_projectList->documentClipList();
4365 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4366 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4371 void MainWindow::slotOpenBackupDialog(const KUrl url)
4376 kDebug()<<"// BACKUP URL: "<<url.path();
4377 if (!url.isEmpty()) {
4378 // we could not open the project file, guess where the backups are
4379 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4383 projectFolder = m_activeDocument->projectFolder();
4384 projectFile = m_activeDocument->url();
4385 projectId = m_activeDocument->getDocumentProperty("documentid");
4388 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4389 if (dia->exec() == QDialog::Accepted) {
4390 QString requestedBackup = dia->selectedFile();
4391 m_activeDocument->backupLastSavedVersion(projectFile.path());
4392 closeCurrentDocument(false);
4393 doOpenFile(KUrl(requestedBackup), NULL);
4394 m_activeDocument->setUrl(projectFile);
4395 m_activeDocument->setModified(true);
4396 setCaption(m_activeDocument->description());
4401 void MainWindow::slotElapsedTime()
4403 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4406 #include "mainwindow.moc"