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 MainWindow::~MainWindow()
471 m_effectStack->slotClipItemSelected(NULL, 0);
472 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
474 if (m_projectMonitor) m_projectMonitor->stop();
475 if (m_clipMonitor) m_clipMonitor->stop();
477 if (m_activeTimeline) delete m_activeTimeline;
479 delete m_effectStack;
480 delete m_transitionConfig;
482 if (m_activeDocument) delete m_activeDocument;
484 // This sometimes causes crash on exit on OS X for some reason.
485 delete m_projectMonitor;
486 delete m_clipMonitor;
488 delete m_shortcutRemoveFocus;
489 Mlt::Factory::close();
492 void MainWindow::queryQuit()
500 bool MainWindow::queryClose()
502 if (m_renderWidget) {
503 int waitingJobs = m_renderWidget->waitingJobsCount();
504 if (waitingJobs > 0) {
505 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")))) {
506 case KMessageBox::Yes :
507 // create script with waiting jobs and start it
508 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
510 case KMessageBox::No :
511 // Don't do anything, jobs will be deleted
519 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
520 // warn the user to save if document is modified and we have clips in our project list
521 if (m_activeDocument && m_activeDocument->isModified() &&
522 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
523 !m_projectList->documentClipList().isEmpty())) {
525 if (m_activeDocument->url().fileName().isEmpty())
526 message = i18n("Save changes to document?");
528 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
529 switch (KMessageBox::warningYesNoCancel(this, message)) {
530 case KMessageBox::Yes :
531 // save document here. If saving fails, return false;
533 case KMessageBox::No :
534 // User does not want to save the changes, clear recovery files
535 m_activeDocument->m_autosave->resize(0);
544 void MainWindow::loadPlugins()
546 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
547 populateMenus(plugin);
550 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
552 filters << "libkdenlive*";
553 foreach(const QString &folder, directories) {
554 kDebug() << "Parsing plugin folder: " << folder;
555 QDir pluginsDir(folder);
556 foreach(const QString &fileName,
557 pluginsDir.entryList(filters, QDir::Files)) {
559 * Avoid loading the same plugin twice when there is more than one
562 if (!m_pluginFileNames.contains(fileName)) {
563 kDebug() << "Found plugin: " << fileName;
564 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
565 QObject *plugin = loader.instance();
567 populateMenus(plugin);
568 m_pluginFileNames += fileName;
570 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
576 void MainWindow::populateMenus(QObject *plugin)
578 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
579 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
581 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
585 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
586 QMenu *menu, const char *member,
587 QActionGroup *actionGroup)
589 kDebug() << "// ADD to MENU" << texts;
590 foreach(const QString &text, texts) {
591 QAction *action = new QAction(text, plugin);
592 action->setData(text);
593 connect(action, SIGNAL(triggered()), this, member);
594 menu->addAction(action);
597 action->setCheckable(true);
598 actionGroup->addAction(action);
603 void MainWindow::aboutPlugins()
605 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
610 void MainWindow::generateClip()
612 QAction *action = qobject_cast<QAction *>(sender());
613 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
615 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
616 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
617 if (!clipUrl.isEmpty()) {
618 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
622 void MainWindow::saveProperties(KConfigGroup &config)
624 // save properties here,used by session management
626 KMainWindow::saveProperties(config);
630 void MainWindow::readProperties(const KConfigGroup &config)
632 // read properties here,used by session management
633 KMainWindow::readProperties(config);
634 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
635 openFile(KUrl(Lastproject));
638 void MainWindow::slotReloadEffects()
640 m_customEffectsMenu->clear();
641 initEffects::parseCustomEffectsFile();
643 QStringList effectInfo;
644 QMap<QString, QStringList> effectsList;
645 for (int ix = 0; ix < customEffects.count(); ix++) {
646 effectInfo = customEffects.effectIdInfo(ix);
647 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
649 if (effectsList.isEmpty())
650 m_customEffectsMenu->setEnabled(false);
652 m_customEffectsMenu->setEnabled(true);
654 foreach(const QStringList &value, effectsList) {
655 action = new QAction(value.at(0), this);
656 action->setData(value);
657 m_customEffectsMenu->addAction(action);
659 m_effectList->reloadEffectList();
662 #ifndef NO_JOGSHUTTLE
663 void MainWindow::activateShuttleDevice()
667 if (KdenliveSettings::enableshuttle() == false) return;
668 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
669 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
670 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
671 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
672 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
673 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
674 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
677 void MainWindow::slotShuttleButton(int code)
681 slotShuttleAction(KdenliveSettings::shuttle1());
684 slotShuttleAction(KdenliveSettings::shuttle2());
687 slotShuttleAction(KdenliveSettings::shuttle3());
690 slotShuttleAction(KdenliveSettings::shuttle4());
693 slotShuttleAction(KdenliveSettings::shuttle5());
698 void MainWindow::slotShuttleAction(int code)
704 m_monitorManager->slotPlay();
707 m_monitorManager->slotPlay();
711 #endif /* NO_JOGSHUTTLE */
713 void MainWindow::configureNotifications()
715 KNotifyConfigWidget::configure(this);
718 void MainWindow::slotFullScreen()
720 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
723 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
725 if (!m_activeDocument) return;
726 if (effect.isNull()) {
727 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
730 QDomElement effectToAdd = effect.cloneNode().toElement();
731 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
734 void MainWindow::slotRaiseMonitor(bool clipMonitor)
736 if (clipMonitor) m_clipMonitorDock->raise();
737 else m_projectMonitorDock->raise();
740 void MainWindow::slotUpdateClip(const QString &id)
742 if (!m_activeDocument) return;
743 m_activeTimeline->projectView()->slotUpdateClip(id);
746 void MainWindow::slotConnectMonitors()
748 m_projectList->setRenderer(m_projectMonitor->render);
749 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
750 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
751 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
752 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
753 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
754 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
755 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)));
757 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
759 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
761 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
762 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
764 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
765 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
768 void MainWindow::slotAdjustClipMonitor()
770 m_clipMonitorDock->updateGeometry();
771 m_clipMonitorDock->adjustSize();
772 m_clipMonitor->resetSize();
775 void MainWindow::slotAdjustProjectMonitor()
777 m_projectMonitorDock->updateGeometry();
778 m_projectMonitorDock->adjustSize();
779 m_projectMonitor->resetSize();
782 void MainWindow::setupActions()
785 KActionCollection* collection = actionCollection();
786 m_timecodeFormat = new KComboBox(this);
787 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
788 m_timecodeFormat->addItem(i18n("Frames"));
789 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
790 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
792 m_statusProgressBar = new QProgressBar(this);
793 m_statusProgressBar->setMinimum(0);
794 m_statusProgressBar->setMaximum(100);
795 m_statusProgressBar->setMaximumWidth(150);
796 m_statusProgressBar->setVisible(false);
798 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
799 toolbar->setMovable(false);
800 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
801 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;}";
802 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
804 //create edit mode buttons
805 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
806 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
807 toolbar->addAction(m_normalEditTool);
808 m_normalEditTool->setCheckable(true);
809 m_normalEditTool->setChecked(true);
811 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
812 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
813 toolbar->addAction(m_overwriteEditTool);
814 m_overwriteEditTool->setCheckable(true);
815 m_overwriteEditTool->setChecked(false);
817 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
818 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
819 toolbar->addAction(m_insertEditTool);
820 m_insertEditTool->setCheckable(true);
821 m_insertEditTool->setChecked(false);
822 // not implemented yet
823 m_insertEditTool->setEnabled(false);
825 QActionGroup *editGroup = new QActionGroup(this);
826 editGroup->addAction(m_normalEditTool);
827 editGroup->addAction(m_overwriteEditTool);
828 editGroup->addAction(m_insertEditTool);
829 editGroup->setExclusive(true);
830 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
831 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
833 toolbar->addSeparator();
835 // create tools buttons
836 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
837 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
838 toolbar->addAction(m_buttonSelectTool);
839 m_buttonSelectTool->setCheckable(true);
840 m_buttonSelectTool->setChecked(true);
842 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
843 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
844 toolbar->addAction(m_buttonRazorTool);
845 m_buttonRazorTool->setCheckable(true);
846 m_buttonRazorTool->setChecked(false);
848 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
849 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
850 toolbar->addAction(m_buttonSpacerTool);
851 m_buttonSpacerTool->setCheckable(true);
852 m_buttonSpacerTool->setChecked(false);
854 QActionGroup *toolGroup = new QActionGroup(this);
855 toolGroup->addAction(m_buttonSelectTool);
856 toolGroup->addAction(m_buttonRazorTool);
857 toolGroup->addAction(m_buttonSpacerTool);
858 toolGroup->setExclusive(true);
859 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
861 QWidget * actionWidget;
862 int max = toolbar->iconSizeDefault() + 2;
863 actionWidget = toolbar->widgetForAction(m_normalEditTool);
864 actionWidget->setMaximumWidth(max);
865 actionWidget->setMaximumHeight(max - 4);
867 actionWidget = toolbar->widgetForAction(m_insertEditTool);
868 actionWidget->setMaximumWidth(max);
869 actionWidget->setMaximumHeight(max - 4);
871 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
872 actionWidget->setMaximumWidth(max);
873 actionWidget->setMaximumHeight(max - 4);
875 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
876 actionWidget->setMaximumWidth(max);
877 actionWidget->setMaximumHeight(max - 4);
879 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
880 actionWidget->setMaximumWidth(max);
881 actionWidget->setMaximumHeight(max - 4);
883 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
884 actionWidget->setMaximumWidth(max);
885 actionWidget->setMaximumHeight(max - 4);
887 toolbar->setStyleSheet(style1);
888 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
890 toolbar->addSeparator();
891 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
892 toolbar->addAction(m_buttonFitZoom);
893 m_buttonFitZoom->setCheckable(false);
895 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
896 toolbar->addAction(m_zoomOut);
897 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
899 m_zoomSlider = new QSlider(Qt::Horizontal, this);
900 m_zoomSlider->setMaximum(13);
901 m_zoomSlider->setPageStep(1);
902 m_zoomSlider->setInvertedAppearance(true);
904 m_zoomSlider->setMaximumWidth(150);
905 m_zoomSlider->setMinimumWidth(100);
906 toolbar->addWidget(m_zoomSlider);
908 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
909 toolbar->addAction(m_zoomIn);
910 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
912 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
913 actionWidget->setMaximumWidth(max);
914 actionWidget->setMaximumHeight(max - 4);
915 actionWidget->setStyleSheet(styleBorderless);
917 actionWidget = toolbar->widgetForAction(m_zoomIn);
918 actionWidget->setMaximumWidth(max);
919 actionWidget->setMaximumHeight(max - 4);
920 actionWidget->setStyleSheet(styleBorderless);
922 actionWidget = toolbar->widgetForAction(m_zoomOut);
923 actionWidget->setMaximumWidth(max);
924 actionWidget->setMaximumHeight(max - 4);
925 actionWidget->setStyleSheet(styleBorderless);
927 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
928 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
929 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
930 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
931 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
933 toolbar->addSeparator();
935 //create automatic audio split button
936 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
937 toolbar->addAction(m_buttonAutomaticSplitAudio);
938 m_buttonAutomaticSplitAudio->setCheckable(true);
939 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
940 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
942 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
943 toolbar->addAction(m_buttonVideoThumbs);
944 m_buttonVideoThumbs->setCheckable(true);
945 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
946 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
948 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
949 toolbar->addAction(m_buttonAudioThumbs);
950 m_buttonAudioThumbs->setCheckable(true);
951 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
952 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
954 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
955 toolbar->addAction(m_buttonShowMarkers);
956 m_buttonShowMarkers->setCheckable(true);
957 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
958 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
960 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
961 toolbar->addAction(m_buttonSnap);
962 m_buttonSnap->setCheckable(true);
963 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
964 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
966 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
967 actionWidget->setMaximumWidth(max);
968 actionWidget->setMaximumHeight(max - 4);
970 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
971 actionWidget->setMaximumWidth(max);
972 actionWidget->setMaximumHeight(max - 4);
974 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
975 actionWidget->setMaximumWidth(max);
976 actionWidget->setMaximumHeight(max - 4);
978 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
979 actionWidget->setMaximumWidth(max);
980 actionWidget->setMaximumHeight(max - 4);
982 actionWidget = toolbar->widgetForAction(m_buttonSnap);
983 actionWidget->setMaximumWidth(max);
984 actionWidget->setMaximumHeight(max - 4);
986 m_messageLabel = new StatusBarMessageLabel(this);
987 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
989 statusBar()->addWidget(m_messageLabel, 10);
990 statusBar()->addWidget(m_statusProgressBar, 0);
991 statusBar()->addPermanentWidget(toolbar);
992 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
993 statusBar()->addPermanentWidget(m_timecodeFormat);
994 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
996 collection->addAction("normal_mode", m_normalEditTool);
997 collection->addAction("overwrite_mode", m_overwriteEditTool);
998 collection->addAction("insert_mode", m_insertEditTool);
999 collection->addAction("select_tool", m_buttonSelectTool);
1000 collection->addAction("razor_tool", m_buttonRazorTool);
1001 collection->addAction("spacer_tool", m_buttonSpacerTool);
1003 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1004 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1005 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1006 collection->addAction("show_markers", m_buttonShowMarkers);
1007 collection->addAction("snap", m_buttonSnap);
1008 collection->addAction("zoom_fit", m_buttonFitZoom);
1009 collection->addAction("zoom_in", m_zoomIn);
1010 collection->addAction("zoom_out", m_zoomOut);
1012 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1013 collection->addAction("project_find", m_projectSearch);
1014 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1015 m_projectSearch->setShortcut(Qt::Key_Slash);
1017 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1018 collection->addAction("project_find_next", m_projectSearchNext);
1019 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1020 m_projectSearchNext->setShortcut(Qt::Key_F3);
1021 m_projectSearchNext->setEnabled(false);
1023 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1024 collection->addAction("manage_profiles", profilesAction);
1025 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1027 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1028 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1029 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1030 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1032 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1033 collection->addAction("run_wizard", wizAction);
1034 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1036 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1037 collection->addAction("project_settings", projectAction);
1038 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1040 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1041 collection->addAction("project_render", projectRender);
1042 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1043 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1045 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1046 collection->addAction("project_clean", projectClean);
1047 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1049 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1050 KShortcut playShortcut;
1051 playShortcut.setPrimary(Qt::Key_Space);
1052 playShortcut.setAlternate(Qt::Key_K);
1053 monitorPlay->setShortcut(playShortcut);
1054 collection->addAction("monitor_play", monitorPlay);
1055 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1057 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1058 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1059 collection->addAction("monitor_play_zone", m_playZone);
1060 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1062 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1063 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1064 collection->addAction("monitor_loop_zone", m_loopZone);
1065 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1067 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1068 collection->addAction("dvd_wizard", dvdWizard);
1069 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1071 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1072 collection->addAction("transcode_clip", transcodeClip);
1073 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1075 KAction *markIn = collection->addAction("mark_in");
1076 markIn->setText(i18n("Set Zone In"));
1077 markIn->setShortcut(Qt::Key_I);
1078 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1080 KAction *markOut = collection->addAction("mark_out");
1081 markOut->setText(i18n("Set Zone Out"));
1082 markOut->setShortcut(Qt::Key_O);
1083 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1085 KAction *switchMon = collection->addAction("switch_monitor");
1086 switchMon->setText(i18n("Switch monitor"));
1087 switchMon->setShortcut(Qt::Key_T);
1088 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1090 KAction *insertTree = collection->addAction("insert_project_tree");
1091 insertTree->setText(i18n("Insert zone in project tree"));
1092 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1093 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1095 KAction *insertTimeline = collection->addAction("insert_timeline");
1096 insertTimeline->setText(i18n("Insert zone in timeline"));
1097 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1098 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1100 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1101 collection->addAction("resize_timeline_clip_start", resizeStart);
1102 resizeStart->setShortcut(Qt::Key_1);
1103 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1105 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1106 collection->addAction("resize_timeline_clip_end", resizeEnd);
1107 resizeEnd->setShortcut(Qt::Key_2);
1108 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1110 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1111 monitorSeekBackward->setShortcut(Qt::Key_J);
1112 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1113 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1115 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1116 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1117 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1118 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1120 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1121 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1122 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1123 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1125 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1126 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1127 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1128 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1130 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1131 monitorSeekForward->setShortcut(Qt::Key_L);
1132 collection->addAction("monitor_seek_forward", monitorSeekForward);
1133 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1135 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1136 clipStart->setShortcut(Qt::Key_Home);
1137 collection->addAction("seek_clip_start", clipStart);
1138 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1140 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1141 clipEnd->setShortcut(Qt::Key_End);
1142 collection->addAction("seek_clip_end", clipEnd);
1143 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1145 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1146 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1147 collection->addAction("seek_zone_start", zoneStart);
1148 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1150 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1151 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1152 collection->addAction("seek_zone_end", zoneEnd);
1153 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1155 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1156 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1157 collection->addAction("seek_start", projectStart);
1158 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1160 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1161 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1162 collection->addAction("seek_end", projectEnd);
1163 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1165 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1166 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1167 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1168 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1170 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1171 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1172 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1173 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1175 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1176 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1177 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1178 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1180 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1181 deleteItem->setShortcut(Qt::Key_Delete);
1182 collection->addAction("delete_timeline_clip", deleteItem);
1183 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1185 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1186 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1187 editTimelineClipSpeed->setData("change_speed");
1188 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1190 KAction *stickTransition = collection->addAction("auto_transition");
1191 stickTransition->setData(QString("auto"));
1192 stickTransition->setCheckable(true);
1193 stickTransition->setEnabled(false);
1194 stickTransition->setText(i18n("Automatic Transition"));
1195 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1197 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1198 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1199 collection->addAction("group_clip", groupClip);
1200 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1202 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1203 collection->addAction("ungroup_clip", ungroupClip);
1204 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1205 ungroupClip->setData("ungroup_clip");
1206 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1208 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1209 collection->addAction("edit_item_duration", editItemDuration);
1210 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1212 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1213 collection->addAction("clip_in_project_tree", clipInProjectTree);
1214 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1216 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1217 collection->addAction("clip_to_project_tree", clipToProjectTree);
1218 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1220 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1221 insertOvertwrite->setShortcut(Qt::Key_V);
1222 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1223 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1225 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1226 selectTimelineClip->setShortcut(Qt::Key_Plus);
1227 collection->addAction("select_timeline_clip", selectTimelineClip);
1228 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1230 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1231 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1232 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1233 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1235 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1236 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1237 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1238 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1240 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1241 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1242 collection->addAction("select_timeline_transition", selectTimelineTransition);
1243 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1245 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1246 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1247 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1248 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1250 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1251 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1252 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1253 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1255 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1256 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1257 collection->addAction("cut_timeline_clip", cutTimelineClip);
1258 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1260 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1261 collection->addAction("add_clip_marker", addClipMarker);
1262 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1264 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1265 collection->addAction("delete_clip_marker", deleteClipMarker);
1266 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1268 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1269 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1270 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1272 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1273 collection->addAction("edit_clip_marker", editClipMarker);
1274 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1276 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1277 collection->addAction("split_audio", splitAudio);
1278 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1280 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1281 collection->addAction("clip_audio_only", audioOnly);
1282 audioOnly->setData("clip_audio_only");
1283 audioOnly->setCheckable(true);
1285 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1286 collection->addAction("clip_video_only", videoOnly);
1287 videoOnly->setData("clip_video_only");
1288 videoOnly->setCheckable(true);
1290 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1291 collection->addAction("clip_audio_and_video", audioAndVideo);
1292 audioAndVideo->setData("clip_audio_and_video");
1293 audioAndVideo->setCheckable(true);
1295 m_clipTypeGroup = new QActionGroup(this);
1296 m_clipTypeGroup->addAction(audioOnly);
1297 m_clipTypeGroup->addAction(videoOnly);
1298 m_clipTypeGroup->addAction(audioAndVideo);
1299 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1300 m_clipTypeGroup->setEnabled(false);
1302 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1303 collection->addAction("insert_space", insertSpace);
1304 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1306 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1307 collection->addAction("delete_space", removeSpace);
1308 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1310 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1311 collection->addAction("insert_track", insertTrack);
1312 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1314 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1315 collection->addAction("delete_track", deleteTrack);
1316 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1318 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1319 collection->addAction("config_tracks", configTracks);
1320 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1322 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1323 collection->addAction("add_guide", addGuide);
1324 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1326 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1327 collection->addAction("delete_guide", delGuide);
1328 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1330 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1331 collection->addAction("edit_guide", editGuide);
1332 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1334 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1335 collection->addAction("delete_all_guides", delAllGuides);
1336 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1338 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1339 collection->addAction("paste_effects", pasteEffects);
1340 pasteEffects->setData("paste_effects");
1341 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1343 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1344 collection->addAction("show_timeline", showTimeline);
1345 showTimeline->setCheckable(true);
1346 showTimeline->setChecked(true);
1347 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1349 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1350 collection->addAction("show_titlebars", showTitleBar);
1351 showTitleBar->setCheckable(true);
1352 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1353 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1354 slotShowTitleBars(KdenliveSettings::showtitlebars());
1356 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1357 collection->addAction("maximize_current", maxCurrent);
1358 maxCurrent->setCheckable(true);
1359 maxCurrent->setChecked(false);
1360 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1362 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1363 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1364 KStandardAction::open(this, SLOT(openFile()), collection);
1365 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1366 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1367 KStandardAction::openNew(this, SLOT(newFile()), collection);
1368 // TODO: make the following connection to slotEditKeys work
1369 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1370 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1371 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1372 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1373 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1374 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1376 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1377 undo->setEnabled(false);
1378 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1380 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1381 redo->setEnabled(false);
1382 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1385 //TODO: Add status tooltip to actions ?
1386 connect(collection, SIGNAL(actionHovered(QAction*)),
1387 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1390 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1391 collection->addAction("add_clip", addClip);
1392 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1394 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1395 collection->addAction("add_color_clip", addColorClip);
1396 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1398 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1399 collection->addAction("add_slide_clip", addSlideClip);
1400 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1402 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1403 collection->addAction("add_text_clip", addTitleClip);
1404 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1406 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1407 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1408 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1410 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1411 collection->addAction("add_folder", addFolderButton);
1412 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1414 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1415 collection->addAction("clip_properties", clipProperties);
1416 clipProperties->setData("clip_properties");
1417 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1418 clipProperties->setEnabled(false);
1420 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1421 collection->addAction("edit_clip", openClip);
1422 openClip->setData("edit_clip");
1423 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1424 openClip->setEnabled(false);
1426 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1427 collection->addAction("delete_clip", deleteClip);
1428 deleteClip->setData("delete_clip");
1429 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1430 deleteClip->setEnabled(false);
1432 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1433 collection->addAction("reload_clip", reloadClip);
1434 reloadClip->setData("reload_clip");
1435 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1436 reloadClip->setEnabled(false);
1438 QMenu *addClips = new QMenu();
1439 addClips->addAction(addClip);
1440 addClips->addAction(addColorClip);
1441 addClips->addAction(addSlideClip);
1442 addClips->addAction(addTitleClip);
1443 addClips->addAction(addTitleTemplateClip);
1444 addClips->addAction(addFolderButton);
1446 addClips->addAction(reloadClip);
1447 addClips->addAction(clipProperties);
1448 addClips->addAction(openClip);
1449 addClips->addAction(deleteClip);
1450 m_projectList->setupMenu(addClips, addClip);
1452 // Setup effects and transitions actions.
1453 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1454 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1455 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1456 m_videoEffects = new KAction*[videoEffects.count()];
1457 for (int i = 0; i < videoEffects.count(); ++i) {
1458 QStringList effectInfo = videoEffects.effectIdInfo(i);
1459 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1460 m_videoEffects[i]->setData(effectInfo);
1461 m_videoEffects[i]->setIconVisibleInMenu(false);
1462 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1464 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1465 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1466 m_audioEffects = new KAction*[audioEffects.count()];
1467 for (int i = 0; i < audioEffects.count(); ++i) {
1468 QStringList effectInfo = audioEffects.effectIdInfo(i);
1469 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1470 m_audioEffects[i]->setData(effectInfo);
1471 m_audioEffects[i]->setIconVisibleInMenu(false);
1472 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1474 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1475 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1476 m_customEffects = new KAction*[customEffects.count()];
1477 for (int i = 0; i < customEffects.count(); ++i) {
1478 QStringList effectInfo = customEffects.effectIdInfo(i);
1479 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1480 m_customEffects[i]->setData(effectInfo);
1481 m_customEffects[i]->setIconVisibleInMenu(false);
1482 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1484 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1485 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1486 m_transitions = new KAction*[transitions.count()];
1487 for (int i = 0; i < transitions.count(); i++) {
1488 QStringList effectInfo = transitions.effectIdInfo(i);
1489 m_transitions[i] = new KAction(effectInfo.at(0), this);
1490 m_transitions[i]->setData(effectInfo);
1491 m_transitions[i]->setIconVisibleInMenu(false);
1492 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1494 m_effectsActionCollection->readSettings();
1496 //connect(collection, SIGNAL( clearStatusText() ),
1497 //statusBar(), SLOT( clear() ) );
1500 void MainWindow::slotDisplayActionMessage(QAction *a)
1502 statusBar()->showMessage(a->data().toString(), 3000);
1505 void MainWindow::saveOptions()
1507 KdenliveSettings::self()->writeConfig();
1508 KSharedConfigPtr config = KGlobal::config();
1509 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1510 KConfigGroup treecolumns(config, "Project Tree");
1511 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1515 void MainWindow::readOptions()
1517 KSharedConfigPtr config = KGlobal::config();
1518 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1519 KConfigGroup initialGroup(config, "version");
1520 bool upgrade = false;
1521 if (initialGroup.exists()) {
1522 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1526 if (initialGroup.readEntry("version") == "0.7") {
1527 //Add new settings from 0.7.1
1528 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1529 QString path = QDir::homePath() + "/kdenlive";
1530 if (KStandardDirs::makeDir(path) == false) {
1531 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1532 } else KdenliveSettings::setDefaultprojectfolder(path);
1538 if (!initialGroup.exists() || upgrade) {
1539 // this is our first run, show Wizard
1540 Wizard *w = new Wizard(upgrade, this);
1541 if (w->exec() == QDialog::Accepted && w->isOk()) {
1542 w->adjustSettings();
1543 initialGroup.writeEntry("version", version);
1549 KConfigGroup treecolumns(config, "Project Tree");
1550 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1551 if (!state.isEmpty())
1552 m_projectList->setHeaderInfo(state);
1555 void MainWindow::slotRunWizard()
1557 Wizard *w = new Wizard(false, this);
1558 if (w->exec() == QDialog::Accepted && w->isOk()) {
1559 w->adjustSettings();
1564 void MainWindow::newFile(bool showProjectSettings, bool force)
1566 if (!m_timelineArea->isEnabled() && !force) return;
1567 m_fileRevert->setEnabled(false);
1568 QString profileName;
1570 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1571 if (!showProjectSettings) {
1572 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1573 profileName = KdenliveSettings::default_profile();
1574 projectFolder = KdenliveSettings::defaultprojectfolder();
1576 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1577 if (w->exec() != QDialog::Accepted) return;
1578 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1579 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1580 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1581 profileName = w->selectedProfile();
1582 projectFolder = w->selectedFolder();
1583 projectTracks = w->tracks();
1586 m_timelineArea->setEnabled(true);
1587 m_projectList->setEnabled(true);
1588 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1589 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1591 TrackView *trackView = new TrackView(doc, &ok, this);
1592 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1595 //m_timelineArea->setEnabled(false);
1596 //m_projectList->setEnabled(false);
1600 if (m_timelineArea->count() == 1) {
1601 connectDocumentInfo(doc);
1602 connectDocument(trackView, doc);
1603 } else m_timelineArea->setTabBarHidden(false);
1604 m_monitorManager->activateMonitor("clip");
1605 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1608 void MainWindow::activateDocument()
1610 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1611 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1612 KdenliveDoc *currentDoc = currentTab->document();
1613 connectDocumentInfo(currentDoc);
1614 connectDocument(currentTab, currentDoc);
1617 void MainWindow::closeCurrentDocument(bool saveChanges)
1619 QWidget *w = m_timelineArea->currentWidget();
1621 // closing current document
1622 int ix = m_timelineArea->currentIndex() + 1;
1623 if (ix == m_timelineArea->count()) ix = 0;
1624 m_timelineArea->setCurrentIndex(ix);
1625 TrackView *tabToClose = (TrackView *) w;
1626 KdenliveDoc *docToClose = tabToClose->document();
1627 if (docToClose && docToClose->isModified() && saveChanges) {
1629 if (m_activeDocument->url().fileName().isEmpty())
1630 message = i18n("Save changes to document?");
1632 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1633 switch (KMessageBox::warningYesNoCancel(this, message)) {
1634 case KMessageBox::Yes :
1635 // save document here. If saving fails, return false;
1636 if (saveFile() == false) return;
1638 case KMessageBox::Cancel :
1645 m_clipMonitor->slotSetXml(NULL);
1646 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1647 if (m_timelineArea->count() == 1) {
1648 m_timelineArea->setTabBarHidden(true);
1649 m_closeAction->setEnabled(false);
1651 if (docToClose == m_activeDocument) {
1652 delete m_activeDocument;
1653 m_activeDocument = NULL;
1654 m_effectStack->clear();
1655 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1659 if (w == m_activeTimeline) {
1660 delete m_activeTimeline;
1661 m_activeTimeline = NULL;
1667 bool MainWindow::saveFileAs(const QString &outputFileName)
1669 QString currentSceneList;
1670 m_monitorManager->stopActiveMonitor();
1671 if (KdenliveSettings::dropbframes()) {
1672 KdenliveSettings::setDropbframes(false);
1673 m_activeDocument->clipManager()->updatePreviewSettings();
1674 currentSceneList = m_projectMonitor->sceneList();
1675 KdenliveSettings::setDropbframes(true);
1676 m_activeDocument->clipManager()->updatePreviewSettings();
1677 } else currentSceneList = m_projectMonitor->sceneList();
1679 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1682 // Save timeline thumbnails
1683 m_activeTimeline->projectView()->saveThumbnails();
1684 m_activeDocument->setUrl(KUrl(outputFileName));
1685 if (m_activeDocument->m_autosave == NULL) {
1686 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1687 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1688 setCaption(m_activeDocument->description());
1689 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1690 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1691 m_activeDocument->setModified(false);
1692 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1693 m_fileRevert->setEnabled(true);
1697 bool MainWindow::saveFileAs()
1699 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1700 if (outputFile.isEmpty()) {
1703 if (QFile::exists(outputFile)) {
1704 // Show the file dialog again if the user does not want to overwrite the file
1705 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1706 return saveFileAs();
1708 return saveFileAs(outputFile);
1711 bool MainWindow::saveFile()
1713 if (!m_activeDocument) return true;
1714 if (m_activeDocument->url().isEmpty()) {
1715 return saveFileAs();
1717 bool result = saveFileAs(m_activeDocument->url().path());
1718 m_activeDocument->m_autosave->resize(0);
1723 void MainWindow::openFile()
1725 if (!m_startUrl.isEmpty()) {
1726 openFile(m_startUrl);
1727 m_startUrl = KUrl();
1730 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1731 if (url.isEmpty()) return;
1732 m_fileOpenRecent->addUrl(url);
1736 void MainWindow::openLastFile()
1738 KSharedConfigPtr config = KGlobal::config();
1739 KUrl::List urls = m_fileOpenRecent->urls();
1740 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1741 if (urls.isEmpty()) newFile(false);
1742 else openFile(urls.last());
1745 void MainWindow::openFile(const KUrl &url)
1747 // Check if the document is already opened
1748 const int ct = m_timelineArea->count();
1749 bool isOpened = false;
1751 for (i = 0; i < ct; i++) {
1752 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1753 KdenliveDoc *doc = tab->document();
1754 if (doc->url() == url) {
1760 m_timelineArea->setCurrentIndex(i);
1764 // Check for backup file
1765 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1766 if (!staleFiles.isEmpty()) {
1767 if (KMessageBox::questionYesNo(this,
1768 i18n("Auto-saved files exist. Do you want to recover them now?"),
1769 i18n("File Recovery"),
1770 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1771 recoverFiles(staleFiles);
1774 // remove the stale files
1775 foreach(KAutoSaveFile *stale, staleFiles) {
1776 stale->open(QIODevice::ReadWrite);
1781 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1782 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1783 m_messageLabel->repaint();
1784 doOpenFile(url, NULL);
1787 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1789 if (!m_timelineArea->isEnabled()) return;
1790 m_fileRevert->setEnabled(true);
1791 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1792 if (stale == NULL) {
1793 stale = new KAutoSaveFile(url, doc);
1794 doc->m_autosave = stale;
1796 doc->m_autosave = stale;
1797 doc->setUrl(stale->managedFile());
1798 doc->setModified(true);
1799 stale->setParent(doc);
1801 connectDocumentInfo(doc);
1803 TrackView *trackView = new TrackView(doc, &ok, this);
1804 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1806 m_timelineArea->setEnabled(false);
1807 m_projectList->setEnabled(false);
1808 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1809 slotGotProgressInfo(QString(), -1);
1810 newFile(false, true);
1813 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1814 trackView->setDuration(trackView->duration());
1815 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1817 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1818 slotGotProgressInfo(QString(), -1);
1819 m_projectMonitor->adjustRulerSize(trackView->duration());
1820 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1821 m_clipMonitor->refreshMonitor(true);
1824 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1826 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1827 foreach(KAutoSaveFile *stale, staleFiles) {
1828 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1829 // show an error message; we could not steal the lockfile
1830 // maybe another application got to the file before us?
1834 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1835 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1836 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1837 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1841 void MainWindow::parseProfiles(const QString &mltPath)
1843 //KdenliveSettings::setDefaulttmpfolder();
1844 if (!mltPath.isEmpty()) {
1845 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1846 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1849 if (KdenliveSettings::mltpath().isEmpty())
1850 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1852 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1853 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1854 if (!QFile::exists(meltPath))
1855 meltPath = KStandardDirs::findExe("melt");
1856 KdenliveSettings::setRendererpath(meltPath);
1859 if (KdenliveSettings::rendererpath().isEmpty()) {
1860 // Cannot find the MLT melt renderer, ask for location
1861 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1862 if (getUrl->exec() == QDialog::Rejected) {
1865 KUrl rendererPath = getUrl->selectedUrl();
1867 if (rendererPath.isEmpty()) ::exit(0);
1868 KdenliveSettings::setRendererpath(rendererPath.path());
1871 QStringList profilesFilter;
1872 profilesFilter << "*";
1873 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1874 if (profilesList.isEmpty()) {
1875 // Cannot find MLT path, try finding melt
1876 QString profilePath = KdenliveSettings::rendererpath();
1877 if (!profilePath.isEmpty()) {
1878 profilePath = profilePath.section('/', 0, -3);
1879 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1880 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1882 if (profilesList.isEmpty()) {
1883 // Cannot find the MLT profiles, ask for location
1884 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1885 getUrl->fileDialog()->setMode(KFile::Directory);
1886 if (getUrl->exec() == QDialog::Rejected) {
1889 KUrl mltPath = getUrl->selectedUrl();
1891 if (mltPath.isEmpty()) ::exit(0);
1892 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1893 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1897 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1899 // Parse again MLT profiles to build a list of available video formats
1900 if (profilesList.isEmpty()) parseProfiles();
1904 void MainWindow::slotEditProfiles()
1906 ProfilesDialog *w = new ProfilesDialog;
1907 if (w->exec() == QDialog::Accepted) {
1908 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1909 if (d) d->checkProfile();
1914 void MainWindow::slotDetectAudioDriver()
1916 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1917 leading to no audio output, see bug #934 */
1919 //decide which audio driver is really best, in some cases SDL is wrong
1920 if (KdenliveSettings::audiodrivername().isEmpty()) {
1922 KProcess readProcess;
1923 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1924 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1925 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1926 readProcess.setProgram("pactl", QStringList() << "stat");
1927 readProcess.execute(2000); // Kill it after 2 seconds
1929 QString result = QString(readProcess.readAllStandardOutput());
1930 kDebug() << "// / / / / / READING PACTL: ";
1932 if (!result.isEmpty()) {
1934 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1938 KdenliveSettings::setAutoaudiodrivername(driver);
1942 void MainWindow::slotEditProjectSettings()
1944 QPoint p = m_activeDocument->getTracksCount();
1945 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1947 if (w->exec() == QDialog::Accepted) {
1948 QString profile = w->selectedProfile();
1949 m_activeDocument->setProjectFolder(w->selectedFolder());
1950 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1951 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1952 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1953 if (m_activeDocument->profilePath() != profile) {
1954 // Profile was changed
1955 double dar = m_activeDocument->dar();
1957 // Deselect current effect / transition
1958 m_effectStack->slotClipItemSelected(NULL, 0);
1959 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1960 m_clipMonitor->slotSetXml(NULL);
1961 bool updateFps = m_activeDocument->setProfilePath(profile);
1962 KdenliveSettings::setCurrent_profile(profile);
1963 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1964 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1966 m_activeDocument->clipManager()->clearUnusedProducers();
1967 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1969 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1970 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1971 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1972 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1973 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1974 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1975 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1976 if (updateFps) m_activeTimeline->updateProjectFps();
1977 m_activeDocument->setModified(true);
1978 m_commandStack->activeStack()->clear();
1979 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1980 slotUpdateMousePosition(0);
1981 // We need to desactivate & reactivate monitors to get a refresh
1982 //m_monitorManager->switchMonitors();
1989 void MainWindow::slotRenderProject()
1991 if (!m_renderWidget) {
1992 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1993 m_renderWidget = new RenderWidget(projectfolder, this);
1994 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1995 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
1996 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1997 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1998 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1999 if (m_activeDocument) {
2000 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2001 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2002 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2003 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2006 slotCheckRenderStatus();
2007 m_renderWidget->show();
2008 m_renderWidget->showNormal();
2010 // What are the following lines supposed to do?
2011 //m_activeTimeline->tracksNumber();
2012 //m_renderWidget->enableAudio(false);
2013 //m_renderWidget->export_audio;
2016 void MainWindow::slotCheckRenderStatus()
2018 // Make sure there are no missing clips
2020 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2023 void MainWindow::setRenderingProgress(const QString &url, int progress)
2026 m_renderWidget->setRenderJob(url, progress);
2029 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2032 m_renderWidget->setRenderStatus(url, status, error);
2035 void MainWindow::slotCleanProject()
2037 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2038 m_projectList->cleanup();
2041 void MainWindow::slotUpdateMousePosition(int pos)
2043 if (m_activeDocument)
2044 switch (m_timecodeFormat->currentIndex()) {
2046 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2049 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2053 void MainWindow::slotUpdateDocumentState(bool modified)
2055 if (!m_activeDocument) return;
2056 setCaption(m_activeDocument->description(), modified);
2057 m_saveAction->setEnabled(modified);
2059 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2060 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2062 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2063 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2067 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2069 if (m_activeDocument) {
2070 if (m_activeDocument == doc) return;
2071 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2073 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2076 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2078 //m_projectMonitor->stop();
2079 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2080 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2081 if (m_activeDocument) {
2082 if (m_activeDocument == doc) return;
2083 if (m_activeTimeline) {
2084 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2085 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2086 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2087 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2088 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2089 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2090 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2092 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2093 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2094 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2095 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2096 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2097 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2098 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2099 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2100 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2101 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2102 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2103 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2104 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2105 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2106 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2107 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2108 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2109 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2110 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2111 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2112 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2113 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2114 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2115 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2116 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2117 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2118 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2119 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2120 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2121 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2122 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2123 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2124 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2125 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2126 m_effectStack->clear();
2128 //m_activeDocument->setRenderer(NULL);
2129 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2130 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2131 m_clipMonitor->stop();
2133 KdenliveSettings::setCurrent_profile(doc->profilePath());
2134 KdenliveSettings::setProject_fps(doc->fps());
2135 m_monitorManager->resetProfiles(doc->timecode());
2136 m_projectList->setDocument(doc);
2137 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2138 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2139 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2140 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2141 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2143 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2144 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2146 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2149 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2150 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2151 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2152 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2153 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2154 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2155 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2156 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2157 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2158 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2159 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2160 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2161 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2162 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2164 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2165 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2166 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2167 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2168 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2170 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2171 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2172 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2175 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2176 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2177 connect(trackView, SIGNAL(showTrackEffects(int, EffectsList)), m_effectStack, SLOT(slotTrackItemSelected(int, EffectsList)));
2178 connect(trackView, SIGNAL(showTrackEffects(int, EffectsList)), this, SLOT(slotActivateEffectStackView()));
2180 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2181 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2182 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2183 m_zoomSlider->setValue(doc->zoom().x());
2184 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2185 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2186 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2187 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2189 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2190 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2193 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2194 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2195 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2196 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2197 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2198 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2199 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2200 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2201 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2202 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2203 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2205 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2206 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2207 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2208 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2209 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2212 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2213 m_activeTimeline = trackView;
2214 if (m_renderWidget) {
2215 slotCheckRenderStatus();
2216 m_renderWidget->setProfile(doc->mltProfile());
2217 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2218 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2219 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2221 //doc->setRenderer(m_projectMonitor->render);
2222 m_commandStack->setActiveStack(doc->commandStack());
2223 KdenliveSettings::setProject_display_ratio(doc->dar());
2224 //doc->clipManager()->checkAudioThumbs();
2226 //m_overView->setScene(trackView->projectScene());
2227 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2228 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2230 setCaption(doc->description(), doc->isModified());
2231 m_saveAction->setEnabled(doc->isModified());
2232 m_normalEditTool->setChecked(true);
2233 m_activeDocument = doc;
2234 m_activeTimeline->updateProjectFps();
2235 m_activeDocument->checkProjectClips();
2236 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2237 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2238 slotUpdateMousePosition(0);
2239 // set tool to select tool
2240 m_buttonSelectTool->setChecked(true);
2243 void MainWindow::slotZoneMoved(int start, int end)
2245 m_activeDocument->setZone(start, end);
2246 m_projectMonitor->slotZoneMoved(start, end);
2249 void MainWindow::slotGuidesUpdated()
2252 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2255 void MainWindow::slotEditKeys()
2257 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2258 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2259 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2263 void MainWindow::slotPreferences(int page, int option)
2265 //An instance of your dialog could be already created and could be
2266 // cached, in which case you want to display the cached dialog
2267 // instead of creating another one
2268 if (KConfigDialog::showDialog("settings")) {
2269 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2270 if (page != -1) d->showPage(page, option);
2274 // KConfigDialog didn't find an instance of this dialog, so lets
2276 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2277 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2278 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2279 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2280 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2282 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2284 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2286 if (page != -1) dialog->showPage(page, option);
2289 void MainWindow::slotUpdatePreviewSettings()
2291 if (m_activeDocument) {
2292 m_clipMonitor->slotSetXml(NULL);
2293 m_activeDocument->updatePreviewSettings();
2297 void MainWindow::updateConfiguration()
2299 //TODO: we should apply settings to all projects, not only the current one
2300 if (m_activeTimeline) {
2301 m_activeTimeline->refresh();
2302 m_activeTimeline->projectView()->checkAutoScroll();
2303 m_activeTimeline->projectView()->checkTrackHeight();
2304 if (m_activeDocument)
2305 m_activeDocument->clipManager()->checkAudioThumbs();
2307 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2308 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2309 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2310 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2312 // Update list of transcoding profiles
2314 #ifndef NO_JOGSHUTTLE
2315 activateShuttleDevice();
2316 #endif /* NO_JOGSHUTTLE */
2320 void MainWindow::slotSwitchSplitAudio()
2322 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2323 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2326 void MainWindow::slotSwitchVideoThumbs()
2328 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2329 if (m_activeTimeline)
2330 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2331 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2334 void MainWindow::slotSwitchAudioThumbs()
2336 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2337 if (m_activeTimeline) {
2338 m_activeTimeline->refresh();
2339 m_activeTimeline->projectView()->checkAutoScroll();
2340 if (m_activeDocument)
2341 m_activeDocument->clipManager()->checkAudioThumbs();
2343 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2346 void MainWindow::slotSwitchMarkersComments()
2348 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2349 if (m_activeTimeline)
2350 m_activeTimeline->refresh();
2351 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2354 void MainWindow::slotSwitchSnap()
2356 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2357 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2361 void MainWindow::slotDeleteItem()
2363 if (QApplication::focusWidget() &&
2364 QApplication::focusWidget()->parentWidget() &&
2365 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2366 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2367 m_projectList->slotRemoveClip();
2370 QWidget *widget = QApplication::focusWidget();
2372 if (widget == m_effectStackDock) {
2373 m_effectStack->slotItemDel();
2376 widget = widget->parentWidget();
2379 // effect stack has no focus
2380 if (m_activeTimeline)
2381 m_activeTimeline->projectView()->deleteSelectedClips();
2385 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2387 if (m_clipMonitor->isActive())
2388 m_clipMonitor->checkOverlay();
2389 m_clipMonitor->updateMarkers(clip);
2392 void MainWindow::slotAddClipMarker()
2394 DocClipBase *clip = NULL;
2396 if (m_projectMonitor->isActive()) {
2397 if (m_activeTimeline) {
2398 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2400 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2401 clip = item->baseClip();
2405 clip = m_clipMonitor->activeClip();
2406 pos = m_clipMonitor->position();
2409 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2412 QString id = clip->getId();
2413 CommentedTime marker(pos, i18n("Marker"));
2414 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2415 if (d.exec() == QDialog::Accepted)
2416 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2419 void MainWindow::slotDeleteClipMarker()
2421 DocClipBase *clip = NULL;
2423 if (m_projectMonitor->isActive()) {
2424 if (m_activeTimeline) {
2425 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2427 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2428 clip = item->baseClip();
2432 clip = m_clipMonitor->activeClip();
2433 pos = m_clipMonitor->position();
2436 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2440 QString id = clip->getId();
2441 QString comment = clip->markerComment(pos);
2442 if (comment.isEmpty()) {
2443 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2446 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2449 void MainWindow::slotDeleteAllClipMarkers()
2451 DocClipBase *clip = NULL;
2452 if (m_projectMonitor->isActive()) {
2453 if (m_activeTimeline) {
2454 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2456 clip = item->baseClip();
2460 clip = m_clipMonitor->activeClip();
2463 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2466 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2469 void MainWindow::slotEditClipMarker()
2471 DocClipBase *clip = NULL;
2473 if (m_projectMonitor->isActive()) {
2474 if (m_activeTimeline) {
2475 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2477 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2478 clip = item->baseClip();
2482 clip = m_clipMonitor->activeClip();
2483 pos = m_clipMonitor->position();
2486 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2490 QString id = clip->getId();
2491 QString oldcomment = clip->markerComment(pos);
2492 if (oldcomment.isEmpty()) {
2493 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2497 CommentedTime marker(pos, oldcomment);
2498 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2499 if (d.exec() == QDialog::Accepted) {
2500 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2501 if (d.newMarker().time() != pos) {
2502 // remove old marker
2503 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2508 void MainWindow::slotAddGuide()
2510 if (m_activeTimeline)
2511 m_activeTimeline->projectView()->slotAddGuide();
2514 void MainWindow::slotInsertSpace()
2516 if (m_activeTimeline)
2517 m_activeTimeline->projectView()->slotInsertSpace();
2520 void MainWindow::slotRemoveSpace()
2522 if (m_activeTimeline)
2523 m_activeTimeline->projectView()->slotRemoveSpace();
2526 void MainWindow::slotInsertTrack(int ix)
2528 m_projectMonitor->activateMonitor();
2529 if (m_activeTimeline)
2530 m_activeTimeline->projectView()->slotInsertTrack(ix);
2531 if (m_activeDocument)
2532 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2535 void MainWindow::slotDeleteTrack(int ix)
2537 m_projectMonitor->activateMonitor();
2538 if (m_activeTimeline)
2539 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2540 if (m_activeDocument)
2541 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2544 void MainWindow::slotConfigTrack(int ix)
2546 m_projectMonitor->activateMonitor();
2547 if (m_activeTimeline)
2548 m_activeTimeline->projectView()->slotConfigTracks(ix);
2549 if (m_activeDocument)
2550 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2553 void MainWindow::slotEditGuide()
2555 if (m_activeTimeline)
2556 m_activeTimeline->projectView()->slotEditGuide();
2559 void MainWindow::slotDeleteGuide()
2561 if (m_activeTimeline)
2562 m_activeTimeline->projectView()->slotDeleteGuide();
2565 void MainWindow::slotDeleteAllGuides()
2567 if (m_activeTimeline)
2568 m_activeTimeline->projectView()->slotDeleteAllGuides();
2571 void MainWindow::slotCutTimelineClip()
2573 if (m_activeTimeline)
2574 m_activeTimeline->projectView()->cutSelectedClips();
2577 void MainWindow::slotInsertClipOverwrite()
2579 if (m_activeTimeline) {
2580 QStringList data = m_clipMonitor->getZoneInfo();
2581 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2585 void MainWindow::slotSelectTimelineClip()
2587 if (m_activeTimeline)
2588 m_activeTimeline->projectView()->selectClip(true);
2591 void MainWindow::slotSelectTimelineTransition()
2593 if (m_activeTimeline)
2594 m_activeTimeline->projectView()->selectTransition(true);
2597 void MainWindow::slotDeselectTimelineClip()
2599 if (m_activeTimeline)
2600 m_activeTimeline->projectView()->selectClip(false, true);
2603 void MainWindow::slotDeselectTimelineTransition()
2605 if (m_activeTimeline)
2606 m_activeTimeline->projectView()->selectTransition(false, true);
2609 void MainWindow::slotSelectAddTimelineClip()
2611 if (m_activeTimeline)
2612 m_activeTimeline->projectView()->selectClip(true, true);
2615 void MainWindow::slotSelectAddTimelineTransition()
2617 if (m_activeTimeline)
2618 m_activeTimeline->projectView()->selectTransition(true, true);
2621 void MainWindow::slotGroupClips()
2623 if (m_activeTimeline)
2624 m_activeTimeline->projectView()->groupClips();
2627 void MainWindow::slotUnGroupClips()
2629 if (m_activeTimeline)
2630 m_activeTimeline->projectView()->groupClips(false);
2633 void MainWindow::slotEditItemDuration()
2635 if (m_activeTimeline)
2636 m_activeTimeline->projectView()->editItemDuration();
2639 void MainWindow::slotAddProjectClip(KUrl url)
2641 if (m_activeDocument)
2642 m_activeDocument->slotAddClipFile(url, QString());
2645 void MainWindow::slotAddTransition(QAction *result)
2647 if (!result) return;
2648 QStringList info = result->data().toStringList();
2649 if (info.isEmpty()) return;
2650 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2651 if (m_activeTimeline && !transition.isNull()) {
2652 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2656 void MainWindow::slotAddVideoEffect(QAction *result)
2658 if (!result) return;
2659 QStringList info = result->data().toStringList();
2660 if (info.isEmpty()) return;
2661 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2662 slotAddEffect(effect);
2665 void MainWindow::slotAddAudioEffect(QAction *result)
2667 if (!result) return;
2668 QStringList info = result->data().toStringList();
2669 if (info.isEmpty()) return;
2670 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2671 slotAddEffect(effect);
2674 void MainWindow::slotAddCustomEffect(QAction *result)
2676 if (!result) return;
2677 QStringList info = result->data().toStringList();
2678 if (info.isEmpty()) return;
2679 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2680 slotAddEffect(effect);
2683 void MainWindow::slotZoomIn()
2685 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2686 slotShowZoomSliderToolTip();
2689 void MainWindow::slotZoomOut()
2691 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2692 slotShowZoomSliderToolTip();
2695 void MainWindow::slotFitZoom()
2697 if (m_activeTimeline)
2698 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2701 void MainWindow::slotSetZoom(int value)
2703 if (m_activeTimeline)
2704 m_activeTimeline->slotChangeZoom(value);
2706 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2707 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2708 slotUpdateZoomSliderToolTip(value);
2710 m_zoomSlider->blockSignals(true);
2711 m_zoomSlider->setValue(value);
2712 m_zoomSlider->blockSignals(false);
2715 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2717 if (zoomlevel != -1)
2718 slotUpdateZoomSliderToolTip(zoomlevel);
2720 QPoint global = m_zoomSlider->rect().topLeft();
2721 global.ry() += m_zoomSlider->height() / 2;
2722 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2723 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2726 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2728 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2731 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2733 m_statusProgressBar->setValue(progress);
2734 if (progress >= 0) {
2735 if (!message.isEmpty())
2736 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2737 m_statusProgressBar->setVisible(true);
2738 } else if (progress == -2) {
2739 if (!message.isEmpty())
2740 m_messageLabel->setMessage(message, ErrorMessage);
2741 m_statusProgressBar->setVisible(false);
2743 m_messageLabel->setMessage(QString(), DefaultMessage);
2744 m_statusProgressBar->setVisible(false);
2748 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2750 if (clip->clipType() == TEXT) {
2751 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2752 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2753 // template text clip
2755 // Get the list of existing templates
2757 filter << "*.kdenlivetitle";
2758 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2760 QDialog *dia = new QDialog(this);
2761 Ui::TemplateClip_UI dia_ui;
2762 dia_ui.setupUi(dia);
2764 const QString templatePath = clip->getProperty("resource");
2765 for (int i = 0; i < templateFiles.size(); ++i) {
2766 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2767 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2769 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2770 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2771 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2772 //warning: setting base directory doesn't work??
2773 KUrl startDir(titlepath);
2774 dia_ui.template_list->fileDialog()->setUrl(startDir);
2775 dia_ui.description->setText(clip->getProperty("description"));
2776 if (dia->exec() == QDialog::Accepted) {
2777 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2778 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2780 QMap <QString, QString> newprops;
2782 if (KUrl(textTemplate).path() != templatePath) {
2783 // The template was changed
2784 newprops.insert("resource", textTemplate);
2787 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2788 newprops.insert("description", dia_ui.description->toPlainText());
2791 QString newtemplate = newprops.value("xmltemplate");
2792 if (newtemplate.isEmpty()) newtemplate = templatePath;
2794 // template modified we need to update xmldata
2795 QString description = newprops.value("description");
2796 if (description.isEmpty()) description = clip->getProperty("description");
2797 else newprops.insert("templatetext", description);
2798 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2799 if (!newprops.isEmpty()) {
2800 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2801 m_activeDocument->commandStack()->push(command);
2807 QString path = clip->getProperty("resource");
2808 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2810 doc.setContent(clip->getProperty("xmldata"));
2811 dia_ui->setXml(doc);
2812 if (dia_ui->exec() == QDialog::Accepted) {
2813 QMap <QString, QString> newprops;
2814 newprops.insert("xmldata", dia_ui->xml().toString());
2815 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2816 // duration changed, we need to update duration
2817 newprops.insert("out", QString::number(dia_ui->outPoint()));
2819 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2820 m_activeDocument->commandStack()->push(command);
2821 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2822 m_activeDocument->setModified(true);
2826 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2829 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2830 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2831 if (dia.exec() == QDialog::Accepted) {
2832 QMap <QString, QString> newprops = dia.properties();
2833 if (newprops.isEmpty()) return;
2834 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2835 m_activeDocument->commandStack()->push(command);
2837 if (dia.needsTimelineRefresh()) {
2838 // update clip occurences in timeline
2839 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2845 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2847 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2848 if (dia.exec() == QDialog::Accepted) {
2849 QUndoCommand *command = new QUndoCommand();
2850 command->setText(i18n("Edit clips"));
2851 for (int i = 0; i < cliplist.count(); i++) {
2852 DocClipBase *clip = cliplist.at(i);
2853 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2855 m_activeDocument->commandStack()->push(command);
2856 for (int i = 0; i < cliplist.count(); i++)
2857 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2861 void MainWindow::customEvent(QEvent* e)
2863 if (e->type() == QEvent::User)
2864 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2866 void MainWindow::slotActivateEffectStackView()
2868 m_effectStack->raiseWindow(m_effectStackDock);
2871 void MainWindow::slotActivateTransitionView(Transition *t)
2874 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2877 void MainWindow::slotSnapRewind()
2879 if (m_projectMonitor->isActive()) {
2880 if (m_activeTimeline)
2881 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2883 m_clipMonitor->slotSeekToPreviousSnap();
2887 void MainWindow::slotSnapForward()
2889 if (m_projectMonitor->isActive()) {
2890 if (m_activeTimeline)
2891 m_activeTimeline->projectView()->slotSeekToNextSnap();
2893 m_clipMonitor->slotSeekToNextSnap();
2897 void MainWindow::slotClipStart()
2899 if (m_projectMonitor->isActive()) {
2900 if (m_activeTimeline)
2901 m_activeTimeline->projectView()->clipStart();
2905 void MainWindow::slotClipEnd()
2907 if (m_projectMonitor->isActive()) {
2908 if (m_activeTimeline)
2909 m_activeTimeline->projectView()->clipEnd();
2913 void MainWindow::slotZoneStart()
2915 if (m_projectMonitor->isActive())
2916 m_projectMonitor->slotZoneStart();
2918 m_clipMonitor->slotZoneStart();
2921 void MainWindow::slotZoneEnd()
2923 if (m_projectMonitor->isActive())
2924 m_projectMonitor->slotZoneEnd();
2926 m_clipMonitor->slotZoneEnd();
2929 void MainWindow::slotChangeTool(QAction * action)
2931 if (action == m_buttonSelectTool)
2932 slotSetTool(SELECTTOOL);
2933 else if (action == m_buttonRazorTool)
2934 slotSetTool(RAZORTOOL);
2935 else if (action == m_buttonSpacerTool)
2936 slotSetTool(SPACERTOOL);
2939 void MainWindow::slotChangeEdit(QAction * action)
2941 if (!m_activeTimeline)
2944 if (action == m_overwriteEditTool)
2945 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2946 else if (action == m_insertEditTool)
2947 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2949 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2952 void MainWindow::slotSetTool(PROJECTTOOL tool)
2954 if (m_activeDocument && m_activeTimeline) {
2955 //m_activeDocument->setTool(tool);
2959 message = i18n("Ctrl + click to use spacer on current track only");
2962 message = i18n("Click on a clip to cut it");
2965 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2968 m_messageLabel->setMessage(message, InformationMessage);
2969 m_activeTimeline->projectView()->setTool(tool);
2973 void MainWindow::slotCopy()
2975 if (m_activeDocument && m_activeTimeline)
2976 m_activeTimeline->projectView()->copyClip();
2979 void MainWindow::slotPaste()
2981 if (m_activeDocument && m_activeTimeline)
2982 m_activeTimeline->projectView()->pasteClip();
2985 void MainWindow::slotPasteEffects()
2987 if (m_activeDocument && m_activeTimeline)
2988 m_activeTimeline->projectView()->pasteClipEffects();
2991 void MainWindow::slotFind()
2993 if (!m_activeDocument || !m_activeTimeline) return;
2994 m_projectSearch->setEnabled(false);
2995 m_findActivated = true;
2996 m_findString.clear();
2997 m_activeTimeline->projectView()->initSearchStrings();
2998 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2999 m_findTimer.start(5000);
3000 qApp->installEventFilter(this);
3003 void MainWindow::slotFindNext()
3005 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3006 statusBar()->showMessage(i18n("Found: %1", m_findString));
3008 statusBar()->showMessage(i18n("Reached end of project"));
3009 m_findTimer.start(4000);
3012 void MainWindow::findAhead()
3014 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3015 m_projectSearchNext->setEnabled(true);
3016 statusBar()->showMessage(i18n("Found: %1", m_findString));
3018 m_projectSearchNext->setEnabled(false);
3019 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3023 void MainWindow::findTimeout()
3025 m_projectSearchNext->setEnabled(false);
3026 m_findActivated = false;
3027 m_findString.clear();
3028 statusBar()->showMessage(i18n("Find stopped"), 3000);
3029 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3030 m_projectSearch->setEnabled(true);
3031 removeEventFilter(this);
3034 void MainWindow::slotClipInTimeline(const QString &clipId)
3036 if (m_activeTimeline && m_activeDocument) {
3037 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3039 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3040 inTimelineMenu->clear();
3042 QList <QAction *> actionList;
3044 for (int i = 0; i < matching.count(); ++i) {
3045 QString track = QString::number(matching.at(i).track);
3046 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3048 QAction *a = new QAction(track + ": " + start, this);
3049 a->setData(QStringList() << track << start);
3050 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3051 while (j < actionList.count()) {
3052 if (actionList.at(j)->text() > a->text()) break;
3055 actionList.insert(j, a);
3057 inTimelineMenu->addActions(actionList);
3059 if (matching.empty())
3060 inTimelineMenu->setEnabled(false);
3062 inTimelineMenu->setEnabled(true);
3066 void MainWindow::slotClipInProjectTree()
3068 if (m_activeTimeline) {
3069 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3070 if (clipIds.isEmpty())
3072 m_projectListDock->raise();
3073 for (int i = 0; i < clipIds.count(); i++)
3074 m_projectList->selectItemById(clipIds.at(i));
3075 if (m_projectMonitor->isActive())
3076 slotSwitchMonitors();
3080 /*void MainWindow::slotClipToProjectTree()
3082 if (m_activeTimeline) {
3083 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3084 if (clips.isEmpty()) return;
3085 for (int i = 0; i < clips.count(); i++) {
3086 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3088 //m_projectList->selectItemById(clipIds.at(i));
3092 void MainWindow::slotSelectClipInTimeline()
3094 if (m_activeTimeline) {
3095 QAction *action = qobject_cast<QAction *>(sender());
3096 QStringList data = action->data().toStringList();
3097 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3101 void MainWindow::keyPressEvent(QKeyEvent *ke)
3103 if (m_findActivated) {
3104 if (ke->key() == Qt::Key_Backspace) {
3105 m_findString = m_findString.left(m_findString.length() - 1);
3107 if (!m_findString.isEmpty())
3112 m_findTimer.start(4000);
3115 } else if (ke->key() == Qt::Key_Escape) {
3119 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3120 m_findString += ke->text();
3124 m_findTimer.start(4000);
3129 KXmlGuiWindow::keyPressEvent(ke);
3134 /** Gets called when the window gets hidden */
3135 void MainWindow::hideEvent(QHideEvent */*event*/)
3138 if (m_monitorManager)
3139 m_monitorManager->stopActiveMonitor();
3142 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3144 if (m_findActivated) {
3145 if (event->type() == QEvent::ShortcutOverride) {
3146 QKeyEvent* ke = (QKeyEvent*) event;
3147 if (ke->text().trimmed().isEmpty()) return false;
3154 // pass the event on to the parent class
3155 return QMainWindow::eventFilter(obj, event);
3160 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3162 KDialog *dialog = new KDialog(this);
3163 dialog->setCaption("Save clip zone");
3164 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3166 QWidget *widget = new QWidget(dialog);
3167 dialog->setMainWidget(widget);
3169 QVBoxLayout *vbox = new QVBoxLayout(widget);
3170 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3171 QString path = m_activeDocument->projectFolder().path();
3173 path.append("untitled.mlt");
3174 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3175 url->setFilter("video/mlt-playlist");
3176 QLabel *label2 = new QLabel(i18n("Description:"), this);
3177 KLineEdit *edit = new KLineEdit(this);
3178 vbox->addWidget(label1);
3179 vbox->addWidget(url);
3180 vbox->addWidget(label2);
3181 vbox->addWidget(edit);
3182 if (dialog->exec() == QDialog::Accepted)
3183 render->saveZone(url->url(), edit->text(), zone);
3187 void MainWindow::slotSetInPoint()
3189 if (m_clipMonitor->isActive())
3190 m_clipMonitor->slotSetZoneStart();
3192 m_projectMonitor->slotSetZoneStart();
3193 //else m_activeTimeline->projectView()->setInPoint();
3196 void MainWindow::slotSetOutPoint()
3198 if (m_clipMonitor->isActive())
3199 m_clipMonitor->slotSetZoneEnd();
3201 m_projectMonitor->slotSetZoneEnd();
3202 // else m_activeTimeline->projectView()->setOutPoint();
3205 void MainWindow::slotResizeItemStart()
3207 if (m_activeTimeline)
3208 m_activeTimeline->projectView()->setInPoint();
3211 void MainWindow::slotResizeItemEnd()
3213 if (m_activeTimeline)
3214 m_activeTimeline->projectView()->setOutPoint();
3217 int MainWindow::getNewStuff(const QString &configFile)
3219 KNS3::Entry::List entries;
3220 #if KDE_IS_VERSION(4,3,80)
3221 KNS3::DownloadDialog dialog(configFile);
3223 entries = dialog.changedEntries();
3224 foreach(const KNS3::Entry &entry, entries) {
3225 if (entry.status() == KNS3::Entry::Installed)
3226 kDebug() << "// Installed files: " << entry.installedFiles();
3229 KNS::Engine engine(0);
3230 if (engine.init(configFile))
3231 entries = engine.downloadDialogModal(this);
3232 foreach(KNS::Entry *entry, entries) {
3233 if (entry->status() == KNS::Entry::Installed)
3234 kDebug() << "// Installed files: " << entry->installedFiles();
3236 #endif /* KDE_IS_VERSION(4,3,80) */
3237 return entries.size();
3240 void MainWindow::slotGetNewTitleStuff()
3242 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3243 TitleWidget::refreshTitleTemplates();
3246 void MainWindow::slotGetNewLumaStuff()
3248 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3249 initEffects::refreshLumas();
3250 m_activeTimeline->projectView()->reloadTransitionLumas();
3254 void MainWindow::slotGetNewRenderStuff()
3256 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3258 m_renderWidget->reloadProfiles();
3261 void MainWindow::slotGetNewMltProfileStuff()
3263 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3264 // update the list of profiles in settings dialog
3265 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3271 void MainWindow::slotAutoTransition()
3273 if (m_activeTimeline)
3274 m_activeTimeline->projectView()->autoTransition();
3277 void MainWindow::slotSplitAudio()
3279 if (m_activeTimeline)
3280 m_activeTimeline->projectView()->splitAudio();
3283 void MainWindow::slotUpdateClipType(QAction *action)
3285 if (m_activeTimeline) {
3286 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3287 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3288 else m_activeTimeline->projectView()->setAudioAndVideo();
3292 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3294 // We must stop the monitors since we create a new on in the dvd wizard
3295 m_clipMonitor->stop();
3296 m_projectMonitor->stop();
3297 DvdWizard w(url, profile, this);
3299 m_projectMonitor->start();
3302 void MainWindow::slotShowTimeline(bool show)
3304 if (show == false) {
3305 m_timelineState = saveState();
3306 centralWidget()->setHidden(true);
3308 centralWidget()->setHidden(false);
3309 restoreState(m_timelineState);
3313 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3315 //TODO: is there a way to maximize current widget?
3318 m_timelineState = saveState();
3319 QWidget *par = focusWidget()->parentWidget();
3320 while (par->parentWidget() && par->parentWidget() != this)
3321 par = par->parentWidget();
3322 kDebug() << "CURRENT WIDGET: " << par->objectName();
3325 //centralWidget()->setHidden(false);
3326 //restoreState(m_timelineState);
3330 void MainWindow::loadTranscoders()
3332 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3335 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3336 KConfigGroup transConfig(config, "Transcoding");
3338 QMap< QString, QString > profiles = transConfig.entryMap();
3339 QMapIterator<QString, QString> i(profiles);
3340 while (i.hasNext()) {
3342 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3343 QAction *a = transMenu->addAction(i.key());
3345 if (data.count() > 1)
3346 a->setToolTip(data.at(1));
3347 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3351 void MainWindow::slotTranscode(KUrl::List urls)
3356 if (urls.isEmpty()) {
3357 QAction *action = qobject_cast<QAction *>(sender());
3358 QStringList data = action->data().toStringList();
3359 params = data.at(0);
3360 if (data.count() > 1) desc = data.at(1);
3361 if (data.count() > 2) condition = data.at(2);
3362 urls << m_projectList->getConditionalUrls(condition);
3363 urls.removeAll(KUrl());
3365 if (urls.isEmpty()) {
3366 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3369 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3370 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3372 //QProcess::startDetached("ffmpeg", parameters);
3375 void MainWindow::slotTranscodeClip()
3377 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3378 if (urls.isEmpty()) return;
3379 slotTranscode(urls);
3382 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3384 if (m_activeDocument == NULL) return;
3385 QMapIterator<QString, QString> i(props);
3386 while (i.hasNext()) {
3388 m_activeDocument->setDocumentProperty(i.key(), i.value());
3390 m_activeDocument->setModified(true);
3394 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3396 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3398 QString playlistPath;
3401 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3402 QString path = m_renderWidget->getFreeScriptName();
3403 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3404 if (!ok || scriptPath.isEmpty()) return;
3405 scriptPath.prepend(scriptsFolder);
3406 QFile f(scriptPath);
3408 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3411 playlistPath = scriptPath + ".mlt";
3412 m_projectMonitor->saveSceneList(playlistPath);
3414 KTemporaryFile temp;
3415 temp.setAutoRemove(false);
3416 temp.setSuffix(".mlt");
3418 playlistPath = temp.fileName();
3419 m_projectMonitor->saveSceneList(playlistPath);
3422 if (!chapterFile.isEmpty()) {
3425 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3427 in = m_activeTimeline->inPoint();
3428 out = m_activeTimeline->outPoint();
3431 QDomElement chapters = doc.createElement("chapters");
3432 chapters.setAttribute("fps", m_activeDocument->fps());
3433 doc.appendChild(chapters);
3435 QDomElement guidesxml = m_activeDocument->guidesXml();
3436 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3437 for (int i = 0; i < nodes.count(); i++) {
3438 QDomElement e = nodes.item(i).toElement();
3440 QString comment = e.attribute("comment");
3441 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3442 if (time >= in && time < out) {
3443 if (zoneOnly) time = time - in;
3444 QDomElement chapter = doc.createElement("chapter");
3445 chapters.appendChild(chapter);
3446 chapter.setAttribute("title", comment);
3447 chapter.setAttribute("time", time);
3451 if (chapters.childNodes().count() > 0) {
3452 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3453 // Always insert a guide in pos 0
3454 QDomElement chapter = doc.createElement("chapter");
3455 chapters.insertBefore(chapter, QDomNode());
3456 chapter.setAttribute("title", i18n("Start"));
3457 chapter.setAttribute("time", "0");
3459 // save chapters file
3460 QFile file(chapterFile);
3461 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3462 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3464 file.write(doc.toString().toUtf8());
3465 if (file.error() != QFile::NoError) {
3466 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3473 if (m_renderWidget->automaticAudioExport()) {
3474 exportAudio = m_activeTimeline->checkProjectAudio();
3475 } else exportAudio = m_renderWidget->selectedAudioExport();
3476 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3479 void MainWindow::slotUpdateTimecodeFormat(int ix)
3481 KdenliveSettings::setFrametimecode(ix == 1);
3482 m_clipMonitor->updateTimecodeFormat();
3483 m_projectMonitor->updateTimecodeFormat();
3484 m_transitionConfig->updateTimecodeFormat();
3485 m_effectStack->updateTimecodeFormat();
3486 //m_activeTimeline->projectView()->clearSelection();
3487 m_activeTimeline->updateRuler();
3490 void MainWindow::slotRemoveFocus()
3492 statusBar()->setFocus();
3493 statusBar()->clearFocus();
3496 void MainWindow::slotRevert()
3498 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;
3499 KUrl url = m_activeDocument->url();
3500 closeCurrentDocument(false);
3501 doOpenFile(url, NULL);
3505 void MainWindow::slotShutdown()
3507 if (m_activeDocument) m_activeDocument->setModified(false);
3509 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3510 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3511 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3512 smserver.call("logout", 1, 2, 2);
3513 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3514 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3515 smserver.call("Shutdown");
3519 void MainWindow::slotUpdateTrackInfo()
3521 if (m_activeDocument)
3522 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3525 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3527 // Load the theme file
3529 if (action == NULL) theme = themename;
3530 else theme = action->data().toString();
3531 KdenliveSettings::setColortheme(theme);
3532 // Make palette for all widgets.
3534 if (theme.isEmpty())
3535 plt = QApplication::desktop()->palette();
3537 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3538 plt = KGlobalSettings::createApplicationPalette(config);
3541 kapp->setPalette(plt);
3542 const QObjectList children = statusBar()->children();
3544 foreach(QObject *child, children) {
3545 if (child->isWidgetType())
3546 ((QWidget*)child)->setPalette(plt);
3547 const QObjectList subchildren = child->children();
3548 foreach(QObject *subchild, subchildren) {
3549 if (subchild->isWidgetType())
3550 ((QWidget*)subchild)->setPalette(plt);
3553 if (m_activeTimeline)
3554 m_activeTimeline->projectView()->updatePalette();
3558 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3560 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3561 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3562 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3563 const QSize bitsSize(24, 2);
3564 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3565 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3567 QPixmap pixmap(23, 16);
3568 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3570 KConfigGroup group(config, "WM");
3571 QPainter p(&pixmap);
3572 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3573 p.fillRect(1, 1, 7, 7, windowScheme.background());
3574 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3576 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3577 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3578 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3580 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3581 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3583 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3584 p.fillRect(1, 8, 7, 7, viewScheme.background());
3585 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3587 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3588 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3589 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3591 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3592 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3598 void MainWindow::slotSwitchMonitors()
3600 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3601 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3602 else m_projectList->focusTree();
3605 void MainWindow::slotInsertZoneToTree()
3607 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3608 QStringList info = m_clipMonitor->getZoneInfo();
3609 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3612 void MainWindow::slotInsertZoneToTimeline()
3614 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3615 QStringList info = m_clipMonitor->getZoneInfo();
3616 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3620 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3622 if (m_activeDocument && m_activeTimeline) {
3623 if (!ids.isEmpty()) {
3624 for (int i = 0; i < ids.size(); ++i) {
3625 m_activeTimeline->slotDeleteClip(ids.at(i));
3627 m_activeDocument->clipManager()->slotDeleteClips(ids);
3629 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3630 m_activeDocument->setModified(true);
3634 void MainWindow::slotShowTitleBars(bool show)
3637 m_effectStackDock->setTitleBarWidget(0);
3638 m_clipMonitorDock->setTitleBarWidget(0);
3639 m_projectMonitorDock->setTitleBarWidget(0);
3641 m_recMonitorDock->setTitleBarWidget(0);
3643 m_effectListDock->setTitleBarWidget(0);
3644 m_transitionConfigDock->setTitleBarWidget(0);
3645 m_projectListDock->setTitleBarWidget(0);
3646 m_undoViewDock->setTitleBarWidget(0);
3647 m_vectorscopeDock->setTitleBarWidget(0);
3648 m_waveformDock->setTitleBarWidget(0);
3649 m_RGBParadeDock->setTitleBarWidget(0);
3650 m_histogramDock->setTitleBarWidget(0);
3652 if (!m_effectStackDock->isFloating()) {
3653 m_effectStackDock->setTitleBarWidget(new QWidget);
3655 if (!m_clipMonitorDock->isFloating()) {
3656 m_clipMonitorDock->setTitleBarWidget(new QWidget);
3658 if (!m_projectMonitorDock->isFloating()) {
3659 m_projectMonitorDock->setTitleBarWidget(new QWidget);
3662 if (!m_recMonitorDock->isFloating()) {
3663 m_recMonitorDock->setTitleBarWidget(new QWidget);
3666 if (!m_effectListDock->isFloating()) {
3667 m_effectListDock->setTitleBarWidget(new QWidget);
3669 if (!m_transitionConfigDock->isFloating()) {
3670 m_transitionConfigDock->setTitleBarWidget(new QWidget);
3672 if (!m_projectListDock->isFloating()) {
3673 m_projectListDock->setTitleBarWidget(new QWidget);
3675 if (!m_undoViewDock->isFloating()) {
3676 m_undoViewDock->setTitleBarWidget(new QWidget);
3678 if (!m_vectorscopeDock->isFloating()) {
3679 m_vectorscopeDock->setTitleBarWidget(new QWidget);
3681 if (!m_waveformDock->isFloating()) {
3682 m_waveformDock->setTitleBarWidget(new QWidget);
3684 if (!m_RGBParadeDock->isFloating()) {
3685 m_RGBParadeDock->setTitleBarWidget(new QWidget(this));
3687 if (!m_histogramDock->isFloating()) {
3688 m_histogramDock->setTitleBarWidget(new QWidget(this));
3691 KdenliveSettings::setShowtitlebars(show);
3694 void MainWindow::slotSwitchTitles()
3696 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3699 QString MainWindow::getMimeType()
3701 QString mimetype = "application/x-kdenlive";
3702 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3703 if (!mime) mimetype = "*.kdenlive";
3707 #include "mainwindow.moc"