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)));
226 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor, this);
227 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
228 m_waveformDock->setObjectName(m_waveform->widgetName());
229 m_waveformDock->setWidget(m_waveform);
230 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
231 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
233 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor, this);
234 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
235 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
236 m_RGBParadeDock->setWidget(m_RGBParade);
237 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
238 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
240 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor, this);
241 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
242 m_histogramDock->setObjectName(m_histogram->widgetName());
243 m_histogramDock->setWidget(m_histogram);
244 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
245 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
248 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
249 m_undoViewDock->setObjectName("undo_history");
250 m_undoView = new QUndoView(this);
251 m_undoView->setCleanIcon(KIcon("edit-clear"));
252 m_undoView->setEmptyLabel(i18n("Clean"));
253 m_undoViewDock->setWidget(m_undoView);
254 m_undoView->setGroup(m_commandStack);
255 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
257 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
258 //overviewDock->setObjectName("project_overview");
259 //m_overView = new CustomTrackView(NULL, NULL, this);
260 //overviewDock->setWidget(m_overView);
261 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
266 /// Tabify Widgets ///
267 tabifyDockWidget(m_projectListDock, m_effectStackDock);
268 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
271 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
273 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
276 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
277 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
278 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
279 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
280 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
283 setCentralWidget(m_timelineArea);
286 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
287 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
289 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
290 m_fileRevert->setEnabled(false);
296 // Find QDockWidget tab bars and show / hide widget title bars on right click
297 QList <QTabBar *> tabs = findChildren<QTabBar *>();
298 for (int i = 0; i < tabs.count(); i++) {
299 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
300 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
303 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
304 guiFactory()->addClient(sp);*/
308 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
310 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
311 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
313 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
314 clipInTimeline->setIcon(KIcon("go-jump"));
315 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
316 static_cast<QMenu*>(factory()->container("transcoders", this)),
320 // build themes menus
321 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
322 QActionGroup *themegroup = new QActionGroup(this);
323 themegroup->setExclusive(true);
324 action = new KAction(i18n("Default"), this);
325 action->setCheckable(true);
326 themegroup->addAction(action);
327 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
329 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
331 for (int i = 0; i < schemeFiles.size(); ++i) {
333 const QString filename = schemeFiles.at(i);
334 const QFileInfo info(filename);
337 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
338 QIcon icon = createSchemePreviewIcon(config);
339 KConfigGroup group(config, "General");
340 const QString name = group.readEntry("Name", info.baseName());
341 action = new KAction(name, this);
342 action->setData(filename);
343 action->setIcon(icon);
344 action->setCheckable(true);
345 themegroup->addAction(action);
346 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
349 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
350 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
351 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
354 action = new QAction(fi.fileName(), this);
355 action->setData(*it);
356 action->setCheckable(true);
357 themegroup->addAction(action);
358 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
360 themesMenu->addActions(themegroup->actions());
361 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
363 // Setup and fill effects and transitions menus.
364 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
365 for (int i = 0; i < videoEffects.count(); ++i)
366 m_videoEffectsMenu->addAction(m_videoEffects[i]);
367 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
368 for (int i = 0; i < audioEffects.count(); ++i)
369 m_audioEffectsMenu->addAction(m_audioEffects[i]);
370 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
371 if (customEffects.isEmpty())
372 m_customEffectsMenu->setEnabled(false);
374 m_customEffectsMenu->setEnabled(true);
375 for (int i = 0; i < customEffects.count(); ++i)
376 m_customEffectsMenu->addAction(m_customEffects[i]);
377 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
378 for (int i = 0; i < transitions.count(); ++i)
379 m_transitionsMenu->addAction(m_transitions[i]);
381 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
382 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
383 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
384 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
386 QMenu *newEffect = new QMenu(this);
387 newEffect->addMenu(m_videoEffectsMenu);
388 newEffect->addMenu(m_audioEffectsMenu);
389 newEffect->addMenu(m_customEffectsMenu);
390 m_effectStack->setMenu(newEffect);
392 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
393 const QList<QAction *> viewActions = createPopupMenu()->actions();
394 viewMenu->insertActions(NULL, viewActions);
396 m_timelineContextMenu = new QMenu(this);
397 m_timelineContextClipMenu = new QMenu(this);
398 m_timelineContextTransitionMenu = new QMenu(this);
400 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
401 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
402 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
404 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
405 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
406 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
407 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
408 m_timelineContextClipMenu->addSeparator();
409 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
410 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
411 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
412 m_timelineContextClipMenu->addSeparator();
413 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
414 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
415 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
416 m_timelineContextClipMenu->addSeparator();
418 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
419 m_timelineContextClipMenu->addMenu(markersMenu);
420 m_timelineContextClipMenu->addSeparator();
421 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
422 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
423 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
424 //TODO: re-enable custom effects menu when it is implemented
425 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
427 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
428 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
429 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
431 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
433 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
434 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
435 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
436 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
437 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_vectorscope, SLOT(slotActiveMonitorChanged(bool)));
438 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_waveform, SLOT(slotActiveMonitorChanged(bool)));
439 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_RGBParade, SLOT(slotActiveMonitorChanged(bool)));
440 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), m_histogram, SLOT(slotActiveMonitorChanged(bool)));
441 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
442 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
444 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
445 slotConnectMonitors();
447 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
448 KdenliveSettings::setDropbframes(false);
450 // Open or create a file. Command line argument passed in Url has
451 // precedence, then "openlastproject", then just a plain empty file.
452 // If opening Url fails, openlastproject will _not_ be used.
453 if (!Url.isEmpty()) {
454 // delay loading so that the window shows up
456 QTimer::singleShot(500, this, SLOT(openFile()));
457 } else if (KdenliveSettings::openlastproject()) {
458 QTimer::singleShot(500, this, SLOT(openLastFile()));
459 } else { //if (m_timelineArea->count() == 0) {
463 #ifndef NO_JOGSHUTTLE
464 activateShuttleDevice();
465 #endif /* NO_JOGSHUTTLE */
466 m_projectListDock->raise();
469 void MainWindow::queryQuit()
472 if (m_projectMonitor) m_projectMonitor->stop();
473 if (m_clipMonitor) m_clipMonitor->stop();
474 delete m_activeTimeline;
476 // This sometimes causes crash on exit on OS X for some reason.
477 delete m_projectMonitor;
478 delete m_clipMonitor;
480 delete m_effectStack;
481 delete m_activeDocument;
482 delete m_shortcutRemoveFocus;
483 Mlt::Factory::close();
489 bool MainWindow::queryClose()
491 if (m_renderWidget) {
492 int waitingJobs = m_renderWidget->waitingJobsCount();
493 if (waitingJobs > 0) {
494 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")))) {
495 case KMessageBox::Yes :
496 // create script with waiting jobs and start it
497 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
499 case KMessageBox::No :
500 // Don't do anything, jobs will be deleted
508 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
509 // warn the user to save if document is modified and we have clips in our project list
510 if (m_activeDocument && m_activeDocument->isModified() &&
511 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
512 !m_projectList->documentClipList().isEmpty())) {
514 if (m_activeDocument->url().fileName().isEmpty())
515 message = i18n("Save changes to document?");
517 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
518 switch (KMessageBox::warningYesNoCancel(this, message)) {
519 case KMessageBox::Yes :
520 // save document here. If saving fails, return false;
522 case KMessageBox::No :
523 // User does not want to save the changes, clear recovery files
524 m_activeDocument->m_autosave->resize(0);
533 void MainWindow::loadPlugins()
535 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
536 populateMenus(plugin);
539 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
541 filters << "libkdenlive*";
542 foreach(const QString &folder, directories) {
543 kDebug() << "Parsing plugin folder: " << folder;
544 QDir pluginsDir(folder);
545 foreach(const QString &fileName,
546 pluginsDir.entryList(filters, QDir::Files)) {
548 * Avoid loading the same plugin twice when there is more than one
551 if (!m_pluginFileNames.contains(fileName)) {
552 kDebug() << "Found plugin: " << fileName;
553 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
554 QObject *plugin = loader.instance();
556 populateMenus(plugin);
557 m_pluginFileNames += fileName;
559 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
565 void MainWindow::populateMenus(QObject *plugin)
567 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
568 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
570 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
574 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
575 QMenu *menu, const char *member,
576 QActionGroup *actionGroup)
578 kDebug() << "// ADD to MENU" << texts;
579 foreach(const QString &text, texts) {
580 QAction *action = new QAction(text, plugin);
581 action->setData(text);
582 connect(action, SIGNAL(triggered()), this, member);
583 menu->addAction(action);
586 action->setCheckable(true);
587 actionGroup->addAction(action);
592 void MainWindow::aboutPlugins()
594 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
599 void MainWindow::generateClip()
601 QAction *action = qobject_cast<QAction *>(sender());
602 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
604 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
605 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
606 if (!clipUrl.isEmpty()) {
607 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
611 void MainWindow::saveProperties(KConfigGroup &config)
613 // save properties here,used by session management
615 KMainWindow::saveProperties(config);
619 void MainWindow::readProperties(const KConfigGroup &config)
621 // read properties here,used by session management
622 KMainWindow::readProperties(config);
623 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
624 openFile(KUrl(Lastproject));
627 void MainWindow::slotReloadEffects()
629 m_customEffectsMenu->clear();
630 initEffects::parseCustomEffectsFile();
632 QStringList effectInfo;
633 QMap<QString, QStringList> effectsList;
634 for (int ix = 0; ix < customEffects.count(); ix++) {
635 effectInfo = customEffects.effectIdInfo(ix);
636 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
638 if (effectsList.isEmpty())
639 m_customEffectsMenu->setEnabled(false);
641 m_customEffectsMenu->setEnabled(true);
643 foreach(const QStringList &value, effectsList) {
644 action = new QAction(value.at(0), this);
645 action->setData(value);
646 m_customEffectsMenu->addAction(action);
648 m_effectList->reloadEffectList();
651 #ifndef NO_JOGSHUTTLE
652 void MainWindow::activateShuttleDevice()
656 if (KdenliveSettings::enableshuttle() == false) return;
657 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
658 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
659 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
660 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
661 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
662 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
663 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
666 void MainWindow::slotShuttleButton(int code)
670 slotShuttleAction(KdenliveSettings::shuttle1());
673 slotShuttleAction(KdenliveSettings::shuttle2());
676 slotShuttleAction(KdenliveSettings::shuttle3());
679 slotShuttleAction(KdenliveSettings::shuttle4());
682 slotShuttleAction(KdenliveSettings::shuttle5());
687 void MainWindow::slotShuttleAction(int code)
693 m_monitorManager->slotPlay();
696 m_monitorManager->slotPlay();
700 #endif /* NO_JOGSHUTTLE */
702 void MainWindow::configureNotifications()
704 KNotifyConfigWidget::configure(this);
707 void MainWindow::slotFullScreen()
709 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
712 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
714 if (!m_activeDocument) return;
715 if (effect.isNull()) {
716 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
719 QDomElement effectToAdd = effect.cloneNode().toElement();
720 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
723 void MainWindow::slotRaiseMonitor(bool clipMonitor)
725 if (clipMonitor) m_clipMonitorDock->raise();
726 else m_projectMonitorDock->raise();
729 void MainWindow::slotUpdateClip(const QString &id)
731 if (!m_activeDocument) return;
732 m_activeTimeline->projectView()->slotUpdateClip(id);
735 void MainWindow::slotConnectMonitors()
737 m_projectList->setRenderer(m_projectMonitor->render);
738 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
739 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
740 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
741 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
742 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
743 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
744 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)));
746 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
748 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
750 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
751 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
753 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
754 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
757 void MainWindow::slotAdjustClipMonitor()
759 m_clipMonitorDock->updateGeometry();
760 m_clipMonitorDock->adjustSize();
761 m_clipMonitor->resetSize();
764 void MainWindow::slotAdjustProjectMonitor()
766 m_projectMonitorDock->updateGeometry();
767 m_projectMonitorDock->adjustSize();
768 m_projectMonitor->resetSize();
771 void MainWindow::setupActions()
774 KActionCollection* collection = actionCollection();
775 m_timecodeFormat = new KComboBox(this);
776 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
777 m_timecodeFormat->addItem(i18n("Frames"));
778 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
779 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
781 m_statusProgressBar = new QProgressBar(this);
782 m_statusProgressBar->setMinimum(0);
783 m_statusProgressBar->setMaximum(100);
784 m_statusProgressBar->setMaximumWidth(150);
785 m_statusProgressBar->setVisible(false);
787 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
788 toolbar->setMovable(false);
789 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
790 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;}";
791 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
793 //create edit mode buttons
794 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
795 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
796 toolbar->addAction(m_normalEditTool);
797 m_normalEditTool->setCheckable(true);
798 m_normalEditTool->setChecked(true);
800 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
801 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
802 toolbar->addAction(m_overwriteEditTool);
803 m_overwriteEditTool->setCheckable(true);
804 m_overwriteEditTool->setChecked(false);
806 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
807 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
808 toolbar->addAction(m_insertEditTool);
809 m_insertEditTool->setCheckable(true);
810 m_insertEditTool->setChecked(false);
811 // not implemented yet
812 m_insertEditTool->setEnabled(false);
814 QActionGroup *editGroup = new QActionGroup(this);
815 editGroup->addAction(m_normalEditTool);
816 editGroup->addAction(m_overwriteEditTool);
817 editGroup->addAction(m_insertEditTool);
818 editGroup->setExclusive(true);
819 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
820 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
822 toolbar->addSeparator();
824 // create tools buttons
825 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
826 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
827 toolbar->addAction(m_buttonSelectTool);
828 m_buttonSelectTool->setCheckable(true);
829 m_buttonSelectTool->setChecked(true);
831 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
832 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
833 toolbar->addAction(m_buttonRazorTool);
834 m_buttonRazorTool->setCheckable(true);
835 m_buttonRazorTool->setChecked(false);
837 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
838 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
839 toolbar->addAction(m_buttonSpacerTool);
840 m_buttonSpacerTool->setCheckable(true);
841 m_buttonSpacerTool->setChecked(false);
843 QActionGroup *toolGroup = new QActionGroup(this);
844 toolGroup->addAction(m_buttonSelectTool);
845 toolGroup->addAction(m_buttonRazorTool);
846 toolGroup->addAction(m_buttonSpacerTool);
847 toolGroup->setExclusive(true);
848 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
850 QWidget * actionWidget;
851 int max = toolbar->iconSizeDefault() + 2;
852 actionWidget = toolbar->widgetForAction(m_normalEditTool);
853 actionWidget->setMaximumWidth(max);
854 actionWidget->setMaximumHeight(max - 4);
856 actionWidget = toolbar->widgetForAction(m_insertEditTool);
857 actionWidget->setMaximumWidth(max);
858 actionWidget->setMaximumHeight(max - 4);
860 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
861 actionWidget->setMaximumWidth(max);
862 actionWidget->setMaximumHeight(max - 4);
864 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
865 actionWidget->setMaximumWidth(max);
866 actionWidget->setMaximumHeight(max - 4);
868 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
869 actionWidget->setMaximumWidth(max);
870 actionWidget->setMaximumHeight(max - 4);
872 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
873 actionWidget->setMaximumWidth(max);
874 actionWidget->setMaximumHeight(max - 4);
876 toolbar->setStyleSheet(style1);
877 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
879 toolbar->addSeparator();
880 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
881 toolbar->addAction(m_buttonFitZoom);
882 m_buttonFitZoom->setCheckable(false);
884 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
885 toolbar->addAction(m_zoomOut);
886 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
888 m_zoomSlider = new QSlider(Qt::Horizontal, this);
889 m_zoomSlider->setMaximum(13);
890 m_zoomSlider->setPageStep(1);
891 m_zoomSlider->setInvertedAppearance(true);
893 m_zoomSlider->setMaximumWidth(150);
894 m_zoomSlider->setMinimumWidth(100);
895 toolbar->addWidget(m_zoomSlider);
897 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
898 toolbar->addAction(m_zoomIn);
899 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
901 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
902 actionWidget->setMaximumWidth(max);
903 actionWidget->setMaximumHeight(max - 4);
904 actionWidget->setStyleSheet(styleBorderless);
906 actionWidget = toolbar->widgetForAction(m_zoomIn);
907 actionWidget->setMaximumWidth(max);
908 actionWidget->setMaximumHeight(max - 4);
909 actionWidget->setStyleSheet(styleBorderless);
911 actionWidget = toolbar->widgetForAction(m_zoomOut);
912 actionWidget->setMaximumWidth(max);
913 actionWidget->setMaximumHeight(max - 4);
914 actionWidget->setStyleSheet(styleBorderless);
916 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
917 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
918 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
919 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
920 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
922 toolbar->addSeparator();
924 //create automatic audio split button
925 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
926 toolbar->addAction(m_buttonAutomaticSplitAudio);
927 m_buttonAutomaticSplitAudio->setCheckable(true);
928 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
929 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
931 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
932 toolbar->addAction(m_buttonVideoThumbs);
933 m_buttonVideoThumbs->setCheckable(true);
934 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
935 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
937 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
938 toolbar->addAction(m_buttonAudioThumbs);
939 m_buttonAudioThumbs->setCheckable(true);
940 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
941 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
943 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
944 toolbar->addAction(m_buttonShowMarkers);
945 m_buttonShowMarkers->setCheckable(true);
946 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
947 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
949 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
950 toolbar->addAction(m_buttonSnap);
951 m_buttonSnap->setCheckable(true);
952 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
953 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
955 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
956 actionWidget->setMaximumWidth(max);
957 actionWidget->setMaximumHeight(max - 4);
959 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
960 actionWidget->setMaximumWidth(max);
961 actionWidget->setMaximumHeight(max - 4);
963 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
964 actionWidget->setMaximumWidth(max);
965 actionWidget->setMaximumHeight(max - 4);
967 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
968 actionWidget->setMaximumWidth(max);
969 actionWidget->setMaximumHeight(max - 4);
971 actionWidget = toolbar->widgetForAction(m_buttonSnap);
972 actionWidget->setMaximumWidth(max);
973 actionWidget->setMaximumHeight(max - 4);
975 m_messageLabel = new StatusBarMessageLabel(this);
976 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
978 statusBar()->addWidget(m_messageLabel, 10);
979 statusBar()->addWidget(m_statusProgressBar, 0);
980 statusBar()->addPermanentWidget(toolbar);
981 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
982 statusBar()->addPermanentWidget(m_timecodeFormat);
983 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
985 collection->addAction("normal_mode", m_normalEditTool);
986 collection->addAction("overwrite_mode", m_overwriteEditTool);
987 collection->addAction("insert_mode", m_insertEditTool);
988 collection->addAction("select_tool", m_buttonSelectTool);
989 collection->addAction("razor_tool", m_buttonRazorTool);
990 collection->addAction("spacer_tool", m_buttonSpacerTool);
992 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
993 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
994 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
995 collection->addAction("show_markers", m_buttonShowMarkers);
996 collection->addAction("snap", m_buttonSnap);
997 collection->addAction("zoom_fit", m_buttonFitZoom);
998 collection->addAction("zoom_in", m_zoomIn);
999 collection->addAction("zoom_out", m_zoomOut);
1001 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1002 collection->addAction("project_find", m_projectSearch);
1003 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1004 m_projectSearch->setShortcut(Qt::Key_Slash);
1006 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1007 collection->addAction("project_find_next", m_projectSearchNext);
1008 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1009 m_projectSearchNext->setShortcut(Qt::Key_F3);
1010 m_projectSearchNext->setEnabled(false);
1012 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1013 collection->addAction("manage_profiles", profilesAction);
1014 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1016 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1017 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1018 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1019 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1021 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1022 collection->addAction("run_wizard", wizAction);
1023 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1025 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1026 collection->addAction("project_settings", projectAction);
1027 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1029 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1030 collection->addAction("project_render", projectRender);
1031 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1032 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1034 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1035 collection->addAction("project_clean", projectClean);
1036 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1038 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1039 KShortcut playShortcut;
1040 playShortcut.setPrimary(Qt::Key_Space);
1041 playShortcut.setAlternate(Qt::Key_K);
1042 monitorPlay->setShortcut(playShortcut);
1043 collection->addAction("monitor_play", monitorPlay);
1044 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1046 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1047 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1048 collection->addAction("monitor_play_zone", m_playZone);
1049 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1051 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1052 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1053 collection->addAction("monitor_loop_zone", m_loopZone);
1054 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1056 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1057 collection->addAction("dvd_wizard", dvdWizard);
1058 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1060 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1061 collection->addAction("transcode_clip", transcodeClip);
1062 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1064 KAction *markIn = collection->addAction("mark_in");
1065 markIn->setText(i18n("Set Zone In"));
1066 markIn->setShortcut(Qt::Key_I);
1067 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1069 KAction *markOut = collection->addAction("mark_out");
1070 markOut->setText(i18n("Set Zone Out"));
1071 markOut->setShortcut(Qt::Key_O);
1072 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1074 KAction *switchMon = collection->addAction("switch_monitor");
1075 switchMon->setText(i18n("Switch monitor"));
1076 switchMon->setShortcut(Qt::Key_T);
1077 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1079 KAction *insertTree = collection->addAction("insert_project_tree");
1080 insertTree->setText(i18n("Insert zone in project tree"));
1081 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1082 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1084 KAction *insertTimeline = collection->addAction("insert_timeline");
1085 insertTimeline->setText(i18n("Insert zone in timeline"));
1086 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1087 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1089 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1090 collection->addAction("resize_timeline_clip_start", resizeStart);
1091 resizeStart->setShortcut(Qt::Key_1);
1092 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1094 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1095 collection->addAction("resize_timeline_clip_end", resizeEnd);
1096 resizeEnd->setShortcut(Qt::Key_2);
1097 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1099 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1100 monitorSeekBackward->setShortcut(Qt::Key_J);
1101 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1102 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1104 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1105 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1106 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1107 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1109 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1110 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1111 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1112 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1114 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1115 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1116 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1117 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1119 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1120 monitorSeekForward->setShortcut(Qt::Key_L);
1121 collection->addAction("monitor_seek_forward", monitorSeekForward);
1122 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1124 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1125 clipStart->setShortcut(Qt::Key_Home);
1126 collection->addAction("seek_clip_start", clipStart);
1127 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1129 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1130 clipEnd->setShortcut(Qt::Key_End);
1131 collection->addAction("seek_clip_end", clipEnd);
1132 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1134 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1135 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1136 collection->addAction("seek_zone_start", zoneStart);
1137 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1139 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1140 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1141 collection->addAction("seek_zone_end", zoneEnd);
1142 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1144 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1145 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1146 collection->addAction("seek_start", projectStart);
1147 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1149 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1150 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1151 collection->addAction("seek_end", projectEnd);
1152 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1154 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1155 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1156 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1157 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1159 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1160 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1161 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1162 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1164 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1165 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1166 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1167 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1169 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1170 deleteItem->setShortcut(Qt::Key_Delete);
1171 collection->addAction("delete_timeline_clip", deleteItem);
1172 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1174 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1175 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1176 editTimelineClipSpeed->setData("change_speed");
1177 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1179 KAction *stickTransition = collection->addAction("auto_transition");
1180 stickTransition->setData(QString("auto"));
1181 stickTransition->setCheckable(true);
1182 stickTransition->setEnabled(false);
1183 stickTransition->setText(i18n("Automatic Transition"));
1184 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1186 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1187 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1188 collection->addAction("group_clip", groupClip);
1189 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1191 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1192 collection->addAction("ungroup_clip", ungroupClip);
1193 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1194 ungroupClip->setData("ungroup_clip");
1195 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1197 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1198 collection->addAction("edit_item_duration", editItemDuration);
1199 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1201 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1202 collection->addAction("clip_in_project_tree", clipInProjectTree);
1203 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1205 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1206 collection->addAction("clip_to_project_tree", clipToProjectTree);
1207 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1209 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1210 insertOvertwrite->setShortcut(Qt::Key_V);
1211 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1212 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1214 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1215 selectTimelineClip->setShortcut(Qt::Key_Plus);
1216 collection->addAction("select_timeline_clip", selectTimelineClip);
1217 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1219 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1220 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1221 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1222 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1224 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1225 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1226 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1227 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1229 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1230 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1231 collection->addAction("select_timeline_transition", selectTimelineTransition);
1232 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1234 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1235 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1236 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1237 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1239 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1240 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1241 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1242 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1244 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1245 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1246 collection->addAction("cut_timeline_clip", cutTimelineClip);
1247 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1249 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1250 collection->addAction("add_clip_marker", addClipMarker);
1251 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1253 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1254 collection->addAction("delete_clip_marker", deleteClipMarker);
1255 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1257 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1258 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1259 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1261 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1262 collection->addAction("edit_clip_marker", editClipMarker);
1263 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1265 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1266 collection->addAction("split_audio", splitAudio);
1267 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1269 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1270 collection->addAction("clip_audio_only", audioOnly);
1271 audioOnly->setData("clip_audio_only");
1272 audioOnly->setCheckable(true);
1274 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1275 collection->addAction("clip_video_only", videoOnly);
1276 videoOnly->setData("clip_video_only");
1277 videoOnly->setCheckable(true);
1279 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1280 collection->addAction("clip_audio_and_video", audioAndVideo);
1281 audioAndVideo->setData("clip_audio_and_video");
1282 audioAndVideo->setCheckable(true);
1284 m_clipTypeGroup = new QActionGroup(this);
1285 m_clipTypeGroup->addAction(audioOnly);
1286 m_clipTypeGroup->addAction(videoOnly);
1287 m_clipTypeGroup->addAction(audioAndVideo);
1288 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1289 m_clipTypeGroup->setEnabled(false);
1291 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1292 collection->addAction("insert_space", insertSpace);
1293 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1295 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1296 collection->addAction("delete_space", removeSpace);
1297 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1299 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1300 collection->addAction("insert_track", insertTrack);
1301 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1303 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1304 collection->addAction("delete_track", deleteTrack);
1305 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1307 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1308 collection->addAction("config_tracks", configTracks);
1309 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1311 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1312 collection->addAction("add_guide", addGuide);
1313 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1315 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1316 collection->addAction("delete_guide", delGuide);
1317 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1319 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1320 collection->addAction("edit_guide", editGuide);
1321 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1323 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1324 collection->addAction("delete_all_guides", delAllGuides);
1325 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1327 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1328 collection->addAction("paste_effects", pasteEffects);
1329 pasteEffects->setData("paste_effects");
1330 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1332 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1333 collection->addAction("show_timeline", showTimeline);
1334 showTimeline->setCheckable(true);
1335 showTimeline->setChecked(true);
1336 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1338 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1339 collection->addAction("show_titlebars", showTitleBar);
1340 showTitleBar->setCheckable(true);
1341 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1342 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1343 slotShowTitleBars(KdenliveSettings::showtitlebars());
1345 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1346 collection->addAction("maximize_current", maxCurrent);
1347 maxCurrent->setCheckable(true);
1348 maxCurrent->setChecked(false);
1349 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1351 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1352 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1353 KStandardAction::open(this, SLOT(openFile()), collection);
1354 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1355 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1356 KStandardAction::openNew(this, SLOT(newFile()), collection);
1357 // TODO: make the following connection to slotEditKeys work
1358 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1359 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1360 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1361 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1362 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1363 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1365 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1366 undo->setEnabled(false);
1367 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1369 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1370 redo->setEnabled(false);
1371 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1374 //TODO: Add status tooltip to actions ?
1375 connect(collection, SIGNAL(actionHovered(QAction*)),
1376 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1379 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1380 collection->addAction("add_clip", addClip);
1381 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1383 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1384 collection->addAction("add_color_clip", addColorClip);
1385 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1387 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1388 collection->addAction("add_slide_clip", addSlideClip);
1389 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1391 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1392 collection->addAction("add_text_clip", addTitleClip);
1393 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1395 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1396 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1397 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1399 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1400 collection->addAction("add_folder", addFolderButton);
1401 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1403 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1404 collection->addAction("clip_properties", clipProperties);
1405 clipProperties->setData("clip_properties");
1406 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1407 clipProperties->setEnabled(false);
1409 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1410 collection->addAction("edit_clip", openClip);
1411 openClip->setData("edit_clip");
1412 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1413 openClip->setEnabled(false);
1415 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1416 collection->addAction("delete_clip", deleteClip);
1417 deleteClip->setData("delete_clip");
1418 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1419 deleteClip->setEnabled(false);
1421 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1422 collection->addAction("reload_clip", reloadClip);
1423 reloadClip->setData("reload_clip");
1424 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1425 reloadClip->setEnabled(false);
1427 QMenu *addClips = new QMenu();
1428 addClips->addAction(addClip);
1429 addClips->addAction(addColorClip);
1430 addClips->addAction(addSlideClip);
1431 addClips->addAction(addTitleClip);
1432 addClips->addAction(addTitleTemplateClip);
1433 addClips->addAction(addFolderButton);
1435 addClips->addAction(reloadClip);
1436 addClips->addAction(clipProperties);
1437 addClips->addAction(openClip);
1438 addClips->addAction(deleteClip);
1439 m_projectList->setupMenu(addClips, addClip);
1441 // Setup effects and transitions actions.
1442 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1443 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1444 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1445 m_videoEffects = new KAction*[videoEffects.count()];
1446 for (int i = 0; i < videoEffects.count(); ++i) {
1447 QStringList effectInfo = videoEffects.effectIdInfo(i);
1448 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1449 m_videoEffects[i]->setData(effectInfo);
1450 m_videoEffects[i]->setIconVisibleInMenu(false);
1451 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1453 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1454 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1455 m_audioEffects = new KAction*[audioEffects.count()];
1456 for (int i = 0; i < audioEffects.count(); ++i) {
1457 QStringList effectInfo = audioEffects.effectIdInfo(i);
1458 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1459 m_audioEffects[i]->setData(effectInfo);
1460 m_audioEffects[i]->setIconVisibleInMenu(false);
1461 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1463 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1464 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1465 m_customEffects = new KAction*[customEffects.count()];
1466 for (int i = 0; i < customEffects.count(); ++i) {
1467 QStringList effectInfo = customEffects.effectIdInfo(i);
1468 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1469 m_customEffects[i]->setData(effectInfo);
1470 m_customEffects[i]->setIconVisibleInMenu(false);
1471 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1473 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1474 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1475 m_transitions = new KAction*[transitions.count()];
1476 for (int i = 0; i < transitions.count(); i++) {
1477 QStringList effectInfo = transitions.effectIdInfo(i);
1478 m_transitions[i] = new KAction(effectInfo.at(0), this);
1479 m_transitions[i]->setData(effectInfo);
1480 m_transitions[i]->setIconVisibleInMenu(false);
1481 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1483 m_effectsActionCollection->readSettings();
1485 //connect(collection, SIGNAL( clearStatusText() ),
1486 //statusBar(), SLOT( clear() ) );
1489 void MainWindow::slotDisplayActionMessage(QAction *a)
1491 statusBar()->showMessage(a->data().toString(), 3000);
1494 void MainWindow::saveOptions()
1496 KdenliveSettings::self()->writeConfig();
1497 KSharedConfigPtr config = KGlobal::config();
1498 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1499 KConfigGroup treecolumns(config, "Project Tree");
1500 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1504 void MainWindow::readOptions()
1506 KSharedConfigPtr config = KGlobal::config();
1507 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1508 KConfigGroup initialGroup(config, "version");
1509 bool upgrade = false;
1510 if (initialGroup.exists()) {
1511 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1515 if (initialGroup.readEntry("version") == "0.7") {
1516 //Add new settings from 0.7.1
1517 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1518 QString path = QDir::homePath() + "/kdenlive";
1519 if (KStandardDirs::makeDir(path) == false) {
1520 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1521 } else KdenliveSettings::setDefaultprojectfolder(path);
1527 if (!initialGroup.exists() || upgrade) {
1528 // this is our first run, show Wizard
1529 Wizard *w = new Wizard(upgrade, this);
1530 if (w->exec() == QDialog::Accepted && w->isOk()) {
1531 w->adjustSettings();
1532 initialGroup.writeEntry("version", version);
1538 KConfigGroup treecolumns(config, "Project Tree");
1539 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1540 if (!state.isEmpty())
1541 m_projectList->setHeaderInfo(state);
1544 void MainWindow::slotRunWizard()
1546 Wizard *w = new Wizard(false, this);
1547 if (w->exec() == QDialog::Accepted && w->isOk()) {
1548 w->adjustSettings();
1553 void MainWindow::newFile(bool showProjectSettings, bool force)
1555 if (!m_timelineArea->isEnabled() && !force) return;
1556 m_fileRevert->setEnabled(false);
1557 QString profileName;
1559 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1560 if (!showProjectSettings) {
1561 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1562 profileName = KdenliveSettings::default_profile();
1563 projectFolder = KdenliveSettings::defaultprojectfolder();
1565 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1566 if (w->exec() != QDialog::Accepted) return;
1567 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1568 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1569 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1570 profileName = w->selectedProfile();
1571 projectFolder = w->selectedFolder();
1572 projectTracks = w->tracks();
1575 m_timelineArea->setEnabled(true);
1576 m_projectList->setEnabled(true);
1577 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1578 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1580 TrackView *trackView = new TrackView(doc, &ok, this);
1581 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1584 //m_timelineArea->setEnabled(false);
1585 //m_projectList->setEnabled(false);
1589 if (m_timelineArea->count() == 1) {
1590 connectDocumentInfo(doc);
1591 connectDocument(trackView, doc);
1592 } else m_timelineArea->setTabBarHidden(false);
1593 m_monitorManager->activateMonitor("clip");
1594 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1597 void MainWindow::activateDocument()
1599 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1600 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1601 KdenliveDoc *currentDoc = currentTab->document();
1602 connectDocumentInfo(currentDoc);
1603 connectDocument(currentTab, currentDoc);
1606 void MainWindow::closeCurrentDocument(bool saveChanges)
1608 QWidget *w = m_timelineArea->currentWidget();
1610 // closing current document
1611 int ix = m_timelineArea->currentIndex() + 1;
1612 if (ix == m_timelineArea->count()) ix = 0;
1613 m_timelineArea->setCurrentIndex(ix);
1614 TrackView *tabToClose = (TrackView *) w;
1615 KdenliveDoc *docToClose = tabToClose->document();
1616 if (docToClose && docToClose->isModified() && saveChanges) {
1618 if (m_activeDocument->url().fileName().isEmpty())
1619 message = i18n("Save changes to document?");
1621 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1622 switch (KMessageBox::warningYesNoCancel(this, message)) {
1623 case KMessageBox::Yes :
1624 // save document here. If saving fails, return false;
1625 if (saveFile() == false) return;
1627 case KMessageBox::Cancel :
1634 m_clipMonitor->slotSetXml(NULL);
1635 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1636 if (m_timelineArea->count() == 1) {
1637 m_timelineArea->setTabBarHidden(true);
1638 m_closeAction->setEnabled(false);
1640 if (docToClose == m_activeDocument) {
1641 delete m_activeDocument;
1642 m_activeDocument = NULL;
1643 m_effectStack->clear();
1644 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1648 if (w == m_activeTimeline) {
1649 delete m_activeTimeline;
1650 m_activeTimeline = NULL;
1656 bool MainWindow::saveFileAs(const QString &outputFileName)
1658 QString currentSceneList;
1659 m_monitorManager->stopActiveMonitor();
1660 if (KdenliveSettings::dropbframes()) {
1661 KdenliveSettings::setDropbframes(false);
1662 m_activeDocument->clipManager()->updatePreviewSettings();
1663 currentSceneList = m_projectMonitor->sceneList();
1664 KdenliveSettings::setDropbframes(true);
1665 m_activeDocument->clipManager()->updatePreviewSettings();
1666 } else currentSceneList = m_projectMonitor->sceneList();
1668 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1671 // Save timeline thumbnails
1672 m_activeTimeline->projectView()->saveThumbnails();
1673 m_activeDocument->setUrl(KUrl(outputFileName));
1674 if (m_activeDocument->m_autosave == NULL) {
1675 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1676 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1677 setCaption(m_activeDocument->description());
1678 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1679 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1680 m_activeDocument->setModified(false);
1681 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1682 m_fileRevert->setEnabled(true);
1686 bool MainWindow::saveFileAs()
1688 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1689 if (outputFile.isEmpty()) {
1692 if (QFile::exists(outputFile)) {
1693 // Show the file dialog again if the user does not want to overwrite the file
1694 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1695 return saveFileAs();
1697 return saveFileAs(outputFile);
1700 bool MainWindow::saveFile()
1702 if (!m_activeDocument) return true;
1703 if (m_activeDocument->url().isEmpty()) {
1704 return saveFileAs();
1706 bool result = saveFileAs(m_activeDocument->url().path());
1707 m_activeDocument->m_autosave->resize(0);
1712 void MainWindow::openFile()
1714 if (!m_startUrl.isEmpty()) {
1715 openFile(m_startUrl);
1716 m_startUrl = KUrl();
1719 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1720 if (url.isEmpty()) return;
1721 m_fileOpenRecent->addUrl(url);
1725 void MainWindow::openLastFile()
1727 KSharedConfigPtr config = KGlobal::config();
1728 KUrl::List urls = m_fileOpenRecent->urls();
1729 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1730 if (urls.isEmpty()) newFile(false);
1731 else openFile(urls.last());
1734 void MainWindow::openFile(const KUrl &url)
1736 // Check if the document is already opened
1737 const int ct = m_timelineArea->count();
1738 bool isOpened = false;
1740 for (i = 0; i < ct; i++) {
1741 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1742 KdenliveDoc *doc = tab->document();
1743 if (doc->url() == url) {
1749 m_timelineArea->setCurrentIndex(i);
1753 // Check for backup file
1754 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1755 if (!staleFiles.isEmpty()) {
1756 if (KMessageBox::questionYesNo(this,
1757 i18n("Auto-saved files exist. Do you want to recover them now?"),
1758 i18n("File Recovery"),
1759 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1760 recoverFiles(staleFiles);
1763 // remove the stale files
1764 foreach(KAutoSaveFile *stale, staleFiles) {
1765 stale->open(QIODevice::ReadWrite);
1770 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1771 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1772 m_messageLabel->repaint();
1773 doOpenFile(url, NULL);
1776 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1778 if (!m_timelineArea->isEnabled()) return;
1779 m_fileRevert->setEnabled(true);
1780 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1781 if (stale == NULL) {
1782 stale = new KAutoSaveFile(url, doc);
1783 doc->m_autosave = stale;
1785 doc->m_autosave = stale;
1786 doc->setUrl(stale->managedFile());
1787 doc->setModified(true);
1788 stale->setParent(doc);
1790 connectDocumentInfo(doc);
1792 TrackView *trackView = new TrackView(doc, &ok, this);
1793 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1795 m_timelineArea->setEnabled(false);
1796 m_projectList->setEnabled(false);
1797 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1798 slotGotProgressInfo(QString(), -1);
1799 newFile(false, true);
1802 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1803 trackView->setDuration(trackView->duration());
1804 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1806 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1807 slotGotProgressInfo(QString(), -1);
1808 m_projectMonitor->adjustRulerSize(trackView->duration());
1809 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1810 m_clipMonitor->refreshMonitor(true);
1813 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1815 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1816 foreach(KAutoSaveFile *stale, staleFiles) {
1817 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1818 // show an error message; we could not steal the lockfile
1819 // maybe another application got to the file before us?
1823 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1824 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1825 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1826 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1830 void MainWindow::parseProfiles(const QString &mltPath)
1832 //KdenliveSettings::setDefaulttmpfolder();
1833 if (!mltPath.isEmpty()) {
1834 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1835 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1838 if (KdenliveSettings::mltpath().isEmpty())
1839 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1841 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1842 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1843 if (!QFile::exists(meltPath))
1844 meltPath = KStandardDirs::findExe("melt");
1845 KdenliveSettings::setRendererpath(meltPath);
1848 if (KdenliveSettings::rendererpath().isEmpty()) {
1849 // Cannot find the MLT melt renderer, ask for location
1850 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1851 if (getUrl->exec() == QDialog::Rejected) {
1854 KUrl rendererPath = getUrl->selectedUrl();
1856 if (rendererPath.isEmpty()) ::exit(0);
1857 KdenliveSettings::setRendererpath(rendererPath.path());
1860 QStringList profilesFilter;
1861 profilesFilter << "*";
1862 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1863 if (profilesList.isEmpty()) {
1864 // Cannot find MLT path, try finding melt
1865 QString profilePath = KdenliveSettings::rendererpath();
1866 if (!profilePath.isEmpty()) {
1867 profilePath = profilePath.section('/', 0, -3);
1868 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1869 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1871 if (profilesList.isEmpty()) {
1872 // Cannot find the MLT profiles, ask for location
1873 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1874 getUrl->fileDialog()->setMode(KFile::Directory);
1875 if (getUrl->exec() == QDialog::Rejected) {
1878 KUrl mltPath = getUrl->selectedUrl();
1880 if (mltPath.isEmpty()) ::exit(0);
1881 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1882 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1886 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1888 // Parse again MLT profiles to build a list of available video formats
1889 if (profilesList.isEmpty()) parseProfiles();
1893 void MainWindow::slotEditProfiles()
1895 ProfilesDialog *w = new ProfilesDialog;
1896 if (w->exec() == QDialog::Accepted) {
1897 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1898 if (d) d->checkProfile();
1903 void MainWindow::slotDetectAudioDriver()
1905 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1906 leading to no audio output, see bug #934 */
1908 //decide which audio driver is really best, in some cases SDL is wrong
1909 if (KdenliveSettings::audiodrivername().isEmpty()) {
1911 KProcess readProcess;
1912 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1913 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1914 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1915 readProcess.setProgram("pactl", QStringList() << "stat");
1916 readProcess.execute(2000); // Kill it after 2 seconds
1918 QString result = QString(readProcess.readAllStandardOutput());
1919 kDebug() << "// / / / / / READING PACTL: ";
1921 if (!result.isEmpty()) {
1923 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1927 KdenliveSettings::setAutoaudiodrivername(driver);
1931 void MainWindow::slotEditProjectSettings()
1933 QPoint p = m_activeDocument->getTracksCount();
1934 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1936 if (w->exec() == QDialog::Accepted) {
1937 QString profile = w->selectedProfile();
1938 m_activeDocument->setProjectFolder(w->selectedFolder());
1939 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1940 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1941 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1942 if (m_activeDocument->profilePath() != profile) {
1943 // Profile was changed
1944 double dar = m_activeDocument->dar();
1946 // Deselect current effect / transition
1947 m_effectStack->slotClipItemSelected(NULL, 0);
1948 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1949 m_clipMonitor->slotSetXml(NULL);
1950 bool updateFps = m_activeDocument->setProfilePath(profile);
1951 KdenliveSettings::setCurrent_profile(profile);
1952 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1953 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1955 m_activeDocument->clipManager()->clearUnusedProducers();
1956 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1958 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1959 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1960 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1961 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1962 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1963 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1964 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1965 if (updateFps) m_activeTimeline->updateProjectFps();
1966 m_activeDocument->setModified(true);
1967 m_commandStack->activeStack()->clear();
1968 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1969 slotUpdateMousePosition(0);
1970 // We need to desactivate & reactivate monitors to get a refresh
1971 //m_monitorManager->switchMonitors();
1978 void MainWindow::slotRenderProject()
1980 if (!m_renderWidget) {
1981 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1982 m_renderWidget = new RenderWidget(projectfolder, this);
1983 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1984 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
1985 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1986 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1987 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1988 if (m_activeDocument) {
1989 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1990 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1991 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1992 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
1995 slotCheckRenderStatus();
1996 m_renderWidget->show();
1997 m_renderWidget->showNormal();
1999 // What are the following lines supposed to do?
2000 //m_activeTimeline->tracksNumber();
2001 //m_renderWidget->enableAudio(false);
2002 //m_renderWidget->export_audio;
2005 void MainWindow::slotCheckRenderStatus()
2007 // Make sure there are no missing clips
2009 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2012 void MainWindow::setRenderingProgress(const QString &url, int progress)
2015 m_renderWidget->setRenderJob(url, progress);
2018 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2021 m_renderWidget->setRenderStatus(url, status, error);
2024 void MainWindow::slotCleanProject()
2026 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2027 m_projectList->cleanup();
2030 void MainWindow::slotUpdateMousePosition(int pos)
2032 if (m_activeDocument)
2033 switch (m_timecodeFormat->currentIndex()) {
2035 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2038 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2042 void MainWindow::slotUpdateDocumentState(bool modified)
2044 if (!m_activeDocument) return;
2045 setCaption(m_activeDocument->description(), modified);
2046 m_saveAction->setEnabled(modified);
2048 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2049 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2051 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2052 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2056 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2058 if (m_activeDocument) {
2059 if (m_activeDocument == doc) return;
2060 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2062 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2065 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2067 //m_projectMonitor->stop();
2068 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2069 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2070 if (m_activeDocument) {
2071 if (m_activeDocument == doc) return;
2072 if (m_activeTimeline) {
2073 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2074 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2075 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2076 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2077 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2078 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2079 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2081 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2082 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2083 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2084 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2085 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2086 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2087 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2088 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2089 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2090 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2091 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2092 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2093 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2094 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2095 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2096 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2097 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2098 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2099 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2100 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2101 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2102 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2103 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2104 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2105 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2106 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2107 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2108 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2109 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2110 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2111 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2112 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2113 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2114 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2115 m_effectStack->clear();
2117 //m_activeDocument->setRenderer(NULL);
2118 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2119 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2120 m_clipMonitor->stop();
2122 KdenliveSettings::setCurrent_profile(doc->profilePath());
2123 KdenliveSettings::setProject_fps(doc->fps());
2124 m_monitorManager->resetProfiles(doc->timecode());
2125 m_projectList->setDocument(doc);
2126 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2127 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2128 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2129 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2130 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2132 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2133 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2135 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2138 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2139 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2140 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2141 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2142 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2143 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2144 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2145 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2146 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2147 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2148 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2149 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2150 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2151 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2153 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2154 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2155 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2156 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2157 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2159 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2160 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2161 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2164 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2165 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2167 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2168 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2169 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2170 m_zoomSlider->setValue(doc->zoom().x());
2171 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2172 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2173 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2174 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2176 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2177 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2180 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2181 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2182 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2183 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2184 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2185 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2186 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2187 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2188 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2189 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2190 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2192 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2193 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2194 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2195 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2196 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2199 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2200 m_activeTimeline = trackView;
2201 if (m_renderWidget) {
2202 slotCheckRenderStatus();
2203 m_renderWidget->setProfile(doc->mltProfile());
2204 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2205 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2206 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2208 //doc->setRenderer(m_projectMonitor->render);
2209 m_commandStack->setActiveStack(doc->commandStack());
2210 KdenliveSettings::setProject_display_ratio(doc->dar());
2211 //doc->clipManager()->checkAudioThumbs();
2213 //m_overView->setScene(trackView->projectScene());
2214 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2215 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2217 setCaption(doc->description(), doc->isModified());
2218 m_saveAction->setEnabled(doc->isModified());
2219 m_normalEditTool->setChecked(true);
2220 m_activeDocument = doc;
2221 m_activeTimeline->updateProjectFps();
2222 m_activeDocument->checkProjectClips();
2223 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2224 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2225 slotUpdateMousePosition(0);
2226 // set tool to select tool
2227 m_buttonSelectTool->setChecked(true);
2230 void MainWindow::slotZoneMoved(int start, int end)
2232 m_activeDocument->setZone(start, end);
2233 m_projectMonitor->slotZoneMoved(start, end);
2236 void MainWindow::slotGuidesUpdated()
2239 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2242 void MainWindow::slotEditKeys()
2244 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2245 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2246 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2250 void MainWindow::slotPreferences(int page, int option)
2252 //An instance of your dialog could be already created and could be
2253 // cached, in which case you want to display the cached dialog
2254 // instead of creating another one
2255 if (KConfigDialog::showDialog("settings")) {
2256 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2257 if (page != -1) d->showPage(page, option);
2261 // KConfigDialog didn't find an instance of this dialog, so lets
2263 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2264 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2265 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2266 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2267 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2269 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2271 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2273 if (page != -1) dialog->showPage(page, option);
2276 void MainWindow::slotUpdatePreviewSettings()
2278 if (m_activeDocument) {
2279 m_clipMonitor->slotSetXml(NULL);
2280 m_activeDocument->updatePreviewSettings();
2284 void MainWindow::updateConfiguration()
2286 //TODO: we should apply settings to all projects, not only the current one
2287 if (m_activeTimeline) {
2288 m_activeTimeline->refresh();
2289 m_activeTimeline->projectView()->checkAutoScroll();
2290 m_activeTimeline->projectView()->checkTrackHeight();
2291 if (m_activeDocument)
2292 m_activeDocument->clipManager()->checkAudioThumbs();
2294 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2295 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2296 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2297 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2299 // Update list of transcoding profiles
2301 #ifndef NO_JOGSHUTTLE
2302 activateShuttleDevice();
2303 #endif /* NO_JOGSHUTTLE */
2307 void MainWindow::slotSwitchSplitAudio()
2309 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2310 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2313 void MainWindow::slotSwitchVideoThumbs()
2315 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2316 if (m_activeTimeline)
2317 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2318 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2321 void MainWindow::slotSwitchAudioThumbs()
2323 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2324 if (m_activeTimeline) {
2325 m_activeTimeline->refresh();
2326 m_activeTimeline->projectView()->checkAutoScroll();
2327 if (m_activeDocument)
2328 m_activeDocument->clipManager()->checkAudioThumbs();
2330 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2333 void MainWindow::slotSwitchMarkersComments()
2335 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2336 if (m_activeTimeline)
2337 m_activeTimeline->refresh();
2338 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2341 void MainWindow::slotSwitchSnap()
2343 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2344 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2348 void MainWindow::slotDeleteItem()
2350 if (QApplication::focusWidget() &&
2351 QApplication::focusWidget()->parentWidget() &&
2352 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2353 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2354 m_projectList->slotRemoveClip();
2357 QWidget *widget = QApplication::focusWidget();
2359 if (widget == m_effectStackDock) {
2360 m_effectStack->slotItemDel();
2363 widget = widget->parentWidget();
2366 // effect stack has no focus
2367 if (m_activeTimeline)
2368 m_activeTimeline->projectView()->deleteSelectedClips();
2372 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2374 if (m_clipMonitor->isActive())
2375 m_clipMonitor->checkOverlay();
2376 m_clipMonitor->updateMarkers(clip);
2379 void MainWindow::slotAddClipMarker()
2381 DocClipBase *clip = NULL;
2383 if (m_projectMonitor->isActive()) {
2384 if (m_activeTimeline) {
2385 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2387 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2388 clip = item->baseClip();
2392 clip = m_clipMonitor->activeClip();
2393 pos = m_clipMonitor->position();
2396 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2399 QString id = clip->getId();
2400 CommentedTime marker(pos, i18n("Marker"));
2401 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2402 if (d.exec() == QDialog::Accepted)
2403 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2406 void MainWindow::slotDeleteClipMarker()
2408 DocClipBase *clip = NULL;
2410 if (m_projectMonitor->isActive()) {
2411 if (m_activeTimeline) {
2412 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2414 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2415 clip = item->baseClip();
2419 clip = m_clipMonitor->activeClip();
2420 pos = m_clipMonitor->position();
2423 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2427 QString id = clip->getId();
2428 QString comment = clip->markerComment(pos);
2429 if (comment.isEmpty()) {
2430 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2433 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2436 void MainWindow::slotDeleteAllClipMarkers()
2438 DocClipBase *clip = NULL;
2439 if (m_projectMonitor->isActive()) {
2440 if (m_activeTimeline) {
2441 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2443 clip = item->baseClip();
2447 clip = m_clipMonitor->activeClip();
2450 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2453 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2456 void MainWindow::slotEditClipMarker()
2458 DocClipBase *clip = NULL;
2460 if (m_projectMonitor->isActive()) {
2461 if (m_activeTimeline) {
2462 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2464 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2465 clip = item->baseClip();
2469 clip = m_clipMonitor->activeClip();
2470 pos = m_clipMonitor->position();
2473 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2477 QString id = clip->getId();
2478 QString oldcomment = clip->markerComment(pos);
2479 if (oldcomment.isEmpty()) {
2480 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2484 CommentedTime marker(pos, oldcomment);
2485 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2486 if (d.exec() == QDialog::Accepted) {
2487 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2488 if (d.newMarker().time() != pos) {
2489 // remove old marker
2490 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2495 void MainWindow::slotAddGuide()
2497 if (m_activeTimeline)
2498 m_activeTimeline->projectView()->slotAddGuide();
2501 void MainWindow::slotInsertSpace()
2503 if (m_activeTimeline)
2504 m_activeTimeline->projectView()->slotInsertSpace();
2507 void MainWindow::slotRemoveSpace()
2509 if (m_activeTimeline)
2510 m_activeTimeline->projectView()->slotRemoveSpace();
2513 void MainWindow::slotInsertTrack(int ix)
2515 m_projectMonitor->activateMonitor();
2516 if (m_activeTimeline)
2517 m_activeTimeline->projectView()->slotInsertTrack(ix);
2518 if (m_activeDocument)
2519 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2522 void MainWindow::slotDeleteTrack(int ix)
2524 m_projectMonitor->activateMonitor();
2525 if (m_activeTimeline)
2526 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2527 if (m_activeDocument)
2528 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2531 void MainWindow::slotConfigTrack(int ix)
2533 m_projectMonitor->activateMonitor();
2534 if (m_activeTimeline)
2535 m_activeTimeline->projectView()->slotConfigTracks(ix);
2536 if (m_activeDocument)
2537 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2540 void MainWindow::slotEditGuide()
2542 if (m_activeTimeline)
2543 m_activeTimeline->projectView()->slotEditGuide();
2546 void MainWindow::slotDeleteGuide()
2548 if (m_activeTimeline)
2549 m_activeTimeline->projectView()->slotDeleteGuide();
2552 void MainWindow::slotDeleteAllGuides()
2554 if (m_activeTimeline)
2555 m_activeTimeline->projectView()->slotDeleteAllGuides();
2558 void MainWindow::slotCutTimelineClip()
2560 if (m_activeTimeline)
2561 m_activeTimeline->projectView()->cutSelectedClips();
2564 void MainWindow::slotInsertClipOverwrite()
2566 if (m_activeTimeline) {
2567 QStringList data = m_clipMonitor->getZoneInfo();
2568 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2572 void MainWindow::slotSelectTimelineClip()
2574 if (m_activeTimeline)
2575 m_activeTimeline->projectView()->selectClip(true);
2578 void MainWindow::slotSelectTimelineTransition()
2580 if (m_activeTimeline)
2581 m_activeTimeline->projectView()->selectTransition(true);
2584 void MainWindow::slotDeselectTimelineClip()
2586 if (m_activeTimeline)
2587 m_activeTimeline->projectView()->selectClip(false, true);
2590 void MainWindow::slotDeselectTimelineTransition()
2592 if (m_activeTimeline)
2593 m_activeTimeline->projectView()->selectTransition(false, true);
2596 void MainWindow::slotSelectAddTimelineClip()
2598 if (m_activeTimeline)
2599 m_activeTimeline->projectView()->selectClip(true, true);
2602 void MainWindow::slotSelectAddTimelineTransition()
2604 if (m_activeTimeline)
2605 m_activeTimeline->projectView()->selectTransition(true, true);
2608 void MainWindow::slotGroupClips()
2610 if (m_activeTimeline)
2611 m_activeTimeline->projectView()->groupClips();
2614 void MainWindow::slotUnGroupClips()
2616 if (m_activeTimeline)
2617 m_activeTimeline->projectView()->groupClips(false);
2620 void MainWindow::slotEditItemDuration()
2622 if (m_activeTimeline)
2623 m_activeTimeline->projectView()->editItemDuration();
2626 void MainWindow::slotAddProjectClip(KUrl url)
2628 if (m_activeDocument)
2629 m_activeDocument->slotAddClipFile(url, QString());
2632 void MainWindow::slotAddTransition(QAction *result)
2634 if (!result) return;
2635 QStringList info = result->data().toStringList();
2636 if (info.isEmpty()) return;
2637 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2638 if (m_activeTimeline && !transition.isNull()) {
2639 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2643 void MainWindow::slotAddVideoEffect(QAction *result)
2645 if (!result) return;
2646 QStringList info = result->data().toStringList();
2647 if (info.isEmpty()) return;
2648 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2649 slotAddEffect(effect);
2652 void MainWindow::slotAddAudioEffect(QAction *result)
2654 if (!result) return;
2655 QStringList info = result->data().toStringList();
2656 if (info.isEmpty()) return;
2657 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2658 slotAddEffect(effect);
2661 void MainWindow::slotAddCustomEffect(QAction *result)
2663 if (!result) return;
2664 QStringList info = result->data().toStringList();
2665 if (info.isEmpty()) return;
2666 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2667 slotAddEffect(effect);
2670 void MainWindow::slotZoomIn()
2672 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2673 slotShowZoomSliderToolTip();
2676 void MainWindow::slotZoomOut()
2678 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2679 slotShowZoomSliderToolTip();
2682 void MainWindow::slotFitZoom()
2684 if (m_activeTimeline)
2685 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2688 void MainWindow::slotSetZoom(int value)
2690 if (m_activeTimeline)
2691 m_activeTimeline->slotChangeZoom(value);
2693 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2694 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2695 slotUpdateZoomSliderToolTip(value);
2697 m_zoomSlider->blockSignals(true);
2698 m_zoomSlider->setValue(value);
2699 m_zoomSlider->blockSignals(false);
2702 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2704 if (zoomlevel != -1)
2705 slotUpdateZoomSliderToolTip(zoomlevel);
2707 QPoint global = m_zoomSlider->rect().topLeft();
2708 global.ry() += m_zoomSlider->height() / 2;
2709 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2710 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2713 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2715 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2718 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2720 m_statusProgressBar->setValue(progress);
2721 if (progress >= 0) {
2722 if (!message.isEmpty())
2723 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2724 m_statusProgressBar->setVisible(true);
2725 } else if (progress == -2) {
2726 if (!message.isEmpty())
2727 m_messageLabel->setMessage(message, ErrorMessage);
2728 m_statusProgressBar->setVisible(false);
2730 m_messageLabel->setMessage(QString(), DefaultMessage);
2731 m_statusProgressBar->setVisible(false);
2735 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2737 if (clip->clipType() == TEXT) {
2738 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2739 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2740 // template text clip
2742 // Get the list of existing templates
2744 filter << "*.kdenlivetitle";
2745 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2747 QDialog *dia = new QDialog(this);
2748 Ui::TemplateClip_UI dia_ui;
2749 dia_ui.setupUi(dia);
2751 const QString templatePath = clip->getProperty("resource");
2752 for (int i = 0; i < templateFiles.size(); ++i) {
2753 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2754 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2756 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2757 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2758 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2759 //warning: setting base directory doesn't work??
2760 KUrl startDir(titlepath);
2761 dia_ui.template_list->fileDialog()->setUrl(startDir);
2762 dia_ui.description->setText(clip->getProperty("description"));
2763 if (dia->exec() == QDialog::Accepted) {
2764 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2765 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2767 QMap <QString, QString> newprops;
2769 if (KUrl(textTemplate).path() != templatePath) {
2770 // The template was changed
2771 newprops.insert("resource", textTemplate);
2774 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2775 newprops.insert("description", dia_ui.description->toPlainText());
2778 QString newtemplate = newprops.value("xmltemplate");
2779 if (newtemplate.isEmpty()) newtemplate = templatePath;
2781 // template modified we need to update xmldata
2782 QString description = newprops.value("description");
2783 if (description.isEmpty()) description = clip->getProperty("description");
2784 else newprops.insert("templatetext", description);
2785 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2786 if (!newprops.isEmpty()) {
2787 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2788 m_activeDocument->commandStack()->push(command);
2794 QString path = clip->getProperty("resource");
2795 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2797 doc.setContent(clip->getProperty("xmldata"));
2798 dia_ui->setXml(doc);
2799 if (dia_ui->exec() == QDialog::Accepted) {
2800 QMap <QString, QString> newprops;
2801 newprops.insert("xmldata", dia_ui->xml().toString());
2802 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2803 // duration changed, we need to update duration
2804 newprops.insert("out", QString::number(dia_ui->outPoint()));
2806 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2807 m_activeDocument->commandStack()->push(command);
2808 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2809 m_activeDocument->setModified(true);
2813 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2816 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2817 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2818 if (dia.exec() == QDialog::Accepted) {
2819 QMap <QString, QString> newprops = dia.properties();
2820 if (newprops.isEmpty()) return;
2821 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2822 m_activeDocument->commandStack()->push(command);
2824 if (dia.needsTimelineRefresh()) {
2825 // update clip occurences in timeline
2826 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2832 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2834 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2835 if (dia.exec() == QDialog::Accepted) {
2836 QUndoCommand *command = new QUndoCommand();
2837 command->setText(i18n("Edit clips"));
2838 for (int i = 0; i < cliplist.count(); i++) {
2839 DocClipBase *clip = cliplist.at(i);
2840 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2842 m_activeDocument->commandStack()->push(command);
2843 for (int i = 0; i < cliplist.count(); i++)
2844 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2848 void MainWindow::customEvent(QEvent* e)
2850 if (e->type() == QEvent::User)
2851 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2853 void MainWindow::slotActivateEffectStackView()
2855 m_effectStack->raiseWindow(m_effectStackDock);
2858 void MainWindow::slotActivateTransitionView(Transition *t)
2861 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2864 void MainWindow::slotSnapRewind()
2866 if (m_projectMonitor->isActive()) {
2867 if (m_activeTimeline)
2868 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2870 m_clipMonitor->slotSeekToPreviousSnap();
2874 void MainWindow::slotSnapForward()
2876 if (m_projectMonitor->isActive()) {
2877 if (m_activeTimeline)
2878 m_activeTimeline->projectView()->slotSeekToNextSnap();
2880 m_clipMonitor->slotSeekToNextSnap();
2884 void MainWindow::slotClipStart()
2886 if (m_projectMonitor->isActive()) {
2887 if (m_activeTimeline)
2888 m_activeTimeline->projectView()->clipStart();
2892 void MainWindow::slotClipEnd()
2894 if (m_projectMonitor->isActive()) {
2895 if (m_activeTimeline)
2896 m_activeTimeline->projectView()->clipEnd();
2900 void MainWindow::slotZoneStart()
2902 if (m_projectMonitor->isActive())
2903 m_projectMonitor->slotZoneStart();
2905 m_clipMonitor->slotZoneStart();
2908 void MainWindow::slotZoneEnd()
2910 if (m_projectMonitor->isActive())
2911 m_projectMonitor->slotZoneEnd();
2913 m_clipMonitor->slotZoneEnd();
2916 void MainWindow::slotChangeTool(QAction * action)
2918 if (action == m_buttonSelectTool)
2919 slotSetTool(SELECTTOOL);
2920 else if (action == m_buttonRazorTool)
2921 slotSetTool(RAZORTOOL);
2922 else if (action == m_buttonSpacerTool)
2923 slotSetTool(SPACERTOOL);
2926 void MainWindow::slotChangeEdit(QAction * action)
2928 if (!m_activeTimeline)
2931 if (action == m_overwriteEditTool)
2932 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2933 else if (action == m_insertEditTool)
2934 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2936 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2939 void MainWindow::slotSetTool(PROJECTTOOL tool)
2941 if (m_activeDocument && m_activeTimeline) {
2942 //m_activeDocument->setTool(tool);
2946 message = i18n("Ctrl + click to use spacer on current track only");
2949 message = i18n("Click on a clip to cut it");
2952 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2955 m_messageLabel->setMessage(message, InformationMessage);
2956 m_activeTimeline->projectView()->setTool(tool);
2960 void MainWindow::slotCopy()
2962 if (m_activeDocument && m_activeTimeline)
2963 m_activeTimeline->projectView()->copyClip();
2966 void MainWindow::slotPaste()
2968 if (m_activeDocument && m_activeTimeline)
2969 m_activeTimeline->projectView()->pasteClip();
2972 void MainWindow::slotPasteEffects()
2974 if (m_activeDocument && m_activeTimeline)
2975 m_activeTimeline->projectView()->pasteClipEffects();
2978 void MainWindow::slotFind()
2980 if (!m_activeDocument || !m_activeTimeline) return;
2981 m_projectSearch->setEnabled(false);
2982 m_findActivated = true;
2983 m_findString.clear();
2984 m_activeTimeline->projectView()->initSearchStrings();
2985 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2986 m_findTimer.start(5000);
2987 qApp->installEventFilter(this);
2990 void MainWindow::slotFindNext()
2992 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
2993 statusBar()->showMessage(i18n("Found: %1", m_findString));
2995 statusBar()->showMessage(i18n("Reached end of project"));
2996 m_findTimer.start(4000);
2999 void MainWindow::findAhead()
3001 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3002 m_projectSearchNext->setEnabled(true);
3003 statusBar()->showMessage(i18n("Found: %1", m_findString));
3005 m_projectSearchNext->setEnabled(false);
3006 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3010 void MainWindow::findTimeout()
3012 m_projectSearchNext->setEnabled(false);
3013 m_findActivated = false;
3014 m_findString.clear();
3015 statusBar()->showMessage(i18n("Find stopped"), 3000);
3016 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3017 m_projectSearch->setEnabled(true);
3018 removeEventFilter(this);
3021 void MainWindow::slotClipInTimeline(const QString &clipId)
3023 if (m_activeTimeline && m_activeDocument) {
3024 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3026 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3027 inTimelineMenu->clear();
3029 QList <QAction *> actionList;
3031 for (int i = 0; i < matching.count(); ++i) {
3032 QString track = QString::number(matching.at(i).track);
3033 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3035 QAction *a = new QAction(track + ": " + start, this);
3036 a->setData(QStringList() << track << start);
3037 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3038 while (j < actionList.count()) {
3039 if (actionList.at(j)->text() > a->text()) break;
3042 actionList.insert(j, a);
3044 inTimelineMenu->addActions(actionList);
3046 if (matching.empty())
3047 inTimelineMenu->setEnabled(false);
3049 inTimelineMenu->setEnabled(true);
3053 void MainWindow::slotClipInProjectTree()
3055 if (m_activeTimeline) {
3056 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3057 if (clipIds.isEmpty())
3059 m_projectListDock->raise();
3060 for (int i = 0; i < clipIds.count(); i++)
3061 m_projectList->selectItemById(clipIds.at(i));
3062 if (m_projectMonitor->isActive())
3063 slotSwitchMonitors();
3067 /*void MainWindow::slotClipToProjectTree()
3069 if (m_activeTimeline) {
3070 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3071 if (clips.isEmpty()) return;
3072 for (int i = 0; i < clips.count(); i++) {
3073 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3075 //m_projectList->selectItemById(clipIds.at(i));
3079 void MainWindow::slotSelectClipInTimeline()
3081 if (m_activeTimeline) {
3082 QAction *action = qobject_cast<QAction *>(sender());
3083 QStringList data = action->data().toStringList();
3084 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3088 void MainWindow::keyPressEvent(QKeyEvent *ke)
3090 if (m_findActivated) {
3091 if (ke->key() == Qt::Key_Backspace) {
3092 m_findString = m_findString.left(m_findString.length() - 1);
3094 if (!m_findString.isEmpty())
3099 m_findTimer.start(4000);
3102 } else if (ke->key() == Qt::Key_Escape) {
3106 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3107 m_findString += ke->text();
3111 m_findTimer.start(4000);
3116 KXmlGuiWindow::keyPressEvent(ke);
3121 /** Gets called when the window gets hidden */
3122 void MainWindow::hideEvent(QHideEvent */*event*/)
3125 if (m_monitorManager)
3126 m_monitorManager->stopActiveMonitor();
3129 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3131 if (m_findActivated) {
3132 if (event->type() == QEvent::ShortcutOverride) {
3133 QKeyEvent* ke = (QKeyEvent*) event;
3134 if (ke->text().trimmed().isEmpty()) return false;
3141 // pass the event on to the parent class
3142 return QMainWindow::eventFilter(obj, event);
3147 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3149 KDialog *dialog = new KDialog(this);
3150 dialog->setCaption("Save clip zone");
3151 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3153 QWidget *widget = new QWidget(dialog);
3154 dialog->setMainWidget(widget);
3156 QVBoxLayout *vbox = new QVBoxLayout(widget);
3157 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3158 QString path = m_activeDocument->projectFolder().path();
3160 path.append("untitled.mlt");
3161 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3162 url->setFilter("video/mlt-playlist");
3163 QLabel *label2 = new QLabel(i18n("Description:"), this);
3164 KLineEdit *edit = new KLineEdit(this);
3165 vbox->addWidget(label1);
3166 vbox->addWidget(url);
3167 vbox->addWidget(label2);
3168 vbox->addWidget(edit);
3169 if (dialog->exec() == QDialog::Accepted)
3170 render->saveZone(url->url(), edit->text(), zone);
3174 void MainWindow::slotSetInPoint()
3176 if (m_clipMonitor->isActive())
3177 m_clipMonitor->slotSetZoneStart();
3179 m_projectMonitor->slotSetZoneStart();
3180 //else m_activeTimeline->projectView()->setInPoint();
3183 void MainWindow::slotSetOutPoint()
3185 if (m_clipMonitor->isActive())
3186 m_clipMonitor->slotSetZoneEnd();
3188 m_projectMonitor->slotSetZoneEnd();
3189 // else m_activeTimeline->projectView()->setOutPoint();
3192 void MainWindow::slotResizeItemStart()
3194 if (m_activeTimeline)
3195 m_activeTimeline->projectView()->setInPoint();
3198 void MainWindow::slotResizeItemEnd()
3200 if (m_activeTimeline)
3201 m_activeTimeline->projectView()->setOutPoint();
3204 int MainWindow::getNewStuff(const QString &configFile)
3206 KNS3::Entry::List entries;
3207 #if KDE_IS_VERSION(4,3,80)
3208 KNS3::DownloadDialog dialog(configFile);
3210 entries = dialog.changedEntries();
3211 foreach(const KNS3::Entry &entry, entries) {
3212 if (entry.status() == KNS3::Entry::Installed)
3213 kDebug() << "// Installed files: " << entry.installedFiles();
3216 KNS::Engine engine(0);
3217 if (engine.init(configFile))
3218 entries = engine.downloadDialogModal(this);
3219 foreach(KNS::Entry *entry, entries) {
3220 if (entry->status() == KNS::Entry::Installed)
3221 kDebug() << "// Installed files: " << entry->installedFiles();
3223 #endif /* KDE_IS_VERSION(4,3,80) */
3224 return entries.size();
3227 void MainWindow::slotGetNewTitleStuff()
3229 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3230 TitleWidget::refreshTitleTemplates();
3233 void MainWindow::slotGetNewLumaStuff()
3235 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3236 initEffects::refreshLumas();
3237 m_activeTimeline->projectView()->reloadTransitionLumas();
3241 void MainWindow::slotGetNewRenderStuff()
3243 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3245 m_renderWidget->reloadProfiles();
3248 void MainWindow::slotGetNewMltProfileStuff()
3250 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3251 // update the list of profiles in settings dialog
3252 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3258 void MainWindow::slotAutoTransition()
3260 if (m_activeTimeline)
3261 m_activeTimeline->projectView()->autoTransition();
3264 void MainWindow::slotSplitAudio()
3266 if (m_activeTimeline)
3267 m_activeTimeline->projectView()->splitAudio();
3270 void MainWindow::slotUpdateClipType(QAction *action)
3272 if (m_activeTimeline) {
3273 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3274 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3275 else m_activeTimeline->projectView()->setAudioAndVideo();
3279 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3281 // We must stop the monitors since we create a new on in the dvd wizard
3282 m_clipMonitor->stop();
3283 m_projectMonitor->stop();
3284 DvdWizard w(url, profile, this);
3286 m_projectMonitor->start();
3289 void MainWindow::slotShowTimeline(bool show)
3291 if (show == false) {
3292 m_timelineState = saveState();
3293 centralWidget()->setHidden(true);
3295 centralWidget()->setHidden(false);
3296 restoreState(m_timelineState);
3300 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3302 //TODO: is there a way to maximize current widget?
3305 m_timelineState = saveState();
3306 QWidget *par = focusWidget()->parentWidget();
3307 while (par->parentWidget() && par->parentWidget() != this)
3308 par = par->parentWidget();
3309 kDebug() << "CURRENT WIDGET: " << par->objectName();
3312 //centralWidget()->setHidden(false);
3313 //restoreState(m_timelineState);
3317 void MainWindow::loadTranscoders()
3319 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3322 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3323 KConfigGroup transConfig(config, "Transcoding");
3325 QMap< QString, QString > profiles = transConfig.entryMap();
3326 QMapIterator<QString, QString> i(profiles);
3327 while (i.hasNext()) {
3329 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3330 QAction *a = transMenu->addAction(i.key());
3332 if (data.count() > 1)
3333 a->setToolTip(data.at(1));
3334 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3338 void MainWindow::slotTranscode(KUrl::List urls)
3343 if (urls.isEmpty()) {
3344 QAction *action = qobject_cast<QAction *>(sender());
3345 QStringList data = action->data().toStringList();
3346 params = data.at(0);
3347 if (data.count() > 1) desc = data.at(1);
3348 if (data.count() > 2) condition = data.at(2);
3349 urls << m_projectList->getConditionalUrls(condition);
3350 urls.removeAll(KUrl());
3352 if (urls.isEmpty()) {
3353 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3356 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3357 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3359 //QProcess::startDetached("ffmpeg", parameters);
3362 void MainWindow::slotTranscodeClip()
3364 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3365 if (urls.isEmpty()) return;
3366 slotTranscode(urls);
3369 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3371 if (m_activeDocument == NULL) return;
3372 QMapIterator<QString, QString> i(props);
3373 while (i.hasNext()) {
3375 m_activeDocument->setDocumentProperty(i.key(), i.value());
3377 m_activeDocument->setModified(true);
3381 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3383 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3385 QString playlistPath;
3388 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3389 QString path = m_renderWidget->getFreeScriptName();
3390 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3391 if (!ok || scriptPath.isEmpty()) return;
3392 scriptPath.prepend(scriptsFolder);
3393 QFile f(scriptPath);
3395 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3398 playlistPath = scriptPath + ".mlt";
3399 m_projectMonitor->saveSceneList(playlistPath);
3401 KTemporaryFile temp;
3402 temp.setAutoRemove(false);
3403 temp.setSuffix(".mlt");
3405 playlistPath = temp.fileName();
3406 m_projectMonitor->saveSceneList(playlistPath);
3409 if (!chapterFile.isEmpty()) {
3412 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3414 in = m_activeTimeline->inPoint();
3415 out = m_activeTimeline->outPoint();
3418 QDomElement chapters = doc.createElement("chapters");
3419 chapters.setAttribute("fps", m_activeDocument->fps());
3420 doc.appendChild(chapters);
3422 QDomElement guidesxml = m_activeDocument->guidesXml();
3423 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3424 for (int i = 0; i < nodes.count(); i++) {
3425 QDomElement e = nodes.item(i).toElement();
3427 QString comment = e.attribute("comment");
3428 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3429 if (time >= in && time < out) {
3430 if (zoneOnly) time = time - in;
3431 QDomElement chapter = doc.createElement("chapter");
3432 chapters.appendChild(chapter);
3433 chapter.setAttribute("title", comment);
3434 chapter.setAttribute("time", time);
3438 if (chapters.childNodes().count() > 0) {
3439 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3440 // Always insert a guide in pos 0
3441 QDomElement chapter = doc.createElement("chapter");
3442 chapters.insertBefore(chapter, QDomNode());
3443 chapter.setAttribute("title", i18n("Start"));
3444 chapter.setAttribute("time", "0");
3446 // save chapters file
3447 QFile file(chapterFile);
3448 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3449 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3451 file.write(doc.toString().toUtf8());
3452 if (file.error() != QFile::NoError) {
3453 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3460 if (m_renderWidget->automaticAudioExport()) {
3461 exportAudio = m_activeTimeline->checkProjectAudio();
3462 } else exportAudio = m_renderWidget->selectedAudioExport();
3463 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3466 void MainWindow::slotUpdateTimecodeFormat(int ix)
3468 KdenliveSettings::setFrametimecode(ix == 1);
3469 m_clipMonitor->updateTimecodeFormat();
3470 m_projectMonitor->updateTimecodeFormat();
3471 m_transitionConfig->updateTimecodeFormat();
3472 m_effectStack->updateTimecodeFormat();
3473 //m_activeTimeline->projectView()->clearSelection();
3474 m_activeTimeline->updateRuler();
3477 void MainWindow::slotRemoveFocus()
3479 statusBar()->setFocus();
3480 statusBar()->clearFocus();
3483 void MainWindow::slotRevert()
3485 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;
3486 KUrl url = m_activeDocument->url();
3487 closeCurrentDocument(false);
3488 doOpenFile(url, NULL);
3492 void MainWindow::slotShutdown()
3494 if (m_activeDocument) m_activeDocument->setModified(false);
3496 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3497 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3498 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3499 smserver.call("logout", 1, 2, 2);
3500 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3501 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3502 smserver.call("Shutdown");
3506 void MainWindow::slotUpdateTrackInfo()
3508 if (m_activeDocument)
3509 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3512 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3514 // Load the theme file
3516 if (action == NULL) theme = themename;
3517 else theme = action->data().toString();
3518 KdenliveSettings::setColortheme(theme);
3519 // Make palette for all widgets.
3521 if (theme.isEmpty())
3522 plt = QApplication::desktop()->palette();
3524 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3525 plt = KGlobalSettings::createApplicationPalette(config);
3528 kapp->setPalette(plt);
3529 const QObjectList children = statusBar()->children();
3531 foreach(QObject *child, children) {
3532 if (child->isWidgetType())
3533 ((QWidget*)child)->setPalette(plt);
3534 const QObjectList subchildren = child->children();
3535 foreach(QObject *subchild, subchildren) {
3536 if (subchild->isWidgetType())
3537 ((QWidget*)subchild)->setPalette(plt);
3540 if (m_activeTimeline)
3541 m_activeTimeline->projectView()->updatePalette();
3545 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3547 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3548 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3549 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3550 const QSize bitsSize(24, 2);
3551 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3552 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3554 QPixmap pixmap(23, 16);
3555 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3557 KConfigGroup group(config, "WM");
3558 QPainter p(&pixmap);
3559 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3560 p.fillRect(1, 1, 7, 7, windowScheme.background());
3561 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3563 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3564 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3565 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3567 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3568 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3570 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3571 p.fillRect(1, 8, 7, 7, viewScheme.background());
3572 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3574 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3575 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3576 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3578 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3579 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3585 void MainWindow::slotSwitchMonitors()
3587 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3588 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3589 else m_projectList->focusTree();
3592 void MainWindow::slotInsertZoneToTree()
3594 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3595 QStringList info = m_clipMonitor->getZoneInfo();
3596 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3599 void MainWindow::slotInsertZoneToTimeline()
3601 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3602 QStringList info = m_clipMonitor->getZoneInfo();
3603 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3607 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3609 if (m_activeDocument && m_activeTimeline) {
3610 if (!ids.isEmpty()) {
3611 for (int i = 0; i < ids.size(); ++i) {
3612 m_activeTimeline->slotDeleteClip(ids.at(i));
3614 m_activeDocument->clipManager()->slotDeleteClips(ids);
3616 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3617 m_activeDocument->setModified(true);
3621 void MainWindow::slotShowTitleBars(bool show)
3624 m_effectStackDock->setTitleBarWidget(0);
3625 m_clipMonitorDock->setTitleBarWidget(0);
3626 m_projectMonitorDock->setTitleBarWidget(0);
3628 m_recMonitorDock->setTitleBarWidget(0);
3630 m_effectListDock->setTitleBarWidget(0);
3631 m_transitionConfigDock->setTitleBarWidget(0);
3632 m_projectListDock->setTitleBarWidget(0);
3633 m_undoViewDock->setTitleBarWidget(0);
3634 m_vectorscopeDock->setTitleBarWidget(0);
3635 m_waveformDock->setTitleBarWidget(0);
3636 m_RGBParadeDock->setTitleBarWidget(0);
3637 m_histogramDock->setTitleBarWidget(0);
3639 if (!m_effectStackDock->isFloating()) {
3640 m_effectStackDock->setTitleBarWidget(new QWidget);
3642 if (!m_clipMonitorDock->isFloating()) {
3643 m_clipMonitorDock->setTitleBarWidget(new QWidget);
3645 if (!m_projectMonitorDock->isFloating()) {
3646 m_projectMonitorDock->setTitleBarWidget(new QWidget);
3649 if (!m_recMonitorDock->isFloating()) {
3650 m_recMonitorDock->setTitleBarWidget(new QWidget);
3653 if (!m_effectListDock->isFloating()) {
3654 m_effectListDock->setTitleBarWidget(new QWidget);
3656 if (!m_transitionConfigDock->isFloating()) {
3657 m_transitionConfigDock->setTitleBarWidget(new QWidget);
3659 if (!m_projectListDock->isFloating()) {
3660 m_projectListDock->setTitleBarWidget(new QWidget);
3662 if (!m_undoViewDock->isFloating()) {
3663 m_undoViewDock->setTitleBarWidget(new QWidget);
3665 if (!m_vectorscopeDock->isFloating()) {
3666 m_vectorscopeDock->setTitleBarWidget(new QWidget);
3668 if (!m_waveformDock->isFloating()) {
3669 m_waveformDock->setTitleBarWidget(new QWidget);
3671 if (!m_RGBParadeDock->isFloating()) {
3672 m_RGBParadeDock->setTitleBarWidget(new QWidget(this));
3674 if (!m_histogramDock->isFloating()) {
3675 m_histogramDock->setTitleBarWidget(new QWidget(this));
3678 KdenliveSettings::setShowtitlebars(show);
3681 void MainWindow::slotSwitchTitles()
3683 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3686 QString MainWindow::getMimeType()
3688 QString mimetype = "application/x-kdenlive";
3689 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3690 if (!mime) mimetype = "*.kdenlive";
3694 #include "mainwindow.moc"