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 "config-kdenlive.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 #if KDE_IS_VERSION(4,3,80)
96 #include <knewstuff3/downloaddialog.h>
97 #include <knewstuff3/knewstuffaction.h>
99 #include <knewstuff2/engine.h>
100 #include <knewstuff2/ui/knewstuffaction.h>
104 #include <KColorScheme>
105 #include <KProgressDialog>
107 #include <QTextStream>
111 #include <QInputDialog>
112 #include <QDesktopWidget>
118 // Uncomment for deeper debugging
119 //#define DEBUG_MAINW
125 static const char version[] = VERSION;
127 static const int ID_TIMELINE_POS = 0;
133 Q_DECLARE_METATYPE(QVector<int16_t>)
136 EffectsList MainWindow::videoEffects;
137 EffectsList MainWindow::audioEffects;
138 EffectsList MainWindow::customEffects;
139 EffectsList MainWindow::transitions;
141 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
142 KXmlGuiWindow(parent),
143 m_activeDocument(NULL),
144 m_activeTimeline(NULL),
146 m_renderWidget(NULL),
147 #ifdef USE_JOGSHUTTLE
151 m_findActivated(false),
154 qRegisterMetaType<QVector<int16_t> > ();
155 qRegisterMetaType<stringMap> ("stringMap");
156 qRegisterMetaType<audioByteArray> ("audioByteArray");
159 QLocale systemLocale = QLocale();
160 setlocale(LC_NUMERIC, NULL);
161 char *separator = localeconv()->decimal_point;
162 if (separator != systemLocale.decimalPoint()) {
163 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
164 // HACK: There is a locale conflict, so set locale to at least have correct decimal point
165 if (strncmp(separator, ".", 1) == 0) systemLocale = QLocale::c();
166 else if (strncmp(separator, ",", 1) == 0) systemLocale = QLocale("fr_FR.UTF-8");
169 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
170 QLocale::setDefault(systemLocale);
172 // Create DBus interface
173 new MainWindowAdaptor(this);
174 QDBusConnection dbus = QDBusConnection::sessionBus();
175 dbus.registerObject("/MainWindow", this);
177 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
178 setFont(KGlobalSettings::toolBarFont());
179 parseProfiles(MltPath);
180 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
181 m_commandStack = new QUndoGroup;
182 setDockNestingEnabled(true);
183 m_timelineArea = new KTabWidget(this);
184 m_timelineArea->setTabReorderingEnabled(true);
185 m_timelineArea->setTabBarHidden(true);
186 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
187 m_timelineArea->setMinimumHeight(200);
189 QToolButton *closeTabButton = new QToolButton;
190 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
191 closeTabButton->setIcon(KIcon("tab-close"));
192 closeTabButton->adjustSize();
193 closeTabButton->setToolTip(i18n("Close the current tab"));
194 m_timelineArea->setCornerWidget(closeTabButton);
195 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
197 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
198 m_findTimer.setSingleShot(true);
200 // FIXME: the next call returns a newly allocated object, which leaks
201 initEffects::parseEffectFiles();
202 //initEffects::parseCustomEffectsFile();
204 m_monitorManager = new MonitorManager();
206 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
207 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
212 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
213 m_projectListDock->setObjectName("project_tree");
214 m_projectList = new ProjectList();
215 m_projectListDock->setWidget(m_projectList);
216 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
218 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
219 m_clipMonitorDock->setObjectName("clip_monitor");
220 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
221 m_clipMonitorDock->setWidget(m_clipMonitor);
223 // Connect the project list
224 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
225 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(activateMonitor()));
226 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
227 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
228 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
229 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
230 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
231 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
232 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
233 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
235 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
236 m_projectMonitorDock->setObjectName("project_monitor");
237 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
238 m_projectMonitorDock->setWidget(m_projectMonitor);
241 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
242 m_recMonitorDock->setObjectName("record_monitor");
243 m_recMonitor = new RecMonitor("record", m_monitorManager);
244 m_recMonitorDock->setWidget(m_recMonitor);
245 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
246 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
247 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
248 #endif /* ! Q_WS_MAC */
249 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
251 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
252 m_notesDock->setObjectName("notes_widget");
253 m_notesWidget = new NotesWidget();
254 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
255 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
257 m_notesWidget->setTabChangesFocus(true);
258 #if KDE_IS_VERSION(4,4,0)
259 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
261 m_notesDock->setWidget(m_notesWidget);
262 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
264 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
265 m_effectStackDock->setObjectName("effect_stack");
266 m_effectStack = new EffectStackView(m_projectMonitor);
267 m_effectStackDock->setWidget(m_effectStack);
268 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
270 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
271 m_transitionConfigDock->setObjectName("transition");
272 m_transitionConfig = new TransitionSettings(m_projectMonitor);
273 m_transitionConfigDock->setWidget(m_transitionConfig);
274 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
276 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
277 m_effectListDock->setObjectName("effect_list");
278 m_effectList = new EffectsListView();
279 m_effectListDock->setWidget(m_effectList);
280 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
282 m_vectorscope = new Vectorscope(m_monitorManager);
283 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
284 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
285 m_vectorscopeDock->setWidget(m_vectorscope);
286 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
287 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
288 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
289 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
290 m_gfxScopesList.append(m_vectorscopeDock);
292 m_waveform = new Waveform(m_monitorManager);
293 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
294 m_waveformDock->setObjectName(m_waveform->widgetName());
295 m_waveformDock->setWidget(m_waveform);
296 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
297 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
298 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
299 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
300 m_gfxScopesList.append(m_waveformDock);
302 m_RGBParade = new RGBParade(m_monitorManager);
303 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
304 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
305 m_RGBParadeDock->setWidget(m_RGBParade);
306 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
307 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
308 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
309 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
310 m_gfxScopesList.append(m_RGBParadeDock);
312 m_histogram = new Histogram(m_monitorManager);
313 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
314 m_histogramDock->setObjectName(m_histogram->widgetName());
315 m_histogramDock->setWidget(m_histogram);
316 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
317 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
318 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
319 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
320 m_gfxScopesList.append(m_histogramDock);
323 m_audiosignal = new AudioSignal;
324 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
325 m_audiosignalDock->setObjectName("audiosignal");
326 m_audiosignalDock->setWidget(m_audiosignal);
327 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
328 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
329 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
331 m_audioSpectrum = new AudioSpectrum();
332 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
333 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
334 m_audioSpectrumDock->setWidget(m_audioSpectrum);
335 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
336 m_audioScopesList.append(m_audioSpectrum);
337 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
338 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
340 m_spectrogram = new Spectrogram();
341 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
342 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
343 m_spectrogramDock->setWidget(m_spectrogram);
344 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
345 m_audioScopesList.append(m_spectrogram);
346 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
347 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
349 // Connect the audio signal to the audio scope slots
351 if (m_projectMonitor) {
352 qDebug() << "project monitor connected";
353 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
354 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
355 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
356 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
357 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
358 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
361 qDebug() << "clip monitor connected";
362 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
363 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
364 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
365 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
366 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
367 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
369 // Ensure connections were set up correctly
374 // Add monitors here to keep them at the right of the window
375 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
376 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
378 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
381 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
382 m_undoViewDock->setObjectName("undo_history");
383 m_undoView = new QUndoView();
384 m_undoView->setCleanIcon(KIcon("edit-clear"));
385 m_undoView->setEmptyLabel(i18n("Clean"));
386 m_undoViewDock->setWidget(m_undoView);
387 m_undoView->setGroup(m_commandStack);
388 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
392 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
395 // Close non-general docks for the initial layout
396 // only show important ones
397 m_histogramDock->close();
398 m_RGBParadeDock->close();
399 m_waveformDock->close();
400 m_vectorscopeDock->close();
402 m_audioSpectrumDock->close();
403 m_spectrogramDock->close();
404 m_audiosignalDock->close();
406 m_undoViewDock->close();
410 /// Tabify Widgets ///
411 tabifyDockWidget(m_effectListDock, m_effectStackDock);
412 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
413 tabifyDockWidget(m_projectListDock, m_notesDock);
415 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
417 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
423 setCentralWidget(m_timelineArea);
426 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
428 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
429 m_fileRevert->setEnabled(false);
431 // Prepare layout actions
432 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
433 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
434 for (int i = 1; i < 5; i++) {
435 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
436 load->setData("_" + QString::number(i));
437 layoutActions->addAction("load_layout" + QString::number(i), load);
438 m_loadLayout->addAction(load);
439 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
440 save->setData("_" + QString::number(i));
441 layoutActions->addAction("save_layout" + QString::number(i), save);
443 layoutActions->addAction("load_layouts", m_loadLayout);
444 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
447 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
448 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
449 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
450 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
451 m_stopmotion_actions->addAction("stopmotion_capture", action);
452 action = new KAction(i18n("Switch live / captured frame"), this);
453 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
454 m_stopmotion_actions->addAction("stopmotion_switch", action);
455 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
456 action->setCheckable(true);
457 action->setChecked(false);
458 m_stopmotion_actions->addAction("stopmotion_overlay", action);
460 // Build effects menu
461 m_effectsMenu = new QMenu(i18n("Add Effect"));
462 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
463 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
464 m_effectsActionCollection->readSettings();
468 // Find QDockWidget tab bars and show / hide widget title bars on right click
469 QList <QTabBar *> tabs = findChildren<QTabBar *>();
470 for (int i = 0; i < tabs.count(); i++) {
471 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
472 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
475 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
476 guiFactory()->addClient(sp);*/
478 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
480 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
483 // Load layout names from config file
490 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
491 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
493 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
494 clipInTimeline->setIcon(KIcon("go-jump"));
495 QHash<QString,QMenu*> menus;
496 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
497 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
498 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
499 menus.insert("inTimelineMenu",clipInTimeline);
500 m_projectList->setupGeneratorMenu(menus);
502 // build themes menus
503 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
504 QActionGroup *themegroup = new QActionGroup(this);
505 themegroup->setExclusive(true);
506 action = new KAction(i18n("Default"), this);
507 action->setCheckable(true);
508 themegroup->addAction(action);
509 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
511 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
513 for (int i = 0; i < schemeFiles.size(); ++i) {
515 const QString filename = schemeFiles.at(i);
516 const QFileInfo info(filename);
519 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
520 QIcon icon = createSchemePreviewIcon(config);
521 KConfigGroup group(config, "General");
522 const QString name = group.readEntry("Name", info.baseName());
523 action = new KAction(name, this);
524 action->setData(filename);
525 action->setIcon(icon);
526 action->setCheckable(true);
527 themegroup->addAction(action);
528 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
531 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
532 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
533 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
536 action = new QAction(fi.fileName(), this);
537 action->setData(*it);
538 action->setCheckable(true);
539 themegroup->addAction(action);
540 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
542 themesMenu->addActions(themegroup->actions());
543 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
545 // Setup and fill effects and transitions menus.
548 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
549 m->addActions(m_effectsMenu->actions());
552 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
553 for (int i = 0; i < transitions.count(); ++i)
554 m_transitionsMenu->addAction(m_transitions[i]);
556 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
557 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
558 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
560 m_effectStack->setMenu(m_effectsMenu);
562 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
563 const QList<QAction *> viewActions = createPopupMenu()->actions();
564 viewMenu->insertActions(NULL, viewActions);
566 m_timelineContextMenu = new QMenu(this);
567 m_timelineContextClipMenu = new QMenu(this);
568 m_timelineContextTransitionMenu = new QMenu(this);
570 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
571 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
572 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
574 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
575 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
576 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
577 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
578 m_timelineContextClipMenu->addSeparator();
579 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
580 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
581 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
582 m_timelineContextClipMenu->addSeparator();
583 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
584 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
585 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
586 m_timelineContextClipMenu->addSeparator();
588 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
589 m_timelineContextClipMenu->addMenu(markersMenu);
590 m_timelineContextClipMenu->addSeparator();
591 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
592 m_timelineContextClipMenu->addMenu(m_effectsMenu);
594 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
595 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
596 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
598 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
600 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
601 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
602 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
603 connect(m_monitorManager, SIGNAL(clearScopes()), this, SLOT(slotClearColorScopes()));
604 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
605 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
607 slotConnectMonitors();
609 // Open or create a file. Command line argument passed in Url has
610 // precedence, then "openlastproject", then just a plain empty file.
611 // If opening Url fails, openlastproject will _not_ be used.
612 if (!Url.isEmpty()) {
613 // delay loading so that the window shows up
615 QTimer::singleShot(500, this, SLOT(openFile()));
616 } else if (KdenliveSettings::openlastproject()) {
617 QTimer::singleShot(500, this, SLOT(openLastFile()));
618 } else { //if (m_timelineArea->count() == 0) {
622 if (!clipsToLoad.isEmpty() && m_activeDocument) {
623 QStringList list = clipsToLoad.split(',');
625 foreach(QString path, list) {
626 kDebug() << QDir::current().absoluteFilePath(path);
627 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
629 m_projectList->slotAddClip(urls);
632 #ifdef USE_JOGSHUTTLE
633 activateShuttleDevice();
635 m_projectListDock->raise();
637 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
638 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
640 // Populate encoding profiles
641 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
642 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
643 KConfigGroup group(&conf, "proxy");
644 QMap< QString, QString > values = group.entryMap();
645 QMapIterator<QString, QString> i(values);
648 QString data = i.value();
649 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
650 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
653 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
654 KConfigGroup group(&conf, "video4linux");
655 QMap< QString, QString > values = group.entryMap();
656 QMapIterator<QString, QString> i(values);
659 QString data = i.value();
660 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
661 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
664 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
665 KConfigGroup group(&conf, "decklink");
666 QMap< QString, QString > values = group.entryMap();
667 QMapIterator<QString, QString> i(values);
670 QString data = i.value();
671 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
672 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
677 MainWindow::~MainWindow()
682 m_effectStack->slotClipItemSelected(NULL, 0);
683 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
685 if (m_projectMonitor) m_projectMonitor->stop();
686 if (m_clipMonitor) m_clipMonitor->stop();
688 delete m_activeTimeline;
689 delete m_effectStack;
690 delete m_transitionConfig;
691 delete m_activeDocument;
692 delete m_projectMonitor;
693 delete m_clipMonitor;
694 delete m_shortcutRemoveFocus;
695 delete[] m_transitions;
696 Mlt::Factory::close();
700 bool MainWindow::queryClose()
702 if (m_renderWidget) {
703 int waitingJobs = m_renderWidget->waitingJobsCount();
704 if (waitingJobs > 0) {
705 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")))) {
706 case KMessageBox::Yes :
707 // create script with waiting jobs and start it
708 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
710 case KMessageBox::No :
711 // Don't do anything, jobs will be deleted
719 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
720 // warn the user to save if document is modified and we have clips in our project list
721 if (m_activeDocument && m_activeDocument->isModified() &&
722 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
723 !m_projectList->documentClipList().isEmpty())) {
727 if (m_activeDocument->url().fileName().isEmpty())
728 message = i18n("Save changes to document?");
730 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
731 switch (KMessageBox::warningYesNoCancel(this, message)) {
732 case KMessageBox::Yes :
733 // save document here. If saving fails, return false;
735 case KMessageBox::No :
736 // User does not want to save the changes, clear recovery files
737 m_activeDocument->m_autosave->resize(0);
746 void MainWindow::loadPlugins()
748 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
749 populateMenus(plugin);
752 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
754 filters << "libkdenlive*";
755 foreach(const QString & folder, directories) {
756 kDebug() << "Parsing plugin folder: " << folder;
757 QDir pluginsDir(folder);
758 foreach(const QString & fileName,
759 pluginsDir.entryList(filters, QDir::Files)) {
761 * Avoid loading the same plugin twice when there is more than one
764 if (!m_pluginFileNames.contains(fileName)) {
765 kDebug() << "Found plugin: " << fileName;
766 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
767 QObject *plugin = loader.instance();
769 populateMenus(plugin);
770 m_pluginFileNames += fileName;
772 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
778 void MainWindow::populateMenus(QObject *plugin)
780 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
781 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
783 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
787 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
788 QMenu *menu, const char *member,
789 QActionGroup *actionGroup)
791 kDebug() << "// ADD to MENU" << texts;
792 foreach(const QString & text, texts) {
793 QAction *action = new QAction(text, plugin);
794 action->setData(text);
795 connect(action, SIGNAL(triggered()), this, member);
796 menu->addAction(action);
799 action->setCheckable(true);
800 actionGroup->addAction(action);
805 void MainWindow::aboutPlugins()
807 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
812 void MainWindow::generateClip()
814 QAction *action = qobject_cast<QAction *>(sender());
815 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
817 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
818 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
819 if (!clipUrl.isEmpty()) {
820 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
824 void MainWindow::saveProperties(KConfigGroup &config)
826 // save properties here,used by session management
828 KMainWindow::saveProperties(config);
832 void MainWindow::readProperties(const KConfigGroup &config)
834 // read properties here,used by session management
835 KMainWindow::readProperties(config);
836 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
837 openFile(KUrl(Lastproject));
840 void MainWindow::slotReloadEffects()
842 initEffects::parseCustomEffectsFile();
843 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
846 #ifdef USE_JOGSHUTTLE
847 void MainWindow::activateShuttleDevice()
853 if (KdenliveSettings::enableshuttle() == false) return;
855 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
856 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
858 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
859 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
860 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
861 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
862 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
864 #endif /* USE_JOGSHUTTLE */
866 void MainWindow::slotDoAction(const QString& action_name)
868 QAction* action = actionCollection()->action(action_name);
870 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
876 void MainWindow::configureNotifications()
878 KNotifyConfigWidget::configure(this);
881 void MainWindow::slotFullScreen()
883 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
886 void MainWindow::slotAddEffect(const QDomElement effect)
888 if (!m_activeDocument) return;
889 if (effect.isNull()) {
890 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
893 QDomElement effectToAdd = effect.cloneNode().toElement();
895 int ix = m_effectStack->isTrackMode(&ok);
896 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
897 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
900 void MainWindow::slotUpdateClip(const QString &id)
902 if (!m_activeDocument) return;
903 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
905 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
906 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
907 Mlt::Producer *monitorProducer = clip->getCloneProducer();
908 m_clipMonitor->updateClipProducer(monitorProducer);
910 clip->cleanupProducers();
913 void MainWindow::slotConnectMonitors()
915 m_projectList->setRenderer(m_projectMonitor->render);
916 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
917 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
918 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
919 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
920 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
921 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)));
923 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
925 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
927 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
929 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
930 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
932 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
934 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
935 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
938 void MainWindow::slotAdjustClipMonitor()
940 m_clipMonitorDock->updateGeometry();
941 m_clipMonitorDock->adjustSize();
942 m_clipMonitor->resetSize();
945 void MainWindow::slotAdjustProjectMonitor()
947 m_projectMonitorDock->updateGeometry();
948 m_projectMonitorDock->adjustSize();
949 m_projectMonitor->resetSize();
953 class NameGrabbingKActionCollection {
955 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
956 : m_collection(collection), m_action_names(action_names) {
957 m_action_names.clear();
959 KAction* addAction(const QString& action_name) {
960 m_action_names << action_name;
961 return m_collection->addAction(action_name);
963 void addAction(const QString& action_name, QAction* action) {
964 m_action_names << action_name;
965 m_collection->addAction(action_name, action);
967 operator KActionCollection*() { return m_collection; }
968 const QStringList& actionNames() const { return m_action_names; }
970 KActionCollection* m_collection;
971 QStringList& m_action_names;
974 void MainWindow::setupActions()
977 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
978 m_timecodeFormat = new KComboBox(this);
979 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
980 m_timecodeFormat->addItem(i18n("Frames"));
981 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
982 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
984 m_statusProgressBar = new QProgressBar(this);
985 m_statusProgressBar->setMinimum(0);
986 m_statusProgressBar->setMaximum(100);
987 m_statusProgressBar->setMaximumWidth(150);
988 m_statusProgressBar->setVisible(false);
990 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
991 toolbar->setMovable(false);
992 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
993 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
994 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
995 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
996 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
997 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());
998 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
1000 //create edit mode buttons
1001 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
1002 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
1003 toolbar->addAction(m_normalEditTool);
1004 m_normalEditTool->setCheckable(true);
1005 m_normalEditTool->setChecked(true);
1007 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
1008 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
1009 toolbar->addAction(m_overwriteEditTool);
1010 m_overwriteEditTool->setCheckable(true);
1011 m_overwriteEditTool->setChecked(false);
1013 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
1014 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
1015 toolbar->addAction(m_insertEditTool);
1016 m_insertEditTool->setCheckable(true);
1017 m_insertEditTool->setChecked(false);
1018 // not implemented yet
1019 m_insertEditTool->setEnabled(false);
1021 QActionGroup *editGroup = new QActionGroup(this);
1022 editGroup->addAction(m_normalEditTool);
1023 editGroup->addAction(m_overwriteEditTool);
1024 editGroup->addAction(m_insertEditTool);
1025 editGroup->setExclusive(true);
1026 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
1027 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1029 toolbar->addSeparator();
1031 // create tools buttons
1032 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1033 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1034 toolbar->addAction(m_buttonSelectTool);
1035 m_buttonSelectTool->setCheckable(true);
1036 m_buttonSelectTool->setChecked(true);
1038 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1039 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1040 toolbar->addAction(m_buttonRazorTool);
1041 m_buttonRazorTool->setCheckable(true);
1042 m_buttonRazorTool->setChecked(false);
1044 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1045 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1046 toolbar->addAction(m_buttonSpacerTool);
1047 m_buttonSpacerTool->setCheckable(true);
1048 m_buttonSpacerTool->setChecked(false);
1050 QActionGroup *toolGroup = new QActionGroup(this);
1051 toolGroup->addAction(m_buttonSelectTool);
1052 toolGroup->addAction(m_buttonRazorTool);
1053 toolGroup->addAction(m_buttonSpacerTool);
1054 toolGroup->setExclusive(true);
1055 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1057 QWidget * actionWidget;
1058 int max = toolbar->iconSizeDefault() + 2;
1059 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1060 actionWidget->setMaximumWidth(max);
1061 actionWidget->setMaximumHeight(max - 4);
1063 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1064 actionWidget->setMaximumWidth(max);
1065 actionWidget->setMaximumHeight(max - 4);
1067 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1068 actionWidget->setMaximumWidth(max);
1069 actionWidget->setMaximumHeight(max - 4);
1071 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1072 actionWidget->setMaximumWidth(max);
1073 actionWidget->setMaximumHeight(max - 4);
1075 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1076 actionWidget->setMaximumWidth(max);
1077 actionWidget->setMaximumHeight(max - 4);
1079 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1080 actionWidget->setMaximumWidth(max);
1081 actionWidget->setMaximumHeight(max - 4);
1083 toolbar->setStyleSheet(style1);
1084 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1086 toolbar->addSeparator();
1087 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1088 toolbar->addAction(m_buttonFitZoom);
1089 m_buttonFitZoom->setCheckable(false);
1091 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1092 toolbar->addAction(m_zoomOut);
1093 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1095 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1096 m_zoomSlider->setMaximum(13);
1097 m_zoomSlider->setPageStep(1);
1098 m_zoomSlider->setInvertedAppearance(true);
1100 m_zoomSlider->setMaximumWidth(150);
1101 m_zoomSlider->setMinimumWidth(100);
1102 toolbar->addWidget(m_zoomSlider);
1104 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1105 toolbar->addAction(m_zoomIn);
1106 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1108 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1109 actionWidget->setMaximumWidth(max);
1110 actionWidget->setMaximumHeight(max - 4);
1111 actionWidget->setStyleSheet(styleBorderless);
1113 actionWidget = toolbar->widgetForAction(m_zoomIn);
1114 actionWidget->setMaximumWidth(max);
1115 actionWidget->setMaximumHeight(max - 4);
1116 actionWidget->setStyleSheet(styleBorderless);
1118 actionWidget = toolbar->widgetForAction(m_zoomOut);
1119 actionWidget->setMaximumWidth(max);
1120 actionWidget->setMaximumHeight(max - 4);
1121 actionWidget->setStyleSheet(styleBorderless);
1123 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1124 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1125 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1126 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1127 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1129 toolbar->addSeparator();
1131 //create automatic audio split button
1132 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1133 toolbar->addAction(m_buttonAutomaticSplitAudio);
1134 m_buttonAutomaticSplitAudio->setCheckable(true);
1135 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1136 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1138 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1139 toolbar->addAction(m_buttonVideoThumbs);
1140 m_buttonVideoThumbs->setCheckable(true);
1141 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1142 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1144 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1145 toolbar->addAction(m_buttonAudioThumbs);
1146 m_buttonAudioThumbs->setCheckable(true);
1147 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1148 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1150 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1151 toolbar->addAction(m_buttonShowMarkers);
1152 m_buttonShowMarkers->setCheckable(true);
1153 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1154 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1156 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1157 toolbar->addAction(m_buttonSnap);
1158 m_buttonSnap->setCheckable(true);
1159 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1160 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1162 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1163 actionWidget->setMaximumWidth(max);
1164 actionWidget->setMaximumHeight(max - 4);
1166 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1167 actionWidget->setMaximumWidth(max);
1168 actionWidget->setMaximumHeight(max - 4);
1170 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1171 actionWidget->setMaximumWidth(max);
1172 actionWidget->setMaximumHeight(max - 4);
1174 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1175 actionWidget->setMaximumWidth(max);
1176 actionWidget->setMaximumHeight(max - 4);
1178 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1179 actionWidget->setMaximumWidth(max);
1180 actionWidget->setMaximumHeight(max - 4);
1182 m_messageLabel = new StatusBarMessageLabel(this);
1183 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1185 statusBar()->addWidget(m_messageLabel, 10);
1186 statusBar()->addWidget(m_statusProgressBar, 0);
1187 statusBar()->addPermanentWidget(toolbar);
1188 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1189 statusBar()->addPermanentWidget(m_timecodeFormat);
1190 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1192 collection.addAction("normal_mode", m_normalEditTool);
1193 collection.addAction("overwrite_mode", m_overwriteEditTool);
1194 collection.addAction("insert_mode", m_insertEditTool);
1195 collection.addAction("select_tool", m_buttonSelectTool);
1196 collection.addAction("razor_tool", m_buttonRazorTool);
1197 collection.addAction("spacer_tool", m_buttonSpacerTool);
1199 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1200 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1201 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1202 collection.addAction("show_markers", m_buttonShowMarkers);
1203 collection.addAction("snap", m_buttonSnap);
1204 collection.addAction("zoom_fit", m_buttonFitZoom);
1205 collection.addAction("zoom_in", m_zoomIn);
1206 collection.addAction("zoom_out", m_zoomOut);
1208 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1209 collection.addAction("project_find", m_projectSearch);
1210 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1211 m_projectSearch->setShortcut(Qt::Key_Slash);
1213 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1214 collection.addAction("project_find_next", m_projectSearchNext);
1215 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1216 m_projectSearchNext->setShortcut(Qt::Key_F3);
1217 m_projectSearchNext->setEnabled(false);
1219 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1220 collection.addAction("manage_profiles", profilesAction);
1221 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1223 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1224 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1225 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1226 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1228 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1229 collection.addAction("run_wizard", wizAction);
1230 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1232 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1233 collection.addAction("project_settings", projectAction);
1234 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1236 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1237 collection.addAction("open_backup", backupAction);
1238 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1240 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1241 collection.addAction("project_render", projectRender);
1242 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1243 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1245 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1246 collection.addAction("project_clean", projectClean);
1247 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1249 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1250 collection.addAction("project_adjust_profile", projectAdjust);
1251 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1253 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1254 KShortcut playShortcut;
1255 playShortcut.setPrimary(Qt::Key_Space);
1256 playShortcut.setAlternate(Qt::Key_K);
1257 monitorPlay->setShortcut(playShortcut);
1258 collection.addAction("monitor_play", monitorPlay);
1259 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1261 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1262 collection.addAction("monitor_pause", monitorPause);
1263 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1265 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1266 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1267 collection.addAction("monitor_play_zone", m_playZone);
1268 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1270 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1271 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1272 collection.addAction("monitor_loop_zone", m_loopZone);
1273 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1275 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1276 m_loopClip->setEnabled(false);
1277 collection.addAction("monitor_loop_clip", m_loopClip);
1278 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1280 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1281 collection.addAction("dvd_wizard", dvdWizard);
1282 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1284 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1285 collection.addAction("transcode_clip", transcodeClip);
1286 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1288 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1289 collection.addAction("archive_project", archiveProject);
1290 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1293 KAction *markIn = collection.addAction("mark_in");
1294 markIn->setText(i18n("Set Zone In"));
1295 markIn->setShortcut(Qt::Key_I);
1296 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1298 KAction *markOut = collection.addAction("mark_out");
1299 markOut->setText(i18n("Set Zone Out"));
1300 markOut->setShortcut(Qt::Key_O);
1301 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1303 KAction *switchMon = collection.addAction("switch_monitor");
1304 switchMon->setText(i18n("Switch monitor"));
1305 switchMon->setShortcut(Qt::Key_T);
1306 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1308 KAction *fullMon = collection.addAction("monitor_fullscreen");
1309 fullMon->setText(i18n("Switch monitor fullscreen"));
1310 fullMon->setIcon(KIcon("view-fullscreen"));
1311 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1313 KAction *insertTree = collection.addAction("insert_project_tree");
1314 insertTree->setText(i18n("Insert zone in project tree"));
1315 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1316 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1318 KAction *insertTimeline = collection.addAction("insert_timeline");
1319 insertTimeline->setText(i18n("Insert zone in timeline"));
1320 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1321 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1323 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1324 collection.addAction("resize_timeline_clip_start", resizeStart);
1325 resizeStart->setShortcut(Qt::Key_1);
1326 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1328 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1329 collection.addAction("resize_timeline_clip_end", resizeEnd);
1330 resizeEnd->setShortcut(Qt::Key_2);
1331 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1333 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1334 monitorSeekBackward->setShortcut(Qt::Key_J);
1335 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1336 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1338 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1339 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1340 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1341 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1343 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1344 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1345 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1346 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1348 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1349 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1350 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1351 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1353 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1354 monitorSeekForward->setShortcut(Qt::Key_L);
1355 collection.addAction("monitor_seek_forward", monitorSeekForward);
1356 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1358 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1359 clipStart->setShortcut(Qt::Key_Home);
1360 collection.addAction("seek_clip_start", clipStart);
1361 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1363 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1364 clipEnd->setShortcut(Qt::Key_End);
1365 collection.addAction("seek_clip_end", clipEnd);
1366 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1368 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1369 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1370 collection.addAction("seek_zone_start", zoneStart);
1371 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1373 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1374 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1375 collection.addAction("seek_zone_end", zoneEnd);
1376 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1378 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1379 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1380 collection.addAction("seek_start", projectStart);
1381 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1383 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1384 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1385 collection.addAction("seek_end", projectEnd);
1386 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1388 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1389 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1390 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1391 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1393 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1394 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1395 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1396 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1398 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1399 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1400 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1401 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1403 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1404 deleteItem->setShortcut(Qt::Key_Delete);
1405 collection.addAction("delete_timeline_clip", deleteItem);
1406 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1408 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1409 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1410 editTimelineClipSpeed->setData("change_speed");
1411 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1413 KAction *stickTransition = collection.addAction("auto_transition");
1414 stickTransition->setData(QString("auto"));
1415 stickTransition->setCheckable(true);
1416 stickTransition->setEnabled(false);
1417 stickTransition->setText(i18n("Automatic Transition"));
1418 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1420 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1421 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1422 collection.addAction("group_clip", groupClip);
1423 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1425 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1426 collection.addAction("ungroup_clip", ungroupClip);
1427 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1428 ungroupClip->setData("ungroup_clip");
1429 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1431 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1432 collection.addAction("edit_item_duration", editItemDuration);
1433 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1435 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1436 collection.addAction("clip_in_project_tree", clipInProjectTree);
1437 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1439 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1440 collection.addAction("clip_to_project_tree", clipToProjectTree);
1441 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1443 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1444 insertOvertwrite->setShortcut(Qt::Key_V);
1445 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1446 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1448 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1449 selectTimelineClip->setShortcut(Qt::Key_Plus);
1450 collection.addAction("select_timeline_clip", selectTimelineClip);
1451 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1453 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1454 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1455 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1456 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1458 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1459 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1460 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1461 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1463 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1464 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1465 collection.addAction("select_timeline_transition", selectTimelineTransition);
1466 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1468 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1469 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1470 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1471 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1473 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1474 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1475 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1476 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1478 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1479 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1480 collection.addAction("cut_timeline_clip", cutTimelineClip);
1481 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1483 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1484 collection.addAction("add_clip_marker", addClipMarker);
1485 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1487 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1488 collection.addAction("delete_clip_marker", deleteClipMarker);
1489 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1491 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1492 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1493 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1495 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1496 editClipMarker->setData(QString("edit_marker"));
1497 collection.addAction("edit_clip_marker", editClipMarker);
1498 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1500 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1501 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1502 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1503 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1505 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1506 collection.addAction("split_audio", splitAudio);
1507 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1509 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1510 collection.addAction("clip_audio_only", audioOnly);
1511 audioOnly->setData("clip_audio_only");
1512 audioOnly->setCheckable(true);
1514 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1515 collection.addAction("clip_video_only", videoOnly);
1516 videoOnly->setData("clip_video_only");
1517 videoOnly->setCheckable(true);
1519 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1520 collection.addAction("clip_audio_and_video", audioAndVideo);
1521 audioAndVideo->setData("clip_audio_and_video");
1522 audioAndVideo->setCheckable(true);
1524 m_clipTypeGroup = new QActionGroup(this);
1525 m_clipTypeGroup->addAction(audioOnly);
1526 m_clipTypeGroup->addAction(videoOnly);
1527 m_clipTypeGroup->addAction(audioAndVideo);
1528 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1529 m_clipTypeGroup->setEnabled(false);
1531 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1532 collection.addAction("insert_space", insertSpace);
1533 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1535 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1536 collection.addAction("delete_space", removeSpace);
1537 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1539 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1540 collection.addAction("insert_track", insertTrack);
1541 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1543 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1544 collection.addAction("delete_track", deleteTrack);
1545 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1547 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1548 collection.addAction("config_tracks", configTracks);
1549 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1551 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1552 collection.addAction("add_guide", addGuide);
1553 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1555 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1556 collection.addAction("delete_guide", delGuide);
1557 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1559 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1560 collection.addAction("edit_guide", editGuide);
1561 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1563 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1564 collection.addAction("delete_all_guides", delAllGuides);
1565 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1567 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1568 collection.addAction("paste_effects", pasteEffects);
1569 pasteEffects->setData("paste_effects");
1570 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1572 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1573 collection.addAction("show_timeline", showTimeline);
1574 showTimeline->setCheckable(true);
1575 showTimeline->setChecked(true);
1576 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1578 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1579 collection.addAction("show_titlebars", showTitleBar);
1580 showTitleBar->setCheckable(true);
1581 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1582 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1583 slotShowTitleBars(KdenliveSettings::showtitlebars());
1585 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1586 KStandardAction::quit(this, SLOT(close()), collection);
1587 KStandardAction::open(this, SLOT(openFile()), collection);
1588 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1589 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1590 KStandardAction::openNew(this, SLOT(newFile()), collection);
1591 // TODO: make the following connection to slotEditKeys work
1592 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1593 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1594 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1595 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1596 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1597 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1599 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1600 undo->setEnabled(false);
1601 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1603 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1604 redo->setEnabled(false);
1605 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1608 //TODO: Add status tooltip to actions ?
1609 connect(collection, SIGNAL(actionHovered(QAction*)),
1610 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1613 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1614 collection.addAction("add_clip", addClip);
1615 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1617 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1618 collection.addAction("add_color_clip", addColorClip);
1619 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1621 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1622 collection.addAction("add_slide_clip", addSlideClip);
1623 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1625 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1626 collection.addAction("add_text_clip", addTitleClip);
1627 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1629 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1630 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1631 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1633 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1634 collection.addAction("add_folder", addFolderButton);
1635 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1637 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1638 collection.addAction("clip_properties", clipProperties);
1639 clipProperties->setData("clip_properties");
1640 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1641 clipProperties->setEnabled(false);
1643 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1644 collection.addAction("edit_clip", openClip);
1645 openClip->setData("edit_clip");
1646 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1647 openClip->setEnabled(false);
1649 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1650 collection.addAction("delete_clip", deleteClip);
1651 deleteClip->setData("delete_clip");
1652 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1653 deleteClip->setEnabled(false);
1655 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1656 collection.addAction("reload_clip", reloadClip);
1657 reloadClip->setData("reload_clip");
1658 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1659 reloadClip->setEnabled(false);
1661 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1662 collection.addAction("proxy_clip", proxyClip);
1663 proxyClip->setData("proxy_clip");
1664 proxyClip->setCheckable(true);
1665 proxyClip->setChecked(false);
1666 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1668 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1669 collection.addAction("stopmotion", stopMotion);
1670 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1672 QMenu *addClips = new QMenu();
1673 addClips->addAction(addClip);
1674 addClips->addAction(addColorClip);
1675 addClips->addAction(addSlideClip);
1676 addClips->addAction(addTitleClip);
1677 addClips->addAction(addTitleTemplateClip);
1678 addClips->addAction(addFolderButton);
1680 addClips->addAction(reloadClip);
1681 addClips->addAction(proxyClip);
1682 addClips->addAction(clipProperties);
1683 addClips->addAction(openClip);
1684 addClips->addAction(deleteClip);
1685 m_projectList->setupMenu(addClips, addClip);
1687 // Setup effects and transitions actions.
1688 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1689 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1690 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1691 m_transitions = new KAction*[transitions.count()];
1692 for (int i = 0; i < transitions.count(); i++) {
1693 QStringList effectInfo = transitions.effectIdInfo(i);
1694 m_transitions[i] = new KAction(effectInfo.at(0), this);
1695 m_transitions[i]->setData(effectInfo);
1696 m_transitions[i]->setIconVisibleInMenu(false);
1697 QString id = effectInfo.at(2);
1698 if (id.isEmpty()) id = effectInfo.at(1);
1699 transitionActions->addAction("transition_" + id, m_transitions[i]);
1701 //m_effectsActionCollection->readSettings();
1705 void MainWindow::slotDisplayActionMessage(QAction *a)
1707 statusBar()->showMessage(a->data().toString(), 3000);
1710 void MainWindow::loadLayouts()
1712 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1713 if (m_loadLayout == NULL || saveLayout == NULL) return;
1714 KSharedConfigPtr config = KGlobal::config();
1715 KConfigGroup layoutGroup(config, "Layouts");
1716 QStringList entries = layoutGroup.keyList();
1717 QList<QAction *> loadActions = m_loadLayout->actions();
1718 QList<QAction *> saveActions = saveLayout->actions();
1719 for (int i = 1; i < 5; i++) {
1720 // Rename the layouts actions
1721 foreach(const QString & key, entries) {
1722 if (key.endsWith(QString("_%1").arg(i))) {
1723 // Found previously saved layout
1724 QString layoutName = key.section("_", 0, -2);
1725 for (int j = 0; j < loadActions.count(); j++) {
1726 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1727 loadActions[j]->setText(layoutName);
1728 loadActions[j]->setData(key);
1732 for (int j = 0; j < saveActions.count(); j++) {
1733 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1734 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1735 saveActions[j]->setData(key);
1744 void MainWindow::slotLoadLayout(QAction *action)
1746 if (!action) return;
1747 QString layoutId = action->data().toString();
1748 if (layoutId.isEmpty()) return;
1749 KSharedConfigPtr config = KGlobal::config();
1750 KConfigGroup layouts(config, "Layouts");
1751 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1752 restoreState(state);
1755 void MainWindow::slotSaveLayout(QAction *action)
1757 QString originallayoutName = action->data().toString();
1758 int layoutId = originallayoutName.section('_', -1).toInt();
1760 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1761 if (layoutName.isEmpty()) return;
1762 KSharedConfigPtr config = KGlobal::config();
1763 KConfigGroup layouts(config, "Layouts");
1764 layouts.deleteEntry(originallayoutName);
1766 QByteArray st = saveState();
1767 layoutName.append("_" + QString::number(layoutId));
1768 layouts.writeEntry(layoutName, st.toBase64());
1772 void MainWindow::saveOptions()
1774 KdenliveSettings::self()->writeConfig();
1775 KSharedConfigPtr config = KGlobal::config();
1776 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1777 KConfigGroup treecolumns(config, "Project Tree");
1778 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1782 void MainWindow::readOptions()
1784 KSharedConfigPtr config = KGlobal::config();
1785 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1786 KConfigGroup initialGroup(config, "version");
1787 bool upgrade = false;
1788 if (initialGroup.exists()) {
1789 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1793 if (initialGroup.readEntry("version") == "0.7") {
1794 //Add new settings from 0.7.1
1795 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1796 QString path = QDir::homePath() + "/kdenlive";
1797 if (KStandardDirs::makeDir(path) == false) {
1798 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1799 } else KdenliveSettings::setDefaultprojectfolder(path);
1805 if (!initialGroup.exists() || upgrade) {
1806 // this is our first run, show Wizard
1807 Wizard *w = new Wizard(upgrade, this);
1808 if (w->exec() == QDialog::Accepted && w->isOk()) {
1809 w->adjustSettings();
1810 initialGroup.writeEntry("version", version);
1816 KConfigGroup treecolumns(config, "Project Tree");
1817 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1818 if (!state.isEmpty())
1819 m_projectList->setHeaderInfo(state);
1822 void MainWindow::slotRunWizard()
1824 Wizard *w = new Wizard(false, this);
1825 if (w->exec() == QDialog::Accepted && w->isOk()) {
1826 w->adjustSettings();
1831 void MainWindow::newFile(bool showProjectSettings, bool force)
1833 if (!m_timelineArea->isEnabled() && !force)
1835 m_fileRevert->setEnabled(false);
1836 QString profileName = KdenliveSettings::default_profile();
1837 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1838 QMap <QString, QString> documentProperties;
1839 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1840 if (!showProjectSettings) {
1841 if (!KdenliveSettings::activatetabs())
1842 if (!closeCurrentDocument())
1845 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1846 if (w->exec() != QDialog::Accepted)
1848 if (!KdenliveSettings::activatetabs())
1849 if (!closeCurrentDocument())
1851 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1852 slotSwitchVideoThumbs();
1853 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1854 slotSwitchAudioThumbs();
1855 profileName = w->selectedProfile();
1856 projectFolder = w->selectedFolder();
1857 projectTracks = w->tracks();
1858 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1859 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1860 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1861 documentProperties.insert("proxyparams", w->proxyParams());
1862 documentProperties.insert("proxyextension", w->proxyExtension());
1863 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1864 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1867 m_timelineArea->setEnabled(true);
1868 m_projectList->setEnabled(true);
1870 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1871 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1873 TrackView *trackView = new TrackView(doc, &ok, this);
1874 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1877 //m_timelineArea->setEnabled(false);
1878 //m_projectList->setEnabled(false);
1882 if (m_timelineArea->count() == 1) {
1883 connectDocumentInfo(doc);
1884 connectDocument(trackView, doc);
1886 m_timelineArea->setTabBarHidden(false);
1887 m_monitorManager->activateMonitor("clip");
1888 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1891 void MainWindow::activateDocument()
1893 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1894 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1895 KdenliveDoc *currentDoc = currentTab->document();
1896 connectDocumentInfo(currentDoc);
1897 connectDocument(currentTab, currentDoc);
1900 bool MainWindow::closeCurrentDocument(bool saveChanges)
1902 QWidget *w = m_timelineArea->currentWidget();
1903 if (!w) return true;
1904 // closing current document
1905 int ix = m_timelineArea->currentIndex() + 1;
1906 if (ix == m_timelineArea->count()) ix = 0;
1907 m_timelineArea->setCurrentIndex(ix);
1908 TrackView *tabToClose = (TrackView *) w;
1909 KdenliveDoc *docToClose = tabToClose->document();
1910 if (docToClose && docToClose->isModified() && saveChanges) {
1912 if (m_activeDocument->url().fileName().isEmpty())
1913 message = i18n("Save changes to document?");
1915 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1916 switch (KMessageBox::warningYesNoCancel(this, message)) {
1917 case KMessageBox::Yes :
1918 // save document here. If saving fails, return false;
1919 if (saveFile() == false) return false;
1921 case KMessageBox::Cancel :
1928 m_clipMonitor->slotSetClipProducer(NULL);
1929 m_projectList->slotResetProjectList();
1930 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1931 if (m_timelineArea->count() == 1) {
1932 m_timelineArea->setTabBarHidden(true);
1933 m_closeAction->setEnabled(false);
1935 if (docToClose == m_activeDocument) {
1936 delete m_activeDocument;
1937 m_activeDocument = NULL;
1938 m_effectStack->clear();
1939 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1943 if (w == m_activeTimeline) {
1944 delete m_activeTimeline;
1945 m_activeTimeline = NULL;
1952 bool MainWindow::saveFileAs(const QString &outputFileName)
1954 QString currentSceneList;
1955 m_monitorManager->stopActiveMonitor();
1957 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1960 // Save timeline thumbnails
1961 m_activeTimeline->projectView()->saveThumbnails();
1962 m_activeDocument->setUrl(KUrl(outputFileName));
1963 if (m_activeDocument->m_autosave == NULL) {
1964 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1965 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1966 setCaption(m_activeDocument->description());
1967 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1968 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1969 m_activeDocument->setModified(false);
1970 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1971 m_fileRevert->setEnabled(true);
1972 m_undoView->stack()->setClean();
1976 bool MainWindow::saveFileAs()
1978 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1979 if (outputFile.isEmpty()) {
1982 if (QFile::exists(outputFile)) {
1983 // Show the file dialog again if the user does not want to overwrite the file
1984 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1985 return saveFileAs();
1987 return saveFileAs(outputFile);
1990 bool MainWindow::saveFile()
1992 if (!m_activeDocument) return true;
1993 if (m_activeDocument->url().isEmpty()) {
1994 return saveFileAs();
1996 bool result = saveFileAs(m_activeDocument->url().path());
1997 m_activeDocument->m_autosave->resize(0);
2002 void MainWindow::openFile()
2004 if (!m_startUrl.isEmpty()) {
2005 openFile(m_startUrl);
2006 m_startUrl = KUrl();
2009 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2010 if (url.isEmpty()) return;
2011 m_fileOpenRecent->addUrl(url);
2015 void MainWindow::openLastFile()
2017 KSharedConfigPtr config = KGlobal::config();
2018 KUrl::List urls = m_fileOpenRecent->urls();
2019 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2020 if (urls.isEmpty()) newFile(false);
2021 else openFile(urls.last());
2024 void MainWindow::openFile(const KUrl &url)
2026 // Make sure the url is a Kdenlive project file
2027 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2028 if (mime.data()->is("application/x-compressed-tar")) {
2029 // Opening a compressed project file, we need to process it
2030 kDebug()<<"Opening archive, processing";
2031 ArchiveWidget *ar = new ArchiveWidget(url);
2032 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2036 if (!url.fileName().endsWith(".kdenlive")) {
2037 // This is not a Kdenlive project file, abort loading
2038 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2042 // Check if the document is already opened
2043 const int ct = m_timelineArea->count();
2044 bool isOpened = false;
2046 for (i = 0; i < ct; i++) {
2047 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2048 KdenliveDoc *doc = tab->document();
2049 if (doc->url() == url) {
2055 m_timelineArea->setCurrentIndex(i);
2059 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2061 // Check for backup file
2062 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
2063 if (!staleFiles.isEmpty()) {
2064 if (KMessageBox::questionYesNo(this,
2065 i18n("Auto-saved files exist. Do you want to recover them now?"),
2066 i18n("File Recovery"),
2067 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2068 recoverFiles(staleFiles);
2071 // remove the stale files
2072 foreach(KAutoSaveFile * stale, staleFiles) {
2073 stale->open(QIODevice::ReadWrite);
2078 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2079 m_messageLabel->repaint();
2080 doOpenFile(url, NULL);
2083 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2085 if (!m_timelineArea->isEnabled()) return;
2086 m_fileRevert->setEnabled(true);
2088 // Recreate stopmotion widget on document change
2090 delete m_stopmotion;
2091 m_stopmotion = NULL;
2095 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2096 progressDialog.setAllowCancel(false);
2097 progressDialog.progressBar()->setMaximum(4);
2098 progressDialog.show();
2099 progressDialog.progressBar()->setValue(0);
2100 qApp->processEvents();
2103 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);
2105 progressDialog.progressBar()->setValue(1);
2106 progressDialog.progressBar()->setMaximum(4);
2107 progressDialog.setLabelText(i18n("Loading project"));
2108 qApp->processEvents();
2110 if (stale == NULL) {
2111 stale = new KAutoSaveFile(url, doc);
2112 doc->m_autosave = stale;
2114 doc->m_autosave = stale;
2115 doc->setUrl(stale->managedFile());
2116 doc->setModified(true);
2117 stale->setParent(doc);
2119 connectDocumentInfo(doc);
2121 progressDialog.progressBar()->setValue(2);
2122 qApp->processEvents();
2125 TrackView *trackView = new TrackView(doc, &ok, this);
2126 connectDocument(trackView, doc);
2127 progressDialog.progressBar()->setValue(3);
2128 qApp->processEvents();
2130 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2132 m_timelineArea->setEnabled(false);
2133 m_projectList->setEnabled(false);
2134 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2135 slotGotProgressInfo(QString(), -1);
2136 newFile(false, true);
2139 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2140 trackView->setDuration(trackView->duration());
2141 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2143 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2144 slotGotProgressInfo(QString(), -1);
2145 m_projectMonitor->adjustRulerSize(trackView->duration());
2146 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2147 progressDialog.progressBar()->setValue(4);
2148 if (openBackup) slotOpenBackupDialog(url);
2151 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2153 foreach(KAutoSaveFile * stale, staleFiles) {
2154 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2155 // show an error message; we could not steal the lockfile
2156 // maybe another application got to the file before us?
2160 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2161 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2162 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2163 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2167 void MainWindow::parseProfiles(const QString &mltPath)
2169 //KdenliveSettings::setDefaulttmpfolder();
2170 if (!mltPath.isEmpty()) {
2171 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2172 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2175 if (KdenliveSettings::mltpath().isEmpty())
2176 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2178 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2179 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2180 if (!QFile::exists(meltPath))
2181 meltPath = KStandardDirs::findExe("melt");
2182 KdenliveSettings::setRendererpath(meltPath);
2185 if (KdenliveSettings::rendererpath().isEmpty()) {
2186 // Cannot find the MLT melt renderer, ask for location
2187 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2188 if (getUrl->exec() == QDialog::Rejected) {
2191 KUrl rendererPath = getUrl->selectedUrl();
2193 if (rendererPath.isEmpty()) ::exit(0);
2194 KdenliveSettings::setRendererpath(rendererPath.path());
2197 QStringList profilesFilter;
2198 profilesFilter << "*";
2199 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2200 if (profilesList.isEmpty()) {
2201 // Cannot find MLT path, try finding melt
2202 QString profilePath = KdenliveSettings::rendererpath();
2203 if (!profilePath.isEmpty()) {
2204 profilePath = profilePath.section('/', 0, -3);
2205 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2206 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2208 if (profilesList.isEmpty()) {
2209 // Cannot find the MLT profiles, ask for location
2210 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2211 getUrl->fileDialog()->setMode(KFile::Directory);
2212 if (getUrl->exec() == QDialog::Rejected) {
2215 KUrl mltPath = getUrl->selectedUrl();
2217 if (mltPath.isEmpty()) ::exit(0);
2218 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2219 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2223 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2225 // Parse again MLT profiles to build a list of available video formats
2226 if (profilesList.isEmpty()) parseProfiles();
2230 void MainWindow::slotEditProfiles()
2232 ProfilesDialog *w = new ProfilesDialog;
2233 if (w->exec() == QDialog::Accepted) {
2234 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2235 if (d) d->checkProfile();
2240 void MainWindow::slotDetectAudioDriver()
2242 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2243 leading to no audio output, see bug #934 */
2245 //decide which audio driver is really best, in some cases SDL is wrong
2246 if (KdenliveSettings::audiodrivername().isEmpty()) {
2248 KProcess readProcess;
2249 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2250 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2251 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2252 readProcess.setProgram("pactl", QStringList() << "stat");
2253 readProcess.execute(2000); // Kill it after 2 seconds
2255 QString result = QString(readProcess.readAllStandardOutput());
2256 kDebug() << "// / / / / / READING PACTL: ";
2258 if (!result.isEmpty()) {
2260 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2264 KdenliveSettings::setAutoaudiodrivername(driver);
2268 void MainWindow::slotEditProjectSettings()
2270 QPoint p = m_activeDocument->getTracksCount();
2271 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2272 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2274 if (w->exec() == QDialog::Accepted) {
2275 QString profile = w->selectedProfile();
2276 m_activeDocument->setProjectFolder(w->selectedFolder());
2278 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2280 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2281 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2282 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2283 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2284 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2285 m_activeDocument->setModified();
2286 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2287 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) {
2288 //TODO: rebuild all proxies
2289 //m_projectList->rebuildProxies();
2292 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2293 m_activeDocument->setModified();
2294 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2296 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2297 m_activeDocument->setModified();
2298 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2300 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2301 m_activeDocument->setModified();
2302 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2304 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2305 m_activeDocument->setModified();
2306 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2308 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2309 m_activeDocument->setModified();
2310 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2312 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2313 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2314 m_activeDocument->setModified();
2315 slotUpdateProxySettings();
2321 void MainWindow::slotDisableProxies()
2323 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2324 m_activeDocument->setModified();
2325 slotUpdateProxySettings();
2328 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2330 // Recreate the stopmotion widget if profile changes
2332 delete m_stopmotion;
2333 m_stopmotion = NULL;
2336 // Deselect current effect / transition
2337 m_effectStack->slotClipItemSelected(NULL, 0);
2338 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2339 m_clipMonitor->slotSetClipProducer(NULL);
2340 bool updateFps = m_activeDocument->setProfilePath(profile);
2341 KdenliveSettings::setCurrent_profile(profile);
2342 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2343 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2345 m_activeDocument->clipManager()->clearUnusedProducers();
2346 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2347 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2348 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2349 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2350 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2351 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2352 if (updateFps) m_activeTimeline->updateProjectFps();
2353 m_activeDocument->clipManager()->clearCache();
2354 m_activeTimeline->updateProfile();
2355 m_activeDocument->setModified(true);
2356 m_commandStack->activeStack()->clear();
2357 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2358 slotUpdateMousePosition(0);
2359 // We need to desactivate & reactivate monitors to get a refresh
2360 //m_monitorManager->switchMonitors();
2364 void MainWindow::slotRenderProject()
2366 if (!m_renderWidget) {
2367 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2368 MltVideoProfile profile;
2369 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2370 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2371 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2372 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2373 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2374 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2375 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2376 if (m_activeDocument) {
2377 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2378 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2379 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2380 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2383 slotCheckRenderStatus();
2384 m_renderWidget->show();
2385 m_renderWidget->showNormal();
2387 // What are the following lines supposed to do?
2388 //m_activeTimeline->tracksNumber();
2389 //m_renderWidget->enableAudio(false);
2390 //m_renderWidget->export_audio;
2393 void MainWindow::slotCheckRenderStatus()
2395 // Make sure there are no missing clips
2397 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2400 void MainWindow::setRenderingProgress(const QString &url, int progress)
2403 m_renderWidget->setRenderJob(url, progress);
2406 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2409 m_renderWidget->setRenderStatus(url, status, error);
2412 void MainWindow::slotCleanProject()
2414 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2415 m_projectList->cleanup();
2418 void MainWindow::slotUpdateMousePosition(int pos)
2420 if (m_activeDocument)
2421 switch (m_timecodeFormat->currentIndex()) {
2423 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2426 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2430 void MainWindow::slotUpdateDocumentState(bool modified)
2432 if (!m_activeDocument) return;
2433 setCaption(m_activeDocument->description(), modified);
2434 m_saveAction->setEnabled(modified);
2436 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2437 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2439 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2440 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2444 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2446 if (m_activeDocument) {
2447 if (m_activeDocument == doc) return;
2448 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2450 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2453 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2455 //m_projectMonitor->stop();
2456 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2457 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2458 if (m_activeDocument) {
2459 if (m_activeDocument == doc) return;
2460 if (m_activeTimeline) {
2461 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2462 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2463 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2464 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2465 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2466 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2467 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2469 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2471 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2472 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2473 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2474 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2475 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2476 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2477 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2478 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2479 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2480 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2481 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2482 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2483 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2484 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2485 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2486 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2487 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2488 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2489 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2490 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2491 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2492 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2493 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2494 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2495 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2496 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2497 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2498 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2499 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2500 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2501 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2502 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2503 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2504 m_effectStack->clear();
2506 //m_activeDocument->setRenderer(NULL);
2507 m_clipMonitor->stop();
2509 KdenliveSettings::setCurrent_profile(doc->profilePath());
2510 KdenliveSettings::setProject_fps(doc->fps());
2511 m_monitorManager->resetProfiles(doc->timecode());
2512 m_clipMonitorDock->raise();
2513 m_projectList->setDocument(doc);
2514 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2515 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2516 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2518 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2519 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2521 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2522 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2523 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2524 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2525 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2526 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2527 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2528 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2529 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2530 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2531 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2532 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2533 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2535 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2536 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2537 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2538 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2539 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2541 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2542 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2543 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2545 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2547 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2548 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2549 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2550 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2552 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2553 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2554 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2555 m_zoomSlider->setValue(doc->zoom().x());
2556 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2557 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2558 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2559 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2561 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2562 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2564 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2565 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2567 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2568 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2569 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2570 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2571 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2572 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2573 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2574 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2575 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2576 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2577 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2579 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2580 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2581 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2584 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2585 m_activeTimeline = trackView;
2586 if (m_renderWidget) {
2587 slotCheckRenderStatus();
2588 m_renderWidget->setProfile(doc->mltProfile());
2589 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2590 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2591 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2593 //doc->setRenderer(m_projectMonitor->render);
2594 m_commandStack->setActiveStack(doc->commandStack());
2595 KdenliveSettings::setProject_display_ratio(doc->dar());
2596 //doc->clipManager()->checkAudioThumbs();
2598 //m_overView->setScene(trackView->projectScene());
2599 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2600 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2602 setCaption(doc->description(), doc->isModified());
2603 m_saveAction->setEnabled(doc->isModified());
2604 m_normalEditTool->setChecked(true);
2605 m_activeDocument = doc;
2606 m_activeTimeline->updateProjectFps();
2607 m_activeDocument->checkProjectClips();
2609 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2611 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2612 slotUpdateMousePosition(0);
2613 m_monitorManager->activateMonitor("clip");
2614 // set tool to select tool
2615 m_buttonSelectTool->setChecked(true);
2618 void MainWindow::slotZoneMoved(int start, int end)
2620 m_activeDocument->setZone(start, end);
2621 m_projectMonitor->slotZoneMoved(start, end);
2624 void MainWindow::slotGuidesUpdated()
2627 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2630 void MainWindow::slotEditKeys()
2632 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2633 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2634 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2638 void MainWindow::slotPreferences(int page, int option)
2641 * An instance of your dialog could be already created and could be
2642 * cached, in which case you want to display the cached dialog
2643 * instead of creating another one
2645 if (m_stopmotion) m_stopmotion->slotLive(false);
2646 if (KConfigDialog::showDialog("settings")) {
2647 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2648 if (page != -1) d->showPage(page, option);
2652 // KConfigDialog didn't find an instance of this dialog, so lets
2655 // Get the mappable actions in localized form
2656 QMap<QString, QString> actions;
2657 KActionCollection* collection = actionCollection();
2658 foreach (const QString& action_name, m_action_names) {
2659 actions[collection->action(action_name)->text()] = action_name;
2662 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2663 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2664 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2666 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2669 if (page != -1) dialog->showPage(page, option);
2672 void MainWindow::slotUpdateCaptureFolder()
2676 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2677 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2681 void MainWindow::updateConfiguration()
2683 //TODO: we should apply settings to all projects, not only the current one
2684 if (m_activeTimeline) {
2685 m_activeTimeline->refresh();
2686 m_activeTimeline->projectView()->checkAutoScroll();
2687 m_activeTimeline->checkTrackHeight();
2688 if (m_activeDocument)
2689 m_activeDocument->clipManager()->checkAudioThumbs();
2691 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2692 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2693 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2694 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2696 // Update list of transcoding profiles
2699 #ifdef USE_JOGSHUTTLE
2700 activateShuttleDevice();
2705 void MainWindow::slotSwitchSplitAudio()
2707 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2708 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2711 void MainWindow::slotSwitchVideoThumbs()
2713 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2714 if (m_activeTimeline)
2715 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2716 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2719 void MainWindow::slotSwitchAudioThumbs()
2721 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2722 if (m_activeTimeline) {
2723 m_activeTimeline->refresh();
2724 m_activeTimeline->projectView()->checkAutoScroll();
2725 if (m_activeDocument)
2726 m_activeDocument->clipManager()->checkAudioThumbs();
2728 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2731 void MainWindow::slotSwitchMarkersComments()
2733 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2734 if (m_activeTimeline)
2735 m_activeTimeline->refresh();
2736 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2739 void MainWindow::slotSwitchSnap()
2741 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2742 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2746 void MainWindow::slotDeleteItem()
2748 if (QApplication::focusWidget() &&
2749 QApplication::focusWidget()->parentWidget() &&
2750 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2751 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2752 m_projectList->slotRemoveClip();
2755 QWidget *widget = QApplication::focusWidget();
2757 if (widget == m_effectStackDock) {
2758 m_effectStack->slotItemDel();
2761 widget = widget->parentWidget();
2764 // effect stack has no focus
2765 if (m_activeTimeline)
2766 m_activeTimeline->projectView()->deleteSelectedClips();
2770 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2772 if (m_clipMonitor->isActive())
2773 m_clipMonitor->checkOverlay();
2774 m_clipMonitor->updateMarkers(clip);
2777 void MainWindow::slotAddClipMarker()
2779 DocClipBase *clip = NULL;
2781 if (m_projectMonitor->isActive()) {
2782 if (m_activeTimeline) {
2783 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2785 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2786 clip = item->baseClip();
2790 clip = m_clipMonitor->activeClip();
2791 pos = m_clipMonitor->position();
2794 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2797 QString id = clip->getId();
2798 CommentedTime marker(pos, i18n("Marker"));
2799 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2800 if (d.exec() == QDialog::Accepted)
2801 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2804 void MainWindow::slotDeleteClipMarker()
2806 DocClipBase *clip = NULL;
2808 if (m_projectMonitor->isActive()) {
2809 if (m_activeTimeline) {
2810 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2812 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2813 clip = item->baseClip();
2817 clip = m_clipMonitor->activeClip();
2818 pos = m_clipMonitor->position();
2821 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2825 QString id = clip->getId();
2826 QString comment = clip->markerComment(pos);
2827 if (comment.isEmpty()) {
2828 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2831 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2834 void MainWindow::slotDeleteAllClipMarkers()
2836 DocClipBase *clip = NULL;
2837 if (m_projectMonitor->isActive()) {
2838 if (m_activeTimeline) {
2839 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2841 clip = item->baseClip();
2845 clip = m_clipMonitor->activeClip();
2848 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2851 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2854 void MainWindow::slotEditClipMarker()
2856 DocClipBase *clip = NULL;
2858 if (m_projectMonitor->isActive()) {
2859 if (m_activeTimeline) {
2860 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2862 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2863 clip = item->baseClip();
2867 clip = m_clipMonitor->activeClip();
2868 pos = m_clipMonitor->position();
2871 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2875 QString id = clip->getId();
2876 QString oldcomment = clip->markerComment(pos);
2877 if (oldcomment.isEmpty()) {
2878 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2882 CommentedTime marker(pos, oldcomment);
2883 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2884 if (d.exec() == QDialog::Accepted) {
2885 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2886 if (d.newMarker().time() != pos) {
2887 // remove old marker
2888 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2893 void MainWindow::slotAddMarkerGuideQuickly()
2895 if (!m_activeTimeline || !m_activeDocument)
2898 if (m_clipMonitor->isActive()) {
2899 DocClipBase *clip = m_clipMonitor->activeClip();
2900 GenTime pos = m_clipMonitor->position();
2903 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2907 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2909 m_activeTimeline->projectView()->slotAddGuide(false);
2913 void MainWindow::slotAddGuide()
2915 if (m_activeTimeline)
2916 m_activeTimeline->projectView()->slotAddGuide();
2919 void MainWindow::slotInsertSpace()
2921 if (m_activeTimeline)
2922 m_activeTimeline->projectView()->slotInsertSpace();
2925 void MainWindow::slotRemoveSpace()
2927 if (m_activeTimeline)
2928 m_activeTimeline->projectView()->slotRemoveSpace();
2931 void MainWindow::slotInsertTrack(int ix)
2933 m_projectMonitor->activateMonitor();
2934 if (m_activeTimeline)
2935 m_activeTimeline->projectView()->slotInsertTrack(ix);
2936 if (m_activeDocument)
2937 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2940 void MainWindow::slotDeleteTrack(int ix)
2942 m_projectMonitor->activateMonitor();
2943 if (m_activeTimeline)
2944 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2945 if (m_activeDocument)
2946 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2949 void MainWindow::slotConfigTrack(int ix)
2951 m_projectMonitor->activateMonitor();
2952 if (m_activeTimeline)
2953 m_activeTimeline->projectView()->slotConfigTracks(ix);
2954 if (m_activeDocument)
2955 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2958 void MainWindow::slotEditGuide()
2960 if (m_activeTimeline)
2961 m_activeTimeline->projectView()->slotEditGuide();
2964 void MainWindow::slotDeleteGuide()
2966 if (m_activeTimeline)
2967 m_activeTimeline->projectView()->slotDeleteGuide();
2970 void MainWindow::slotDeleteAllGuides()
2972 if (m_activeTimeline)
2973 m_activeTimeline->projectView()->slotDeleteAllGuides();
2976 void MainWindow::slotCutTimelineClip()
2978 if (m_activeTimeline)
2979 m_activeTimeline->projectView()->cutSelectedClips();
2982 void MainWindow::slotInsertClipOverwrite()
2984 if (m_activeTimeline) {
2985 QStringList data = m_clipMonitor->getZoneInfo();
2986 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2990 void MainWindow::slotSelectTimelineClip()
2992 if (m_activeTimeline)
2993 m_activeTimeline->projectView()->selectClip(true);
2996 void MainWindow::slotSelectTimelineTransition()
2998 if (m_activeTimeline)
2999 m_activeTimeline->projectView()->selectTransition(true);
3002 void MainWindow::slotDeselectTimelineClip()
3004 if (m_activeTimeline)
3005 m_activeTimeline->projectView()->selectClip(false, true);
3008 void MainWindow::slotDeselectTimelineTransition()
3010 if (m_activeTimeline)
3011 m_activeTimeline->projectView()->selectTransition(false, true);
3014 void MainWindow::slotSelectAddTimelineClip()
3016 if (m_activeTimeline)
3017 m_activeTimeline->projectView()->selectClip(true, true);
3020 void MainWindow::slotSelectAddTimelineTransition()
3022 if (m_activeTimeline)
3023 m_activeTimeline->projectView()->selectTransition(true, true);
3026 void MainWindow::slotGroupClips()
3028 if (m_activeTimeline)
3029 m_activeTimeline->projectView()->groupClips();
3032 void MainWindow::slotUnGroupClips()
3034 if (m_activeTimeline)
3035 m_activeTimeline->projectView()->groupClips(false);
3038 void MainWindow::slotEditItemDuration()
3040 if (m_activeTimeline)
3041 m_activeTimeline->projectView()->editItemDuration();
3044 void MainWindow::slotAddProjectClip(KUrl url)
3046 if (m_activeDocument)
3047 m_activeDocument->slotAddClipFile(url, QString());
3050 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3052 if (m_activeDocument)
3053 m_activeDocument->slotAddClipList(urls, QString());
3056 void MainWindow::slotAddTransition(QAction *result)
3058 if (!result) return;
3059 QStringList info = result->data().toStringList();
3060 if (info.isEmpty()) return;
3061 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3062 if (m_activeTimeline && !transition.isNull()) {
3063 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3067 void MainWindow::slotAddVideoEffect(QAction *result)
3069 if (!result) return;
3070 const int EFFECT_VIDEO = 1;
3071 const int EFFECT_AUDIO = 2;
3072 QStringList info = result->data().toStringList();
3074 if (info.isEmpty() || info.size() < 3) return;
3075 QDomElement effect ;
3076 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3077 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3078 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3079 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3081 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3082 if (!effect.isNull()) slotAddEffect(effect);
3083 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3087 void MainWindow::slotZoomIn()
3089 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3090 slotShowZoomSliderToolTip();
3093 void MainWindow::slotZoomOut()
3095 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3096 slotShowZoomSliderToolTip();
3099 void MainWindow::slotFitZoom()
3101 if (m_activeTimeline)
3102 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3105 void MainWindow::slotSetZoom(int value)
3107 value = qMax(m_zoomSlider->minimum(), value);
3108 value = qMin(m_zoomSlider->maximum(), value);
3110 if (m_activeTimeline)
3111 m_activeTimeline->slotChangeZoom(value);
3113 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3114 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3115 slotUpdateZoomSliderToolTip(value);
3117 m_zoomSlider->blockSignals(true);
3118 m_zoomSlider->setValue(value);
3119 m_zoomSlider->blockSignals(false);
3122 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3124 if (zoomlevel != -1)
3125 slotUpdateZoomSliderToolTip(zoomlevel);
3127 QPoint global = m_zoomSlider->rect().topLeft();
3128 global.ry() += m_zoomSlider->height() / 2;
3129 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3130 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3133 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3135 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3138 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3140 m_statusProgressBar->setValue(progress);
3141 if (progress >= 0) {
3142 if (!message.isEmpty())
3143 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3144 m_statusProgressBar->setVisible(true);
3145 } else if (progress == -2) {
3146 if (!message.isEmpty())
3147 m_messageLabel->setMessage(message, ErrorMessage);
3148 m_statusProgressBar->setVisible(false);
3150 m_messageLabel->setMessage(QString(), DefaultMessage);
3151 m_statusProgressBar->setVisible(false);
3155 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3157 if (clip->clipType() == TEXT) {
3158 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3159 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3160 // template text clip
3162 // Get the list of existing templates
3164 filter << "*.kdenlivetitle";
3165 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3167 QDialog *dia = new QDialog(this);
3168 Ui::TemplateClip_UI dia_ui;
3169 dia_ui.setupUi(dia);
3171 const QString templatePath = clip->getProperty("resource");
3172 for (int i = 0; i < templateFiles.size(); ++i) {
3173 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3174 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3176 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3177 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3178 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3179 //warning: setting base directory doesn't work??
3180 KUrl startDir(titlepath);
3181 dia_ui.template_list->fileDialog()->setUrl(startDir);
3182 dia_ui.description->setText(clip->getProperty("description"));
3183 if (dia->exec() == QDialog::Accepted) {
3184 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3185 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3187 QMap <QString, QString> newprops;
3189 if (KUrl(textTemplate).path() != templatePath) {
3190 // The template was changed
3191 newprops.insert("resource", textTemplate);
3194 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3195 newprops.insert("description", dia_ui.description->toPlainText());
3198 QString newtemplate = newprops.value("xmltemplate");
3199 if (newtemplate.isEmpty()) newtemplate = templatePath;
3201 // template modified we need to update xmldata
3202 QString description = newprops.value("description");
3203 if (description.isEmpty()) description = clip->getProperty("description");
3204 else newprops.insert("templatetext", description);
3205 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3206 if (!newprops.isEmpty()) {
3207 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3208 m_activeDocument->commandStack()->push(command);
3214 QString path = clip->getProperty("resource");
3215 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3217 doc.setContent(clip->getProperty("xmldata"));
3218 dia_ui->setXml(doc);
3219 if (dia_ui->exec() == QDialog::Accepted) {
3220 QMap <QString, QString> newprops;
3221 newprops.insert("xmldata", dia_ui->xml().toString());
3222 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3223 // duration changed, we need to update duration
3224 newprops.insert("out", QString::number(dia_ui->outPoint()));
3225 int currentLength = QString(clip->producerProperty("length")).toInt();
3226 if (currentLength <= dia_ui->outPoint())
3227 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3228 else newprops.insert("length", clip->producerProperty("length"));
3230 if (!path.isEmpty()) {
3231 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3232 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) {
3233 // save to external file
3234 dia_ui->saveTitle(path);
3235 } else newprops.insert("resource", QString());
3237 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3238 m_activeDocument->commandStack()->push(command);
3239 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3240 m_activeDocument->setModified(true);
3244 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3248 // any type of clip but a title
3249 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3250 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3251 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3252 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)));
3257 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3259 if (newprops.isEmpty()) return;
3260 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3261 m_activeDocument->commandStack()->push(command);
3262 m_activeDocument->setModified();
3265 // update clip occurences in timeline
3266 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3271 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3273 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3274 if (dia.exec() == QDialog::Accepted) {
3275 QUndoCommand *command = new QUndoCommand();
3276 command->setText(i18n("Edit clips"));
3277 QMap <QString, QString> newImageProps = dia.properties();
3278 // Transparency setting applies only for images
3279 QMap <QString, QString> newProps = newImageProps;
3280 newProps.remove("transparency");
3282 for (int i = 0; i < cliplist.count(); i++) {
3283 DocClipBase *clip = cliplist.at(i);
3284 if (clip->clipType() == IMAGE)
3285 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3287 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3289 m_activeDocument->commandStack()->push(command);
3290 for (int i = 0; i < cliplist.count(); i++)
3291 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3295 void MainWindow::customEvent(QEvent* e)
3297 if (e->type() == QEvent::User)
3298 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3300 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3306 m_effectStack->raiseWindow(m_effectStackDock);
3309 void MainWindow::slotActivateTransitionView(Transition *t)
3312 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3315 void MainWindow::slotSnapRewind()
3317 if (m_projectMonitor->isActive()) {
3318 if (m_activeTimeline)
3319 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3321 m_clipMonitor->slotSeekToPreviousSnap();
3325 void MainWindow::slotSnapForward()
3327 if (m_projectMonitor->isActive()) {
3328 if (m_activeTimeline)
3329 m_activeTimeline->projectView()->slotSeekToNextSnap();
3331 m_clipMonitor->slotSeekToNextSnap();
3335 void MainWindow::slotClipStart()
3337 if (m_projectMonitor->isActive()) {
3338 if (m_activeTimeline)
3339 m_activeTimeline->projectView()->clipStart();
3343 void MainWindow::slotClipEnd()
3345 if (m_projectMonitor->isActive()) {
3346 if (m_activeTimeline)
3347 m_activeTimeline->projectView()->clipEnd();
3351 void MainWindow::slotZoneStart()
3353 if (m_projectMonitor->isActive())
3354 m_projectMonitor->slotZoneStart();
3356 m_clipMonitor->slotZoneStart();
3359 void MainWindow::slotZoneEnd()
3361 if (m_projectMonitor->isActive())
3362 m_projectMonitor->slotZoneEnd();
3364 m_clipMonitor->slotZoneEnd();
3367 void MainWindow::slotChangeTool(QAction * action)
3369 if (action == m_buttonSelectTool)
3370 slotSetTool(SELECTTOOL);
3371 else if (action == m_buttonRazorTool)
3372 slotSetTool(RAZORTOOL);
3373 else if (action == m_buttonSpacerTool)
3374 slotSetTool(SPACERTOOL);
3377 void MainWindow::slotChangeEdit(QAction * action)
3379 if (!m_activeTimeline)
3382 if (action == m_overwriteEditTool)
3383 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3384 else if (action == m_insertEditTool)
3385 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3387 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3390 void MainWindow::slotSetTool(PROJECTTOOL tool)
3392 if (m_activeDocument && m_activeTimeline) {
3393 //m_activeDocument->setTool(tool);
3397 message = i18n("Ctrl + click to use spacer on current track only");
3400 message = i18n("Click on a clip to cut it");
3403 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3406 m_messageLabel->setMessage(message, InformationMessage);
3407 m_activeTimeline->projectView()->setTool(tool);
3411 void MainWindow::slotCopy()
3413 if (m_activeDocument && m_activeTimeline)
3414 m_activeTimeline->projectView()->copyClip();
3417 void MainWindow::slotPaste()
3419 if (m_activeDocument && m_activeTimeline)
3420 m_activeTimeline->projectView()->pasteClip();
3423 void MainWindow::slotPasteEffects()
3425 if (m_activeDocument && m_activeTimeline)
3426 m_activeTimeline->projectView()->pasteClipEffects();
3429 void MainWindow::slotFind()
3431 if (!m_activeDocument || !m_activeTimeline) return;
3432 m_projectSearch->setEnabled(false);
3433 m_findActivated = true;
3434 m_findString.clear();
3435 m_activeTimeline->projectView()->initSearchStrings();
3436 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3437 m_findTimer.start(5000);
3438 qApp->installEventFilter(this);
3441 void MainWindow::slotFindNext()
3443 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3444 statusBar()->showMessage(i18n("Found: %1", m_findString));
3446 statusBar()->showMessage(i18n("Reached end of project"));
3447 m_findTimer.start(4000);
3450 void MainWindow::findAhead()
3452 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3453 m_projectSearchNext->setEnabled(true);
3454 statusBar()->showMessage(i18n("Found: %1", m_findString));
3456 m_projectSearchNext->setEnabled(false);
3457 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3461 void MainWindow::findTimeout()
3463 m_projectSearchNext->setEnabled(false);
3464 m_findActivated = false;
3465 m_findString.clear();
3466 statusBar()->showMessage(i18n("Find stopped"), 3000);
3467 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3468 m_projectSearch->setEnabled(true);
3469 removeEventFilter(this);
3472 void MainWindow::slotClipInTimeline(const QString &clipId)
3474 if (m_activeTimeline && m_activeDocument) {
3475 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3477 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3478 inTimelineMenu->clear();
3480 QList <QAction *> actionList;
3482 for (int i = 0; i < matching.count(); ++i) {
3483 QString track = QString::number(matching.at(i).track);
3484 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3486 QAction *a = new QAction(track + ": " + start, this);
3487 a->setData(QStringList() << track << start);
3488 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3489 while (j < actionList.count()) {
3490 if (actionList.at(j)->text() > a->text()) break;
3493 actionList.insert(j, a);
3495 inTimelineMenu->addActions(actionList);
3497 if (matching.empty())
3498 inTimelineMenu->setEnabled(false);
3500 inTimelineMenu->setEnabled(true);
3504 void MainWindow::slotClipInProjectTree()
3506 if (m_activeTimeline) {
3507 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3508 if (clipIds.isEmpty())
3510 m_projectListDock->raise();
3511 for (int i = 0; i < clipIds.count(); i++)
3512 m_projectList->selectItemById(clipIds.at(i));
3513 if (m_projectMonitor->isActive())
3514 slotSwitchMonitors();
3518 /*void MainWindow::slotClipToProjectTree()
3520 if (m_activeTimeline) {
3521 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3522 if (clips.isEmpty()) return;
3523 for (int i = 0; i < clips.count(); i++) {
3524 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3526 //m_projectList->selectItemById(clipIds.at(i));
3530 void MainWindow::slotSelectClipInTimeline()
3532 if (m_activeTimeline) {
3533 QAction *action = qobject_cast<QAction *>(sender());
3534 QStringList data = action->data().toStringList();
3535 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3539 void MainWindow::keyPressEvent(QKeyEvent *ke)
3541 if (m_findActivated) {
3542 if (ke->key() == Qt::Key_Backspace) {
3543 m_findString = m_findString.left(m_findString.length() - 1);
3545 if (!m_findString.isEmpty())
3550 m_findTimer.start(4000);
3553 } else if (ke->key() == Qt::Key_Escape) {
3557 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3558 m_findString += ke->text();
3562 m_findTimer.start(4000);
3567 KXmlGuiWindow::keyPressEvent(ke);
3572 /** Gets called when the window gets hidden */
3573 void MainWindow::hideEvent(QHideEvent */*event*/)
3575 if (isMinimized() && m_monitorManager)
3576 m_monitorManager->stopActiveMonitor();
3579 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3581 if (m_findActivated) {
3582 if (event->type() == QEvent::ShortcutOverride) {
3583 QKeyEvent* ke = (QKeyEvent*) event;
3584 if (ke->text().trimmed().isEmpty()) return false;
3591 // pass the event on to the parent class
3592 return QMainWindow::eventFilter(obj, event);
3597 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3599 KDialog *dialog = new KDialog(this);
3600 dialog->setCaption("Save clip zone");
3601 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3603 QWidget *widget = new QWidget(dialog);
3604 dialog->setMainWidget(widget);
3606 QVBoxLayout *vbox = new QVBoxLayout(widget);
3607 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3608 if (path.isEmpty()) {
3609 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3610 if (baseClip == NULL) tmppath.append("untitled.mlt");
3612 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3614 path = KUrl(tmppath);
3616 KUrlRequester *url = new KUrlRequester(path, this);
3617 url->setFilter("video/mlt-playlist");
3618 QLabel *label2 = new QLabel(i18n("Description:"), this);
3619 KLineEdit *edit = new KLineEdit(this);
3620 vbox->addWidget(label1);
3621 vbox->addWidget(url);
3622 vbox->addWidget(label2);
3623 vbox->addWidget(edit);
3624 if (dialog->exec() == QDialog::Accepted) {
3625 if (QFile::exists(url->url().path())) {
3626 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3627 slotSaveZone(render, zone, baseClip, url->url());
3631 if (baseClip && !baseClip->fileURL().isEmpty()) {
3632 // create zone from clip url, so that we don't have problems with proxy clips
3634 #if QT_VERSION >= 0x040600
3635 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3636 env.remove("MLT_PROFILE");
3637 p.setProcessEnvironment(env);
3639 QStringList env = QProcess::systemEnvironment();
3640 env << "MLT_PROFILE='\0'";
3641 p.setEnvironment(env);
3643 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3644 if (!p.waitForStarted(3000)) {
3645 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3647 else if (!p.waitForFinished(5000)) {
3648 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3651 else render->saveZone(url->url(), edit->text(), zone);
3656 void MainWindow::slotSetInPoint()
3658 if (m_clipMonitor->isActive()) {
3659 m_clipMonitor->slotSetZoneStart();
3661 m_projectMonitor->slotSetZoneStart();
3665 void MainWindow::slotSetOutPoint()
3667 if (m_clipMonitor->isActive()) {
3668 m_clipMonitor->slotSetZoneEnd();
3670 m_projectMonitor->slotSetZoneEnd();
3674 void MainWindow::slotResizeItemStart()
3676 if (m_activeTimeline)
3677 m_activeTimeline->projectView()->setInPoint();
3680 void MainWindow::slotResizeItemEnd()
3682 if (m_activeTimeline)
3683 m_activeTimeline->projectView()->setOutPoint();
3686 int MainWindow::getNewStuff(const QString &configFile)
3688 KNS3::Entry::List entries;
3689 #if KDE_IS_VERSION(4,3,80)
3690 KNS3::DownloadDialog dialog(configFile);
3692 entries = dialog.changedEntries();
3693 foreach(const KNS3::Entry & entry, entries) {
3694 if (entry.status() == KNS3::Entry::Installed)
3695 kDebug() << "// Installed files: " << entry.installedFiles();
3698 KNS::Engine engine(0);
3699 if (engine.init(configFile))
3700 entries = engine.downloadDialogModal(this);
3701 foreach(KNS::Entry * entry, entries) {
3702 if (entry->status() == KNS::Entry::Installed)
3703 kDebug() << "// Installed files: " << entry->installedFiles();
3706 return entries.size();
3709 void MainWindow::slotGetNewTitleStuff()
3711 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3712 TitleWidget::refreshTitleTemplates();
3715 void MainWindow::slotGetNewLumaStuff()
3717 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3718 initEffects::refreshLumas();
3719 m_activeTimeline->projectView()->reloadTransitionLumas();
3723 void MainWindow::slotGetNewRenderStuff()
3725 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3727 m_renderWidget->reloadProfiles();
3730 void MainWindow::slotGetNewMltProfileStuff()
3732 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3733 // update the list of profiles in settings dialog
3734 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3740 void MainWindow::slotAutoTransition()
3742 if (m_activeTimeline)
3743 m_activeTimeline->projectView()->autoTransition();
3746 void MainWindow::slotSplitAudio()
3748 if (m_activeTimeline)
3749 m_activeTimeline->projectView()->splitAudio();
3752 void MainWindow::slotUpdateClipType(QAction *action)
3754 if (m_activeTimeline) {
3755 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3756 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3757 else m_activeTimeline->projectView()->setAudioAndVideo();
3761 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3763 // We must stop the monitors since we create a new on in the dvd wizard
3764 m_clipMonitor->stop();
3765 m_projectMonitor->stop();
3766 DvdWizard w(url, profile, this);
3768 m_projectMonitor->start();
3771 void MainWindow::slotShowTimeline(bool show)
3773 if (show == false) {
3774 m_timelineState = saveState();
3775 centralWidget()->setHidden(true);
3777 centralWidget()->setHidden(false);
3778 restoreState(m_timelineState);
3782 void MainWindow::slotMaximizeCurrent(bool)
3784 //TODO: is there a way to maximize current widget?
3786 m_timelineState = saveState();
3787 QWidget *par = focusWidget()->parentWidget();
3788 while (par->parentWidget() && par->parentWidget() != this)
3789 par = par->parentWidget();
3790 kDebug() << "CURRENT WIDGET: " << par->objectName();
3793 void MainWindow::loadStabilize()
3795 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3797 Mlt::Profile profile;
3798 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3799 QAction *action=stabMenu->addAction("Videostab (vstab)");
3800 action->setData("videostab");
3801 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3803 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3804 QAction *action=stabMenu->addAction("Videostab (transcode)");
3805 action->setData("videostab2");
3806 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3812 void MainWindow::loadTranscoders()
3814 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3817 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3818 KConfigGroup transConfig(config, "Transcoding");
3820 QMap< QString, QString > profiles = transConfig.entryMap();
3821 QMapIterator<QString, QString> i(profiles);
3822 while (i.hasNext()) {
3824 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3825 QAction *a = transMenu->addAction(i.key());
3827 if (data.count() > 1)
3828 a->setToolTip(data.at(1));
3829 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3833 void MainWindow::slotStabilize(KUrl::List urls)
3836 if (urls.isEmpty()) {
3837 QAction *action = qobject_cast<QAction *>(sender());
3839 QString filtername=action->data().toString();
3840 urls = m_projectList->getConditionalUrls(condition);
3845 void MainWindow::slotTranscode(KUrl::List urls)
3850 if (urls.isEmpty()) {
3851 QAction *action = qobject_cast<QAction *>(sender());
3852 QStringList data = action->data().toStringList();
3853 params = data.at(0);
3854 if (data.count() > 1) desc = data.at(1);
3855 if (data.count() > 2) condition = data.at(2);
3856 urls << m_projectList->getConditionalUrls(condition);
3857 urls.removeAll(KUrl());
3859 if (urls.isEmpty()) {
3860 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3863 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3864 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3866 //QProcess::startDetached("ffmpeg", parameters);
3869 void MainWindow::slotTranscodeClip()
3871 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3872 if (urls.isEmpty()) return;
3873 slotTranscode(urls);
3876 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3878 if (m_activeDocument == NULL) return;
3879 QMapIterator<QString, QString> i(props);
3880 while (i.hasNext()) {
3882 m_activeDocument->setDocumentProperty(i.key(), i.value());
3884 m_activeDocument->setModified(true);
3888 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3890 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3892 QString playlistPath;
3895 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3896 QString path = m_renderWidget->getFreeScriptName();
3897 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3898 if (!ok || scriptPath.isEmpty()) return;
3899 scriptPath.prepend(scriptsFolder);
3900 QFile f(scriptPath);
3902 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3905 playlistPath = scriptPath + ".mlt";
3907 KTemporaryFile temp;
3908 temp.setAutoRemove(false);
3909 temp.setSuffix(".mlt");
3911 playlistPath = temp.fileName();
3913 QString playlistContent = m_projectMonitor->sceneList();
3914 if (!chapterFile.isEmpty()) {
3917 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3919 in = m_activeTimeline->inPoint();
3920 out = m_activeTimeline->outPoint();
3923 QDomElement chapters = doc.createElement("chapters");
3924 chapters.setAttribute("fps", m_activeDocument->fps());
3925 doc.appendChild(chapters);
3927 QDomElement guidesxml = m_activeDocument->guidesXml();
3928 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3929 for (int i = 0; i < nodes.count(); i++) {
3930 QDomElement e = nodes.item(i).toElement();
3932 QString comment = e.attribute("comment");
3933 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3934 if (time >= in && time < out) {
3935 if (zoneOnly) time = time - in;
3936 QDomElement chapter = doc.createElement("chapter");
3937 chapters.appendChild(chapter);
3938 chapter.setAttribute("title", comment);
3939 chapter.setAttribute("time", time);
3943 if (chapters.childNodes().count() > 0) {
3944 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3945 // Always insert a guide in pos 0
3946 QDomElement chapter = doc.createElement("chapter");
3947 chapters.insertBefore(chapter, QDomNode());
3948 chapter.setAttribute("title", i18n("Start"));
3949 chapter.setAttribute("time", "0");
3951 // save chapters file
3952 QFile file(chapterFile);
3953 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3954 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3956 file.write(doc.toString().toUtf8());
3957 if (file.error() != QFile::NoError) {
3958 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3965 if (m_renderWidget->automaticAudioExport()) {
3966 exportAudio = m_activeTimeline->checkProjectAudio();
3967 } else exportAudio = m_renderWidget->selectedAudioExport();
3969 // Set playlist audio volume to 100%
3971 doc.setContent(playlistContent);
3972 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
3973 if (!tractor.isNull()) {
3974 QDomNodeList props = tractor.elementsByTagName("property");
3975 for (int i = 0; i < props.count(); i++) {
3976 if (props.at(i).toElement().attribute("name") == "meta.volume") {
3977 props.at(i).firstChild().setNodeValue("1");
3983 // Do we want proxy rendering
3984 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3985 QString root = doc.documentElement().attribute("root");
3987 // replace proxy clips with originals
3988 QMap <QString, QString> proxies = m_projectList->getProxies();
3990 QDomNodeList producers = doc.elementsByTagName("producer");
3991 QString producerResource;
3993 for (uint n = 0; n < producers.length(); n++) {
3994 QDomElement e = producers.item(n).toElement();
3995 producerResource = EffectsList::property(e, "resource");
3996 if (producerResource.isEmpty()) continue;
3997 if (!producerResource.startsWith("/")) {
3998 producerResource.prepend(root + "/");
4000 if (producerResource.contains('?')) {
4001 // slowmotion producer
4002 suffix = "?" + producerResource.section('?', 1);
4003 producerResource = producerResource.section('?', 0, 0);
4005 else suffix.clear();
4006 if (!producerResource.isEmpty()) {
4007 if (proxies.contains(producerResource)) {
4008 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4009 // We need to delete the "aspect_ratio" property because proxy clips
4010 // sometimes have different ratio than original clips
4011 EffectsList::removeProperty(e, "aspect_ratio");
4012 EffectsList::removeMetaProperties(e);
4017 /*QMapIterator<QString, QString> i(proxies);
4018 while (i.hasNext()) {
4020 // Replace all keys with their values (proxy path with original path)
4021 QString key = i.key();
4022 playlistContent.replace(key, i.value());
4023 if (!root.isEmpty() && key.startsWith(root)) {
4024 // in case the resource path in MLT playlist is relative
4025 key.remove(0, root.count() + 1);
4026 playlistContent.replace(key, i.value());
4030 playlistContent = doc.toString();
4032 // Do save scenelist
4033 QFile file(playlistPath);
4034 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4035 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4038 file.write(playlistContent.toUtf8());
4039 if (file.error() != QFile::NoError) {
4040 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4045 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
4048 void MainWindow::slotUpdateTimecodeFormat(int ix)
4050 KdenliveSettings::setFrametimecode(ix == 1);
4051 m_clipMonitor->updateTimecodeFormat();
4052 m_projectMonitor->updateTimecodeFormat();
4053 m_transitionConfig->updateTimecodeFormat();
4054 m_effectStack->updateTimecodeFormat();
4055 //m_activeTimeline->projectView()->clearSelection();
4056 m_activeTimeline->updateRuler();
4059 void MainWindow::slotRemoveFocus()
4061 statusBar()->setFocus();
4062 statusBar()->clearFocus();
4065 void MainWindow::slotRevert()
4067 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;
4068 KUrl url = m_activeDocument->url();
4069 if (closeCurrentDocument(false))
4070 doOpenFile(url, NULL);
4074 void MainWindow::slotShutdown()
4076 if (m_activeDocument) m_activeDocument->setModified(false);
4078 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4079 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4080 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4081 smserver.call("logout", 1, 2, 2);
4082 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4083 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4084 smserver.call("Shutdown");
4088 void MainWindow::slotUpdateTrackInfo()
4090 if (m_activeDocument)
4091 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4094 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4096 // Load the theme file
4098 if (action == NULL) theme = themename;
4099 else theme = action->data().toString();
4100 KdenliveSettings::setColortheme(theme);
4101 // Make palette for all widgets.
4102 QPalette plt = kapp->palette();
4103 if (theme.isEmpty()) {
4104 plt = QApplication::desktop()->palette();
4106 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4108 #if KDE_IS_VERSION(4,6,3)
4109 plt = KGlobalSettings::createNewApplicationPalette(config);
4111 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4112 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4113 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4114 QPalette::Disabled };
4115 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4116 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4118 for ( int i = 0; i < 3 ; i++ ) {
4119 QPalette::ColorGroup state = states[i];
4120 KColorScheme schemeView(state, KColorScheme::View, config);
4121 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4122 KColorScheme schemeButton(state, KColorScheme::Button, config);
4123 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4125 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4126 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4127 plt.setBrush( state, QPalette::Base, schemeView.background() );
4128 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4129 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4130 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4131 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4132 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4133 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4134 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4136 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4137 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4138 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4139 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4140 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4142 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4143 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4144 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4149 kapp->setPalette(plt);
4150 const QObjectList children = statusBar()->children();
4152 foreach(QObject * child, children) {
4153 if (child->isWidgetType())
4154 ((QWidget*)child)->setPalette(plt);
4155 const QObjectList subchildren = child->children();
4156 foreach(QObject * subchild, subchildren) {
4157 if (subchild->isWidgetType())
4158 ((QWidget*)subchild)->setPalette(plt);
4161 if (m_activeTimeline) {
4162 m_activeTimeline->projectView()->updatePalette();
4167 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4169 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4170 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4171 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4172 const QSize bitsSize(24, 2);
4173 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4174 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4176 QPixmap pixmap(23, 16);
4177 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4179 KConfigGroup group(config, "WM");
4180 QPainter p(&pixmap);
4181 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4182 p.fillRect(1, 1, 7, 7, windowScheme.background());
4183 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4185 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4186 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4187 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4189 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4190 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4192 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4193 p.fillRect(1, 8, 7, 7, viewScheme.background());
4194 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4196 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4197 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4198 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4200 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4201 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4207 void MainWindow::slotSwitchMonitors()
4209 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4210 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4211 else m_projectList->focusTree();
4214 void MainWindow::slotSwitchFullscreen()
4216 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4217 else m_clipMonitor->slotSwitchFullScreen();
4220 void MainWindow::slotInsertZoneToTree()
4222 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4223 QStringList info = m_clipMonitor->getZoneInfo();
4224 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4227 void MainWindow::slotInsertZoneToTimeline()
4229 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4230 QStringList info = m_clipMonitor->getZoneInfo();
4231 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4235 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4237 if (m_activeDocument && m_activeTimeline) {
4238 if (!ids.isEmpty()) {
4239 for (int i = 0; i < ids.size(); ++i) {
4240 m_activeTimeline->slotDeleteClip(ids.at(i));
4242 m_activeDocument->clipManager()->slotDeleteClips(ids);
4244 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4245 m_activeDocument->setModified(true);
4249 void MainWindow::slotShowTitleBars(bool show)
4251 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4252 for (int i = 0; i < docks.count(); i++) {
4253 QDockWidget* dock = docks.at(i);
4255 dock->setTitleBarWidget(0);
4257 if (!dock->isFloating()) {
4258 dock->setTitleBarWidget(new QWidget);
4262 KdenliveSettings::setShowtitlebars(show);
4265 void MainWindow::slotSwitchTitles()
4267 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4270 QString MainWindow::getMimeType(bool open)
4272 QString mimetype = "application/x-kdenlive";
4273 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4275 mimetype = "*.kdenlive";
4276 if (open) mimetype.append(" *.tar.gz");
4278 else if (open) mimetype.append(" application/x-compressed-tar");
4282 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4285 m_projectMonitor->render->sendFrameForAnalysis = true;
4288 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4289 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4296 qDebug() << "Any scope accepting new frames? " << request;
4299 m_projectMonitor->render->sendFrameForAnalysis = false;
4303 void MainWindow::slotUpdateGfxScopeFrameRequest()
4305 // We need a delay to make sure widgets are hidden after a close event for example
4306 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4309 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4312 bool request = false;
4313 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4314 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4315 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4321 if (!m_projectMonitor->effectSceneDisplayed()) {
4322 m_projectMonitor->render->sendFrameForAnalysis = false;
4324 m_clipMonitor->render->sendFrameForAnalysis = false;
4326 m_recMonitor->analyseFrames(false);
4328 m_projectMonitor->render->sendFrameForAnalysis = true;
4329 m_clipMonitor->render->sendFrameForAnalysis = true;
4331 m_recMonitor->analyseFrames(true);
4335 void MainWindow::slotUpdateAudioScopeFrameRequest()
4337 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4340 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4342 bool request = false;
4343 for (int i = 0; i < m_audioScopesList.count(); i++) {
4344 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4345 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4350 // Handle audio signal separately (no common interface)
4351 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4352 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4356 qDebug() << "Scopes Requesting Audio data: " << request;
4358 KdenliveSettings::setMonitor_audio(request);
4359 m_monitorManager->slotUpdateAudioMonitoring();
4362 void MainWindow::slotUpdateColorScopes()
4364 bool request = false;
4365 kDebug()<<"// UPDATE SCOPES";
4366 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4367 // Check if we need the renderer to send a new frame for update
4368 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4369 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged();
4371 if (request && m_monitorManager->activeRenderer()) {
4372 m_monitorManager->activeRenderer()->sendFrameUpdate();
4376 void MainWindow::slotClearColorScopes()
4378 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4379 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotClearMonitor();
4383 void MainWindow::slotOpenStopmotion()
4385 if (m_stopmotion == NULL) {
4386 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4387 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4388 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4389 // Check if we need the renderer to send a new frame for update
4390 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4391 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4392 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4395 m_stopmotion->show();
4398 void MainWindow::slotDeleteClip(const QString &id)
4400 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4401 for (int i = 0; i < list.size(); ++i) {
4402 list.at(i)->disableClipId(id);
4404 m_projectList->slotDeleteClip(id);
4407 void MainWindow::slotUpdateProxySettings()
4409 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4410 if (KdenliveSettings::enableproxy())
4411 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4412 m_projectList->updateProxyConfig();
4415 void MainWindow::slotInsertNotesTimecode()
4417 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4418 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4419 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4422 void MainWindow::slotArchiveProject()
4424 QList <DocClipBase*> list = m_projectList->documentClipList();
4425 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4426 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4431 void MainWindow::slotOpenBackupDialog(const KUrl url)
4436 kDebug()<<"// BACKUP URL: "<<url.path();
4437 if (!url.isEmpty()) {
4438 // we could not open the project file, guess where the backups are
4439 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4443 projectFolder = m_activeDocument->projectFolder();
4444 projectFile = m_activeDocument->url();
4445 projectId = m_activeDocument->getDocumentProperty("documentid");
4448 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4449 if (dia->exec() == QDialog::Accepted) {
4450 QString requestedBackup = dia->selectedFile();
4451 m_activeDocument->backupLastSavedVersion(projectFile.path());
4452 closeCurrentDocument(false);
4453 doOpenFile(KUrl(requestedBackup), NULL);
4454 m_activeDocument->setUrl(projectFile);
4455 m_activeDocument->setModified(true);
4456 setCaption(m_activeDocument->description());
4461 void MainWindow::slotElapsedTime()
4463 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4466 #include "mainwindow.moc"