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"
48 #include "clipproperties.h"
50 #include "commands/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 "audioscopes/audiospectrum.h"
63 #include "audioscopes/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 #ifdef USE_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);
207 // Connect the project list
208 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint)));
209 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
210 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
211 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
212 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
213 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
214 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
215 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
216 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
217 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
219 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
220 m_projectMonitorDock->setObjectName("project_monitor");
221 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
222 m_projectMonitorDock->setWidget(m_projectMonitor);
225 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
226 m_recMonitorDock->setObjectName("record_monitor");
227 m_recMonitor = new RecMonitor("record", m_monitorManager);
228 m_recMonitorDock->setWidget(m_recMonitor);
229 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
230 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
231 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
232 #endif /* ! Q_WS_MAC */
233 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
235 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
236 m_notesDock->setObjectName("notes_widget");
237 m_notesWidget = new NotesWidget();
238 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
239 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
241 m_notesWidget->setTabChangesFocus(true);
242 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
243 m_notesDock->setWidget(m_notesWidget);
244 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
246 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
247 m_effectStackDock->setObjectName("effect_stack");
248 m_effectStack = new EffectStackView(m_projectMonitor);
249 m_effectStackDock->setWidget(m_effectStack);
250 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
252 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
253 m_transitionConfigDock->setObjectName("transition");
254 m_transitionConfig = new TransitionSettings(m_projectMonitor);
255 m_transitionConfigDock->setWidget(m_transitionConfig);
256 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
258 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
259 m_effectListDock->setObjectName("effect_list");
260 m_effectList = new EffectsListView();
261 m_effectListDock->setWidget(m_effectList);
262 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
264 m_vectorscope = new Vectorscope(m_monitorManager);
265 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
266 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
267 m_vectorscopeDock->setWidget(m_vectorscope);
268 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
269 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
270 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
271 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
272 m_gfxScopesList.append(m_vectorscopeDock);
274 m_waveform = new Waveform(m_monitorManager);
275 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
276 m_waveformDock->setObjectName(m_waveform->widgetName());
277 m_waveformDock->setWidget(m_waveform);
278 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
279 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
280 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
281 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
282 m_gfxScopesList.append(m_waveformDock);
284 m_RGBParade = new RGBParade(m_monitorManager);
285 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
286 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
287 m_RGBParadeDock->setWidget(m_RGBParade);
288 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
289 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
290 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
291 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
292 m_gfxScopesList.append(m_RGBParadeDock);
294 m_histogram = new Histogram(m_monitorManager);
295 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
296 m_histogramDock->setObjectName(m_histogram->widgetName());
297 m_histogramDock->setWidget(m_histogram);
298 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
299 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
300 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
301 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
302 m_gfxScopesList.append(m_histogramDock);
305 m_audiosignal = new AudioSignal;
306 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
307 m_audiosignalDock->setObjectName("audiosignal");
308 m_audiosignalDock->setWidget(m_audiosignal);
309 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
310 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
311 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
313 m_audioSpectrum = new AudioSpectrum();
314 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
315 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
316 m_audioSpectrumDock->setWidget(m_audioSpectrum);
317 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
318 m_audioScopesList.append(m_audioSpectrum);
319 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
320 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
322 m_spectrogram = new Spectrogram();
323 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
324 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
325 m_spectrogramDock->setWidget(m_spectrogram);
326 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
327 m_audioScopesList.append(m_spectrogram);
328 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
329 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
331 // Connect the audio signal to the audio scope slots
333 if (m_projectMonitor) {
334 qDebug() << "project monitor connected";
335 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
336 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
337 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
338 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
339 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
340 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
343 qDebug() << "clip monitor connected";
344 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
345 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
346 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
347 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
348 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
349 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
351 // Ensure connections were set up correctly
356 // Add monitors here to keep them at the right of the window
357 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
358 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
360 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
363 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
364 m_undoViewDock->setObjectName("undo_history");
365 m_undoView = new QUndoView();
366 m_undoView->setCleanIcon(KIcon("edit-clear"));
367 m_undoView->setEmptyLabel(i18n("Clean"));
368 m_undoViewDock->setWidget(m_undoView);
369 m_undoView->setGroup(m_commandStack);
370 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
374 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
377 // Close non-general docks for the initial layout
378 // only show important ones
379 m_histogramDock->close();
380 m_RGBParadeDock->close();
381 m_waveformDock->close();
382 m_vectorscopeDock->close();
384 m_audioSpectrumDock->close();
385 m_spectrogramDock->close();
386 m_audiosignalDock->close();
388 m_undoViewDock->close();
392 /// Tabify Widgets ///
393 tabifyDockWidget(m_effectListDock, m_effectStackDock);
394 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
395 tabifyDockWidget(m_projectListDock, m_notesDock);
397 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
399 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
405 setCentralWidget(m_timelineArea);
408 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
410 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
411 m_fileRevert->setEnabled(false);
413 // Prepare layout actions
414 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
415 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
416 for (int i = 1; i < 5; i++) {
417 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
418 load->setData("_" + QString::number(i));
419 layoutActions->addAction("load_layout" + QString::number(i), load);
420 m_loadLayout->addAction(load);
421 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
422 save->setData("_" + QString::number(i));
423 layoutActions->addAction("save_layout" + QString::number(i), save);
425 layoutActions->addAction("load_layouts", m_loadLayout);
426 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
429 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
430 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
431 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
432 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
433 m_stopmotion_actions->addAction("stopmotion_capture", action);
434 action = new KAction(i18n("Switch live / captured frame"), this);
435 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
436 m_stopmotion_actions->addAction("stopmotion_switch", action);
437 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
438 action->setCheckable(true);
439 action->setChecked(false);
440 m_stopmotion_actions->addAction("stopmotion_overlay", action);
442 // Build effects menu
443 m_effectsMenu = new QMenu(i18n("Add Effect"));
444 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
445 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
446 m_effectsActionCollection->readSettings();
450 // Find QDockWidget tab bars and show / hide widget title bars on right click
451 QList <QTabBar *> tabs = findChildren<QTabBar *>();
452 for (int i = 0; i < tabs.count(); i++) {
453 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
454 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
457 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
458 guiFactory()->addClient(sp);*/
460 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
462 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
465 // Load layout names from config file
471 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
472 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
474 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
475 clipInTimeline->setIcon(KIcon("go-jump"));
476 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
477 static_cast<QMenu*>(factory()->container("transcoders", this)),
480 // build themes menus
481 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
482 QActionGroup *themegroup = new QActionGroup(this);
483 themegroup->setExclusive(true);
484 action = new KAction(i18n("Default"), this);
485 action->setCheckable(true);
486 themegroup->addAction(action);
487 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
489 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
491 for (int i = 0; i < schemeFiles.size(); ++i) {
493 const QString filename = schemeFiles.at(i);
494 const QFileInfo info(filename);
497 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
498 QIcon icon = createSchemePreviewIcon(config);
499 KConfigGroup group(config, "General");
500 const QString name = group.readEntry("Name", info.baseName());
501 action = new KAction(name, this);
502 action->setData(filename);
503 action->setIcon(icon);
504 action->setCheckable(true);
505 themegroup->addAction(action);
506 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
509 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
510 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
511 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
514 action = new QAction(fi.fileName(), this);
515 action->setData(*it);
516 action->setCheckable(true);
517 themegroup->addAction(action);
518 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
520 themesMenu->addActions(themegroup->actions());
521 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
523 // Setup and fill effects and transitions menus.
526 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
527 m->addActions(m_effectsMenu->actions());
530 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
531 for (int i = 0; i < transitions.count(); ++i)
532 m_transitionsMenu->addAction(m_transitions[i]);
534 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
535 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
536 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
538 m_effectStack->setMenu(m_effectsMenu);
540 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
541 const QList<QAction *> viewActions = createPopupMenu()->actions();
542 viewMenu->insertActions(NULL, viewActions);
544 m_timelineContextMenu = new QMenu(this);
545 m_timelineContextClipMenu = new QMenu(this);
546 m_timelineContextTransitionMenu = new QMenu(this);
548 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
549 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
550 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
552 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
553 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
554 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
555 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
556 m_timelineContextClipMenu->addSeparator();
557 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
558 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
559 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
560 m_timelineContextClipMenu->addSeparator();
561 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
562 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
563 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
564 m_timelineContextClipMenu->addSeparator();
566 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
567 m_timelineContextClipMenu->addMenu(markersMenu);
568 m_timelineContextClipMenu->addSeparator();
569 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
570 m_timelineContextClipMenu->addMenu(m_effectsMenu);
572 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
573 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
574 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
576 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
578 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
579 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
580 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
581 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
582 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
583 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
585 slotConnectMonitors();
587 // Open or create a file. Command line argument passed in Url has
588 // precedence, then "openlastproject", then just a plain empty file.
589 // If opening Url fails, openlastproject will _not_ be used.
590 if (!Url.isEmpty()) {
591 // delay loading so that the window shows up
593 QTimer::singleShot(500, this, SLOT(openFile()));
594 } else if (KdenliveSettings::openlastproject()) {
595 QTimer::singleShot(500, this, SLOT(openLastFile()));
596 } else { //if (m_timelineArea->count() == 0) {
600 if (!clipsToLoad.isEmpty() && m_activeDocument) {
601 QStringList list = clipsToLoad.split(',');
603 foreach(QString path, list) {
604 kDebug() << QDir::current().absoluteFilePath(path);
605 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
607 m_projectList->slotAddClip(urls);
610 #ifdef USE_JOGSHUTTLE
611 activateShuttleDevice();
613 m_projectListDock->raise();
615 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
616 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
618 // Populate encoding profiles
619 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
620 if (KdenliveSettings::proxyparams().isEmpty()) {
621 KConfigGroup group(&conf, "proxy");
622 QMap< QString, QString > values = group.entryMap();
623 QMapIterator<QString, QString> i(values);
626 QString data = i.value();
627 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
628 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
631 if (KdenliveSettings::v4l_parameters().isEmpty()) {
632 KConfigGroup group(&conf, "video4linux");
633 QMap< QString, QString > values = group.entryMap();
634 QMapIterator<QString, QString> i(values);
637 QString data = i.value();
638 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
639 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
642 if (KdenliveSettings::decklink_parameters().isEmpty()) {
643 KConfigGroup group(&conf, "decklink");
644 QMap< QString, QString > values = group.entryMap();
645 QMapIterator<QString, QString> i(values);
648 QString data = i.value();
649 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
650 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
655 MainWindow::~MainWindow()
660 m_effectStack->slotClipItemSelected(NULL, 0);
661 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
663 if (m_projectMonitor) m_projectMonitor->stop();
664 if (m_clipMonitor) m_clipMonitor->stop();
666 delete m_activeTimeline;
667 delete m_effectStack;
668 delete m_transitionConfig;
669 delete m_activeDocument;
670 delete m_projectMonitor;
671 delete m_clipMonitor;
672 delete m_shortcutRemoveFocus;
673 delete[] m_transitions;
674 Mlt::Factory::close();
678 bool MainWindow::queryClose()
680 if (m_renderWidget) {
681 int waitingJobs = m_renderWidget->waitingJobsCount();
682 if (waitingJobs > 0) {
683 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")))) {
684 case KMessageBox::Yes :
685 // create script with waiting jobs and start it
686 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
688 case KMessageBox::No :
689 // Don't do anything, jobs will be deleted
697 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
698 // warn the user to save if document is modified and we have clips in our project list
699 if (m_activeDocument && m_activeDocument->isModified() &&
700 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
701 !m_projectList->documentClipList().isEmpty())) {
705 if (m_activeDocument->url().fileName().isEmpty())
706 message = i18n("Save changes to document?");
708 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
709 switch (KMessageBox::warningYesNoCancel(this, message)) {
710 case KMessageBox::Yes :
711 // save document here. If saving fails, return false;
713 case KMessageBox::No :
714 // User does not want to save the changes, clear recovery files
715 m_activeDocument->m_autosave->resize(0);
724 void MainWindow::loadPlugins()
726 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
727 populateMenus(plugin);
730 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
732 filters << "libkdenlive*";
733 foreach(const QString & folder, directories) {
734 kDebug() << "Parsing plugin folder: " << folder;
735 QDir pluginsDir(folder);
736 foreach(const QString & fileName,
737 pluginsDir.entryList(filters, QDir::Files)) {
739 * Avoid loading the same plugin twice when there is more than one
742 if (!m_pluginFileNames.contains(fileName)) {
743 kDebug() << "Found plugin: " << fileName;
744 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
745 QObject *plugin = loader.instance();
747 populateMenus(plugin);
748 m_pluginFileNames += fileName;
750 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
756 void MainWindow::populateMenus(QObject *plugin)
758 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
759 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
761 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
765 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
766 QMenu *menu, const char *member,
767 QActionGroup *actionGroup)
769 kDebug() << "// ADD to MENU" << texts;
770 foreach(const QString & text, texts) {
771 QAction *action = new QAction(text, plugin);
772 action->setData(text);
773 connect(action, SIGNAL(triggered()), this, member);
774 menu->addAction(action);
777 action->setCheckable(true);
778 actionGroup->addAction(action);
783 void MainWindow::aboutPlugins()
785 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
790 void MainWindow::generateClip()
792 QAction *action = qobject_cast<QAction *>(sender());
793 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
795 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
796 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
797 if (!clipUrl.isEmpty()) {
798 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
802 void MainWindow::saveProperties(KConfigGroup &config)
804 // save properties here,used by session management
806 KMainWindow::saveProperties(config);
810 void MainWindow::readProperties(const KConfigGroup &config)
812 // read properties here,used by session management
813 KMainWindow::readProperties(config);
814 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
815 openFile(KUrl(Lastproject));
818 void MainWindow::slotReloadEffects()
820 initEffects::parseCustomEffectsFile();
821 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
824 #ifdef USE_JOGSHUTTLE
825 void MainWindow::activateShuttleDevice()
831 if (KdenliveSettings::enableshuttle() == false) return;
833 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
834 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
836 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
837 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
838 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
839 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
840 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
842 #endif /* USE_JOGSHUTTLE */
844 void MainWindow::slotDoAction(const QString& action_name)
846 QAction* action = actionCollection()->action(action_name);
848 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
854 void MainWindow::configureNotifications()
856 KNotifyConfigWidget::configure(this);
859 void MainWindow::slotFullScreen()
861 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
864 void MainWindow::slotAddEffect(const QDomElement effect)
866 if (!m_activeDocument) return;
867 if (effect.isNull()) {
868 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
871 QDomElement effectToAdd = effect.cloneNode().toElement();
873 int ix = m_effectStack->isTrackMode(&ok);
874 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
875 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
878 void MainWindow::slotUpdateClip(const QString &id)
880 if (!m_activeDocument) return;
881 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
883 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
884 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
885 Mlt::Producer *monitorProducer = clip->getCloneProducer();
886 m_clipMonitor->updateClipProducer(monitorProducer);
888 clip->cleanupProducers();
891 void MainWindow::slotConnectMonitors()
893 m_projectList->setRenderer(m_projectMonitor->render);
894 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
895 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
896 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
897 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
898 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
899 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)));
901 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
903 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
905 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
907 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
908 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
910 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
912 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
913 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
916 void MainWindow::slotAdjustClipMonitor()
918 m_clipMonitorDock->updateGeometry();
919 m_clipMonitorDock->adjustSize();
920 m_clipMonitor->resetSize();
923 void MainWindow::slotAdjustProjectMonitor()
925 m_projectMonitorDock->updateGeometry();
926 m_projectMonitorDock->adjustSize();
927 m_projectMonitor->resetSize();
931 class NameGrabbingKActionCollection {
933 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
934 : m_collection(collection), m_action_names(action_names) {
935 m_action_names.clear();
937 KAction* addAction(const QString& action_name) {
938 m_action_names << action_name;
939 return m_collection->addAction(action_name);
941 void addAction(const QString& action_name, QAction* action) {
942 m_action_names << action_name;
943 m_collection->addAction(action_name, action);
945 operator KActionCollection*() { return m_collection; }
946 const QStringList& actionNames() const { return m_action_names; }
948 KActionCollection* m_collection;
949 QStringList& m_action_names;
952 void MainWindow::setupActions()
955 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
956 m_timecodeFormat = new KComboBox(this);
957 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
958 m_timecodeFormat->addItem(i18n("Frames"));
959 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
960 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
962 m_statusProgressBar = new QProgressBar(this);
963 m_statusProgressBar->setMinimum(0);
964 m_statusProgressBar->setMaximum(100);
965 m_statusProgressBar->setMaximumWidth(150);
966 m_statusProgressBar->setVisible(false);
968 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
969 toolbar->setMovable(false);
970 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
971 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
972 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
973 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
974 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
975 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());
976 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
978 //create edit mode buttons
979 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
980 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
981 toolbar->addAction(m_normalEditTool);
982 m_normalEditTool->setCheckable(true);
983 m_normalEditTool->setChecked(true);
985 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
986 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
987 toolbar->addAction(m_overwriteEditTool);
988 m_overwriteEditTool->setCheckable(true);
989 m_overwriteEditTool->setChecked(false);
991 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
992 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
993 toolbar->addAction(m_insertEditTool);
994 m_insertEditTool->setCheckable(true);
995 m_insertEditTool->setChecked(false);
996 // not implemented yet
997 m_insertEditTool->setEnabled(false);
999 QActionGroup *editGroup = new QActionGroup(this);
1000 editGroup->addAction(m_normalEditTool);
1001 editGroup->addAction(m_overwriteEditTool);
1002 editGroup->addAction(m_insertEditTool);
1003 editGroup->setExclusive(true);
1004 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
1005 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1007 toolbar->addSeparator();
1009 // create tools buttons
1010 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1011 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1012 toolbar->addAction(m_buttonSelectTool);
1013 m_buttonSelectTool->setCheckable(true);
1014 m_buttonSelectTool->setChecked(true);
1016 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1017 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1018 toolbar->addAction(m_buttonRazorTool);
1019 m_buttonRazorTool->setCheckable(true);
1020 m_buttonRazorTool->setChecked(false);
1022 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1023 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1024 toolbar->addAction(m_buttonSpacerTool);
1025 m_buttonSpacerTool->setCheckable(true);
1026 m_buttonSpacerTool->setChecked(false);
1028 QActionGroup *toolGroup = new QActionGroup(this);
1029 toolGroup->addAction(m_buttonSelectTool);
1030 toolGroup->addAction(m_buttonRazorTool);
1031 toolGroup->addAction(m_buttonSpacerTool);
1032 toolGroup->setExclusive(true);
1033 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1035 QWidget * actionWidget;
1036 int max = toolbar->iconSizeDefault() + 2;
1037 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1038 actionWidget->setMaximumWidth(max);
1039 actionWidget->setMaximumHeight(max - 4);
1041 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1042 actionWidget->setMaximumWidth(max);
1043 actionWidget->setMaximumHeight(max - 4);
1045 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1046 actionWidget->setMaximumWidth(max);
1047 actionWidget->setMaximumHeight(max - 4);
1049 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1050 actionWidget->setMaximumWidth(max);
1051 actionWidget->setMaximumHeight(max - 4);
1053 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1054 actionWidget->setMaximumWidth(max);
1055 actionWidget->setMaximumHeight(max - 4);
1057 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1058 actionWidget->setMaximumWidth(max);
1059 actionWidget->setMaximumHeight(max - 4);
1061 toolbar->setStyleSheet(style1);
1062 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1064 toolbar->addSeparator();
1065 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1066 toolbar->addAction(m_buttonFitZoom);
1067 m_buttonFitZoom->setCheckable(false);
1069 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1070 toolbar->addAction(m_zoomOut);
1071 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1073 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1074 m_zoomSlider->setMaximum(13);
1075 m_zoomSlider->setPageStep(1);
1076 m_zoomSlider->setInvertedAppearance(true);
1078 m_zoomSlider->setMaximumWidth(150);
1079 m_zoomSlider->setMinimumWidth(100);
1080 toolbar->addWidget(m_zoomSlider);
1082 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1083 toolbar->addAction(m_zoomIn);
1084 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1086 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1087 actionWidget->setMaximumWidth(max);
1088 actionWidget->setMaximumHeight(max - 4);
1089 actionWidget->setStyleSheet(styleBorderless);
1091 actionWidget = toolbar->widgetForAction(m_zoomIn);
1092 actionWidget->setMaximumWidth(max);
1093 actionWidget->setMaximumHeight(max - 4);
1094 actionWidget->setStyleSheet(styleBorderless);
1096 actionWidget = toolbar->widgetForAction(m_zoomOut);
1097 actionWidget->setMaximumWidth(max);
1098 actionWidget->setMaximumHeight(max - 4);
1099 actionWidget->setStyleSheet(styleBorderless);
1101 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1102 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1103 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1104 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1105 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1107 toolbar->addSeparator();
1109 //create automatic audio split button
1110 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1111 toolbar->addAction(m_buttonAutomaticSplitAudio);
1112 m_buttonAutomaticSplitAudio->setCheckable(true);
1113 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1114 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1116 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1117 toolbar->addAction(m_buttonVideoThumbs);
1118 m_buttonVideoThumbs->setCheckable(true);
1119 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1120 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1122 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1123 toolbar->addAction(m_buttonAudioThumbs);
1124 m_buttonAudioThumbs->setCheckable(true);
1125 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1126 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1128 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1129 toolbar->addAction(m_buttonShowMarkers);
1130 m_buttonShowMarkers->setCheckable(true);
1131 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1132 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1134 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1135 toolbar->addAction(m_buttonSnap);
1136 m_buttonSnap->setCheckable(true);
1137 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1138 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1140 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1141 actionWidget->setMaximumWidth(max);
1142 actionWidget->setMaximumHeight(max - 4);
1144 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1145 actionWidget->setMaximumWidth(max);
1146 actionWidget->setMaximumHeight(max - 4);
1148 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1149 actionWidget->setMaximumWidth(max);
1150 actionWidget->setMaximumHeight(max - 4);
1152 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1153 actionWidget->setMaximumWidth(max);
1154 actionWidget->setMaximumHeight(max - 4);
1156 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1157 actionWidget->setMaximumWidth(max);
1158 actionWidget->setMaximumHeight(max - 4);
1160 m_messageLabel = new StatusBarMessageLabel(this);
1161 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1163 statusBar()->addWidget(m_messageLabel, 10);
1164 statusBar()->addWidget(m_statusProgressBar, 0);
1165 statusBar()->addPermanentWidget(toolbar);
1166 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1167 statusBar()->addPermanentWidget(m_timecodeFormat);
1168 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1170 collection.addAction("normal_mode", m_normalEditTool);
1171 collection.addAction("overwrite_mode", m_overwriteEditTool);
1172 collection.addAction("insert_mode", m_insertEditTool);
1173 collection.addAction("select_tool", m_buttonSelectTool);
1174 collection.addAction("razor_tool", m_buttonRazorTool);
1175 collection.addAction("spacer_tool", m_buttonSpacerTool);
1177 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1178 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1179 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1180 collection.addAction("show_markers", m_buttonShowMarkers);
1181 collection.addAction("snap", m_buttonSnap);
1182 collection.addAction("zoom_fit", m_buttonFitZoom);
1183 collection.addAction("zoom_in", m_zoomIn);
1184 collection.addAction("zoom_out", m_zoomOut);
1186 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1187 collection.addAction("project_find", m_projectSearch);
1188 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1189 m_projectSearch->setShortcut(Qt::Key_Slash);
1191 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1192 collection.addAction("project_find_next", m_projectSearchNext);
1193 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1194 m_projectSearchNext->setShortcut(Qt::Key_F3);
1195 m_projectSearchNext->setEnabled(false);
1197 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1198 collection.addAction("manage_profiles", profilesAction);
1199 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1201 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1202 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1203 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1204 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1206 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1207 collection.addAction("run_wizard", wizAction);
1208 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1210 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1211 collection.addAction("project_settings", projectAction);
1212 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1214 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1215 collection.addAction("open_backup", backupAction);
1216 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1218 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1219 collection.addAction("project_render", projectRender);
1220 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1221 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1223 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1224 collection.addAction("project_clean", projectClean);
1225 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1227 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1228 collection.addAction("project_adjust_profile", projectAdjust);
1229 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1231 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1232 KShortcut playShortcut;
1233 playShortcut.setPrimary(Qt::Key_Space);
1234 playShortcut.setAlternate(Qt::Key_K);
1235 monitorPlay->setShortcut(playShortcut);
1236 collection.addAction("monitor_play", monitorPlay);
1237 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1239 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1240 collection.addAction("monitor_pause", monitorPause);
1241 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1243 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1244 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1245 collection.addAction("monitor_play_zone", m_playZone);
1246 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1248 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1249 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1250 collection.addAction("monitor_loop_zone", m_loopZone);
1251 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1253 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1254 m_loopClip->setEnabled(false);
1255 collection.addAction("monitor_loop_clip", m_loopClip);
1256 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1258 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1259 collection.addAction("dvd_wizard", dvdWizard);
1260 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1262 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1263 collection.addAction("transcode_clip", transcodeClip);
1264 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1266 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1267 collection.addAction("archive_project", archiveProject);
1268 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1271 KAction *markIn = collection.addAction("mark_in");
1272 markIn->setText(i18n("Set Zone In"));
1273 markIn->setShortcut(Qt::Key_I);
1274 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1276 KAction *markOut = collection.addAction("mark_out");
1277 markOut->setText(i18n("Set Zone Out"));
1278 markOut->setShortcut(Qt::Key_O);
1279 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1281 KAction *switchMon = collection.addAction("switch_monitor");
1282 switchMon->setText(i18n("Switch monitor"));
1283 switchMon->setShortcut(Qt::Key_T);
1284 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1286 KAction *fullMon = collection.addAction("monitor_fullscreen");
1287 fullMon->setText(i18n("Switch monitor fullscreen"));
1288 fullMon->setIcon(KIcon("view-fullscreen"));
1289 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1291 KAction *insertTree = collection.addAction("insert_project_tree");
1292 insertTree->setText(i18n("Insert zone in project tree"));
1293 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1294 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1296 KAction *insertTimeline = collection.addAction("insert_timeline");
1297 insertTimeline->setText(i18n("Insert zone in timeline"));
1298 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1299 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1301 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1302 collection.addAction("resize_timeline_clip_start", resizeStart);
1303 resizeStart->setShortcut(Qt::Key_1);
1304 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1306 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1307 collection.addAction("resize_timeline_clip_end", resizeEnd);
1308 resizeEnd->setShortcut(Qt::Key_2);
1309 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1311 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1312 monitorSeekBackward->setShortcut(Qt::Key_J);
1313 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1314 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1316 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1317 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1318 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1319 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1321 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1322 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1323 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1324 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1326 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1327 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1328 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1329 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1331 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1332 monitorSeekForward->setShortcut(Qt::Key_L);
1333 collection.addAction("monitor_seek_forward", monitorSeekForward);
1334 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1336 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1337 clipStart->setShortcut(Qt::Key_Home);
1338 collection.addAction("seek_clip_start", clipStart);
1339 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1341 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1342 clipEnd->setShortcut(Qt::Key_End);
1343 collection.addAction("seek_clip_end", clipEnd);
1344 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1346 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1347 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1348 collection.addAction("seek_zone_start", zoneStart);
1349 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1351 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1352 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1353 collection.addAction("seek_zone_end", zoneEnd);
1354 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1356 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1357 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1358 collection.addAction("seek_start", projectStart);
1359 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1361 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1362 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1363 collection.addAction("seek_end", projectEnd);
1364 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1366 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1367 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1368 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1369 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1371 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1372 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1373 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1374 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1376 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1377 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1378 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1379 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1381 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1382 deleteItem->setShortcut(Qt::Key_Delete);
1383 collection.addAction("delete_timeline_clip", deleteItem);
1384 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1386 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1387 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1388 editTimelineClipSpeed->setData("change_speed");
1389 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1391 KAction *stickTransition = collection.addAction("auto_transition");
1392 stickTransition->setData(QString("auto"));
1393 stickTransition->setCheckable(true);
1394 stickTransition->setEnabled(false);
1395 stickTransition->setText(i18n("Automatic Transition"));
1396 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1398 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1399 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1400 collection.addAction("group_clip", groupClip);
1401 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1403 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1404 collection.addAction("ungroup_clip", ungroupClip);
1405 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1406 ungroupClip->setData("ungroup_clip");
1407 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1409 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1410 collection.addAction("edit_item_duration", editItemDuration);
1411 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1413 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1414 collection.addAction("clip_in_project_tree", clipInProjectTree);
1415 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1417 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1418 collection.addAction("clip_to_project_tree", clipToProjectTree);
1419 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1421 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1422 insertOvertwrite->setShortcut(Qt::Key_V);
1423 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1424 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1426 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1427 selectTimelineClip->setShortcut(Qt::Key_Plus);
1428 collection.addAction("select_timeline_clip", selectTimelineClip);
1429 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1431 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1432 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1433 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1434 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1436 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1437 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1438 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1439 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1441 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1442 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1443 collection.addAction("select_timeline_transition", selectTimelineTransition);
1444 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1446 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1447 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1448 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1449 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1451 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1452 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1453 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1454 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1456 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1457 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1458 collection.addAction("cut_timeline_clip", cutTimelineClip);
1459 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1461 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1462 collection.addAction("add_clip_marker", addClipMarker);
1463 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1465 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1466 collection.addAction("delete_clip_marker", deleteClipMarker);
1467 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1469 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1470 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1471 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1473 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1474 editClipMarker->setData(QString("edit_marker"));
1475 collection.addAction("edit_clip_marker", editClipMarker);
1476 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1478 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1479 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1480 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1481 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1483 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1484 collection.addAction("split_audio", splitAudio);
1485 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1487 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1488 collection.addAction("clip_audio_only", audioOnly);
1489 audioOnly->setData("clip_audio_only");
1490 audioOnly->setCheckable(true);
1492 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1493 collection.addAction("clip_video_only", videoOnly);
1494 videoOnly->setData("clip_video_only");
1495 videoOnly->setCheckable(true);
1497 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1498 collection.addAction("clip_audio_and_video", audioAndVideo);
1499 audioAndVideo->setData("clip_audio_and_video");
1500 audioAndVideo->setCheckable(true);
1502 m_clipTypeGroup = new QActionGroup(this);
1503 m_clipTypeGroup->addAction(audioOnly);
1504 m_clipTypeGroup->addAction(videoOnly);
1505 m_clipTypeGroup->addAction(audioAndVideo);
1506 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1507 m_clipTypeGroup->setEnabled(false);
1509 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1510 collection.addAction("insert_space", insertSpace);
1511 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1513 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1514 collection.addAction("delete_space", removeSpace);
1515 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1517 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1518 collection.addAction("insert_track", insertTrack);
1519 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1521 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1522 collection.addAction("delete_track", deleteTrack);
1523 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1525 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1526 collection.addAction("config_tracks", configTracks);
1527 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1529 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1530 collection.addAction("add_guide", addGuide);
1531 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1533 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1534 collection.addAction("delete_guide", delGuide);
1535 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1537 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1538 collection.addAction("edit_guide", editGuide);
1539 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1541 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1542 collection.addAction("delete_all_guides", delAllGuides);
1543 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1545 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1546 collection.addAction("paste_effects", pasteEffects);
1547 pasteEffects->setData("paste_effects");
1548 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1550 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1551 collection.addAction("show_timeline", showTimeline);
1552 showTimeline->setCheckable(true);
1553 showTimeline->setChecked(true);
1554 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1556 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1557 collection.addAction("show_titlebars", showTitleBar);
1558 showTitleBar->setCheckable(true);
1559 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1560 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1561 slotShowTitleBars(KdenliveSettings::showtitlebars());
1563 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1564 KStandardAction::quit(this, SLOT(close()), collection);
1565 KStandardAction::open(this, SLOT(openFile()), collection);
1566 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1567 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1568 KStandardAction::openNew(this, SLOT(newFile()), collection);
1569 // TODO: make the following connection to slotEditKeys work
1570 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1571 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1572 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1573 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1574 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1575 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1577 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1578 undo->setEnabled(false);
1579 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1581 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1582 redo->setEnabled(false);
1583 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1586 //TODO: Add status tooltip to actions ?
1587 connect(collection, SIGNAL(actionHovered(QAction*)),
1588 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1591 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1592 collection.addAction("add_clip", addClip);
1593 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1595 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1596 collection.addAction("add_color_clip", addColorClip);
1597 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1599 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1600 collection.addAction("add_slide_clip", addSlideClip);
1601 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1603 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1604 collection.addAction("add_text_clip", addTitleClip);
1605 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1607 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1608 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1609 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1611 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1612 collection.addAction("add_folder", addFolderButton);
1613 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1615 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1616 collection.addAction("clip_properties", clipProperties);
1617 clipProperties->setData("clip_properties");
1618 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1619 clipProperties->setEnabled(false);
1621 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1622 collection.addAction("edit_clip", openClip);
1623 openClip->setData("edit_clip");
1624 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1625 openClip->setEnabled(false);
1627 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1628 collection.addAction("delete_clip", deleteClip);
1629 deleteClip->setData("delete_clip");
1630 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1631 deleteClip->setEnabled(false);
1633 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1634 collection.addAction("reload_clip", reloadClip);
1635 reloadClip->setData("reload_clip");
1636 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1637 reloadClip->setEnabled(false);
1639 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1640 collection.addAction("proxy_clip", proxyClip);
1641 proxyClip->setData("proxy_clip");
1642 proxyClip->setCheckable(true);
1643 proxyClip->setChecked(false);
1644 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1646 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1647 collection.addAction("stopmotion", stopMotion);
1648 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1650 QMenu *addClips = new QMenu();
1651 addClips->addAction(addClip);
1652 addClips->addAction(addColorClip);
1653 addClips->addAction(addSlideClip);
1654 addClips->addAction(addTitleClip);
1655 addClips->addAction(addTitleTemplateClip);
1656 addClips->addAction(addFolderButton);
1658 addClips->addAction(reloadClip);
1659 addClips->addAction(proxyClip);
1660 addClips->addAction(clipProperties);
1661 addClips->addAction(openClip);
1662 addClips->addAction(deleteClip);
1663 m_projectList->setupMenu(addClips, addClip);
1665 // Setup effects and transitions actions.
1666 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1667 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1668 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1669 m_transitions = new KAction*[transitions.count()];
1670 for (int i = 0; i < transitions.count(); i++) {
1671 QStringList effectInfo = transitions.effectIdInfo(i);
1672 m_transitions[i] = new KAction(effectInfo.at(0), this);
1673 m_transitions[i]->setData(effectInfo);
1674 m_transitions[i]->setIconVisibleInMenu(false);
1675 QString id = effectInfo.at(2);
1676 if (id.isEmpty()) id = effectInfo.at(1);
1677 transitionActions->addAction("transition_" + id, m_transitions[i]);
1679 //m_effectsActionCollection->readSettings();
1683 void MainWindow::slotDisplayActionMessage(QAction *a)
1685 statusBar()->showMessage(a->data().toString(), 3000);
1688 void MainWindow::loadLayouts()
1690 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1691 if (m_loadLayout == NULL || saveLayout == NULL) return;
1692 KSharedConfigPtr config = KGlobal::config();
1693 KConfigGroup layoutGroup(config, "Layouts");
1694 QStringList entries = layoutGroup.keyList();
1695 QList<QAction *> loadActions = m_loadLayout->actions();
1696 QList<QAction *> saveActions = saveLayout->actions();
1697 for (int i = 1; i < 5; i++) {
1698 // Rename the layouts actions
1699 foreach(const QString & key, entries) {
1700 if (key.endsWith(QString("_%1").arg(i))) {
1701 // Found previously saved layout
1702 QString layoutName = key.section("_", 0, -2);
1703 for (int j = 0; j < loadActions.count(); j++) {
1704 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1705 loadActions[j]->setText(layoutName);
1706 loadActions[j]->setData(key);
1710 for (int j = 0; j < saveActions.count(); j++) {
1711 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1712 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1713 saveActions[j]->setData(key);
1722 void MainWindow::slotLoadLayout(QAction *action)
1724 if (!action) return;
1725 QString layoutId = action->data().toString();
1726 if (layoutId.isEmpty()) return;
1727 KSharedConfigPtr config = KGlobal::config();
1728 KConfigGroup layouts(config, "Layouts");
1729 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1730 restoreState(state);
1733 void MainWindow::slotSaveLayout(QAction *action)
1735 QString originallayoutName = action->data().toString();
1736 int layoutId = originallayoutName.section('_', -1).toInt();
1738 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1739 if (layoutName.isEmpty()) return;
1740 KSharedConfigPtr config = KGlobal::config();
1741 KConfigGroup layouts(config, "Layouts");
1742 layouts.deleteEntry(originallayoutName);
1744 QByteArray st = saveState();
1745 layoutName.append("_" + QString::number(layoutId));
1746 layouts.writeEntry(layoutName, st.toBase64());
1750 void MainWindow::saveOptions()
1752 KdenliveSettings::self()->writeConfig();
1753 KSharedConfigPtr config = KGlobal::config();
1754 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1755 KConfigGroup treecolumns(config, "Project Tree");
1756 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1760 void MainWindow::readOptions()
1762 KSharedConfigPtr config = KGlobal::config();
1763 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1764 KConfigGroup initialGroup(config, "version");
1765 bool upgrade = false;
1766 if (initialGroup.exists()) {
1767 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1771 if (initialGroup.readEntry("version") == "0.7") {
1772 //Add new settings from 0.7.1
1773 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1774 QString path = QDir::homePath() + "/kdenlive";
1775 if (KStandardDirs::makeDir(path) == false) {
1776 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1777 } else KdenliveSettings::setDefaultprojectfolder(path);
1783 if (!initialGroup.exists() || upgrade) {
1784 // this is our first run, show Wizard
1785 Wizard *w = new Wizard(upgrade, this);
1786 if (w->exec() == QDialog::Accepted && w->isOk()) {
1787 w->adjustSettings();
1788 initialGroup.writeEntry("version", version);
1794 KConfigGroup treecolumns(config, "Project Tree");
1795 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1796 if (!state.isEmpty())
1797 m_projectList->setHeaderInfo(state);
1800 void MainWindow::slotRunWizard()
1802 Wizard *w = new Wizard(false, this);
1803 if (w->exec() == QDialog::Accepted && w->isOk()) {
1804 w->adjustSettings();
1809 void MainWindow::newFile(bool showProjectSettings, bool force)
1811 if (!m_timelineArea->isEnabled() && !force)
1813 m_fileRevert->setEnabled(false);
1814 QString profileName = KdenliveSettings::default_profile();
1815 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1816 QMap <QString, QString> documentProperties;
1817 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1818 if (!showProjectSettings) {
1819 if (!KdenliveSettings::activatetabs())
1820 if (!closeCurrentDocument())
1823 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1824 if (w->exec() != QDialog::Accepted)
1826 if (!KdenliveSettings::activatetabs())
1827 if (!closeCurrentDocument())
1829 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1830 slotSwitchVideoThumbs();
1831 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1832 slotSwitchAudioThumbs();
1833 profileName = w->selectedProfile();
1834 projectFolder = w->selectedFolder();
1835 projectTracks = w->tracks();
1836 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1837 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1838 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1839 documentProperties.insert("proxyparams", w->proxyParams());
1840 documentProperties.insert("proxyextension", w->proxyExtension());
1841 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1842 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1845 m_timelineArea->setEnabled(true);
1846 m_projectList->setEnabled(true);
1848 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1849 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1851 TrackView *trackView = new TrackView(doc, &ok, this);
1852 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1855 //m_timelineArea->setEnabled(false);
1856 //m_projectList->setEnabled(false);
1860 if (m_timelineArea->count() == 1) {
1861 connectDocumentInfo(doc);
1862 connectDocument(trackView, doc);
1864 m_timelineArea->setTabBarHidden(false);
1865 m_monitorManager->activateMonitor("clip");
1866 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1869 void MainWindow::activateDocument()
1871 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1872 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1873 KdenliveDoc *currentDoc = currentTab->document();
1874 connectDocumentInfo(currentDoc);
1875 connectDocument(currentTab, currentDoc);
1878 bool MainWindow::closeCurrentDocument(bool saveChanges)
1880 QWidget *w = m_timelineArea->currentWidget();
1881 if (!w) return true;
1882 // closing current document
1883 int ix = m_timelineArea->currentIndex() + 1;
1884 if (ix == m_timelineArea->count()) ix = 0;
1885 m_timelineArea->setCurrentIndex(ix);
1886 TrackView *tabToClose = (TrackView *) w;
1887 KdenliveDoc *docToClose = tabToClose->document();
1888 if (docToClose && docToClose->isModified() && saveChanges) {
1890 if (m_activeDocument->url().fileName().isEmpty())
1891 message = i18n("Save changes to document?");
1893 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1894 switch (KMessageBox::warningYesNoCancel(this, message)) {
1895 case KMessageBox::Yes :
1896 // save document here. If saving fails, return false;
1897 if (saveFile() == false) return false;
1899 case KMessageBox::Cancel :
1906 m_clipMonitor->slotSetClipProducer(NULL);
1907 m_projectList->slotResetProjectList();
1908 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1909 if (m_timelineArea->count() == 1) {
1910 m_timelineArea->setTabBarHidden(true);
1911 m_closeAction->setEnabled(false);
1913 if (docToClose == m_activeDocument) {
1914 delete m_activeDocument;
1915 m_activeDocument = NULL;
1916 m_effectStack->clear();
1917 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1921 if (w == m_activeTimeline) {
1922 delete m_activeTimeline;
1923 m_activeTimeline = NULL;
1930 bool MainWindow::saveFileAs(const QString &outputFileName)
1932 QString currentSceneList;
1933 m_monitorManager->stopActiveMonitor();
1935 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1938 // Save timeline thumbnails
1939 m_activeTimeline->projectView()->saveThumbnails();
1940 m_activeDocument->setUrl(KUrl(outputFileName));
1941 if (m_activeDocument->m_autosave == NULL) {
1942 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1943 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1944 setCaption(m_activeDocument->description());
1945 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1946 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1947 m_activeDocument->setModified(false);
1948 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1949 m_fileRevert->setEnabled(true);
1950 m_undoView->stack()->setClean();
1954 bool MainWindow::saveFileAs()
1956 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1957 if (outputFile.isEmpty()) {
1960 if (QFile::exists(outputFile)) {
1961 // Show the file dialog again if the user does not want to overwrite the file
1962 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1963 return saveFileAs();
1965 return saveFileAs(outputFile);
1968 bool MainWindow::saveFile()
1970 if (!m_activeDocument) return true;
1971 if (m_activeDocument->url().isEmpty()) {
1972 return saveFileAs();
1974 bool result = saveFileAs(m_activeDocument->url().path());
1975 m_activeDocument->m_autosave->resize(0);
1980 void MainWindow::openFile()
1982 if (!m_startUrl.isEmpty()) {
1983 openFile(m_startUrl);
1984 m_startUrl = KUrl();
1987 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1988 if (url.isEmpty()) return;
1989 m_fileOpenRecent->addUrl(url);
1993 void MainWindow::openLastFile()
1995 KSharedConfigPtr config = KGlobal::config();
1996 KUrl::List urls = m_fileOpenRecent->urls();
1997 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1998 if (urls.isEmpty()) newFile(false);
1999 else openFile(urls.last());
2002 void MainWindow::openFile(const KUrl &url)
2004 // Make sure the url is a Kdenlive project file
2005 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2006 if (mime.data()->is("application/x-compressed-tar")) {
2007 // Opening a compressed project file, we need to process it
2008 kDebug()<<"Opening archive, processing";
2009 ArchiveWidget *ar = new ArchiveWidget(url);
2010 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2014 if (!url.fileName().endsWith(".kdenlive")) {
2015 // This is not a Kdenlive project file, abort loading
2016 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2020 // Check if the document is already opened
2021 const int ct = m_timelineArea->count();
2022 bool isOpened = false;
2024 for (i = 0; i < ct; i++) {
2025 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2026 KdenliveDoc *doc = tab->document();
2027 if (doc->url() == url) {
2033 m_timelineArea->setCurrentIndex(i);
2037 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2039 // Check for backup file
2040 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2041 if (!staleFiles.isEmpty()) {
2042 if (KMessageBox::questionYesNo(this,
2043 i18n("Auto-saved files exist. Do you want to recover them now?"),
2044 i18n("File Recovery"),
2045 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2046 recoverFiles(staleFiles);
2049 // remove the stale files
2050 foreach(KAutoSaveFile * stale, staleFiles) {
2051 stale->open(QIODevice::ReadWrite);
2056 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2057 m_messageLabel->repaint();
2058 doOpenFile(url, NULL);
2061 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2063 if (!m_timelineArea->isEnabled()) return;
2064 m_fileRevert->setEnabled(true);
2066 // Recreate stopmotion widget on document change
2068 delete m_stopmotion;
2069 m_stopmotion = NULL;
2073 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2074 progressDialog.setAllowCancel(false);
2075 progressDialog.progressBar()->setMaximum(4);
2076 progressDialog.show();
2077 progressDialog.progressBar()->setValue(0);
2078 qApp->processEvents();
2081 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);
2083 progressDialog.progressBar()->setValue(1);
2084 progressDialog.progressBar()->setMaximum(4);
2085 progressDialog.setLabelText(i18n("Loading project"));
2086 qApp->processEvents();
2088 if (stale == NULL) {
2089 stale = new KAutoSaveFile(url, doc);
2090 doc->m_autosave = stale;
2092 doc->m_autosave = stale;
2093 doc->setUrl(stale->managedFile());
2094 doc->setModified(true);
2095 stale->setParent(doc);
2097 connectDocumentInfo(doc);
2099 progressDialog.progressBar()->setValue(2);
2100 qApp->processEvents();
2103 TrackView *trackView = new TrackView(doc, &ok, this);
2104 connectDocument(trackView, doc);
2105 progressDialog.progressBar()->setValue(3);
2106 qApp->processEvents();
2108 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2110 m_timelineArea->setEnabled(false);
2111 m_projectList->setEnabled(false);
2112 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2113 slotGotProgressInfo(QString(), -1);
2114 newFile(false, true);
2117 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2118 trackView->setDuration(trackView->duration());
2119 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2121 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2122 slotGotProgressInfo(QString(), -1);
2123 m_projectMonitor->adjustRulerSize(trackView->duration());
2124 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2125 progressDialog.progressBar()->setValue(4);
2126 if (openBackup) slotOpenBackupDialog(url);
2129 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2131 foreach(KAutoSaveFile * stale, staleFiles) {
2132 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2133 // show an error message; we could not steal the lockfile
2134 // maybe another application got to the file before us?
2138 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2139 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2140 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2141 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2145 void MainWindow::parseProfiles(const QString &mltPath)
2147 //KdenliveSettings::setDefaulttmpfolder();
2148 if (!mltPath.isEmpty()) {
2149 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2150 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2153 if (KdenliveSettings::mltpath().isEmpty())
2154 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2156 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2157 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2158 if (!QFile::exists(meltPath))
2159 meltPath = KStandardDirs::findExe("melt");
2160 KdenliveSettings::setRendererpath(meltPath);
2163 if (KdenliveSettings::rendererpath().isEmpty()) {
2164 // Cannot find the MLT melt renderer, ask for location
2165 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2166 if (getUrl->exec() == QDialog::Rejected) {
2169 KUrl rendererPath = getUrl->selectedUrl();
2171 if (rendererPath.isEmpty()) ::exit(0);
2172 KdenliveSettings::setRendererpath(rendererPath.path());
2175 QStringList profilesFilter;
2176 profilesFilter << "*";
2177 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2178 if (profilesList.isEmpty()) {
2179 // Cannot find MLT path, try finding melt
2180 QString profilePath = KdenliveSettings::rendererpath();
2181 if (!profilePath.isEmpty()) {
2182 profilePath = profilePath.section('/', 0, -3);
2183 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2184 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2186 if (profilesList.isEmpty()) {
2187 // Cannot find the MLT profiles, ask for location
2188 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2189 getUrl->fileDialog()->setMode(KFile::Directory);
2190 if (getUrl->exec() == QDialog::Rejected) {
2193 KUrl mltPath = getUrl->selectedUrl();
2195 if (mltPath.isEmpty()) ::exit(0);
2196 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2197 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2201 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2203 // Parse again MLT profiles to build a list of available video formats
2204 if (profilesList.isEmpty()) parseProfiles();
2208 void MainWindow::slotEditProfiles()
2210 ProfilesDialog *w = new ProfilesDialog;
2211 if (w->exec() == QDialog::Accepted) {
2212 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2213 if (d) d->checkProfile();
2218 void MainWindow::slotDetectAudioDriver()
2220 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2221 leading to no audio output, see bug #934 */
2223 //decide which audio driver is really best, in some cases SDL is wrong
2224 if (KdenliveSettings::audiodrivername().isEmpty()) {
2226 KProcess readProcess;
2227 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2228 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2229 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2230 readProcess.setProgram("pactl", QStringList() << "stat");
2231 readProcess.execute(2000); // Kill it after 2 seconds
2233 QString result = QString(readProcess.readAllStandardOutput());
2234 kDebug() << "// / / / / / READING PACTL: ";
2236 if (!result.isEmpty()) {
2238 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2242 KdenliveSettings::setAutoaudiodrivername(driver);
2246 void MainWindow::slotEditProjectSettings()
2248 QPoint p = m_activeDocument->getTracksCount();
2249 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2250 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2252 if (w->exec() == QDialog::Accepted) {
2253 QString profile = w->selectedProfile();
2254 m_activeDocument->setProjectFolder(w->selectedFolder());
2256 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2258 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2259 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2260 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2261 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2262 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2263 m_activeDocument->setModified();
2264 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2265 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) {
2266 //TODO: rebuild all proxies
2267 //m_projectList->rebuildProxies();
2270 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2271 m_activeDocument->setModified();
2272 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2274 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2275 m_activeDocument->setModified();
2276 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2278 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2279 m_activeDocument->setModified();
2280 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2282 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2283 m_activeDocument->setModified();
2284 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2286 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2287 m_activeDocument->setModified();
2288 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2290 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2291 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2292 m_activeDocument->setModified();
2293 slotUpdateProxySettings();
2299 void MainWindow::slotDisableProxies()
2301 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2302 m_activeDocument->setModified();
2303 slotUpdateProxySettings();
2306 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2308 // Recreate the stopmotion widget if profile changes
2310 delete m_stopmotion;
2311 m_stopmotion = NULL;
2314 // Deselect current effect / transition
2315 m_effectStack->slotClipItemSelected(NULL, 0);
2316 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2317 m_clipMonitor->slotSetClipProducer(NULL);
2318 bool updateFps = m_activeDocument->setProfilePath(profile);
2319 KdenliveSettings::setCurrent_profile(profile);
2320 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2321 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2323 m_activeDocument->clipManager()->clearUnusedProducers();
2324 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2325 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2326 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2327 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2328 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2329 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2330 if (updateFps) m_activeTimeline->updateProjectFps();
2331 m_activeDocument->clipManager()->clearCache();
2332 m_activeTimeline->updateProfile();
2333 m_activeDocument->setModified(true);
2334 m_commandStack->activeStack()->clear();
2335 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2336 slotUpdateMousePosition(0);
2337 // We need to desactivate & reactivate monitors to get a refresh
2338 //m_monitorManager->switchMonitors();
2342 void MainWindow::slotRenderProject()
2344 if (!m_renderWidget) {
2345 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2346 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2347 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2348 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2349 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2350 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2351 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2352 if (m_activeDocument) {
2353 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2354 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2355 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2356 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2359 slotCheckRenderStatus();
2360 m_renderWidget->show();
2361 m_renderWidget->showNormal();
2363 // What are the following lines supposed to do?
2364 //m_activeTimeline->tracksNumber();
2365 //m_renderWidget->enableAudio(false);
2366 //m_renderWidget->export_audio;
2369 void MainWindow::slotCheckRenderStatus()
2371 // Make sure there are no missing clips
2373 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2376 void MainWindow::setRenderingProgress(const QString &url, int progress)
2379 m_renderWidget->setRenderJob(url, progress);
2382 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2385 m_renderWidget->setRenderStatus(url, status, error);
2388 void MainWindow::slotCleanProject()
2390 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2391 m_projectList->cleanup();
2394 void MainWindow::slotUpdateMousePosition(int pos)
2396 if (m_activeDocument)
2397 switch (m_timecodeFormat->currentIndex()) {
2399 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2402 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2406 void MainWindow::slotUpdateDocumentState(bool modified)
2408 if (!m_activeDocument) return;
2409 setCaption(m_activeDocument->description(), modified);
2410 m_saveAction->setEnabled(modified);
2412 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2413 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2415 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2416 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2420 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2422 if (m_activeDocument) {
2423 if (m_activeDocument == doc) return;
2424 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2426 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2429 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2431 //m_projectMonitor->stop();
2432 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2433 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2434 if (m_activeDocument) {
2435 if (m_activeDocument == doc) return;
2436 if (m_activeTimeline) {
2437 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2438 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2439 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2440 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2441 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2442 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2443 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2445 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2447 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2448 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2449 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2450 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2451 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2452 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2453 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2454 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2455 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2456 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2457 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2458 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2459 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2460 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2461 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2462 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2463 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2464 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2465 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2466 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2467 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2468 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2469 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2470 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2471 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2472 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2473 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2474 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2475 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2476 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2477 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2478 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2479 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2480 m_effectStack->clear();
2482 //m_activeDocument->setRenderer(NULL);
2483 m_clipMonitor->stop();
2485 KdenliveSettings::setCurrent_profile(doc->profilePath());
2486 KdenliveSettings::setProject_fps(doc->fps());
2487 m_monitorManager->resetProfiles(doc->timecode());
2488 m_clipMonitorDock->raise();
2489 m_projectList->setDocument(doc);
2490 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2491 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2492 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2494 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2495 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2497 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2498 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2499 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2500 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2501 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2502 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2503 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2504 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2505 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2506 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2507 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2508 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2509 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2511 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2512 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2513 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2514 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2515 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2517 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2518 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2519 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2521 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2523 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2524 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2525 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2526 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2528 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2529 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2530 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2531 m_zoomSlider->setValue(doc->zoom().x());
2532 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2533 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2534 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2535 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2537 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, const int)));
2538 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2540 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2541 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2543 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2544 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2545 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2546 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2547 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2548 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2549 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2550 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2551 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2552 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2553 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2555 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2556 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2557 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2560 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2561 m_activeTimeline = trackView;
2562 if (m_renderWidget) {
2563 slotCheckRenderStatus();
2564 m_renderWidget->setProfile(doc->mltProfile());
2565 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2566 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2567 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2569 //doc->setRenderer(m_projectMonitor->render);
2570 m_commandStack->setActiveStack(doc->commandStack());
2571 KdenliveSettings::setProject_display_ratio(doc->dar());
2572 //doc->clipManager()->checkAudioThumbs();
2574 //m_overView->setScene(trackView->projectScene());
2575 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2576 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2578 setCaption(doc->description(), doc->isModified());
2579 m_saveAction->setEnabled(doc->isModified());
2580 m_normalEditTool->setChecked(true);
2581 m_activeDocument = doc;
2582 m_activeTimeline->updateProjectFps();
2583 m_activeDocument->checkProjectClips();
2585 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2587 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2588 slotUpdateMousePosition(0);
2589 m_monitorManager->activateMonitor("clip");
2590 // set tool to select tool
2591 m_buttonSelectTool->setChecked(true);
2594 void MainWindow::slotZoneMoved(int start, int end)
2596 m_activeDocument->setZone(start, end);
2597 m_projectMonitor->slotZoneMoved(start, end);
2600 void MainWindow::slotGuidesUpdated()
2603 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2606 void MainWindow::slotEditKeys()
2608 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2609 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2610 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2614 void MainWindow::slotPreferences(int page, int option)
2617 * An instance of your dialog could be already created and could be
2618 * cached, in which case you want to display the cached dialog
2619 * instead of creating another one
2621 if (m_stopmotion) m_stopmotion->slotLive(false);
2622 if (KConfigDialog::showDialog("settings")) {
2623 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2624 if (page != -1) d->showPage(page, option);
2628 // KConfigDialog didn't find an instance of this dialog, so lets
2631 // Get the mappable actions in localized form
2632 QMap<QString, QString> actions;
2633 KActionCollection* collection = actionCollection();
2634 foreach (const QString& action_name, m_action_names) {
2635 actions[collection->action(action_name)->text()] = action_name;
2638 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2639 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2640 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2642 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2645 if (page != -1) dialog->showPage(page, option);
2648 void MainWindow::slotUpdateCaptureFolder()
2652 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2653 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2657 void MainWindow::updateConfiguration()
2659 //TODO: we should apply settings to all projects, not only the current one
2660 if (m_activeTimeline) {
2661 m_activeTimeline->refresh();
2662 m_activeTimeline->projectView()->checkAutoScroll();
2663 m_activeTimeline->checkTrackHeight();
2664 if (m_activeDocument)
2665 m_activeDocument->clipManager()->checkAudioThumbs();
2667 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2668 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2669 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2670 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2672 // Update list of transcoding profiles
2674 #ifdef USE_JOGSHUTTLE
2675 activateShuttleDevice();
2680 void MainWindow::slotSwitchSplitAudio()
2682 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2683 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2686 void MainWindow::slotSwitchVideoThumbs()
2688 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2689 if (m_activeTimeline)
2690 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2691 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2694 void MainWindow::slotSwitchAudioThumbs()
2696 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2697 if (m_activeTimeline) {
2698 m_activeTimeline->refresh();
2699 m_activeTimeline->projectView()->checkAutoScroll();
2700 if (m_activeDocument)
2701 m_activeDocument->clipManager()->checkAudioThumbs();
2703 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2706 void MainWindow::slotSwitchMarkersComments()
2708 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2709 if (m_activeTimeline)
2710 m_activeTimeline->refresh();
2711 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2714 void MainWindow::slotSwitchSnap()
2716 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2717 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2721 void MainWindow::slotDeleteItem()
2723 if (QApplication::focusWidget() &&
2724 QApplication::focusWidget()->parentWidget() &&
2725 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2726 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2727 m_projectList->slotRemoveClip();
2730 QWidget *widget = QApplication::focusWidget();
2732 if (widget == m_effectStackDock) {
2733 m_effectStack->slotItemDel();
2736 widget = widget->parentWidget();
2739 // effect stack has no focus
2740 if (m_activeTimeline)
2741 m_activeTimeline->projectView()->deleteSelectedClips();
2745 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2747 if (m_clipMonitor->isActive())
2748 m_clipMonitor->checkOverlay();
2749 m_clipMonitor->updateMarkers(clip);
2752 void MainWindow::slotAddClipMarker()
2754 DocClipBase *clip = NULL;
2756 if (m_projectMonitor->isActive()) {
2757 if (m_activeTimeline) {
2758 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2760 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2761 clip = item->baseClip();
2765 clip = m_clipMonitor->activeClip();
2766 pos = m_clipMonitor->position();
2769 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2772 QString id = clip->getId();
2773 CommentedTime marker(pos, i18n("Marker"));
2774 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2775 if (d.exec() == QDialog::Accepted)
2776 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2779 void MainWindow::slotDeleteClipMarker()
2781 DocClipBase *clip = NULL;
2783 if (m_projectMonitor->isActive()) {
2784 if (m_activeTimeline) {
2785 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2787 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2788 clip = item->baseClip();
2792 clip = m_clipMonitor->activeClip();
2793 pos = m_clipMonitor->position();
2796 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2800 QString id = clip->getId();
2801 QString comment = clip->markerComment(pos);
2802 if (comment.isEmpty()) {
2803 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2806 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2809 void MainWindow::slotDeleteAllClipMarkers()
2811 DocClipBase *clip = NULL;
2812 if (m_projectMonitor->isActive()) {
2813 if (m_activeTimeline) {
2814 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2816 clip = item->baseClip();
2820 clip = m_clipMonitor->activeClip();
2823 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2826 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2829 void MainWindow::slotEditClipMarker()
2831 DocClipBase *clip = NULL;
2833 if (m_projectMonitor->isActive()) {
2834 if (m_activeTimeline) {
2835 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2837 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2838 clip = item->baseClip();
2842 clip = m_clipMonitor->activeClip();
2843 pos = m_clipMonitor->position();
2846 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2850 QString id = clip->getId();
2851 QString oldcomment = clip->markerComment(pos);
2852 if (oldcomment.isEmpty()) {
2853 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2857 CommentedTime marker(pos, oldcomment);
2858 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2859 if (d.exec() == QDialog::Accepted) {
2860 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2861 if (d.newMarker().time() != pos) {
2862 // remove old marker
2863 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2868 void MainWindow::slotAddMarkerGuideQuickly()
2870 if (!m_activeTimeline || !m_activeDocument)
2873 if (m_clipMonitor->isActive()) {
2874 DocClipBase *clip = m_clipMonitor->activeClip();
2875 GenTime pos = m_clipMonitor->position();
2878 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2882 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2884 m_activeTimeline->projectView()->slotAddGuide(false);
2888 void MainWindow::slotAddGuide()
2890 if (m_activeTimeline)
2891 m_activeTimeline->projectView()->slotAddGuide();
2894 void MainWindow::slotInsertSpace()
2896 if (m_activeTimeline)
2897 m_activeTimeline->projectView()->slotInsertSpace();
2900 void MainWindow::slotRemoveSpace()
2902 if (m_activeTimeline)
2903 m_activeTimeline->projectView()->slotRemoveSpace();
2906 void MainWindow::slotInsertTrack(int ix)
2908 m_projectMonitor->activateMonitor();
2909 if (m_activeTimeline)
2910 m_activeTimeline->projectView()->slotInsertTrack(ix);
2911 if (m_activeDocument)
2912 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2915 void MainWindow::slotDeleteTrack(int ix)
2917 m_projectMonitor->activateMonitor();
2918 if (m_activeTimeline)
2919 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2920 if (m_activeDocument)
2921 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2924 void MainWindow::slotConfigTrack(int ix)
2926 m_projectMonitor->activateMonitor();
2927 if (m_activeTimeline)
2928 m_activeTimeline->projectView()->slotConfigTracks(ix);
2929 if (m_activeDocument)
2930 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2933 void MainWindow::slotEditGuide()
2935 if (m_activeTimeline)
2936 m_activeTimeline->projectView()->slotEditGuide();
2939 void MainWindow::slotDeleteGuide()
2941 if (m_activeTimeline)
2942 m_activeTimeline->projectView()->slotDeleteGuide();
2945 void MainWindow::slotDeleteAllGuides()
2947 if (m_activeTimeline)
2948 m_activeTimeline->projectView()->slotDeleteAllGuides();
2951 void MainWindow::slotCutTimelineClip()
2953 if (m_activeTimeline)
2954 m_activeTimeline->projectView()->cutSelectedClips();
2957 void MainWindow::slotInsertClipOverwrite()
2959 if (m_activeTimeline) {
2960 QStringList data = m_clipMonitor->getZoneInfo();
2961 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2965 void MainWindow::slotSelectTimelineClip()
2967 if (m_activeTimeline)
2968 m_activeTimeline->projectView()->selectClip(true);
2971 void MainWindow::slotSelectTimelineTransition()
2973 if (m_activeTimeline)
2974 m_activeTimeline->projectView()->selectTransition(true);
2977 void MainWindow::slotDeselectTimelineClip()
2979 if (m_activeTimeline)
2980 m_activeTimeline->projectView()->selectClip(false, true);
2983 void MainWindow::slotDeselectTimelineTransition()
2985 if (m_activeTimeline)
2986 m_activeTimeline->projectView()->selectTransition(false, true);
2989 void MainWindow::slotSelectAddTimelineClip()
2991 if (m_activeTimeline)
2992 m_activeTimeline->projectView()->selectClip(true, true);
2995 void MainWindow::slotSelectAddTimelineTransition()
2997 if (m_activeTimeline)
2998 m_activeTimeline->projectView()->selectTransition(true, true);
3001 void MainWindow::slotGroupClips()
3003 if (m_activeTimeline)
3004 m_activeTimeline->projectView()->groupClips();
3007 void MainWindow::slotUnGroupClips()
3009 if (m_activeTimeline)
3010 m_activeTimeline->projectView()->groupClips(false);
3013 void MainWindow::slotEditItemDuration()
3015 if (m_activeTimeline)
3016 m_activeTimeline->projectView()->editItemDuration();
3019 void MainWindow::slotAddProjectClip(KUrl url)
3021 if (m_activeDocument)
3022 m_activeDocument->slotAddClipFile(url, QString());
3025 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3027 if (m_activeDocument)
3028 m_activeDocument->slotAddClipList(urls, QString());
3031 void MainWindow::slotAddTransition(QAction *result)
3033 if (!result) return;
3034 QStringList info = result->data().toStringList();
3035 if (info.isEmpty()) return;
3036 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3037 if (m_activeTimeline && !transition.isNull()) {
3038 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3042 void MainWindow::slotAddVideoEffect(QAction *result)
3044 if (!result) return;
3045 const int EFFECT_VIDEO = 1;
3046 const int EFFECT_AUDIO = 2;
3047 QStringList info = result->data().toStringList();
3049 if (info.isEmpty() || info.size() < 3) return;
3050 QDomElement effect ;
3051 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3052 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3053 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3054 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3056 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3057 if (!effect.isNull()) slotAddEffect(effect);
3058 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3062 void MainWindow::slotZoomIn()
3064 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3065 slotShowZoomSliderToolTip();
3068 void MainWindow::slotZoomOut()
3070 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3071 slotShowZoomSliderToolTip();
3074 void MainWindow::slotFitZoom()
3076 if (m_activeTimeline)
3077 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3080 void MainWindow::slotSetZoom(int value)
3082 value = qMax(m_zoomSlider->minimum(), value);
3083 value = qMin(m_zoomSlider->maximum(), value);
3085 if (m_activeTimeline)
3086 m_activeTimeline->slotChangeZoom(value);
3088 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3089 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3090 slotUpdateZoomSliderToolTip(value);
3092 m_zoomSlider->blockSignals(true);
3093 m_zoomSlider->setValue(value);
3094 m_zoomSlider->blockSignals(false);
3097 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3099 if (zoomlevel != -1)
3100 slotUpdateZoomSliderToolTip(zoomlevel);
3102 QPoint global = m_zoomSlider->rect().topLeft();
3103 global.ry() += m_zoomSlider->height() / 2;
3104 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3105 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3108 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3110 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3113 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3115 m_statusProgressBar->setValue(progress);
3116 if (progress >= 0) {
3117 if (!message.isEmpty())
3118 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3119 m_statusProgressBar->setVisible(true);
3120 } else if (progress == -2) {
3121 if (!message.isEmpty())
3122 m_messageLabel->setMessage(message, ErrorMessage);
3123 m_statusProgressBar->setVisible(false);
3125 m_messageLabel->setMessage(QString(), DefaultMessage);
3126 m_statusProgressBar->setVisible(false);
3130 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3132 if (clip->clipType() == TEXT) {
3133 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3134 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3135 // template text clip
3137 // Get the list of existing templates
3139 filter << "*.kdenlivetitle";
3140 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3142 QDialog *dia = new QDialog(this);
3143 Ui::TemplateClip_UI dia_ui;
3144 dia_ui.setupUi(dia);
3146 const QString templatePath = clip->getProperty("resource");
3147 for (int i = 0; i < templateFiles.size(); ++i) {
3148 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3149 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3151 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3152 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3153 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3154 //warning: setting base directory doesn't work??
3155 KUrl startDir(titlepath);
3156 dia_ui.template_list->fileDialog()->setUrl(startDir);
3157 dia_ui.description->setText(clip->getProperty("description"));
3158 if (dia->exec() == QDialog::Accepted) {
3159 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3160 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3162 QMap <QString, QString> newprops;
3164 if (KUrl(textTemplate).path() != templatePath) {
3165 // The template was changed
3166 newprops.insert("resource", textTemplate);
3169 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3170 newprops.insert("description", dia_ui.description->toPlainText());
3173 QString newtemplate = newprops.value("xmltemplate");
3174 if (newtemplate.isEmpty()) newtemplate = templatePath;
3176 // template modified we need to update xmldata
3177 QString description = newprops.value("description");
3178 if (description.isEmpty()) description = clip->getProperty("description");
3179 else newprops.insert("templatetext", description);
3180 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3181 if (!newprops.isEmpty()) {
3182 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3183 m_activeDocument->commandStack()->push(command);
3189 QString path = clip->getProperty("resource");
3190 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3192 doc.setContent(clip->getProperty("xmldata"));
3193 dia_ui->setXml(doc);
3194 if (dia_ui->exec() == QDialog::Accepted) {
3195 QMap <QString, QString> newprops;
3196 newprops.insert("xmldata", dia_ui->xml().toString());
3197 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3198 // duration changed, we need to update duration
3199 newprops.insert("out", QString::number(dia_ui->outPoint()));
3200 int currentLength = QString(clip->producerProperty("length")).toInt();
3201 if (currentLength <= dia_ui->outPoint())
3202 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3203 else newprops.insert("length", clip->producerProperty("length"));
3205 if (!path.isEmpty()) {
3206 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3207 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) {
3208 // save to external file
3209 dia_ui->saveTitle(path);
3210 } else newprops.insert("resource", QString());
3212 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3213 m_activeDocument->commandStack()->push(command);
3214 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3215 m_activeDocument->setModified(true);
3219 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3223 // any type of clip but a title
3224 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3225 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3226 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3227 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)));
3232 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3234 if (newprops.isEmpty()) return;
3235 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3236 m_activeDocument->commandStack()->push(command);
3237 m_activeDocument->setModified();
3240 // update clip occurences in timeline
3241 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3246 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3248 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3249 if (dia.exec() == QDialog::Accepted) {
3250 QUndoCommand *command = new QUndoCommand();
3251 command->setText(i18n("Edit clips"));
3252 QMap <QString, QString> newImageProps = dia.properties();
3253 // Transparency setting applies only for images
3254 QMap <QString, QString> newProps = newImageProps;
3255 newProps.remove("transparency");
3257 for (int i = 0; i < cliplist.count(); i++) {
3258 DocClipBase *clip = cliplist.at(i);
3259 if (clip->clipType() == IMAGE)
3260 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3262 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3264 m_activeDocument->commandStack()->push(command);
3265 for (int i = 0; i < cliplist.count(); i++)
3266 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3270 void MainWindow::customEvent(QEvent* e)
3272 if (e->type() == QEvent::User)
3273 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3275 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3281 m_effectStack->raiseWindow(m_effectStackDock);
3284 void MainWindow::slotActivateTransitionView(Transition *t)
3287 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3290 void MainWindow::slotSnapRewind()
3292 if (m_projectMonitor->isActive()) {
3293 if (m_activeTimeline)
3294 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3296 m_clipMonitor->slotSeekToPreviousSnap();
3300 void MainWindow::slotSnapForward()
3302 if (m_projectMonitor->isActive()) {
3303 if (m_activeTimeline)
3304 m_activeTimeline->projectView()->slotSeekToNextSnap();
3306 m_clipMonitor->slotSeekToNextSnap();
3310 void MainWindow::slotClipStart()
3312 if (m_projectMonitor->isActive()) {
3313 if (m_activeTimeline)
3314 m_activeTimeline->projectView()->clipStart();
3318 void MainWindow::slotClipEnd()
3320 if (m_projectMonitor->isActive()) {
3321 if (m_activeTimeline)
3322 m_activeTimeline->projectView()->clipEnd();
3326 void MainWindow::slotZoneStart()
3328 if (m_projectMonitor->isActive())
3329 m_projectMonitor->slotZoneStart();
3331 m_clipMonitor->slotZoneStart();
3334 void MainWindow::slotZoneEnd()
3336 if (m_projectMonitor->isActive())
3337 m_projectMonitor->slotZoneEnd();
3339 m_clipMonitor->slotZoneEnd();
3342 void MainWindow::slotChangeTool(QAction * action)
3344 if (action == m_buttonSelectTool)
3345 slotSetTool(SELECTTOOL);
3346 else if (action == m_buttonRazorTool)
3347 slotSetTool(RAZORTOOL);
3348 else if (action == m_buttonSpacerTool)
3349 slotSetTool(SPACERTOOL);
3352 void MainWindow::slotChangeEdit(QAction * action)
3354 if (!m_activeTimeline)
3357 if (action == m_overwriteEditTool)
3358 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3359 else if (action == m_insertEditTool)
3360 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3362 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3365 void MainWindow::slotSetTool(PROJECTTOOL tool)
3367 if (m_activeDocument && m_activeTimeline) {
3368 //m_activeDocument->setTool(tool);
3372 message = i18n("Ctrl + click to use spacer on current track only");
3375 message = i18n("Click on a clip to cut it");
3378 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3381 m_messageLabel->setMessage(message, InformationMessage);
3382 m_activeTimeline->projectView()->setTool(tool);
3386 void MainWindow::slotCopy()
3388 if (m_activeDocument && m_activeTimeline)
3389 m_activeTimeline->projectView()->copyClip();
3392 void MainWindow::slotPaste()
3394 if (m_activeDocument && m_activeTimeline)
3395 m_activeTimeline->projectView()->pasteClip();
3398 void MainWindow::slotPasteEffects()
3400 if (m_activeDocument && m_activeTimeline)
3401 m_activeTimeline->projectView()->pasteClipEffects();
3404 void MainWindow::slotFind()
3406 if (!m_activeDocument || !m_activeTimeline) return;
3407 m_projectSearch->setEnabled(false);
3408 m_findActivated = true;
3409 m_findString.clear();
3410 m_activeTimeline->projectView()->initSearchStrings();
3411 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3412 m_findTimer.start(5000);
3413 qApp->installEventFilter(this);
3416 void MainWindow::slotFindNext()
3418 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3419 statusBar()->showMessage(i18n("Found: %1", m_findString));
3421 statusBar()->showMessage(i18n("Reached end of project"));
3422 m_findTimer.start(4000);
3425 void MainWindow::findAhead()
3427 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3428 m_projectSearchNext->setEnabled(true);
3429 statusBar()->showMessage(i18n("Found: %1", m_findString));
3431 m_projectSearchNext->setEnabled(false);
3432 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3436 void MainWindow::findTimeout()
3438 m_projectSearchNext->setEnabled(false);
3439 m_findActivated = false;
3440 m_findString.clear();
3441 statusBar()->showMessage(i18n("Find stopped"), 3000);
3442 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3443 m_projectSearch->setEnabled(true);
3444 removeEventFilter(this);
3447 void MainWindow::slotClipInTimeline(const QString &clipId)
3449 if (m_activeTimeline && m_activeDocument) {
3450 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3452 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3453 inTimelineMenu->clear();
3455 QList <QAction *> actionList;
3457 for (int i = 0; i < matching.count(); ++i) {
3458 QString track = QString::number(matching.at(i).track);
3459 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3461 QAction *a = new QAction(track + ": " + start, this);
3462 a->setData(QStringList() << track << start);
3463 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3464 while (j < actionList.count()) {
3465 if (actionList.at(j)->text() > a->text()) break;
3468 actionList.insert(j, a);
3470 inTimelineMenu->addActions(actionList);
3472 if (matching.empty())
3473 inTimelineMenu->setEnabled(false);
3475 inTimelineMenu->setEnabled(true);
3479 void MainWindow::slotClipInProjectTree()
3481 if (m_activeTimeline) {
3482 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3483 if (clipIds.isEmpty())
3485 m_projectListDock->raise();
3486 for (int i = 0; i < clipIds.count(); i++)
3487 m_projectList->selectItemById(clipIds.at(i));
3488 if (m_projectMonitor->isActive())
3489 slotSwitchMonitors();
3493 /*void MainWindow::slotClipToProjectTree()
3495 if (m_activeTimeline) {
3496 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3497 if (clips.isEmpty()) return;
3498 for (int i = 0; i < clips.count(); i++) {
3499 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3501 //m_projectList->selectItemById(clipIds.at(i));
3505 void MainWindow::slotSelectClipInTimeline()
3507 if (m_activeTimeline) {
3508 QAction *action = qobject_cast<QAction *>(sender());
3509 QStringList data = action->data().toStringList();
3510 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3514 void MainWindow::keyPressEvent(QKeyEvent *ke)
3516 if (m_findActivated) {
3517 if (ke->key() == Qt::Key_Backspace) {
3518 m_findString = m_findString.left(m_findString.length() - 1);
3520 if (!m_findString.isEmpty())
3525 m_findTimer.start(4000);
3528 } else if (ke->key() == Qt::Key_Escape) {
3532 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3533 m_findString += ke->text();
3537 m_findTimer.start(4000);
3542 KXmlGuiWindow::keyPressEvent(ke);
3547 /** Gets called when the window gets hidden */
3548 void MainWindow::hideEvent(QHideEvent */*event*/)
3550 if (isMinimized() && m_monitorManager)
3551 m_monitorManager->stopActiveMonitor();
3554 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3556 if (m_findActivated) {
3557 if (event->type() == QEvent::ShortcutOverride) {
3558 QKeyEvent* ke = (QKeyEvent*) event;
3559 if (ke->text().trimmed().isEmpty()) return false;
3566 // pass the event on to the parent class
3567 return QMainWindow::eventFilter(obj, event);
3572 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3574 KDialog *dialog = new KDialog(this);
3575 dialog->setCaption("Save clip zone");
3576 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3578 QWidget *widget = new QWidget(dialog);
3579 dialog->setMainWidget(widget);
3581 QVBoxLayout *vbox = new QVBoxLayout(widget);
3582 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3583 if (path.isEmpty()) {
3584 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3585 if (baseClip == NULL) tmppath.append("untitled.mlt");
3587 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3589 path = KUrl(tmppath);
3591 KUrlRequester *url = new KUrlRequester(path, this);
3592 url->setFilter("video/mlt-playlist");
3593 QLabel *label2 = new QLabel(i18n("Description:"), this);
3594 KLineEdit *edit = new KLineEdit(this);
3595 vbox->addWidget(label1);
3596 vbox->addWidget(url);
3597 vbox->addWidget(label2);
3598 vbox->addWidget(edit);
3599 if (dialog->exec() == QDialog::Accepted) {
3600 if (QFile::exists(url->url().path())) {
3601 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3602 slotSaveZone(render, zone, baseClip, url->url());
3606 if (baseClip && !baseClip->fileURL().isEmpty()) {
3607 // create zone from clip url, so that we don't have problems with proxy clips
3609 #if QT_VERSION >= 0x040600
3610 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3611 env.remove("MLT_PROFILE");
3612 p.setProcessEnvironment(env);
3614 QStringList env = QProcess::systemEnvironment();
3615 env << "MLT_PROFILE='\0'";
3616 p.setEnvironment(env);
3618 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3619 if (!p.waitForStarted(3000)) {
3620 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3622 else if (!p.waitForFinished(5000)) {
3623 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3626 else render->saveZone(url->url(), edit->text(), zone);
3631 void MainWindow::slotSetInPoint()
3633 if (m_clipMonitor->isActive()) {
3634 m_clipMonitor->slotSetZoneStart();
3636 m_projectMonitor->slotSetZoneStart();
3640 void MainWindow::slotSetOutPoint()
3642 if (m_clipMonitor->isActive()) {
3643 m_clipMonitor->slotSetZoneEnd();
3645 m_projectMonitor->slotSetZoneEnd();
3649 void MainWindow::slotResizeItemStart()
3651 if (m_activeTimeline)
3652 m_activeTimeline->projectView()->setInPoint();
3655 void MainWindow::slotResizeItemEnd()
3657 if (m_activeTimeline)
3658 m_activeTimeline->projectView()->setOutPoint();
3661 int MainWindow::getNewStuff(const QString &configFile)
3663 KNS3::Entry::List entries;
3664 KNS3::DownloadDialog dialog(configFile);
3666 entries = dialog.changedEntries();
3667 foreach(const KNS3::Entry & entry, entries) {
3668 if (entry.status() == KNS3::Entry::Installed)
3669 kDebug() << "// Installed files: " << entry.installedFiles();
3671 return entries.size();
3674 void MainWindow::slotGetNewTitleStuff()
3676 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3677 TitleWidget::refreshTitleTemplates();
3680 void MainWindow::slotGetNewLumaStuff()
3682 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3683 initEffects::refreshLumas();
3684 m_activeTimeline->projectView()->reloadTransitionLumas();
3688 void MainWindow::slotGetNewRenderStuff()
3690 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3692 m_renderWidget->reloadProfiles();
3695 void MainWindow::slotGetNewMltProfileStuff()
3697 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3698 // update the list of profiles in settings dialog
3699 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3705 void MainWindow::slotAutoTransition()
3707 if (m_activeTimeline)
3708 m_activeTimeline->projectView()->autoTransition();
3711 void MainWindow::slotSplitAudio()
3713 if (m_activeTimeline)
3714 m_activeTimeline->projectView()->splitAudio();
3717 void MainWindow::slotUpdateClipType(QAction *action)
3719 if (m_activeTimeline) {
3720 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3721 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3722 else m_activeTimeline->projectView()->setAudioAndVideo();
3726 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3728 // We must stop the monitors since we create a new on in the dvd wizard
3729 m_clipMonitor->stop();
3730 m_projectMonitor->stop();
3731 DvdWizard w(url, profile, this);
3733 m_projectMonitor->start();
3736 void MainWindow::slotShowTimeline(bool show)
3738 if (show == false) {
3739 m_timelineState = saveState();
3740 centralWidget()->setHidden(true);
3742 centralWidget()->setHidden(false);
3743 restoreState(m_timelineState);
3747 void MainWindow::slotMaximizeCurrent(bool)
3749 //TODO: is there a way to maximize current widget?
3751 m_timelineState = saveState();
3752 QWidget *par = focusWidget()->parentWidget();
3753 while (par->parentWidget() && par->parentWidget() != this)
3754 par = par->parentWidget();
3755 kDebug() << "CURRENT WIDGET: " << par->objectName();
3758 void MainWindow::loadTranscoders()
3760 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3763 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3764 KConfigGroup transConfig(config, "Transcoding");
3766 QMap< QString, QString > profiles = transConfig.entryMap();
3767 QMapIterator<QString, QString> i(profiles);
3768 while (i.hasNext()) {
3770 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3771 QAction *a = transMenu->addAction(i.key());
3773 if (data.count() > 1)
3774 a->setToolTip(data.at(1));
3775 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3779 void MainWindow::slotTranscode(KUrl::List urls)
3784 if (urls.isEmpty()) {
3785 QAction *action = qobject_cast<QAction *>(sender());
3786 QStringList data = action->data().toStringList();
3787 params = data.at(0);
3788 if (data.count() > 1) desc = data.at(1);
3789 if (data.count() > 2) condition = data.at(2);
3790 urls << m_projectList->getConditionalUrls(condition);
3791 urls.removeAll(KUrl());
3793 if (urls.isEmpty()) {
3794 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3797 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3798 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3800 //QProcess::startDetached("ffmpeg", parameters);
3803 void MainWindow::slotTranscodeClip()
3805 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3806 if (urls.isEmpty()) return;
3807 slotTranscode(urls);
3810 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3812 if (m_activeDocument == NULL) return;
3813 QMapIterator<QString, QString> i(props);
3814 while (i.hasNext()) {
3816 m_activeDocument->setDocumentProperty(i.key(), i.value());
3818 m_activeDocument->setModified(true);
3822 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3824 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3826 QString playlistPath;
3829 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3830 QString path = m_renderWidget->getFreeScriptName();
3831 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3832 if (!ok || scriptPath.isEmpty()) return;
3833 scriptPath.prepend(scriptsFolder);
3834 QFile f(scriptPath);
3836 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3839 playlistPath = scriptPath + ".mlt";
3841 KTemporaryFile temp;
3842 temp.setAutoRemove(false);
3843 temp.setSuffix(".mlt");
3845 playlistPath = temp.fileName();
3847 QString playlistContent = m_projectMonitor->sceneList();
3848 if (!chapterFile.isEmpty()) {
3851 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3853 in = m_activeTimeline->inPoint();
3854 out = m_activeTimeline->outPoint();
3857 QDomElement chapters = doc.createElement("chapters");
3858 chapters.setAttribute("fps", m_activeDocument->fps());
3859 doc.appendChild(chapters);
3861 QDomElement guidesxml = m_activeDocument->guidesXml();
3862 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3863 for (int i = 0; i < nodes.count(); i++) {
3864 QDomElement e = nodes.item(i).toElement();
3866 QString comment = e.attribute("comment");
3867 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3868 if (time >= in && time < out) {
3869 if (zoneOnly) time = time - in;
3870 QDomElement chapter = doc.createElement("chapter");
3871 chapters.appendChild(chapter);
3872 chapter.setAttribute("title", comment);
3873 chapter.setAttribute("time", time);
3877 if (chapters.childNodes().count() > 0) {
3878 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3879 // Always insert a guide in pos 0
3880 QDomElement chapter = doc.createElement("chapter");
3881 chapters.insertBefore(chapter, QDomNode());
3882 chapter.setAttribute("title", i18n("Start"));
3883 chapter.setAttribute("time", "0");
3885 // save chapters file
3886 QFile file(chapterFile);
3887 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3888 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3890 file.write(doc.toString().toUtf8());
3891 if (file.error() != QFile::NoError) {
3892 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3899 if (m_renderWidget->automaticAudioExport()) {
3900 exportAudio = m_activeTimeline->checkProjectAudio();
3901 } else exportAudio = m_renderWidget->selectedAudioExport();
3903 // Set playlist audio volume to 100%
3905 doc.setContent(playlistContent);
3906 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3907 if (!tractor.isNull()) {
3908 QDomNodeList props = tractor.elementsByTagName("property");
3909 for (int i = 0; i < props.count(); i++) {
3910 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3911 props.at(i).firstChild().setNodeValue("1");
3917 // Do we want proxy rendering
3918 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3919 QString root = doc.documentElement().attribute("root");
3921 // replace proxy clips with originals
3922 QMap <QString, QString> proxies = m_projectList->getProxies();
3924 QDomNodeList producers = doc.elementsByTagName("producer");
3925 QString producerResource;
3927 for (uint n = 0; n < producers.length(); n++) {
3928 QDomElement e = producers.item(n).toElement();
3929 producerResource = EffectsList::property(e, "resource");
3930 if (producerResource.isEmpty()) continue;
3931 if (!producerResource.startsWith("/")) {
3932 producerResource.prepend(root + "/");
3934 if (producerResource.contains('?')) {
3935 // slowmotion producer
3936 suffix = "?" + producerResource.section('?', 1);
3937 producerResource = producerResource.section('?', 0, 0);
3939 else suffix.clear();
3940 if (!producerResource.isEmpty()) {
3941 if (proxies.contains(producerResource)) {
3942 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3943 // We need to delete the "aspect_ratio" property because proxy clips
3944 // sometimes have different ratio than original clips
3945 EffectsList::removeProperty(e, "aspect_ratio");
3946 EffectsList::removeMetaProperties(e);
3951 /*QMapIterator<QString, QString> i(proxies);
3952 while (i.hasNext()) {
3954 // Replace all keys with their values (proxy path with original path)
3955 QString key = i.key();
3956 playlistContent.replace(key, i.value());
3957 if (!root.isEmpty() && key.startsWith(root)) {
3958 // in case the resource path in MLT playlist is relative
3959 key.remove(0, root.count() + 1);
3960 playlistContent.replace(key, i.value());
3964 playlistContent = doc.toString();
3966 // Do save scenelist
3967 QFile file(playlistPath);
3968 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3969 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3972 file.write(playlistContent.toUtf8());
3973 if (file.error() != QFile::NoError) {
3974 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3979 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3982 void MainWindow::slotUpdateTimecodeFormat(int ix)
3984 KdenliveSettings::setFrametimecode(ix == 1);
3985 m_clipMonitor->updateTimecodeFormat();
3986 m_projectMonitor->updateTimecodeFormat();
3987 m_transitionConfig->updateTimecodeFormat();
3988 m_effectStack->updateTimecodeFormat();
3989 //m_activeTimeline->projectView()->clearSelection();
3990 m_activeTimeline->updateRuler();
3993 void MainWindow::slotRemoveFocus()
3995 statusBar()->setFocus();
3996 statusBar()->clearFocus();
3999 void MainWindow::slotRevert()
4001 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;
4002 KUrl url = m_activeDocument->url();
4003 if (closeCurrentDocument(false))
4004 doOpenFile(url, NULL);
4008 void MainWindow::slotShutdown()
4010 if (m_activeDocument) m_activeDocument->setModified(false);
4012 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4013 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4014 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4015 smserver.call("logout", 1, 2, 2);
4016 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4017 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4018 smserver.call("Shutdown");
4022 void MainWindow::slotUpdateTrackInfo()
4024 if (m_activeDocument)
4025 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4028 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4030 // Load the theme file
4032 if (action == NULL) theme = themename;
4033 else theme = action->data().toString();
4034 KdenliveSettings::setColortheme(theme);
4035 // Make palette for all widgets.
4036 QPalette plt = kapp->palette();
4037 if (theme.isEmpty()) {
4038 plt = QApplication::desktop()->palette();
4040 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4042 #if KDE_IS_VERSION(4,6,3)
4043 plt = KGlobalSettings::createNewApplicationPalette(config);
4045 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4046 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4047 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4048 QPalette::Disabled };
4049 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4050 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4052 for ( int i = 0; i < 3 ; i++ ) {
4053 QPalette::ColorGroup state = states[i];
4054 KColorScheme schemeView(state, KColorScheme::View, config);
4055 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4056 KColorScheme schemeButton(state, KColorScheme::Button, config);
4057 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4059 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4060 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4061 plt.setBrush( state, QPalette::Base, schemeView.background() );
4062 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4063 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4064 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4065 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4066 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4067 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4068 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4070 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4071 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4072 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4073 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4074 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4076 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4077 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4078 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4083 kapp->setPalette(plt);
4084 const QObjectList children = statusBar()->children();
4086 foreach(QObject * child, children) {
4087 if (child->isWidgetType())
4088 ((QWidget*)child)->setPalette(plt);
4089 const QObjectList subchildren = child->children();
4090 foreach(QObject * subchild, subchildren) {
4091 if (subchild->isWidgetType())
4092 ((QWidget*)subchild)->setPalette(plt);
4095 if (m_activeTimeline) {
4096 m_activeTimeline->projectView()->updatePalette();
4101 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4103 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4104 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4105 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4106 const QSize bitsSize(24, 2);
4107 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4108 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4110 QPixmap pixmap(23, 16);
4111 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4113 KConfigGroup group(config, "WM");
4114 QPainter p(&pixmap);
4115 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4116 p.fillRect(1, 1, 7, 7, windowScheme.background());
4117 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4119 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4120 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4121 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4123 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4124 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4126 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4127 p.fillRect(1, 8, 7, 7, viewScheme.background());
4128 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4130 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4131 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4132 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4134 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4135 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4141 void MainWindow::slotSwitchMonitors()
4143 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4144 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4145 else m_projectList->focusTree();
4148 void MainWindow::slotSwitchFullscreen()
4150 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4151 else m_clipMonitor->slotSwitchFullScreen();
4154 void MainWindow::slotInsertZoneToTree()
4156 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4157 QStringList info = m_clipMonitor->getZoneInfo();
4158 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4161 void MainWindow::slotInsertZoneToTimeline()
4163 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4164 QStringList info = m_clipMonitor->getZoneInfo();
4165 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4169 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4171 if (m_activeDocument && m_activeTimeline) {
4172 if (!ids.isEmpty()) {
4173 for (int i = 0; i < ids.size(); ++i) {
4174 m_activeTimeline->slotDeleteClip(ids.at(i));
4176 m_activeDocument->clipManager()->slotDeleteClips(ids);
4178 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4179 m_activeDocument->setModified(true);
4183 void MainWindow::slotShowTitleBars(bool show)
4185 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4186 for (int i = 0; i < docks.count(); i++) {
4187 QDockWidget* dock = docks.at(i);
4189 dock->setTitleBarWidget(0);
4191 if (!dock->isFloating()) {
4192 dock->setTitleBarWidget(new QWidget);
4196 KdenliveSettings::setShowtitlebars(show);
4199 void MainWindow::slotSwitchTitles()
4201 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4204 QString MainWindow::getMimeType(bool open)
4206 QString mimetype = "application/x-kdenlive";
4207 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4209 mimetype = "*.kdenlive";
4210 if (open) mimetype.append(" *.tar.gz");
4212 else if (open) mimetype.append(" application/x-compressed-tar");
4216 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4219 m_projectMonitor->render->sendFrameForAnalysis = true;
4222 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4223 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4230 qDebug() << "Any scope accepting new frames? " << request;
4233 m_projectMonitor->render->sendFrameForAnalysis = false;
4237 void MainWindow::slotUpdateGfxScopeFrameRequest()
4239 // We need a delay to make sure widgets are hidden after a close event for example
4240 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4243 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4246 bool request = false;
4247 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4248 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4249 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4255 if (!m_projectMonitor->effectSceneDisplayed()) {
4256 m_projectMonitor->render->sendFrameForAnalysis = false;
4258 m_clipMonitor->render->sendFrameForAnalysis = false;
4260 m_recMonitor->analyseFrames(false);
4262 m_projectMonitor->render->sendFrameForAnalysis = true;
4263 m_clipMonitor->render->sendFrameForAnalysis = true;
4265 m_recMonitor->analyseFrames(true);
4269 void MainWindow::slotUpdateAudioScopeFrameRequest()
4271 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4274 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4276 bool request = false;
4277 for (int i = 0; i < m_audioScopesList.count(); i++) {
4278 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4279 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4284 // Handle audio signal separately (no common interface)
4285 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4286 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4290 qDebug() << "Scopes Requesting Audio data: " << request;
4292 KdenliveSettings::setMonitor_audio(request);
4293 m_monitorManager->slotUpdateAudioMonitoring();
4296 void MainWindow::slotUpdateColorScopes()
4298 bool request = false;
4299 kDebug()<<"// UPDATE SCOPES";
4300 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4301 // Check if we need the renderer to send a new frame for update
4302 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4303 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4305 if (request && m_monitorManager->activeRenderer()) {
4306 m_monitorManager->activeRenderer()->sendFrameUpdate();
4310 void MainWindow::slotClearColorScopes()
4312 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4313 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4317 void MainWindow::slotOpenStopmotion()
4319 if (m_stopmotion == NULL) {
4320 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4321 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4322 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4323 // Check if we need the renderer to send a new frame for update
4324 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4325 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4326 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4329 m_stopmotion->show();
4332 void MainWindow::slotDeleteClip(const QString &id)
4334 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4335 for (int i = 0; i < list.size(); ++i) {
4336 list.at(i)->disableClipId(id);
4338 m_projectList->slotDeleteClip(id);
4341 void MainWindow::slotUpdateProxySettings()
4343 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4344 if (KdenliveSettings::enableproxy())
4345 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4346 m_projectList->updateProxyConfig();
4349 void MainWindow::slotInsertNotesTimecode()
4351 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4352 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4353 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4356 void MainWindow::slotArchiveProject()
4358 QList <DocClipBase*> list = m_projectList->documentClipList();
4359 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4360 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4365 void MainWindow::slotOpenBackupDialog(const KUrl url)
4370 kDebug()<<"// BACKUP URL: "<<url.path();
4371 if (!url.isEmpty()) {
4372 // we could not open the project file, guess where the backups are
4373 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4377 projectFolder = m_activeDocument->projectFolder();
4378 projectFile = m_activeDocument->url();
4379 projectId = m_activeDocument->getDocumentProperty("documentid");
4382 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4383 if (dia->exec() == QDialog::Accepted) {
4384 QString requestedBackup = dia->selectedFile();
4385 m_activeDocument->backupLastSavedVersion(projectFile.path());
4386 closeCurrentDocument(false);
4387 doOpenFile(KUrl(requestedBackup), NULL);
4388 m_activeDocument->setUrl(projectFile);
4389 m_activeDocument->setModified(true);
4390 setCaption(m_activeDocument->description());
4395 void MainWindow::slotElapsedTime()
4397 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4400 #include "mainwindow.moc"