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),
148 m_renderWidget(NULL),
149 #ifdef USE_JOGSHUTTLE
153 m_findActivated(false),
156 qRegisterMetaType<QVector<int16_t> > ();
157 qRegisterMetaType<stringMap> ("stringMap");
158 qRegisterMetaType<audioByteArray> ("audioByteArray");
161 QLocale systemLocale = QLocale();
162 setlocale(LC_NUMERIC, NULL);
163 char *separator = localeconv()->decimal_point;
164 if (separator != systemLocale.decimalPoint()) {
165 kDebug()<<"------\n!!! system locale is not similar to Qt's locale... be prepared for bugs!!!\n------";
166 // HACK: There is a locale conflict, so set locale to at least have correct decimal point
167 if (strncmp(separator, ".", 1) == 0) systemLocale = QLocale::c();
168 else if (strncmp(separator, ",", 1) == 0) systemLocale = QLocale("fr_FR.UTF-8");
171 systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
172 QLocale::setDefault(systemLocale);
174 // Create DBus interface
175 new MainWindowAdaptor(this);
176 QDBusConnection dbus = QDBusConnection::sessionBus();
177 dbus.registerObject("/MainWindow", this);
179 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
180 setFont(KGlobalSettings::toolBarFont());
181 parseProfiles(MltPath);
182 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
183 m_commandStack = new QUndoGroup;
184 setDockNestingEnabled(true);
185 m_timelineArea = new KTabWidget(this);
186 m_timelineArea->setTabReorderingEnabled(true);
187 m_timelineArea->setTabBarHidden(true);
188 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
189 m_timelineArea->setMinimumHeight(200);
191 QToolButton *closeTabButton = new QToolButton;
192 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
193 closeTabButton->setIcon(KIcon("tab-close"));
194 closeTabButton->adjustSize();
195 closeTabButton->setToolTip(i18n("Close the current tab"));
196 m_timelineArea->setCornerWidget(closeTabButton);
197 //connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
199 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
200 m_findTimer.setSingleShot(true);
202 // FIXME: the next call returns a newly allocated object, which leaks
203 initEffects::parseEffectFiles();
204 //initEffects::parseCustomEffectsFile();
206 m_monitorManager = new MonitorManager();
208 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
209 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
214 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
215 m_projectListDock->setObjectName("project_tree");
216 m_projectList = new ProjectList();
217 m_projectListDock->setWidget(m_projectList);
218 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
220 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
221 m_clipMonitorDock->setObjectName("clip_monitor");
222 m_clipMonitor = new Monitor(Kdenlive::clipMonitor, m_monitorManager, QString(), m_timelineArea);
223 m_clipMonitorDock->setWidget(m_clipMonitor);
225 // Connect the project list
226 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint, bool)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool)));
227 connect(m_projectList, SIGNAL(raiseClipMonitor()), m_clipMonitor, SLOT(slotActivateMonitor()));
228 connect(m_projectList, SIGNAL(loadingIsOver()), this, SLOT(slotElapsedTime()));
229 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
230 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
231 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&)),this, SLOT(slotUpdateClip(const QString &)));
232 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
233 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor(const QString &)));
234 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
235 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
236 connect(m_clipMonitor, SIGNAL(extractZone(const QString &, QPoint)), m_projectList, SLOT(slotCutClipJob(const QString &, QPoint)));
238 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
239 m_projectMonitorDock->setObjectName("project_monitor");
240 m_projectMonitor = new Monitor(Kdenlive::projectMonitor, m_monitorManager, QString());
241 m_projectMonitorDock->setWidget(m_projectMonitor);
244 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
245 m_recMonitorDock->setObjectName("record_monitor");
246 m_recMonitor = new RecMonitor(Kdenlive::recordMonitor, m_monitorManager);
247 m_recMonitorDock->setWidget(m_recMonitor);
248 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
249 connect(m_recMonitor, SIGNAL(addProjectClipList(KUrl::List)), this, SLOT(slotAddProjectClipList(KUrl::List)));
250 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
252 #endif /* ! Q_WS_MAC */
253 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor, m_recMonitor);
255 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
256 m_notesDock->setObjectName("notes_widget");
257 m_notesWidget = new NotesWidget();
258 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
259 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
261 m_notesWidget->setTabChangesFocus(true);
262 #if KDE_IS_VERSION(4,4,0)
263 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
265 m_notesDock->setWidget(m_notesWidget);
266 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
268 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
269 m_effectStackDock->setObjectName("effect_stack");
270 m_effectStack = new EffectStackView2(m_projectMonitor);
271 m_effectStackDock->setWidget(m_effectStack);
272 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
273 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&)));
275 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
276 m_transitionConfigDock->setObjectName("transition");
277 m_transitionConfig = new TransitionSettings(m_projectMonitor);
278 m_transitionConfigDock->setWidget(m_transitionConfig);
279 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
281 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
282 m_effectListDock->setObjectName("effect_list");
283 m_effectList = new EffectsListView();
284 m_effectListDock->setWidget(m_effectList);
285 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
287 m_scopeManager = new ScopeManager(m_monitorManager);
288 m_vectorscope = new Vectorscope();
289 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
290 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
291 m_vectorscopeDock->setWidget(m_vectorscope);
292 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
293 m_scopeManager->addScope(m_vectorscope, m_vectorscopeDock);
295 m_waveform = new Waveform();
296 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
297 m_waveformDock->setObjectName(m_waveform->widgetName());
298 m_waveformDock->setWidget(m_waveform);
299 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
300 m_scopeManager->addScope(m_waveform, m_waveformDock);
302 m_RGBParade = new RGBParade();
303 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
304 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
305 m_RGBParadeDock->setWidget(m_RGBParade);
306 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
307 m_scopeManager->addScope(m_RGBParade, m_RGBParadeDock);
309 m_histogram = new Histogram();
310 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
311 m_histogramDock->setObjectName(m_histogram->widgetName());
312 m_histogramDock->setWidget(m_histogram);
313 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
314 m_scopeManager->addScope(m_histogram, m_histogramDock);
316 m_audiosignal = new AudioSignal;
317 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
318 m_audiosignalDock->setObjectName("audiosignal");
319 m_audiosignalDock->setWidget(m_audiosignal);
320 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
321 m_scopeManager->addScope(m_audiosignal, m_audiosignalDock);
323 m_audioSpectrum = new AudioSpectrum();
324 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
325 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
326 m_audioSpectrumDock->setWidget(m_audioSpectrum);
327 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
328 m_scopeManager->addScope(m_audioSpectrum, m_audioSpectrumDock);
330 m_spectrogram = new Spectrogram();
331 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
332 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
333 m_spectrogramDock->setWidget(m_spectrogram);
334 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
335 m_scopeManager->addScope(m_spectrogram, m_spectrogramDock);
337 // Add monitors here to keep them at the right of the window
338 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
339 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
341 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
344 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
345 m_undoViewDock->setObjectName("undo_history");
346 m_undoView = new QUndoView();
347 m_undoView->setCleanIcon(KIcon("edit-clear"));
348 m_undoView->setEmptyLabel(i18n("Clean"));
349 m_undoViewDock->setWidget(m_undoView);
350 m_undoView->setGroup(m_commandStack);
351 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
355 connect(m_commandStack, SIGNAL(cleanChanged(bool)), m_saveAction, SLOT(setDisabled(bool)));
358 // Close non-general docks for the initial layout
359 // only show important ones
360 m_histogramDock->close();
361 m_RGBParadeDock->close();
362 m_waveformDock->close();
363 m_vectorscopeDock->close();
365 m_audioSpectrumDock->close();
366 m_spectrogramDock->close();
367 m_audiosignalDock->close();
369 m_undoViewDock->close();
373 /// Tabify Widgets ///
374 tabifyDockWidget(m_effectListDock, m_effectStackDock);
375 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
376 tabifyDockWidget(m_projectListDock, m_notesDock);
378 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
380 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
382 setCentralWidget(m_timelineArea);
384 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
386 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
387 m_fileRevert->setEnabled(false);
389 // Prepare layout actions
390 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
391 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
392 for (int i = 1; i < 5; i++) {
393 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
394 load->setData("_" + QString::number(i));
395 layoutActions->addAction("load_layout" + QString::number(i), load);
396 m_loadLayout->addAction(load);
397 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
398 save->setData("_" + QString::number(i));
399 layoutActions->addAction("save_layout" + QString::number(i), save);
401 layoutActions->addAction("load_layouts", m_loadLayout);
402 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
405 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
406 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
407 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
408 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
409 m_stopmotion_actions->addAction("stopmotion_capture", action);
410 action = new KAction(i18n("Switch live / captured frame"), this);
411 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
412 m_stopmotion_actions->addAction("stopmotion_switch", action);
413 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
414 action->setCheckable(true);
415 action->setChecked(false);
416 m_stopmotion_actions->addAction("stopmotion_overlay", action);
418 // Build effects menu
419 m_effectsMenu = new QMenu(i18n("Add Effect"));
420 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
421 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
422 m_effectsActionCollection->readSettings();
426 // Find QDockWidget tab bars and show / hide widget title bars on right click
427 QList <QTabBar *> tabs = findChildren<QTabBar *>();
428 for (int i = 0; i < tabs.count(); i++) {
429 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
430 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
433 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
434 guiFactory()->addClient(sp);*/
435 QMenu *trackMenu = (QMenu*)(factory()->container("track_menu", this));
436 if (trackMenu) trackMenu->addActions(m_tracksActionCollection->actions());
439 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
441 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
444 // Load layout names from config file
451 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
452 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
454 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
455 clipInTimeline->setIcon(KIcon("go-jump"));
456 QHash<QString,QMenu*> menus;
457 menus.insert("addMenu",static_cast<QMenu*>(factory()->container("generators", this)));
458 menus.insert("extractAudioMenu",static_cast<QMenu*>(factory()->container("extract_audio", this)));
459 menus.insert("transcodeMenu",static_cast<QMenu*>(factory()->container("transcoders", this)));
460 menus.insert("stabilizeMenu",static_cast<QMenu*>(factory()->container("stabilize", this)));
461 menus.insert("inTimelineMenu",clipInTimeline);
462 m_projectList->setupGeneratorMenu(menus);
464 // build themes menus
465 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
466 QActionGroup *themegroup = new QActionGroup(this);
467 themegroup->setExclusive(true);
468 action = new KAction(i18n("Default"), this);
469 action->setCheckable(true);
470 themegroup->addAction(action);
471 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
473 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
475 for (int i = 0; i < schemeFiles.size(); ++i) {
477 const QString filename = schemeFiles.at(i);
478 const QFileInfo info(filename);
481 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
482 QIcon icon = createSchemePreviewIcon(config);
483 KConfigGroup group(config, "General");
484 const QString name = group.readEntry("Name", info.baseName());
485 action = new KAction(name, this);
486 action->setData(filename);
487 action->setIcon(icon);
488 action->setCheckable(true);
489 themegroup->addAction(action);
490 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
493 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
494 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
495 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
498 action = new QAction(fi.fileName(), this);
499 action->setData(*it);
500 action->setCheckable(true);
501 themegroup->addAction(action);
502 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
504 themesMenu->addActions(themegroup->actions());
505 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
507 // Setup and fill effects and transitions menus.
510 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
511 m->addActions(m_effectsMenu->actions());
514 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
515 for (int i = 0; i < transitions.count(); ++i)
516 m_transitionsMenu->addAction(m_transitions[i]);
518 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
519 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
520 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
522 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
523 const QList<QAction *> viewActions = createPopupMenu()->actions();
524 viewMenu->insertActions(NULL, viewActions);
526 m_timelineContextMenu = new QMenu(this);
527 m_timelineContextClipMenu = new QMenu(this);
528 m_timelineContextTransitionMenu = new QMenu(this);
530 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
531 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
532 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
534 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
535 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
536 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
537 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
538 m_timelineContextClipMenu->addSeparator();
539 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
540 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
541 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
542 m_timelineContextClipMenu->addSeparator();
543 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
544 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
545 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
546 m_timelineContextClipMenu->addSeparator();
548 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
549 m_timelineContextClipMenu->addMenu(markersMenu);
550 m_timelineContextClipMenu->addSeparator();
551 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
552 m_timelineContextClipMenu->addMenu(m_effectsMenu);
554 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
555 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
556 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
558 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
560 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
561 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
562 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
563 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
565 slotConnectMonitors();
567 // Open or create a file. Command line argument passed in Url has
568 // precedence, then "openlastproject", then just a plain empty file.
569 // If opening Url fails, openlastproject will _not_ be used.
570 if (!Url.isEmpty()) {
571 // delay loading so that the window shows up
573 QTimer::singleShot(500, this, SLOT(openFile()));
574 } else if (KdenliveSettings::openlastproject()) {
575 QTimer::singleShot(500, this, SLOT(openLastFile()));
576 } else { //if (m_timelineArea->count() == 0) {
580 if (!clipsToLoad.isEmpty() && m_activeDocument) {
581 QStringList list = clipsToLoad.split(',');
583 foreach(QString path, list) {
584 kDebug() << QDir::current().absoluteFilePath(path);
585 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
587 m_projectList->slotAddClip(urls);
590 #ifdef USE_JOGSHUTTLE
591 activateShuttleDevice();
593 m_projectListDock->raise();
595 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
596 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
598 // Populate encoding profiles
599 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
600 if (KdenliveSettings::proxyparams().isEmpty() || KdenliveSettings::proxyextension().isEmpty()) {
601 KConfigGroup group(&conf, "proxy");
602 QMap< QString, QString > values = group.entryMap();
603 QMapIterator<QString, QString> i(values);
606 QString data = i.value();
607 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
608 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
611 if (KdenliveSettings::v4l_parameters().isEmpty() || KdenliveSettings::v4l_extension().isEmpty()) {
612 KConfigGroup group(&conf, "video4linux");
613 QMap< QString, QString > values = group.entryMap();
614 QMapIterator<QString, QString> i(values);
617 QString data = i.value();
618 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
619 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
622 if (KdenliveSettings::decklink_parameters().isEmpty() || KdenliveSettings::decklink_extension().isEmpty()) {
623 KConfigGroup group(&conf, "decklink");
624 QMap< QString, QString > values = group.entryMap();
625 QMapIterator<QString, QString> i(values);
628 QString data = i.value();
629 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
630 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
635 MainWindow::~MainWindow()
640 m_effectStack->slotClipItemSelected(NULL, 0);
641 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
643 if (m_projectMonitor) m_projectMonitor->stop();
644 if (m_clipMonitor) m_clipMonitor->stop();
646 delete m_activeTimeline;
647 delete m_effectStack;
648 delete m_transitionConfig;
649 delete m_activeDocument;
650 delete m_projectMonitor;
651 delete m_clipMonitor;
652 delete m_shortcutRemoveFocus;
653 delete[] m_transitions;
654 delete m_monitorManager;
655 delete m_scopeManager;
656 Mlt::Factory::close();
660 bool MainWindow::queryClose()
662 if (m_renderWidget) {
663 int waitingJobs = m_renderWidget->waitingJobsCount();
664 if (waitingJobs > 0) {
665 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")))) {
666 case KMessageBox::Yes :
667 // create script with waiting jobs and start it
668 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
670 case KMessageBox::No :
671 // Don't do anything, jobs will be deleted
679 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
680 // warn the user to save if document is modified and we have clips in our project list
681 if (m_activeDocument && m_activeDocument->isModified() &&
682 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
683 !m_projectList->documentClipList().isEmpty())) {
687 if (m_activeDocument->url().fileName().isEmpty())
688 message = i18n("Save changes to document?");
690 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
691 switch (KMessageBox::warningYesNoCancel(this, message)) {
692 case KMessageBox::Yes :
693 // save document here. If saving fails, return false;
695 case KMessageBox::No :
696 // User does not want to save the changes, clear recovery files
697 m_activeDocument->m_autosave->resize(0);
706 void MainWindow::loadPlugins()
708 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
709 populateMenus(plugin);
712 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
714 filters << "libkdenlive*";
715 foreach(const QString & folder, directories) {
716 kDebug() << "Parsing plugin folder: " << folder;
717 QDir pluginsDir(folder);
718 foreach(const QString & fileName,
719 pluginsDir.entryList(filters, QDir::Files)) {
721 * Avoid loading the same plugin twice when there is more than one
724 if (!m_pluginFileNames.contains(fileName)) {
725 kDebug() << "Found plugin: " << fileName;
726 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
727 QObject *plugin = loader.instance();
729 populateMenus(plugin);
730 m_pluginFileNames += fileName;
732 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
738 void MainWindow::populateMenus(QObject *plugin)
740 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
741 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
743 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
747 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
748 QMenu *menu, const char *member,
749 QActionGroup *actionGroup)
751 kDebug() << "// ADD to MENU" << texts;
752 foreach(const QString & text, texts) {
753 QAction *action = new QAction(text, plugin);
754 action->setData(text);
755 connect(action, SIGNAL(triggered()), this, member);
756 menu->addAction(action);
759 action->setCheckable(true);
760 actionGroup->addAction(action);
765 void MainWindow::aboutPlugins()
767 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
772 void MainWindow::generateClip()
774 QAction *action = qobject_cast<QAction *>(sender());
775 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
777 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
778 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
779 if (!clipUrl.isEmpty()) {
780 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
784 void MainWindow::saveProperties(KConfigGroup &config)
786 // save properties here,used by session management
788 KMainWindow::saveProperties(config);
792 void MainWindow::readProperties(const KConfigGroup &config)
794 // read properties here,used by session management
795 KMainWindow::readProperties(config);
796 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
797 openFile(KUrl(Lastproject));
800 void MainWindow::slotReloadEffects()
802 initEffects::parseCustomEffectsFile();
803 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
806 #ifdef USE_JOGSHUTTLE
807 void MainWindow::activateShuttleDevice()
813 if (KdenliveSettings::enableshuttle() == false) return;
815 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
816 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
818 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
819 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
820 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
821 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
822 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
824 #endif /* USE_JOGSHUTTLE */
826 void MainWindow::slotDoAction(const QString& action_name)
828 QAction* action = actionCollection()->action(action_name);
830 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
836 void MainWindow::configureNotifications()
838 KNotifyConfigWidget::configure(this);
841 void MainWindow::slotFullScreen()
843 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
846 void MainWindow::slotAddEffect(const QDomElement effect)
848 if (!m_activeDocument) return;
849 if (effect.isNull()) {
850 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
853 QDomElement effectToAdd = effect.cloneNode().toElement();
855 int ix = m_effectStack->isTrackMode(&ok);
856 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
857 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
860 void MainWindow::slotUpdateClip(const QString &id)
862 if (!m_activeDocument) return;
863 DocClipBase *clip = m_activeDocument->clipManager()->getClipById(id);
865 if (clip->numReferences() > 0) m_activeTimeline->projectView()->slotUpdateClip(id);
866 if (m_clipMonitor->activeClip() && m_clipMonitor->activeClip()->getId() == id) {
867 Mlt::Producer *monitorProducer = clip->getCloneProducer();
868 m_clipMonitor->updateClipProducer(monitorProducer);
870 clip->cleanupProducers();
873 void MainWindow::slotConnectMonitors()
875 m_projectList->setRenderer(m_projectMonitor->render);
876 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
877 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
878 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
879 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QString &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QString &, int, int)));
880 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QImage &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QImage &)));
881 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)));
883 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
885 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
887 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
889 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
890 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
892 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
894 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
895 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint, DocClipBase *)), this, SLOT(slotSaveZone(Render *, QPoint, DocClipBase *)));
898 void MainWindow::slotAdjustClipMonitor()
900 m_clipMonitorDock->updateGeometry();
901 m_clipMonitorDock->adjustSize();
902 m_clipMonitor->resetSize();
905 void MainWindow::slotAdjustProjectMonitor()
907 m_projectMonitorDock->updateGeometry();
908 m_projectMonitorDock->adjustSize();
909 m_projectMonitor->resetSize();
913 class NameGrabbingKActionCollection {
915 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
916 : m_collection(collection), m_action_names(action_names) {
917 m_action_names.clear();
919 KAction* addAction(const QString& action_name) {
920 m_action_names << action_name;
921 return m_collection->addAction(action_name);
923 void addAction(const QString& action_name, QAction* action) {
924 m_action_names << action_name;
925 m_collection->addAction(action_name, action);
927 operator KActionCollection*() { return m_collection; }
928 const QStringList& actionNames() const { return m_action_names; }
930 KActionCollection* m_collection;
931 QStringList& m_action_names;
934 void MainWindow::setupActions()
937 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
938 m_timecodeFormat = new KComboBox(this);
939 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
940 m_timecodeFormat->addItem(i18n("Frames"));
941 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
942 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
944 m_statusProgressBar = new QProgressBar(this);
945 m_statusProgressBar->setMinimum(0);
946 m_statusProgressBar->setMaximum(100);
947 m_statusProgressBar->setMaximumWidth(150);
948 m_statusProgressBar->setVisible(false);
950 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
951 toolbar->setMovable(false);
952 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
953 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
954 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
955 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
956 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
957 QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
958 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
960 //create edit mode buttons
961 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
962 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
963 toolbar->addAction(m_normalEditTool);
964 m_normalEditTool->setCheckable(true);
965 m_normalEditTool->setChecked(true);
967 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
968 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
969 toolbar->addAction(m_overwriteEditTool);
970 m_overwriteEditTool->setCheckable(true);
971 m_overwriteEditTool->setChecked(false);
973 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
974 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
975 toolbar->addAction(m_insertEditTool);
976 m_insertEditTool->setCheckable(true);
977 m_insertEditTool->setChecked(false);
978 // not implemented yet
979 m_insertEditTool->setEnabled(false);
981 QActionGroup *editGroup = new QActionGroup(this);
982 editGroup->addAction(m_normalEditTool);
983 editGroup->addAction(m_overwriteEditTool);
984 editGroup->addAction(m_insertEditTool);
985 editGroup->setExclusive(true);
986 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
987 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
989 toolbar->addSeparator();
991 // create tools buttons
992 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
993 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
994 toolbar->addAction(m_buttonSelectTool);
995 m_buttonSelectTool->setCheckable(true);
996 m_buttonSelectTool->setChecked(true);
998 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
999 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
1000 toolbar->addAction(m_buttonRazorTool);
1001 m_buttonRazorTool->setCheckable(true);
1002 m_buttonRazorTool->setChecked(false);
1004 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
1005 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
1006 toolbar->addAction(m_buttonSpacerTool);
1007 m_buttonSpacerTool->setCheckable(true);
1008 m_buttonSpacerTool->setChecked(false);
1010 QActionGroup *toolGroup = new QActionGroup(this);
1011 toolGroup->addAction(m_buttonSelectTool);
1012 toolGroup->addAction(m_buttonRazorTool);
1013 toolGroup->addAction(m_buttonSpacerTool);
1014 toolGroup->setExclusive(true);
1015 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
1017 QWidget * actionWidget;
1018 int max = toolbar->iconSizeDefault() + 2;
1019 actionWidget = toolbar->widgetForAction(m_normalEditTool);
1020 actionWidget->setMaximumWidth(max);
1021 actionWidget->setMaximumHeight(max - 4);
1023 actionWidget = toolbar->widgetForAction(m_insertEditTool);
1024 actionWidget->setMaximumWidth(max);
1025 actionWidget->setMaximumHeight(max - 4);
1027 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
1028 actionWidget->setMaximumWidth(max);
1029 actionWidget->setMaximumHeight(max - 4);
1031 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
1032 actionWidget->setMaximumWidth(max);
1033 actionWidget->setMaximumHeight(max - 4);
1035 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1036 actionWidget->setMaximumWidth(max);
1037 actionWidget->setMaximumHeight(max - 4);
1039 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1040 actionWidget->setMaximumWidth(max);
1041 actionWidget->setMaximumHeight(max - 4);
1043 toolbar->setStyleSheet(style1);
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* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1396 collection.addAction("clip_in_project_tree", clipInProjectTree);
1397 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1399 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1400 collection.addAction("clip_to_project_tree", clipToProjectTree);
1401 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1403 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1404 insertOvertwrite->setShortcut(Qt::Key_V);
1405 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1406 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1408 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1409 selectTimelineClip->setShortcut(Qt::Key_Plus);
1410 collection.addAction("select_timeline_clip", selectTimelineClip);
1411 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1413 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1414 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1415 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1416 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1418 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1419 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1420 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1421 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1423 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1424 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1425 collection.addAction("select_timeline_transition", selectTimelineTransition);
1426 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1428 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1429 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1430 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1431 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1433 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1434 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1435 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1436 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1438 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1439 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1440 collection.addAction("cut_timeline_clip", cutTimelineClip);
1441 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1443 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1444 collection.addAction("add_clip_marker", addClipMarker);
1445 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1447 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1448 collection.addAction("delete_clip_marker", deleteClipMarker);
1449 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1451 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1452 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1453 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1455 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1456 editClipMarker->setData(QString("edit_marker"));
1457 collection.addAction("edit_clip_marker", editClipMarker);
1458 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1460 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1461 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1462 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1463 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1465 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1466 collection.addAction("split_audio", splitAudio);
1467 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1469 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1470 collection.addAction("clip_audio_only", audioOnly);
1471 audioOnly->setData("clip_audio_only");
1472 audioOnly->setCheckable(true);
1474 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1475 collection.addAction("clip_video_only", videoOnly);
1476 videoOnly->setData("clip_video_only");
1477 videoOnly->setCheckable(true);
1479 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1480 collection.addAction("clip_audio_and_video", audioAndVideo);
1481 audioAndVideo->setData("clip_audio_and_video");
1482 audioAndVideo->setCheckable(true);
1484 m_clipTypeGroup = new QActionGroup(this);
1485 m_clipTypeGroup->addAction(audioOnly);
1486 m_clipTypeGroup->addAction(videoOnly);
1487 m_clipTypeGroup->addAction(audioAndVideo);
1488 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1489 m_clipTypeGroup->setEnabled(false);
1491 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1492 collection.addAction("insert_space", insertSpace);
1493 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1495 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1496 collection.addAction("delete_space", removeSpace);
1497 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1499 m_tracksActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1500 m_tracksActionCollection->addAssociatedWidget(m_timelineArea);
1502 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), m_tracksActionCollection);
1503 m_tracksActionCollection->addAction("insert_track", insertTrack);
1504 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1506 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), m_tracksActionCollection);
1507 m_tracksActionCollection->addAction("delete_track", deleteTrack);
1508 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1510 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), m_tracksActionCollection);
1511 m_tracksActionCollection->addAction("config_tracks", configTracks);
1512 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1514 KAction *selectTrack = new KAction(KIcon(), i18n("Select All in Current Track"), m_tracksActionCollection);
1515 connect(selectTrack, SIGNAL(triggered()), this, SLOT(slotSelectTrack()));
1516 m_tracksActionCollection->addAction("select_track", selectTrack);
1518 QAction *selectAll = KStandardAction::selectAll(this, SLOT(slotSelectAllTracks()), m_tracksActionCollection);
1519 selectAll->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1520 m_tracksActionCollection->addAction("select_all_tracks", selectAll);
1522 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1523 collection.addAction("add_guide", addGuide);
1524 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1526 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1527 collection.addAction("delete_guide", delGuide);
1528 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1530 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1531 collection.addAction("edit_guide", editGuide);
1532 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1534 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1535 collection.addAction("delete_all_guides", delAllGuides);
1536 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1538 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1539 collection.addAction("paste_effects", pasteEffects);
1540 pasteEffects->setData("paste_effects");
1541 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1543 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1544 collection.addAction("show_timeline", showTimeline);
1545 showTimeline->setCheckable(true);
1546 showTimeline->setChecked(true);
1547 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1549 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1550 collection.addAction("show_titlebars", showTitleBar);
1551 showTitleBar->setCheckable(true);
1552 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1553 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1554 slotShowTitleBars(KdenliveSettings::showtitlebars());
1556 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1557 KStandardAction::quit(this, SLOT(close()), collection);
1558 KStandardAction::open(this, SLOT(openFile()), collection);
1559 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1560 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1561 KStandardAction::openNew(this, SLOT(newFile()), collection);
1562 // TODO: make the following connection to slotEditKeys work
1563 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1564 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1565 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1566 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1567 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1568 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1570 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1571 undo->setEnabled(false);
1572 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1574 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1575 redo->setEnabled(false);
1576 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1579 //TODO: Add status tooltip to actions ?
1580 connect(collection, SIGNAL(actionHovered(QAction*)),
1581 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1584 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1585 collection.addAction("add_clip", addClip);
1586 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1588 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1589 collection.addAction("add_color_clip", addColorClip);
1590 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1592 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1593 collection.addAction("add_slide_clip", addSlideClip);
1594 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1596 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1597 collection.addAction("add_text_clip", addTitleClip);
1598 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1600 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1601 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1602 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1604 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1605 collection.addAction("add_folder", addFolderButton);
1606 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1608 QAction *downloadResources = new KAction(KIcon("download"), i18n("Online Resources"), this);
1609 collection.addAction("download_resource", downloadResources);
1610 connect(downloadResources , SIGNAL(triggered()), this, SLOT(slotDownloadResources()));
1612 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1613 collection.addAction("clip_properties", clipProperties);
1614 clipProperties->setData("clip_properties");
1615 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1616 clipProperties->setEnabled(false);
1618 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1619 collection.addAction("edit_clip", openClip);
1620 openClip->setData("edit_clip");
1621 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1622 openClip->setEnabled(false);
1624 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1625 collection.addAction("delete_clip", deleteClip);
1626 deleteClip->setData("delete_clip");
1627 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1628 deleteClip->setEnabled(false);
1630 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1631 collection.addAction("reload_clip", reloadClip);
1632 reloadClip->setData("reload_clip");
1633 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1634 reloadClip->setEnabled(false);
1636 QAction *proxyClip = new KAction(i18n("Proxy Clip"), this);
1637 collection.addAction("proxy_clip", proxyClip);
1638 proxyClip->setData("proxy_clip");
1639 proxyClip->setCheckable(true);
1640 proxyClip->setChecked(false);
1641 connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
1643 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1644 collection.addAction("stopmotion", stopMotion);
1645 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1647 QMenu *addClips = new QMenu();
1648 addClips->addAction(addClip);
1649 addClips->addAction(addColorClip);
1650 addClips->addAction(addSlideClip);
1651 addClips->addAction(addTitleClip);
1652 addClips->addAction(addTitleTemplateClip);
1653 addClips->addAction(addFolderButton);
1654 addClips->addAction(downloadResources);
1656 addClips->addAction(reloadClip);
1657 addClips->addAction(proxyClip);
1658 addClips->addAction(clipProperties);
1659 addClips->addAction(openClip);
1660 addClips->addAction(deleteClip);
1661 m_projectList->setupMenu(addClips, addClip);
1663 // Setup effects and transitions actions.
1664 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1665 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1666 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1667 m_transitions = new KAction*[transitions.count()];
1668 for (int i = 0; i < transitions.count(); i++) {
1669 QStringList effectInfo = transitions.effectIdInfo(i);
1670 m_transitions[i] = new KAction(effectInfo.at(0), this);
1671 m_transitions[i]->setData(effectInfo);
1672 m_transitions[i]->setIconVisibleInMenu(false);
1673 QString id = effectInfo.at(2);
1674 if (id.isEmpty()) id = effectInfo.at(1);
1675 transitionActions->addAction("transition_" + id, m_transitions[i]);
1677 //m_effectsActionCollection->readSettings();
1681 void MainWindow::slotDisplayActionMessage(QAction *a)
1683 statusBar()->showMessage(a->data().toString(), 3000);
1686 void MainWindow::loadLayouts()
1688 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1689 if (m_loadLayout == NULL || saveLayout == NULL) return;
1690 KSharedConfigPtr config = KGlobal::config();
1691 KConfigGroup layoutGroup(config, "Layouts");
1692 QStringList entries = layoutGroup.keyList();
1693 QList<QAction *> loadActions = m_loadLayout->actions();
1694 QList<QAction *> saveActions = saveLayout->actions();
1695 for (int i = 1; i < 5; i++) {
1696 // Rename the layouts actions
1697 foreach(const QString & key, entries) {
1698 if (key.endsWith(QString("_%1").arg(i))) {
1699 // Found previously saved layout
1700 QString layoutName = key.section("_", 0, -2);
1701 for (int j = 0; j < loadActions.count(); j++) {
1702 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1703 loadActions[j]->setText(layoutName);
1704 loadActions[j]->setData(key);
1708 for (int j = 0; j < saveActions.count(); j++) {
1709 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1710 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1711 saveActions[j]->setData(key);
1720 void MainWindow::slotLoadLayout(QAction *action)
1722 if (!action) return;
1723 QString layoutId = action->data().toString();
1724 if (layoutId.isEmpty()) return;
1725 KSharedConfigPtr config = KGlobal::config();
1726 KConfigGroup layouts(config, "Layouts");
1727 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1728 restoreState(state);
1731 void MainWindow::slotSaveLayout(QAction *action)
1733 QString originallayoutName = action->data().toString();
1734 int layoutId = originallayoutName.section('_', -1).toInt();
1736 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1737 if (layoutName.isEmpty()) return;
1738 KSharedConfigPtr config = KGlobal::config();
1739 KConfigGroup layouts(config, "Layouts");
1740 layouts.deleteEntry(originallayoutName);
1742 QByteArray st = saveState();
1743 layoutName.append("_" + QString::number(layoutId));
1744 layouts.writeEntry(layoutName, st.toBase64());
1748 void MainWindow::saveOptions()
1750 KdenliveSettings::self()->writeConfig();
1751 KSharedConfigPtr config = KGlobal::config();
1752 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1753 KConfigGroup treecolumns(config, "Project Tree");
1754 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1758 void MainWindow::readOptions()
1760 KSharedConfigPtr config = KGlobal::config();
1761 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1762 KConfigGroup initialGroup(config, "version");
1763 bool upgrade = false;
1764 if (initialGroup.exists()) {
1765 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1769 if (initialGroup.readEntry("version") == "0.7") {
1770 //Add new settings from 0.7.1
1771 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1772 QString path = QDir::homePath() + "/kdenlive";
1773 if (KStandardDirs::makeDir(path) == false) {
1774 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1775 } else KdenliveSettings::setDefaultprojectfolder(path);
1781 if (!initialGroup.exists() || upgrade) {
1782 // this is our first run, show Wizard
1783 Wizard *w = new Wizard(upgrade, this);
1784 if (w->exec() == QDialog::Accepted && w->isOk()) {
1785 w->adjustSettings();
1786 initialGroup.writeEntry("version", version);
1792 KConfigGroup treecolumns(config, "Project Tree");
1793 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1794 if (!state.isEmpty())
1795 m_projectList->setHeaderInfo(state);
1798 void MainWindow::slotRunWizard()
1800 Wizard *w = new Wizard(false, this);
1801 if (w->exec() == QDialog::Accepted && w->isOk()) {
1802 w->adjustSettings();
1807 void MainWindow::newFile(bool showProjectSettings, bool force)
1809 if (!m_timelineArea->isEnabled() && !force)
1811 m_fileRevert->setEnabled(false);
1812 QString profileName = KdenliveSettings::default_profile();
1813 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1814 QMap <QString, QString> documentProperties;
1815 QMap <QString, QString> documentMetadata;
1816 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1817 if (!showProjectSettings) {
1818 if (!KdenliveSettings::activatetabs())
1819 if (!closeCurrentDocument())
1822 ProjectSettings *w = new ProjectSettings(NULL, QMap <QString, QString> (), QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1823 if (w->exec() != QDialog::Accepted)
1825 if (!KdenliveSettings::activatetabs())
1826 if (!closeCurrentDocument())
1828 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1829 slotSwitchVideoThumbs();
1830 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1831 slotSwitchAudioThumbs();
1832 profileName = w->selectedProfile();
1833 projectFolder = w->selectedFolder();
1834 projectTracks = w->tracks();
1835 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1836 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1837 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1838 documentProperties.insert("proxyparams", w->proxyParams());
1839 documentProperties.insert("proxyextension", w->proxyExtension());
1840 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1841 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1842 documentMetadata = w->metadata();
1845 m_timelineArea->setEnabled(true);
1846 m_projectList->setEnabled(true);
1848 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
1849 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1851 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
1852 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1855 //m_timelineArea->setEnabled(false);
1856 //m_projectList->setEnabled(false);
1860 if (m_timelineArea->count() == 1) {
1861 connectDocumentInfo(doc);
1862 connectDocument(trackView, doc);
1864 m_timelineArea->setTabBarHidden(false);
1865 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
1866 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1869 void MainWindow::activateDocument()
1871 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1872 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1873 KdenliveDoc *currentDoc = currentTab->document();
1874 connectDocumentInfo(currentDoc);
1875 connectDocument(currentTab, currentDoc);
1878 bool MainWindow::closeCurrentDocument(bool saveChanges)
1880 QWidget *w = m_timelineArea->currentWidget();
1881 if (!w) return true;
1882 // closing current document
1883 int ix = m_timelineArea->currentIndex() + 1;
1884 if (ix == m_timelineArea->count()) ix = 0;
1885 m_timelineArea->setCurrentIndex(ix);
1886 TrackView *tabToClose = (TrackView *) w;
1887 KdenliveDoc *docToClose = tabToClose->document();
1888 if (docToClose && docToClose->isModified() && saveChanges) {
1890 if (m_activeDocument->url().fileName().isEmpty())
1891 message = i18n("Save changes to document?");
1893 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1894 switch (KMessageBox::warningYesNoCancel(this, message)) {
1895 case KMessageBox::Yes :
1896 // save document here. If saving fails, return false;
1897 if (saveFile() == false) return false;
1899 case KMessageBox::Cancel :
1906 m_clipMonitor->slotSetClipProducer(NULL);
1907 m_projectList->slotResetProjectList();
1908 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1909 if (m_timelineArea->count() == 1) {
1910 m_timelineArea->setTabBarHidden(true);
1911 m_closeAction->setEnabled(false);
1913 if (docToClose == m_activeDocument) {
1914 delete m_activeDocument;
1915 m_activeDocument = NULL;
1916 m_effectStack->clear();
1917 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1921 if (w == m_activeTimeline) {
1922 delete m_activeTimeline;
1923 m_activeTimeline = NULL;
1930 bool MainWindow::saveFileAs(const QString &outputFileName)
1932 QString currentSceneList;
1933 m_monitorManager->stopActiveMonitor();
1935 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1938 // Save timeline thumbnails
1939 m_activeTimeline->projectView()->saveThumbnails();
1940 m_activeDocument->setUrl(KUrl(outputFileName));
1941 QByteArray hash = QCryptographicHash::hash(KUrl(outputFileName).encodedPath(), QCryptographicHash::Md5).toHex();
1942 if (m_activeDocument->m_autosave == NULL) {
1943 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(hash), this);
1944 } else m_activeDocument->m_autosave->setManagedFile(KUrl(hash));
1945 setCaption(m_activeDocument->description());
1946 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1947 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1948 m_activeDocument->setModified(false);
1949 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1950 m_fileRevert->setEnabled(true);
1951 m_undoView->stack()->setClean();
1955 bool MainWindow::saveFileAs()
1957 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType(false));
1958 if (outputFile.isEmpty()) {
1961 if (QFile::exists(outputFile)) {
1962 // Show the file dialog again if the user does not want to overwrite the file
1963 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1964 return saveFileAs();
1966 return saveFileAs(outputFile);
1969 bool MainWindow::saveFile()
1971 if (!m_activeDocument) return true;
1972 if (m_activeDocument->url().isEmpty()) {
1973 return saveFileAs();
1975 bool result = saveFileAs(m_activeDocument->url().path());
1976 m_activeDocument->m_autosave->resize(0);
1981 void MainWindow::openFile()
1983 if (!m_startUrl.isEmpty()) {
1984 openFile(m_startUrl);
1985 m_startUrl = KUrl();
1988 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1989 if (url.isEmpty()) return;
1990 m_fileOpenRecent->addUrl(url);
1994 void MainWindow::openLastFile()
1996 KSharedConfigPtr config = KGlobal::config();
1997 KUrl::List urls = m_fileOpenRecent->urls();
1998 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1999 if (urls.isEmpty()) newFile(false);
2000 else openFile(urls.last());
2003 void MainWindow::openFile(const KUrl &url)
2005 // Make sure the url is a Kdenlive project file
2006 KMimeType::Ptr mime = KMimeType::findByUrl(url);
2007 if (mime.data()->is("application/x-compressed-tar")) {
2008 // Opening a compressed project file, we need to process it
2009 kDebug()<<"Opening archive, processing";
2010 ArchiveWidget *ar = new ArchiveWidget(url);
2011 if (ar->exec() == QDialog::Accepted) openFile(KUrl(ar->extractedProjectFile()));
2015 if (!url.fileName().endsWith(".kdenlive")) {
2016 // This is not a Kdenlive project file, abort loading
2017 KMessageBox::sorry(this, i18n("File %1 is not a Kdenlive project file", url.path()));
2021 // Check if the document is already opened
2022 const int ct = m_timelineArea->count();
2023 bool isOpened = false;
2025 for (i = 0; i < ct; i++) {
2026 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
2027 KdenliveDoc *doc = tab->document();
2028 if (doc->url() == url) {
2034 m_timelineArea->setCurrentIndex(i);
2038 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
2040 // Check for backup file
2041 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2042 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(KUrl(hash));
2043 if (!staleFiles.isEmpty()) {
2044 if (KMessageBox::questionYesNo(this,
2045 i18n("Auto-saved files exist. Do you want to recover them now?"),
2046 i18n("File Recovery"),
2047 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
2048 recoverFiles(staleFiles, url);
2051 // remove the stale files
2052 foreach(KAutoSaveFile * stale, staleFiles) {
2053 stale->open(QIODevice::ReadWrite);
2058 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
2059 m_messageLabel->repaint();
2060 doOpenFile(url, NULL);
2063 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
2065 if (!m_timelineArea->isEnabled()) return;
2066 m_fileRevert->setEnabled(true);
2068 // Recreate stopmotion widget on document change
2070 delete m_stopmotion;
2071 m_stopmotion = NULL;
2075 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2076 progressDialog.setAllowCancel(false);
2077 progressDialog.progressBar()->setMaximum(4);
2078 progressDialog.show();
2079 progressDialog.progressBar()->setValue(0);
2080 qApp->processEvents();
2083 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);
2085 progressDialog.progressBar()->setValue(1);
2086 progressDialog.progressBar()->setMaximum(4);
2087 progressDialog.setLabelText(i18n("Loading project"));
2088 qApp->processEvents();
2090 if (stale == NULL) {
2091 QByteArray hash = QCryptographicHash::hash(url.encodedPath(), QCryptographicHash::Md5).toHex();
2092 stale = new KAutoSaveFile(KUrl(hash), doc);
2093 doc->m_autosave = stale;
2095 doc->m_autosave = stale;
2096 doc->setUrl(url);//stale->managedFile());
2097 doc->setModified(true);
2098 stale->setParent(doc);
2100 connectDocumentInfo(doc);
2102 progressDialog.progressBar()->setValue(2);
2103 qApp->processEvents();
2106 TrackView *trackView = new TrackView(doc, m_tracksActionCollection->actions(), &ok, this);
2107 connectDocument(trackView, doc);
2108 progressDialog.progressBar()->setValue(3);
2109 qApp->processEvents();
2111 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2113 m_timelineArea->setEnabled(false);
2114 m_projectList->setEnabled(false);
2115 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2116 slotGotProgressInfo(QString(), -1);
2117 newFile(false, true);
2120 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2121 trackView->setDuration(trackView->duration());
2122 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2124 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2125 slotGotProgressInfo(QString(), -1);
2126 m_projectMonitor->adjustRulerSize(trackView->duration());
2127 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2128 progressDialog.progressBar()->setValue(4);
2129 if (openBackup) slotOpenBackupDialog(url);
2132 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles, const KUrl &originUrl)
2134 foreach(KAutoSaveFile * stale, staleFiles) {
2135 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2136 // show an error message; we could not steal the lockfile
2137 // maybe another application got to the file before us?
2141 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2142 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2143 if (!stale->fileName().endsWith(".lock")) doOpenFile(originUrl, stale);
2144 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2148 void MainWindow::parseProfiles(const QString &mltPath)
2150 //KdenliveSettings::setDefaulttmpfolder();
2151 if (!mltPath.isEmpty()) {
2152 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2153 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2156 if (KdenliveSettings::mltpath().isEmpty())
2157 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2159 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2160 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2161 if (!QFile::exists(meltPath))
2162 meltPath = KStandardDirs::findExe("melt");
2163 KdenliveSettings::setRendererpath(meltPath);
2166 if (KdenliveSettings::rendererpath().isEmpty()) {
2167 // Cannot find the MLT melt renderer, ask for location
2168 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2169 if (getUrl->exec() == QDialog::Rejected) {
2172 KUrl rendererPath = getUrl->selectedUrl();
2174 if (rendererPath.isEmpty()) ::exit(0);
2175 KdenliveSettings::setRendererpath(rendererPath.path());
2178 QStringList profilesFilter;
2179 profilesFilter << "*";
2180 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2181 if (profilesList.isEmpty()) {
2182 // Cannot find MLT path, try finding melt
2183 QString profilePath = KdenliveSettings::rendererpath();
2184 if (!profilePath.isEmpty()) {
2185 profilePath = profilePath.section('/', 0, -3);
2186 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2187 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2189 if (profilesList.isEmpty()) {
2190 // Cannot find the MLT profiles, ask for location
2191 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2192 getUrl->fileDialog()->setMode(KFile::Directory);
2193 if (getUrl->exec() == QDialog::Rejected) {
2196 KUrl mltPath = getUrl->selectedUrl();
2198 if (mltPath.isEmpty()) ::exit(0);
2199 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2200 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2204 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2206 // Parse again MLT profiles to build a list of available video formats
2207 if (profilesList.isEmpty()) parseProfiles();
2211 void MainWindow::slotEditProfiles()
2213 ProfilesDialog *w = new ProfilesDialog;
2214 if (w->exec() == QDialog::Accepted) {
2215 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2216 if (d) d->checkProfile();
2221 void MainWindow::slotDetectAudioDriver()
2223 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2224 leading to no audio output, see bug #934 */
2226 //decide which audio driver is really best, in some cases SDL is wrong
2227 if (KdenliveSettings::audiodrivername().isEmpty()) {
2229 KProcess readProcess;
2230 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2231 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2232 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2233 readProcess.setProgram("pactl", QStringList() << "stat");
2234 readProcess.execute(2000); // Kill it after 2 seconds
2236 QString result = QString(readProcess.readAllStandardOutput());
2237 kDebug() << "// / / / / / READING PACTL: ";
2239 if (!result.isEmpty()) {
2241 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2245 KdenliveSettings::setAutoaudiodrivername(driver);
2249 void MainWindow::slotEditProjectSettings()
2251 QPoint p = m_activeDocument->getTracksCount();
2252 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);
2253 connect(w, SIGNAL(disableProxies()), this, SLOT(slotDisableProxies()));
2255 if (w->exec() == QDialog::Accepted) {
2256 QString profile = w->selectedProfile();
2257 m_activeDocument->setProjectFolder(w->selectedFolder());
2259 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2261 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2262 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2263 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2264 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2265 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2266 m_activeDocument->setModified();
2267 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2268 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) {
2269 //TODO: rebuild all proxies
2270 //m_projectList->rebuildProxies();
2273 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2274 m_activeDocument->setModified();
2275 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2277 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2278 m_activeDocument->setModified();
2279 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2281 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2282 m_activeDocument->setModified();
2283 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2285 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2286 m_activeDocument->setModified();
2287 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2289 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2290 m_activeDocument->setModified();
2291 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2293 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2294 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2295 m_activeDocument->setModified();
2296 slotUpdateProxySettings();
2298 m_activeDocument->setMetadata(w->metadata());
2303 void MainWindow::slotDisableProxies()
2305 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) false));
2306 m_activeDocument->setModified();
2307 slotUpdateProxySettings();
2310 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2312 // Recreate the stopmotion widget if profile changes
2314 delete m_stopmotion;
2315 m_stopmotion = NULL;
2318 // Deselect current effect / transition
2319 m_effectStack->slotClipItemSelected(NULL, 0);
2320 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2321 m_clipMonitor->slotSetClipProducer(NULL);
2322 bool updateFps = m_activeDocument->setProfilePath(profile);
2323 KdenliveSettings::setCurrent_profile(profile);
2324 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2325 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2327 m_activeDocument->clipManager()->clearUnusedProducers();
2328 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2329 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2330 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2331 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2332 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2333 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2334 if (updateFps) m_activeTimeline->updateProjectFps();
2335 m_activeDocument->clipManager()->clearCache();
2336 m_activeTimeline->updateProfile();
2337 m_activeDocument->setModified(true);
2338 m_commandStack->activeStack()->clear();
2339 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2340 slotUpdateMousePosition(0);
2341 // We need to desactivate & reactivate monitors to get a refresh
2342 //m_monitorManager->switchMonitors();
2346 void MainWindow::slotRenderProject()
2348 if (!m_renderWidget) {
2349 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2350 MltVideoProfile profile;
2351 if (m_activeDocument) profile = m_activeDocument->mltProfile();
2352 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), profile, this);
2353 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2354 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2355 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2356 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2357 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2358 if (m_activeDocument) {
2359 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2360 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2361 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2362 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2365 slotCheckRenderStatus();
2366 m_renderWidget->show();
2367 m_renderWidget->showNormal();
2369 // What are the following lines supposed to do?
2370 //m_activeTimeline->tracksNumber();
2371 //m_renderWidget->enableAudio(false);
2372 //m_renderWidget->export_audio;
2375 void MainWindow::slotCheckRenderStatus()
2377 // Make sure there are no missing clips
2379 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2382 void MainWindow::setRenderingProgress(const QString &url, int progress)
2385 m_renderWidget->setRenderJob(url, progress);
2388 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2391 m_renderWidget->setRenderStatus(url, status, error);
2394 void MainWindow::slotCleanProject()
2396 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2397 m_projectList->cleanup();
2400 void MainWindow::slotUpdateMousePosition(int pos)
2402 if (m_activeDocument)
2403 switch (m_timecodeFormat->currentIndex()) {
2405 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2408 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2412 void MainWindow::slotUpdateDocumentState(bool modified)
2414 if (!m_activeDocument) return;
2415 setCaption(m_activeDocument->description(), modified);
2416 m_saveAction->setEnabled(modified);
2418 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2419 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2421 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2422 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2426 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2428 if (m_activeDocument) {
2429 if (m_activeDocument == doc) return;
2430 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2432 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2435 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2437 //m_projectMonitor->stop();
2438 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2439 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2440 if (m_activeDocument) {
2441 if (m_activeDocument == doc) return;
2442 if (m_activeTimeline) {
2443 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2444 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2445 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2446 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2447 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2448 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2449 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2451 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool)));
2453 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2454 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2455 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2456 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2457 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2458 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2459 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2460 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2461 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2462 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2463 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2464 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2465 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2466 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2467 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2468 disconnect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), m_activeTimeline->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2470 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(slotActivateMonitor()));
2471 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2472 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2473 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2474 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2475 disconnect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2476 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2477 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2478 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2479 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2480 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2481 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2482 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2483 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2484 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2485 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2486 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2487 m_effectStack->clear();
2489 //m_activeDocument->setRenderer(NULL);
2490 m_clipMonitor->stop();
2492 KdenliveSettings::setCurrent_profile(doc->profilePath());
2493 KdenliveSettings::setProject_fps(doc->fps());
2494 m_monitorManager->resetProfiles(doc->timecode());
2495 m_clipMonitorDock->raise();
2496 m_projectList->setDocument(doc);
2497 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2498 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2499 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2501 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2502 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2504 //connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2505 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2506 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2507 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2508 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2509 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2510 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2511 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2512 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2513 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2514 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool)));
2516 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2517 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2518 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2519 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2520 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2522 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2523 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2524 connect(doc, SIGNAL(saveTimelinePreview(const QString &)), trackView, SLOT(slotSaveTimelinePreview(const QString)));
2526 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2528 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2529 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2530 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2531 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2533 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2534 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2535 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2536 m_zoomSlider->setValue(doc->zoom().x());
2537 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2538 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2539 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2540 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2542 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
2543 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2545 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2546 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2548 connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
2550 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int,bool)));
2551 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2552 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2553 connect(m_effectStack, SIGNAL(addEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotAddEffect(ClipItem*, QDomElement)));
2554 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2555 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2556 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2557 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2558 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2559 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2560 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2561 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2563 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(slotActivateMonitor()));
2564 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2565 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2566 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, static_cast<QMenu*>(factory()->container("marker_menu", this)));
2567 m_activeTimeline = trackView;
2568 if (m_renderWidget) {
2569 slotCheckRenderStatus();
2570 m_renderWidget->setProfile(doc->mltProfile());
2571 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2572 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2573 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2575 //doc->setRenderer(m_projectMonitor->render);
2576 m_commandStack->setActiveStack(doc->commandStack());
2577 KdenliveSettings::setProject_display_ratio(doc->dar());
2578 //doc->clipManager()->checkAudioThumbs();
2580 //m_overView->setScene(trackView->projectScene());
2581 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2582 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2584 setCaption(doc->description(), doc->isModified());
2585 m_saveAction->setEnabled(doc->isModified());
2586 m_normalEditTool->setChecked(true);
2587 m_activeDocument = doc;
2588 m_activeTimeline->updateProjectFps();
2589 m_activeDocument->checkProjectClips();
2591 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2593 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2594 slotUpdateMousePosition(0);
2595 m_monitorManager->activateMonitor(Kdenlive::clipMonitor);
2596 // set tool to select tool
2597 m_buttonSelectTool->setChecked(true);
2600 void MainWindow::slotZoneMoved(int start, int end)
2602 m_activeDocument->setZone(start, end);
2603 m_projectMonitor->slotZoneMoved(start, end);
2606 void MainWindow::slotGuidesUpdated()
2609 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2612 void MainWindow::slotEditKeys()
2614 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2615 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2616 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2617 dialog.addCollection(m_tracksActionCollection, i18nc("timeline track keyboard shortcuts", "Timeline and Tracks"));
2621 void MainWindow::slotPreferences(int page, int option)
2624 * An instance of your dialog could be already created and could be
2625 * cached, in which case you want to display the cached dialog
2626 * instead of creating another one
2628 if (m_stopmotion) m_stopmotion->slotLive(false);
2629 if (KConfigDialog::showDialog("settings")) {
2630 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2631 if (page != -1) d->showPage(page, option);
2635 // KConfigDialog didn't find an instance of this dialog, so lets
2638 // Get the mappable actions in localized form
2639 QMap<QString, QString> actions;
2640 KActionCollection* collection = actionCollection();
2641 foreach (const QString& action_name, m_action_names) {
2642 actions[collection->action(action_name)->text()] = action_name;
2645 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2646 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2647 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2649 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2652 if (page != -1) dialog->showPage(page, option);
2655 void MainWindow::slotUpdateCaptureFolder()
2659 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2660 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2664 void MainWindow::updateConfiguration()
2666 //TODO: we should apply settings to all projects, not only the current one
2667 if (m_activeTimeline) {
2668 m_activeTimeline->refresh();
2669 m_activeTimeline->projectView()->checkAutoScroll();
2670 m_activeTimeline->checkTrackHeight();
2671 if (m_activeDocument)
2672 m_activeDocument->clipManager()->checkAudioThumbs();
2674 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2675 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2676 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2677 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2679 // Update list of transcoding profiles
2682 #ifdef USE_JOGSHUTTLE
2683 activateShuttleDevice();
2688 void MainWindow::slotSwitchSplitAudio()
2690 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2691 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2694 void MainWindow::slotSwitchVideoThumbs()
2696 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2697 if (m_activeTimeline)
2698 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2699 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2702 void MainWindow::slotSwitchAudioThumbs()
2704 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2705 if (m_activeTimeline) {
2706 m_activeTimeline->refresh();
2707 m_activeTimeline->projectView()->checkAutoScroll();
2708 if (m_activeDocument)
2709 m_activeDocument->clipManager()->checkAudioThumbs();
2711 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2714 void MainWindow::slotSwitchMarkersComments()
2716 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2717 if (m_activeTimeline)
2718 m_activeTimeline->refresh();
2719 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2722 void MainWindow::slotSwitchSnap()
2724 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2725 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2729 void MainWindow::slotDeleteItem()
2731 if (QApplication::focusWidget() &&
2732 QApplication::focusWidget()->parentWidget() &&
2733 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2734 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2735 m_projectList->slotRemoveClip();
2738 QWidget *widget = QApplication::focusWidget();
2740 if (widget == m_effectStackDock) {
2741 m_effectStack->deleteCurrentEffect();
2744 widget = widget->parentWidget();
2747 // effect stack has no focus
2748 if (m_activeTimeline)
2749 m_activeTimeline->projectView()->deleteSelectedClips();
2753 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2755 if (m_clipMonitor->isActive())
2756 m_clipMonitor->checkOverlay();
2757 m_clipMonitor->updateMarkers(clip);
2760 void MainWindow::slotAddClipMarker()
2762 DocClipBase *clip = NULL;
2764 if (m_projectMonitor->isActive()) {
2765 if (m_activeTimeline) {
2766 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2768 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2769 clip = item->baseClip();
2773 clip = m_clipMonitor->activeClip();
2774 pos = m_clipMonitor->position();
2777 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2780 QString id = clip->getId();
2781 CommentedTime marker(pos, i18n("Marker"));
2782 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2783 if (d.exec() == QDialog::Accepted)
2784 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2787 void MainWindow::slotDeleteClipMarker()
2789 DocClipBase *clip = NULL;
2791 if (m_projectMonitor->isActive()) {
2792 if (m_activeTimeline) {
2793 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2795 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2796 clip = item->baseClip();
2800 clip = m_clipMonitor->activeClip();
2801 pos = m_clipMonitor->position();
2804 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2808 QString id = clip->getId();
2809 QString comment = clip->markerComment(pos);
2810 if (comment.isEmpty()) {
2811 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2814 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2817 void MainWindow::slotDeleteAllClipMarkers()
2819 DocClipBase *clip = NULL;
2820 if (m_projectMonitor->isActive()) {
2821 if (m_activeTimeline) {
2822 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2824 clip = item->baseClip();
2828 clip = m_clipMonitor->activeClip();
2831 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2834 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2837 void MainWindow::slotEditClipMarker()
2839 DocClipBase *clip = NULL;
2841 if (m_projectMonitor->isActive()) {
2842 if (m_activeTimeline) {
2843 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2845 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2846 clip = item->baseClip();
2850 clip = m_clipMonitor->activeClip();
2851 pos = m_clipMonitor->position();
2854 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2858 QString id = clip->getId();
2859 QString oldcomment = clip->markerComment(pos);
2860 if (oldcomment.isEmpty()) {
2861 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2865 CommentedTime marker(pos, oldcomment);
2866 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2867 if (d.exec() == QDialog::Accepted) {
2868 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2869 if (d.newMarker().time() != pos) {
2870 // remove old marker
2871 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2876 void MainWindow::slotAddMarkerGuideQuickly()
2878 if (!m_activeTimeline || !m_activeDocument)
2881 if (m_clipMonitor->isActive()) {
2882 DocClipBase *clip = m_clipMonitor->activeClip();
2883 GenTime pos = m_clipMonitor->position();
2886 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2890 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2892 m_activeTimeline->projectView()->slotAddGuide(false);
2896 void MainWindow::slotAddGuide()
2898 if (m_activeTimeline)
2899 m_activeTimeline->projectView()->slotAddGuide();
2902 void MainWindow::slotInsertSpace()
2904 if (m_activeTimeline)
2905 m_activeTimeline->projectView()->slotInsertSpace();
2908 void MainWindow::slotRemoveSpace()
2910 if (m_activeTimeline)
2911 m_activeTimeline->projectView()->slotRemoveSpace();
2914 void MainWindow::slotInsertTrack(int ix)
2916 m_projectMonitor->slotActivateMonitor();
2917 if (m_activeTimeline) {
2918 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2919 m_activeTimeline->projectView()->slotInsertTrack(ix);
2921 if (m_activeDocument)
2922 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2925 void MainWindow::slotDeleteTrack(int ix)
2927 m_projectMonitor->slotActivateMonitor();
2928 if (m_activeTimeline) {
2929 if (ix == -1) ix = m_activeTimeline->projectView()->selectedTrack();
2930 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2932 if (m_activeDocument)
2933 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2936 void MainWindow::slotConfigTrack(int ix)
2938 m_projectMonitor->slotActivateMonitor();
2939 if (m_activeTimeline)
2940 m_activeTimeline->projectView()->slotConfigTracks(ix);
2941 if (m_activeDocument)
2942 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2945 void MainWindow::slotSelectTrack()
2947 m_projectMonitor->slotActivateMonitor();
2948 if (m_activeTimeline) {
2949 m_activeTimeline->projectView()->slotSelectClipsInTrack();
2953 void MainWindow::slotSelectAllTracks()
2955 m_projectMonitor->slotActivateMonitor();
2956 if (m_activeTimeline)
2957 m_activeTimeline->projectView()->slotSelectAllClips();
2960 void MainWindow::slotEditGuide()
2962 if (m_activeTimeline)
2963 m_activeTimeline->projectView()->slotEditGuide();
2966 void MainWindow::slotDeleteGuide()
2968 if (m_activeTimeline)
2969 m_activeTimeline->projectView()->slotDeleteGuide();
2972 void MainWindow::slotDeleteAllGuides()
2974 if (m_activeTimeline)
2975 m_activeTimeline->projectView()->slotDeleteAllGuides();
2978 void MainWindow::slotCutTimelineClip()
2980 if (m_activeTimeline)
2981 m_activeTimeline->projectView()->cutSelectedClips();
2984 void MainWindow::slotInsertClipOverwrite()
2986 if (m_activeTimeline) {
2987 QStringList data = m_clipMonitor->getZoneInfo();
2988 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2992 void MainWindow::slotSelectTimelineClip()
2994 if (m_activeTimeline)
2995 m_activeTimeline->projectView()->selectClip(true);
2998 void MainWindow::slotSelectTimelineTransition()
3000 if (m_activeTimeline)
3001 m_activeTimeline->projectView()->selectTransition(true);
3004 void MainWindow::slotDeselectTimelineClip()
3006 if (m_activeTimeline)
3007 m_activeTimeline->projectView()->selectClip(false, true);
3010 void MainWindow::slotDeselectTimelineTransition()
3012 if (m_activeTimeline)
3013 m_activeTimeline->projectView()->selectTransition(false, true);
3016 void MainWindow::slotSelectAddTimelineClip()
3018 if (m_activeTimeline)
3019 m_activeTimeline->projectView()->selectClip(true, true);
3022 void MainWindow::slotSelectAddTimelineTransition()
3024 if (m_activeTimeline)
3025 m_activeTimeline->projectView()->selectTransition(true, true);
3028 void MainWindow::slotGroupClips()
3030 if (m_activeTimeline)
3031 m_activeTimeline->projectView()->groupClips();
3034 void MainWindow::slotUnGroupClips()
3036 if (m_activeTimeline)
3037 m_activeTimeline->projectView()->groupClips(false);
3040 void MainWindow::slotEditItemDuration()
3042 if (m_activeTimeline)
3043 m_activeTimeline->projectView()->editItemDuration();
3046 void MainWindow::slotAddProjectClip(KUrl url, const QString &comment)
3048 if (m_activeDocument)
3049 m_activeDocument->slotAddClipFile(url, QString(), QString(), comment);
3052 void MainWindow::slotAddProjectClipList(KUrl::List urls)
3054 if (m_activeDocument)
3055 m_activeDocument->slotAddClipList(urls, QString());
3058 void MainWindow::slotAddTransition(QAction *result)
3060 if (!result) return;
3061 QStringList info = result->data().toStringList();
3062 if (info.isEmpty()) return;
3063 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
3064 if (m_activeTimeline && !transition.isNull()) {
3065 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
3069 void MainWindow::slotAddVideoEffect(QAction *result)
3071 if (!result) return;
3072 const int EFFECT_VIDEO = 1;
3073 const int EFFECT_AUDIO = 2;
3074 QStringList info = result->data().toStringList();
3076 if (info.isEmpty() || info.size() < 3) return;
3077 QDomElement effect ;
3078 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
3079 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
3080 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
3081 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
3083 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
3084 if (!effect.isNull()) slotAddEffect(effect);
3085 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
3089 void MainWindow::slotZoomIn()
3091 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
3092 slotShowZoomSliderToolTip();
3095 void MainWindow::slotZoomOut()
3097 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3098 slotShowZoomSliderToolTip();
3101 void MainWindow::slotFitZoom()
3103 if (m_activeTimeline)
3104 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3107 void MainWindow::slotSetZoom(int value)
3109 value = qMax(m_zoomSlider->minimum(), value);
3110 value = qMin(m_zoomSlider->maximum(), value);
3112 if (m_activeTimeline)
3113 m_activeTimeline->slotChangeZoom(value);
3115 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3116 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3117 slotUpdateZoomSliderToolTip(value);
3119 m_zoomSlider->blockSignals(true);
3120 m_zoomSlider->setValue(value);
3121 m_zoomSlider->blockSignals(false);
3124 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3126 if (zoomlevel != -1)
3127 slotUpdateZoomSliderToolTip(zoomlevel);
3129 QPoint global = m_zoomSlider->rect().topLeft();
3130 global.ry() += m_zoomSlider->height() / 2;
3131 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3132 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3135 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3137 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3140 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3142 m_statusProgressBar->setValue(progress);
3143 if (progress >= 0) {
3144 if (!message.isEmpty())
3145 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3146 m_statusProgressBar->setVisible(true);
3147 } else if (progress == -2) {
3148 if (!message.isEmpty())
3149 m_messageLabel->setMessage(message, ErrorMessage);
3150 m_statusProgressBar->setVisible(false);
3152 m_messageLabel->setMessage(QString(), DefaultMessage);
3153 m_statusProgressBar->setVisible(false);
3157 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3159 if (clip->clipType() == TEXT) {
3160 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3161 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3162 // template text clip
3164 // Get the list of existing templates
3166 filter << "*.kdenlivetitle";
3167 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3169 QDialog *dia = new QDialog(this);
3170 Ui::TemplateClip_UI dia_ui;
3171 dia_ui.setupUi(dia);
3173 const QString templatePath = clip->getProperty("resource");
3174 for (int i = 0; i < templateFiles.size(); ++i) {
3175 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3176 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3178 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3179 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3180 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3181 //warning: setting base directory doesn't work??
3182 KUrl startDir(titlepath);
3183 dia_ui.template_list->fileDialog()->setUrl(startDir);
3184 dia_ui.description->setText(clip->getProperty("description"));
3185 if (dia->exec() == QDialog::Accepted) {
3186 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3187 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3189 QMap <QString, QString> newprops;
3191 if (KUrl(textTemplate).path() != templatePath) {
3192 // The template was changed
3193 newprops.insert("resource", textTemplate);
3196 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3197 newprops.insert("description", dia_ui.description->toPlainText());
3200 QString newtemplate = newprops.value("xmltemplate");
3201 if (newtemplate.isEmpty()) newtemplate = templatePath;
3203 // template modified we need to update xmldata
3204 QString description = newprops.value("description");
3205 if (description.isEmpty()) description = clip->getProperty("description");
3206 else newprops.insert("templatetext", description);
3207 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3208 if (!newprops.isEmpty()) {
3209 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3210 m_activeDocument->commandStack()->push(command);
3216 QString path = clip->getProperty("resource");
3217 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3219 doc.setContent(clip->getProperty("xmldata"));
3220 dia_ui->setXml(doc);
3221 if (dia_ui->exec() == QDialog::Accepted) {
3222 QMap <QString, QString> newprops;
3223 newprops.insert("xmldata", dia_ui->xml().toString());
3224 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps())) {
3225 // duration changed, we need to update duration
3226 newprops.insert("out", QString::number(dia_ui->outPoint()));
3227 int currentLength = QString(clip->producerProperty("length")).toInt();
3228 if (currentLength <= dia_ui->outPoint())
3229 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3230 else newprops.insert("length", clip->producerProperty("length"));
3232 if (!path.isEmpty()) {
3233 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3234 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) {
3235 // save to external file
3236 dia_ui->saveTitle(path);
3237 } else newprops.insert("resource", QString());
3239 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newprops), newprops, true);
3240 m_activeDocument->commandStack()->push(command);
3241 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3242 m_activeDocument->setModified(true);
3246 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3250 // any type of clip but a title
3251 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3252 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3253 connect(dia, SIGNAL(deleteProxy(const QString)), m_projectList, SLOT(slotDeleteProxy(const QString)));
3254 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)));
3259 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3261 if (newprops.isEmpty()) return;
3262 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3263 m_activeDocument->commandStack()->push(command);
3264 m_activeDocument->setModified();
3267 // update clip occurences in timeline
3268 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3273 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3275 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3276 if (dia.exec() == QDialog::Accepted) {
3277 QUndoCommand *command = new QUndoCommand();
3278 command->setText(i18n("Edit clips"));
3279 QMap <QString, QString> newImageProps = dia.properties();
3280 // Transparency setting applies only for images
3281 QMap <QString, QString> newProps = newImageProps;
3282 newProps.remove("transparency");
3284 for (int i = 0; i < cliplist.count(); i++) {
3285 DocClipBase *clip = cliplist.at(i);
3286 if (clip->clipType() == IMAGE)
3287 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newImageProps), newImageProps, true, command);
3289 new EditClipCommand(m_projectList, clip->getId(), clip->currentProperties(newProps), newProps, true, command);
3291 m_activeDocument->commandStack()->push(command);
3292 for (int i = 0; i < cliplist.count(); i++)
3293 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3297 void MainWindow::customEvent(QEvent* e)
3299 if (e->type() == QEvent::User)
3300 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3302 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3308 m_effectStack->raiseWindow(m_effectStackDock);
3311 void MainWindow::slotActivateTransitionView(Transition *t)
3314 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3317 void MainWindow::slotSnapRewind()
3319 if (m_projectMonitor->isActive()) {
3320 if (m_activeTimeline)
3321 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3323 m_clipMonitor->slotSeekToPreviousSnap();
3327 void MainWindow::slotSnapForward()
3329 if (m_projectMonitor->isActive()) {
3330 if (m_activeTimeline)
3331 m_activeTimeline->projectView()->slotSeekToNextSnap();
3333 m_clipMonitor->slotSeekToNextSnap();
3337 void MainWindow::slotClipStart()
3339 if (m_projectMonitor->isActive()) {
3340 if (m_activeTimeline)
3341 m_activeTimeline->projectView()->clipStart();
3345 void MainWindow::slotClipEnd()
3347 if (m_projectMonitor->isActive()) {
3348 if (m_activeTimeline)
3349 m_activeTimeline->projectView()->clipEnd();
3353 void MainWindow::slotZoneStart()
3355 if (m_projectMonitor->isActive())
3356 m_projectMonitor->slotZoneStart();
3358 m_clipMonitor->slotZoneStart();
3361 void MainWindow::slotZoneEnd()
3363 if (m_projectMonitor->isActive())
3364 m_projectMonitor->slotZoneEnd();
3366 m_clipMonitor->slotZoneEnd();
3369 void MainWindow::slotChangeTool(QAction * action)
3371 if (action == m_buttonSelectTool)
3372 slotSetTool(SELECTTOOL);
3373 else if (action == m_buttonRazorTool)
3374 slotSetTool(RAZORTOOL);
3375 else if (action == m_buttonSpacerTool)
3376 slotSetTool(SPACERTOOL);
3379 void MainWindow::slotChangeEdit(QAction * action)
3381 if (!m_activeTimeline)
3384 if (action == m_overwriteEditTool)
3385 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3386 else if (action == m_insertEditTool)
3387 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3389 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3392 void MainWindow::slotSetTool(PROJECTTOOL tool)
3394 if (m_activeDocument && m_activeTimeline) {
3395 //m_activeDocument->setTool(tool);
3399 message = i18n("Ctrl + click to use spacer on current track only");
3402 message = i18n("Click on a clip to cut it");
3405 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3408 m_messageLabel->setMessage(message, InformationMessage);
3409 m_activeTimeline->projectView()->setTool(tool);
3413 void MainWindow::slotCopy()
3415 if (m_activeDocument && m_activeTimeline)
3416 m_activeTimeline->projectView()->copyClip();
3419 void MainWindow::slotPaste()
3421 if (m_activeDocument && m_activeTimeline)
3422 m_activeTimeline->projectView()->pasteClip();
3425 void MainWindow::slotPasteEffects()
3427 if (m_activeDocument && m_activeTimeline)
3428 m_activeTimeline->projectView()->pasteClipEffects();
3431 void MainWindow::slotFind()
3433 if (!m_activeDocument || !m_activeTimeline) return;
3434 m_projectSearch->setEnabled(false);
3435 m_findActivated = true;
3436 m_findString.clear();
3437 m_activeTimeline->projectView()->initSearchStrings();
3438 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3439 m_findTimer.start(5000);
3440 qApp->installEventFilter(this);
3443 void MainWindow::slotFindNext()
3445 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3446 statusBar()->showMessage(i18n("Found: %1", m_findString));
3448 statusBar()->showMessage(i18n("Reached end of project"));
3449 m_findTimer.start(4000);
3452 void MainWindow::findAhead()
3454 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3455 m_projectSearchNext->setEnabled(true);
3456 statusBar()->showMessage(i18n("Found: %1", m_findString));
3458 m_projectSearchNext->setEnabled(false);
3459 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3463 void MainWindow::findTimeout()
3465 m_projectSearchNext->setEnabled(false);
3466 m_findActivated = false;
3467 m_findString.clear();
3468 statusBar()->showMessage(i18n("Find stopped"), 3000);
3469 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3470 m_projectSearch->setEnabled(true);
3471 removeEventFilter(this);
3474 void MainWindow::slotClipInTimeline(const QString &clipId)
3476 if (m_activeTimeline && m_activeDocument) {
3477 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3479 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3480 inTimelineMenu->clear();
3482 QList <QAction *> actionList;
3484 for (int i = 0; i < matching.count(); ++i) {
3485 QString track = QString::number(matching.at(i).track);
3486 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3488 QAction *a = new QAction(track + ": " + start, this);
3489 a->setData(QStringList() << track << start);
3490 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3491 while (j < actionList.count()) {
3492 if (actionList.at(j)->text() > a->text()) break;
3495 actionList.insert(j, a);
3497 inTimelineMenu->addActions(actionList);
3499 if (matching.empty())
3500 inTimelineMenu->setEnabled(false);
3502 inTimelineMenu->setEnabled(true);
3506 void MainWindow::slotClipInProjectTree()
3508 if (m_activeTimeline) {
3509 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3510 if (clipIds.isEmpty())
3512 m_projectListDock->raise();
3513 for (int i = 0; i < clipIds.count(); i++)
3514 m_projectList->selectItemById(clipIds.at(i));
3515 if (m_projectMonitor->isActive())
3516 slotSwitchMonitors();
3520 /*void MainWindow::slotClipToProjectTree()
3522 if (m_activeTimeline) {
3523 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3524 if (clips.isEmpty()) return;
3525 for (int i = 0; i < clips.count(); i++) {
3526 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3528 //m_projectList->selectItemById(clipIds.at(i));
3532 void MainWindow::slotSelectClipInTimeline()
3534 if (m_activeTimeline) {
3535 QAction *action = qobject_cast<QAction *>(sender());
3536 QStringList data = action->data().toStringList();
3537 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3541 void MainWindow::keyPressEvent(QKeyEvent *ke)
3543 if (m_findActivated) {
3544 if (ke->key() == Qt::Key_Backspace) {
3545 m_findString = m_findString.left(m_findString.length() - 1);
3547 if (!m_findString.isEmpty())
3552 m_findTimer.start(4000);
3555 } else if (ke->key() == Qt::Key_Escape) {
3559 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3560 m_findString += ke->text();
3564 m_findTimer.start(4000);
3569 KXmlGuiWindow::keyPressEvent(ke);
3574 /** Gets called when the window gets hidden */
3575 void MainWindow::hideEvent(QHideEvent */*event*/)
3577 if (isMinimized() && m_monitorManager)
3578 m_monitorManager->stopActiveMonitor();
3581 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3583 if (m_findActivated) {
3584 if (event->type() == QEvent::ShortcutOverride) {
3585 QKeyEvent* ke = (QKeyEvent*) event;
3586 if (ke->text().trimmed().isEmpty()) return false;
3593 // pass the event on to the parent class
3594 return QMainWindow::eventFilter(obj, event);
3599 void MainWindow::slotSaveZone(Render *render, QPoint zone, DocClipBase *baseClip, KUrl path)
3601 KDialog *dialog = new KDialog(this);
3602 dialog->setCaption("Save clip zone");
3603 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3605 QWidget *widget = new QWidget(dialog);
3606 dialog->setMainWidget(widget);
3608 QVBoxLayout *vbox = new QVBoxLayout(widget);
3609 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3610 if (path.isEmpty()) {
3611 QString tmppath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3612 if (baseClip == NULL) tmppath.append("untitled.mlt");
3614 tmppath.append((baseClip->name().isEmpty() ? baseClip->fileURL().fileName() : baseClip->name()) + "-" + QString::number(zone.x()).rightJustified(4, '0') + ".mlt");
3616 path = KUrl(tmppath);
3618 KUrlRequester *url = new KUrlRequester(path, this);
3619 url->setFilter("video/mlt-playlist");
3620 QLabel *label2 = new QLabel(i18n("Description:"), this);
3621 KLineEdit *edit = new KLineEdit(this);
3622 vbox->addWidget(label1);
3623 vbox->addWidget(url);
3624 vbox->addWidget(label2);
3625 vbox->addWidget(edit);
3626 if (dialog->exec() == QDialog::Accepted) {
3627 if (QFile::exists(url->url().path())) {
3628 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", url->url().path())) == KMessageBox::No) {
3629 slotSaveZone(render, zone, baseClip, url->url());
3633 if (baseClip && !baseClip->fileURL().isEmpty()) {
3634 // create zone from clip url, so that we don't have problems with proxy clips
3636 #if QT_VERSION >= 0x040600
3637 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3638 env.remove("MLT_PROFILE");
3639 p.setProcessEnvironment(env);
3641 QStringList env = QProcess::systemEnvironment();
3642 env << "MLT_PROFILE='\0'";
3643 p.setEnvironment(env);
3645 p.start(KdenliveSettings::rendererpath(), QStringList() << baseClip->fileURL().path() << "in=" + QString::number(zone.x()) << "out=" + QString::number(zone.y()) << "-consumer" << "xml:" + url->url().path());
3646 if (!p.waitForStarted(3000)) {
3647 KMessageBox::sorry(this, i18n("Cannot start MLT's renderer:\n%1", KdenliveSettings::rendererpath()));
3649 else if (!p.waitForFinished(5000)) {
3650 KMessageBox::sorry(this, i18n("Timeout while creating xml output"));
3653 else render->saveZone(url->url(), edit->text(), zone);
3658 void MainWindow::slotSetInPoint()
3660 if (m_clipMonitor->isActive()) {
3661 m_clipMonitor->slotSetZoneStart();
3663 m_projectMonitor->slotSetZoneStart();
3667 void MainWindow::slotSetOutPoint()
3669 if (m_clipMonitor->isActive()) {
3670 m_clipMonitor->slotSetZoneEnd();
3672 m_projectMonitor->slotSetZoneEnd();
3676 void MainWindow::slotResizeItemStart()
3678 if (m_activeTimeline)
3679 m_activeTimeline->projectView()->setInPoint();
3682 void MainWindow::slotResizeItemEnd()
3684 if (m_activeTimeline)
3685 m_activeTimeline->projectView()->setOutPoint();
3688 int MainWindow::getNewStuff(const QString &configFile)
3690 KNS3::Entry::List entries;
3691 #if KDE_IS_VERSION(4,3,80)
3692 KNS3::DownloadDialog dialog(configFile);
3694 entries = dialog.changedEntries();
3695 foreach(const KNS3::Entry & entry, entries) {
3696 if (entry.status() == KNS3::Entry::Installed)
3697 kDebug() << "// Installed files: " << entry.installedFiles();
3700 KNS::Engine engine(0);
3701 if (engine.init(configFile))
3702 entries = engine.downloadDialogModal(this);
3703 foreach(KNS::Entry * entry, entries) {
3704 if (entry->status() == KNS::Entry::Installed)
3705 kDebug() << "// Installed files: " << entry->installedFiles();
3708 return entries.size();
3711 void MainWindow::slotGetNewTitleStuff()
3713 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3714 TitleWidget::refreshTitleTemplates();
3717 void MainWindow::slotGetNewLumaStuff()
3719 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3720 initEffects::refreshLumas();
3721 m_activeTimeline->projectView()->reloadTransitionLumas();
3725 void MainWindow::slotGetNewRenderStuff()
3727 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3729 m_renderWidget->reloadProfiles();
3732 void MainWindow::slotGetNewMltProfileStuff()
3734 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3735 // update the list of profiles in settings dialog
3736 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3742 void MainWindow::slotAutoTransition()
3744 if (m_activeTimeline)
3745 m_activeTimeline->projectView()->autoTransition();
3748 void MainWindow::slotSplitAudio()
3750 if (m_activeTimeline)
3751 m_activeTimeline->projectView()->splitAudio();
3754 void MainWindow::slotUpdateClipType(QAction *action)
3756 if (m_activeTimeline) {
3757 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3758 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3759 else m_activeTimeline->projectView()->setAudioAndVideo();
3763 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3765 // We must stop the monitors since we create a new on in the dvd wizard
3766 m_clipMonitor->stop();
3767 m_projectMonitor->stop();
3768 DvdWizard w(url, profile, this);
3770 m_projectMonitor->start();
3773 void MainWindow::slotShowTimeline(bool show)
3775 if (show == false) {
3776 m_timelineState = saveState();
3777 centralWidget()->setHidden(true);
3779 centralWidget()->setHidden(false);
3780 restoreState(m_timelineState);
3784 void MainWindow::slotMaximizeCurrent(bool)
3786 //TODO: is there a way to maximize current widget?
3788 m_timelineState = saveState();
3789 QWidget *par = focusWidget()->parentWidget();
3790 while (par->parentWidget() && par->parentWidget() != this)
3791 par = par->parentWidget();
3792 kDebug() << "CURRENT WIDGET: " << par->objectName();
3795 void MainWindow::loadStabilize()
3797 QMenu* stabMenu= static_cast<QMenu*>(factory()->container("stabilize", this));
3800 Mlt::Profile profile;
3801 if (Mlt::Factory::filter(profile,(char*)"videostab")){
3802 QAction *action=stabMenu->addAction("Videostab (vstab)");
3803 action->setData("videostab");
3804 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3806 if (Mlt::Factory::filter(profile,(char*)"videostab2")){
3807 QAction *action=stabMenu->addAction("Videostab (transcode)");
3808 action->setData("videostab2");
3809 connect(action,SIGNAL(triggered()), this, SLOT(slotStabilize()));
3816 void MainWindow::loadTranscoders()
3818 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3821 QMenu *extractAudioMenu = static_cast<QMenu*>(factory()->container("extract_audio", this));
3822 extractAudioMenu->clear();
3824 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3825 KConfigGroup transConfig(config, "Transcoding");
3827 QMap< QString, QString > profiles = transConfig.entryMap();
3828 QMapIterator<QString, QString> i(profiles);
3829 while (i.hasNext()) {
3831 QStringList data = i.value().split(";");
3833 // separate audio transcoding in a separate menu
3834 if (data.count() > 2 && data.at(2) == "audio") {
3835 a = extractAudioMenu->addAction(i.key());
3838 a = transMenu->addAction(i.key());
3841 if (data.count() > 1) a->setToolTip(data.at(1));
3842 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3846 void MainWindow::slotStabilize()
3848 QString condition,filtername;
3851 // Stablize selected clips
3852 QAction *action = qobject_cast<QAction *>(sender());
3854 filtername=action->data().toString();
3856 m_projectList->startClipFilterJob(filtername, condition);
3858 if (ids.isEmpty()) {
3859 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3862 QString destination;
3863 ProjectItem *item = m_projectList->getClipById(ids.at(0));
3864 if (ids.count() == 1) {
3867 ClipStabilize *d = new ClipStabilize(destination, ids.count(), filtername);
3868 //connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3869 if (d->exec() == QDialog::Accepted) {
3870 m_projectList->slotStabilizeClipJob(ids, d->autoAddClip(), d->params(), d->desc());
3875 void MainWindow::slotTranscode(KUrl::List urls)
3880 if (urls.isEmpty()) {
3881 QAction *action = qobject_cast<QAction *>(sender());
3882 QStringList data = action->data().toStringList();
3883 params = data.at(0);
3884 if (data.count() > 1) desc = data.at(1);
3885 if (data.count() > 3) condition = data.at(3);
3886 m_projectList->slotTranscodeClipJob(condition, params, desc);
3889 if (urls.isEmpty()) {
3890 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3893 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3894 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3898 void MainWindow::slotTranscodeClip()
3900 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3901 if (urls.isEmpty()) return;
3902 slotTranscode(urls);
3905 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3907 if (m_activeDocument == NULL) return;
3908 QMapIterator<QString, QString> i(props);
3909 while (i.hasNext()) {
3911 m_activeDocument->setDocumentProperty(i.key(), i.value());
3913 m_activeDocument->setModified(true);
3917 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3919 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3921 QString playlistPath;
3924 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3925 QString path = m_renderWidget->getFreeScriptName();
3926 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3927 if (!ok || scriptPath.isEmpty()) return;
3928 scriptPath.prepend(scriptsFolder);
3929 QFile f(scriptPath);
3931 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3934 playlistPath = scriptPath + ".mlt";
3936 KTemporaryFile temp;
3937 temp.setAutoRemove(false);
3938 temp.setSuffix(".mlt");
3940 playlistPath = temp.fileName();
3942 QString playlistContent = m_projectMonitor->sceneList();
3943 if (!chapterFile.isEmpty()) {
3946 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3948 in = m_activeTimeline->inPoint();
3949 out = m_activeTimeline->outPoint();
3952 QDomElement chapters = doc.createElement("chapters");
3953 chapters.setAttribute("fps", m_activeDocument->fps());
3954 doc.appendChild(chapters);
3956 QDomElement guidesxml = m_activeDocument->guidesXml();
3957 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3958 for (int i = 0; i < nodes.count(); i++) {
3959 QDomElement e = nodes.item(i).toElement();
3961 QString comment = e.attribute("comment");
3962 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3963 if (time >= in && time < out) {
3964 if (zoneOnly) time = time - in;
3965 QDomElement chapter = doc.createElement("chapter");
3966 chapters.appendChild(chapter);
3967 chapter.setAttribute("title", comment);
3968 chapter.setAttribute("time", time);
3972 if (chapters.childNodes().count() > 0) {
3973 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3974 // Always insert a guide in pos 0
3975 QDomElement chapter = doc.createElement("chapter");
3976 chapters.insertBefore(chapter, QDomNode());
3977 chapter.setAttribute("title", i18n("Start"));
3978 chapter.setAttribute("time", "0");
3980 // save chapters file
3981 QFile file(chapterFile);
3982 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3983 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3985 file.write(doc.toString().toUtf8());
3986 if (file.error() != QFile::NoError) {
3987 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3994 if (m_renderWidget->automaticAudioExport()) {
3995 exportAudio = m_activeTimeline->checkProjectAudio();
3996 } else exportAudio = m_renderWidget->selectedAudioExport();
3998 // Set playlist audio volume to 100%
4000 doc.setContent(playlistContent);
4001 QDomElement tractor = doc.documentElement().firstChildElement("tractor");
4002 if (!tractor.isNull()) {
4003 QDomNodeList props = tractor.elementsByTagName("property");
4004 for (int i = 0; i < props.count(); i++) {
4005 if (props.at(i).toElement().attribute("name") == "meta.volume") {
4006 props.at(i).firstChild().setNodeValue("1");
4012 // Do we want proxy rendering
4013 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
4014 QString root = doc.documentElement().attribute("root");
4016 // replace proxy clips with originals
4017 QMap <QString, QString> proxies = m_projectList->getProxies();
4019 QDomNodeList producers = doc.elementsByTagName("producer");
4020 QString producerResource;
4022 for (uint n = 0; n < producers.length(); n++) {
4023 QDomElement e = producers.item(n).toElement();
4024 producerResource = EffectsList::property(e, "resource");
4025 if (producerResource.isEmpty()) continue;
4026 if (!producerResource.startsWith("/")) {
4027 producerResource.prepend(root + "/");
4029 if (producerResource.contains('?')) {
4030 // slowmotion producer
4031 suffix = "?" + producerResource.section('?', 1);
4032 producerResource = producerResource.section('?', 0, 0);
4034 else suffix.clear();
4035 if (!producerResource.isEmpty()) {
4036 if (proxies.contains(producerResource)) {
4037 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
4038 // We need to delete the "aspect_ratio" property because proxy clips
4039 // sometimes have different ratio than original clips
4040 EffectsList::removeProperty(e, "aspect_ratio");
4041 EffectsList::removeMetaProperties(e);
4046 /*QMapIterator<QString, QString> i(proxies);
4047 while (i.hasNext()) {
4049 // Replace all keys with their values (proxy path with original path)
4050 QString key = i.key();
4051 playlistContent.replace(key, i.value());
4052 if (!root.isEmpty() && key.startsWith(root)) {
4053 // in case the resource path in MLT playlist is relative
4054 key.remove(0, root.count() + 1);
4055 playlistContent.replace(key, i.value());
4059 playlistContent = doc.toString();
4061 // Do save scenelist
4062 QFile file(playlistPath);
4063 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
4064 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4067 file.write(playlistContent.toUtf8());
4068 if (file.error() != QFile::NoError) {
4069 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
4074 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), m_activeDocument->metadata(), playlistPath, scriptPath, exportAudio);
4077 void MainWindow::slotUpdateTimecodeFormat(int ix)
4079 KdenliveSettings::setFrametimecode(ix == 1);
4080 m_clipMonitor->updateTimecodeFormat();
4081 m_projectMonitor->updateTimecodeFormat();
4082 m_transitionConfig->updateTimecodeFormat();
4083 m_effectStack->updateTimecodeFormat();
4084 //m_activeTimeline->projectView()->clearSelection();
4085 m_activeTimeline->updateRuler();
4088 void MainWindow::slotRemoveFocus()
4090 statusBar()->setFocus();
4091 statusBar()->clearFocus();
4094 void MainWindow::slotRevert()
4096 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;
4097 KUrl url = m_activeDocument->url();
4098 if (closeCurrentDocument(false))
4099 doOpenFile(url, NULL);
4103 void MainWindow::slotShutdown()
4105 if (m_activeDocument) m_activeDocument->setModified(false);
4107 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
4108 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
4109 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
4110 smserver.call("logout", 1, 2, 2);
4111 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
4112 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
4113 smserver.call("Shutdown");
4117 void MainWindow::slotUpdateTrackInfo()
4119 if (m_activeDocument)
4120 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
4123 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
4125 // Load the theme file
4127 if (action == NULL) theme = themename;
4128 else theme = action->data().toString();
4129 KdenliveSettings::setColortheme(theme);
4130 // Make palette for all widgets.
4131 QPalette plt = kapp->palette();
4132 if (theme.isEmpty()) {
4133 plt = QApplication::desktop()->palette();
4135 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
4137 #if KDE_IS_VERSION(4,6,3)
4138 plt = KGlobalSettings::createNewApplicationPalette(config);
4140 // Since there was a bug in createApplicationPalette in KDE < 4.6.3 we need
4141 // to do the palette loading stuff ourselves. (https://bugs.kde.org/show_bug.cgi?id=263497)
4142 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
4143 QPalette::Disabled };
4144 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
4145 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
4147 for ( int i = 0; i < 3 ; i++ ) {
4148 QPalette::ColorGroup state = states[i];
4149 KColorScheme schemeView(state, KColorScheme::View, config);
4150 KColorScheme schemeWindow(state, KColorScheme::Window, config);
4151 KColorScheme schemeButton(state, KColorScheme::Button, config);
4152 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
4154 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
4155 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
4156 plt.setBrush( state, QPalette::Base, schemeView.background() );
4157 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
4158 plt.setBrush( state, QPalette::Button, schemeButton.background() );
4159 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
4160 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
4161 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
4162 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
4163 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
4165 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
4166 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
4167 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
4168 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
4169 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
4171 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
4172 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
4173 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
4178 kapp->setPalette(plt);
4179 const QObjectList children = statusBar()->children();
4181 foreach(QObject * child, children) {
4182 if (child->isWidgetType())
4183 ((QWidget*)child)->setPalette(plt);
4184 const QObjectList subchildren = child->children();
4185 foreach(QObject * subchild, subchildren) {
4186 if (subchild->isWidgetType())
4187 ((QWidget*)subchild)->setPalette(plt);
4190 if (m_activeTimeline) {
4191 m_activeTimeline->projectView()->updatePalette();
4196 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4198 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4199 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4200 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4201 const QSize bitsSize(24, 2);
4202 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4203 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4205 QPixmap pixmap(23, 16);
4206 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4208 KConfigGroup group(config, "WM");
4209 QPainter p(&pixmap);
4210 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4211 p.fillRect(1, 1, 7, 7, windowScheme.background());
4212 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4214 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4215 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4216 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4218 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4219 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4221 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4222 p.fillRect(1, 8, 7, 7, viewScheme.background());
4223 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4225 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4226 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4227 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4229 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4230 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4236 void MainWindow::slotSwitchMonitors()
4238 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4239 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4240 else m_projectList->focusTree();
4243 void MainWindow::slotInsertZoneToTree()
4245 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4246 QStringList info = m_clipMonitor->getZoneInfo();
4247 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4250 void MainWindow::slotInsertZoneToTimeline()
4252 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4253 QStringList info = m_clipMonitor->getZoneInfo();
4254 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4258 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4260 if (m_activeDocument && m_activeTimeline) {
4261 if (!ids.isEmpty()) {
4262 for (int i = 0; i < ids.size(); ++i) {
4263 m_activeTimeline->slotDeleteClip(ids.at(i));
4265 m_activeDocument->clipManager()->slotDeleteClips(ids);
4267 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4268 m_activeDocument->setModified(true);
4272 void MainWindow::slotShowTitleBars(bool show)
4274 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4275 for (int i = 0; i < docks.count(); i++) {
4276 QDockWidget* dock = docks.at(i);
4278 dock->setTitleBarWidget(0);
4280 if (!dock->isFloating()) {
4281 dock->setTitleBarWidget(new QWidget);
4285 KdenliveSettings::setShowtitlebars(show);
4288 void MainWindow::slotSwitchTitles()
4290 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4293 QString MainWindow::getMimeType(bool open)
4295 QString mimetype = "application/x-kdenlive";
4296 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4298 mimetype = "*.kdenlive";
4299 if (open) mimetype.append(" *.tar.gz");
4301 else if (open) mimetype.append(" application/x-compressed-tar");
4305 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4308 m_projectMonitor->render->sendFrameForAnalysis = true;
4311 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4312 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4319 qDebug() << "Any scope accepting new frames? " << request;
4322 m_projectMonitor->render->sendFrameForAnalysis = false;
4327 void MainWindow::slotOpenStopmotion()
4329 if (m_stopmotion == NULL) {
4330 m_stopmotion = new StopmotionWidget(m_monitorManager, m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4331 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString &)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4332 //for (int i = 0; i < m_gfxScopesList.count(); i++) {
4333 // Check if we need the renderer to send a new frame for update
4334 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4335 //connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4336 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4339 m_stopmotion->show();
4342 void MainWindow::slotDeleteClip(const QString &id)
4344 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4345 for (int i = 0; i < list.size(); ++i) {
4346 list.at(i)->disableClipId(id);
4348 m_projectList->slotDeleteClip(id);
4351 void MainWindow::slotUpdateProxySettings()
4353 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4354 if (KdenliveSettings::enableproxy())
4355 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4356 m_projectList->updateProxyConfig();
4359 void MainWindow::slotInsertNotesTimecode()
4361 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4362 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4363 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4366 void MainWindow::slotArchiveProject()
4368 QList <DocClipBase*> list = m_projectList->documentClipList();
4369 QDomDocument doc = m_activeDocument->xmlSceneList(m_projectMonitor->sceneList(), m_projectList->expandedFolders());
4370 ArchiveWidget *d = new ArchiveWidget(m_activeDocument->url().fileName(), doc, list, m_activeTimeline->projectView()->extractTransitionsLumas(), this);
4375 void MainWindow::slotOpenBackupDialog(const KUrl url)
4380 kDebug()<<"// BACKUP URL: "<<url.path();
4381 if (!url.isEmpty()) {
4382 // we could not open the project file, guess where the backups are
4383 projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
4387 projectFolder = m_activeDocument->projectFolder();
4388 projectFile = m_activeDocument->url();
4389 projectId = m_activeDocument->getDocumentProperty("documentid");
4392 BackupWidget *dia = new BackupWidget(projectFile, projectFolder, projectId, this);
4393 if (dia->exec() == QDialog::Accepted) {
4394 QString requestedBackup = dia->selectedFile();
4395 m_activeDocument->backupLastSavedVersion(projectFile.path());
4396 closeCurrentDocument(false);
4397 doOpenFile(KUrl(requestedBackup), NULL);
4398 m_activeDocument->setUrl(projectFile);
4399 m_activeDocument->setModified(true);
4400 setCaption(m_activeDocument->description());
4405 void MainWindow::slotElapsedTime()
4407 kDebug()<<"-----------------------------------------\n"<<"Time elapsed: "<<m_timer.elapsed()<<"\n-------------------------";
4411 void MainWindow::slotDownloadResources()
4413 QString currentFolder;
4414 if (m_activeDocument) currentFolder = m_activeDocument->projectFolder().path();
4415 else currentFolder = KdenliveSettings::defaultprojectfolder();
4416 ResourceWidget *d = new ResourceWidget(currentFolder);
4417 connect(d, SIGNAL(addClip(KUrl, const QString &)), this, SLOT(slotAddProjectClip(KUrl, const QString &)));
4421 #include "mainwindow.moc"