1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
55 #include "vectorscope.h"
57 #include "rgbparade.h"
58 #include "histogram.h"
60 #include <KApplication>
64 #include <KActionCollection>
65 #include <KActionCategory>
66 #include <KStandardAction>
67 #include <KShortcutsDialog>
68 #include <KFileDialog>
69 #include <KMessageBox>
71 #include <KIO/NetAccess>
74 #include <KConfigDialog>
75 #include <KXMLGUIFactory>
77 #include <kstandarddirs.h>
78 #include <KUrlRequesterDialog>
79 #include <KTemporaryFile>
81 #include <KActionMenu>
84 #include <ktogglefullscreenaction.h>
86 #include <KNotification>
87 #include <KNotifyConfigWidget>
88 #if KDE_IS_VERSION(4,3,80)
89 #include <knewstuff3/downloaddialog.h>
90 #include <knewstuff3/knewstuffaction.h>
92 #include <knewstuff2/engine.h>
93 #include <knewstuff2/ui/knewstuffaction.h>
95 #endif /* KDE_IS_VERSION(4,3,80) */
97 #include <KColorScheme>
99 #include <QTextStream>
103 #include <QInputDialog>
104 #include <QDesktopWidget>
109 static const char version[] = VERSION;
111 static const int ID_TIMELINE_POS = 0;
118 EffectsList MainWindow::videoEffects;
119 EffectsList MainWindow::audioEffects;
120 EffectsList MainWindow::customEffects;
121 EffectsList MainWindow::transitions;
123 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
124 KXmlGuiWindow(parent),
125 m_activeDocument(NULL),
126 m_activeTimeline(NULL),
127 m_renderWidget(NULL),
128 #ifndef NO_JOGSHUTTLE
130 #endif /* NO_JOGSHUTTLE */
131 m_findActivated(false)
134 // Create DBus interface
135 new MainWindowAdaptor(this);
136 QDBusConnection dbus = QDBusConnection::sessionBus();
137 dbus.registerObject("/MainWindow", this);
139 setlocale(LC_NUMERIC, "POSIX");
140 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
141 setFont(KGlobalSettings::toolBarFont());
142 parseProfiles(MltPath);
143 m_commandStack = new QUndoGroup;
144 m_timelineArea = new KTabWidget(this);
145 m_timelineArea->setTabReorderingEnabled(true);
146 m_timelineArea->setTabBarHidden(true);
147 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
148 m_timelineArea->setMinimumHeight(200);
150 QToolButton *closeTabButton = new QToolButton;
151 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
152 closeTabButton->setIcon(KIcon("tab-close"));
153 closeTabButton->adjustSize();
154 closeTabButton->setToolTip(i18n("Close the current tab"));
155 m_timelineArea->setCornerWidget(closeTabButton);
156 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
158 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
159 m_findTimer.setSingleShot(true);
161 // FIXME: the next call returns a newly allocated object, which leaks
162 initEffects::parseEffectFiles();
163 //initEffects::parseCustomEffectsFile();
165 m_monitorManager = new MonitorManager();
167 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
168 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
173 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
174 m_projectListDock->setObjectName("project_tree");
175 m_projectList = new ProjectList(this);
176 m_projectListDock->setWidget(m_projectList);
177 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
179 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
180 m_clipMonitorDock->setObjectName("clip_monitor");
181 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
182 m_clipMonitorDock->setWidget(m_clipMonitor);
183 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
185 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
186 m_projectMonitorDock->setObjectName("project_monitor");
187 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
188 m_projectMonitorDock->setWidget(m_projectMonitor);
189 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
192 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
193 m_recMonitorDock->setObjectName("record_monitor");
194 m_recMonitor = new RecMonitor("record", this);
195 m_recMonitorDock->setWidget(m_recMonitor);
196 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
197 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
198 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
201 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
202 m_effectStackDock->setObjectName("effect_stack");
203 m_effectStack = new EffectStackView(m_projectMonitor, this);
204 m_effectStackDock->setWidget(m_effectStack);
205 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
207 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
208 m_transitionConfigDock->setObjectName("transition");
209 m_transitionConfig = new TransitionSettings(m_projectMonitor, this);
210 m_transitionConfigDock->setWidget(m_transitionConfig);
211 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
213 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
214 m_effectListDock->setObjectName("effect_list");
215 m_effectList = new EffectsListView();
216 m_effectListDock->setWidget(m_effectList);
217 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
219 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor, this);
220 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
221 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
222 m_vectorscopeDock->setWidget(m_vectorscope);
223 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
224 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
225 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
226 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
227 m_scopesList.append(m_vectorscopeDock);
229 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor, this);
230 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
231 m_waveformDock->setObjectName(m_waveform->widgetName());
232 m_waveformDock->setWidget(m_waveform);
233 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
234 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
235 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
236 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
237 m_scopesList.append(m_waveformDock);
239 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor, this);
240 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
241 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
242 m_RGBParadeDock->setWidget(m_RGBParade);
243 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
244 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
245 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
246 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
247 m_scopesList.append(m_RGBParadeDock);
249 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor, this);
250 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
251 m_histogramDock->setObjectName(m_histogram->widgetName());
252 m_histogramDock->setWidget(m_histogram);
253 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
254 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
255 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
256 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
257 m_scopesList.append(m_histogramDock);
260 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
261 m_undoViewDock->setObjectName("undo_history");
262 m_undoView = new QUndoView(this);
263 m_undoView->setCleanIcon(KIcon("edit-clear"));
264 m_undoView->setEmptyLabel(i18n("Clean"));
265 m_undoViewDock->setWidget(m_undoView);
266 m_undoView->setGroup(m_commandStack);
267 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
269 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
270 //overviewDock->setObjectName("project_overview");
271 //m_overView = new CustomTrackView(NULL, NULL, this);
272 //overviewDock->setWidget(m_overView);
273 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
278 /// Tabify Widgets ///
279 tabifyDockWidget(m_projectListDock, m_effectStackDock);
280 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
283 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
285 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
288 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
289 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
290 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
291 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
292 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
295 setCentralWidget(m_timelineArea);
298 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
299 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
301 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
302 m_fileRevert->setEnabled(false);
308 // Find QDockWidget tab bars and show / hide widget title bars on right click
309 QList <QTabBar *> tabs = findChildren<QTabBar *>();
310 for (int i = 0; i < tabs.count(); i++) {
311 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
312 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
315 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
316 guiFactory()->addClient(sp);*/
320 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
322 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
323 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
325 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
326 clipInTimeline->setIcon(KIcon("go-jump"));
327 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
328 static_cast<QMenu*>(factory()->container("transcoders", this)),
332 // build themes menus
333 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
334 QActionGroup *themegroup = new QActionGroup(this);
335 themegroup->setExclusive(true);
336 action = new KAction(i18n("Default"), this);
337 action->setCheckable(true);
338 themegroup->addAction(action);
339 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
341 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
343 for (int i = 0; i < schemeFiles.size(); ++i) {
345 const QString filename = schemeFiles.at(i);
346 const QFileInfo info(filename);
349 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
350 QIcon icon = createSchemePreviewIcon(config);
351 KConfigGroup group(config, "General");
352 const QString name = group.readEntry("Name", info.baseName());
353 action = new KAction(name, this);
354 action->setData(filename);
355 action->setIcon(icon);
356 action->setCheckable(true);
357 themegroup->addAction(action);
358 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
361 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
362 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
363 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
366 action = new QAction(fi.fileName(), this);
367 action->setData(*it);
368 action->setCheckable(true);
369 themegroup->addAction(action);
370 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
372 themesMenu->addActions(themegroup->actions());
373 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
375 // Setup and fill effects and transitions menus.
376 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
377 for (int i = 0; i < videoEffects.count(); ++i)
378 m_videoEffectsMenu->addAction(m_videoEffects[i]);
379 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
380 for (int i = 0; i < audioEffects.count(); ++i)
381 m_audioEffectsMenu->addAction(m_audioEffects[i]);
382 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
383 if (customEffects.isEmpty())
384 m_customEffectsMenu->setEnabled(false);
386 m_customEffectsMenu->setEnabled(true);
387 for (int i = 0; i < customEffects.count(); ++i)
388 m_customEffectsMenu->addAction(m_customEffects[i]);
389 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
390 for (int i = 0; i < transitions.count(); ++i)
391 m_transitionsMenu->addAction(m_transitions[i]);
393 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
394 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
395 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
396 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
398 QMenu *newEffect = new QMenu(this);
399 newEffect->addMenu(m_videoEffectsMenu);
400 newEffect->addMenu(m_audioEffectsMenu);
401 newEffect->addMenu(m_customEffectsMenu);
402 m_effectStack->setMenu(newEffect);
404 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
405 const QList<QAction *> viewActions = createPopupMenu()->actions();
406 viewMenu->insertActions(NULL, viewActions);
408 m_timelineContextMenu = new QMenu(this);
409 m_timelineContextClipMenu = new QMenu(this);
410 m_timelineContextTransitionMenu = new QMenu(this);
412 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
413 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
414 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
416 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
417 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
418 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
419 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
420 m_timelineContextClipMenu->addSeparator();
421 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
422 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
423 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
424 m_timelineContextClipMenu->addSeparator();
425 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
426 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
427 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
428 m_timelineContextClipMenu->addSeparator();
430 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
431 m_timelineContextClipMenu->addMenu(markersMenu);
432 m_timelineContextClipMenu->addSeparator();
433 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
434 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
435 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
436 //TODO: re-enable custom effects menu when it is implemented
437 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
439 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
440 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
441 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
443 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
445 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
446 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
447 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
448 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
449 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
450 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
451 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
453 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
454 slotConnectMonitors();
456 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
457 KdenliveSettings::setDropbframes(false);
459 // Open or create a file. Command line argument passed in Url has
460 // precedence, then "openlastproject", then just a plain empty file.
461 // If opening Url fails, openlastproject will _not_ be used.
462 if (!Url.isEmpty()) {
463 // delay loading so that the window shows up
465 QTimer::singleShot(500, this, SLOT(openFile()));
466 } else if (KdenliveSettings::openlastproject()) {
467 QTimer::singleShot(500, this, SLOT(openLastFile()));
468 } else { //if (m_timelineArea->count() == 0) {
472 #ifndef NO_JOGSHUTTLE
473 activateShuttleDevice();
474 #endif /* NO_JOGSHUTTLE */
475 m_projectListDock->raise();
478 MainWindow::~MainWindow()
480 m_effectStack->slotClipItemSelected(NULL, 0);
481 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
483 if (m_projectMonitor) m_projectMonitor->stop();
484 if (m_clipMonitor) m_clipMonitor->stop();
486 if (m_activeTimeline) delete m_activeTimeline;
488 delete m_effectStack;
489 delete m_transitionConfig;
491 if (m_activeDocument) delete m_activeDocument;
493 // This sometimes causes crash on exit on OS X for some reason.
494 delete m_projectMonitor;
495 delete m_clipMonitor;
497 delete m_shortcutRemoveFocus;
498 Mlt::Factory::close();
501 void MainWindow::queryQuit()
509 bool MainWindow::queryClose()
511 if (m_renderWidget) {
512 int waitingJobs = m_renderWidget->waitingJobsCount();
513 if (waitingJobs > 0) {
514 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")))) {
515 case KMessageBox::Yes :
516 // create script with waiting jobs and start it
517 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
519 case KMessageBox::No :
520 // Don't do anything, jobs will be deleted
528 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
529 // warn the user to save if document is modified and we have clips in our project list
530 if (m_activeDocument && m_activeDocument->isModified() &&
531 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
532 !m_projectList->documentClipList().isEmpty())) {
536 if (m_activeDocument->url().fileName().isEmpty())
537 message = i18n("Save changes to document?");
539 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
540 switch (KMessageBox::warningYesNoCancel(this, message)) {
541 case KMessageBox::Yes :
542 // save document here. If saving fails, return false;
544 case KMessageBox::No :
545 // User does not want to save the changes, clear recovery files
546 m_activeDocument->m_autosave->resize(0);
555 void MainWindow::loadPlugins()
557 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
558 populateMenus(plugin);
561 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
563 filters << "libkdenlive*";
564 foreach(const QString &folder, directories) {
565 kDebug() << "Parsing plugin folder: " << folder;
566 QDir pluginsDir(folder);
567 foreach(const QString &fileName,
568 pluginsDir.entryList(filters, QDir::Files)) {
570 * Avoid loading the same plugin twice when there is more than one
573 if (!m_pluginFileNames.contains(fileName)) {
574 kDebug() << "Found plugin: " << fileName;
575 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
576 QObject *plugin = loader.instance();
578 populateMenus(plugin);
579 m_pluginFileNames += fileName;
581 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
587 void MainWindow::populateMenus(QObject *plugin)
589 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
590 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
592 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
596 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
597 QMenu *menu, const char *member,
598 QActionGroup *actionGroup)
600 kDebug() << "// ADD to MENU" << texts;
601 foreach(const QString &text, texts) {
602 QAction *action = new QAction(text, plugin);
603 action->setData(text);
604 connect(action, SIGNAL(triggered()), this, member);
605 menu->addAction(action);
608 action->setCheckable(true);
609 actionGroup->addAction(action);
614 void MainWindow::aboutPlugins()
616 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
621 void MainWindow::generateClip()
623 QAction *action = qobject_cast<QAction *>(sender());
624 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
626 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
627 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
628 if (!clipUrl.isEmpty()) {
629 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
633 void MainWindow::saveProperties(KConfigGroup &config)
635 // save properties here,used by session management
637 KMainWindow::saveProperties(config);
641 void MainWindow::readProperties(const KConfigGroup &config)
643 // read properties here,used by session management
644 KMainWindow::readProperties(config);
645 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
646 openFile(KUrl(Lastproject));
649 void MainWindow::slotReloadEffects()
651 m_customEffectsMenu->clear();
652 initEffects::parseCustomEffectsFile();
654 QStringList effectInfo;
655 QMap<QString, QStringList> effectsList;
656 for (int ix = 0; ix < customEffects.count(); ix++) {
657 effectInfo = customEffects.effectIdInfo(ix);
658 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
660 if (effectsList.isEmpty())
661 m_customEffectsMenu->setEnabled(false);
663 m_customEffectsMenu->setEnabled(true);
665 foreach(const QStringList &value, effectsList) {
666 action = new QAction(value.at(0), this);
667 action->setData(value);
668 m_customEffectsMenu->addAction(action);
670 m_effectList->reloadEffectList();
673 #ifndef NO_JOGSHUTTLE
674 void MainWindow::activateShuttleDevice()
678 if (KdenliveSettings::enableshuttle() == false) return;
679 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
680 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
681 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
682 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
683 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
684 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
685 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
688 void MainWindow::slotShuttleButton(int code)
692 slotShuttleAction(KdenliveSettings::shuttle1());
695 slotShuttleAction(KdenliveSettings::shuttle2());
698 slotShuttleAction(KdenliveSettings::shuttle3());
701 slotShuttleAction(KdenliveSettings::shuttle4());
704 slotShuttleAction(KdenliveSettings::shuttle5());
709 void MainWindow::slotShuttleAction(int code)
715 m_monitorManager->slotPlay();
718 m_monitorManager->slotPlay();
722 #endif /* NO_JOGSHUTTLE */
724 void MainWindow::configureNotifications()
726 KNotifyConfigWidget::configure(this);
729 void MainWindow::slotFullScreen()
731 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
734 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
736 if (!m_activeDocument) return;
737 if (effect.isNull()) {
738 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
741 QDomElement effectToAdd = effect.cloneNode().toElement();
742 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
745 void MainWindow::slotRaiseMonitor(bool clipMonitor)
747 if (clipMonitor) m_clipMonitorDock->raise();
748 else m_projectMonitorDock->raise();
751 void MainWindow::slotUpdateClip(const QString &id)
753 if (!m_activeDocument) return;
754 m_activeTimeline->projectView()->slotUpdateClip(id);
757 void MainWindow::slotConnectMonitors()
759 m_projectList->setRenderer(m_projectMonitor->render);
760 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
761 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
762 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
763 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
764 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
765 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
766 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
768 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
770 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
772 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
773 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
775 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
777 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
778 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
781 void MainWindow::slotAdjustClipMonitor()
783 m_clipMonitorDock->updateGeometry();
784 m_clipMonitorDock->adjustSize();
785 m_clipMonitor->resetSize();
788 void MainWindow::slotAdjustProjectMonitor()
790 m_projectMonitorDock->updateGeometry();
791 m_projectMonitorDock->adjustSize();
792 m_projectMonitor->resetSize();
795 void MainWindow::setupActions()
798 KActionCollection* collection = actionCollection();
799 m_timecodeFormat = new KComboBox(this);
800 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
801 m_timecodeFormat->addItem(i18n("Frames"));
802 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
803 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
805 m_statusProgressBar = new QProgressBar(this);
806 m_statusProgressBar->setMinimum(0);
807 m_statusProgressBar->setMaximum(100);
808 m_statusProgressBar->setMaximumWidth(150);
809 m_statusProgressBar->setVisible(false);
811 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
812 toolbar->setMovable(false);
813 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
814 QString style1 = "QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
815 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
817 //create edit mode buttons
818 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
819 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
820 toolbar->addAction(m_normalEditTool);
821 m_normalEditTool->setCheckable(true);
822 m_normalEditTool->setChecked(true);
824 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
825 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
826 toolbar->addAction(m_overwriteEditTool);
827 m_overwriteEditTool->setCheckable(true);
828 m_overwriteEditTool->setChecked(false);
830 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
831 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
832 toolbar->addAction(m_insertEditTool);
833 m_insertEditTool->setCheckable(true);
834 m_insertEditTool->setChecked(false);
835 // not implemented yet
836 m_insertEditTool->setEnabled(false);
838 QActionGroup *editGroup = new QActionGroup(this);
839 editGroup->addAction(m_normalEditTool);
840 editGroup->addAction(m_overwriteEditTool);
841 editGroup->addAction(m_insertEditTool);
842 editGroup->setExclusive(true);
843 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
844 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
846 toolbar->addSeparator();
848 // create tools buttons
849 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
850 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
851 toolbar->addAction(m_buttonSelectTool);
852 m_buttonSelectTool->setCheckable(true);
853 m_buttonSelectTool->setChecked(true);
855 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
856 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
857 toolbar->addAction(m_buttonRazorTool);
858 m_buttonRazorTool->setCheckable(true);
859 m_buttonRazorTool->setChecked(false);
861 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
862 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
863 toolbar->addAction(m_buttonSpacerTool);
864 m_buttonSpacerTool->setCheckable(true);
865 m_buttonSpacerTool->setChecked(false);
867 QActionGroup *toolGroup = new QActionGroup(this);
868 toolGroup->addAction(m_buttonSelectTool);
869 toolGroup->addAction(m_buttonRazorTool);
870 toolGroup->addAction(m_buttonSpacerTool);
871 toolGroup->setExclusive(true);
872 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
874 QWidget * actionWidget;
875 int max = toolbar->iconSizeDefault() + 2;
876 actionWidget = toolbar->widgetForAction(m_normalEditTool);
877 actionWidget->setMaximumWidth(max);
878 actionWidget->setMaximumHeight(max - 4);
880 actionWidget = toolbar->widgetForAction(m_insertEditTool);
881 actionWidget->setMaximumWidth(max);
882 actionWidget->setMaximumHeight(max - 4);
884 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
885 actionWidget->setMaximumWidth(max);
886 actionWidget->setMaximumHeight(max - 4);
888 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
889 actionWidget->setMaximumWidth(max);
890 actionWidget->setMaximumHeight(max - 4);
892 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
893 actionWidget->setMaximumWidth(max);
894 actionWidget->setMaximumHeight(max - 4);
896 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
897 actionWidget->setMaximumWidth(max);
898 actionWidget->setMaximumHeight(max - 4);
900 toolbar->setStyleSheet(style1);
901 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
903 toolbar->addSeparator();
904 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
905 toolbar->addAction(m_buttonFitZoom);
906 m_buttonFitZoom->setCheckable(false);
908 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
909 toolbar->addAction(m_zoomOut);
910 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
912 m_zoomSlider = new QSlider(Qt::Horizontal, this);
913 m_zoomSlider->setMaximum(13);
914 m_zoomSlider->setPageStep(1);
915 m_zoomSlider->setInvertedAppearance(true);
917 m_zoomSlider->setMaximumWidth(150);
918 m_zoomSlider->setMinimumWidth(100);
919 toolbar->addWidget(m_zoomSlider);
921 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
922 toolbar->addAction(m_zoomIn);
923 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
925 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
926 actionWidget->setMaximumWidth(max);
927 actionWidget->setMaximumHeight(max - 4);
928 actionWidget->setStyleSheet(styleBorderless);
930 actionWidget = toolbar->widgetForAction(m_zoomIn);
931 actionWidget->setMaximumWidth(max);
932 actionWidget->setMaximumHeight(max - 4);
933 actionWidget->setStyleSheet(styleBorderless);
935 actionWidget = toolbar->widgetForAction(m_zoomOut);
936 actionWidget->setMaximumWidth(max);
937 actionWidget->setMaximumHeight(max - 4);
938 actionWidget->setStyleSheet(styleBorderless);
940 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
941 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
942 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
943 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
944 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
946 toolbar->addSeparator();
948 //create automatic audio split button
949 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
950 toolbar->addAction(m_buttonAutomaticSplitAudio);
951 m_buttonAutomaticSplitAudio->setCheckable(true);
952 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
953 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
955 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
956 toolbar->addAction(m_buttonVideoThumbs);
957 m_buttonVideoThumbs->setCheckable(true);
958 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
959 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
961 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
962 toolbar->addAction(m_buttonAudioThumbs);
963 m_buttonAudioThumbs->setCheckable(true);
964 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
965 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
967 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
968 toolbar->addAction(m_buttonShowMarkers);
969 m_buttonShowMarkers->setCheckable(true);
970 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
971 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
973 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
974 toolbar->addAction(m_buttonSnap);
975 m_buttonSnap->setCheckable(true);
976 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
977 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
979 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
980 actionWidget->setMaximumWidth(max);
981 actionWidget->setMaximumHeight(max - 4);
983 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
984 actionWidget->setMaximumWidth(max);
985 actionWidget->setMaximumHeight(max - 4);
987 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
988 actionWidget->setMaximumWidth(max);
989 actionWidget->setMaximumHeight(max - 4);
991 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
992 actionWidget->setMaximumWidth(max);
993 actionWidget->setMaximumHeight(max - 4);
995 actionWidget = toolbar->widgetForAction(m_buttonSnap);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
999 m_messageLabel = new StatusBarMessageLabel(this);
1000 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1002 statusBar()->addWidget(m_messageLabel, 10);
1003 statusBar()->addWidget(m_statusProgressBar, 0);
1004 statusBar()->addPermanentWidget(toolbar);
1005 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1006 statusBar()->addPermanentWidget(m_timecodeFormat);
1007 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1009 collection->addAction("normal_mode", m_normalEditTool);
1010 collection->addAction("overwrite_mode", m_overwriteEditTool);
1011 collection->addAction("insert_mode", m_insertEditTool);
1012 collection->addAction("select_tool", m_buttonSelectTool);
1013 collection->addAction("razor_tool", m_buttonRazorTool);
1014 collection->addAction("spacer_tool", m_buttonSpacerTool);
1016 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1017 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1018 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1019 collection->addAction("show_markers", m_buttonShowMarkers);
1020 collection->addAction("snap", m_buttonSnap);
1021 collection->addAction("zoom_fit", m_buttonFitZoom);
1022 collection->addAction("zoom_in", m_zoomIn);
1023 collection->addAction("zoom_out", m_zoomOut);
1025 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1026 collection->addAction("project_find", m_projectSearch);
1027 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1028 m_projectSearch->setShortcut(Qt::Key_Slash);
1030 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1031 collection->addAction("project_find_next", m_projectSearchNext);
1032 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1033 m_projectSearchNext->setShortcut(Qt::Key_F3);
1034 m_projectSearchNext->setEnabled(false);
1036 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1037 collection->addAction("manage_profiles", profilesAction);
1038 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1040 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1041 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1042 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1043 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1045 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1046 collection->addAction("run_wizard", wizAction);
1047 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1049 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1050 collection->addAction("project_settings", projectAction);
1051 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1053 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1054 collection->addAction("project_render", projectRender);
1055 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1056 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1058 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1059 collection->addAction("project_clean", projectClean);
1060 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1062 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1063 KShortcut playShortcut;
1064 playShortcut.setPrimary(Qt::Key_Space);
1065 playShortcut.setAlternate(Qt::Key_K);
1066 monitorPlay->setShortcut(playShortcut);
1067 collection->addAction("monitor_play", monitorPlay);
1068 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1070 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1071 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1072 collection->addAction("monitor_play_zone", m_playZone);
1073 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1075 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1076 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1077 collection->addAction("monitor_loop_zone", m_loopZone);
1078 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1080 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1081 collection->addAction("dvd_wizard", dvdWizard);
1082 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1084 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1085 collection->addAction("transcode_clip", transcodeClip);
1086 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1088 KAction *markIn = collection->addAction("mark_in");
1089 markIn->setText(i18n("Set Zone In"));
1090 markIn->setShortcut(Qt::Key_I);
1091 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1093 KAction *markOut = collection->addAction("mark_out");
1094 markOut->setText(i18n("Set Zone Out"));
1095 markOut->setShortcut(Qt::Key_O);
1096 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1098 KAction *switchMon = collection->addAction("switch_monitor");
1099 switchMon->setText(i18n("Switch monitor"));
1100 switchMon->setShortcut(Qt::Key_T);
1101 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1103 KAction *insertTree = collection->addAction("insert_project_tree");
1104 insertTree->setText(i18n("Insert zone in project tree"));
1105 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1106 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1108 KAction *insertTimeline = collection->addAction("insert_timeline");
1109 insertTimeline->setText(i18n("Insert zone in timeline"));
1110 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1111 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1113 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1114 collection->addAction("resize_timeline_clip_start", resizeStart);
1115 resizeStart->setShortcut(Qt::Key_1);
1116 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1118 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1119 collection->addAction("resize_timeline_clip_end", resizeEnd);
1120 resizeEnd->setShortcut(Qt::Key_2);
1121 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1123 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1124 monitorSeekBackward->setShortcut(Qt::Key_J);
1125 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1126 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1128 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1129 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1130 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1131 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1133 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1134 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1135 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1136 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1138 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1139 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1140 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1141 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1143 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1144 monitorSeekForward->setShortcut(Qt::Key_L);
1145 collection->addAction("monitor_seek_forward", monitorSeekForward);
1146 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1148 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1149 clipStart->setShortcut(Qt::Key_Home);
1150 collection->addAction("seek_clip_start", clipStart);
1151 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1153 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1154 clipEnd->setShortcut(Qt::Key_End);
1155 collection->addAction("seek_clip_end", clipEnd);
1156 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1158 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1159 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1160 collection->addAction("seek_zone_start", zoneStart);
1161 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1163 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1164 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1165 collection->addAction("seek_zone_end", zoneEnd);
1166 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1168 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1169 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1170 collection->addAction("seek_start", projectStart);
1171 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1173 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1174 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1175 collection->addAction("seek_end", projectEnd);
1176 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1178 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1179 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1180 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1181 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1183 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1184 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1185 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1186 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1188 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1189 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1190 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1191 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1193 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1194 deleteItem->setShortcut(Qt::Key_Delete);
1195 collection->addAction("delete_timeline_clip", deleteItem);
1196 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1198 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1199 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1200 editTimelineClipSpeed->setData("change_speed");
1201 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1203 KAction *stickTransition = collection->addAction("auto_transition");
1204 stickTransition->setData(QString("auto"));
1205 stickTransition->setCheckable(true);
1206 stickTransition->setEnabled(false);
1207 stickTransition->setText(i18n("Automatic Transition"));
1208 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1210 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1211 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1212 collection->addAction("group_clip", groupClip);
1213 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1215 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1216 collection->addAction("ungroup_clip", ungroupClip);
1217 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1218 ungroupClip->setData("ungroup_clip");
1219 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1221 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1222 collection->addAction("edit_item_duration", editItemDuration);
1223 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1225 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1226 collection->addAction("clip_in_project_tree", clipInProjectTree);
1227 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1229 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1230 collection->addAction("clip_to_project_tree", clipToProjectTree);
1231 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1233 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1234 insertOvertwrite->setShortcut(Qt::Key_V);
1235 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1236 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1238 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1239 selectTimelineClip->setShortcut(Qt::Key_Plus);
1240 collection->addAction("select_timeline_clip", selectTimelineClip);
1241 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1243 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1244 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1245 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1246 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1248 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1249 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1250 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1251 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1253 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1254 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1255 collection->addAction("select_timeline_transition", selectTimelineTransition);
1256 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1258 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1259 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1260 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1261 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1263 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1264 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1265 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1266 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1268 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1269 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1270 collection->addAction("cut_timeline_clip", cutTimelineClip);
1271 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1273 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1274 collection->addAction("add_clip_marker", addClipMarker);
1275 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1277 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1278 collection->addAction("delete_clip_marker", deleteClipMarker);
1279 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1281 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1282 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1283 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1285 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1286 collection->addAction("edit_clip_marker", editClipMarker);
1287 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1289 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1290 collection->addAction("split_audio", splitAudio);
1291 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1293 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1294 collection->addAction("clip_audio_only", audioOnly);
1295 audioOnly->setData("clip_audio_only");
1296 audioOnly->setCheckable(true);
1298 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1299 collection->addAction("clip_video_only", videoOnly);
1300 videoOnly->setData("clip_video_only");
1301 videoOnly->setCheckable(true);
1303 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1304 collection->addAction("clip_audio_and_video", audioAndVideo);
1305 audioAndVideo->setData("clip_audio_and_video");
1306 audioAndVideo->setCheckable(true);
1308 m_clipTypeGroup = new QActionGroup(this);
1309 m_clipTypeGroup->addAction(audioOnly);
1310 m_clipTypeGroup->addAction(videoOnly);
1311 m_clipTypeGroup->addAction(audioAndVideo);
1312 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1313 m_clipTypeGroup->setEnabled(false);
1315 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1316 collection->addAction("insert_space", insertSpace);
1317 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1319 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1320 collection->addAction("delete_space", removeSpace);
1321 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1323 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1324 collection->addAction("insert_track", insertTrack);
1325 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1327 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1328 collection->addAction("delete_track", deleteTrack);
1329 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1331 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1332 collection->addAction("config_tracks", configTracks);
1333 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1335 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1336 collection->addAction("add_guide", addGuide);
1337 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1339 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1340 collection->addAction("delete_guide", delGuide);
1341 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1343 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1344 collection->addAction("edit_guide", editGuide);
1345 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1347 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1348 collection->addAction("delete_all_guides", delAllGuides);
1349 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1351 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1352 collection->addAction("paste_effects", pasteEffects);
1353 pasteEffects->setData("paste_effects");
1354 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1356 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1357 collection->addAction("show_timeline", showTimeline);
1358 showTimeline->setCheckable(true);
1359 showTimeline->setChecked(true);
1360 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1362 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1363 collection->addAction("show_titlebars", showTitleBar);
1364 showTitleBar->setCheckable(true);
1365 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1366 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1367 slotShowTitleBars(KdenliveSettings::showtitlebars());
1369 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1370 collection->addAction("maximize_current", maxCurrent);
1371 maxCurrent->setCheckable(true);
1372 maxCurrent->setChecked(false);
1373 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1375 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1376 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1377 KStandardAction::open(this, SLOT(openFile()), collection);
1378 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1379 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1380 KStandardAction::openNew(this, SLOT(newFile()), collection);
1381 // TODO: make the following connection to slotEditKeys work
1382 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1383 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1384 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1385 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1386 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1387 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1389 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1390 undo->setEnabled(false);
1391 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1393 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1394 redo->setEnabled(false);
1395 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1398 //TODO: Add status tooltip to actions ?
1399 connect(collection, SIGNAL(actionHovered(QAction*)),
1400 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1403 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1404 collection->addAction("add_clip", addClip);
1405 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1407 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1408 collection->addAction("add_color_clip", addColorClip);
1409 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1411 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1412 collection->addAction("add_slide_clip", addSlideClip);
1413 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1415 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1416 collection->addAction("add_text_clip", addTitleClip);
1417 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1419 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1420 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1421 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1423 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1424 collection->addAction("add_folder", addFolderButton);
1425 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1427 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1428 collection->addAction("clip_properties", clipProperties);
1429 clipProperties->setData("clip_properties");
1430 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1431 clipProperties->setEnabled(false);
1433 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1434 collection->addAction("edit_clip", openClip);
1435 openClip->setData("edit_clip");
1436 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1437 openClip->setEnabled(false);
1439 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1440 collection->addAction("delete_clip", deleteClip);
1441 deleteClip->setData("delete_clip");
1442 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1443 deleteClip->setEnabled(false);
1445 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1446 collection->addAction("reload_clip", reloadClip);
1447 reloadClip->setData("reload_clip");
1448 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1449 reloadClip->setEnabled(false);
1451 QMenu *addClips = new QMenu();
1452 addClips->addAction(addClip);
1453 addClips->addAction(addColorClip);
1454 addClips->addAction(addSlideClip);
1455 addClips->addAction(addTitleClip);
1456 addClips->addAction(addTitleTemplateClip);
1457 addClips->addAction(addFolderButton);
1459 addClips->addAction(reloadClip);
1460 addClips->addAction(clipProperties);
1461 addClips->addAction(openClip);
1462 addClips->addAction(deleteClip);
1463 m_projectList->setupMenu(addClips, addClip);
1465 // Setup effects and transitions actions.
1466 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1467 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1468 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1469 m_videoEffects = new KAction*[videoEffects.count()];
1470 for (int i = 0; i < videoEffects.count(); ++i) {
1471 QStringList effectInfo = videoEffects.effectIdInfo(i);
1472 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1473 m_videoEffects[i]->setData(effectInfo);
1474 m_videoEffects[i]->setIconVisibleInMenu(false);
1475 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1477 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1478 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1479 m_audioEffects = new KAction*[audioEffects.count()];
1480 for (int i = 0; i < audioEffects.count(); ++i) {
1481 QStringList effectInfo = audioEffects.effectIdInfo(i);
1482 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1483 m_audioEffects[i]->setData(effectInfo);
1484 m_audioEffects[i]->setIconVisibleInMenu(false);
1485 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1487 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1488 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1489 m_customEffects = new KAction*[customEffects.count()];
1490 for (int i = 0; i < customEffects.count(); ++i) {
1491 QStringList effectInfo = customEffects.effectIdInfo(i);
1492 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1493 m_customEffects[i]->setData(effectInfo);
1494 m_customEffects[i]->setIconVisibleInMenu(false);
1495 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1497 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1498 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1499 m_transitions = new KAction*[transitions.count()];
1500 for (int i = 0; i < transitions.count(); i++) {
1501 QStringList effectInfo = transitions.effectIdInfo(i);
1502 m_transitions[i] = new KAction(effectInfo.at(0), this);
1503 m_transitions[i]->setData(effectInfo);
1504 m_transitions[i]->setIconVisibleInMenu(false);
1505 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1507 m_effectsActionCollection->readSettings();
1509 //connect(collection, SIGNAL( clearStatusText() ),
1510 //statusBar(), SLOT( clear() ) );
1513 void MainWindow::slotDisplayActionMessage(QAction *a)
1515 statusBar()->showMessage(a->data().toString(), 3000);
1518 void MainWindow::saveOptions()
1520 KdenliveSettings::self()->writeConfig();
1521 KSharedConfigPtr config = KGlobal::config();
1522 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1523 KConfigGroup treecolumns(config, "Project Tree");
1524 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1528 void MainWindow::readOptions()
1530 KSharedConfigPtr config = KGlobal::config();
1531 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1532 KConfigGroup initialGroup(config, "version");
1533 bool upgrade = false;
1534 if (initialGroup.exists()) {
1535 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1539 if (initialGroup.readEntry("version") == "0.7") {
1540 //Add new settings from 0.7.1
1541 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1542 QString path = QDir::homePath() + "/kdenlive";
1543 if (KStandardDirs::makeDir(path) == false) {
1544 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1545 } else KdenliveSettings::setDefaultprojectfolder(path);
1551 if (!initialGroup.exists() || upgrade) {
1552 // this is our first run, show Wizard
1553 Wizard *w = new Wizard(upgrade, this);
1554 if (w->exec() == QDialog::Accepted && w->isOk()) {
1555 w->adjustSettings();
1556 initialGroup.writeEntry("version", version);
1562 KConfigGroup treecolumns(config, "Project Tree");
1563 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1564 if (!state.isEmpty())
1565 m_projectList->setHeaderInfo(state);
1568 void MainWindow::slotRunWizard()
1570 Wizard *w = new Wizard(false, this);
1571 if (w->exec() == QDialog::Accepted && w->isOk()) {
1572 w->adjustSettings();
1577 void MainWindow::newFile(bool showProjectSettings, bool force)
1579 if (!m_timelineArea->isEnabled() && !force) return;
1580 m_fileRevert->setEnabled(false);
1581 QString profileName;
1583 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1584 if (!showProjectSettings) {
1585 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1586 profileName = KdenliveSettings::default_profile();
1587 projectFolder = KdenliveSettings::defaultprojectfolder();
1589 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1590 if (w->exec() != QDialog::Accepted) return;
1591 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1592 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1593 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1594 profileName = w->selectedProfile();
1595 projectFolder = w->selectedFolder();
1596 projectTracks = w->tracks();
1599 m_timelineArea->setEnabled(true);
1600 m_projectList->setEnabled(true);
1601 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1602 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1604 TrackView *trackView = new TrackView(doc, &ok, this);
1605 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1608 //m_timelineArea->setEnabled(false);
1609 //m_projectList->setEnabled(false);
1613 if (m_timelineArea->count() == 1) {
1614 connectDocumentInfo(doc);
1615 connectDocument(trackView, doc);
1616 } else m_timelineArea->setTabBarHidden(false);
1617 m_monitorManager->activateMonitor("clip");
1618 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1621 void MainWindow::activateDocument()
1623 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1624 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1625 KdenliveDoc *currentDoc = currentTab->document();
1626 connectDocumentInfo(currentDoc);
1627 connectDocument(currentTab, currentDoc);
1630 void MainWindow::closeCurrentDocument(bool saveChanges)
1632 QWidget *w = m_timelineArea->currentWidget();
1634 // closing current document
1635 int ix = m_timelineArea->currentIndex() + 1;
1636 if (ix == m_timelineArea->count()) ix = 0;
1637 m_timelineArea->setCurrentIndex(ix);
1638 TrackView *tabToClose = (TrackView *) w;
1639 KdenliveDoc *docToClose = tabToClose->document();
1640 if (docToClose && docToClose->isModified() && saveChanges) {
1642 if (m_activeDocument->url().fileName().isEmpty())
1643 message = i18n("Save changes to document?");
1645 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1646 switch (KMessageBox::warningYesNoCancel(this, message)) {
1647 case KMessageBox::Yes :
1648 // save document here. If saving fails, return false;
1649 if (saveFile() == false) return;
1651 case KMessageBox::Cancel :
1658 m_clipMonitor->slotSetXml(NULL);
1659 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1660 if (m_timelineArea->count() == 1) {
1661 m_timelineArea->setTabBarHidden(true);
1662 m_closeAction->setEnabled(false);
1664 if (docToClose == m_activeDocument) {
1665 delete m_activeDocument;
1666 m_activeDocument = NULL;
1667 m_effectStack->clear();
1668 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1672 if (w == m_activeTimeline) {
1673 delete m_activeTimeline;
1674 m_activeTimeline = NULL;
1680 bool MainWindow::saveFileAs(const QString &outputFileName)
1682 QString currentSceneList;
1683 m_monitorManager->stopActiveMonitor();
1684 if (KdenliveSettings::dropbframes()) {
1685 KdenliveSettings::setDropbframes(false);
1686 m_activeDocument->clipManager()->updatePreviewSettings();
1687 currentSceneList = m_projectMonitor->sceneList();
1688 KdenliveSettings::setDropbframes(true);
1689 m_activeDocument->clipManager()->updatePreviewSettings();
1690 } else currentSceneList = m_projectMonitor->sceneList();
1692 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1695 // Save timeline thumbnails
1696 m_activeTimeline->projectView()->saveThumbnails();
1697 m_activeDocument->setUrl(KUrl(outputFileName));
1698 if (m_activeDocument->m_autosave == NULL) {
1699 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1700 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1701 setCaption(m_activeDocument->description());
1702 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1703 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1704 m_activeDocument->setModified(false);
1705 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1706 m_fileRevert->setEnabled(true);
1710 bool MainWindow::saveFileAs()
1712 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1713 if (outputFile.isEmpty()) {
1716 if (QFile::exists(outputFile)) {
1717 // Show the file dialog again if the user does not want to overwrite the file
1718 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1719 return saveFileAs();
1721 return saveFileAs(outputFile);
1724 bool MainWindow::saveFile()
1726 if (!m_activeDocument) return true;
1727 if (m_activeDocument->url().isEmpty()) {
1728 return saveFileAs();
1730 bool result = saveFileAs(m_activeDocument->url().path());
1731 m_activeDocument->m_autosave->resize(0);
1736 void MainWindow::openFile()
1738 if (!m_startUrl.isEmpty()) {
1739 openFile(m_startUrl);
1740 m_startUrl = KUrl();
1743 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1744 if (url.isEmpty()) return;
1745 m_fileOpenRecent->addUrl(url);
1749 void MainWindow::openLastFile()
1751 KSharedConfigPtr config = KGlobal::config();
1752 KUrl::List urls = m_fileOpenRecent->urls();
1753 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1754 if (urls.isEmpty()) newFile(false);
1755 else openFile(urls.last());
1758 void MainWindow::openFile(const KUrl &url)
1760 // Check if the document is already opened
1761 const int ct = m_timelineArea->count();
1762 bool isOpened = false;
1764 for (i = 0; i < ct; i++) {
1765 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1766 KdenliveDoc *doc = tab->document();
1767 if (doc->url() == url) {
1773 m_timelineArea->setCurrentIndex(i);
1777 // Check for backup file
1778 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1779 if (!staleFiles.isEmpty()) {
1780 if (KMessageBox::questionYesNo(this,
1781 i18n("Auto-saved files exist. Do you want to recover them now?"),
1782 i18n("File Recovery"),
1783 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1784 recoverFiles(staleFiles);
1787 // remove the stale files
1788 foreach(KAutoSaveFile *stale, staleFiles) {
1789 stale->open(QIODevice::ReadWrite);
1794 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1795 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1796 m_messageLabel->repaint();
1797 doOpenFile(url, NULL);
1800 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1802 if (!m_timelineArea->isEnabled()) return;
1803 m_fileRevert->setEnabled(true);
1804 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1805 if (stale == NULL) {
1806 stale = new KAutoSaveFile(url, doc);
1807 doc->m_autosave = stale;
1809 doc->m_autosave = stale;
1810 doc->setUrl(stale->managedFile());
1811 doc->setModified(true);
1812 stale->setParent(doc);
1814 connectDocumentInfo(doc);
1816 TrackView *trackView = new TrackView(doc, &ok, this);
1817 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1819 m_timelineArea->setEnabled(false);
1820 m_projectList->setEnabled(false);
1821 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1822 slotGotProgressInfo(QString(), -1);
1823 newFile(false, true);
1826 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1827 trackView->setDuration(trackView->duration());
1828 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1830 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1831 slotGotProgressInfo(QString(), -1);
1832 m_projectMonitor->adjustRulerSize(trackView->duration());
1833 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1834 m_clipMonitor->refreshMonitor(true);
1837 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1839 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1840 foreach(KAutoSaveFile *stale, staleFiles) {
1841 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1842 // show an error message; we could not steal the lockfile
1843 // maybe another application got to the file before us?
1847 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1848 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1849 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1850 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1854 void MainWindow::parseProfiles(const QString &mltPath)
1856 //KdenliveSettings::setDefaulttmpfolder();
1857 if (!mltPath.isEmpty()) {
1858 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1859 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1862 if (KdenliveSettings::mltpath().isEmpty())
1863 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1865 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1866 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1867 if (!QFile::exists(meltPath))
1868 meltPath = KStandardDirs::findExe("melt");
1869 KdenliveSettings::setRendererpath(meltPath);
1872 if (KdenliveSettings::rendererpath().isEmpty()) {
1873 // Cannot find the MLT melt renderer, ask for location
1874 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1875 if (getUrl->exec() == QDialog::Rejected) {
1878 KUrl rendererPath = getUrl->selectedUrl();
1880 if (rendererPath.isEmpty()) ::exit(0);
1881 KdenliveSettings::setRendererpath(rendererPath.path());
1884 QStringList profilesFilter;
1885 profilesFilter << "*";
1886 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1887 if (profilesList.isEmpty()) {
1888 // Cannot find MLT path, try finding melt
1889 QString profilePath = KdenliveSettings::rendererpath();
1890 if (!profilePath.isEmpty()) {
1891 profilePath = profilePath.section('/', 0, -3);
1892 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1893 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1895 if (profilesList.isEmpty()) {
1896 // Cannot find the MLT profiles, ask for location
1897 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1898 getUrl->fileDialog()->setMode(KFile::Directory);
1899 if (getUrl->exec() == QDialog::Rejected) {
1902 KUrl mltPath = getUrl->selectedUrl();
1904 if (mltPath.isEmpty()) ::exit(0);
1905 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1906 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1910 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1912 // Parse again MLT profiles to build a list of available video formats
1913 if (profilesList.isEmpty()) parseProfiles();
1917 void MainWindow::slotEditProfiles()
1919 ProfilesDialog *w = new ProfilesDialog;
1920 if (w->exec() == QDialog::Accepted) {
1921 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1922 if (d) d->checkProfile();
1927 void MainWindow::slotDetectAudioDriver()
1929 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1930 leading to no audio output, see bug #934 */
1932 //decide which audio driver is really best, in some cases SDL is wrong
1933 if (KdenliveSettings::audiodrivername().isEmpty()) {
1935 KProcess readProcess;
1936 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1937 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1938 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1939 readProcess.setProgram("pactl", QStringList() << "stat");
1940 readProcess.execute(2000); // Kill it after 2 seconds
1942 QString result = QString(readProcess.readAllStandardOutput());
1943 kDebug() << "// / / / / / READING PACTL: ";
1945 if (!result.isEmpty()) {
1947 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1951 KdenliveSettings::setAutoaudiodrivername(driver);
1955 void MainWindow::slotEditProjectSettings()
1957 QPoint p = m_activeDocument->getTracksCount();
1958 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1960 if (w->exec() == QDialog::Accepted) {
1961 QString profile = w->selectedProfile();
1962 m_activeDocument->setProjectFolder(w->selectedFolder());
1963 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1964 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1965 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1966 if (m_activeDocument->profilePath() != profile) {
1967 // Profile was changed
1968 double dar = m_activeDocument->dar();
1970 // Deselect current effect / transition
1971 m_effectStack->slotClipItemSelected(NULL, 0);
1972 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1973 m_clipMonitor->slotSetXml(NULL);
1974 bool updateFps = m_activeDocument->setProfilePath(profile);
1975 KdenliveSettings::setCurrent_profile(profile);
1976 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1977 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1979 m_activeDocument->clipManager()->clearUnusedProducers();
1980 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1982 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1983 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1984 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1985 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1986 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1987 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1988 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1989 if (updateFps) m_activeTimeline->updateProjectFps();
1990 m_activeDocument->setModified(true);
1991 m_commandStack->activeStack()->clear();
1992 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1993 slotUpdateMousePosition(0);
1994 // We need to desactivate & reactivate monitors to get a refresh
1995 //m_monitorManager->switchMonitors();
2002 void MainWindow::slotRenderProject()
2004 if (!m_renderWidget) {
2005 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2006 m_renderWidget = new RenderWidget(projectfolder, this);
2007 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2008 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2009 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2010 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2011 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2012 if (m_activeDocument) {
2013 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2014 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2015 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2016 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2019 slotCheckRenderStatus();
2020 m_renderWidget->show();
2021 m_renderWidget->showNormal();
2023 // What are the following lines supposed to do?
2024 //m_activeTimeline->tracksNumber();
2025 //m_renderWidget->enableAudio(false);
2026 //m_renderWidget->export_audio;
2029 void MainWindow::slotCheckRenderStatus()
2031 // Make sure there are no missing clips
2033 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2036 void MainWindow::setRenderingProgress(const QString &url, int progress)
2039 m_renderWidget->setRenderJob(url, progress);
2042 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2045 m_renderWidget->setRenderStatus(url, status, error);
2048 void MainWindow::slotCleanProject()
2050 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2051 m_projectList->cleanup();
2054 void MainWindow::slotUpdateMousePosition(int pos)
2056 if (m_activeDocument)
2057 switch (m_timecodeFormat->currentIndex()) {
2059 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2062 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2066 void MainWindow::slotUpdateDocumentState(bool modified)
2068 if (!m_activeDocument) return;
2069 setCaption(m_activeDocument->description(), modified);
2070 m_saveAction->setEnabled(modified);
2072 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2073 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2075 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2076 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2080 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2082 if (m_activeDocument) {
2083 if (m_activeDocument == doc) return;
2084 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2086 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2089 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2091 //m_projectMonitor->stop();
2092 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2093 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2094 if (m_activeDocument) {
2095 if (m_activeDocument == doc) return;
2096 if (m_activeTimeline) {
2097 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2098 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2099 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2100 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2101 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2102 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2103 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2105 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2106 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2107 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2108 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2109 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2110 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2111 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2112 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2113 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2114 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2115 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2116 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2117 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2118 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2119 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2120 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2121 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2122 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2123 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2124 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2125 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2126 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2127 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2128 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2129 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2130 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2131 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2132 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2133 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2134 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2135 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2136 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2137 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2138 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2139 m_effectStack->clear();
2141 //m_activeDocument->setRenderer(NULL);
2142 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2143 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2144 m_clipMonitor->stop();
2146 KdenliveSettings::setCurrent_profile(doc->profilePath());
2147 KdenliveSettings::setProject_fps(doc->fps());
2148 m_monitorManager->resetProfiles(doc->timecode());
2149 m_projectList->setDocument(doc);
2150 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2151 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2152 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2153 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2154 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2156 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2157 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2159 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2162 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2163 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2164 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2165 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2166 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2167 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2168 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2169 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2170 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2171 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2172 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2173 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2174 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2175 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2177 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2178 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2179 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2180 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2181 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2183 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2184 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2185 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2188 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2189 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2190 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2191 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2193 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2194 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2195 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2196 m_zoomSlider->setValue(doc->zoom().x());
2197 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2198 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2199 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2200 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2202 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2203 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2206 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2207 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2208 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2209 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2210 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2211 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2212 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2213 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2214 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2215 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2216 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2218 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2219 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2220 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2221 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2222 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2225 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2226 m_activeTimeline = trackView;
2227 if (m_renderWidget) {
2228 slotCheckRenderStatus();
2229 m_renderWidget->setProfile(doc->mltProfile());
2230 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2231 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2232 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2234 //doc->setRenderer(m_projectMonitor->render);
2235 m_commandStack->setActiveStack(doc->commandStack());
2236 KdenliveSettings::setProject_display_ratio(doc->dar());
2237 //doc->clipManager()->checkAudioThumbs();
2239 //m_overView->setScene(trackView->projectScene());
2240 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2241 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2243 setCaption(doc->description(), doc->isModified());
2244 m_saveAction->setEnabled(doc->isModified());
2245 m_normalEditTool->setChecked(true);
2246 m_activeDocument = doc;
2247 m_activeTimeline->updateProjectFps();
2248 m_activeDocument->checkProjectClips();
2249 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2250 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2251 slotUpdateMousePosition(0);
2252 // set tool to select tool
2253 m_buttonSelectTool->setChecked(true);
2256 void MainWindow::slotZoneMoved(int start, int end)
2258 m_activeDocument->setZone(start, end);
2259 m_projectMonitor->slotZoneMoved(start, end);
2262 void MainWindow::slotGuidesUpdated()
2265 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2268 void MainWindow::slotEditKeys()
2270 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2271 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2272 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2276 void MainWindow::slotPreferences(int page, int option)
2278 //An instance of your dialog could be already created and could be
2279 // cached, in which case you want to display the cached dialog
2280 // instead of creating another one
2281 if (KConfigDialog::showDialog("settings")) {
2282 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2283 if (page != -1) d->showPage(page, option);
2287 // KConfigDialog didn't find an instance of this dialog, so lets
2289 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2290 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2291 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2292 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2293 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2295 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2297 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2299 if (page != -1) dialog->showPage(page, option);
2302 void MainWindow::slotUpdatePreviewSettings()
2304 if (m_activeDocument) {
2305 m_clipMonitor->slotSetXml(NULL);
2306 m_activeDocument->updatePreviewSettings();
2310 void MainWindow::updateConfiguration()
2312 //TODO: we should apply settings to all projects, not only the current one
2313 if (m_activeTimeline) {
2314 m_activeTimeline->refresh();
2315 m_activeTimeline->projectView()->checkAutoScroll();
2316 m_activeTimeline->projectView()->checkTrackHeight();
2317 if (m_activeDocument)
2318 m_activeDocument->clipManager()->checkAudioThumbs();
2320 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2321 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2322 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2323 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2325 // Update list of transcoding profiles
2327 #ifndef NO_JOGSHUTTLE
2328 activateShuttleDevice();
2329 #endif /* NO_JOGSHUTTLE */
2333 void MainWindow::slotSwitchSplitAudio()
2335 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2336 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2339 void MainWindow::slotSwitchVideoThumbs()
2341 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2342 if (m_activeTimeline)
2343 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2344 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2347 void MainWindow::slotSwitchAudioThumbs()
2349 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2350 if (m_activeTimeline) {
2351 m_activeTimeline->refresh();
2352 m_activeTimeline->projectView()->checkAutoScroll();
2353 if (m_activeDocument)
2354 m_activeDocument->clipManager()->checkAudioThumbs();
2356 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2359 void MainWindow::slotSwitchMarkersComments()
2361 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2362 if (m_activeTimeline)
2363 m_activeTimeline->refresh();
2364 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2367 void MainWindow::slotSwitchSnap()
2369 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2370 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2374 void MainWindow::slotDeleteItem()
2376 if (QApplication::focusWidget() &&
2377 QApplication::focusWidget()->parentWidget() &&
2378 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2379 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2380 m_projectList->slotRemoveClip();
2383 QWidget *widget = QApplication::focusWidget();
2385 if (widget == m_effectStackDock) {
2386 m_effectStack->slotItemDel();
2389 widget = widget->parentWidget();
2392 // effect stack has no focus
2393 if (m_activeTimeline)
2394 m_activeTimeline->projectView()->deleteSelectedClips();
2398 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2400 if (m_clipMonitor->isActive())
2401 m_clipMonitor->checkOverlay();
2402 m_clipMonitor->updateMarkers(clip);
2405 void MainWindow::slotAddClipMarker()
2407 DocClipBase *clip = NULL;
2409 if (m_projectMonitor->isActive()) {
2410 if (m_activeTimeline) {
2411 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2413 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2414 clip = item->baseClip();
2418 clip = m_clipMonitor->activeClip();
2419 pos = m_clipMonitor->position();
2422 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2425 QString id = clip->getId();
2426 CommentedTime marker(pos, i18n("Marker"));
2427 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2428 if (d.exec() == QDialog::Accepted)
2429 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2432 void MainWindow::slotDeleteClipMarker()
2434 DocClipBase *clip = NULL;
2436 if (m_projectMonitor->isActive()) {
2437 if (m_activeTimeline) {
2438 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2440 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2441 clip = item->baseClip();
2445 clip = m_clipMonitor->activeClip();
2446 pos = m_clipMonitor->position();
2449 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2453 QString id = clip->getId();
2454 QString comment = clip->markerComment(pos);
2455 if (comment.isEmpty()) {
2456 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2459 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2462 void MainWindow::slotDeleteAllClipMarkers()
2464 DocClipBase *clip = NULL;
2465 if (m_projectMonitor->isActive()) {
2466 if (m_activeTimeline) {
2467 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2469 clip = item->baseClip();
2473 clip = m_clipMonitor->activeClip();
2476 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2479 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2482 void MainWindow::slotEditClipMarker()
2484 DocClipBase *clip = NULL;
2486 if (m_projectMonitor->isActive()) {
2487 if (m_activeTimeline) {
2488 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2490 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2491 clip = item->baseClip();
2495 clip = m_clipMonitor->activeClip();
2496 pos = m_clipMonitor->position();
2499 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2503 QString id = clip->getId();
2504 QString oldcomment = clip->markerComment(pos);
2505 if (oldcomment.isEmpty()) {
2506 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2510 CommentedTime marker(pos, oldcomment);
2511 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2512 if (d.exec() == QDialog::Accepted) {
2513 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2514 if (d.newMarker().time() != pos) {
2515 // remove old marker
2516 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2521 void MainWindow::slotAddGuide()
2523 if (m_activeTimeline)
2524 m_activeTimeline->projectView()->slotAddGuide();
2527 void MainWindow::slotInsertSpace()
2529 if (m_activeTimeline)
2530 m_activeTimeline->projectView()->slotInsertSpace();
2533 void MainWindow::slotRemoveSpace()
2535 if (m_activeTimeline)
2536 m_activeTimeline->projectView()->slotRemoveSpace();
2539 void MainWindow::slotInsertTrack(int ix)
2541 m_projectMonitor->activateMonitor();
2542 if (m_activeTimeline)
2543 m_activeTimeline->projectView()->slotInsertTrack(ix);
2544 if (m_activeDocument)
2545 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2548 void MainWindow::slotDeleteTrack(int ix)
2550 m_projectMonitor->activateMonitor();
2551 if (m_activeTimeline)
2552 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2553 if (m_activeDocument)
2554 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2557 void MainWindow::slotConfigTrack(int ix)
2559 m_projectMonitor->activateMonitor();
2560 if (m_activeTimeline)
2561 m_activeTimeline->projectView()->slotConfigTracks(ix);
2562 if (m_activeDocument)
2563 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2566 void MainWindow::slotEditGuide()
2568 if (m_activeTimeline)
2569 m_activeTimeline->projectView()->slotEditGuide();
2572 void MainWindow::slotDeleteGuide()
2574 if (m_activeTimeline)
2575 m_activeTimeline->projectView()->slotDeleteGuide();
2578 void MainWindow::slotDeleteAllGuides()
2580 if (m_activeTimeline)
2581 m_activeTimeline->projectView()->slotDeleteAllGuides();
2584 void MainWindow::slotCutTimelineClip()
2586 if (m_activeTimeline)
2587 m_activeTimeline->projectView()->cutSelectedClips();
2590 void MainWindow::slotInsertClipOverwrite()
2592 if (m_activeTimeline) {
2593 QStringList data = m_clipMonitor->getZoneInfo();
2594 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2598 void MainWindow::slotSelectTimelineClip()
2600 if (m_activeTimeline)
2601 m_activeTimeline->projectView()->selectClip(true);
2604 void MainWindow::slotSelectTimelineTransition()
2606 if (m_activeTimeline)
2607 m_activeTimeline->projectView()->selectTransition(true);
2610 void MainWindow::slotDeselectTimelineClip()
2612 if (m_activeTimeline)
2613 m_activeTimeline->projectView()->selectClip(false, true);
2616 void MainWindow::slotDeselectTimelineTransition()
2618 if (m_activeTimeline)
2619 m_activeTimeline->projectView()->selectTransition(false, true);
2622 void MainWindow::slotSelectAddTimelineClip()
2624 if (m_activeTimeline)
2625 m_activeTimeline->projectView()->selectClip(true, true);
2628 void MainWindow::slotSelectAddTimelineTransition()
2630 if (m_activeTimeline)
2631 m_activeTimeline->projectView()->selectTransition(true, true);
2634 void MainWindow::slotGroupClips()
2636 if (m_activeTimeline)
2637 m_activeTimeline->projectView()->groupClips();
2640 void MainWindow::slotUnGroupClips()
2642 if (m_activeTimeline)
2643 m_activeTimeline->projectView()->groupClips(false);
2646 void MainWindow::slotEditItemDuration()
2648 if (m_activeTimeline)
2649 m_activeTimeline->projectView()->editItemDuration();
2652 void MainWindow::slotAddProjectClip(KUrl url)
2654 if (m_activeDocument)
2655 m_activeDocument->slotAddClipFile(url, QString());
2658 void MainWindow::slotAddTransition(QAction *result)
2660 if (!result) return;
2661 QStringList info = result->data().toStringList();
2662 if (info.isEmpty()) return;
2663 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2664 if (m_activeTimeline && !transition.isNull()) {
2665 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2669 void MainWindow::slotAddVideoEffect(QAction *result)
2671 if (!result) return;
2672 QStringList info = result->data().toStringList();
2673 if (info.isEmpty()) return;
2674 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2675 slotAddEffect(effect);
2678 void MainWindow::slotAddAudioEffect(QAction *result)
2680 if (!result) return;
2681 QStringList info = result->data().toStringList();
2682 if (info.isEmpty()) return;
2683 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2684 slotAddEffect(effect);
2687 void MainWindow::slotAddCustomEffect(QAction *result)
2689 if (!result) return;
2690 QStringList info = result->data().toStringList();
2691 if (info.isEmpty()) return;
2692 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2693 slotAddEffect(effect);
2696 void MainWindow::slotZoomIn()
2698 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2699 slotShowZoomSliderToolTip();
2702 void MainWindow::slotZoomOut()
2704 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2705 slotShowZoomSliderToolTip();
2708 void MainWindow::slotFitZoom()
2710 if (m_activeTimeline)
2711 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2714 void MainWindow::slotSetZoom(int value)
2716 if (m_activeTimeline)
2717 m_activeTimeline->slotChangeZoom(value);
2719 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2720 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2721 slotUpdateZoomSliderToolTip(value);
2723 m_zoomSlider->blockSignals(true);
2724 m_zoomSlider->setValue(value);
2725 m_zoomSlider->blockSignals(false);
2728 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2730 if (zoomlevel != -1)
2731 slotUpdateZoomSliderToolTip(zoomlevel);
2733 QPoint global = m_zoomSlider->rect().topLeft();
2734 global.ry() += m_zoomSlider->height() / 2;
2735 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2736 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2739 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2741 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2744 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2746 m_statusProgressBar->setValue(progress);
2747 if (progress >= 0) {
2748 if (!message.isEmpty())
2749 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2750 m_statusProgressBar->setVisible(true);
2751 } else if (progress == -2) {
2752 if (!message.isEmpty())
2753 m_messageLabel->setMessage(message, ErrorMessage);
2754 m_statusProgressBar->setVisible(false);
2756 m_messageLabel->setMessage(QString(), DefaultMessage);
2757 m_statusProgressBar->setVisible(false);
2761 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2763 if (clip->clipType() == TEXT) {
2764 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2765 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2766 // template text clip
2768 // Get the list of existing templates
2770 filter << "*.kdenlivetitle";
2771 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2773 QDialog *dia = new QDialog(this);
2774 Ui::TemplateClip_UI dia_ui;
2775 dia_ui.setupUi(dia);
2777 const QString templatePath = clip->getProperty("resource");
2778 for (int i = 0; i < templateFiles.size(); ++i) {
2779 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2780 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2782 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2783 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2784 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2785 //warning: setting base directory doesn't work??
2786 KUrl startDir(titlepath);
2787 dia_ui.template_list->fileDialog()->setUrl(startDir);
2788 dia_ui.description->setText(clip->getProperty("description"));
2789 if (dia->exec() == QDialog::Accepted) {
2790 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2791 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2793 QMap <QString, QString> newprops;
2795 if (KUrl(textTemplate).path() != templatePath) {
2796 // The template was changed
2797 newprops.insert("resource", textTemplate);
2800 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2801 newprops.insert("description", dia_ui.description->toPlainText());
2804 QString newtemplate = newprops.value("xmltemplate");
2805 if (newtemplate.isEmpty()) newtemplate = templatePath;
2807 // template modified we need to update xmldata
2808 QString description = newprops.value("description");
2809 if (description.isEmpty()) description = clip->getProperty("description");
2810 else newprops.insert("templatetext", description);
2811 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2812 if (!newprops.isEmpty()) {
2813 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2814 m_activeDocument->commandStack()->push(command);
2820 QString path = clip->getProperty("resource");
2821 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2823 doc.setContent(clip->getProperty("xmldata"));
2824 dia_ui->setXml(doc);
2825 if (dia_ui->exec() == QDialog::Accepted) {
2826 QMap <QString, QString> newprops;
2827 newprops.insert("xmldata", dia_ui->xml().toString());
2828 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2829 // duration changed, we need to update duration
2830 newprops.insert("out", QString::number(dia_ui->outPoint()));
2832 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2833 m_activeDocument->commandStack()->push(command);
2834 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2835 m_activeDocument->setModified(true);
2839 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2842 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2843 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2844 if (dia.exec() == QDialog::Accepted) {
2845 QMap <QString, QString> newprops = dia.properties();
2846 if (newprops.isEmpty()) return;
2847 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2848 m_activeDocument->commandStack()->push(command);
2850 if (dia.needsTimelineRefresh()) {
2851 // update clip occurences in timeline
2852 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2858 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2860 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2861 if (dia.exec() == QDialog::Accepted) {
2862 QUndoCommand *command = new QUndoCommand();
2863 command->setText(i18n("Edit clips"));
2864 for (int i = 0; i < cliplist.count(); i++) {
2865 DocClipBase *clip = cliplist.at(i);
2866 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2868 m_activeDocument->commandStack()->push(command);
2869 for (int i = 0; i < cliplist.count(); i++)
2870 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2874 void MainWindow::customEvent(QEvent* e)
2876 if (e->type() == QEvent::User)
2877 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2879 void MainWindow::slotActivateEffectStackView()
2881 m_effectStack->raiseWindow(m_effectStackDock);
2884 void MainWindow::slotActivateTransitionView(Transition *t)
2887 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2890 void MainWindow::slotSnapRewind()
2892 if (m_projectMonitor->isActive()) {
2893 if (m_activeTimeline)
2894 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2896 m_clipMonitor->slotSeekToPreviousSnap();
2900 void MainWindow::slotSnapForward()
2902 if (m_projectMonitor->isActive()) {
2903 if (m_activeTimeline)
2904 m_activeTimeline->projectView()->slotSeekToNextSnap();
2906 m_clipMonitor->slotSeekToNextSnap();
2910 void MainWindow::slotClipStart()
2912 if (m_projectMonitor->isActive()) {
2913 if (m_activeTimeline)
2914 m_activeTimeline->projectView()->clipStart();
2918 void MainWindow::slotClipEnd()
2920 if (m_projectMonitor->isActive()) {
2921 if (m_activeTimeline)
2922 m_activeTimeline->projectView()->clipEnd();
2926 void MainWindow::slotZoneStart()
2928 if (m_projectMonitor->isActive())
2929 m_projectMonitor->slotZoneStart();
2931 m_clipMonitor->slotZoneStart();
2934 void MainWindow::slotZoneEnd()
2936 if (m_projectMonitor->isActive())
2937 m_projectMonitor->slotZoneEnd();
2939 m_clipMonitor->slotZoneEnd();
2942 void MainWindow::slotChangeTool(QAction * action)
2944 if (action == m_buttonSelectTool)
2945 slotSetTool(SELECTTOOL);
2946 else if (action == m_buttonRazorTool)
2947 slotSetTool(RAZORTOOL);
2948 else if (action == m_buttonSpacerTool)
2949 slotSetTool(SPACERTOOL);
2952 void MainWindow::slotChangeEdit(QAction * action)
2954 if (!m_activeTimeline)
2957 if (action == m_overwriteEditTool)
2958 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2959 else if (action == m_insertEditTool)
2960 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2962 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2965 void MainWindow::slotSetTool(PROJECTTOOL tool)
2967 if (m_activeDocument && m_activeTimeline) {
2968 //m_activeDocument->setTool(tool);
2972 message = i18n("Ctrl + click to use spacer on current track only");
2975 message = i18n("Click on a clip to cut it");
2978 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2981 m_messageLabel->setMessage(message, InformationMessage);
2982 m_activeTimeline->projectView()->setTool(tool);
2986 void MainWindow::slotCopy()
2988 if (m_activeDocument && m_activeTimeline)
2989 m_activeTimeline->projectView()->copyClip();
2992 void MainWindow::slotPaste()
2994 if (m_activeDocument && m_activeTimeline)
2995 m_activeTimeline->projectView()->pasteClip();
2998 void MainWindow::slotPasteEffects()
3000 if (m_activeDocument && m_activeTimeline)
3001 m_activeTimeline->projectView()->pasteClipEffects();
3004 void MainWindow::slotFind()
3006 if (!m_activeDocument || !m_activeTimeline) return;
3007 m_projectSearch->setEnabled(false);
3008 m_findActivated = true;
3009 m_findString.clear();
3010 m_activeTimeline->projectView()->initSearchStrings();
3011 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3012 m_findTimer.start(5000);
3013 qApp->installEventFilter(this);
3016 void MainWindow::slotFindNext()
3018 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3019 statusBar()->showMessage(i18n("Found: %1", m_findString));
3021 statusBar()->showMessage(i18n("Reached end of project"));
3022 m_findTimer.start(4000);
3025 void MainWindow::findAhead()
3027 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3028 m_projectSearchNext->setEnabled(true);
3029 statusBar()->showMessage(i18n("Found: %1", m_findString));
3031 m_projectSearchNext->setEnabled(false);
3032 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3036 void MainWindow::findTimeout()
3038 m_projectSearchNext->setEnabled(false);
3039 m_findActivated = false;
3040 m_findString.clear();
3041 statusBar()->showMessage(i18n("Find stopped"), 3000);
3042 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3043 m_projectSearch->setEnabled(true);
3044 removeEventFilter(this);
3047 void MainWindow::slotClipInTimeline(const QString &clipId)
3049 if (m_activeTimeline && m_activeDocument) {
3050 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3052 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3053 inTimelineMenu->clear();
3055 QList <QAction *> actionList;
3057 for (int i = 0; i < matching.count(); ++i) {
3058 QString track = QString::number(matching.at(i).track);
3059 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3061 QAction *a = new QAction(track + ": " + start, this);
3062 a->setData(QStringList() << track << start);
3063 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3064 while (j < actionList.count()) {
3065 if (actionList.at(j)->text() > a->text()) break;
3068 actionList.insert(j, a);
3070 inTimelineMenu->addActions(actionList);
3072 if (matching.empty())
3073 inTimelineMenu->setEnabled(false);
3075 inTimelineMenu->setEnabled(true);
3079 void MainWindow::slotClipInProjectTree()
3081 if (m_activeTimeline) {
3082 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3083 if (clipIds.isEmpty())
3085 m_projectListDock->raise();
3086 for (int i = 0; i < clipIds.count(); i++)
3087 m_projectList->selectItemById(clipIds.at(i));
3088 if (m_projectMonitor->isActive())
3089 slotSwitchMonitors();
3093 /*void MainWindow::slotClipToProjectTree()
3095 if (m_activeTimeline) {
3096 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3097 if (clips.isEmpty()) return;
3098 for (int i = 0; i < clips.count(); i++) {
3099 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3101 //m_projectList->selectItemById(clipIds.at(i));
3105 void MainWindow::slotSelectClipInTimeline()
3107 if (m_activeTimeline) {
3108 QAction *action = qobject_cast<QAction *>(sender());
3109 QStringList data = action->data().toStringList();
3110 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3114 void MainWindow::keyPressEvent(QKeyEvent *ke)
3116 if (m_findActivated) {
3117 if (ke->key() == Qt::Key_Backspace) {
3118 m_findString = m_findString.left(m_findString.length() - 1);
3120 if (!m_findString.isEmpty())
3125 m_findTimer.start(4000);
3128 } else if (ke->key() == Qt::Key_Escape) {
3132 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3133 m_findString += ke->text();
3137 m_findTimer.start(4000);
3142 KXmlGuiWindow::keyPressEvent(ke);
3147 /** Gets called when the window gets hidden */
3148 void MainWindow::hideEvent(QHideEvent */*event*/)
3150 if (isMinimized() && m_monitorManager)
3151 m_monitorManager->stopActiveMonitor();
3154 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3156 if (m_findActivated) {
3157 if (event->type() == QEvent::ShortcutOverride) {
3158 QKeyEvent* ke = (QKeyEvent*) event;
3159 if (ke->text().trimmed().isEmpty()) return false;
3166 // pass the event on to the parent class
3167 return QMainWindow::eventFilter(obj, event);
3172 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3174 KDialog *dialog = new KDialog(this);
3175 dialog->setCaption("Save clip zone");
3176 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3178 QWidget *widget = new QWidget(dialog);
3179 dialog->setMainWidget(widget);
3181 QVBoxLayout *vbox = new QVBoxLayout(widget);
3182 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3183 QString path = m_activeDocument->projectFolder().path();
3185 path.append("untitled.mlt");
3186 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3187 url->setFilter("video/mlt-playlist");
3188 QLabel *label2 = new QLabel(i18n("Description:"), this);
3189 KLineEdit *edit = new KLineEdit(this);
3190 vbox->addWidget(label1);
3191 vbox->addWidget(url);
3192 vbox->addWidget(label2);
3193 vbox->addWidget(edit);
3194 if (dialog->exec() == QDialog::Accepted)
3195 render->saveZone(url->url(), edit->text(), zone);
3199 void MainWindow::slotSetInPoint()
3201 if (m_clipMonitor->isActive())
3202 m_clipMonitor->slotSetZoneStart();
3204 m_projectMonitor->slotSetZoneStart();
3205 //else m_activeTimeline->projectView()->setInPoint();
3208 void MainWindow::slotSetOutPoint()
3210 if (m_clipMonitor->isActive())
3211 m_clipMonitor->slotSetZoneEnd();
3213 m_projectMonitor->slotSetZoneEnd();
3214 // else m_activeTimeline->projectView()->setOutPoint();
3217 void MainWindow::slotResizeItemStart()
3219 if (m_activeTimeline)
3220 m_activeTimeline->projectView()->setInPoint();
3223 void MainWindow::slotResizeItemEnd()
3225 if (m_activeTimeline)
3226 m_activeTimeline->projectView()->setOutPoint();
3229 int MainWindow::getNewStuff(const QString &configFile)
3231 KNS3::Entry::List entries;
3232 #if KDE_IS_VERSION(4,3,80)
3233 KNS3::DownloadDialog dialog(configFile);
3235 entries = dialog.changedEntries();
3236 foreach(const KNS3::Entry &entry, entries) {
3237 if (entry.status() == KNS3::Entry::Installed)
3238 kDebug() << "// Installed files: " << entry.installedFiles();
3241 KNS::Engine engine(0);
3242 if (engine.init(configFile))
3243 entries = engine.downloadDialogModal(this);
3244 foreach(KNS::Entry *entry, entries) {
3245 if (entry->status() == KNS::Entry::Installed)
3246 kDebug() << "// Installed files: " << entry->installedFiles();
3248 #endif /* KDE_IS_VERSION(4,3,80) */
3249 return entries.size();
3252 void MainWindow::slotGetNewTitleStuff()
3254 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3255 TitleWidget::refreshTitleTemplates();
3258 void MainWindow::slotGetNewLumaStuff()
3260 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3261 initEffects::refreshLumas();
3262 m_activeTimeline->projectView()->reloadTransitionLumas();
3266 void MainWindow::slotGetNewRenderStuff()
3268 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3270 m_renderWidget->reloadProfiles();
3273 void MainWindow::slotGetNewMltProfileStuff()
3275 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3276 // update the list of profiles in settings dialog
3277 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3283 void MainWindow::slotAutoTransition()
3285 if (m_activeTimeline)
3286 m_activeTimeline->projectView()->autoTransition();
3289 void MainWindow::slotSplitAudio()
3291 if (m_activeTimeline)
3292 m_activeTimeline->projectView()->splitAudio();
3295 void MainWindow::slotUpdateClipType(QAction *action)
3297 if (m_activeTimeline) {
3298 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3299 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3300 else m_activeTimeline->projectView()->setAudioAndVideo();
3304 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3306 // We must stop the monitors since we create a new on in the dvd wizard
3307 m_clipMonitor->stop();
3308 m_projectMonitor->stop();
3309 DvdWizard w(url, profile, this);
3311 m_projectMonitor->start();
3314 void MainWindow::slotShowTimeline(bool show)
3316 if (show == false) {
3317 m_timelineState = saveState();
3318 centralWidget()->setHidden(true);
3320 centralWidget()->setHidden(false);
3321 restoreState(m_timelineState);
3325 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3327 //TODO: is there a way to maximize current widget?
3330 m_timelineState = saveState();
3331 QWidget *par = focusWidget()->parentWidget();
3332 while (par->parentWidget() && par->parentWidget() != this)
3333 par = par->parentWidget();
3334 kDebug() << "CURRENT WIDGET: " << par->objectName();
3337 //centralWidget()->setHidden(false);
3338 //restoreState(m_timelineState);
3342 void MainWindow::loadTranscoders()
3344 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3347 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3348 KConfigGroup transConfig(config, "Transcoding");
3350 QMap< QString, QString > profiles = transConfig.entryMap();
3351 QMapIterator<QString, QString> i(profiles);
3352 while (i.hasNext()) {
3354 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3355 QAction *a = transMenu->addAction(i.key());
3357 if (data.count() > 1)
3358 a->setToolTip(data.at(1));
3359 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3363 void MainWindow::slotTranscode(KUrl::List urls)
3368 if (urls.isEmpty()) {
3369 QAction *action = qobject_cast<QAction *>(sender());
3370 QStringList data = action->data().toStringList();
3371 params = data.at(0);
3372 if (data.count() > 1) desc = data.at(1);
3373 if (data.count() > 2) condition = data.at(2);
3374 urls << m_projectList->getConditionalUrls(condition);
3375 urls.removeAll(KUrl());
3377 if (urls.isEmpty()) {
3378 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3381 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3382 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3384 //QProcess::startDetached("ffmpeg", parameters);
3387 void MainWindow::slotTranscodeClip()
3389 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3390 if (urls.isEmpty()) return;
3391 slotTranscode(urls);
3394 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3396 if (m_activeDocument == NULL) return;
3397 QMapIterator<QString, QString> i(props);
3398 while (i.hasNext()) {
3400 m_activeDocument->setDocumentProperty(i.key(), i.value());
3402 m_activeDocument->setModified(true);
3406 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3408 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3410 QString playlistPath;
3413 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3414 QString path = m_renderWidget->getFreeScriptName();
3415 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3416 if (!ok || scriptPath.isEmpty()) return;
3417 scriptPath.prepend(scriptsFolder);
3418 QFile f(scriptPath);
3420 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3423 playlistPath = scriptPath + ".mlt";
3424 m_projectMonitor->saveSceneList(playlistPath);
3426 KTemporaryFile temp;
3427 temp.setAutoRemove(false);
3428 temp.setSuffix(".mlt");
3430 playlistPath = temp.fileName();
3431 m_projectMonitor->saveSceneList(playlistPath);
3434 if (!chapterFile.isEmpty()) {
3437 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3439 in = m_activeTimeline->inPoint();
3440 out = m_activeTimeline->outPoint();
3443 QDomElement chapters = doc.createElement("chapters");
3444 chapters.setAttribute("fps", m_activeDocument->fps());
3445 doc.appendChild(chapters);
3447 QDomElement guidesxml = m_activeDocument->guidesXml();
3448 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3449 for (int i = 0; i < nodes.count(); i++) {
3450 QDomElement e = nodes.item(i).toElement();
3452 QString comment = e.attribute("comment");
3453 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3454 if (time >= in && time < out) {
3455 if (zoneOnly) time = time - in;
3456 QDomElement chapter = doc.createElement("chapter");
3457 chapters.appendChild(chapter);
3458 chapter.setAttribute("title", comment);
3459 chapter.setAttribute("time", time);
3463 if (chapters.childNodes().count() > 0) {
3464 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3465 // Always insert a guide in pos 0
3466 QDomElement chapter = doc.createElement("chapter");
3467 chapters.insertBefore(chapter, QDomNode());
3468 chapter.setAttribute("title", i18n("Start"));
3469 chapter.setAttribute("time", "0");
3471 // save chapters file
3472 QFile file(chapterFile);
3473 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3474 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3476 file.write(doc.toString().toUtf8());
3477 if (file.error() != QFile::NoError) {
3478 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3485 if (m_renderWidget->automaticAudioExport()) {
3486 exportAudio = m_activeTimeline->checkProjectAudio();
3487 } else exportAudio = m_renderWidget->selectedAudioExport();
3488 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3491 void MainWindow::slotUpdateTimecodeFormat(int ix)
3493 KdenliveSettings::setFrametimecode(ix == 1);
3494 m_clipMonitor->updateTimecodeFormat();
3495 m_projectMonitor->updateTimecodeFormat();
3496 m_transitionConfig->updateTimecodeFormat();
3497 m_effectStack->updateTimecodeFormat();
3498 //m_activeTimeline->projectView()->clearSelection();
3499 m_activeTimeline->updateRuler();
3502 void MainWindow::slotRemoveFocus()
3504 statusBar()->setFocus();
3505 statusBar()->clearFocus();
3508 void MainWindow::slotRevert()
3510 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;
3511 KUrl url = m_activeDocument->url();
3512 closeCurrentDocument(false);
3513 doOpenFile(url, NULL);
3517 void MainWindow::slotShutdown()
3519 if (m_activeDocument) m_activeDocument->setModified(false);
3521 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3522 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3523 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3524 smserver.call("logout", 1, 2, 2);
3525 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3526 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3527 smserver.call("Shutdown");
3531 void MainWindow::slotUpdateTrackInfo()
3533 if (m_activeDocument)
3534 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3537 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3539 // Load the theme file
3541 if (action == NULL) theme = themename;
3542 else theme = action->data().toString();
3543 KdenliveSettings::setColortheme(theme);
3544 // Make palette for all widgets.
3546 if (theme.isEmpty())
3547 plt = QApplication::desktop()->palette();
3549 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3550 plt = KGlobalSettings::createApplicationPalette(config);
3553 kapp->setPalette(plt);
3554 const QObjectList children = statusBar()->children();
3556 foreach(QObject *child, children) {
3557 if (child->isWidgetType())
3558 ((QWidget*)child)->setPalette(plt);
3559 const QObjectList subchildren = child->children();
3560 foreach(QObject *subchild, subchildren) {
3561 if (subchild->isWidgetType())
3562 ((QWidget*)subchild)->setPalette(plt);
3565 if (m_activeTimeline)
3566 m_activeTimeline->projectView()->updatePalette();
3570 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3572 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3573 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3574 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3575 const QSize bitsSize(24, 2);
3576 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3577 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3579 QPixmap pixmap(23, 16);
3580 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3582 KConfigGroup group(config, "WM");
3583 QPainter p(&pixmap);
3584 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3585 p.fillRect(1, 1, 7, 7, windowScheme.background());
3586 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3588 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3589 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3590 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3592 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3593 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3595 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3596 p.fillRect(1, 8, 7, 7, viewScheme.background());
3597 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3599 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3600 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3601 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3603 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3604 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3610 void MainWindow::slotSwitchMonitors()
3612 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3613 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3614 else m_projectList->focusTree();
3617 void MainWindow::slotInsertZoneToTree()
3619 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3620 QStringList info = m_clipMonitor->getZoneInfo();
3621 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3624 void MainWindow::slotInsertZoneToTimeline()
3626 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3627 QStringList info = m_clipMonitor->getZoneInfo();
3628 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3632 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3634 if (m_activeDocument && m_activeTimeline) {
3635 if (!ids.isEmpty()) {
3636 for (int i = 0; i < ids.size(); ++i) {
3637 m_activeTimeline->slotDeleteClip(ids.at(i));
3639 m_activeDocument->clipManager()->slotDeleteClips(ids);
3641 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3642 m_activeDocument->setModified(true);
3646 void MainWindow::slotShowTitleBars(bool show)
3649 m_effectStackDock->setTitleBarWidget(0);
3650 m_clipMonitorDock->setTitleBarWidget(0);
3651 m_projectMonitorDock->setTitleBarWidget(0);
3653 m_recMonitorDock->setTitleBarWidget(0);
3655 m_effectListDock->setTitleBarWidget(0);
3656 m_transitionConfigDock->setTitleBarWidget(0);
3657 m_projectListDock->setTitleBarWidget(0);
3658 m_undoViewDock->setTitleBarWidget(0);
3659 m_vectorscopeDock->setTitleBarWidget(0);
3660 m_waveformDock->setTitleBarWidget(0);
3661 m_RGBParadeDock->setTitleBarWidget(0);
3662 m_histogramDock->setTitleBarWidget(0);
3664 if (!m_effectStackDock->isFloating()) {
3665 m_effectStackDock->setTitleBarWidget(new QWidget);
3667 if (!m_clipMonitorDock->isFloating()) {
3668 m_clipMonitorDock->setTitleBarWidget(new QWidget);
3670 if (!m_projectMonitorDock->isFloating()) {
3671 m_projectMonitorDock->setTitleBarWidget(new QWidget);
3674 if (!m_recMonitorDock->isFloating()) {
3675 m_recMonitorDock->setTitleBarWidget(new QWidget);
3678 if (!m_effectListDock->isFloating()) {
3679 m_effectListDock->setTitleBarWidget(new QWidget);
3681 if (!m_transitionConfigDock->isFloating()) {
3682 m_transitionConfigDock->setTitleBarWidget(new QWidget);
3684 if (!m_projectListDock->isFloating()) {
3685 m_projectListDock->setTitleBarWidget(new QWidget);
3687 if (!m_undoViewDock->isFloating()) {
3688 m_undoViewDock->setTitleBarWidget(new QWidget);
3690 if (!m_vectorscopeDock->isFloating()) {
3691 m_vectorscopeDock->setTitleBarWidget(new QWidget);
3693 if (!m_waveformDock->isFloating()) {
3694 m_waveformDock->setTitleBarWidget(new QWidget);
3696 if (!m_RGBParadeDock->isFloating()) {
3697 m_RGBParadeDock->setTitleBarWidget(new QWidget(this));
3699 if (!m_histogramDock->isFloating()) {
3700 m_histogramDock->setTitleBarWidget(new QWidget(this));
3703 KdenliveSettings::setShowtitlebars(show);
3706 void MainWindow::slotSwitchTitles()
3708 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3711 QString MainWindow::getMimeType()
3713 QString mimetype = "application/x-kdenlive";
3714 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3715 if (!mime) mimetype = "*.kdenlive";
3719 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3722 m_projectMonitor->render->sendFrameForAnalysis = true;
3725 for (int i = 0; i < m_scopesList.count(); i++) {
3726 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3733 m_projectMonitor->render->sendFrameForAnalysis = false;
3737 void MainWindow::slotUpdateScopeFrameRequest()
3739 // We need a delay to make sure widgets are hidden after a close event for example
3740 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3743 void MainWindow::slotDoUpdateScopeFrameRequest()
3746 bool request = false;
3747 for (int i = 0; i < m_scopesList.count(); i++) {
3748 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3749 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
3755 if (!m_projectMonitor->effectSceneDisplayed())
3756 m_projectMonitor->render->sendFrameForAnalysis = false;
3757 m_clipMonitor->render->sendFrameForAnalysis = false;
3759 m_projectMonitor->render->sendFrameForAnalysis = true;
3760 m_clipMonitor->render->sendFrameForAnalysis = true;
3764 void MainWindow::slotUpdateColorScopes()
3766 bool request = false;
3767 for (int i = 0; i < m_scopesList.count(); i++) {
3768 // Check if we need the renderer to send a new frame for update
3769 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
3770 static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
3773 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
3774 else m_projectMonitor->render->sendFrameUpdate();
3778 #include "mainwindow.moc"