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 "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 "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 "archivewidget.h"
66 #include "databackup/backupwidget.h"
67 #include "utils/resourcewidget.h"
70 #include <KApplication>
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>
120 // Uncomment for deeper debugging
121 //#define DEBUG_MAINW
127 static const char version[] = VERSION;
129 static const int ID_TIMELINE_POS = 0;
135 Q_DECLARE_METATYPE(QVector<int16_t>)
138 EffectsList MainWindow::videoEffects;
139 EffectsList MainWindow::audioEffects;
140 EffectsList MainWindow::customEffects;
141 EffectsList MainWindow::transitions;
143 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
144 KXmlGuiWindow(parent),
145 m_activeDocument(NULL),
146 m_activeTimeline(NULL),
151 m_projectMonitor(NULL),
153 m_renderWidget(NULL),
154 #ifdef USE_JOGSHUTTLE
158 m_findActivated(false),
161 qRegisterMetaType<QVector<int16_t> > ();
162 qRegisterMetaType<stringMap> ("stringMap");
163 qRegisterMetaType<audioByteArray> ("audioByteArray");
166 QLocale systemLocale = QLocale();
167 setlocale(LC_NUMERIC, NULL);
168 char *separator = localeconv()->decimal_point;
169 if (separator != systemLocale.decimalPoint()) {
170 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
171 // HACK: There is a locale conflict, so set locale to at least have correct decimal point
172 if (strncmp(separator, ".", 1) == 0) systemLocale = QLocale::c();
173 else if (strncmp(separator, ",", 1) == 0) systemLocale = QLocale("fr_FR.UTF-8");
176 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
177 QLocale::setDefault(systemLocale);
179 // Create DBus interface
180 new MainWindowAdaptor(this);
181 QDBusConnection dbus = QDBusConnection::sessionBus();
182 dbus.registerObject("/MainWindow", this);
184 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
185 setFont(KGlobalSettings::toolBarFont());
186 parseProfiles(MltPath);
187 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
188 m_commandStack = new QUndoGroup;
189 setDockNestingEnabled(true);
190 m_timelineArea = new KTabWidget(this);
191 m_timelineArea->setTabReorderingEnabled(true);
192 m_timelineArea->setTabBarHidden(true);
193 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
194 m_timelineArea->setMinimumHeight(200);
196 QToolButton *closeTabButton = new QToolButton;
197 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
198 closeTabButton->setIcon(KIcon("tab-close"));
199 closeTabButton->adjustSize();
200 closeTabButton->setToolTip(i18n("Close the current tab"));
201 m_timelineArea->setCornerWidget(closeTabButton);
202 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
204 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
205 m_findTimer.setSingleShot(true);
207 // FIXME: the next call returns a newly allocated object, which leaks
208 initEffects::parseEffectFiles();
209 //initEffects::parseCustomEffectsFile();
211 m_monitorManager = new MonitorManager();
213 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
214 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
219 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
220 m_projectListDock->setObjectName("project_tree");
221 m_projectList = new ProjectList();
222 m_projectListDock->setWidget(m_projectList);
223 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
225 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
226 m_clipMonitorDock->setObjectName("clip_monitor");
227 m_clipMonitor = new Monitor(Kdenlive::clipMonitor, m_monitorManager, QString(), m_timelineArea);
228 m_clipMonitorDock->setWidget(m_clipMonitor);
230 // Connect the project list
231 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
232 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(slotActivateMonitor()));
233 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
234 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
235 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
236 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
237 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
238 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
239 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
240 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
241 connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
243 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
244 m_projectMonitorDock->setObjectName("project_monitor");
245 m_projectMonitor = new Monitor(Kdenlive::projectMonitor, m_monitorManager, QString());
246 m_projectMonitorDock->setWidget(m_projectMonitor);
249 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
250 m_recMonitorDock->setObjectName("record_monitor");
251 m_recMonitor = new RecMonitor(Kdenlive::recordMonitor, m_monitorManager);
252 m_recMonitorDock->setWidget(m_recMonitor);
253 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
254 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
255 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
257 #endif /* ! Q_WS_MAC */
258 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
260 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
261 m_notesDock->setObjectName("notes_widget");
262 m_notesWidget = new NotesWidget();
263 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
264 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
266 m_notesWidget->setTabChangesFocus(true);
267 #if KDE_IS_VERSION(4,4,0)
268 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
270 m_notesDock->setWidget(m_notesWidget);
271 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
273 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
274 m_effectStackDock->setObjectName("effect_stack");
275 m_effectStack = new EffectStackView2(m_projectMonitor);
276 m_effectStackDock->setWidget(m_effectStack);
277 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
278 connect(m_effectStack, SIGNAL(startFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&)), m_projectList, SLOT(slotStartFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QString&,const QString&)));
280 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
281 m_transitionConfigDock->setObjectName("transition");
282 m_transitionConfig = new TransitionSettings(m_projectMonitor);
283 m_transitionConfigDock->setWidget(m_transitionConfig);
284 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
286 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
287 m_effectListDock->setObjectName("effect_list");
288 m_effectList = new EffectsListView();
289 m_effectListDock->setWidget(m_effectList);
290 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
292 m_scopeManager = new ScopeManager(m_monitorManager);
293 m_vectorscope = new Vectorscope();
294 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
295 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
296 m_vectorscopeDock->setWidget(m_vectorscope);
297 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
298 m_scopeManager->addScope(m_vectorscope, m_vectorscopeDock);
300 m_waveform = new Waveform();
301 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
302 m_waveformDock->setObjectName(m_waveform->widgetName());
303 m_waveformDock->setWidget(m_waveform);
304 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
305 m_scopeManager->addScope(m_waveform, m_waveformDock);
307 m_RGBParade = new RGBParade();
308 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
309 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
310 m_RGBParadeDock->setWidget(m_RGBParade);
311 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
312 m_scopeManager->addScope(m_RGBParade, m_RGBParadeDock);
314 m_histogram = new Histogram();
315 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
316 m_histogramDock->setObjectName(m_histogram->widgetName());
317 m_histogramDock->setWidget(m_histogram);
318 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
319 m_scopeManager->addScope(m_histogram, m_histogramDock);
321 m_audiosignal = new AudioSignal;
322 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
323 m_audiosignalDock->setObjectName("audiosignal");
324 m_audiosignalDock->setWidget(m_audiosignal);
325 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
326 m_scopeManager->addScope(m_audiosignal, m_audiosignalDock);
328 m_audioSpectrum = new AudioSpectrum();
329 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
330 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
331 m_audioSpectrumDock->setWidget(m_audioSpectrum);
332 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
333 m_scopeManager->addScope(m_audioSpectrum, m_audioSpectrumDock);
335 m_spectrogram = new Spectrogram();
336 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
337 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
338 m_spectrogramDock->setWidget(m_spectrogram);
339 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
340 m_scopeManager->addScope(m_spectrogram, m_spectrogramDock);
342 // Add monitors here to keep them at the right of the window
343 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
344 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
346 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
349 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
350 m_undoViewDock->setObjectName("undo_history");
351 m_undoView = new QUndoView();
352 m_undoView->setCleanIcon(KIcon("edit-clear"));
353 m_undoView->setEmptyLabel(i18n("Clean"));
354 m_undoViewDock->setWidget(m_undoView);
355 m_undoView->setGroup(m_commandStack);
356 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
360 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
363 // Close non-general docks for the initial layout
364 // only show important ones
365 m_histogramDock->close();
366 m_RGBParadeDock->close();
367 m_waveformDock->close();
368 m_vectorscopeDock->close();
370 m_audioSpectrumDock->close();
371 m_spectrogramDock->close();
372 m_audiosignalDock->close();
374 m_undoViewDock->close();
378 /// Tabify Widgets ///
379 tabifyDockWidget(m_effectListDock, m_effectStackDock);
380 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
381 tabifyDockWidget(m_projectListDock, m_notesDock);
383 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
385 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
387 setCentralWidget(m_timelineArea);
389 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
391 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
392 m_fileRevert->setEnabled(false);
394 // Prepare layout actions
395 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
396 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
397 for (int i = 1; i < 5; i++) {
398 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
399 load->setData("_" + QString::number(i));
400 layoutActions->addAction("load_layout" + QString::number(i), load);
401 m_loadLayout->addAction(load);
402 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
403 save->setData("_" + QString::number(i));
404 layoutActions->addAction("save_layout" + QString::number(i), save);
406 layoutActions->addAction("load_layouts", m_loadLayout);
407 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
410 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
411 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
412 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
413 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
414 m_stopmotion_actions->addAction("stopmotion_capture", action);
415 action = new KAction(i18n("Switch live / captured frame"), this);
416 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
417 m_stopmotion_actions->addAction("stopmotion_switch", action);
418 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
419 action->setCheckable(true);
420 action->setChecked(false);
421 m_stopmotion_actions->addAction("stopmotion_overlay", action);
423 // Build effects menu
424 m_effectsMenu = new QMenu(i18n("Add Effect"));
425 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
426 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
427 m_effectsActionCollection->readSettings();
431 // Find QDockWidget tab bars and show / hide widget title bars on right click
432 QList <QTabBar *> tabs = findChildren<QTabBar *>();
433 for (int i = 0; i < tabs.count(); i++) {
434 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
435 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
438 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
439 guiFactory()->addClient(sp);*/
440 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
441 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
444 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
446 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
449 // Load layout names from config file
456 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
457 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
459 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
460 clipInTimeline->setIcon(KIcon("go-jump"));
461 QHash<QString,QMenu*> menus;
462 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
463 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
464 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
465 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
466 menus.insert("inTimelineMenu",clipInTimeline);
467 m_projectList->setupGeneratorMenu(menus);
469 // build themes menus
470 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
471 QActionGroup *themegroup = new QActionGroup(this);
472 themegroup->setExclusive(true);
473 action = new KAction(i18n("Default"), this);
474 action->setCheckable(true);
475 themegroup->addAction(action);
476 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
478 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
480 for (int i = 0; i < schemeFiles.size(); ++i) {
482 const QString filename = schemeFiles.at(i);
483 const QFileInfo info(filename);
486 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
487 QIcon icon = createSchemePreviewIcon(config);
488 KConfigGroup group(config, "General");
489 const QString name = group.readEntry("Name", info.baseName());
490 action = new KAction(name, this);
491 action->setData(filename);
492 action->setIcon(icon);
493 action->setCheckable(true);
494 themegroup->addAction(action);
495 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
498 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
499 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
500 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
503 action = new QAction(fi.fileName(), this);
504 action->setData(*it);
505 action->setCheckable(true);
506 themegroup->addAction(action);
507 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
509 themesMenu->addActions(themegroup->actions());
510 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
512 // Setup and fill effects and transitions menus.
515 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
516 m->addActions(m_effectsMenu->actions());
519 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
520 for (int i = 0; i < transitions.count(); ++i)
521 m_transitionsMenu->addAction(m_transitions[i]);
523 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
524 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
525 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
527 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
528 const QList<QAction *> viewActions = createPopupMenu()->actions();
529 viewMenu->insertActions(NULL, viewActions);
531 m_timelineContextMenu = new QMenu(this);
532 m_timelineContextClipMenu = new QMenu(this);
533 m_timelineContextTransitionMenu = new QMenu(this);
535 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
536 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
537 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
539 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
540 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
541 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
542 m_timelineContextClipMenu->addSeparator();
543 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
544 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
545 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
546 m_timelineContextClipMenu->addSeparator();
547 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
548 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
549 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
550 m_timelineContextClipMenu->addSeparator();
552 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
553 m_timelineContextClipMenu->addMenu(markersMenu);
554 m_timelineContextClipMenu->addSeparator();
555 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
556 m_timelineContextClipMenu->addMenu(m_effectsMenu);
558 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
559 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
561 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
563 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
564 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
565 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
566 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
568 slotConnectMonitors();
570 // Open or create a file. Command line argument passed in Url has
571 // precedence, then "openlastproject", then just a plain empty file.
572 // If opening Url fails, openlastproject will _not_ be used.
573 if (!Url.isEmpty()) {
574 // delay loading so that the window shows up
576 QTimer::singleShot(500, this, SLOT(openFile()));
577 } else if (KdenliveSettings::openlastproject()) {
578 QTimer::singleShot(500, this, SLOT(openLastFile()));
579 } else { //if (m_timelineArea->count() == 0) {
583 if (!clipsToLoad.isEmpty() && m_activeDocument) {
584 QStringList list = clipsToLoad.split(',');
586 foreach(QString path, list) {
587 kDebug() << QDir::current().absoluteFilePath(path);
588 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
590 m_projectList->slotAddClip(urls);
593 #ifdef USE_JOGSHUTTLE
594 activateShuttleDevice();
596 m_projectListDock->raise();
598 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
599 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
601 // Populate encoding profiles
602 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
603 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
604 KConfigGroup group(&conf, "proxy");
605 QMap< QString, QString > values = group.entryMap();
606 QMapIterator<QString, QString> i(values);
609 QString data = i.value();
610 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
611 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
614 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
615 KConfigGroup group(&conf, "video4linux");
616 QMap< QString, QString > values = group.entryMap();
617 QMapIterator<QString, QString> i(values);
620 QString data = i.value();
621 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
622 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
625 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
626 KConfigGroup group(&conf, "decklink");
627 QMap< QString, QString > values = group.entryMap();
628 QMapIterator<QString, QString> i(values);
631 QString data = i.value();
632 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
633 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
637 connect (KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(slotChangePalette()));
640 MainWindow::~MainWindow()
645 m_effectStack->slotClipItemSelected(NULL);
646 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
648 if (m_projectMonitor) m_projectMonitor->stop();
649 if (m_clipMonitor) m_clipMonitor->stop();
651 delete m_activeTimeline;
652 delete m_effectStack;
653 delete m_transitionConfig;
654 delete m_activeDocument;
655 delete m_projectMonitor;
656 delete m_clipMonitor;
657 delete m_shortcutRemoveFocus;
658 delete[] m_transitions;
659 delete m_monitorManager;
660 delete m_scopeManager;
661 Mlt::Factory::close();
665 bool MainWindow::queryClose()
667 if (m_renderWidget) {
668 int waitingJobs = m_renderWidget->waitingJobsCount();
669 if (waitingJobs > 0) {
670 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")))) {
671 case KMessageBox::Yes :
672 // create script with waiting jobs and start it
673 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
675 case KMessageBox::No :
676 // Don't do anything, jobs will be deleted
684 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
685 // warn the user to save if document is modified and we have clips in our project list
686 if (m_activeDocument && m_activeDocument->isModified() &&
687 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
688 !m_projectList->documentClipList().isEmpty())) {
692 if (m_activeDocument->url().fileName().isEmpty())
693 message = i18n("Save changes to document?");
695 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
696 switch (KMessageBox::warningYesNoCancel(this, message)) {
697 case KMessageBox::Yes :
698 // save document here. If saving fails, return false;
700 case KMessageBox::No :
701 // User does not want to save the changes, clear recovery files
702 m_activeDocument->m_autosave->resize(0);
711 void MainWindow::loadPlugins()
713 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
714 populateMenus(plugin);
717 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
719 filters << "libkdenlive*";
720 foreach(const QString & folder, directories) {
721 kDebug() << "Parsing plugin folder: " << folder;
722 QDir pluginsDir(folder);
723 foreach(const QString & fileName,
724 pluginsDir.entryList(filters, QDir::Files)) {
726 * Avoid loading the same plugin twice when there is more than one
729 if (!m_pluginFileNames.contains(fileName)) {
730 kDebug() << "Found plugin: " << fileName;
731 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
732 QObject *plugin = loader.instance();
734 populateMenus(plugin);
735 m_pluginFileNames += fileName;
737 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
743 void MainWindow::populateMenus(QObject *plugin)
745 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
746 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
748 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
752 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
753 QMenu *menu, const char *member,
754 QActionGroup *actionGroup)
756 kDebug() << "// ADD to MENU" << texts;
757 foreach(const QString & text, texts) {
758 QAction *action = new QAction(text, plugin);
759 action->setData(text);
760 connect(action, SIGNAL(triggered()), this, member);
761 menu->addAction(action);
764 action->setCheckable(true);
765 actionGroup->addAction(action);
770 void MainWindow::aboutPlugins()
772 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
777 void MainWindow::generateClip()
779 QAction *action = qobject_cast<QAction *>(sender());
780 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
782 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
783 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
784 if (!clipUrl.isEmpty()) {
785 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
789 void MainWindow::saveProperties(KConfigGroup &config)
791 // save properties here,used by session management
793 KMainWindow::saveProperties(config);
797 void MainWindow::readProperties(const KConfigGroup &config)
799 // read properties here,used by session management
800 KMainWindow::readProperties(config);
801 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
802 openFile(KUrl(Lastproject));
805 void MainWindow::slotReloadEffects()
807 initEffects::parseCustomEffectsFile();
808 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
811 #ifdef USE_JOGSHUTTLE
812 void MainWindow::activateShuttleDevice()
818 if (KdenliveSettings::enableshuttle() == false) return;
820 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
821 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
823 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
824 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
825 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
826 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
827 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
829 #endif /* USE_JOGSHUTTLE */
831 void MainWindow::slotDoAction(const QString& action_name)
833 QAction* action = actionCollection()->action(action_name);
835 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
841 void MainWindow::configureNotifications()
843 KNotifyConfigWidget::configure(this);
846 void MainWindow::slotFullScreen()
848 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
851 void MainWindow::slotAddEffect(const QDomElement effect)
853 if (!m_activeDocument) return;
854 if (effect.isNull()) {
855 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
858 QDomElement effectToAdd = effect.cloneNode().toElement();
860 int ix = m_effectStack->isTrackMode(&ok);
861 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
862 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
865 void MainWindow::slotUpdateClip(const QString &id)
867 if (!m_activeDocument) return;
868 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
870 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
871 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
872 Mlt::Producer *monitorProducer = clip->getCloneProducer();
873 m_clipMonitor->updateClipProducer(monitorProducer);
875 clip->cleanupProducers();
878 void MainWindow::slotConnectMonitors()
880 m_projectList->setRenderer(m_projectMonitor->render);
881 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
882 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
883 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
884 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
885 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
886 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const stringMap &, const stringMap &, bool)));
888 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
890 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
892 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
894 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
895 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
897 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
899 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
900 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
903 void MainWindow::slotAdjustClipMonitor()
905 m_clipMonitorDock->updateGeometry();
906 m_clipMonitorDock->adjustSize();
907 m_clipMonitor->resetSize();
910 void MainWindow::slotAdjustProjectMonitor()
912 m_projectMonitorDock->updateGeometry();
913 m_projectMonitorDock->adjustSize();
914 m_projectMonitor->resetSize();
918 class NameGrabbingKActionCollection {
920 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
921 : m_collection(collection), m_action_names(action_names) {
922 m_action_names.clear();
924 KAction* addAction(const QString& action_name) {
925 m_action_names << action_name;
926 return m_collection->addAction(action_name);
928 void addAction(const QString& action_name, QAction* action) {
929 m_action_names << action_name;
930 m_collection->addAction(action_name, action);
932 operator KActionCollection*() { return m_collection; }
933 const QStringList& actionNames() const { return m_action_names; }
935 KActionCollection* m_collection;
936 QStringList& m_action_names;
939 void MainWindow::setupActions()
942 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
943 m_timecodeFormat = new KComboBox(this);
944 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
945 m_timecodeFormat->addItem(i18n("Frames"));
946 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
947 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
949 m_statusProgressBar = new QProgressBar(this);
950 m_statusProgressBar->setMinimum(0);
951 m_statusProgressBar->setMaximum(100);
952 m_statusProgressBar->setMaximumWidth(150);
953 m_statusProgressBar->setVisible(false);
955 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
956 toolbar->setMovable(false);
958 setStatusBarStyleSheet(palette());
959 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
961 //create edit mode buttons
962 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
963 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
964 toolbar->addAction(m_normalEditTool);
965 m_normalEditTool->setCheckable(true);
966 m_normalEditTool->setChecked(true);
968 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
969 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
970 toolbar->addAction(m_overwriteEditTool);
971 m_overwriteEditTool->setCheckable(true);
972 m_overwriteEditTool->setChecked(false);
974 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
975 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
976 toolbar->addAction(m_insertEditTool);
977 m_insertEditTool->setCheckable(true);
978 m_insertEditTool->setChecked(false);
979 // not implemented yet
980 m_insertEditTool->setEnabled(false);
982 QActionGroup *editGroup = new QActionGroup(this);
983 editGroup->addAction(m_normalEditTool);
984 editGroup->addAction(m_overwriteEditTool);
985 editGroup->addAction(m_insertEditTool);
986 editGroup->setExclusive(true);
987 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
988 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
990 toolbar->addSeparator();
992 // create tools buttons
993 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
994 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
995 toolbar->addAction(m_buttonSelectTool);
996 m_buttonSelectTool->setCheckable(true);
997 m_buttonSelectTool->setChecked(true);
999 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
1000 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1001 toolbar->addAction(m_buttonRazorTool);
1002 m_buttonRazorTool->setCheckable(true);
1003 m_buttonRazorTool->setChecked(false);
1005 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1006 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1007 toolbar->addAction(m_buttonSpacerTool);
1008 m_buttonSpacerTool->setCheckable(true);
1009 m_buttonSpacerTool->setChecked(false);
1011 QActionGroup *toolGroup = new QActionGroup(this);
1012 toolGroup->addAction(m_buttonSelectTool);
1013 toolGroup->addAction(m_buttonRazorTool);
1014 toolGroup->addAction(m_buttonSpacerTool);
1015 toolGroup->setExclusive(true);
1016 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1018 QWidget * actionWidget;
1019 int max = toolbar->iconSizeDefault() + 2;
1020 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1021 actionWidget->setMaximumWidth(max);
1022 actionWidget->setMaximumHeight(max - 4);
1024 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1025 actionWidget->setMaximumWidth(max);
1026 actionWidget->setMaximumHeight(max - 4);
1028 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1029 actionWidget->setMaximumWidth(max);
1030 actionWidget->setMaximumHeight(max - 4);
1032 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1033 actionWidget->setMaximumWidth(max);
1034 actionWidget->setMaximumHeight(max - 4);
1036 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1037 actionWidget->setMaximumWidth(max);
1038 actionWidget->setMaximumHeight(max - 4);
1040 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1041 actionWidget->setMaximumWidth(max);
1042 actionWidget->setMaximumHeight(max - 4);
1044 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1046 toolbar->addSeparator();
1047 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1048 toolbar->addAction(m_buttonFitZoom);
1049 m_buttonFitZoom->setCheckable(false);
1051 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1052 toolbar->addAction(m_zoomOut);
1053 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1055 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1056 m_zoomSlider->setMaximum(13);
1057 m_zoomSlider->setPageStep(1);
1058 m_zoomSlider->setInvertedAppearance(true);
1060 m_zoomSlider->setMaximumWidth(150);
1061 m_zoomSlider->setMinimumWidth(100);
1062 toolbar->addWidget(m_zoomSlider);
1064 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1065 toolbar->addAction(m_zoomIn);
1066 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1068 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1069 actionWidget->setMaximumWidth(max);
1070 actionWidget->setMaximumHeight(max - 4);
1071 actionWidget->setStyleSheet(styleBorderless);
1073 actionWidget = toolbar->widgetForAction(m_zoomIn);
1074 actionWidget->setMaximumWidth(max);
1075 actionWidget->setMaximumHeight(max - 4);
1076 actionWidget->setStyleSheet(styleBorderless);
1078 actionWidget = toolbar->widgetForAction(m_zoomOut);
1079 actionWidget->setMaximumWidth(max);
1080 actionWidget->setMaximumHeight(max - 4);
1081 actionWidget->setStyleSheet(styleBorderless);
1083 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1084 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1085 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1086 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1087 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1089 toolbar->addSeparator();
1091 //create automatic audio split button
1092 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1093 toolbar->addAction(m_buttonAutomaticSplitAudio);
1094 m_buttonAutomaticSplitAudio->setCheckable(true);
1095 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1096 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1098 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1099 toolbar->addAction(m_buttonVideoThumbs);
1100 m_buttonVideoThumbs->setCheckable(true);
1101 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1102 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1104 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1105 toolbar->addAction(m_buttonAudioThumbs);
1106 m_buttonAudioThumbs->setCheckable(true);
1107 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1108 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1110 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1111 toolbar->addAction(m_buttonShowMarkers);
1112 m_buttonShowMarkers->setCheckable(true);
1113 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1114 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1116 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1117 toolbar->addAction(m_buttonSnap);
1118 m_buttonSnap->setCheckable(true);
1119 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1120 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1122 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1123 actionWidget->setMaximumWidth(max);
1124 actionWidget->setMaximumHeight(max - 4);
1126 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1127 actionWidget->setMaximumWidth(max);
1128 actionWidget->setMaximumHeight(max - 4);
1130 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1131 actionWidget->setMaximumWidth(max);
1132 actionWidget->setMaximumHeight(max - 4);
1134 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1135 actionWidget->setMaximumWidth(max);
1136 actionWidget->setMaximumHeight(max - 4);
1138 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1139 actionWidget->setMaximumWidth(max);
1140 actionWidget->setMaximumHeight(max - 4);
1142 m_messageLabel = new StatusBarMessageLabel(this);
1143 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1145 statusBar()->addWidget(m_messageLabel, 10);
1146 statusBar()->addWidget(m_statusProgressBar, 0);
1147 statusBar()->addPermanentWidget(toolbar);
1148 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1149 statusBar()->addPermanentWidget(m_timecodeFormat);
1150 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1152 collection.addAction("normal_mode", m_normalEditTool);
1153 collection.addAction("overwrite_mode", m_overwriteEditTool);
1154 collection.addAction("insert_mode", m_insertEditTool);
1155 collection.addAction("select_tool", m_buttonSelectTool);
1156 collection.addAction("razor_tool", m_buttonRazorTool);
1157 collection.addAction("spacer_tool", m_buttonSpacerTool);
1159 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1160 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1161 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1162 collection.addAction("show_markers", m_buttonShowMarkers);
1163 collection.addAction("snap", m_buttonSnap);
1164 collection.addAction("zoom_fit", m_buttonFitZoom);
1165 collection.addAction("zoom_in", m_zoomIn);
1166 collection.addAction("zoom_out", m_zoomOut);
1168 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1169 collection.addAction("project_find", m_projectSearch);
1170 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1171 m_projectSearch->setShortcut(Qt::Key_Slash);
1173 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1174 collection.addAction("project_find_next", m_projectSearchNext);
1175 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1176 m_projectSearchNext->setShortcut(Qt::Key_F3);
1177 m_projectSearchNext->setEnabled(false);
1179 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1180 collection.addAction("manage_profiles", profilesAction);
1181 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1183 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1184 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1185 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1186 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1188 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1189 collection.addAction("run_wizard", wizAction);
1190 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1192 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1193 collection.addAction("project_settings", projectAction);
1194 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1196 KAction* backupAction = new KAction(KIcon("edit-undo"), i18n("Open Backup File"), this);
1197 collection.addAction("open_backup", backupAction);
1198 connect(backupAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenBackupDialog()));
1200 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1201 collection.addAction("project_render", projectRender);
1202 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1203 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1205 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1206 collection.addAction("project_clean", projectClean);
1207 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1209 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1210 collection.addAction("project_adjust_profile", projectAdjust);
1211 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1213 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1214 KShortcut playShortcut;
1215 playShortcut.setPrimary(Qt::Key_Space);
1216 playShortcut.setAlternate(Qt::Key_K);
1217 monitorPlay->setShortcut(playShortcut);
1218 collection.addAction("monitor_play", monitorPlay);
1219 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1221 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1222 collection.addAction("monitor_pause", monitorPause);
1223 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1225 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1226 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1227 collection.addAction("monitor_play_zone", m_playZone);
1228 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1230 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1231 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1232 collection.addAction("monitor_loop_zone", m_loopZone);
1233 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1235 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1236 m_loopClip->setEnabled(false);
1237 collection.addAction("monitor_loop_clip", m_loopClip);
1238 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1240 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1241 collection.addAction("dvd_wizard", dvdWizard);
1242 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1244 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1245 collection.addAction("transcode_clip", transcodeClip);
1246 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1248 KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this);
1249 collection.addAction("archive_project", archiveProject);
1250 connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject()));
1253 KAction *markIn = collection.addAction("mark_in");
1254 markIn->setText(i18n("Set Zone In"));
1255 markIn->setShortcut(Qt::Key_I);
1256 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1258 KAction *markOut = collection.addAction("mark_out");
1259 markOut->setText(i18n("Set Zone Out"));
1260 markOut->setShortcut(Qt::Key_O);
1261 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1263 KAction *switchMon = collection.addAction("switch_monitor");
1264 switchMon->setText(i18n("Switch monitor"));
1265 switchMon->setShortcut(Qt::Key_T);
1266 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1268 KAction *fullMon = collection.addAction("monitor_fullscreen");
1269 fullMon->setText(i18n("Switch monitor fullscreen"));
1270 fullMon->setIcon(KIcon("view-fullscreen"));
1271 connect(fullMon, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotSwitchFullscreen()));
1273 KAction *insertTree = collection.addAction("insert_project_tree");
1274 insertTree->setText(i18n("Insert zone in project tree"));
1275 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1276 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1278 KAction *insertTimeline = collection.addAction("insert_timeline");
1279 insertTimeline->setText(i18n("Insert zone in timeline"));
1280 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1281 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1283 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1284 collection.addAction("resize_timeline_clip_start", resizeStart);
1285 resizeStart->setShortcut(Qt::Key_1);
1286 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1288 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1289 collection.addAction("resize_timeline_clip_end", resizeEnd);
1290 resizeEnd->setShortcut(Qt::Key_2);
1291 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1293 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1294 monitorSeekBackward->setShortcut(Qt::Key_J);
1295 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1296 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1298 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1299 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1300 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1301 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1303 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1304 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1305 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1306 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1308 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1309 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1310 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1311 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1313 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1314 monitorSeekForward->setShortcut(Qt::Key_L);
1315 collection.addAction("monitor_seek_forward", monitorSeekForward);
1316 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1318 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1319 clipStart->setShortcut(Qt::Key_Home);
1320 collection.addAction("seek_clip_start", clipStart);
1321 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1323 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1324 clipEnd->setShortcut(Qt::Key_End);
1325 collection.addAction("seek_clip_end", clipEnd);
1326 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1328 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1329 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1330 collection.addAction("seek_zone_start", zoneStart);
1331 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1333 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1334 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1335 collection.addAction("seek_zone_end", zoneEnd);
1336 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1338 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1339 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1340 collection.addAction("seek_start", projectStart);
1341 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1343 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1344 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1345 collection.addAction("seek_end", projectEnd);
1346 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1348 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1349 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1350 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1351 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1353 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1354 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1355 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1356 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1358 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1359 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1360 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1361 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1363 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1364 deleteItem->setShortcut(Qt::Key_Delete);
1365 collection.addAction("delete_timeline_clip", deleteItem);
1366 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1368 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1369 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1370 editTimelineClipSpeed->setData("change_speed");
1371 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1373 KAction *stickTransition = collection.addAction("auto_transition");
1374 stickTransition->setData(QString("auto"));
1375 stickTransition->setCheckable(true);
1376 stickTransition->setEnabled(false);
1377 stickTransition->setText(i18n("Automatic Transition"));
1378 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1380 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1381 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1382 collection.addAction("group_clip", groupClip);
1383 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1385 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1386 collection.addAction("ungroup_clip", ungroupClip);
1387 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1388 ungroupClip->setData("ungroup_clip");
1389 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1391 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1392 collection.addAction("edit_item_duration", editItemDuration);
1393 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1395 KAction* saveTimelineClip = new KAction(KIcon("document-save"), i18n("Save clip"), this);
1396 collection.addAction("save_timeline_clip", saveTimelineClip);
1397 connect(saveTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSaveTimelineClip()));
1399 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1400 collection.addAction("clip_in_project_tree", clipInProjectTree);
1401 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1403 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1404 collection.addAction("clip_to_project_tree", clipToProjectTree);
1405 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1407 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1408 insertOvertwrite->setShortcut(Qt::Key_V);
1409 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1410 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1412 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1413 selectTimelineClip->setShortcut(Qt::Key_Plus);
1414 collection.addAction("select_timeline_clip", selectTimelineClip);
1415 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1417 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1418 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1419 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1420 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1422 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1423 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1424 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1425 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1427 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1428 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1429 collection.addAction("select_timeline_transition", selectTimelineTransition);
1430 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1432 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1433 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1434 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1435 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1437 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1438 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1439 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1440 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1442 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1443 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1444 collection.addAction("cut_timeline_clip", cutTimelineClip);
1445 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1447 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1448 collection.addAction("add_clip_marker", addClipMarker);
1449 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1451 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1452 collection.addAction("delete_clip_marker", deleteClipMarker);
1453 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1455 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1456 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1457 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1459 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1460 editClipMarker->setData(QString("edit_marker"));
1461 collection.addAction("edit_clip_marker", editClipMarker);
1462 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1464 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1465 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1466 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1467 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1469 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1470 collection.addAction("split_audio", splitAudio);
1471 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1473 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1474 collection.addAction("clip_audio_only", audioOnly);
1475 audioOnly->setData("clip_audio_only");
1476 audioOnly->setCheckable(true);
1478 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1479 collection.addAction("clip_video_only", videoOnly);
1480 videoOnly->setData("clip_video_only");
1481 videoOnly->setCheckable(true);
1483 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1484 collection.addAction("clip_audio_and_video", audioAndVideo);
1485 audioAndVideo->setData("clip_audio_and_video");
1486 audioAndVideo->setCheckable(true);
1488 m_clipTypeGroup = new QActionGroup(this);
1489 m_clipTypeGroup->addAction(audioOnly);
1490 m_clipTypeGroup->addAction(videoOnly);
1491 m_clipTypeGroup->addAction(audioAndVideo);
1492 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1493 m_clipTypeGroup->setEnabled(false);
1495 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1496 collection.addAction("insert_space", insertSpace);
1497 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1499 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1500 collection.addAction("delete_space", removeSpace);
1501 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1503 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1504 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1506 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1507 m_tracksActionCollection->addAction("insert_track", insertTrack);
1508 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1510 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1511 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1512 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1514 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1515 m_tracksActionCollection->addAction("config_tracks", configTracks);
1516 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1518 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1519 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1520 m_tracksActionCollection->addAction("select_track", selectTrack);
1522 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1523 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1524 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1526 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1527 collection.addAction("add_guide", addGuide);
1528 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1530 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1531 collection.addAction("delete_guide", delGuide);
1532 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1534 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1535 collection.addAction("edit_guide", editGuide);
1536 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1538 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1539 collection.addAction("delete_all_guides", delAllGuides);
1540 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1542 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1543 collection.addAction("paste_effects", pasteEffects);
1544 pasteEffects->setData("paste_effects");
1545 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1547 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1548 collection.addAction("show_timeline", showTimeline);
1549 showTimeline->setCheckable(true);
1550 showTimeline->setChecked(true);
1551 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1553 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1554 collection.addAction("show_titlebars", showTitleBar);
1555 showTitleBar->setCheckable(true);
1556 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1557 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1558 slotShowTitleBars(KdenliveSettings::showtitlebars());
1560 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1561 KStandardAction::quit(this, SLOT(close()), collection);
1562 KStandardAction::open(this, SLOT(openFile()), collection);
1563 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1564 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1565 KStandardAction::openNew(this, SLOT(newFile()), collection);
1566 // TODO: make the following connection to slotEditKeys work
1567 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1568 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1569 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1570 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1571 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1572 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1574 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1575 undo->setEnabled(false);
1576 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1578 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1579 redo->setEnabled(false);
1580 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1583 //TODO: Add status tooltip to actions ?
1584 connect(collection, SIGNAL(actionHovered(QAction*)),
1585 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1588 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1589 collection.addAction("add_clip", addClip);
1590 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1592 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1593 collection.addAction("add_color_clip", addColorClip);
1594 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1596 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1597 collection.addAction("add_slide_clip", addSlideClip);
1598 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1600 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1601 collection.addAction("add_text_clip", addTitleClip);
1602 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1604 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1605 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1606 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1608 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1609 collection.addAction("add_folder", addFolderButton);
1610 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1612 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1613 collection.addAction("download_resource", downloadResources);
1614 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1616 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1617 collection.addAction("clip_properties", clipProperties);
1618 clipProperties->setData("clip_properties");
1619 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1620 clipProperties->setEnabled(false);
1622 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1623 collection.addAction("edit_clip", openClip);
1624 openClip->setData("edit_clip");
1625 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1626 openClip->setEnabled(false);
1628 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1629 collection.addAction("delete_clip", deleteClip);
1630 deleteClip->setData("delete_clip");
1631 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1632 deleteClip->setEnabled(false);
1634 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1635 collection.addAction("reload_clip", reloadClip);
1636 reloadClip->setData("reload_clip");
1637 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1638 reloadClip->setEnabled(false);
1640 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1641 collection.addAction("proxy_clip", proxyClip);
1642 proxyClip->setData("proxy_clip");
1643 proxyClip->setCheckable(true);
1644 proxyClip->setChecked(false);
1645 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1647 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1648 collection.addAction("stopmotion", stopMotion);
1649 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1651 QMenu *addClips = new QMenu();
1652 addClips->addAction(addClip);
1653 addClips->addAction(addColorClip);
1654 addClips->addAction(addSlideClip);
1655 addClips->addAction(addTitleClip);
1656 addClips->addAction(addTitleTemplateClip);
1657 addClips->addAction(addFolderButton);
1658 addClips->addAction(downloadResources);
1660 addClips->addAction(reloadClip);
1661 addClips->addAction(proxyClip);
1662 addClips->addAction(clipProperties);
1663 addClips->addAction(openClip);
1664 addClips->addAction(deleteClip);
1665 m_projectList->setupMenu(addClips, addClip);
1667 // Setup effects and transitions actions.
1668 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1669 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1670 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1671 m_transitions = new KAction*[transitions.count()];
1672 for (int i = 0; i < transitions.count(); i++) {
1673 QStringList effectInfo = transitions.effectIdInfo(i);
1674 m_transitions[i] = new KAction(effectInfo.at(0), this);
1675 m_transitions[i]->setData(effectInfo);
1676 m_transitions[i]->setIconVisibleInMenu(false);
1677 QString id = effectInfo.at(2);
1678 if (id.isEmpty()) id = effectInfo.at(1);
1679 transitionActions->addAction("transition_" + id, m_transitions[i]);
1681 //m_effectsActionCollection->readSettings();
1685 void MainWindow::slotDisplayActionMessage(QAction *a)
1687 statusBar()->showMessage(a->data().toString(), 3000);
1690 void MainWindow::setStatusBarStyleSheet(const QPalette &p)
1692 KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
1693 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
1694 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
1695 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
1696 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
1697 QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: %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());
1698 statusBar()->setStyleSheet(style1);
1701 void MainWindow::loadLayouts()
1703 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1704 if (m_loadLayout == NULL || saveLayout == NULL) return;
1705 KSharedConfigPtr config = KGlobal::config();
1706 KConfigGroup layoutGroup(config, "Layouts");
1707 QStringList entries = layoutGroup.keyList();
1708 QList<QAction *> loadActions = m_loadLayout->actions();
1709 QList<QAction *> saveActions = saveLayout->actions();
1710 for (int i = 1; i < 5; i++) {
1711 // Rename the layouts actions
1712 foreach(const QString & key, entries) {
1713 if (key.endsWith(QString("_%1").arg(i))) {
1714 // Found previously saved layout
1715 QString layoutName = key.section("_", 0, -2);
1716 for (int j = 0; j < loadActions.count(); j++) {
1717 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1718 loadActions[j]->setText(layoutName);
1719 loadActions[j]->setData(key);
1723 for (int j = 0; j < saveActions.count(); j++) {
1724 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1725 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1726 saveActions[j]->setData(key);
1735 void MainWindow::slotLoadLayout(QAction *action)
1737 if (!action) return;
1738 QString layoutId = action->data().toString();
1739 if (layoutId.isEmpty()) return;
1740 KSharedConfigPtr config = KGlobal::config();
1741 KConfigGroup layouts(config, "Layouts");
1742 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1743 restoreState(state);
1746 void MainWindow::slotSaveLayout(QAction *action)
1748 QString originallayoutName = action->data().toString();
1749 int layoutId = originallayoutName.section('_', -1).toInt();
1751 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1752 if (layoutName.isEmpty()) return;
1753 KSharedConfigPtr config = KGlobal::config();
1754 KConfigGroup layouts(config, "Layouts");
1755 layouts.deleteEntry(originallayoutName);
1757 QByteArray st = saveState();
1758 layoutName.append("_" + QString::number(layoutId));
1759 layouts.writeEntry(layoutName, st.toBase64());
1763 void MainWindow::saveOptions()
1765 KdenliveSettings::self()->writeConfig();
1766 KSharedConfigPtr config = KGlobal::config();
1767 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1768 KConfigGroup treecolumns(config, "Project Tree");
1769 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1773 void MainWindow::readOptions()
1775 KSharedConfigPtr config = KGlobal::config();
1776 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1777 KConfigGroup initialGroup(config, "version");
1778 bool upgrade = false;
1779 if (initialGroup.exists()) {
1780 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1784 if (initialGroup.readEntry("version") == "0.7") {
1785 //Add new settings from 0.7.1
1786 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1787 QString path = QDir::homePath() + "/kdenlive";
1788 if (KStandardDirs::makeDir(path) == false) {
1789 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1790 } else KdenliveSettings::setDefaultprojectfolder(path);
1796 if (!initialGroup.exists() || upgrade) {
1797 // this is our first run, show Wizard
1798 Wizard *w = new Wizard(upgrade, this);
1799 if (w->exec() == QDialog::Accepted && w->isOk()) {
1800 w->adjustSettings();
1801 initialGroup.writeEntry("version", version);
1807 KConfigGroup treecolumns(config, "Project Tree");
1808 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1809 if (!state.isEmpty())
1810 m_projectList->setHeaderInfo(state);
1813 void MainWindow::slotRunWizard()
1815 Wizard *w = new Wizard(false, this);
1816 if (w->exec() == QDialog::Accepted && w->isOk()) {
1817 w->adjustSettings();
1822 void MainWindow::newFile(bool showProjectSettings, bool force)
1824 if (!m_timelineArea->isEnabled() && !force)
1826 m_fileRevert->setEnabled(false);
1827 QString profileName = KdenliveSettings::default_profile();
1828 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1829 QMap <QString, QString> documentProperties;
1830 QMap <QString, QString> documentMetadata;
1831 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1832 if (!showProjectSettings) {
1833 if (!KdenliveSettings::activatetabs())
1834 if (!closeCurrentDocument())
1837 ProjectSettings *w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1838 if (w->exec() != QDialog::Accepted)
1840 if (!KdenliveSettings::activatetabs())
1841 if (!closeCurrentDocument())
1843 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1844 slotSwitchVideoThumbs();
1845 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1846 slotSwitchAudioThumbs();
1847 profileName = w->selectedProfile();
1848 projectFolder = w->selectedFolder();
1849 projectTracks = w->tracks();
1850 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1851 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1852 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1853 documentProperties.insert("proxyparams", w->proxyParams());
1854 documentProperties.insert("proxyextension", w->proxyExtension());
1855 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1856 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1857 documentMetadata = w->metadata();
1860 m_timelineArea->setEnabled(true);
1861 m_projectList->setEnabled(true);
1863 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1864 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1866 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
1867 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1870 //m_timelineArea->setEnabled(false);
1871 //m_projectList->setEnabled(false);
1875 if (m_timelineArea->count() == 1) {
1876 connectDocumentInfo(doc);
1877 connectDocument(trackView, doc);
1879 m_timelineArea->setTabBarHidden(false);
1880 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
1881 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1884 void MainWindow::activateDocument()
1886 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1887 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1888 KdenliveDoc *currentDoc = currentTab->document();
1889 connectDocumentInfo(currentDoc);
1890 connectDocument(currentTab, currentDoc);
1893 bool MainWindow::closeCurrentDocument(bool saveChanges)
1895 QWidget *w = m_timelineArea->currentWidget();
1896 if (!w) return true;
1897 // closing current document
1898 int ix = m_timelineArea->currentIndex() + 1;
1899 if (ix == m_timelineArea->count()) ix = 0;
1900 m_timelineArea->setCurrentIndex(ix);
1901 TrackView *tabToClose = (TrackView *) w;
1902 KdenliveDoc *docToClose = tabToClose->document();
1903 if (docToClose && docToClose->isModified() && saveChanges) {
1905 if (m_activeDocument->url().fileName().isEmpty())
1906 message = i18n("Save changes to document?");
1908 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1909 switch (KMessageBox::warningYesNoCancel(this, message)) {
1910 case KMessageBox::Yes :
1911 // save document here. If saving fails, return false;
1912 if (saveFile() == false) return false;
1914 case KMessageBox::Cancel :
1921 m_clipMonitor->slotSetClipProducer(NULL);
1922 m_projectList->slotResetProjectList();
1923 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1924 if (m_timelineArea->count() == 1) {
1925 m_timelineArea->setTabBarHidden(true);
1926 m_closeAction->setEnabled(false);
1928 if (docToClose == m_activeDocument) {
1929 delete m_activeDocument;
1930 m_activeDocument = NULL;
1931 m_effectStack->clear();
1932 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1936 if (w == m_activeTimeline) {
1937 delete m_activeTimeline;
1938 m_activeTimeline = NULL;
1945 bool MainWindow::saveFileAs(const QString &outputFileName)
1947 QString currentSceneList;
1948 m_monitorManager->stopActiveMonitor();
1950 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1953 // Save timeline thumbnails
1954 m_activeTimeline->projectView()->saveThumbnails();
1955 m_activeDocument->setUrl(KUrl(outputFileName));
1956 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
1957 if (m_activeDocument->m_autosave == NULL) {
1958 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
1959 } else m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
1960 setCaption(m_activeDocument->description());
1961 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1962 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1963 m_activeDocument->setModified(false);
1964 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1965 m_fileRevert->setEnabled(true);
1966 m_undoView->stack()->setClean();
1970 bool MainWindow::saveFileAs()
1972 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1973 if (outputFile.isEmpty()) {
1976 if (QFile::exists(outputFile)) {
1977 // Show the file dialog again if the user does not want to overwrite the file
1978 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1979 return saveFileAs();
1981 return saveFileAs(outputFile);
1984 bool MainWindow::saveFile()
1986 if (!m_activeDocument) return true;
1987 if (m_activeDocument->url().isEmpty()) {
1988 return saveFileAs();
1990 bool result = saveFileAs(m_activeDocument->url().path());
1991 m_activeDocument->m_autosave->resize(0);
1996 void MainWindow::openFile()
1998 if (!m_startUrl.isEmpty()) {
1999 openFile(m_startUrl);
2000 m_startUrl = KUrl();
2003 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
2004 if (url.isEmpty()) return;
2005 m_fileOpenRecent->addUrl(url);
2009 void MainWindow::openLastFile()
2011 KSharedConfigPtr config = KGlobal::config();
2012 KUrl::List urls = m_fileOpenRecent->urls();
2013 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
2014 if (urls.isEmpty()) newFile(false);
2015 else openFile(urls.last());
2018 void MainWindow::openFile(const KUrl &url)
2020 // Make sure the url is a Kdenlive project file
2021 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2022 if (mime.data()->is("application/x-compressed-tar")) {
2023 // Opening a compressed project file, we need to process it
2024 kDebug()<<"Opening archive, processing";
2025 ArchiveWidget *ar = new ArchiveWidget(url);
2026 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2030 if (!url.fileName().endsWith(".kdenlive")) {
2031 // This is not a Kdenlive project file, abort loading
2032 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2036 // Check if the document is already opened
2037 const int ct = m_timelineArea->count();
2038 bool isOpened = false;
2040 for (i = 0; i < ct; i++) {
2041 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2042 KdenliveDoc *doc = tab->document();
2043 if (doc->url() == url) {
2049 m_timelineArea->setCurrentIndex(i);
2053 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2055 // Check for backup file
2056 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2057 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2058 if (!staleFiles.isEmpty()) {
2059 if (KMessageBox::questionYesNo(this,
2060 i18n("Auto-saved files exist. Do you want to recover them now?"),
2061 i18n("File Recovery"),
2062 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2063 recoverFiles(staleFiles, url);
2066 // remove the stale files
2067 foreach(KAutoSaveFile * stale, staleFiles) {
2068 stale->open(QIODevice::ReadWrite);
2073 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2074 m_messageLabel->repaint();
2075 doOpenFile(url, NULL);
2078 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2080 if (!m_timelineArea->isEnabled()) return;
2081 m_fileRevert->setEnabled(true);
2083 // Recreate stopmotion widget on document change
2085 delete m_stopmotion;
2086 m_stopmotion = NULL;
2090 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2091 progressDialog.setAllowCancel(false);
2092 progressDialog.progressBar()->setMaximum(4);
2093 progressDialog.show();
2094 progressDialog.progressBar()->setValue(0);
2095 qApp->processEvents();
2098 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);
2100 progressDialog.progressBar()->setValue(1);
2101 progressDialog.progressBar()->setMaximum(4);
2102 progressDialog.setLabelText(i18n("Loading project"));
2103 qApp->processEvents();
2105 if (stale == NULL) {
2106 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2107 stale = new KAutoSaveFile(KUrl(hash), doc);
2108 doc->m_autosave = stale;
2110 doc->m_autosave = stale;
2111 doc->setUrl(url);//stale->managedFile());
2112 doc->setModified(true);
2113 stale->setParent(doc);
2115 connectDocumentInfo(doc);
2117 progressDialog.progressBar()->setValue(2);
2118 qApp->processEvents();
2121 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2122 connectDocument(trackView, doc);
2123 progressDialog.progressBar()->setValue(3);
2124 qApp->processEvents();
2126 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2128 m_timelineArea->setEnabled(false);
2129 m_projectList->setEnabled(false);
2130 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2131 slotGotProgressInfo(QString(), -1);
2132 newFile(false, true);
2135 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2136 trackView->setDuration(trackView->duration());
2137 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2139 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2140 slotGotProgressInfo(QString(), -1);
2141 m_projectMonitor->adjustRulerSize(trackView->duration());
2142 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2143 progressDialog.progressBar()->setValue(4);
2144 if (openBackup) slotOpenBackupDialog(url);
2147 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl)
2149 foreach(KAutoSaveFile * stale, staleFiles) {
2150 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2151 // show an error message; we could not steal the lockfile
2152 // maybe another application got to the file before us?
2156 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2157 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2158 if (!stale->fileName().endsWith(".lock")) doOpenFile(originUrl, stale);
2159 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2163 void MainWindow::parseProfiles(const QString &mltPath)
2165 //KdenliveSettings::setDefaulttmpfolder();
2166 if (!mltPath.isEmpty()) {
2167 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2168 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2171 if (KdenliveSettings::mltpath().isEmpty())
2172 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2174 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2175 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2176 if (!QFile::exists(meltPath))
2177 meltPath = KStandardDirs::findExe("melt");
2178 KdenliveSettings::setRendererpath(meltPath);
2181 if (KdenliveSettings::rendererpath().isEmpty()) {
2182 // Cannot find the MLT melt renderer, ask for location
2183 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2184 if (getUrl->exec() == QDialog::Rejected) {
2187 KUrl rendererPath = getUrl->selectedUrl();
2189 if (rendererPath.isEmpty()) ::exit(0);
2190 KdenliveSettings::setRendererpath(rendererPath.path());
2193 QStringList profilesFilter;
2194 profilesFilter << "*";
2195 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2196 if (profilesList.isEmpty()) {
2197 // Cannot find MLT path, try finding melt
2198 QString profilePath = KdenliveSettings::rendererpath();
2199 if (!profilePath.isEmpty()) {
2200 profilePath = profilePath.section('/', 0, -3);
2201 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2202 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2204 if (profilesList.isEmpty()) {
2205 // Cannot find the MLT profiles, ask for location
2206 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2207 getUrl->fileDialog()->setMode(KFile::Directory);
2208 if (getUrl->exec() == QDialog::Rejected) {
2211 KUrl mltPath = getUrl->selectedUrl();
2213 if (mltPath.isEmpty()) ::exit(0);
2214 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2215 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2219 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2221 // Parse again MLT profiles to build a list of available video formats
2222 if (profilesList.isEmpty()) parseProfiles();
2226 void MainWindow::slotEditProfiles()
2228 ProfilesDialog *w = new ProfilesDialog;
2229 if (w->exec() == QDialog::Accepted) {
2230 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2231 if (d) d->checkProfile();
2236 void MainWindow::slotDetectAudioDriver()
2238 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2239 leading to no audio output, see bug #934 */
2241 //decide which audio driver is really best, in some cases SDL is wrong
2242 if (KdenliveSettings::audiodrivername().isEmpty()) {
2244 KProcess readProcess;
2245 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2246 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2247 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2248 readProcess.setProgram("pactl", QStringList() << "stat");
2249 readProcess.execute(2000); // Kill it after 2 seconds
2251 QString result = QString(readProcess.readAllStandardOutput());
2252 kDebug() << "// / / / / / READING PACTL: ";
2254 if (!result.isEmpty()) {
2256 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2260 KdenliveSettings::setAutoaudiodrivername(driver);
2264 void MainWindow::slotEditProjectSettings()
2266 QPoint p = m_activeDocument->getTracksCount();
2267 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);
2268 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2270 if (w->exec() == QDialog::Accepted) {
2271 QString profile = w->selectedProfile();
2272 m_activeDocument->setProjectFolder(w->selectedFolder());
2274 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2276 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2277 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2278 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2279 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2280 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2281 m_activeDocument->setModified();
2282 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2283 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) {
2284 //TODO: rebuild all proxies
2285 //m_projectList->rebuildProxies();
2288 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2289 m_activeDocument->setModified();
2290 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2292 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2293 m_activeDocument->setModified();
2294 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2296 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2297 m_activeDocument->setModified();
2298 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2300 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2301 m_activeDocument->setModified();
2302 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2304 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2305 m_activeDocument->setModified();
2306 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2308 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2309 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2310 m_activeDocument->setModified();
2311 slotUpdateProxySettings();
2313 m_activeDocument->setMetadata(w->metadata());
2318 void MainWindow::slotDisableProxies()
2320 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2321 m_activeDocument->setModified();
2322 slotUpdateProxySettings();
2325 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2327 // Recreate the stopmotion widget if profile changes
2329 delete m_stopmotion;
2330 m_stopmotion = NULL;
2333 // Deselect current effect / transition
2334 m_effectStack->slotClipItemSelected(NULL);
2335 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2336 m_clipMonitor->slotSetClipProducer(NULL);
2337 bool updateFps = m_activeDocument->setProfilePath(profile);
2338 KdenliveSettings::setCurrent_profile(profile);
2339 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2340 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2342 m_activeDocument->clipManager()->clearUnusedProducers();
2343 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2344 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2345 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2346 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2347 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2348 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2349 if (updateFps) m_activeTimeline->updateProjectFps();
2350 m_activeDocument->clipManager()->clearCache();
2351 m_activeTimeline->updateProfile();
2352 m_activeDocument->setModified(true);
2353 m_commandStack->activeStack()->clear();
2354 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2355 slotUpdateMousePosition(0);
2356 // We need to desactivate & reactivate monitors to get a refresh
2357 //m_monitorManager->switchMonitors();
2361 void MainWindow::slotRenderProject()
2363 if (!m_renderWidget) {
2364 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2365 MltVideoProfile profile;
2366 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2367 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2368 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2369 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2370 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2371 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2372 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2373 if (m_activeDocument) {
2374 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2375 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2376 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2377 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2380 slotCheckRenderStatus();
2381 m_renderWidget->show();
2382 m_renderWidget->showNormal();
2384 // What are the following lines supposed to do?
2385 //m_activeTimeline->tracksNumber();
2386 //m_renderWidget->enableAudio(false);
2387 //m_renderWidget->export_audio;
2390 void MainWindow::slotCheckRenderStatus()
2392 // Make sure there are no missing clips
2394 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2397 void MainWindow::setRenderingProgress(const QString &url, int progress)
2400 m_renderWidget->setRenderJob(url, progress);
2403 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2406 m_renderWidget->setRenderStatus(url, status, error);
2409 void MainWindow::slotCleanProject()
2411 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2412 m_projectList->cleanup();
2415 void MainWindow::slotUpdateMousePosition(int pos)
2417 if (m_activeDocument)
2418 switch (m_timecodeFormat->currentIndex()) {
2420 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2423 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2427 void MainWindow::slotUpdateDocumentState(bool modified)
2429 if (!m_activeDocument) return;
2430 setCaption(m_activeDocument->description(), modified);
2431 m_saveAction->setEnabled(modified);
2433 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2434 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2436 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2437 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2441 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2443 if (m_activeDocument) {
2444 if (m_activeDocument == doc) return;
2445 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2447 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2450 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2452 //m_projectMonitor->stop();
2453 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2454 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2455 if (m_activeDocument) {
2456 if (m_activeDocument == doc) return;
2457 if (m_activeTimeline) {
2458 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2459 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2460 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2461 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2462 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2463 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2464 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2466 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2468 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2469 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2470 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2471 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2472 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2473 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2474 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
2475 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2476 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2477 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2478 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2479 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2480 disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2482 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
2483 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2484 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2485 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2486 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2487 disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2488 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2489 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2490 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2491 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2492 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2493 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2494 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2495 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2496 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2497 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2498 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2499 m_effectStack->clear();
2501 //m_activeDocument->setRenderer(NULL);
2502 m_clipMonitor->stop();
2504 KdenliveSettings::setCurrent_profile(doc->profilePath());
2505 KdenliveSettings::setProject_fps(doc->fps());
2506 m_monitorManager->resetProfiles(doc->timecode());
2507 m_clipMonitorDock->raise();
2508 m_projectList->setDocument(doc);
2509 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2510 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2511 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2513 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2514 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2516 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2517 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2518 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2519 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2520 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2521 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2522 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2523 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2524 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2525 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2526 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2528 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2529 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2530 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2531 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2532 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2534 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2535 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2536 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2538 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2540 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2541 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotTrackSelected(int, TrackInfo)));
2543 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
2544 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2545 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2546 m_zoomSlider->setValue(doc->zoom().x());
2547 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2548 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2549 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2550 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2552 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2553 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2555 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2557 connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2559 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2560 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2561 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2562 connect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2563 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2564 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2565 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2566 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2567 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2568 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2569 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2570 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2572 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2573 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2574 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2575 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2576 m_activeTimeline = trackView;
2577 if (m_renderWidget) {
2578 slotCheckRenderStatus();
2579 m_renderWidget->setProfile(doc->mltProfile());
2580 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2581 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2582 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2584 //doc->setRenderer(m_projectMonitor->render);
2585 m_commandStack->setActiveStack(doc->commandStack());
2586 KdenliveSettings::setProject_display_ratio(doc->dar());
2587 //doc->clipManager()->checkAudioThumbs();
2589 //m_overView->setScene(trackView->projectScene());
2590 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2591 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2593 setCaption(doc->description(), doc->isModified());
2594 m_saveAction->setEnabled(doc->isModified());
2595 m_normalEditTool->setChecked(true);
2596 m_activeDocument = doc;
2597 m_activeTimeline->updateProjectFps();
2598 m_activeDocument->checkProjectClips();
2600 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2602 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2603 slotUpdateMousePosition(0);
2604 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
2605 // set tool to select tool
2606 m_buttonSelectTool->setChecked(true);
2609 void MainWindow::slotZoneMoved(int start, int end)
2611 m_activeDocument->setZone(start, end);
2612 m_projectMonitor->slotZoneMoved(start, end);
2615 void MainWindow::slotGuidesUpdated()
2618 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2621 void MainWindow::slotEditKeys()
2623 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2624 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2625 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2626 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2630 void MainWindow::slotPreferences(int page, int option)
2633 * An instance of your dialog could be already created and could be
2634 * cached, in which case you want to display the cached dialog
2635 * instead of creating another one
2637 if (m_stopmotion) m_stopmotion->slotLive(false);
2638 if (KConfigDialog::showDialog("settings")) {
2639 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2640 if (page != -1) d->showPage(page, option);
2644 // KConfigDialog didn't find an instance of this dialog, so lets
2647 // Get the mappable actions in localized form
2648 QMap<QString, QString> actions;
2649 KActionCollection* collection = actionCollection();
2650 foreach (const QString& action_name, m_action_names) {
2651 actions[collection->action(action_name)->text()] = action_name;
2654 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2655 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2656 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2658 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2661 if (page != -1) dialog->showPage(page, option);
2664 void MainWindow::slotUpdateCaptureFolder()
2668 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2669 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2673 void MainWindow::updateConfiguration()
2675 //TODO: we should apply settings to all projects, not only the current one
2676 if (m_activeTimeline) {
2677 m_activeTimeline->refresh();
2678 m_activeTimeline->projectView()->checkAutoScroll();
2679 m_activeTimeline->checkTrackHeight();
2680 if (m_activeDocument)
2681 m_activeDocument->clipManager()->checkAudioThumbs();
2683 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2684 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2685 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2686 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2688 // Update list of transcoding profiles
2691 #ifdef USE_JOGSHUTTLE
2692 activateShuttleDevice();
2697 void MainWindow::slotSwitchSplitAudio()
2699 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2700 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2703 void MainWindow::slotSwitchVideoThumbs()
2705 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2706 if (m_activeTimeline)
2707 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2708 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2711 void MainWindow::slotSwitchAudioThumbs()
2713 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2714 if (m_activeTimeline) {
2715 m_activeTimeline->refresh();
2716 m_activeTimeline->projectView()->checkAutoScroll();
2717 if (m_activeDocument)
2718 m_activeDocument->clipManager()->checkAudioThumbs();
2720 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2723 void MainWindow::slotSwitchMarkersComments()
2725 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2726 if (m_activeTimeline)
2727 m_activeTimeline->refresh();
2728 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2731 void MainWindow::slotSwitchSnap()
2733 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2734 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2738 void MainWindow::slotDeleteItem()
2740 if (QApplication::focusWidget() &&
2741 QApplication::focusWidget()->parentWidget() &&
2742 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2743 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2744 m_projectList->slotRemoveClip();
2747 QWidget *widget = QApplication::focusWidget();
2749 if (widget == m_effectStackDock) {
2750 m_effectStack->deleteCurrentEffect();
2753 widget = widget->parentWidget();
2756 // effect stack has no focus
2757 if (m_activeTimeline)
2758 m_activeTimeline->projectView()->deleteSelectedClips();
2762 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2764 if (m_clipMonitor->isActive())
2765 m_clipMonitor->checkOverlay();
2766 m_clipMonitor->updateMarkers(clip);
2769 void MainWindow::slotAddClipMarker()
2771 DocClipBase *clip = NULL;
2773 if (m_projectMonitor->isActive()) {
2774 if (m_activeTimeline) {
2775 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2777 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2778 clip = item->baseClip();
2782 clip = m_clipMonitor->activeClip();
2783 pos = m_clipMonitor->position();
2786 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2789 QString id = clip->getId();
2790 CommentedTime marker(pos, i18n("Marker"));
2791 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2792 if (d.exec() == QDialog::Accepted)
2793 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2796 void MainWindow::slotDeleteClipMarker()
2798 DocClipBase *clip = NULL;
2800 if (m_projectMonitor->isActive()) {
2801 if (m_activeTimeline) {
2802 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2804 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2805 clip = item->baseClip();
2809 clip = m_clipMonitor->activeClip();
2810 pos = m_clipMonitor->position();
2813 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2817 QString id = clip->getId();
2818 QString comment = clip->markerComment(pos);
2819 if (comment.isEmpty()) {
2820 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2823 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2826 void MainWindow::slotDeleteAllClipMarkers()
2828 DocClipBase *clip = NULL;
2829 if (m_projectMonitor->isActive()) {
2830 if (m_activeTimeline) {
2831 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2833 clip = item->baseClip();
2837 clip = m_clipMonitor->activeClip();
2840 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2843 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2846 void MainWindow::slotEditClipMarker()
2848 DocClipBase *clip = NULL;
2850 if (m_projectMonitor->isActive()) {
2851 if (m_activeTimeline) {
2852 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2854 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2855 clip = item->baseClip();
2859 clip = m_clipMonitor->activeClip();
2860 pos = m_clipMonitor->position();
2863 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2867 QString id = clip->getId();
2868 QString oldcomment = clip->markerComment(pos);
2869 if (oldcomment.isEmpty()) {
2870 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2874 CommentedTime marker(pos, oldcomment);
2875 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2876 if (d.exec() == QDialog::Accepted) {
2877 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2878 if (d.newMarker().time() != pos) {
2879 // remove old marker
2880 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2885 void MainWindow::slotAddMarkerGuideQuickly()
2887 if (!m_activeTimeline || !m_activeDocument)
2890 if (m_clipMonitor->isActive()) {
2891 DocClipBase *clip = m_clipMonitor->activeClip();
2892 GenTime pos = m_clipMonitor->position();
2895 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2899 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2901 m_activeTimeline->projectView()->slotAddGuide(false);
2905 void MainWindow::slotAddGuide()
2907 if (m_activeTimeline)
2908 m_activeTimeline->projectView()->slotAddGuide();
2911 void MainWindow::slotInsertSpace()
2913 if (m_activeTimeline)
2914 m_activeTimeline->projectView()->slotInsertSpace();
2917 void MainWindow::slotRemoveSpace()
2919 if (m_activeTimeline)
2920 m_activeTimeline->projectView()->slotRemoveSpace();
2923 void MainWindow::slotInsertTrack(int ix)
2925 m_projectMonitor->slotActivateMonitor();
2926 if (m_activeTimeline) {
2927 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2928 m_activeTimeline->projectView()->slotInsertTrack(ix);
2930 if (m_activeDocument)
2931 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2934 void MainWindow::slotDeleteTrack(int ix)
2936 m_projectMonitor->slotActivateMonitor();
2937 if (m_activeTimeline) {
2938 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2939 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2941 if (m_activeDocument)
2942 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2945 void MainWindow::slotConfigTrack(int ix)
2947 m_projectMonitor->slotActivateMonitor();
2948 if (m_activeTimeline)
2949 m_activeTimeline->projectView()->slotConfigTracks(ix);
2950 if (m_activeDocument)
2951 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2954 void MainWindow::slotSelectTrack()
2956 m_projectMonitor->slotActivateMonitor();
2957 if (m_activeTimeline) {
2958 m_activeTimeline->projectView()->slotSelectClipsInTrack();
2962 void MainWindow::slotSelectAllTracks()
2964 m_projectMonitor->slotActivateMonitor();
2965 if (m_activeTimeline)
2966 m_activeTimeline->projectView()->slotSelectAllClips();
2969 void MainWindow::slotEditGuide()
2971 if (m_activeTimeline)
2972 m_activeTimeline->projectView()->slotEditGuide();
2975 void MainWindow::slotDeleteGuide()
2977 if (m_activeTimeline)
2978 m_activeTimeline->projectView()->slotDeleteGuide();
2981 void MainWindow::slotDeleteAllGuides()
2983 if (m_activeTimeline)
2984 m_activeTimeline->projectView()->slotDeleteAllGuides();
2987 void MainWindow::slotCutTimelineClip()
2989 if (m_activeTimeline)
2990 m_activeTimeline->projectView()->cutSelectedClips();
2993 void MainWindow::slotInsertClipOverwrite()
2995 if (m_activeTimeline) {
2996 QStringList data = m_clipMonitor->getZoneInfo();
2997 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
3001 void MainWindow::slotSelectTimelineClip()
3003 if (m_activeTimeline)
3004 m_activeTimeline->projectView()->selectClip(true);
3007 void MainWindow::slotSelectTimelineTransition()
3009 if (m_activeTimeline)
3010 m_activeTimeline->projectView()->selectTransition(true);
3013 void MainWindow::slotDeselectTimelineClip()
3015 if (m_activeTimeline)
3016 m_activeTimeline->projectView()->selectClip(false, true);
3019 void MainWindow::slotDeselectTimelineTransition()
3021 if (m_activeTimeline)
3022 m_activeTimeline->projectView()->selectTransition(false, true);
3025 void MainWindow::slotSelectAddTimelineClip()
3027 if (m_activeTimeline)
3028 m_activeTimeline->projectView()->selectClip(true, true);
3031 void MainWindow::slotSelectAddTimelineTransition()
3033 if (m_activeTimeline)
3034 m_activeTimeline->projectView()->selectTransition(true, true);
3037 void MainWindow::slotGroupClips()
3039 if (m_activeTimeline)
3040 m_activeTimeline->projectView()->groupClips();
3043 void MainWindow::slotUnGroupClips()
3045 if (m_activeTimeline)
3046 m_activeTimeline->projectView()->groupClips(false);
3049 void MainWindow::slotEditItemDuration()
3051 if (m_activeTimeline)
3052 m_activeTimeline->projectView()->editItemDuration();
3055 void MainWindow::slotAddProjectClip(KUrl url, const QString &comment)
3057 if (m_activeDocument)
3058 m_activeDocument->slotAddClipFile(url, QString(), QString(), comment);
3061 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3063 if (m_activeDocument)
3064 m_activeDocument->slotAddClipList(urls, QString());
3067 void MainWindow::slotAddTransition(QAction *result)
3069 if (!result) return;
3070 QStringList info = result->data().toStringList();
3071 if (info.isEmpty()) return;
3072 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3073 if (m_activeTimeline && !transition.isNull()) {
3074 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3078 void MainWindow::slotAddVideoEffect(QAction *result)
3080 if (!result) return;
3081 const int EFFECT_VIDEO = 1;
3082 const int EFFECT_AUDIO = 2;
3083 QStringList info = result->data().toStringList();
3085 if (info.isEmpty() || info.size() < 3) return;
3086 QDomElement effect ;
3087 if (info.last() == QString::number((int) EFFECT_VIDEO))
3088 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3089 else if (info.last() == QString::number((int) EFFECT_AUDIO))
3090 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3092 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3093 if (!effect.isNull()) slotAddEffect(effect);
3094 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3098 void MainWindow::slotZoomIn()
3100 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3101 slotShowZoomSliderToolTip();
3104 void MainWindow::slotZoomOut()
3106 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3107 slotShowZoomSliderToolTip();
3110 void MainWindow::slotFitZoom()
3112 if (m_activeTimeline)
3113 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3116 void MainWindow::slotSetZoom(int value)
3118 value = qMax(m_zoomSlider->minimum(), value);
3119 value = qMin(m_zoomSlider->maximum(), value);
3121 if (m_activeTimeline)
3122 m_activeTimeline->slotChangeZoom(value);
3124 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3125 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3126 slotUpdateZoomSliderToolTip(value);
3128 m_zoomSlider->blockSignals(true);
3129 m_zoomSlider->setValue(value);
3130 m_zoomSlider->blockSignals(false);
3133 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3135 if (zoomlevel != -1)
3136 slotUpdateZoomSliderToolTip(zoomlevel);
3138 QPoint global = m_zoomSlider->rect().topLeft();
3139 global.ry() += m_zoomSlider->height() / 2;
3140 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3141 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3144 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3146 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3149 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3151 m_statusProgressBar->setValue(progress);
3152 if (progress >= 0) {
3153 if (!message.isEmpty())
3154 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3155 m_statusProgressBar->setVisible(true);
3156 } else if (progress == -2) {
3157 if (!message.isEmpty())
3158 m_messageLabel->setMessage(message, ErrorMessage);
3159 m_statusProgressBar->setVisible(false);
3161 m_messageLabel->setMessage(QString(), DefaultMessage);
3162 m_statusProgressBar->setVisible(false);
3166 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3168 if (clip->clipType() == TEXT) {
3169 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3170 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3171 // template text clip
3173 // Get the list of existing templates
3175 filter << "*.kdenlivetitle";
3176 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3178 QDialog *dia = new QDialog(this);
3179 Ui::TemplateClip_UI dia_ui;
3180 dia_ui.setupUi(dia);
3182 const QString templatePath = clip->getProperty("resource");
3183 for (int i = 0; i < templateFiles.size(); ++i) {
3184 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3185 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3187 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3188 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3189 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3190 //warning: setting base directory doesn't work??
3191 KUrl startDir(titlepath);
3192 dia_ui.template_list->fileDialog()->setUrl(startDir);
3193 dia_ui.description->setText(clip->getProperty("description"));
3194 if (dia->exec() == QDialog::Accepted) {
3195 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3196 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3198 QMap <QString, QString> newprops;
3200 if (KUrl(textTemplate).path() != templatePath) {
3201 // The template was changed
3202 newprops.insert("resource", textTemplate);
3205 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3206 newprops.insert("description", dia_ui.description->toPlainText());
3209 QString newtemplate = newprops.value("xmltemplate");
3210 if (newtemplate.isEmpty()) newtemplate = templatePath;
3212 // template modified we need to update xmldata
3213 QString description = newprops.value("description");
3214 if (description.isEmpty()) description = clip->getProperty("description");
3215 else newprops.insert("templatetext", description);
3216 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3217 if (!newprops.isEmpty()) {
3218 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3219 m_activeDocument->commandStack()->push(command);
3225 QString path = clip->getProperty("resource");
3226 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3228 doc.setContent(clip->getProperty("xmldata"));
3229 dia_ui->setXml(doc);
3230 if (dia_ui->exec() == QDialog::Accepted) {
3231 QMap <QString, QString> newprops;
3232 newprops.insert("xmldata", dia_ui->xml().toString());
3233 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3234 // duration changed, we need to update duration
3235 newprops.insert("out", QString::number(dia_ui->outPoint()));
3236 int currentLength = QString(clip->producerProperty("length")).toInt();
3237 if (currentLength <= dia_ui->outPoint())
3238 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3239 else newprops.insert("length", clip->producerProperty("length"));
3241 if (!path.isEmpty()) {
3242 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3243 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) {
3244 // save to external file
3245 dia_ui->saveTitle(path);
3246 } else newprops.insert("resource", QString());
3248 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3249 m_activeDocument->commandStack()->push(command);
3250 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3251 m_activeDocument->setModified(true);
3255 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3259 // any type of clip but a title
3260 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3261 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3262 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3263 connect(dia, SIGNAL(applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)), this, SLOT(slotApplyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)));
3268 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3270 if (newprops.isEmpty()) return;
3271 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3272 m_activeDocument->commandStack()->push(command);
3273 m_activeDocument->setModified();
3276 // update clip occurences in timeline
3277 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3282 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3284 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3285 if (dia.exec() == QDialog::Accepted) {
3286 QUndoCommand *command = new QUndoCommand();
3287 command->setText(i18n("Edit clips"));
3288 QMap <QString, QString> newImageProps = dia.properties();
3289 // Transparency setting applies only for images
3290 QMap <QString, QString> newProps = newImageProps;
3291 newProps.remove("transparency");
3293 for (int i = 0; i < cliplist.count(); i++) {
3294 DocClipBase *clip = cliplist.at(i);
3295 if (clip->clipType() == IMAGE)
3296 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3298 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3300 m_activeDocument->commandStack()->push(command);
3301 for (int i = 0; i < cliplist.count(); i++)
3302 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3306 void MainWindow::customEvent(QEvent* e)
3308 if (e->type() == QEvent::User)
3309 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3312 void MainWindow::slotTimelineClipSelected(ClipItem* item, bool raise)
3314 m_effectStack->slotClipItemSelected(item);
3315 m_projectMonitor->slotSetSelectedClip(item);
3317 m_effectStack->raiseWindow(m_effectStackDock);
3320 void MainWindow::slotTrackSelected(int index, TrackInfo info, bool raise)
3322 m_effectStack->slotTrackItemSelected(index, info);
3324 m_effectStack->raiseWindow(m_effectStackDock);
3327 void MainWindow::slotActivateTransitionView(Transition *t)
3330 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3333 void MainWindow::slotSnapRewind()
3335 if (m_projectMonitor->isActive()) {
3336 if (m_activeTimeline)
3337 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3339 m_clipMonitor->slotSeekToPreviousSnap();
3343 void MainWindow::slotSnapForward()
3345 if (m_projectMonitor->isActive()) {
3346 if (m_activeTimeline)
3347 m_activeTimeline->projectView()->slotSeekToNextSnap();
3349 m_clipMonitor->slotSeekToNextSnap();
3353 void MainWindow::slotClipStart()
3355 if (m_projectMonitor->isActive()) {
3356 if (m_activeTimeline)
3357 m_activeTimeline->projectView()->clipStart();
3361 void MainWindow::slotClipEnd()
3363 if (m_projectMonitor->isActive()) {
3364 if (m_activeTimeline)
3365 m_activeTimeline->projectView()->clipEnd();
3369 void MainWindow::slotZoneStart()
3371 if (m_projectMonitor->isActive())
3372 m_projectMonitor->slotZoneStart();
3374 m_clipMonitor->slotZoneStart();
3377 void MainWindow::slotZoneEnd()
3379 if (m_projectMonitor->isActive())
3380 m_projectMonitor->slotZoneEnd();
3382 m_clipMonitor->slotZoneEnd();
3385 void MainWindow::slotChangeTool(QAction * action)
3387 if (action == m_buttonSelectTool)
3388 slotSetTool(SELECTTOOL);
3389 else if (action == m_buttonRazorTool)
3390 slotSetTool(RAZORTOOL);
3391 else if (action == m_buttonSpacerTool)
3392 slotSetTool(SPACERTOOL);
3395 void MainWindow::slotChangeEdit(QAction * action)
3397 if (!m_activeTimeline)
3400 if (action == m_overwriteEditTool)
3401 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3402 else if (action == m_insertEditTool)
3403 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3405 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3408 void MainWindow::slotSetTool(PROJECTTOOL tool)
3410 if (m_activeDocument && m_activeTimeline) {
3411 //m_activeDocument->setTool(tool);
3415 message = i18n("Ctrl + click to use spacer on current track only");
3418 message = i18n("Click on a clip to cut it");
3421 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3424 m_messageLabel->setMessage(message, InformationMessage);
3425 m_activeTimeline->projectView()->setTool(tool);
3429 void MainWindow::slotCopy()
3431 if (m_activeDocument && m_activeTimeline)
3432 m_activeTimeline->projectView()->copyClip();
3435 void MainWindow::slotPaste()
3437 if (m_activeDocument && m_activeTimeline)
3438 m_activeTimeline->projectView()->pasteClip();
3441 void MainWindow::slotPasteEffects()
3443 if (m_activeDocument && m_activeTimeline)
3444 m_activeTimeline->projectView()->pasteClipEffects();
3447 void MainWindow::slotFind()
3449 if (!m_activeDocument || !m_activeTimeline) return;
3450 m_projectSearch->setEnabled(false);
3451 m_findActivated = true;
3452 m_findString.clear();
3453 m_activeTimeline->projectView()->initSearchStrings();
3454 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3455 m_findTimer.start(5000);
3456 qApp->installEventFilter(this);
3459 void MainWindow::slotFindNext()
3461 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3462 statusBar()->showMessage(i18n("Found: %1", m_findString));
3464 statusBar()->showMessage(i18n("Reached end of project"));
3465 m_findTimer.start(4000);
3468 void MainWindow::findAhead()
3470 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3471 m_projectSearchNext->setEnabled(true);
3472 statusBar()->showMessage(i18n("Found: %1", m_findString));
3474 m_projectSearchNext->setEnabled(false);
3475 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3479 void MainWindow::findTimeout()
3481 m_projectSearchNext->setEnabled(false);
3482 m_findActivated = false;
3483 m_findString.clear();
3484 statusBar()->showMessage(i18n("Find stopped"), 3000);
3485 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3486 m_projectSearch->setEnabled(true);
3487 removeEventFilter(this);
3490 void MainWindow::slotClipInTimeline(const QString &clipId)
3492 if (m_activeTimeline && m_activeDocument) {
3493 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3495 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3496 inTimelineMenu->clear();
3498 QList <QAction *> actionList;
3500 for (int i = 0; i < matching.count(); ++i) {
3501 QString track = QString::number(matching.at(i).track);
3502 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3504 QAction *a = new QAction(track + ": " + start, this);
3505 a->setData(QStringList() << track << start);
3506 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3507 while (j < actionList.count()) {
3508 if (actionList.at(j)->text() > a->text()) break;
3511 actionList.insert(j, a);
3513 inTimelineMenu->addActions(actionList);
3515 if (matching.empty())
3516 inTimelineMenu->setEnabled(false);
3518 inTimelineMenu->setEnabled(true);
3522 void MainWindow::slotClipInProjectTree()
3524 if (m_activeTimeline) {
3525 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3526 if (clipIds.isEmpty())
3528 m_projectListDock->raise();
3529 for (int i = 0; i < clipIds.count(); i++)
3530 m_projectList->selectItemById(clipIds.at(i));
3531 if (m_projectMonitor->isActive())
3532 slotSwitchMonitors();
3536 /*void MainWindow::slotClipToProjectTree()
3538 if (m_activeTimeline) {
3539 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3540 if (clips.isEmpty()) return;
3541 for (int i = 0; i < clips.count(); i++) {
3542 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3544 //m_projectList->selectItemById(clipIds.at(i));
3548 void MainWindow::slotSelectClipInTimeline()
3550 if (m_activeTimeline) {
3551 QAction *action = qobject_cast<QAction *>(sender());
3552 QStringList data = action->data().toStringList();
3553 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3557 void MainWindow::keyPressEvent(QKeyEvent *ke)
3559 if (m_findActivated) {
3560 if (ke->key() == Qt::Key_Backspace) {
3561 m_findString = m_findString.left(m_findString.length() - 1);
3563 if (!m_findString.isEmpty())
3568 m_findTimer.start(4000);
3571 } else if (ke->key() == Qt::Key_Escape) {
3575 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3576 m_findString += ke->text();
3580 m_findTimer.start(4000);
3585 KXmlGuiWindow::keyPressEvent(ke);
3590 /** Gets called when the window gets hidden */
3591 void MainWindow::hideEvent(QHideEvent */*event*/)
3593 if (isMinimized() && m_monitorManager)
3594 m_monitorManager->stopActiveMonitor();
3597 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3599 if (m_findActivated) {
3600 if (event->type() == QEvent::ShortcutOverride) {
3601 QKeyEvent* ke = (QKeyEvent*) event;
3602 if (ke->text().trimmed().isEmpty()) return false;
3609 // pass the event on to the parent class
3610 return QMainWindow::eventFilter(obj, event);
3615 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3617 KDialog *dialog = new KDialog(this);
3618 dialog->setCaption("Save clip zone");
3619 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3621 QWidget *widget = new QWidget(dialog);
3622 dialog->setMainWidget(widget);
3624 QVBoxLayout *vbox = new QVBoxLayout(widget);
3625 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3626 if (path.isEmpty()) {
3627 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3628 if (baseClip == NULL) tmppath.append("untitled.mlt");
3630 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3632 path = KUrl(tmppath);
3634 KUrlRequester *url = new KUrlRequester(path, this);
3635 url->setFilter("video/mlt-playlist");
3636 QLabel *label2 = new QLabel(i18n("Description:"), this);
3637 KLineEdit *edit = new KLineEdit(this);
3638 vbox->addWidget(label1);
3639 vbox->addWidget(url);
3640 vbox->addWidget(label2);
3641 vbox->addWidget(edit);
3642 if (dialog->exec() == QDialog::Accepted) {
3643 if (QFile::exists(url->url().path())) {
3644 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3645 slotSaveZone(render, zone, baseClip, url->url());
3649 if (baseClip && !baseClip->fileURL().isEmpty()) {
3650 // create zone from clip url, so that we don't have problems with proxy clips
3652 #if QT_VERSION >= 0x040600
3653 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3654 env.remove("MLT_PROFILE");
3655 p.setProcessEnvironment(env);
3657 QStringList env = QProcess::systemEnvironment();
3658 env << "MLT_PROFILE='\0'";
3659 p.setEnvironment(env);
3661 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3662 if (!p.waitForStarted(3000)) {
3663 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3665 else if (!p.waitForFinished(5000)) {
3666 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3669 else render->saveZone(url->url(), edit->text(), zone);
3674 void MainWindow::slotSetInPoint()
3676 if (m_clipMonitor->isActive()) {
3677 m_clipMonitor->slotSetZoneStart();
3679 m_projectMonitor->slotSetZoneStart();
3683 void MainWindow::slotSetOutPoint()
3685 if (m_clipMonitor->isActive()) {
3686 m_clipMonitor->slotSetZoneEnd();
3688 m_projectMonitor->slotSetZoneEnd();
3692 void MainWindow::slotResizeItemStart()
3694 if (m_activeTimeline)
3695 m_activeTimeline->projectView()->setInPoint();
3698 void MainWindow::slotResizeItemEnd()
3700 if (m_activeTimeline)
3701 m_activeTimeline->projectView()->setOutPoint();
3704 int MainWindow::getNewStuff(const QString &configFile)
3706 KNS3::Entry::List entries;
3707 #if KDE_IS_VERSION(4,3,80)
3708 KNS3::DownloadDialog dialog(configFile);
3710 entries = dialog.changedEntries();
3711 foreach(const KNS3::Entry & entry, entries) {
3712 if (entry.status() == KNS3::Entry::Installed)
3713 kDebug() << "// Installed files: " << entry.installedFiles();
3716 KNS::Engine engine(0);
3717 if (engine.init(configFile))
3718 entries = engine.downloadDialogModal(this);
3719 foreach(KNS::Entry * entry, entries) {
3720 if (entry->status() == KNS::Entry::Installed)
3721 kDebug() << "// Installed files: " << entry->installedFiles();
3724 return entries.size();
3727 void MainWindow::slotGetNewTitleStuff()
3729 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3730 TitleWidget::refreshTitleTemplates();
3733 void MainWindow::slotGetNewLumaStuff()
3735 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3736 initEffects::refreshLumas();
3737 m_activeTimeline->projectView()->reloadTransitionLumas();
3741 void MainWindow::slotGetNewRenderStuff()
3743 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3745 m_renderWidget->reloadProfiles();
3748 void MainWindow::slotGetNewMltProfileStuff()
3750 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3751 // update the list of profiles in settings dialog
3752 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3758 void MainWindow::slotAutoTransition()
3760 if (m_activeTimeline)
3761 m_activeTimeline->projectView()->autoTransition();
3764 void MainWindow::slotSplitAudio()
3766 if (m_activeTimeline)
3767 m_activeTimeline->projectView()->splitAudio();
3770 void MainWindow::slotUpdateClipType(QAction *action)
3772 if (m_activeTimeline) {
3773 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3774 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3775 else m_activeTimeline->projectView()->setAudioAndVideo();
3779 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3781 // We must stop the monitors since we create a new on in the dvd wizard
3782 m_clipMonitor->stop();
3783 m_projectMonitor->stop();
3784 DvdWizard w(url, profile, this);
3786 m_projectMonitor->start();
3789 void MainWindow::slotShowTimeline(bool show)
3791 if (show == false) {
3792 m_timelineState = saveState();
3793 centralWidget()->setHidden(true);
3795 centralWidget()->setHidden(false);
3796 restoreState(m_timelineState);
3800 void MainWindow::slotMaximizeCurrent(bool)
3802 //TODO: is there a way to maximize current widget?
3804 m_timelineState = saveState();
3805 QWidget *par = focusWidget()->parentWidget();
3806 while (par->parentWidget() && par->parentWidget() != this)
3807 par = par->parentWidget();
3808 kDebug() << "CURRENT WIDGET: " << par->objectName();
3811 void MainWindow::loadStabilize()
3813 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3816 Mlt::Profile profile;
3817 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3818 QAction *action=stabMenu->addAction("Videostab (vstab)");
3819 action->setData("videostab");
3820 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3822 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3823 QAction *action=stabMenu->addAction("Videostab (transcode)");
3824 action->setData("videostab2");
3825 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3832 void MainWindow::loadTranscoders()
3834 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3837 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
3838 extractAudioMenu->clear();
3840 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3841 KConfigGroup transConfig(config, "Transcoding");
3843 QMap< QString, QString > profiles = transConfig.entryMap();
3844 QMapIterator<QString, QString> i(profiles);
3845 while (i.hasNext()) {
3847 QStringList data = i.value().split(";");
3849 // separate audio transcoding in a separate menu
3850 if (data.count() > 2 && data.at(2) == "audio") {
3851 a = extractAudioMenu->addAction(i.key());
3854 a = transMenu->addAction(i.key());
3857 if (data.count() > 1) a->setToolTip(data.at(1));
3858 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3862 void MainWindow::slotStabilize()
3864 QString condition,filtername;
3867 // Stablize selected clips
3868 QAction *action = qobject_cast<QAction *>(sender());
3870 filtername=action->data().toString();
3872 m_projectList->startClipFilterJob(filtername, condition);
3874 if (ids.isEmpty()) {
3875 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3878 QString destination;
3879 ProjectItem *item = m_projectList->getClipById(ids.at(0));
3880 if (ids.count() == 1) {
3883 ClipStabilize *d = new ClipStabilize(destination, ids.count(), filtername);
3884 //connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3885 if (d->exec() == QDialog::Accepted) {
3886 m_projectList->slotStabilizeClipJob(ids, d->autoAddClip(), d->params(), d->desc());
3891 void MainWindow::slotTranscode(KUrl::List urls)
3896 if (urls.isEmpty()) {
3897 QAction *action = qobject_cast<QAction *>(sender());
3898 QStringList data = action->data().toStringList();
3899 params = data.at(0);
3900 if (data.count() > 1) desc = data.at(1);
3901 if (data.count() > 3) condition = data.at(3);
3902 m_projectList->slotTranscodeClipJob(condition, params, desc);
3905 if (urls.isEmpty()) {
3906 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3909 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3910 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3914 void MainWindow::slotTranscodeClip()
3916 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3917 if (urls.isEmpty()) return;
3918 slotTranscode(urls);
3921 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3923 if (m_activeDocument == NULL) return;
3924 QMapIterator<QString, QString> i(props);
3925 while (i.hasNext()) {
3927 m_activeDocument->setDocumentProperty(i.key(), i.value());
3929 m_activeDocument->setModified(true);
3933 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3935 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3937 QString playlistPath;
3940 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3941 QString path = m_renderWidget->getFreeScriptName();
3942 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3943 if (!ok || scriptPath.isEmpty()) return;
3944 scriptPath.prepend(scriptsFolder);
3945 QFile f(scriptPath);
3947 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3950 playlistPath = scriptPath + ".mlt";
3952 KTemporaryFile temp;
3953 temp.setAutoRemove(false);
3954 temp.setSuffix(".mlt");
3956 playlistPath = temp.fileName();
3958 QString playlistContent = m_projectMonitor->sceneList();
3959 if (!chapterFile.isEmpty()) {
3962 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3964 in = m_activeTimeline->inPoint();
3965 out = m_activeTimeline->outPoint();
3968 QDomElement chapters = doc.createElement("chapters");
3969 chapters.setAttribute("fps", m_activeDocument->fps());
3970 doc.appendChild(chapters);
3972 QDomElement guidesxml = m_activeDocument->guidesXml();
3973 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3974 for (int i = 0; i < nodes.count(); i++) {
3975 QDomElement e = nodes.item(i).toElement();
3977 QString comment = e.attribute("comment");
3978 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3979 if (time >= in && time < out) {
3980 if (zoneOnly) time = time - in;
3981 QDomElement chapter = doc.createElement("chapter");
3982 chapters.appendChild(chapter);
3983 chapter.setAttribute("title", comment);
3984 chapter.setAttribute("time", time);
3988 if (chapters.childNodes().count() > 0) {
3989 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3990 // Always insert a guide in pos 0
3991 QDomElement chapter = doc.createElement("chapter");
3992 chapters.insertBefore(chapter, QDomNode());
3993 chapter.setAttribute("title", i18n("Start"));
3994 chapter.setAttribute("time", "0");
3996 // save chapters file
3997 QFile file(chapterFile);
3998 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3999 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4001 file.write(doc.toString().toUtf8());
4002 if (file.error() != QFile::NoError) {
4003 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
4010 if (m_renderWidget->automaticAudioExport()) {
4011 exportAudio = m_activeTimeline->checkProjectAudio();
4012 } else exportAudio = m_renderWidget->selectedAudioExport();
4014 // Set playlist audio volume to 100%
4016 doc.setContent(playlistContent);
4017 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4018 if (!tractor.isNull()) {
4019 QDomNodeList props = tractor.elementsByTagName("property");
4020 for (int i = 0; i < props.count(); i++) {
4021 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4022 props.at(i).firstChild().setNodeValue("1");
4028 // Do we want proxy rendering
4029 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4030 QString root = doc.documentElement().attribute("root");
4032 // replace proxy clips with originals
4033 QMap <QString, QString> proxies = m_projectList->getProxies();
4035 QDomNodeList producers = doc.elementsByTagName("producer");
4036 QString producerResource;
4038 for (uint n = 0; n < producers.length(); n++) {
4039 QDomElement e = producers.item(n).toElement();
4040 producerResource = EffectsList::property(e, "resource");
4041 if (producerResource.isEmpty()) continue;
4042 if (!producerResource.startsWith("/")) {
4043 producerResource.prepend(root + "/");
4045 if (producerResource.contains('?')) {
4046 // slowmotion producer
4047 suffix = "?" + producerResource.section('?', 1);
4048 producerResource = producerResource.section('?', 0, 0);
4050 else suffix.clear();
4051 if (!producerResource.isEmpty()) {
4052 if (proxies.contains(producerResource)) {
4053 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4054 // We need to delete the "aspect_ratio" property because proxy clips
4055 // sometimes have different ratio than original clips
4056 EffectsList::removeProperty(e, "aspect_ratio");
4057 EffectsList::removeMetaProperties(e);
4062 /*QMapIterator<QString, QString> i(proxies);
4063 while (i.hasNext()) {
4065 // Replace all keys with their values (proxy path with original path)
4066 QString key = i.key();
4067 playlistContent.replace(key, i.value());
4068 if (!root.isEmpty() && key.startsWith(root)) {
4069 // in case the resource path in MLT playlist is relative
4070 key.remove(0, root.count() + 1);
4071 playlistContent.replace(key, i.value());
4075 playlistContent = doc.toString();
4077 // Do save scenelist
4078 QFile file(playlistPath);
4079 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4080 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4083 file.write(playlistContent.toUtf8());
4084 if (file.error() != QFile::NoError) {
4085 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4090 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4093 void MainWindow::slotUpdateTimecodeFormat(int ix)
4095 KdenliveSettings::setFrametimecode(ix == 1);
4096 m_clipMonitor->updateTimecodeFormat();
4097 m_projectMonitor->updateTimecodeFormat();
4098 m_transitionConfig->updateTimecodeFormat();
4099 m_effectStack->updateTimecodeFormat();
4100 //m_activeTimeline->projectView()->clearSelection();
4101 m_activeTimeline->updateRuler();
4104 void MainWindow::slotRemoveFocus()
4106 statusBar()->setFocus();
4107 statusBar()->clearFocus();
4110 void MainWindow::slotRevert()
4112 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;
4113 KUrl url = m_activeDocument->url();
4114 if (closeCurrentDocument(false))
4115 doOpenFile(url, NULL);
4119 void MainWindow::slotShutdown()
4121 if (m_activeDocument) m_activeDocument->setModified(false);
4123 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4124 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4125 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4126 smserver.call("logout", 1, 2, 2);
4127 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4128 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4129 smserver.call("Shutdown");
4133 void MainWindow::slotUpdateTrackInfo()
4135 if (m_activeDocument)
4136 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4139 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4141 // Load the theme file
4143 if (action == NULL) theme = themename;
4144 else theme = action->data().toString();
4145 KdenliveSettings::setColortheme(theme);
4146 // Make palette for all widgets.
4147 QPalette plt = kapp->palette();
4148 if (theme.isEmpty()) {
4149 plt = QApplication::desktop()->palette();
4151 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4153 #if KDE_IS_VERSION(4,6,3)
4154 plt = KGlobalSettings::createNewApplicationPalette(config);
4156 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4157 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4158 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4159 QPalette::Disabled };
4160 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4161 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4163 for ( int i = 0; i < 3 ; i++ ) {
4164 QPalette::ColorGroup state = states[i];
4165 KColorScheme schemeView(state, KColorScheme::View, config);
4166 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4167 KColorScheme schemeButton(state, KColorScheme::Button, config);
4168 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4170 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4171 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4172 plt.setBrush( state, QPalette::Base, schemeView.background() );
4173 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4174 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4175 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4176 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4177 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4178 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4179 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4181 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4182 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4183 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4184 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4185 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4187 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4188 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4189 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4194 kapp->setPalette(plt);
4195 slotChangePalette();
4196 const QObjectList children = statusBar()->children();
4198 foreach(QObject * child, children) {
4199 if (child->isWidgetType())
4200 ((QWidget*)child)->setPalette(plt);
4201 const QObjectList subchildren = child->children();
4202 foreach(QObject * subchild, subchildren) {
4203 if (subchild->isWidgetType())
4204 ((QWidget*)subchild)->setPalette(plt);
4210 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4212 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4213 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4214 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4215 const QSize bitsSize(24, 2);
4216 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4217 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4219 QPixmap pixmap(23, 16);
4220 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4222 KConfigGroup group(config, "WM");
4223 QPainter p(&pixmap);
4224 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4225 p.fillRect(1, 1, 7, 7, windowScheme.background());
4226 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4228 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4229 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4230 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4232 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4233 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4235 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4236 p.fillRect(1, 8, 7, 7, viewScheme.background());
4237 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4239 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4240 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4241 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4243 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4244 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4250 void MainWindow::slotSwitchMonitors()
4252 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4253 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4254 else m_projectList->focusTree();
4257 void MainWindow::slotInsertZoneToTree()
4259 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4260 QStringList info = m_clipMonitor->getZoneInfo();
4261 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4264 void MainWindow::slotInsertZoneToTimeline()
4266 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4267 QStringList info = m_clipMonitor->getZoneInfo();
4268 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4272 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4274 if (m_activeDocument && m_activeTimeline) {
4275 if (!ids.isEmpty()) {
4276 for (int i = 0; i < ids.size(); ++i) {
4277 m_activeTimeline->slotDeleteClip(ids.at(i));
4279 m_activeDocument->clipManager()->slotDeleteClips(ids);
4281 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4282 m_activeDocument->setModified(true);
4286 void MainWindow::slotShowTitleBars(bool show)
4288 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4289 for (int i = 0; i < docks.count(); i++) {
4290 QDockWidget* dock = docks.at(i);
4292 dock->setTitleBarWidget(0);
4294 if (!dock->isFloating()) {
4295 dock->setTitleBarWidget(new QWidget);
4299 KdenliveSettings::setShowtitlebars(show);
4302 void MainWindow::slotSwitchTitles()
4304 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4307 QString MainWindow::getMimeType(bool open)
4309 QString mimetype = "application/x-kdenlive";
4310 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4312 mimetype = "*.kdenlive";
4313 if (open) mimetype.append(" *.tar.gz");
4315 else if (open) mimetype.append(" application/x-compressed-tar");
4319 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4322 m_projectMonitor->render->sendFrameForAnalysis = true;
4325 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4326 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4333 qDebug() << "Any scope accepting new frames? " << request;
4336 m_projectMonitor->render->sendFrameForAnalysis = false;
4341 void MainWindow::slotOpenStopmotion()
4343 if (m_stopmotion == NULL) {
4344 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4345 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4346 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4347 // Check if we need the renderer to send a new frame for update
4348 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4349 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4350 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4353 m_stopmotion->show();
4356 void MainWindow::slotDeleteClip(const QString &id)
4358 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4359 for (int i = 0; i < list.size(); ++i) {
4360 list.at(i)->disableClipId(id);
4362 m_projectList->slotDeleteClip(id);
4365 void MainWindow::slotUpdateProxySettings()
4367 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4368 if (KdenliveSettings::enableproxy())
4369 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4370 m_projectList->updateProxyConfig();
4373 void MainWindow::slotInsertNotesTimecode()
4375 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4376 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4377 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4380 void MainWindow::slotArchiveProject()
4382 QList <DocClipBase*> list = m_projectList->documentClipList();
4383 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4384 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4389 void MainWindow::slotOpenBackupDialog(const KUrl url)
4394 kDebug()<<"// BACKUP URL: "<<url.path();
4395 if (!url.isEmpty()) {
4396 // we could not open the project file, guess where the backups are
4397 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4401 projectFolder = m_activeDocument->projectFolder();
4402 projectFile = m_activeDocument->url();
4403 projectId = m_activeDocument->getDocumentProperty("documentid");
4406 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4407 if (dia->exec() == QDialog::Accepted) {
4408 QString requestedBackup = dia->selectedFile();
4409 m_activeDocument->backupLastSavedVersion(projectFile.path());
4410 closeCurrentDocument(false);
4411 doOpenFile(KUrl(requestedBackup), NULL);
4412 m_activeDocument->setUrl(projectFile);
4413 m_activeDocument->setModified(true);
4414 setCaption(m_activeDocument->description());
4419 void MainWindow::slotElapsedTime()
4421 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4425 void MainWindow::slotDownloadResources()
4427 QString currentFolder;
4428 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4429 else currentFolder = KdenliveSettings::defaultprojectfolder();
4430 ResourceWidget *d = new ResourceWidget(currentFolder);
4431 connect(d, SIGNAL(addClip(KUrl, const QString &)), this, SLOT(slotAddProjectClip(KUrl, const QString &)));
4435 void MainWindow::slotChangePalette()
4437 QPalette plt = QApplication::palette();
4438 if (m_effectStack) m_effectStack->updatePalette();
4439 if (m_projectList) m_projectList->updatePalette();
4440 if (m_effectList) m_effectList->updatePalette();
4442 if (m_clipMonitor) m_clipMonitor->setPalette(plt);
4443 if (m_projectMonitor) m_projectMonitor->setPalette(plt);
4445 setStatusBarStyleSheet(plt);
4446 if (m_activeTimeline) {
4447 m_activeTimeline->updatePalette();
4451 void MainWindow::slotSaveTimelineClip()
4453 if (m_activeTimeline && m_projectMonitor->render) {
4454 ClipItem *clip = m_activeTimeline->projectView()->getActiveClipUnderCursor(true);
4456 m_messageLabel->setMessage(i18n("Select a clip to save"), InformationMessage);
4459 KUrl url = KFileDialog::getSaveUrl(m_activeDocument->projectFolder(), "video/mlt-playlist");
4460 if (!url.isEmpty()) m_projectMonitor->render->saveClip(m_activeDocument->tracksCount() - clip->track(), clip->startPos(), url);
4465 #include "mainwindow.moc"