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 "effectstack/effectstackview2.h"
39 #include "transitionsettings.h"
40 #include "widgets/renderwidget.h"
43 #include "jogshuttle.h"
44 #include "jogaction.h"
45 #include "jogshuttleconfig.h"
47 #include "clipproperties.h"
49 #include "commands/editclipcommand.h"
50 #include "widgets/titlewidget.h"
51 #include "markerdialog.h"
53 #include "interfaces.h"
54 #include "config-kdenlive.h"
55 #include "cliptranscode.h"
56 #include "ui_templateclip_ui.h"
57 #include "scopes/scopemanager.h"
58 #include "scopes/colorscopes/vectorscope.h"
59 #include "scopes/colorscopes/waveform.h"
60 #include "scopes/colorscopes/rgbparade.h"
61 #include "scopes/colorscopes/histogram.h"
62 #include "scopes/audioscopes/audiosignal.h"
63 #include "scopes/audioscopes/audiospectrum.h"
64 #include "scopes/audioscopes/spectrogram.h"
65 #include "widgets/archivewidget.h"
66 #include "databackup/backupwidget.h"
67 #include "utils/resourcewidget.h"
70 #include <KApplication>
72 #include <KLocalizedString>
74 #include <KActionCollection>
75 #include <KActionCategory>
76 #include <KStandardAction>
77 #include <KShortcutsDialog>
78 #include <KFileDialog>
79 #include <KMessageBox>
81 #include <KIO/NetAccess>
84 #include <KConfigDialog>
85 #include <KXMLGUIFactory>
87 #include <kstandarddirs.h>
88 #include <KUrlRequesterDialog>
89 #include <KTemporaryFile>
91 #include <KActionMenu>
93 #include <ktogglefullscreenaction.h>
95 #include <KNotification>
96 #include <KNotifyConfigWidget>
97 #if KDE_IS_VERSION(4,3,80)
98 #include <knewstuff3/downloaddialog.h>
99 #include <knewstuff3/knewstuffaction.h>
101 #include <knewstuff2/engine.h>
102 #include <knewstuff2/ui/knewstuffaction.h>
106 #include <KColorScheme>
107 #include <KProgressDialog>
109 #include <QTextStream>
113 #include <QInputDialog>
114 #include <QDesktopWidget>
116 #include <QUndoGroup>
121 // Uncomment for deeper debugging
122 //#define DEBUG_MAINW
128 static const char version[] = VERSION;
135 Q_DECLARE_METATYPE(QVector<int16_t>)
138 EffectsList MainWindow::videoEffects;
139 EffectsList MainWindow::audioEffects;
140 EffectsList MainWindow::customEffects;
141 EffectsList MainWindow::transitions;
143 QMap <QString,QImage> MainWindow::m_lumacache;
145 static bool sortByNames(const QPair<QString, KAction*> &a, const QPair<QString, KAction*> &b)
147 return a.first < b.first;
150 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
151 KXmlGuiWindow(parent),
152 m_activeDocument(NULL),
153 m_activeTimeline(NULL),
158 m_projectMonitor(NULL),
160 m_renderWidget(NULL),
161 #ifdef USE_JOGSHUTTLE
165 m_findActivated(false),
169 qRegisterMetaType<QVector<int16_t> > ();
170 qRegisterMetaType<stringMap> ("stringMap");
171 qRegisterMetaType<audioByteArray> ("audioByteArray");
174 QLocale systemLocale = QLocale();
175 setlocale(LC_NUMERIC, NULL);
176 char *separator = localeconv()->decimal_point;
177 if (separator != systemLocale.decimalPoint()) {
178 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
179 // HACK: There is a locale conflict, so set locale to C
180 // Make sure to override exported values or it won't work
181 setenv("LANG", "C", 1);
182 setlocale(LC_NUMERIC, "C");
183 systemLocale = QLocale::c();
186 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
187 QLocale::setDefault(systemLocale);
189 // Create DBus interface
190 new MainWindowAdaptor(this);
191 QDBusConnection dbus = QDBusConnection::sessionBus();
192 dbus.registerObject("/MainWindow", this);
194 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
195 setFont(KGlobalSettings::toolBarFont());
196 parseProfiles(MltPath);
197 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
198 m_commandStack = new QUndoGroup;
199 setDockNestingEnabled(true);
200 m_timelineArea = new KTabWidget(this);
201 m_timelineArea->setTabReorderingEnabled(true);
202 m_timelineArea->setTabBarHidden(true);
203 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
204 m_timelineArea->setMinimumHeight(200);
206 QToolButton *closeTabButton = new QToolButton;
207 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
208 closeTabButton->setIcon(KIcon("tab-close"));
209 closeTabButton->adjustSize();
210 closeTabButton->setToolTip(i18n("Close the current tab"));
211 m_timelineArea->setCornerWidget(closeTabButton);
212 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
214 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
215 m_findTimer.setSingleShot(true);
217 // FIXME: the next call returns a newly allocated object, which leaks
218 initEffects::parseEffectFiles();
219 //initEffects::parseCustomEffectsFile();
221 m_monitorManager = new MonitorManager();
223 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
224 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
229 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
230 m_projectListDock->setObjectName("project_tree");
231 m_projectList = new ProjectList();
232 m_projectListDock->setWidget(m_projectList);
233 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
235 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
236 m_clipMonitorDock->setObjectName("clip_monitor");
237 m_clipMonitor = new Monitor(Kdenlive::ClipMonitor, m_monitorManager, QString(), m_timelineArea);
238 m_clipMonitorDock->setWidget(m_clipMonitor);
240 // Connect the project list
241 connect(m_projectList, SIGNAL(clipSelected(DocClipBase*,QPoint,bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase*,QPoint,bool)));
242 connect(m_projectList, SIGNAL(raiseClipMonitor(bool)), m_clipMonitor, SLOT(slotActivateMonitor(bool)));
243 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
244 connect(m_projectList, SIGNAL(displayMessage(QString,int,MessageType)), this, SLOT(slotGotProgressInfo(QString,int,MessageType)));
245 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
246 connect(m_projectList, SIGNAL(clipNeedsReload(QString)),this, SLOT(slotUpdateClip(QString)));
247 connect(m_projectList, SIGNAL(updateProfile(QString)), this, SLOT(slotUpdateProjectProfile(QString)));
248 connect(m_projectList, SIGNAL(refreshClip(QString,bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(QString)));
249 connect(m_projectList, SIGNAL(findInTimeline(QString)), this, SLOT(slotClipInTimeline(QString)));
250 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
251 connect(m_clipMonitor, SIGNAL(extractZone(QString,QPoint)), m_projectList, SLOT(slotCutClipJob(QString,QPoint)));
253 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
254 m_projectMonitorDock->setObjectName("project_monitor");
255 m_projectMonitor = new Monitor(Kdenlive::ProjectMonitor, m_monitorManager, QString());
256 m_projectMonitorDock->setWidget(m_projectMonitor);
259 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
260 m_recMonitorDock->setObjectName("record_monitor");
261 m_recMonitor = new RecMonitor(Kdenlive::RecordMonitor, m_monitorManager);
262 m_recMonitorDock->setWidget(m_recMonitor);
263 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
264 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
265 connect(m_recMonitor, SIGNAL(showConfigDialog(int,int)), this, SLOT(slotPreferences(int,int)));
267 #endif /* ! Q_WS_MAC */
268 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
270 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
271 m_notesDock->setObjectName("notes_widget");
272 m_notesWidget = new NotesWidget();
273 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
274 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
276 m_notesWidget->setTabChangesFocus(true);
277 #if KDE_IS_VERSION(4,4,0)
278 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
280 m_notesDock->setWidget(m_notesWidget);
281 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
283 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
284 m_effectStackDock->setObjectName("effect_stack");
285 m_effectStack = new EffectStackView2(m_projectMonitor);
286 m_effectStackDock->setWidget(m_effectStack);
287 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
288 connect(m_effectStack, SIGNAL(startFilterJob(ItemInfo,QString,QString,QString,QString,QString,QMap<QString,QString>)), m_projectList, SLOT(slotStartFilterJob(ItemInfo,QString,QString,QString,QString,QString,QMap<QString,QString>)));
290 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
291 m_transitionConfigDock->setObjectName("transition");
292 m_transitionConfig = new TransitionSettings(m_projectMonitor);
293 m_transitionConfigDock->setWidget(m_transitionConfig);
294 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
296 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
297 m_effectListDock->setObjectName("effect_list");
298 m_effectList = new EffectsListView();
299 m_effectListDock->setWidget(m_effectList);
300 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
302 m_scopeManager = new ScopeManager(m_monitorManager);
303 m_vectorscope = new Vectorscope();
304 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
305 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
306 m_vectorscopeDock->setWidget(m_vectorscope);
307 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
308 m_scopeManager->addScope(m_vectorscope, m_vectorscopeDock);
310 m_waveform = new Waveform();
311 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
312 m_waveformDock->setObjectName(m_waveform->widgetName());
313 m_waveformDock->setWidget(m_waveform);
314 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
315 m_scopeManager->addScope(m_waveform, m_waveformDock);
317 m_RGBParade = new RGBParade();
318 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
319 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
320 m_RGBParadeDock->setWidget(m_RGBParade);
321 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
322 m_scopeManager->addScope(m_RGBParade, m_RGBParadeDock);
324 m_histogram = new Histogram();
325 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
326 m_histogramDock->setObjectName(m_histogram->widgetName());
327 m_histogramDock->setWidget(m_histogram);
328 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
329 m_scopeManager->addScope(m_histogram, m_histogramDock);
331 m_audiosignal = new AudioSignal;
332 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
333 m_audiosignalDock->setObjectName("audiosignal");
334 m_audiosignalDock->setWidget(m_audiosignal);
335 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
336 m_scopeManager->addScope(m_audiosignal, m_audiosignalDock);
338 m_audioSpectrum = new AudioSpectrum();
339 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
340 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
341 m_audioSpectrumDock->setWidget(m_audioSpectrum);
342 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
343 m_scopeManager->addScope(m_audioSpectrum, m_audioSpectrumDock);
345 m_spectrogram = new Spectrogram();
346 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
347 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
348 m_spectrogramDock->setWidget(m_spectrogram);
349 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
350 m_scopeManager->addScope(m_spectrogram, m_spectrogramDock);
352 // Add monitors here to keep them at the right of the window
353 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
354 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
356 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
359 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
360 m_undoViewDock->setObjectName("undo_history");
361 m_undoView = new QUndoView();
362 m_undoView->setCleanIcon(KIcon("edit-clear"));
363 m_undoView->setEmptyLabel(i18n("Clean"));
364 m_undoViewDock->setWidget(m_undoView);
365 m_undoView->setGroup(m_commandStack);
366 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
370 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
373 // Close non-general docks for the initial layout
374 // only show important ones
375 m_histogramDock->close();
376 m_RGBParadeDock->close();
377 m_waveformDock->close();
378 m_vectorscopeDock->close();
380 m_audioSpectrumDock->close();
381 m_spectrogramDock->close();
382 m_audiosignalDock->close();
384 m_undoViewDock->close();
388 /// Tabify Widgets ///
389 tabifyDockWidget(m_effectListDock, m_effectStackDock);
390 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
391 tabifyDockWidget(m_projectListDock, m_notesDock);
393 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
395 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
397 setCentralWidget(m_timelineArea);
399 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(KUrl)), actionCollection());
401 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
402 m_fileRevert->setEnabled(false);
404 // Prepare layout actions
405 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
406 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
407 for (int i = 1; i < 5; ++i) {
408 KAction *load = new KAction(KIcon(), i18n("Layout %1", i), this);
409 load->setData('_' + QString::number(i));
410 layoutActions->addAction("load_layout" + QString::number(i), load);
411 m_loadLayout->addAction(load);
412 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1", i), this);
413 save->setData('_' + QString::number(i));
414 layoutActions->addAction("save_layout" + QString::number(i), save);
416 // Required to enable user to add the load layout action to toolbar
417 layoutActions->addAction("load_layouts", m_loadLayout);
418 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
421 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
422 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
423 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
424 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
425 m_stopmotion_actions->addAction("stopmotion_capture", action);
426 action = new KAction(i18n("Switch live / captured frame"), this);
427 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
428 m_stopmotion_actions->addAction("stopmotion_switch", action);
429 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
430 action->setCheckable(true);
431 action->setChecked(false);
432 m_stopmotion_actions->addAction("stopmotion_overlay", action);
434 // Build effects menu
435 m_effectsMenu = new QMenu(i18n("Add Effect"));
436 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
437 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
438 m_effectsActionCollection->readSettings();
440 // Populate View menu with show / hide actions for dock widgets
441 KActionCategory *guiActions = new KActionCategory(i18n("Interface"), actionCollection());
445 // Find QDockWidget tab bars and show / hide widget title bars on right click
446 QList <QTabBar *> tabs = findChildren<QTabBar *>();
447 for (int i = 0; i < tabs.count(); ++i) {
448 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
449 connect(tabs.at(i), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotSwitchTitles()));
452 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
453 guiFactory()->addClient(sp);*/
454 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
455 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
458 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
460 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
463 // Load layout names from config file
470 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
471 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
473 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
474 clipInTimeline->setIcon(KIcon("go-jump"));
475 QHash<QString,QMenu*> menus;
476 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
477 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
478 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
479 menus.insert("clipActionsMenu",static_cast<QMenu*>(factory()->container("clip_actions", this)));
480 menus.insert("inTimelineMenu",clipInTimeline);
481 m_projectList->setupGeneratorMenu(menus);
483 // build themes menus
484 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
485 QActionGroup *themegroup = new QActionGroup(this);
486 themegroup->setExclusive(true);
487 action = new KAction(i18n("Default"), this);
488 action->setCheckable(true);
489 themegroup->addAction(action);
490 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
492 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
494 for (int i = 0; i < schemeFiles.size(); ++i) {
496 const QString filename = schemeFiles.at(i);
497 const QFileInfo info(filename);
500 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
501 QIcon icon = createSchemePreviewIcon(config);
502 KConfigGroup group(config, "General");
503 const QString name = group.readEntry("Name", info.baseName());
504 action = new KAction(name, this);
505 action->setData(filename);
506 action->setIcon(icon);
507 action->setCheckable(true);
508 themegroup->addAction(action);
509 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
512 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
513 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
514 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
517 action = new QAction(fi.fileName(), this);
518 action->setData(*it);
519 action->setCheckable(true);
520 themegroup->addAction(action);
521 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
523 themesMenu->addActions(themegroup->actions());
524 connect(themesMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotChangePalette(QAction*)));
526 // Setup and fill effects and transitions menus.
529 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
530 m->addActions(m_effectsMenu->actions());
533 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
534 for (int i = 0; i < transitions.count(); ++i)
535 m_transitionsMenu->addAction(m_transitions[i]);
537 connect(m, SIGNAL(triggered(QAction*)), this, SLOT(slotAddVideoEffect(QAction*)));
538 connect(m_effectsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotAddVideoEffect(QAction*)));
539 connect(m_transitionsMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotAddTransition(QAction*)));
541 m_timelineContextMenu = new QMenu(this);
542 m_timelineContextClipMenu = new QMenu(this);
543 m_timelineContextTransitionMenu = new QMenu(this);
545 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
546 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
547 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
549 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
550 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
551 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
552 m_timelineContextClipMenu->addSeparator();
553 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
554 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
555 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
556 m_timelineContextClipMenu->addAction(actionCollection()->action("set_audio_align_ref"));
557 m_timelineContextClipMenu->addAction(actionCollection()->action("align_audio"));
558 m_timelineContextClipMenu->addSeparator();
559 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
560 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
561 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
562 m_timelineContextClipMenu->addSeparator();
564 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
565 m_timelineContextClipMenu->addMenu(markersMenu);
566 m_timelineContextClipMenu->addSeparator();
567 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
568 m_timelineContextClipMenu->addMenu(m_effectsMenu);
570 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
571 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
573 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
575 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
576 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
577 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
578 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
580 slotConnectMonitors();
582 #ifdef USE_JOGSHUTTLE
583 activateShuttleDevice();
585 m_projectListDock->raise();
587 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
588 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
590 QList<QPair<QString, KAction *> > viewActions;
591 QPair <QString, KAction *> pair;
592 KAction *showTimeline = new KAction(i18n("Timeline"), this);
593 showTimeline->setCheckable(true);
594 showTimeline->setChecked(true);
595 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
597 KMenu *viewMenu = static_cast<KMenu*>(factory()->container("dockwindows", this));
598 pair.first = showTimeline->text();
599 pair.second = showTimeline;
600 viewActions.append(pair);
602 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
603 for (int i = 0; i < docks.count(); ++i) {
604 QDockWidget* dock = docks.at(i);
605 QAction * a = dock->toggleViewAction();
607 KAction* dockInformations = new KAction(this);
608 dockInformations->setText(a->text());
609 dockInformations->setCheckable(true);
610 dockInformations->setChecked(!dock->isHidden());
611 // HACK: since QActions cannot be used in KActionCategory to allow shortcut, we create a duplicate KAction of the dock QAction and link them
612 connect(a,SIGNAL(toggled(bool)), dockInformations, SLOT(setChecked(bool)));
613 connect(dockInformations,SIGNAL(triggered(bool)), a, SLOT(trigger()));
614 pair.first = dockInformations->text();
615 pair.second = dockInformations;
616 viewActions.append(pair);
619 // Sort dock view action by name
620 qSort(viewActions.begin(), viewActions.end(), sortByNames);
621 // Populate view menu
622 for (int i = 0; i < viewActions.count(); ++i)
623 viewMenu->addAction(guiActions->addAction(viewActions.at(i).first, viewActions.at(i).second));
625 // Populate encoding profiles
626 KConfig conf("encodingprofiles.rc", KConfig::CascadeConfig, "appdata");
627 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
628 KConfigGroup group(&conf, "proxy");
629 QMap< QString, QString > values = group.entryMap();
630 QMapIterator<QString, QString> i(values);
633 QString data = i.value();
634 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
635 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
638 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
639 KConfigGroup group(&conf, "video4linux");
640 QMap< QString, QString > values = group.entryMap();
641 QMapIterator<QString, QString> i(values);
644 QString data = i.value();
645 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
646 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
649 if (KdenliveSettings::grab_parameters().isEmpty() || KdenliveSettings::grab_extension().isEmpty()) {
650 KConfigGroup group(&conf, "screengrab");
651 QMap< QString, QString > values = group.entryMap();
652 QMapIterator<QString, QString> i(values);
655 QString data = i.value();
656 KdenliveSettings::setGrab_parameters(data.section(';', 0, 0));
657 KdenliveSettings::setGrab_extension(data.section(';', 1, 1));
660 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
661 KConfigGroup group(&conf, "decklink");
662 QMap< QString, QString > values = group.entryMap();
663 QMapIterator<QString, QString> i(values);
666 QString data = i.value();
667 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
668 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
672 connect (KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(slotChangePalette()));
674 // Open or create a file. Command line argument passed in Url has
675 // precedence, then "openlastproject", then just a plain empty file.
676 // If opening Url fails, openlastproject will _not_ be used.
677 if (!Url.isEmpty()) {
678 // delay loading so that the window shows up
680 QTimer::singleShot(500, this, SLOT(openFile()));
681 } else if (KdenliveSettings::openlastproject()) {
682 QTimer::singleShot(500, this, SLOT(openLastFile()));
683 } else { //if (m_timelineArea->count() == 0) {
687 if (!clipsToLoad.isEmpty() && m_activeDocument) {
688 QStringList list = clipsToLoad.split(',');
690 foreach(const QString &path, list) {
691 kDebug() << QDir::current().absoluteFilePath(path);
692 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
694 m_projectList->slotAddClip(urls);
698 MainWindow::~MainWindow()
702 #ifdef USE_JOGSHUTTLE
706 m_effectStack->slotClipItemSelected(NULL);
707 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
709 if (m_projectMonitor) m_projectMonitor->stop();
710 if (m_clipMonitor) m_clipMonitor->stop();
712 delete m_activeTimeline;
713 delete m_effectStack;
714 delete m_transitionConfig;
715 delete m_activeDocument;
716 delete m_projectMonitor;
717 delete m_clipMonitor;
718 delete m_shortcutRemoveFocus;
719 delete[] m_transitions;
720 delete m_monitorManager;
721 delete m_scopeManager;
722 Mlt::Factory::close();
726 bool MainWindow::queryClose()
728 if (m_renderWidget) {
729 int waitingJobs = m_renderWidget->waitingJobsCount();
730 if (waitingJobs > 0) {
731 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")))) {
732 case KMessageBox::Yes :
733 // create script with waiting jobs and start it
734 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
736 case KMessageBox::No :
737 // Don't do anything, jobs will be deleted
745 if (m_monitorManager) {
746 m_monitorManager->stopActiveMonitor();
749 // warn the user to save if document is modified and we have clips in our project list
750 if (m_activeDocument && m_activeDocument->isModified() &&
751 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
752 !m_projectList->documentClipList().isEmpty())) {
756 if (m_activeDocument->url().fileName().isEmpty()) {
757 message = i18n("Save changes to document?");
759 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?", m_activeDocument->url().fileName());
761 switch (KMessageBox::warningYesNoCancel(this, message)) {
762 case KMessageBox::Yes :
763 // save document here. If saving fails, return false;
765 case KMessageBox::No :
766 // User does not want to save the changes, clear recovery files
767 m_activeDocument->m_autosave->resize(0);
776 void MainWindow::loadPlugins()
778 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
779 populateMenus(plugin);
782 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
784 filters << "libkdenlive*";
785 foreach(const QString & folder, directories) {
786 kDebug() << "Parsing plugin folder: " << folder;
787 QDir pluginsDir(folder);
788 foreach(const QString & fileName,
789 pluginsDir.entryList(filters, QDir::Files)) {
791 * Avoid loading the same plugin twice when there is more than one
794 if (!m_pluginFileNames.contains(fileName)) {
795 kDebug() << "Found plugin: " << fileName;
796 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
797 QObject *plugin = loader.instance();
799 populateMenus(plugin);
800 m_pluginFileNames += fileName;
802 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
808 void MainWindow::populateMenus(QObject *plugin)
810 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
811 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
813 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
817 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
818 QMenu *menu, const char *member,
819 QActionGroup *actionGroup)
821 kDebug() << "// ADD to MENU" << texts;
822 foreach(const QString & text, texts) {
823 QAction *action = new QAction(text, plugin);
824 action->setData(text);
825 connect(action, SIGNAL(triggered()), this, member);
826 menu->addAction(action);
829 action->setCheckable(true);
830 actionGroup->addAction(action);
835 void MainWindow::aboutPlugins()
837 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
842 void MainWindow::generateClip()
844 QAction *action = qobject_cast<QAction *>(sender());
845 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
847 KUrl clipUrl = iGenerator->generatedClip(KdenliveSettings::rendererpath(), action->data().toString(), m_activeDocument->projectFolder(),
848 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
849 if (!clipUrl.isEmpty()) {
850 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
854 void MainWindow::saveProperties(KConfigGroup &config)
856 // save properties here,used by session management
858 KMainWindow::saveProperties(config);
862 void MainWindow::readProperties(const KConfigGroup &config)
864 // read properties here,used by session management
865 KMainWindow::readProperties(config);
866 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
867 openFile(KUrl(Lastproject));
870 void MainWindow::slotReloadEffects()
872 initEffects::parseCustomEffectsFile();
873 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
876 #ifdef USE_JOGSHUTTLE
877 void MainWindow::activateShuttleDevice()
883 if (KdenliveSettings::enableshuttle() == false) return;
885 m_jogProcess = new JogShuttle(JogShuttle::canonicalDevice(KdenliveSettings::shuttledevice()));
886 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
888 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
889 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
890 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
891 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
892 connect(m_jogShuttle, SIGNAL(action(QString)), this, SLOT(slotDoAction(QString)));
894 #endif /* USE_JOGSHUTTLE */
896 void MainWindow::slotDoAction(const QString& action_name)
898 QAction* action = actionCollection()->action(action_name);
900 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
906 void MainWindow::configureNotifications()
908 KNotifyConfigWidget::configure(this);
911 void MainWindow::slotFullScreen()
913 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
916 void MainWindow::slotAddEffect(const QDomElement &effect)
918 if (!m_activeDocument) return;
919 if (effect.isNull()) {
920 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
923 QDomElement effectToAdd = effect.cloneNode().toElement();
925 int ix = m_effectStack->isTrackMode(&ok);
926 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
927 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
930 void MainWindow::slotUpdateClip(const QString &id)
932 if (!m_activeDocument) {
935 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
939 if (clip->numReferences() > 0) {
940 m_activeTimeline->projectView()->slotUpdateClip(id);
942 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
943 Mlt::Producer *monitorProducer = clip->getCloneProducer();
944 m_clipMonitor->updateClipProducer(monitorProducer);
946 clip->cleanupProducers();
949 void MainWindow::slotConnectMonitors()
951 m_projectList->setRenderer(m_projectMonitor->render);
952 connect(m_projectList, SIGNAL(pauseMonitor()), m_monitorManager, SLOT(slotPause()));
953 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList,QMap<QString,QString>)), this, SLOT(slotDeleteProjectClips(QStringList,QMap<QString,QString>)));
954 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase*)), this, SLOT(slotShowClipProperties(DocClipBase*)));
955 connect(m_projectList, SIGNAL(showClipProperties(QList<DocClipBase*>,QMap<QString,QString>)), this, SLOT(slotShowClipProperties(QList<DocClipBase*>,QMap<QString,QString>)));
956 connect(m_projectMonitor->render, SIGNAL(replyGetImage(QString,QString,int,int)), m_projectList, SLOT(slotReplyGetImage(QString,QString,int,int)));
957 connect(m_projectMonitor->render, SIGNAL(replyGetImage(QString,QImage)), m_projectList, SLOT(slotReplyGetImage(QString,QImage)));
959 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(QString,Mlt::Producer*,stringMap,stringMap,bool)), m_projectList, SLOT(slotReplyGetFileProperties(QString,Mlt::Producer*,stringMap,stringMap,bool)));
961 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(QString,bool)), m_projectList, SLOT(slotRemoveInvalidClip(QString,bool)));
963 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(QString,bool)), m_projectList, SLOT(slotRemoveInvalidProxy(QString,bool)));
965 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(QString,bool)), m_projectList, SLOT(slotRefreshClipThumbnail(QString,bool)));
967 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
968 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
970 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
972 connect(m_clipMonitor, SIGNAL(saveZone(Render*,QPoint,DocClipBase*)), this, SLOT(slotSaveZone(Render*,QPoint,DocClipBase*)));
973 connect(m_projectMonitor, SIGNAL(saveZone(Render*,QPoint,DocClipBase*)), this, SLOT(slotSaveZone(Render*,QPoint,DocClipBase*)));
976 void MainWindow::slotAdjustClipMonitor()
978 m_clipMonitorDock->updateGeometry();
979 m_clipMonitorDock->adjustSize();
980 m_clipMonitor->resetSize();
983 void MainWindow::slotAdjustProjectMonitor()
985 m_projectMonitorDock->updateGeometry();
986 m_projectMonitorDock->adjustSize();
987 m_projectMonitor->resetSize();
991 class NameGrabbingKActionCollection {
993 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
994 : m_collection(collection), m_action_names(action_names) {
995 m_action_names.clear();
997 KAction* addAction(const QString& action_name) {
998 m_action_names << action_name;
999 return m_collection->addAction(action_name);
1001 void addAction(const QString& action_name, QAction* action) {
1002 m_action_names << action_name;
1003 m_collection->addAction(action_name, action);
1005 operator KActionCollection*() { return m_collection; }
1006 const QStringList& actionNames() const { return m_action_names; }
1008 KActionCollection* m_collection;
1009 QStringList& m_action_names;
1012 void MainWindow::setupActions()
1014 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
1015 m_statusProgressBar = new QProgressBar(this);
1016 m_statusProgressBar->setMinimum(0);
1017 m_statusProgressBar->setMaximum(100);
1018 m_statusProgressBar->setMaximumWidth(150);
1019 m_statusProgressBar->setVisible(false);
1021 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
1022 toolbar->setMovable(false);
1024 setStatusBarStyleSheet(palette());
1025 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
1027 //create edit mode buttons
1028 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
1029 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
1030 toolbar->addAction(m_normalEditTool);
1031 m_normalEditTool->setCheckable(true);
1032 m_normalEditTool->setChecked(true);
1034 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
1035 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
1036 toolbar->addAction(m_overwriteEditTool);
1037 m_overwriteEditTool->setCheckable(true);
1038 m_overwriteEditTool->setChecked(false);
1040 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
1041 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
1042 toolbar->addAction(m_insertEditTool);
1043 m_insertEditTool->setCheckable(true);
1044 m_insertEditTool->setChecked(false);
1045 // not implemented yet
1046 m_insertEditTool->setEnabled(false);
1048 QActionGroup *editGroup = new QActionGroup(this);
1049 editGroup->addAction(m_normalEditTool);
1050 editGroup->addAction(m_overwriteEditTool);
1051 editGroup->addAction(m_insertEditTool);
1052 editGroup->setExclusive(true);
1053 connect(editGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotChangeEdit(QAction*)));
1054 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
1056 toolbar->addSeparator();
1058 // create tools buttons
1059 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
1060 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
1061 toolbar->addAction(m_buttonSelectTool);
1062 m_buttonSelectTool->setCheckable(true);
1063 m_buttonSelectTool->setChecked(true);
1065 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1066 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1067 toolbar->addAction(m_buttonRazorTool);
1068 m_buttonRazorTool->setCheckable(true);
1069 m_buttonRazorTool->setChecked(false);
1071 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1072 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1073 toolbar->addAction(m_buttonSpacerTool);
1074 m_buttonSpacerTool->setCheckable(true);
1075 m_buttonSpacerTool->setChecked(false);
1077 QActionGroup *toolGroup = new QActionGroup(this);
1078 toolGroup->addAction(m_buttonSelectTool);
1079 toolGroup->addAction(m_buttonRazorTool);
1080 toolGroup->addAction(m_buttonSpacerTool);
1081 toolGroup->setExclusive(true);
1082 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1084 QWidget * actionWidget;
1085 int max = toolbar->iconSizeDefault() + 2;
1086 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1087 actionWidget->setMaximumWidth(max);
1088 actionWidget->setMaximumHeight(max - 4);
1090 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1091 actionWidget->setMaximumWidth(max);
1092 actionWidget->setMaximumHeight(max - 4);
1094 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1095 actionWidget->setMaximumWidth(max);
1096 actionWidget->setMaximumHeight(max - 4);
1098 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1099 actionWidget->setMaximumWidth(max);
1100 actionWidget->setMaximumHeight(max - 4);
1102 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1103 actionWidget->setMaximumWidth(max);
1104 actionWidget->setMaximumHeight(max - 4);
1106 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1107 actionWidget->setMaximumWidth(max);
1108 actionWidget->setMaximumHeight(max - 4);
1110 connect(toolGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotChangeTool(QAction*)));
1112 toolbar->addSeparator();
1113 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1114 toolbar->addAction(m_buttonFitZoom);
1115 m_buttonFitZoom->setCheckable(false);
1117 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1118 toolbar->addAction(m_zoomOut);
1119 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1121 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1122 m_zoomSlider->setMaximum(13);
1123 m_zoomSlider->setPageStep(1);
1124 m_zoomSlider->setInvertedAppearance(true);
1126 m_zoomSlider->setMaximumWidth(150);
1127 m_zoomSlider->setMinimumWidth(100);
1128 toolbar->addWidget(m_zoomSlider);
1130 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1131 toolbar->addAction(m_zoomIn);
1132 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1134 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1135 actionWidget->setMaximumWidth(max);
1136 actionWidget->setMaximumHeight(max - 4);
1137 actionWidget->setStyleSheet(styleBorderless);
1139 actionWidget = toolbar->widgetForAction(m_zoomIn);
1140 actionWidget->setMaximumWidth(max);
1141 actionWidget->setMaximumHeight(max - 4);
1142 actionWidget->setStyleSheet(styleBorderless);
1144 actionWidget = toolbar->widgetForAction(m_zoomOut);
1145 actionWidget->setMaximumWidth(max);
1146 actionWidget->setMaximumHeight(max - 4);
1147 actionWidget->setStyleSheet(styleBorderless);
1149 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1150 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1151 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1152 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1153 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1155 toolbar->addSeparator();
1157 //create automatic audio split button
1158 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1159 toolbar->addAction(m_buttonAutomaticSplitAudio);
1160 m_buttonAutomaticSplitAudio->setCheckable(true);
1161 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1162 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1164 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1165 toolbar->addAction(m_buttonVideoThumbs);
1166 m_buttonVideoThumbs->setCheckable(true);
1167 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1168 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1170 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1171 toolbar->addAction(m_buttonAudioThumbs);
1172 m_buttonAudioThumbs->setCheckable(true);
1173 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1174 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1176 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1177 toolbar->addAction(m_buttonShowMarkers);
1178 m_buttonShowMarkers->setCheckable(true);
1179 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1180 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1182 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1183 toolbar->addAction(m_buttonSnap);
1184 m_buttonSnap->setCheckable(true);
1185 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1186 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1188 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1189 actionWidget->setMaximumWidth(max);
1190 actionWidget->setMaximumHeight(max - 4);
1192 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1193 actionWidget->setMaximumWidth(max);
1194 actionWidget->setMaximumHeight(max - 4);
1196 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1197 actionWidget->setMaximumWidth(max);
1198 actionWidget->setMaximumHeight(max - 4);
1200 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1201 actionWidget->setMaximumWidth(max);
1202 actionWidget->setMaximumHeight(max - 4);
1204 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1205 actionWidget->setMaximumWidth(max);
1206 actionWidget->setMaximumHeight(max - 4);
1208 m_messageLabel = new StatusBarMessageLabel(this);
1209 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1211 statusBar()->addWidget(m_messageLabel, 10);
1212 statusBar()->addWidget(m_statusProgressBar, 0);
1213 statusBar()->addPermanentWidget(toolbar);
1215 m_timeFormatButton = new KSelectAction("00:00:00:00 / 00:00:00:00", this);
1216 m_timeFormatButton->addAction(i18n("hh:mm:ss:ff"));
1217 m_timeFormatButton->addAction(i18n("Frames"));
1218 if (KdenliveSettings::frametimecode()) m_timeFormatButton->setCurrentItem(1);
1219 else m_timeFormatButton->setCurrentItem(0);
1220 connect(m_timeFormatButton, SIGNAL(triggered(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
1221 m_timeFormatButton->setToolBarMode(KSelectAction::MenuMode);
1222 toolbar->addAction(m_timeFormatButton);
1224 const QFontMetrics metric(statusBar()->font());
1225 int requiredWidth = metric.boundingRect("00:00:00:00 / 00:00:00:00").width() + 20;
1226 actionWidget = toolbar->widgetForAction(m_timeFormatButton);
1227 actionWidget->setObjectName("timecode");
1228 actionWidget->setMinimumWidth(requiredWidth);
1230 collection.addAction("normal_mode", m_normalEditTool);
1231 collection.addAction("overwrite_mode", m_overwriteEditTool);
1232 collection.addAction("insert_mode", m_insertEditTool);
1233 collection.addAction("select_tool", m_buttonSelectTool);
1234 collection.addAction("razor_tool", m_buttonRazorTool);
1235 collection.addAction("spacer_tool", m_buttonSpacerTool);
1237 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1238 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1239 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1240 collection.addAction("show_markers", m_buttonShowMarkers);
1241 collection.addAction("snap", m_buttonSnap);
1242 collection.addAction("zoom_fit", m_buttonFitZoom);
1243 collection.addAction("zoom_in", m_zoomIn);
1244 collection.addAction("zoom_out", m_zoomOut);
1246 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1247 collection.addAction("project_find", m_projectSearch);
1248 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1249 m_projectSearch->setShortcut(Qt::Key_Slash);
1251 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1252 collection.addAction("project_find_next", m_projectSearchNext);
1253 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1254 m_projectSearchNext->setShortcut(Qt::Key_F3);
1255 m_projectSearchNext->setEnabled(false);
1257 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1258 collection.addAction("manage_profiles", profilesAction);
1259 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1261 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1262 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1263 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1264 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1266 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1267 collection.addAction("run_wizard", wizAction);
1268 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1270 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1271 collection.addAction("project_settings", projectAction);
1272 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1274 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1275 collection.addAction("open_backup", backupAction);
1276 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1278 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1279 collection.addAction("project_render", projectRender);
1280 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1281 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1283 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1284 collection.addAction("project_clean", projectClean);
1285 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1287 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1288 collection.addAction("project_adjust_profile", projectAdjust);
1289 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1291 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1292 monitorPlay->setShortcut(Qt::Key_Space);
1293 collection.addAction("monitor_play", monitorPlay);
1294 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1296 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1297 monitorPause->setShortcut(Qt::Key_K);
1298 collection.addAction("monitor_pause", monitorPause);
1299 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1301 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1302 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1303 collection.addAction("monitor_play_zone", m_playZone);
1304 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1306 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1307 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1308 collection.addAction("monitor_loop_zone", m_loopZone);
1309 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1311 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1312 m_loopClip->setEnabled(false);
1313 collection.addAction("monitor_loop_clip", m_loopClip);
1314 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1316 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1317 collection.addAction("dvd_wizard", dvdWizard);
1318 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1320 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1321 collection.addAction("transcode_clip", transcodeClip);
1322 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1324 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1325 collection.addAction("archive_project", archiveProject);
1326 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1329 KAction *markIn = collection.addAction("mark_in");
1330 markIn->setText(i18n("Set Zone In"));
1331 markIn->setShortcut(Qt::Key_I);
1332 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1334 KAction *markOut = collection.addAction("mark_out");
1335 markOut->setText(i18n("Set Zone Out"));
1336 markOut->setShortcut(Qt::Key_O);
1337 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1339 KAction *switchMon = collection.addAction("switch_monitor");
1340 switchMon->setText(i18n("Switch monitor"));
1341 switchMon->setShortcut(Qt::Key_T);
1342 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1344 KAction *fullMon = collection.addAction("monitor_fullscreen");
1345 fullMon->setText(i18n("Switch monitor fullscreen"));
1346 fullMon->setIcon(KIcon("view-fullscreen"));
1347 connect(fullMon, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotSwitchFullscreen()));
1349 KSelectAction *interlace = new KSelectAction(i18n("Deinterlacer"), this);
1350 interlace->addAction(i18n("One Field (fast)"));
1351 interlace->addAction(i18n("Linear Blend (fast)"));
1352 interlace->addAction(i18n("YADIF - temporal only (good)"));
1353 interlace->addAction(i18n("YADIF - temporal + spacial (best)"));
1354 if (KdenliveSettings::mltdeinterlacer() == "linearblend") interlace->setCurrentItem(1);
1355 else if (KdenliveSettings::mltdeinterlacer() == "yadif-temporal") interlace->setCurrentItem(2);
1356 else if (KdenliveSettings::mltdeinterlacer() == "yadif") interlace->setCurrentItem(3);
1357 else interlace->setCurrentItem(0);
1358 collection.addAction("mlt_interlace", interlace);
1359 connect(interlace, SIGNAL(triggered(int)), this, SLOT(slotSetDeinterlacer(int)));
1361 KSelectAction *interpol = new KSelectAction(i18n("Interpolation"), this);
1362 interpol->addAction(i18n("Nearest Neighbor (fast)"));
1363 interpol->addAction(i18n("Bilinear (good)"));
1364 interpol->addAction(i18n("Bicubic (better)"));
1365 interpol->addAction(i18n("Hyper/Lanczos (best)"));
1366 if (KdenliveSettings::mltinterpolation() == "bilinear") interpol->setCurrentItem(1);
1367 else if (KdenliveSettings::mltinterpolation() == "bicubic") interpol->setCurrentItem(2);
1368 else if (KdenliveSettings::mltinterpolation() == "hyper") interpol->setCurrentItem(3);
1369 else interpol->setCurrentItem(0);
1370 collection.addAction("mlt_interpolation", interpol);
1371 connect(interpol, SIGNAL(triggered(int)), this, SLOT(slotSetInterpolation(int)));
1373 KAction *insertTree = collection.addAction("insert_project_tree");
1374 insertTree->setText(i18n("Insert zone in project tree"));
1375 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1376 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1378 KAction *insertTimeline = collection.addAction("insert_timeline");
1379 insertTimeline->setText(i18n("Insert zone in timeline"));
1380 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1381 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1383 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1384 collection.addAction("resize_timeline_clip_start", resizeStart);
1385 resizeStart->setShortcut(Qt::Key_1);
1386 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1388 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1389 collection.addAction("resize_timeline_clip_end", resizeEnd);
1390 resizeEnd->setShortcut(Qt::Key_2);
1391 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1393 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1394 monitorSeekBackward->setShortcut(Qt::Key_J);
1395 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1396 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1398 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1399 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1400 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1401 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1403 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1404 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1405 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1406 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1408 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1409 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1410 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1411 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1413 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1414 monitorSeekForward->setShortcut(Qt::Key_L);
1415 collection.addAction("monitor_seek_forward", monitorSeekForward);
1416 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1418 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1419 clipStart->setShortcut(Qt::Key_Home);
1420 collection.addAction("seek_clip_start", clipStart);
1421 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1423 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1424 clipEnd->setShortcut(Qt::Key_End);
1425 collection.addAction("seek_clip_end", clipEnd);
1426 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1428 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1429 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1430 collection.addAction("seek_zone_start", zoneStart);
1431 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1433 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1434 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1435 collection.addAction("seek_zone_end", zoneEnd);
1436 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1438 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1439 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1440 collection.addAction("seek_start", projectStart);
1441 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1443 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1444 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1445 collection.addAction("seek_end", projectEnd);
1446 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1448 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1449 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1450 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1451 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1453 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1454 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1455 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1456 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1458 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1459 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1460 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1461 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1463 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1464 deleteItem->setShortcut(Qt::Key_Delete);
1465 collection.addAction("delete_timeline_clip", deleteItem);
1466 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1468 KAction* alignPlayhead = new KAction(i18n("Align Playhead to Mouse Position"), this);
1469 alignPlayhead->setShortcut(Qt::Key_P);
1470 collection.addAction("align_playhead", alignPlayhead);
1471 connect(alignPlayhead, SIGNAL(triggered(bool)), this, SLOT(slotAlignPlayheadToMousePos()));
1473 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1474 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1475 editTimelineClipSpeed->setData("change_speed");
1476 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1478 KAction *stickTransition = collection.addAction("auto_transition");
1479 stickTransition->setData(QString("auto"));
1480 stickTransition->setCheckable(true);
1481 stickTransition->setEnabled(false);
1482 stickTransition->setText(i18n("Automatic Transition"));
1483 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1485 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1486 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1487 collection.addAction("group_clip", groupClip);
1488 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1490 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1491 collection.addAction("ungroup_clip", ungroupClip);
1492 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1493 ungroupClip->setData("ungroup_clip");
1494 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1496 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1497 collection.addAction("edit_item_duration", editItemDuration);
1498 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1500 KAction* saveTimelineClip = new KAction(KIcon("document-save"), i18n("Save clip"), this);
1501 collection.addAction("save_timeline_clip", saveTimelineClip);
1502 connect(saveTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSaveTimelineClip()));
1504 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1505 collection.addAction("clip_in_project_tree", clipInProjectTree);
1506 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1508 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1509 collection.addAction("clip_to_project_tree", clipToProjectTree);
1510 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1512 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1513 insertOvertwrite->setShortcut(Qt::Key_V);
1514 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1515 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1517 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1518 selectTimelineClip->setShortcut(Qt::Key_Plus);
1519 collection.addAction("select_timeline_clip", selectTimelineClip);
1520 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1522 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1523 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1524 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1525 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1527 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1528 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1529 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1530 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1532 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1533 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1534 collection.addAction("select_timeline_transition", selectTimelineTransition);
1535 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1537 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1538 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1539 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1540 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1542 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1543 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1544 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1545 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1547 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1548 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1549 collection.addAction("cut_timeline_clip", cutTimelineClip);
1550 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1552 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1553 collection.addAction("add_clip_marker", addClipMarker);
1554 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1556 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1557 collection.addAction("delete_clip_marker", deleteClipMarker);
1558 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1560 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1561 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1562 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1564 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1565 editClipMarker->setData(QString("edit_marker"));
1566 collection.addAction("edit_clip_marker", editClipMarker);
1567 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1569 KAction* addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1570 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1571 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1572 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1574 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1575 collection.addAction("split_audio", splitAudio);
1576 // "A+V" as data means this action should only be available for clips with audio AND video
1577 splitAudio->setData("A+V");
1578 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1580 KAction* setAudioAlignReference = new KAction(i18n("Set Audio Reference"), this);
1581 collection.addAction("set_audio_align_ref", setAudioAlignReference);
1582 // "A" as data means this action should only be available for clips with audio
1583 setAudioAlignReference->setData("A");
1584 connect(setAudioAlignReference, SIGNAL(triggered()), this, SLOT(slotSetAudioAlignReference()));
1586 KAction* alignAudio = new KAction(i18n("Align Audio to Reference"), this);
1587 collection.addAction("align_audio", alignAudio);
1588 // "A" as data means this action should only be available for clips with audio
1589 alignAudio->setData("A");
1590 connect(alignAudio, SIGNAL(triggered()), this, SLOT(slotAlignAudio()));
1592 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1593 collection.addAction("clip_audio_only", audioOnly);
1594 audioOnly->setData("clip_audio_only");
1595 audioOnly->setCheckable(true);
1597 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1598 collection.addAction("clip_video_only", videoOnly);
1599 videoOnly->setData("clip_video_only");
1600 videoOnly->setCheckable(true);
1602 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1603 collection.addAction("clip_audio_and_video", audioAndVideo);
1604 audioAndVideo->setData("clip_audio_and_video");
1605 audioAndVideo->setCheckable(true);
1607 m_clipTypeGroup = new QActionGroup(this);
1608 m_clipTypeGroup->addAction(audioOnly);
1609 m_clipTypeGroup->addAction(videoOnly);
1610 m_clipTypeGroup->addAction(audioAndVideo);
1611 connect(m_clipTypeGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotUpdateClipType(QAction*)));
1612 m_clipTypeGroup->setEnabled(false);
1614 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1615 collection.addAction("insert_space", insertSpace);
1616 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1618 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1619 collection.addAction("delete_space", removeSpace);
1620 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1622 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1623 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1625 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1626 m_tracksActionCollection->addAction("insert_track", insertTrack);
1627 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1629 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1630 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1631 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1633 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1634 m_tracksActionCollection->addAction("config_tracks", configTracks);
1635 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1637 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1638 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1639 m_tracksActionCollection->addAction("select_track", selectTrack);
1641 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1642 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1643 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1645 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1646 collection.addAction("add_guide", addGuide);
1647 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1649 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1650 collection.addAction("delete_guide", delGuide);
1651 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1653 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1654 collection.addAction("edit_guide", editGuide);
1655 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1657 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1658 collection.addAction("delete_all_guides", delAllGuides);
1659 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1661 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1662 collection.addAction("paste_effects", pasteEffects);
1663 pasteEffects->setData("paste_effects");
1664 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1666 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1667 collection.addAction("show_titlebars", showTitleBar);
1668 showTitleBar->setCheckable(true);
1669 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1670 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1671 slotShowTitleBars(KdenliveSettings::showtitlebars());
1673 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1674 KStandardAction::quit(this, SLOT(close()), collection);
1675 KStandardAction::open(this, SLOT(openFile()), collection);
1676 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1677 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1678 KStandardAction::openNew(this, SLOT(newFile()), collection);
1679 // TODO: make the following connection to slotEditKeys work
1680 //KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1681 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1682 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1683 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1684 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1685 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1687 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1688 undo->setEnabled(false);
1689 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1691 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1692 redo->setEnabled(false);
1693 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1696 //TODO: Add status tooltip to actions ?
1697 connect(collection, SIGNAL(actionHovered(QAction*)),
1698 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1701 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1702 collection.addAction("add_clip", addClip);
1703 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1705 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1706 collection.addAction("add_color_clip", addColorClip);
1707 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1709 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1710 collection.addAction("add_slide_clip", addSlideClip);
1711 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1713 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1714 collection.addAction("add_text_clip", addTitleClip);
1715 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1717 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1718 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1719 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1721 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1722 collection.addAction("add_folder", addFolderButton);
1723 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1725 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1726 collection.addAction("download_resource", downloadResources);
1727 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1729 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1730 collection.addAction("clip_properties", clipProperties);
1731 clipProperties->setData("clip_properties");
1732 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1733 clipProperties->setEnabled(false);
1735 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1736 collection.addAction("edit_clip", openClip);
1737 openClip->setData("edit_clip");
1738 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1739 openClip->setEnabled(false);
1741 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1742 collection.addAction("delete_clip", deleteClip);
1743 deleteClip->setData("delete_clip");
1744 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1745 deleteClip->setEnabled(false);
1747 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1748 collection.addAction("reload_clip", reloadClip);
1749 reloadClip->setData("reload_clip");
1750 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1751 reloadClip->setEnabled(false);
1753 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1754 collection.addAction("proxy_clip", proxyClip);
1755 proxyClip->setData("proxy_clip");
1756 proxyClip->setCheckable(true);
1757 proxyClip->setChecked(false);
1758 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1760 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1761 collection.addAction("stopmotion", stopMotion);
1762 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1764 QMenu *addClips = new QMenu();
1765 addClips->addAction(addClip);
1766 addClips->addAction(addColorClip);
1767 addClips->addAction(addSlideClip);
1768 addClips->addAction(addTitleClip);
1769 addClips->addAction(addTitleTemplateClip);
1770 addClips->addAction(addFolderButton);
1771 addClips->addAction(downloadResources);
1773 addClips->addAction(reloadClip);
1774 addClips->addAction(proxyClip);
1775 addClips->addAction(clipProperties);
1776 addClips->addAction(openClip);
1777 addClips->addAction(deleteClip);
1778 m_projectList->setupMenu(addClips, addClip);
1780 // Setup effects and transitions actions.
1781 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1782 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1783 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1784 m_transitions = new KAction*[transitions.count()];
1785 for (int i = 0; i < transitions.count(); ++i) {
1786 QStringList effectInfo = transitions.effectIdInfo(i);
1787 m_transitions[i] = new KAction(effectInfo.at(0), this);
1788 m_transitions[i]->setData(effectInfo);
1789 m_transitions[i]->setIconVisibleInMenu(false);
1790 QString id = effectInfo.at(2);
1791 if (id.isEmpty()) id = effectInfo.at(1);
1792 transitionActions->addAction("transition_" + id, m_transitions[i]);
1794 //m_effectsActionCollection->readSettings();
1798 void MainWindow::slotDisplayActionMessage(QAction *a)
1800 statusBar()->showMessage(a->data().toString(), 3000);
1803 void MainWindow::setStatusBarStyleSheet(const QPalette &p)
1805 KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
1806 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
1807 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
1808 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
1809 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
1810 QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton#timecode {padding-right:10px;} QToolButton:hover { background: %3;border-style: inset; border:1px solid %3;border-radius: 3px;} QToolButton:checked { background-color: %1; border-style: inset; border:1px solid %2;border-radius: 3px;}").arg(buttonBg.name()).arg(buttonBord.name()).arg(buttonBord2.name());
1811 statusBar()->setStyleSheet(style1);
1814 void MainWindow::loadLayouts()
1816 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1817 if (m_loadLayout == NULL || saveLayout == NULL) return;
1818 KSharedConfigPtr config = KGlobal::config();
1819 KConfigGroup layoutGroup(config, "Layouts");
1820 QStringList entries = layoutGroup.keyList();
1821 QList<QAction *> loadActions = m_loadLayout->actions();
1822 QList<QAction *> saveActions = saveLayout->actions();
1823 for (int i = 1; i < 5; ++i) {
1824 // Rename the layouts actions
1825 foreach(const QString & key, entries) {
1826 if (key.endsWith(QString("_%1").arg(i))) {
1827 // Found previously saved layout
1828 QString layoutName = key.section('_', 0, -2);
1829 for (int j = 0; j < loadActions.count(); j++) {
1830 if (loadActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
1831 loadActions[j]->setText(layoutName);
1832 loadActions[j]->setData(key);
1836 for (int j = 0; j < saveActions.count(); j++) {
1837 if (saveActions.at(j)->data().toString().endsWith('_' + QString::number(i))) {
1838 saveActions[j]->setText(i18n("Save as %1", layoutName));
1839 saveActions[j]->setData(key);
1848 void MainWindow::slotLoadLayout(QAction *action)
1854 QString layoutId = action->data().toString();
1855 if (layoutId.isEmpty()) {
1859 KSharedConfigPtr config = KGlobal::config();
1860 KConfigGroup layouts(config, "Layouts");
1861 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1862 restoreState(state);
1865 void MainWindow::slotSaveLayout(QAction *action)
1867 QString originallayoutName = action->data().toString();
1868 int layoutId = originallayoutName.section('_', -1).toInt();
1870 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1871 if (layoutName.isEmpty()) {
1874 KSharedConfigPtr config = KGlobal::config();
1875 KConfigGroup layouts(config, "Layouts");
1876 layouts.deleteEntry(originallayoutName);
1878 QByteArray st = saveState();
1879 layoutName.append('_' + QString::number(layoutId));
1880 layouts.writeEntry(layoutName, st.toBase64());
1884 void MainWindow::saveOptions()
1886 KdenliveSettings::self()->writeConfig();
1887 KSharedConfigPtr config = KGlobal::config();
1888 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1889 KConfigGroup treecolumns(config, "Project Tree");
1890 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1894 void MainWindow::readOptions()
1896 KSharedConfigPtr config = KGlobal::config();
1897 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1898 KConfigGroup initialGroup(config, "version");
1899 bool upgrade = false;
1900 if (initialGroup.exists()) {
1901 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1905 if (initialGroup.readEntry("version") == "0.7") {
1906 //Add new settings from 0.7.1
1907 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1908 QString path = QDir::homePath() + "/kdenlive";
1909 if (KStandardDirs::makeDir(path) == false) {
1910 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1912 KdenliveSettings::setDefaultprojectfolder(path);
1918 if (KdenliveSettings::ffmpegpath().isEmpty() || KdenliveSettings::ffplaypath().isEmpty()) {
1922 if (!initialGroup.exists() || upgrade) {
1923 // this is our first run, show Wizard
1924 QPointer<Wizard> w = new Wizard(upgrade, this);
1925 if (w->exec() == QDialog::Accepted && w->isOk()) {
1926 w->adjustSettings();
1927 initialGroup.writeEntry("version", version);
1935 KConfigGroup treecolumns(config, "Project Tree");
1936 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1937 if (!state.isEmpty()) {
1938 m_projectList->setHeaderInfo(state);
1942 void MainWindow::slotRunWizard()
1944 QPointer<Wizard> w = new Wizard(false, this);
1945 if (w->exec() == QDialog::Accepted && w->isOk()) {
1946 w->adjustSettings();
1951 void MainWindow::newFile(bool showProjectSettings, bool force)
1953 if (!m_timelineArea->isEnabled() && !force) {
1956 m_fileRevert->setEnabled(false);
1957 QString profileName = KdenliveSettings::default_profile();
1958 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1959 QMap <QString, QString> documentProperties;
1960 QMap <QString, QString> documentMetadata;
1961 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1962 if (!showProjectSettings) {
1963 if (!KdenliveSettings::activatetabs()) {
1964 if (!closeCurrentDocument()) {
1969 QPointer<ProjectSettings> w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1970 if (w->exec() != QDialog::Accepted) {
1974 if (!KdenliveSettings::activatetabs()) {
1975 if (!closeCurrentDocument()) {
1980 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) {
1981 slotSwitchVideoThumbs();
1983 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) {
1984 slotSwitchAudioThumbs();
1986 profileName = w->selectedProfile();
1987 projectFolder = w->selectedFolder();
1988 projectTracks = w->tracks();
1989 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1990 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1991 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1992 documentProperties.insert("proxyparams", w->proxyParams());
1993 documentProperties.insert("proxyextension", w->proxyExtension());
1994 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1995 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1996 documentMetadata = w->metadata();
1999 m_timelineArea->setEnabled(true);
2000 m_projectList->setEnabled(true);
2002 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
2003 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
2005 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2006 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
2009 //m_timelineArea->setEnabled(false);
2010 //m_projectList->setEnabled(false);
2014 if (m_timelineArea->count() == 1) {
2015 connectDocumentInfo(doc);
2016 connectDocument(trackView, doc);
2018 m_timelineArea->setTabBarHidden(false);
2020 m_monitorManager->activateMonitor(Kdenlive::ClipMonitor);
2021 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2024 void MainWindow::activateDocument()
2026 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) {
2029 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
2030 KdenliveDoc *currentDoc = currentTab->document();
2031 connectDocumentInfo(currentDoc);
2032 connectDocument(currentTab, currentDoc);
2035 bool MainWindow::closeCurrentDocument(bool saveChanges)
2037 QWidget *w = m_timelineArea->currentWidget();
2041 // closing current document
2042 int ix = m_timelineArea->currentIndex() + 1;
2043 if (ix == m_timelineArea->count()) {
2046 m_timelineArea->setCurrentIndex(ix);
2047 TrackView *tabToClose = (TrackView *) w;
2048 KdenliveDoc *docToClose = tabToClose->document();
2049 if (docToClose && docToClose->isModified() && saveChanges) {
2051 if (m_activeDocument->url().fileName().isEmpty()) {
2052 message = i18n("Save changes to document?");
2054 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?", m_activeDocument->url().fileName());
2057 switch (KMessageBox::warningYesNoCancel(this, message)) {
2058 case KMessageBox::Yes :
2059 // save document here. If saving fails, return false;
2060 if (saveFile() == false) return false;
2062 case KMessageBox::Cancel :
2070 slotTimelineClipSelected(NULL, false);
2071 m_clipMonitor->slotSetClipProducer(NULL);
2072 m_projectList->slotResetProjectList();
2073 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
2074 if (m_timelineArea->count() == 1) {
2075 m_timelineArea->setTabBarHidden(true);
2076 m_closeAction->setEnabled(false);
2079 if (docToClose == m_activeDocument) {
2080 delete m_activeDocument;
2081 m_activeDocument = NULL;
2082 m_monitorManager->setDocument(m_activeDocument);
2083 m_effectStack->clear();
2084 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2089 if (w == m_activeTimeline) {
2090 delete m_activeTimeline;
2091 m_activeTimeline = NULL;
2099 bool MainWindow::saveFileAs(const QString &outputFileName)
2101 m_monitorManager->stopActiveMonitor();
2103 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false) {
2107 // Save timeline thumbnails
2108 m_activeTimeline->projectView()->saveThumbnails();
2109 m_activeDocument->setUrl(KUrl(outputFileName));
2110 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
2111 if (m_activeDocument->m_autosave == NULL) {
2112 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
2114 m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
2117 setCaption(m_activeDocument->description());
2118 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2119 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
2120 m_activeDocument->setModified(false);
2121 m_fileOpenRecent->addUrl(KUrl(outputFileName));
2122 m_fileRevert->setEnabled(true);
2123 m_undoView->stack()->setClean();
2128 bool MainWindow::saveFileAs()
2130 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
2131 if (outputFile.isEmpty()) {
2135 if (QFile::exists(outputFile)) {
2136 // Show the file dialog again if the user does not want to overwrite the file
2137 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No) {
2138 return saveFileAs();
2142 return saveFileAs(outputFile);
2145 bool MainWindow::saveFile()
2147 if (!m_activeDocument) {
2151 if (m_activeDocument->url().isEmpty()) {
2152 return saveFileAs();
2154 bool result = saveFileAs(m_activeDocument->url().path());
2155 m_activeDocument->m_autosave->resize(0);
2160 void MainWindow::openFile()
2162 if (!m_startUrl.isEmpty()) {
2163 openFile(m_startUrl);
2164 m_startUrl = KUrl();
2167 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2168 if (url.isEmpty()) {
2172 m_fileOpenRecent->addUrl(url);
2176 void MainWindow::openLastFile()
2178 if (m_fileOpenRecent->selectableActionGroup()->actions().isEmpty()) {
2179 // No files in history
2184 QAction *firstUrlAction = m_fileOpenRecent->selectableActionGroup()->actions().last();
2185 if (firstUrlAction) {
2186 firstUrlAction->trigger();
2192 void MainWindow::openFile(const KUrl &url)
2194 // Make sure the url is a Kdenlive project file
2195 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2196 if (mime.data()->is("application/x-compressed-tar")) {
2197 // Opening a compressed project file, we need to process it
2198 kDebug()<<"Opening archive, processing";
2199 QPointer<ArchiveWidget> ar = new ArchiveWidget(url);
2200 if (ar->exec() == QDialog::Accepted) {
2201 openFile(KUrl(ar->extractedProjectFile()));
2202 } else if (!m_startUrl.isEmpty()) {
2203 // we tried to open an invalid file from command line, init new project
2210 if (!url.fileName().endsWith(".kdenlive")) {
2211 // This is not a Kdenlive project file, abort loading
2212 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2213 if (!m_startUrl.isEmpty()) {
2214 // we tried to open an invalid file from command line, init new project
2220 // Check if the document is already opened
2221 const int ct = m_timelineArea->count();
2222 bool isOpened = false;
2224 for (i = 0; i < ct; ++i) {
2225 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2226 KdenliveDoc *doc = tab->document();
2227 if (doc->url() == url) {
2234 m_timelineArea->setCurrentIndex(i);
2238 if (!KdenliveSettings::activatetabs()) {
2239 if (!closeCurrentDocument()) {
2244 // Check for backup file
2245 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2246 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2247 if (!staleFiles.isEmpty()) {
2248 if (KMessageBox::questionYesNo(this,
2249 i18n("Auto-saved files exist. Do you want to recover them now?"),
2250 i18n("File Recovery"),
2251 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2252 recoverFiles(staleFiles, url);
2255 // remove the stale files
2256 foreach(KAutoSaveFile * stale, staleFiles) {
2257 stale->open(QIODevice::ReadWrite);
2262 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2263 m_messageLabel->repaint();
2264 doOpenFile(url, NULL);
2267 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2269 if (!m_timelineArea->isEnabled()) return;
2270 m_fileRevert->setEnabled(true);
2272 // Recreate stopmotion widget on document change
2274 delete m_stopmotion;
2275 m_stopmotion = NULL;
2279 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2280 progressDialog.setAllowCancel(false);
2281 progressDialog.progressBar()->setMaximum(4);
2282 progressDialog.show();
2283 progressDialog.progressBar()->setValue(0);
2286 KdenliveDoc *doc = new KdenliveDoc(stale ? KUrl(stale->fileName()) : url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
2288 progressDialog.progressBar()->setValue(1);
2289 progressDialog.progressBar()->setMaximum(4);
2290 progressDialog.setLabelText(i18n("Loading project"));
2291 progressDialog.repaint();
2293 if (stale == NULL) {
2294 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2295 stale = new KAutoSaveFile(KUrl(hash), doc);
2296 doc->m_autosave = stale;
2298 doc->m_autosave = stale;
2299 doc->setUrl(url);//stale->managedFile());
2300 doc->setModified(true);
2301 stale->setParent(doc);
2303 connectDocumentInfo(doc);
2305 progressDialog.progressBar()->setValue(2);
2306 progressDialog.repaint();
2309 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2310 connectDocument(trackView, doc);
2311 progressDialog.progressBar()->setValue(3);
2312 progressDialog.repaint();
2314 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2316 m_timelineArea->setEnabled(false);
2317 m_projectList->setEnabled(false);
2318 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2319 slotGotProgressInfo(QString(), -1);
2320 newFile(false, true);
2323 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2324 trackView->setDuration(trackView->duration());
2326 if (m_timelineArea->count() > 1) {
2327 m_timelineArea->setTabBarHidden(false);
2330 slotGotProgressInfo(QString(), -1);
2331 m_projectMonitor->adjustRulerSize(trackView->duration());
2332 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2333 progressDialog.progressBar()->setValue(4);
2335 slotOpenBackupDialog(url);
2339 void MainWindow::recoverFiles(const QList<KAutoSaveFile *> &staleFiles, const KUrl &originUrl)
2341 foreach(KAutoSaveFile * stale, staleFiles) {
2342 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2343 // show an error message; we could not steal the lockfile
2344 // maybe another application got to the file before us?
2348 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2349 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2350 if (!stale->fileName().endsWith(".lock")) {
2351 doOpenFile(originUrl, stale);
2353 KIO::NetAccess::del(KUrl(stale->fileName()), this);
2358 void MainWindow::parseProfiles(const QString &mltPath)
2360 //KdenliveSettings::setDefaulttmpfolder();
2361 if (!mltPath.isEmpty()) {
2362 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2363 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2366 if (KdenliveSettings::mltpath().isEmpty()) {
2367 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2370 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2371 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2372 if (!QFile::exists(meltPath)) {
2373 meltPath = KStandardDirs::findExe("melt");
2375 KdenliveSettings::setRendererpath(meltPath);
2378 if (KdenliveSettings::rendererpath().isEmpty()) {
2379 // Cannot find the MLT melt renderer, ask for location
2380 QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2381 if (getUrl->exec() == QDialog::Rejected) {
2385 KUrl rendererPath = getUrl->selectedUrl();
2387 if (rendererPath.isEmpty()) ::exit(0);
2388 KdenliveSettings::setRendererpath(rendererPath.path());
2391 QStringList profilesFilter;
2392 profilesFilter << "*";
2393 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2394 if (profilesList.isEmpty()) {
2395 // Cannot find MLT path, try finding melt
2396 QString profilePath = KdenliveSettings::rendererpath();
2397 if (!profilePath.isEmpty()) {
2398 profilePath = profilePath.section('/', 0, -3);
2399 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2400 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2402 if (profilesList.isEmpty()) {
2403 // Cannot find the MLT profiles, ask for location
2404 QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2405 getUrl->fileDialog()->setMode(KFile::Directory);
2406 if (getUrl->exec() == QDialog::Rejected) {
2410 KUrl mltPath = getUrl->selectedUrl();
2412 if (mltPath.isEmpty()) ::exit(0);
2413 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2414 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2418 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2420 // Parse again MLT profiles to build a list of available video formats
2421 if (profilesList.isEmpty()) {
2427 void MainWindow::slotEditProfiles()
2429 ProfilesDialog *w = new ProfilesDialog;
2430 if (w->exec() == QDialog::Accepted) {
2431 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2439 void MainWindow::slotDetectAudioDriver()
2441 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2442 leading to no audio output, see bug #934 */
2444 //decide which audio driver is really best, in some cases SDL is wrong
2445 if (KdenliveSettings::audiodrivername().isEmpty()) {
2447 KProcess readProcess;
2448 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2449 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2450 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2451 readProcess.setProgram("pactl", QStringList() << "stat");
2452 readProcess.execute(2000); // Kill it after 2 seconds
2454 QString result = QString(readProcess.readAllStandardOutput());
2455 kDebug() << "// / / / / / READING PACTL: ";
2457 if (!result.isEmpty()) {
2459 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2463 KdenliveSettings::setAutoaudiodrivername(driver);
2467 void MainWindow::slotEditProjectSettings()
2469 QPoint p = m_activeDocument->getTracksCount();
2470 QPointer<ProjectSettings> w = new ProjectSettings(m_projectList, m_activeDocument->metadata(), m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2471 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2473 if (w->exec() == QDialog::Accepted) {
2474 QString profile = w->selectedProfile();
2475 m_activeDocument->setProjectFolder(w->selectedFolder());
2477 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2479 if (m_renderWidget) {
2480 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2482 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) {
2483 slotSwitchVideoThumbs();
2485 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) {
2486 slotSwitchAudioThumbs();
2488 if (m_activeDocument->profilePath() != profile) {
2489 slotUpdateProjectProfile(profile);
2491 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2492 m_activeDocument->setModified();
2493 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2494 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) {
2495 //TODO: rebuild all proxies
2496 //m_projectList->rebuildProxies();
2499 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2500 m_activeDocument->setModified();
2501 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2503 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2504 m_activeDocument->setModified();
2505 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2507 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2508 m_activeDocument->setModified();
2509 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2511 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2512 m_activeDocument->setModified();
2513 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2515 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2516 m_activeDocument->setModified();
2517 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2519 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2520 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2521 m_activeDocument->setModified();
2522 slotUpdateProxySettings();
2524 if (w->metadata() != m_activeDocument->metadata()) {
2525 m_activeDocument->setMetadata(w->metadata());
2531 void MainWindow::slotDisableProxies()
2533 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2534 m_activeDocument->setModified();
2535 slotUpdateProxySettings();
2538 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2540 // Recreate the stopmotion widget if profile changes
2542 delete m_stopmotion;
2543 m_stopmotion = NULL;
2546 // Deselect current effect / transition
2547 m_effectStack->slotClipItemSelected(NULL);
2548 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2549 m_clipMonitor->slotSetClipProducer(NULL);
2550 bool updateFps = m_activeDocument->setProfilePath(profile);
2551 KdenliveSettings::setCurrent_profile(profile);
2552 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2553 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2554 m_activeDocument->clipManager()->clearUnusedProducers();
2555 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2556 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2557 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2558 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2559 if (m_renderWidget) {
2560 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2562 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2564 m_activeTimeline->updateProjectFps();
2566 m_activeDocument->clipManager()->clearCache();
2567 m_activeTimeline->updateProfile();
2568 m_activeDocument->setModified(true);
2569 m_commandStack->activeStack()->clear();
2570 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2571 slotUpdateMousePosition(0);
2572 m_projectList->slotReloadClip();
2573 // We need to desactivate & reactivate monitors to get a refresh
2574 //m_monitorManager->switchMonitors();
2578 void MainWindow::slotRenderProject()
2580 if (!m_renderWidget) {
2581 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2582 MltVideoProfile profile;
2583 if (m_activeDocument) {
2584 profile = m_activeDocument->mltProfile();
2586 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2587 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2588 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap<QString,QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap<QString,QString>)));
2589 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool,bool,QString)), this, SLOT(slotPrepareRendering(bool,bool,QString)));
2590 connect(m_renderWidget, SIGNAL(abortProcess(QString)), this, SIGNAL(abortRenderJob(QString)));
2591 connect(m_renderWidget, SIGNAL(openDvdWizard(QString)), this, SLOT(slotDvdWizard(QString)));
2592 if (m_activeDocument) {
2593 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2594 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2595 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2596 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2599 slotCheckRenderStatus();
2600 m_renderWidget->show();
2601 m_renderWidget->showNormal();
2603 // What are the following lines supposed to do?
2604 //m_activeTimeline->tracksNumber();
2605 //m_renderWidget->enableAudio(false);
2606 //m_renderWidget->export_audio;
2609 void MainWindow::slotCheckRenderStatus()
2611 // Make sure there are no missing clips
2613 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2616 void MainWindow::setRenderingProgress(const QString &url, int progress)
2619 m_renderWidget->setRenderJob(url, progress);
2622 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2625 m_renderWidget->setRenderStatus(url, status, error);
2628 void MainWindow::slotCleanProject()
2630 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2631 m_projectList->cleanup();
2634 void MainWindow::slotUpdateMousePosition(int pos)
2636 if (m_activeDocument) {
2637 switch (m_timeFormatButton->currentItem()) {
2639 m_timeFormatButton->setText(m_activeDocument->timecode().getTimecodeFromFrames(pos) + " / " + m_activeDocument->timecode().getTimecodeFromFrames(m_activeTimeline->duration()));
2642 m_timeFormatButton->setText(QString::number(pos) + " / " + QString::number(m_activeTimeline->duration()));
2647 void MainWindow::slotUpdateProjectDuration(int pos)
2649 if (m_activeDocument) {
2650 m_activeTimeline->setDuration(pos);
2651 slotUpdateMousePosition(m_activeTimeline->projectView()->getMousePos());
2655 void MainWindow::slotUpdateDocumentState(bool modified)
2657 if (!m_activeDocument) return;
2658 setCaption(m_activeDocument->description(), modified);
2659 m_saveAction->setEnabled(modified);
2661 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2662 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2664 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2665 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2669 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2671 if (m_activeDocument) {
2672 if (m_activeDocument == doc) return;
2673 disconnect(m_activeDocument, SIGNAL(progressInfo(QString,int)), this, SLOT(slotGotProgressInfo(QString,int)));
2675 connect(doc, SIGNAL(progressInfo(QString,int)), this, SLOT(slotGotProgressInfo(QString,int)));
2678 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2680 //m_projectMonitor->stop();
2681 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2682 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2683 if (m_activeDocument) {
2684 if (m_activeDocument == doc) {
2687 if (m_activeTimeline) {
2688 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2689 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2690 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2691 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2692 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2693 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2694 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2696 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool,bool)), m_activeDocument, SLOT(checkProjectClips(bool,bool)));
2698 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2699 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase*,bool)), m_projectList, SLOT(slotAddClip(DocClipBase*,bool)));
2700 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2701 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(QString)), this, SLOT(slotDeleteClip(QString)));
2702 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(QString)), m_projectList, SLOT(slotUpdateClip(QString)));
2703 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(QString)), m_projectList, SLOT(slotSelectClip(QString)));
2704 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*,bool)), this, SLOT(slotTimelineClipSelected(ClipItem*,bool)));
2705 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*,int,QPoint,bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*,int,QPoint,bool)));
2706 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*,int,QPoint,bool)), this, SLOT(slotActivateTransitionView(Transition*)));
2707 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2708 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(QString,MessageType)), m_messageLabel, SLOT(setMessage(QString,MessageType)));
2709 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase*,QPoint,bool,int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase*,QPoint,bool,int)));
2710 disconnect(m_projectList, SIGNAL(gotFilterJobResults(QString,int,int,stringMap,stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(QString,int,int,stringMap,stringMap)));
2712 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
2713 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2714 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2715 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*,int,QDomElement,QDomElement,int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*,int,QDomElement,QDomElement,int,bool)));
2716 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*,int,QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*,int,QDomElement)));
2717 disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*,QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*,QDomElement)));
2718 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*,int,QList<int>,bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*,int,QList<int>,bool)));
2719 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*,int,QList<int>,int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*,int,QList<int>,int)));
2720 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2721 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2722 disconnect(m_effectStack, SIGNAL(displayMessage(QString,int)), this, SLOT(slotGotProgressInfo(QString,int)));
2723 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition*,QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition*,QDomElement)));
2724 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2725 disconnect(m_transitionConfig, SIGNAL(importClipKeyframes(GraphicsRectItem)), m_activeTimeline->projectView() , SLOT(slotImportClipKeyframes(GraphicsRectItem)));
2727 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2728 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int,int)), this, SLOT(slotZoneMoved(int,int)));
2729 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2730 disconnect(m_projectList, SIGNAL(refreshClip(QString)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(QString)));
2731 disconnect(m_projectList, SIGNAL(addMarkers(QString,QList<CommentedTime>)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(QString,QList<CommentedTime>)));
2732 m_effectStack->clear();
2734 //m_activeDocument->setRenderer(NULL);
2735 m_clipMonitor->stop();
2737 KdenliveSettings::setCurrent_profile(doc->profilePath());
2738 KdenliveSettings::setProject_fps(doc->fps());
2739 m_monitorManager->resetProfiles(doc->timecode());
2740 m_clipMonitorDock->raise();
2741 m_projectList->setDocument(doc);
2742 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2743 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2744 connect(m_projectList, SIGNAL(refreshClip(QString,bool)), trackView->projectView(), SLOT(slotRefreshThumbs(QString,bool)));
2746 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2747 connect(m_projectList, SIGNAL(clipNameChanged(QString,QString)), trackView->projectView(), SLOT(clipNameChanged(QString,QString)));
2749 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2750 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2751 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2752 connect(trackView->projectView(), SIGNAL(forceClipProcessing(QString)), m_projectList, SLOT(slotForceProcessing(QString)));
2754 connect(trackView->projectView(), SIGNAL(importKeyframes(GraphicsRectItem,QString,int)), this, SLOT(slotProcessImportKeyframes(GraphicsRectItem,QString,int)));
2756 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2757 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2758 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2759 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2760 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool,bool)), doc, SLOT(checkProjectClips(bool,bool)));
2762 connect(doc, SIGNAL(addProjectClip(DocClipBase*,bool)), m_projectList, SLOT(slotAddClip(DocClipBase*,bool)));
2763 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2764 connect(doc, SIGNAL(signalDeleteProjectClip(QString)), this, SLOT(slotDeleteClip(QString)));
2765 connect(doc, SIGNAL(updateClipDisplay(QString)), m_projectList, SLOT(slotUpdateClip(QString)));
2766 connect(doc, SIGNAL(selectLastAddedClip(QString)), m_projectList, SLOT(slotSelectClip(QString)));
2768 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2769 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2770 connect(doc, SIGNAL(saveTimelinePreview(QString)), trackView, SLOT(slotSaveTimelinePreview(QString)));
2772 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2774 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase*)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2775 connect(trackView, SIGNAL(showTrackEffects(int,TrackInfo)), this, SLOT(slotTrackSelected(int,TrackInfo)));
2777 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*,bool)), this, SLOT(slotTimelineClipSelected(ClipItem*,bool)));
2778 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*,int,QPoint,bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*,int,QPoint,bool)));
2779 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*,int,QPoint,bool)), this, SLOT(slotActivateTransitionView(Transition*)));
2780 m_zoomSlider->setValue(doc->zoom().x());
2781 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2782 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2783 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2784 connect(trackView->projectView(), SIGNAL(displayMessage(QString,MessageType)), m_messageLabel, SLOT(setMessage(QString,MessageType)));
2786 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase*,QPoint,bool,int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase*,QPoint,bool,int)));
2787 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2789 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*,int,QPoint,bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2791 connect(m_projectList, SIGNAL(gotFilterJobResults(QString,int,int,stringMap,stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(QString,int,int,stringMap,stringMap)));
2793 connect(m_projectList, SIGNAL(addMarkers(QString,QList<CommentedTime>)), trackView->projectView(), SLOT(slotAddClipMarker(QString,QList<CommentedTime>)));
2795 // Effect stack signals
2796 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*,int,QDomElement,QDomElement,int,bool)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*,int,QDomElement,QDomElement,int,bool)));
2797 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*,int,QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*,int,QString)));
2798 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*,int,QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*,int,QDomElement)));
2799 connect(m_effectStack, SIGNAL(addEffect(ClipItem*,QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*,QDomElement)));
2800 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*,int,QList<int>,bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*,int,QList<int>,bool)));
2801 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*,int,QList<int>,int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*,int,QList<int>,int)));
2803 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2804 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView(), SLOT(seekCursorPos(int)));
2805 connect(m_effectStack, SIGNAL(importClipKeyframes(GraphicsRectItem)), trackView->projectView(), SLOT(slotImportClipKeyframes(GraphicsRectItem)));
2806 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2807 connect(m_effectStack, SIGNAL(displayMessage(QString,int)), this, SLOT(slotGotProgressInfo(QString,int)));
2809 // Transition config signals
2810 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition*,QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition*,QDomElement)));
2811 connect(m_transitionConfig, SIGNAL(importClipKeyframes(GraphicsRectItem)), trackView->projectView() , SLOT(slotImportClipKeyframes(GraphicsRectItem)));
2812 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(seekCursorPos(int)));
2814 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2815 connect(trackView, SIGNAL(zoneMoved(int,int)), this, SLOT(slotZoneMoved(int,int)));
2816 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2817 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2818 m_activeTimeline = trackView;
2819 if (m_renderWidget) {
2820 slotCheckRenderStatus();
2821 m_renderWidget->setProfile(doc->mltProfile());
2822 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2823 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2824 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2826 //doc->setRenderer(m_projectMonitor->render);
2827 m_commandStack->setActiveStack(doc->commandStack());
2828 KdenliveSettings::setProject_display_ratio(doc->dar());
2829 //doc->clipManager()->checkAudioThumbs();
2831 //m_overView->setScene(trackView->projectScene());
2832 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2833 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2835 setCaption(doc->description(), doc->isModified());
2836 m_saveAction->setEnabled(doc->isModified());
2837 m_normalEditTool->setChecked(true);
2838 m_activeDocument = doc;
2839 connect(m_projectMonitor, SIGNAL(durationChanged(int)), this, SLOT(slotUpdateProjectDuration(int)));
2840 m_monitorManager->setDocument(m_activeDocument);
2841 m_activeTimeline->updateProjectFps();
2842 m_activeDocument->checkProjectClips();
2844 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2846 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2847 slotUpdateMousePosition(0);
2849 // Make sure monitor is visible so that it is painted black on startup
2851 m_monitorManager->activateMonitor(Kdenlive::ClipMonitor, true);
2852 // set tool to select tool
2853 m_buttonSelectTool->setChecked(true);
2856 void MainWindow::slotZoneMoved(int start, int end)
2858 m_activeDocument->setZone(start, end);
2859 m_projectMonitor->slotZoneMoved(start, end);
2862 void MainWindow::slotGuidesUpdated()
2865 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2868 void MainWindow::slotEditKeys()
2870 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2871 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2872 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2873 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2877 void MainWindow::slotPreferences(int page, int option)
2880 * An instance of your dialog could be already created and could be
2881 * cached, in which case you want to display the cached dialog
2882 * instead of creating another one
2885 m_stopmotion->slotLive(false);
2888 if (KConfigDialog::showDialog("settings")) {
2889 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2890 if (page != -1) d->showPage(page, option);
2894 // KConfigDialog didn't find an instance of this dialog, so lets
2897 // Get the mappable actions in localized form
2898 QMap<QString, QString> actions;
2899 KActionCollection* collection = actionCollection();
2900 foreach (const QString& action_name, m_action_names) {
2901 actions[collection->action(action_name)->text()] = action_name;
2904 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2905 connect(dialog, SIGNAL(settingsChanged(QString)), this, SLOT(updateConfiguration()));
2906 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2908 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2912 dialog->showPage(page, option);
2916 void MainWindow::slotUpdateCaptureFolder()
2920 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2921 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2925 void MainWindow::updateConfiguration()
2927 //TODO: we should apply settings to all projects, not only the current one
2928 if (m_activeTimeline) {
2929 m_activeTimeline->refresh();
2930 m_activeTimeline->projectView()->checkAutoScroll();
2931 m_activeTimeline->checkTrackHeight();
2932 if (m_activeDocument)
2933 m_activeDocument->clipManager()->checkAudioThumbs();
2935 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2936 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2937 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2938 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2940 // Update list of transcoding profiles
2943 #ifdef USE_JOGSHUTTLE
2944 activateShuttleDevice();
2949 void MainWindow::slotSwitchSplitAudio()
2951 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2952 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2955 void MainWindow::slotSwitchVideoThumbs()
2957 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2958 if (m_activeTimeline) {
2959 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2961 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2964 void MainWindow::slotSwitchAudioThumbs()
2966 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2967 if (m_activeTimeline) {
2968 m_activeTimeline->refresh();
2969 m_activeTimeline->projectView()->checkAutoScroll();
2970 if (m_activeDocument) {
2971 m_activeDocument->clipManager()->checkAudioThumbs();
2974 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2977 void MainWindow::slotSwitchMarkersComments()
2979 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2980 if (m_activeTimeline) {
2981 m_activeTimeline->refresh();
2983 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2986 void MainWindow::slotSwitchSnap()
2988 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2989 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2993 void MainWindow::slotDeleteItem()
2995 if (QApplication::focusWidget() &&
2996 QApplication::focusWidget()->parentWidget() &&
2997 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2998 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2999 m_projectList->slotRemoveClip();
3002 QWidget *widget = QApplication::focusWidget();
3004 if (widget == m_effectStackDock) {
3005 m_effectStack->deleteCurrentEffect();
3008 widget = widget->parentWidget();
3011 // effect stack has no focus
3012 if (m_activeTimeline) {
3013 m_activeTimeline->projectView()->deleteSelectedClips();
3018 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
3020 if (m_clipMonitor->isActive()) {
3021 m_clipMonitor->checkOverlay();
3023 m_clipMonitor->updateMarkers(clip);
3026 void MainWindow::slotAddClipMarker()
3028 DocClipBase *clip = NULL;
3030 if (m_projectMonitor->isActive()) {
3031 if (m_activeTimeline) {
3032 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
3034 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
3035 clip = item->baseClip();
3039 clip = m_clipMonitor->activeClip();
3040 pos = m_clipMonitor->position();
3043 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
3046 QString id = clip->getId();
3047 CommentedTime marker(pos, i18n("Marker"), KdenliveSettings::default_marker_type());
3048 QPointer<MarkerDialog> d = new MarkerDialog(clip, marker,
3049 m_activeDocument->timecode(), i18n("Add Marker"), this);
3050 if (d->exec() == QDialog::Accepted) {
3051 m_activeTimeline->projectView()->slotAddClipMarker(id, QList <CommentedTime>() << d->newMarker());
3052 QString hash = clip->getClipHash();
3053 if (!hash.isEmpty()) m_activeDocument->cacheImage(hash + '#' + QString::number(d->newMarker().time().frames(m_activeDocument->fps())), d->markerImage());
3058 void MainWindow::slotDeleteClipMarker()
3060 DocClipBase *clip = NULL;
3062 if (m_projectMonitor->isActive()) {
3063 if (m_activeTimeline) {
3064 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
3066 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
3067 clip = item->baseClip();
3071 clip = m_clipMonitor->activeClip();
3072 pos = m_clipMonitor->position();
3075 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
3079 QString id = clip->getId();
3080 QString comment = clip->markerComment(pos);
3081 if (comment.isEmpty()) {
3082 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
3085 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
3088 void MainWindow::slotDeleteAllClipMarkers()
3090 DocClipBase *clip = NULL;
3091 if (m_projectMonitor->isActive()) {
3092 if (m_activeTimeline) {
3093 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
3095 clip = item->baseClip();
3099 clip = m_clipMonitor->activeClip();
3102 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
3105 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
3108 void MainWindow::slotEditClipMarker()
3110 DocClipBase *clip = NULL;
3112 if (m_projectMonitor->isActive()) {
3113 if (m_activeTimeline) {
3114 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
3116 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
3117 clip = item->baseClip();
3121 clip = m_clipMonitor->activeClip();
3122 pos = m_clipMonitor->position();
3125 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
3129 QString id = clip->getId();
3130 CommentedTime oldMarker = clip->markerAt(pos);
3131 if (oldMarker == CommentedTime()) {
3132 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
3136 QPointer<MarkerDialog> d = new MarkerDialog(clip, oldMarker,
3137 m_activeDocument->timecode(), i18n("Edit Marker"), this);
3138 if (d->exec() == QDialog::Accepted) {
3139 m_activeTimeline->projectView()->slotAddClipMarker(id, QList <CommentedTime>() <<d->newMarker());
3140 QString hash = clip->getClipHash();
3141 if (!hash.isEmpty()) m_activeDocument->cacheImage(hash + '#' + QString::number(d->newMarker().time().frames(m_activeDocument->fps())), d->markerImage());
3142 if (d->newMarker().time() != pos) {
3143 // remove old marker
3144 oldMarker.setMarkerType(-1);
3145 m_activeTimeline->projectView()->slotAddClipMarker(id, QList <CommentedTime>() <<oldMarker);
3151 void MainWindow::slotAddMarkerGuideQuickly()
3153 if (!m_activeTimeline || !m_activeDocument)
3156 if (m_clipMonitor->isActive()) {
3157 DocClipBase *clip = m_clipMonitor->activeClip();
3158 GenTime pos = m_clipMonitor->position();
3161 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
3164 //TODO: allow user to set default marker category
3165 CommentedTime marker(pos, m_activeDocument->timecode().getDisplayTimecode(pos, false), KdenliveSettings::default_marker_type());
3166 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), QList <CommentedTime>() <<marker);
3168 m_activeTimeline->projectView()->slotAddGuide(false);
3172 void MainWindow::slotAddGuide()
3174 if (m_activeTimeline)
3175 m_activeTimeline->projectView()->slotAddGuide();
3178 void MainWindow::slotInsertSpace()
3180 if (m_activeTimeline)
3181 m_activeTimeline->projectView()->slotInsertSpace();
3184 void MainWindow::slotRemoveSpace()
3186 if (m_activeTimeline)
3187 m_activeTimeline->projectView()->slotRemoveSpace();
3190 void MainWindow::slotInsertTrack(int ix)
3192 m_monitorManager->activateMonitor(Kdenlive::ProjectMonitor);
3193 if (m_activeTimeline) {
3195 ix = m_activeTimeline->projectView()->selectedTrack();
3197 m_activeTimeline->projectView()->slotInsertTrack(ix);
3199 if (m_activeDocument) {
3200 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3204 void MainWindow::slotDeleteTrack(int ix)
3206 m_monitorManager->activateMonitor(Kdenlive::ProjectMonitor);
3207 if (m_activeTimeline) {
3209 ix = m_activeTimeline->projectView()->selectedTrack();
3211 m_activeTimeline->projectView()->slotDeleteTrack(ix);
3213 if (m_activeDocument) {
3214 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3218 void MainWindow::slotConfigTrack(int ix)
3220 m_monitorManager->activateMonitor(Kdenlive::ProjectMonitor);
3221 if (m_activeTimeline)
3222 m_activeTimeline->projectView()->slotConfigTracks(ix);
3223 if (m_activeDocument)
3224 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3227 void MainWindow::slotSelectTrack()
3229 m_monitorManager->activateMonitor(Kdenlive::ProjectMonitor);
3230 if (m_activeTimeline) {
3231 m_activeTimeline->projectView()->slotSelectClipsInTrack();
3235 void MainWindow::slotSelectAllTracks()
3237 m_monitorManager->activateMonitor(Kdenlive::ProjectMonitor);
3238 if (m_activeTimeline)
3239 m_activeTimeline->projectView()->slotSelectAllClips();
3242 void MainWindow::slotEditGuide()
3244 if (m_activeTimeline)
3245 m_activeTimeline->projectView()->slotEditGuide();
3248 void MainWindow::slotDeleteGuide()
3250 if (m_activeTimeline)
3251 m_activeTimeline->projectView()->slotDeleteGuide();
3254 void MainWindow::slotDeleteAllGuides()
3256 if (m_activeTimeline)
3257 m_activeTimeline->projectView()->slotDeleteAllGuides();
3260 void MainWindow::slotCutTimelineClip()
3262 if (m_activeTimeline)
3263 m_activeTimeline->projectView()->cutSelectedClips();
3266 void MainWindow::slotInsertClipOverwrite()
3268 if (m_activeTimeline) {
3269 QStringList data = m_clipMonitor->getZoneInfo();
3270 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
3274 void MainWindow::slotSelectTimelineClip()
3276 if (m_activeTimeline)
3277 m_activeTimeline->projectView()->selectClip(true);
3280 void MainWindow::slotSelectTimelineTransition()
3282 if (m_activeTimeline)
3283 m_activeTimeline->projectView()->selectTransition(true);
3286 void MainWindow::slotDeselectTimelineClip()
3288 if (m_activeTimeline)
3289 m_activeTimeline->projectView()->selectClip(false, true);
3292 void MainWindow::slotDeselectTimelineTransition()
3294 if (m_activeTimeline)
3295 m_activeTimeline->projectView()->selectTransition(false, true);
3298 void MainWindow::slotSelectAddTimelineClip()
3300 if (m_activeTimeline)
3301 m_activeTimeline->projectView()->selectClip(true, true);
3304 void MainWindow::slotSelectAddTimelineTransition()
3306 if (m_activeTimeline)
3307 m_activeTimeline->projectView()->selectTransition(true, true);
3310 void MainWindow::slotGroupClips()
3312 if (m_activeTimeline)
3313 m_activeTimeline->projectView()->groupClips();
3316 void MainWindow::slotUnGroupClips()
3318 if (m_activeTimeline)
3319 m_activeTimeline->projectView()->groupClips(false);
3322 void MainWindow::slotEditItemDuration()
3324 if (m_activeTimeline)
3325 m_activeTimeline->projectView()->editItemDuration();
3328 void MainWindow::slotAddProjectClip(const KUrl &url, const stringMap &data)
3330 if (m_activeDocument) {
3331 m_activeDocument->slotAddClipFile(url, data);
3335 void MainWindow::slotAddProjectClipList(const KUrl::List &urls)
3337 if (m_activeDocument)
3338 m_activeDocument->slotAddClipList(urls);
3341 void MainWindow::slotAddTransition(QAction *result)
3343 if (!result) return;
3344 QStringList info = result->data().toStringList();
3345 if (info.isEmpty()) return;
3346 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3347 if (m_activeTimeline && !transition.isNull()) {
3348 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3352 void MainWindow::slotAddVideoEffect(QAction *result)
3357 const int VideoEffect = 1;
3358 const int AudioEffect = 2;
3359 QStringList info = result->data().toStringList();
3361 if (info.isEmpty() || info.size() < 3) {
3364 QDomElement effect ;
3365 if (info.last() == QString::number((int) VideoEffect)) {
3366 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3367 } else if (info.last() == QString::number((int) AudioEffect)) {
3368 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3370 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3373 if (!effect.isNull()) {
3374 slotAddEffect(effect);
3376 m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2", info.at(0), info.at(1)), ErrorMessage);
3381 void MainWindow::slotZoomIn()
3383 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3384 slotShowZoomSliderToolTip();
3387 void MainWindow::slotZoomOut()
3389 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3390 slotShowZoomSliderToolTip();
3393 void MainWindow::slotFitZoom()
3395 if (m_activeTimeline)
3396 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3399 void MainWindow::slotSetZoom(int value)
3401 value = qMax(m_zoomSlider->minimum(), value);
3402 value = qMin(m_zoomSlider->maximum(), value);
3404 if (m_activeTimeline) {
3405 m_activeTimeline->slotChangeZoom(value);
3408 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3409 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3410 slotUpdateZoomSliderToolTip(value);
3412 m_zoomSlider->blockSignals(true);
3413 m_zoomSlider->setValue(value);
3414 m_zoomSlider->blockSignals(false);
3417 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3419 if (zoomlevel != -1) {
3420 slotUpdateZoomSliderToolTip(zoomlevel);
3423 QPoint global = m_zoomSlider->rect().topLeft();
3424 global.ry() += m_zoomSlider->height() / 2;
3425 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3426 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3429 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3431 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3434 void MainWindow::slotGotProgressInfo(const QString &message, int progress, MessageType type)
3436 if (type == DefaultMessage) {
3437 m_statusProgressBar->setValue(progress);
3439 m_messageLabel->setMessage(message, type);
3440 if (progress >= 0) {
3441 if (type == DefaultMessage) {
3442 m_statusProgressBar->setVisible(true);
3445 m_statusProgressBar->setVisible(false);
3449 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3451 if (clip->clipType() == Text) {
3452 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3453 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3454 // template text clip
3456 // Get the list of existing templates
3458 filter << "*.kdenlivetitle";
3459 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3461 QDialog *dia = new QDialog(this);
3462 Ui::TemplateClip_UI dia_ui;
3463 dia_ui.setupUi(dia);
3465 const QString templatePath = clip->getProperty("resource");
3466 for (int i = 0; i < templateFiles.size(); ++i) {
3467 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3468 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3470 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3471 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3472 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3473 //warning: setting base directory doesn't work??
3474 KUrl startDir(titlepath);
3475 dia_ui.template_list->fileDialog()->setUrl(startDir);
3476 dia_ui.description->setText(clip->getProperty("description"));
3477 if (dia->exec() == QDialog::Accepted) {
3478 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3479 if (textTemplate.isEmpty()) {
3480 textTemplate = dia_ui.template_list->comboBox()->currentText();
3483 QMap <QString, QString> newprops;
3485 if (KUrl(textTemplate).path() != templatePath) {
3486 // The template was changed
3487 newprops.insert("resource", textTemplate);
3490 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3491 newprops.insert("description", dia_ui.description->toPlainText());
3494 QString newtemplate = newprops.value("xmltemplate");
3495 if (newtemplate.isEmpty()) {
3496 newtemplate = templatePath;
3499 // template modified we need to update xmldata
3500 QString description = newprops.value("description");
3501 if (description.isEmpty()) {
3502 description = clip->getProperty("description");
3504 newprops.insert("templatetext", description);
3507 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3508 if (!newprops.isEmpty()) {
3509 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3510 m_activeDocument->commandStack()->push(command);
3516 QString path = clip->getProperty("resource");
3517 QPointer<TitleWidget> dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3519 doc.setContent(clip->getProperty("xmldata"));
3520 dia_ui->setXml(doc);
3521 if (dia_ui->exec() == QDialog::Accepted) {
3522 QMap <QString, QString> newprops;
3523 newprops.insert("xmldata", dia_ui->xml().toString());
3524 if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps())) {
3525 // duration changed, we need to update duration
3526 newprops.insert("out", QString::number(dia_ui->duration() - 1));
3527 int currentLength = QString(clip->producerProperty("length")).toInt();
3528 if (currentLength <= dia_ui->duration()) {
3529 newprops.insert("length", QString::number(dia_ui->duration()));
3531 newprops.insert("length", clip->producerProperty("length"));
3534 if (!path.isEmpty()) {
3535 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3536 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) {
3537 // save to external file
3538 dia_ui->saveTitle(path);
3540 newprops.insert("resource", QString());
3543 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3544 m_activeDocument->commandStack()->push(command);
3545 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3546 m_activeDocument->setModified(true);
3550 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3554 // Check if we already have a properties dialog opened for that clip
3555 QList <ClipProperties *> list = findChildren<ClipProperties *>();
3556 for (int i = 0; i < list.size(); ++i) {
3557 if (list.at(i)->clipId() == clip->getId()) {
3558 // We have one dialog, show it
3559 list.at(i)->raise();
3564 // any type of clip but a title
3565 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3567 if (clip->clipType() == AV || clip->clipType() == Video || clip->clipType() == Playlist || clip->clipType() == SlideShow) {
3568 // request clip thumbnails
3569 connect(m_activeDocument->clipManager(), SIGNAL(gotClipPropertyThumbnail(QString,QImage)), dia, SLOT(slotGotThumbnail(QString,QImage)));
3570 connect(dia, SIGNAL(requestThumb(QString,QList<int>)), m_activeDocument->clipManager(), SLOT(slotRequestThumbs(QString,QList<int>)));
3571 m_activeDocument->clipManager()->slotRequestThumbs(QString('?' + clip->getId()), QList<int>() << clip->getClipThumbFrame());
3574 connect(dia, SIGNAL(addMarkers(QString,QList<CommentedTime>)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(QString,QList<CommentedTime>)));
3575 connect(dia, SIGNAL(editAnalysis(QString,QString,QString)), m_activeTimeline->projectView(), SLOT(slotAddClipExtraData(QString,QString,QString)));
3576 connect(m_activeTimeline->projectView(), SIGNAL(updateClipMarkers(DocClipBase*)), dia, SLOT(slotFillMarkersList(DocClipBase*)));
3577 connect(m_activeTimeline->projectView(), SIGNAL(updateClipExtraData(DocClipBase*)), dia, SLOT(slotUpdateAnalysisData(DocClipBase*)));
3578 connect(m_projectList, SIGNAL(updateAnalysisData(DocClipBase*)), dia, SLOT(slotUpdateAnalysisData(DocClipBase*)));
3579 connect(dia, SIGNAL(loadMarkers(QString)), m_activeTimeline->projectView(), SLOT(slotLoadClipMarkers(QString)));
3580 connect(dia, SIGNAL(saveMarkers(QString)), m_activeTimeline->projectView(), SLOT(slotSaveClipMarkers(QString)));
3581 connect(dia, SIGNAL(deleteProxy(QString)), m_projectList, SLOT(slotDeleteProxy(QString)));
3582 connect(dia, SIGNAL(applyNewClipProperties(QString,QMap<QString,QString>,QMap<QString,QString>,bool,bool)), this, SLOT(slotApplyNewClipProperties(QString,QMap<QString,QString>,QMap<QString,QString>,bool,bool)));
3587 void MainWindow::slotApplyNewClipProperties(const QString &id, const QMap <QString, QString> &props, const QMap <QString, QString> &newprops, bool refresh, bool reload)
3589 if (newprops.isEmpty()) {
3593 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3594 m_activeDocument->commandStack()->push(command);
3595 m_activeDocument->setModified();
3598 // update clip occurences in timeline
3599 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3604 void MainWindow::slotShowClipProperties(const QList <DocClipBase *> &cliplist, const QMap<QString, QString> &commonproperties)
3606 QPointer<ClipProperties> dia = new ClipProperties(cliplist,
3607 m_activeDocument->timecode(), commonproperties, this);
3608 if (dia->exec() == QDialog::Accepted) {
3609 QUndoCommand *command = new QUndoCommand();
3610 command->setText(i18n("Edit clips"));
3611 QMap <QString, QString> newImageProps = dia->properties();
3612 // Transparency setting applies only for images
3613 QMap <QString, QString> newProps = newImageProps;
3614 newProps.remove("transparency");
3616 for (int i = 0; i < cliplist.count(); ++i) {
3617 DocClipBase *clip = cliplist.at(i);
3618 if (clip->clipType() == Image)
3619 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3621 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3623 m_activeDocument->commandStack()->push(command);
3624 for (int i = 0; i < cliplist.count(); ++i) {
3625 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia->needsTimelineReload());
3631 void MainWindow::customEvent(QEvent* e)
3633 if (e->type() == QEvent::User)
3634 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3637 void MainWindow::slotTimelineClipSelected(ClipItem* item, bool raise)
3639 if (item != m_mainClip) {
3641 m_mainClip->setMainSelectedClip(false);
3644 item->setMainSelectedClip(true);
3649 m_effectStack->slotClipItemSelected(item);
3650 m_projectMonitor->slotSetSelectedClip(item);
3652 m_effectStack->raiseWindow(m_effectStackDock);
3656 void MainWindow::slotTrackSelected(int index, const TrackInfo &info, bool raise)
3658 m_effectStack->slotTrackItemSelected(index, info);
3660 m_effectStack->raiseWindow(m_effectStackDock);
3664 void MainWindow::slotActivateTransitionView(Transition *transition)
3667 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3670 void MainWindow::slotSnapRewind()
3672 if (m_projectMonitor->isActive()) {
3673 if (m_activeTimeline) {
3674 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3677 m_clipMonitor->slotSeekToPreviousSnap();
3681 void MainWindow::slotSnapForward()
3683 if (m_projectMonitor->isActive()) {
3684 if (m_activeTimeline) {
3685 m_activeTimeline->projectView()->slotSeekToNextSnap();
3688 m_clipMonitor->slotSeekToNextSnap();
3692 void MainWindow::slotClipStart()
3694 if (m_projectMonitor->isActive()) {
3695 if (m_activeTimeline) {
3696 m_activeTimeline->projectView()->clipStart();
3701 void MainWindow::slotClipEnd()
3703 if (m_projectMonitor->isActive()) {
3704 if (m_activeTimeline) {
3705 m_activeTimeline->projectView()->clipEnd();
3710 void MainWindow::slotZoneStart()
3712 if (m_projectMonitor->isActive())
3713 m_projectMonitor->slotZoneStart();
3715 m_clipMonitor->slotZoneStart();
3718 void MainWindow::slotZoneEnd()
3720 if (m_projectMonitor->isActive())
3721 m_projectMonitor->slotZoneEnd();
3723 m_clipMonitor->slotZoneEnd();
3726 void MainWindow::slotChangeTool(QAction * action)
3728 if (action == m_buttonSelectTool)
3729 slotSetTool(SelectTool);
3730 else if (action == m_buttonRazorTool)
3731 slotSetTool(RazorTool);
3732 else if (action == m_buttonSpacerTool)
3733 slotSetTool(SpacerTool);
3736 void MainWindow::slotChangeEdit(QAction * action)
3738 if (!m_activeTimeline)
3741 if (action == m_overwriteEditTool)
3742 m_activeTimeline->projectView()->setEditMode(OverwriteEdit);
3743 else if (action == m_insertEditTool)
3744 m_activeTimeline->projectView()->setEditMode(InsertEdit);
3746 m_activeTimeline->projectView()->setEditMode(NormalEdit);
3749 void MainWindow::slotSetTool(ProjectTool tool)
3751 if (m_activeDocument && m_activeTimeline) {
3752 //m_activeDocument->setTool(tool);
3756 message = i18n("Ctrl + click to use spacer on current track only");
3759 message = i18n("Click on a clip to cut it");
3762 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3765 m_messageLabel->setMessage(message, InformationMessage);
3766 m_activeTimeline->projectView()->setTool(tool);
3770 void MainWindow::slotCopy()
3772 if (m_activeDocument && m_activeTimeline)
3773 m_activeTimeline->projectView()->copyClip();
3776 void MainWindow::slotPaste()
3778 if (m_activeDocument && m_activeTimeline)
3779 m_activeTimeline->projectView()->pasteClip();
3782 void MainWindow::slotPasteEffects()
3784 if (m_activeDocument && m_activeTimeline)
3785 m_activeTimeline->projectView()->pasteClipEffects();
3788 void MainWindow::slotFind()
3790 if (!m_activeDocument || !m_activeTimeline) {
3794 m_projectSearch->setEnabled(false);
3795 m_findActivated = true;
3796 m_findString.clear();
3797 m_activeTimeline->projectView()->initSearchStrings();
3798 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3799 m_findTimer.start(5000);
3800 qApp->installEventFilter(this);
3803 void MainWindow::slotFindNext()
3805 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
3806 statusBar()->showMessage(i18n("Found: %1", m_findString));
3808 statusBar()->showMessage(i18n("Reached end of project"));
3810 m_findTimer.start(4000);
3813 void MainWindow::findAhead()
3815 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3816 m_projectSearchNext->setEnabled(true);
3817 statusBar()->showMessage(i18n("Found: %1", m_findString));
3819 m_projectSearchNext->setEnabled(false);
3820 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3824 void MainWindow::findTimeout()
3826 m_projectSearchNext->setEnabled(false);
3827 m_findActivated = false;
3828 m_findString.clear();
3829 statusBar()->showMessage(i18n("Find stopped"), 3000);
3830 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3831 m_projectSearch->setEnabled(true);
3832 removeEventFilter(this);
3835 void MainWindow::slotClipInTimeline(const QString &clipId)
3837 if (m_activeTimeline && m_activeDocument) {
3838 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3840 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3841 inTimelineMenu->clear();
3843 QList <QAction *> actionList;
3845 for (int i = 0; i < matching.count(); ++i) {
3846 QString track = QString::number(matching.at(i).track);
3847 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3849 QAction *a = new QAction(track + ": " + start, this);
3850 a->setData(QStringList() << track << start);
3851 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3852 while (j < actionList.count()) {
3853 if (actionList.at(j)->text() > a->text()) break;
3856 actionList.insert(j, a);
3858 inTimelineMenu->addActions(actionList);
3860 if (matching.empty()) {
3861 inTimelineMenu->setEnabled(false);
3863 inTimelineMenu->setEnabled(true);
3868 void MainWindow::slotClipInProjectTree()
3870 if (m_activeTimeline) {
3871 QStringList clipIds;
3873 clipIds << m_mainClip->clipProducer();
3875 clipIds = m_activeTimeline->projectView()->selectedClips();
3877 if (clipIds.isEmpty()) {
3880 m_projectListDock->raise();
3881 m_projectList->selectItemById(clipIds.at(0));
3882 if (m_projectMonitor->isActive()) {
3883 slotSwitchMonitors();
3888 /*void MainWindow::slotClipToProjectTree()
3890 if (m_activeTimeline) {
3891 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3892 if (clips.isEmpty()) return;
3893 for (int i = 0; i < clips.count(); ++i) {
3894 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3896 //m_projectList->selectItemById(clipIds.at(i));
3900 void MainWindow::slotSelectClipInTimeline()
3902 if (m_activeTimeline) {
3903 QAction *action = qobject_cast<QAction *>(sender());
3904 QStringList data = action->data().toStringList();
3905 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3909 void MainWindow::keyPressEvent(QKeyEvent *ke)
3911 if (m_findActivated) {
3912 if (ke->key() == Qt::Key_Backspace) {
3913 m_findString = m_findString.left(m_findString.length() - 1);
3915 if (!m_findString.isEmpty()) {
3921 m_findTimer.start(4000);
3924 } else if (ke->key() == Qt::Key_Escape) {
3928 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3929 m_findString += ke->text();
3933 m_findTimer.start(4000);
3938 KXmlGuiWindow::keyPressEvent(ke);
3943 /** Gets called when the window gets hidden */
3944 void MainWindow::hideEvent(QHideEvent */*event*/)
3946 if (isMinimized() && m_monitorManager)
3947 m_monitorManager->stopActiveMonitor();
3950 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3952 if (m_findActivated) {
3953 if (event->type() == QEvent::ShortcutOverride) {
3954 QKeyEvent* ke = (QKeyEvent*) event;
3955 if (ke->text().trimmed().isEmpty()) return false;
3962 // pass the event on to the parent class
3963 return QMainWindow::eventFilter(obj, event);
3968 void MainWindow::slotSaveZone(Render *render, const QPoint &zone, DocClipBase *baseClip, KUrl path)
3970 KDialog *dialog = new KDialog(this);
3971 dialog->setCaption("Save clip zone");
3972 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3974 QWidget *widget = new QWidget(dialog);
3975 dialog->setMainWidget(widget);
3977 QVBoxLayout *vbox = new QVBoxLayout(widget);
3978 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3979 if (path.isEmpty()) {
3980 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3981 if (baseClip == NULL) {
3982 tmppath.append("untitled.mlt");
3984 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + '-' + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3986 path = KUrl(tmppath);
3988 KUrlRequester *url = new KUrlRequester(path, this);
3989 url->setFilter("video/mlt-playlist");
3990 QLabel *label2 = new QLabel(i18n("Description:"), this);
3991 KLineEdit *edit = new KLineEdit(this);
3992 vbox->addWidget(label1);
3993 vbox->addWidget(url);
3994 vbox->addWidget(label2);
3995 vbox->addWidget(edit);
3996 if (dialog->exec() == QDialog::Accepted) {
3997 if (QFile::exists(url->url().path())) {
3998 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3999 slotSaveZone(render, zone, baseClip, url->url());
4004 if (baseClip && !baseClip->fileURL().isEmpty()) {
4005 // create zone from clip url, so that we don't have problems with proxy clips
4007 #if QT_VERSION >= 0x040600
4008 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
4009 env.remove("MLT_PROFILE");
4010 p.setProcessEnvironment(env);
4012 QStringList env = QProcess::systemEnvironment();
4013 env << "MLT_PROFILE='\0'";
4014 p.setEnvironment(env);
4016 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
4017 if (!p.waitForStarted(3000)) {
4018 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
4020 else if (!p.waitForFinished(5000)) {
4021 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
4024 else render->saveZone(url->url(), edit->text(), zone);
4030 void MainWindow::slotSetInPoint()
4032 if (m_clipMonitor->isActive()) {
4033 m_clipMonitor->slotSetZoneStart();
4035 m_projectMonitor->slotSetZoneStart();
4039 void MainWindow::slotSetOutPoint()
4041 if (m_clipMonitor->isActive()) {
4042 m_clipMonitor->slotSetZoneEnd();
4044 m_projectMonitor->slotSetZoneEnd();
4048 void MainWindow::slotResizeItemStart()
4050 if (m_activeTimeline)
4051 m_activeTimeline->projectView()->setInPoint();
4054 void MainWindow::slotResizeItemEnd()
4056 if (m_activeTimeline)
4057 m_activeTimeline->projectView()->setOutPoint();
4060 int MainWindow::getNewStuff(const QString &configFile)
4062 KNS3::Entry::List entries;
4063 #if KDE_IS_VERSION(4,3,80)
4064 QPointer<KNS3::DownloadDialog> dialog = new KNS3::DownloadDialog(configFile);
4065 if (dialog->exec()) entries = dialog->changedEntries();
4066 foreach(const KNS3::Entry & entry, entries) {
4067 if (entry.status() == KNS3::Entry::Installed)
4068 kDebug() << "// Installed files: " << entry.installedFiles();
4072 KNS::Engine engine(0);
4073 if (engine.init(configFile))
4074 entries = engine.downloadDialogModal(this);
4075 foreach(KNS::Entry * entry, entries) {
4076 if (entry->status() == KNS::Entry::Installed)
4077 kDebug() << "// Installed files: " << entry->installedFiles();
4080 return entries.size();
4083 void MainWindow::slotGetNewTitleStuff()
4085 if (getNewStuff("kdenlive_titles.knsrc") > 0)
4086 TitleWidget::refreshTitleTemplates();
4089 void MainWindow::slotGetNewLumaStuff()
4091 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
4092 initEffects::refreshLumas();
4093 m_activeTimeline->projectView()->reloadTransitionLumas();
4097 void MainWindow::slotGetNewRenderStuff()
4099 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
4101 m_renderWidget->reloadProfiles();
4104 void MainWindow::slotGetNewMltProfileStuff()
4106 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
4107 // update the list of profiles in settings dialog
4108 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
4114 void MainWindow::slotAutoTransition()
4116 if (m_activeTimeline)
4117 m_activeTimeline->projectView()->autoTransition();
4120 void MainWindow::slotSplitAudio()
4122 if (m_activeTimeline)
4123 m_activeTimeline->projectView()->splitAudio();
4126 void MainWindow::slotSetAudioAlignReference()
4128 if (m_activeTimeline) {
4129 m_activeTimeline->projectView()->setAudioAlignReference();
4133 void MainWindow::slotAlignAudio()
4135 if (m_activeTimeline) {
4136 m_activeTimeline->projectView()->alignAudio();
4140 void MainWindow::slotUpdateClipType(QAction *action)
4142 if (m_activeTimeline) {
4143 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
4144 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
4145 else m_activeTimeline->projectView()->setAudioAndVideo();
4149 void MainWindow::slotDvdWizard(const QString &url)
4151 // We must stop the monitors since we create a new on in the dvd wizard
4152 m_monitorManager->activateMonitor(Kdenlive::DvdMonitor);
4153 QPointer<DvdWizard> w = new DvdWizard(m_monitorManager, url, this);
4156 m_monitorManager->activateMonitor(Kdenlive::ClipMonitor);
4159 void MainWindow::slotShowTimeline(bool show)
4161 if (show == false) {
4162 m_timelineState = saveState();
4163 centralWidget()->setHidden(true);
4165 centralWidget()->setHidden(false);
4166 restoreState(m_timelineState);
4170 void MainWindow::slotMaximizeCurrent(bool)
4172 //TODO: is there a way to maximize current widget?
4174 m_timelineState = saveState();
4175 QWidget *par = focusWidget()->parentWidget();
4176 while (par->parentWidget() && par->parentWidget() != this)
4177 par = par->parentWidget();
4178 kDebug() << "CURRENT WIDGET: " << par->objectName();
4181 void MainWindow::loadClipActions()
4183 QMenu* actionMenu= static_cast<QMenu*>(factory()->container("clip_actions", this));
4185 actionMenu->clear();
4186 Mlt::Profile profile;
4187 Mlt::Filter *filter = Mlt::Factory::filter(profile,(char*)"videostab");
4189 if (!filter->is_valid()) {
4194 QAction *action=actionMenu->addAction(i18n("Stabilize (vstab)"));
4195 action->setData("videostab");
4196 connect(action,SIGNAL(triggered()), this, SLOT(slotStartClipAction()));
4199 filter = Mlt::Factory::filter(profile,(char*)"videostab2");
4201 if (!filter->is_valid()) {
4206 QAction *action=actionMenu->addAction(i18n("Stabilize (transcode)"));
4207 action->setData("videostab2");
4208 connect(action,SIGNAL(triggered()), this, SLOT(slotStartClipAction()));
4211 filter = Mlt::Factory::filter(profile,(char*)"motion_est");
4213 if (!filter->is_valid()) {
4218 QAction *action=actionMenu->addAction(i18n("Automatic scene split"));
4219 action->setData("motion_est");
4220 connect(action,SIGNAL(triggered()), this, SLOT(slotStartClipAction()));
4223 if (KdenliveSettings::producerslist().contains("framebuffer")) {
4224 QAction *action=actionMenu->addAction(i18n("Reverse clip"));
4225 action->setData("framebuffer");
4226 connect(action,SIGNAL(triggered()), this, SLOT(slotStartClipAction()));
4232 void MainWindow::loadTranscoders()
4234 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
4237 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
4238 extractAudioMenu->clear();
4240 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc", KConfig::CascadeConfig);
4241 KConfigGroup transConfig(config, "Transcoding");
4243 QMap< QString, QString > profiles = transConfig.entryMap();
4244 QMapIterator<QString, QString> i(profiles);
4245 while (i.hasNext()) {
4247 QStringList data = i.value().split(';');
4249 // separate audio transcoding in a separate menu
4250 if (data.count() > 2 && data.at(2) == "audio") {
4251 a = extractAudioMenu->addAction(i.key());
4254 a = transMenu->addAction(i.key());
4257 if (data.count() > 1) a->setToolTip(data.at(1));
4258 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
4262 void MainWindow::slotStartClipAction()
4264 QString condition,filtername;
4267 // Stablize selected clips
4268 QAction *action = qobject_cast<QAction *>(sender());
4270 filtername=action->data().toString();
4272 m_projectList->startClipFilterJob(filtername, condition);
4275 void MainWindow::slotTranscode(const KUrl::List &urls)
4280 if (urls.isEmpty()) {
4281 QAction *action = qobject_cast<QAction *>(sender());
4282 QStringList data = action->data().toStringList();
4283 params = data.at(0);
4284 if (data.count() > 1)
4286 if (data.count() > 3)
4287 condition = data.at(3);
4288 m_projectList->slotTranscodeClipJob(condition, params, desc);
4291 if (urls.isEmpty()) {
4292 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
4295 ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc);
4296 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
4300 void MainWindow::slotTranscodeClip()
4302 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
4303 if (urls.isEmpty()) return;
4304 slotTranscode(urls);
4307 void MainWindow::slotSetDocumentRenderProfile(const QMap <QString, QString> &props)
4309 if (m_activeDocument == NULL) return;
4310 QMapIterator<QString, QString> i(props);
4311 while (i.hasNext()) {
4313 m_activeDocument->setDocumentProperty(i.key(), i.value());
4315 m_activeDocument->setModified(true);
4319 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
4321 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
4323 QString playlistPath;
4325 //QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
4326 QString path = m_renderWidget->getFreeScriptName(m_activeDocument->url());
4327 QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(path, i18n("Create Render Script"), this);
4328 getUrl->fileDialog()->setMode(KFile::File);
4329 getUrl->fileDialog()->setOperationMode(KFileDialog::Saving);
4330 if (getUrl->exec() == QDialog::Rejected) {
4334 scriptPath = getUrl->selectedUrl().path();
4336 QFile f(scriptPath);
4338 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
4341 playlistPath = scriptPath + ".mlt";
4343 KTemporaryFile temp;
4344 temp.setAutoRemove(false);
4345 temp.setSuffix(".mlt");
4347 playlistPath = temp.fileName();
4349 QString playlistContent = m_projectMonitor->sceneList();
4350 if (!chapterFile.isEmpty()) {
4353 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
4355 in = m_activeTimeline->inPoint();
4356 out = m_activeTimeline->outPoint();
4359 QDomElement chapters = doc.createElement("chapters");
4360 chapters.setAttribute("fps", m_activeDocument->fps());
4361 doc.appendChild(chapters);
4363 QDomElement guidesxml = m_activeDocument->guidesXml();
4364 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
4365 for (int i = 0; i < nodes.count(); ++i) {
4366 QDomElement e = nodes.item(i).toElement();
4368 QString comment = e.attribute("comment");
4369 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
4370 if (time >= in && time < out) {
4371 if (zoneOnly) time = time - in;
4372 QDomElement chapter = doc.createElement("chapter");
4373 chapters.appendChild(chapter);
4374 chapter.setAttribute("title", comment);
4375 chapter.setAttribute("time", time);
4379 if (chapters.childNodes().count() > 0) {
4380 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
4381 // Always insert a guide in pos 0
4382 QDomElement chapter = doc.createElement("chapter");
4383 chapters.insertBefore(chapter, QDomNode());
4384 chapter.setAttribute("title", i18nc("the first in a list of chapters", "Start"));
4385 chapter.setAttribute("time", "0");
4387 // save chapters file
4388 QFile file(chapterFile);
4389 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4390 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4392 file.write(doc.toString().toUtf8());
4393 if (file.error() != QFile::NoError) {
4394 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4401 if (m_renderWidget->automaticAudioExport()) {
4402 exportAudio = m_activeTimeline->checkProjectAudio();
4403 } else exportAudio = m_renderWidget->selectedAudioExport();
4405 // Set playlist audio volume to 100%
4407 doc.setContent(playlistContent);
4408 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4409 if (!tractor.isNull()) {
4410 QDomNodeList props = tractor.elementsByTagName("property");
4411 for (int i = 0; i < props.count(); ++i) {
4412 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4413 props.at(i).firstChild().setNodeValue("1");
4419 // Do we want proxy rendering
4420 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4421 QString root = doc.documentElement().attribute("root");
4423 // replace proxy clips with originals
4424 QMap <QString, QString> proxies = m_projectList->getProxies();
4426 QDomNodeList producers = doc.elementsByTagName("producer");
4427 QString producerResource;
4429 for (uint n = 0; n < producers.length(); n++) {
4430 QDomElement e = producers.item(n).toElement();
4431 producerResource = EffectsList::property(e, "resource");
4432 if (producerResource.isEmpty()) continue;
4433 if (!producerResource.startsWith('/')) {
4434 producerResource.prepend(root + '/');
4436 if (producerResource.contains('?')) {
4437 // slowmotion producer
4438 suffix = '?' + producerResource.section('?', 1);
4439 producerResource = producerResource.section('?', 0, 0);
4441 else suffix.clear();
4442 if (!producerResource.isEmpty()) {
4443 if (proxies.contains(producerResource)) {
4444 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4445 // We need to delete the "aspect_ratio" property because proxy clips
4446 // sometimes have different ratio than original clips
4447 EffectsList::removeProperty(e, "aspect_ratio");
4448 EffectsList::removeMetaProperties(e);
4453 /*QMapIterator<QString, QString> i(proxies);
4454 while (i.hasNext()) {
4456 // Replace all keys with their values (proxy path with original path)
4457 QString key = i.key();
4458 playlistContent.replace(key, i.value());
4459 if (!root.isEmpty() && key.startsWith(root)) {
4460 // in case the resource path in MLT playlist is relative
4461 key.remove(0, root.count() + 1);
4462 playlistContent.replace(key, i.value());
4466 playlistContent = doc.toString();
4468 // Do save scenelist
4469 QFile file(playlistPath);
4470 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4471 m_messageLabel->setMessage(i18n("Cannot write to file %1", playlistPath), ErrorMessage);
4474 file.write(playlistContent.toUtf8());
4475 if (file.error() != QFile::NoError) {
4476 m_messageLabel->setMessage(i18n("Cannot write to file %1", playlistPath), ErrorMessage);
4481 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4484 void MainWindow::slotUpdateTimecodeFormat(int ix)
4486 KdenliveSettings::setFrametimecode(ix == 1);
4487 m_clipMonitor->updateTimecodeFormat();
4488 m_projectMonitor->updateTimecodeFormat();
4489 m_transitionConfig->updateTimecodeFormat();
4490 m_effectStack->updateTimecodeFormat();
4491 //m_activeTimeline->projectView()->clearSelection();
4492 m_activeTimeline->updateRuler();
4493 slotUpdateMousePosition(m_activeTimeline->projectView()->getMousePos());
4496 void MainWindow::slotRemoveFocus()
4498 statusBar()->setFocus();
4499 statusBar()->clearFocus();
4502 void MainWindow::slotRevert()
4504 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;
4505 KUrl url = m_activeDocument->url();
4506 if (closeCurrentDocument(false))
4507 doOpenFile(url, NULL);
4511 void MainWindow::slotShutdown()
4513 if (m_activeDocument) m_activeDocument->setModified(false);
4515 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4516 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4517 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4518 smserver.call("logout", 1, 2, 2);
4519 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4520 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4521 smserver.call("Shutdown");
4525 void MainWindow::slotUpdateTrackInfo()
4527 if (m_activeDocument)
4528 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4531 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4533 // Load the theme file
4535 if (action == NULL) theme = themename;
4536 else theme = action->data().toString();
4537 KdenliveSettings::setColortheme(theme);
4538 // Make palette for all widgets.
4539 QPalette plt = kapp->palette();
4540 if (theme.isEmpty()) {
4541 plt = QApplication::desktop()->palette();
4543 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4545 #if KDE_IS_VERSION(4,6,3)
4546 plt = KGlobalSettings::createNewApplicationPalette(config);
4548 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4549 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4550 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4551 QPalette::Disabled };
4552 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4553 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4555 for ( int i = 0; i < 3 ; ++i ) {
4556 QPalette::ColorGroup state = states[i];
4557 KColorScheme schemeView(state, KColorScheme::View, config);
4558 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4559 KColorScheme schemeButton(state, KColorScheme::Button, config);
4560 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4562 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4563 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4564 plt.setBrush( state, QPalette::Base, schemeView.background() );
4565 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4566 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4567 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4568 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4569 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4570 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4571 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4573 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4574 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4575 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4576 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4577 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4579 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4580 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4581 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4586 kapp->setPalette(plt);
4587 slotChangePalette();
4588 const QObjectList children = statusBar()->children();
4590 foreach(QObject * child, children) {
4591 if (child->isWidgetType())
4592 ((QWidget*)child)->setPalette(plt);
4593 const QObjectList subchildren = child->children();
4594 foreach(QObject * subchild, subchildren) {
4595 if (subchild->isWidgetType())
4596 ((QWidget*)subchild)->setPalette(plt);
4602 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4604 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4605 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4606 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4607 const QSize bitsSize(24, 2);
4608 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4609 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4611 QPixmap pixmap(23, 16);
4612 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4614 KConfigGroup group(config, "WM");
4615 QPainter p(&pixmap);
4616 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4617 p.fillRect(1, 1, 7, 7, windowScheme.background());
4618 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4620 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4621 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4622 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4624 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4625 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4627 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4628 p.fillRect(1, 8, 7, 7, viewScheme.background());
4629 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4631 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4632 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4633 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4635 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4636 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4642 void MainWindow::slotSwitchMonitors()
4644 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4645 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4646 else m_projectList->focusTree();
4649 void MainWindow::slotInsertZoneToTree()
4651 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4652 QStringList info = m_clipMonitor->getZoneInfo();
4653 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4656 void MainWindow::slotInsertZoneToTimeline()
4658 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4659 QStringList info = m_clipMonitor->getZoneInfo();
4660 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4664 void MainWindow::slotDeleteProjectClips(const QStringList &ids, const QMap<QString, QString> &folderids)
4666 if (m_activeDocument && m_activeTimeline) {
4667 if (!ids.isEmpty()) {
4668 for (int i = 0; i < ids.size(); ++i) {
4669 m_activeTimeline->slotDeleteClip(ids.at(i));
4671 m_activeDocument->clipManager()->slotDeleteClips(ids);
4673 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4674 m_activeDocument->setModified(true);
4678 void MainWindow::slotShowTitleBars(bool show)
4680 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4681 for (int i = 0; i < docks.count(); ++i) {
4682 QDockWidget* dock = docks.at(i);
4684 dock->setTitleBarWidget(0);
4686 if (!dock->isFloating()) {
4687 dock->setTitleBarWidget(new QWidget);
4691 KdenliveSettings::setShowtitlebars(show);
4694 void MainWindow::slotSwitchTitles()
4696 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4699 QString MainWindow::getMimeType(bool open)
4701 QString mimetype = "application/x-kdenlive";
4702 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4704 mimetype = "*.kdenlive";
4705 if (open) mimetype.append(" *.tar.gz");
4707 else if (open) mimetype.append(" application/x-compressed-tar");
4711 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4714 m_projectMonitor->render->sendFrameForAnalysis = true;
4717 for (int i = 0; i < m_gfxScopesList.count(); ++i) {
4718 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4725 qDebug() << "Any scope accepting new frames? " << request;
4728 m_projectMonitor->render->sendFrameForAnalysis = false;
4733 void MainWindow::slotOpenStopmotion()
4735 if (m_stopmotion == NULL) {
4736 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4737 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(QString)), m_projectList, SLOT(slotAddOrUpdateSequence(QString)));
4738 //for (int i = 0; i < m_gfxScopesList.count(); ++i) {
4739 // Check if we need the renderer to send a new frame for update
4740 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4741 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4742 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4745 m_stopmotion->show();
4748 void MainWindow::slotDeleteClip(const QString &id)
4750 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4751 for (int i = 0; i < list.size(); ++i) {
4752 list.at(i)->disableClipId(id);
4754 m_projectList->slotDeleteClip(id);
4757 void MainWindow::slotUpdateProxySettings()
4759 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4760 if (KdenliveSettings::enableproxy())
4761 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4762 m_projectList->updateProxyConfig();
4765 void MainWindow::slotInsertNotesTimecode()
4767 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4768 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4769 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4772 void MainWindow::slotArchiveProject()
4774 QList <DocClipBase*> list = m_projectList->documentClipList();
4775 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4776 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4778 m_messageLabel->setMessage(i18n("Archiving project"), OperationCompletedMessage);
4783 void MainWindow::slotOpenBackupDialog(const KUrl &url)
4788 kDebug()<<"// BACKUP URL: "<<url.path();
4789 if (!url.isEmpty()) {
4790 // we could not open the project file, guess where the backups are
4791 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4795 projectFolder = m_activeDocument->projectFolder();
4796 projectFile = m_activeDocument->url();
4797 projectId = m_activeDocument->getDocumentProperty("documentid");
4800 QPointer<BackupWidget> dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4801 if (dia->exec() == QDialog::Accepted) {
4802 QString requestedBackup = dia->selectedFile();
4803 m_activeDocument->backupLastSavedVersion(projectFile.path());
4804 closeCurrentDocument(false);
4805 doOpenFile(KUrl(requestedBackup), NULL);
4806 m_activeDocument->setUrl(projectFile);
4807 m_activeDocument->setModified(true);
4808 setCaption(m_activeDocument->description());
4813 void MainWindow::slotElapsedTime()
4815 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4819 void MainWindow::slotDownloadResources()
4821 QString currentFolder;
4822 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4823 else currentFolder = KdenliveSettings::defaultprojectfolder();
4824 ResourceWidget *d = new ResourceWidget(currentFolder);
4825 connect(d, SIGNAL(addClip(KUrl,stringMap)), this, SLOT(slotAddProjectClip(KUrl,stringMap)));
4829 void MainWindow::slotChangePalette()
4831 QPalette plt = QApplication::palette();
4832 if (m_effectStack) m_effectStack->updatePalette();
4833 if (m_projectList) m_projectList->updatePalette();
4834 if (m_effectList) m_effectList->updatePalette();
4836 if (m_clipMonitor) m_clipMonitor->setPalette(plt);
4837 if (m_projectMonitor) m_projectMonitor->setPalette(plt);
4839 setStatusBarStyleSheet(plt);
4840 if (m_activeTimeline) {
4841 m_activeTimeline->updatePalette();
4845 void MainWindow::slotSaveTimelineClip()
4847 if (m_activeTimeline && m_projectMonitor->render) {
4848 ClipItem *clip = m_activeTimeline->projectView()->getActiveClipUnderCursor(true);
4850 m_messageLabel->setMessage(i18n("Select a clip to save"), InformationMessage);
4853 KUrl url = KFileDialog::getSaveUrl(m_activeDocument->projectFolder(), "video/mlt-playlist");
4854 if (!url.isEmpty()) m_projectMonitor->render->saveClip(m_activeDocument->tracksCount() - clip->track(), clip->startPos(), url);
4858 void MainWindow::slotProcessImportKeyframes(GraphicsRectItem type, const QString& data, int maximum)
4860 if (type == AVWidget) {
4861 // This data should be sent to the effect stack
4862 m_effectStack->setKeyframes(data, maximum);
4864 else if (type == TransitionWidget) {
4865 // This data should be sent to the transition stack
4866 m_transitionConfig->setKeyframes(data, maximum);
4873 void MainWindow::slotAlignPlayheadToMousePos()
4875 m_monitorManager->activateMonitor(Kdenlive::ProjectMonitor);
4876 m_activeTimeline->projectView()->slotAlignPlayheadToMousePos();
4879 void MainWindow::slotSetDeinterlacer(int ix)
4885 value = "linearblend";
4888 value = "yadif-nospatial";
4896 KdenliveSettings::setMltdeinterlacer(value);
4897 m_monitorManager->setConsumerProperty("deinterlace_method", value);
4900 void MainWindow::slotSetInterpolation(int ix)
4916 KdenliveSettings::setMltinterpolation(value);
4917 m_monitorManager->setConsumerProperty("rescale", value);
4920 #include "mainwindow.moc"