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())) {
527 if (m_activeDocument->url().fileName().isEmpty())
528 message = i18n("Save changes to document?");
530 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
531 switch (KMessageBox::warningYesNoCancel(this, message)) {
532 case KMessageBox::Yes :
533 // save document here. If saving fails, return false;
535 case KMessageBox::No :
536 // User does not want to save the changes, clear recovery files
537 m_activeDocument->m_autosave->resize(0);
546 void MainWindow::loadPlugins()
548 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
549 populateMenus(plugin);
552 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
554 filters << "libkdenlive*";
555 foreach(const QString &folder, directories) {
556 kDebug() << "Parsing plugin folder: " << folder;
557 QDir pluginsDir(folder);
558 foreach(const QString &fileName,
559 pluginsDir.entryList(filters, QDir::Files)) {
561 * Avoid loading the same plugin twice when there is more than one
564 if (!m_pluginFileNames.contains(fileName)) {
565 kDebug() << "Found plugin: " << fileName;
566 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
567 QObject *plugin = loader.instance();
569 populateMenus(plugin);
570 m_pluginFileNames += fileName;
572 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
578 void MainWindow::populateMenus(QObject *plugin)
580 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
581 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
583 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
587 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
588 QMenu *menu, const char *member,
589 QActionGroup *actionGroup)
591 kDebug() << "// ADD to MENU" << texts;
592 foreach(const QString &text, texts) {
593 QAction *action = new QAction(text, plugin);
594 action->setData(text);
595 connect(action, SIGNAL(triggered()), this, member);
596 menu->addAction(action);
599 action->setCheckable(true);
600 actionGroup->addAction(action);
605 void MainWindow::aboutPlugins()
607 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
612 void MainWindow::generateClip()
614 QAction *action = qobject_cast<QAction *>(sender());
615 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
617 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
618 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
619 if (!clipUrl.isEmpty()) {
620 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
624 void MainWindow::saveProperties(KConfigGroup &config)
626 // save properties here,used by session management
628 KMainWindow::saveProperties(config);
632 void MainWindow::readProperties(const KConfigGroup &config)
634 // read properties here,used by session management
635 KMainWindow::readProperties(config);
636 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
637 openFile(KUrl(Lastproject));
640 void MainWindow::slotReloadEffects()
642 m_customEffectsMenu->clear();
643 initEffects::parseCustomEffectsFile();
645 QStringList effectInfo;
646 QMap<QString, QStringList> effectsList;
647 for (int ix = 0; ix < customEffects.count(); ix++) {
648 effectInfo = customEffects.effectIdInfo(ix);
649 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
651 if (effectsList.isEmpty())
652 m_customEffectsMenu->setEnabled(false);
654 m_customEffectsMenu->setEnabled(true);
656 foreach(const QStringList &value, effectsList) {
657 action = new QAction(value.at(0), this);
658 action->setData(value);
659 m_customEffectsMenu->addAction(action);
661 m_effectList->reloadEffectList();
664 #ifndef NO_JOGSHUTTLE
665 void MainWindow::activateShuttleDevice()
669 if (KdenliveSettings::enableshuttle() == false) return;
670 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
671 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
672 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
673 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
674 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
675 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
676 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
679 void MainWindow::slotShuttleButton(int code)
683 slotShuttleAction(KdenliveSettings::shuttle1());
686 slotShuttleAction(KdenliveSettings::shuttle2());
689 slotShuttleAction(KdenliveSettings::shuttle3());
692 slotShuttleAction(KdenliveSettings::shuttle4());
695 slotShuttleAction(KdenliveSettings::shuttle5());
700 void MainWindow::slotShuttleAction(int code)
706 m_monitorManager->slotPlay();
709 m_monitorManager->slotPlay();
713 #endif /* NO_JOGSHUTTLE */
715 void MainWindow::configureNotifications()
717 KNotifyConfigWidget::configure(this);
720 void MainWindow::slotFullScreen()
722 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
725 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
727 if (!m_activeDocument) return;
728 if (effect.isNull()) {
729 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
732 QDomElement effectToAdd = effect.cloneNode().toElement();
733 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
736 void MainWindow::slotRaiseMonitor(bool clipMonitor)
738 if (clipMonitor) m_clipMonitorDock->raise();
739 else m_projectMonitorDock->raise();
742 void MainWindow::slotUpdateClip(const QString &id)
744 if (!m_activeDocument) return;
745 m_activeTimeline->projectView()->slotUpdateClip(id);
748 void MainWindow::slotConnectMonitors()
750 m_projectList->setRenderer(m_projectMonitor->render);
751 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
752 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
753 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
754 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
755 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
756 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
757 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)));
759 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
761 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
763 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
764 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
766 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
767 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
770 void MainWindow::slotAdjustClipMonitor()
772 m_clipMonitorDock->updateGeometry();
773 m_clipMonitorDock->adjustSize();
774 m_clipMonitor->resetSize();
777 void MainWindow::slotAdjustProjectMonitor()
779 m_projectMonitorDock->updateGeometry();
780 m_projectMonitorDock->adjustSize();
781 m_projectMonitor->resetSize();
784 void MainWindow::setupActions()
787 KActionCollection* collection = actionCollection();
788 m_timecodeFormat = new KComboBox(this);
789 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
790 m_timecodeFormat->addItem(i18n("Frames"));
791 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
792 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
794 m_statusProgressBar = new QProgressBar(this);
795 m_statusProgressBar->setMinimum(0);
796 m_statusProgressBar->setMaximum(100);
797 m_statusProgressBar->setMaximumWidth(150);
798 m_statusProgressBar->setVisible(false);
800 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
801 toolbar->setMovable(false);
802 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
803 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;}";
804 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
806 //create edit mode buttons
807 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
808 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
809 toolbar->addAction(m_normalEditTool);
810 m_normalEditTool->setCheckable(true);
811 m_normalEditTool->setChecked(true);
813 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
814 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
815 toolbar->addAction(m_overwriteEditTool);
816 m_overwriteEditTool->setCheckable(true);
817 m_overwriteEditTool->setChecked(false);
819 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
820 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
821 toolbar->addAction(m_insertEditTool);
822 m_insertEditTool->setCheckable(true);
823 m_insertEditTool->setChecked(false);
824 // not implemented yet
825 m_insertEditTool->setEnabled(false);
827 QActionGroup *editGroup = new QActionGroup(this);
828 editGroup->addAction(m_normalEditTool);
829 editGroup->addAction(m_overwriteEditTool);
830 editGroup->addAction(m_insertEditTool);
831 editGroup->setExclusive(true);
832 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
833 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
835 toolbar->addSeparator();
837 // create tools buttons
838 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
839 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
840 toolbar->addAction(m_buttonSelectTool);
841 m_buttonSelectTool->setCheckable(true);
842 m_buttonSelectTool->setChecked(true);
844 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
845 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
846 toolbar->addAction(m_buttonRazorTool);
847 m_buttonRazorTool->setCheckable(true);
848 m_buttonRazorTool->setChecked(false);
850 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
851 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
852 toolbar->addAction(m_buttonSpacerTool);
853 m_buttonSpacerTool->setCheckable(true);
854 m_buttonSpacerTool->setChecked(false);
856 QActionGroup *toolGroup = new QActionGroup(this);
857 toolGroup->addAction(m_buttonSelectTool);
858 toolGroup->addAction(m_buttonRazorTool);
859 toolGroup->addAction(m_buttonSpacerTool);
860 toolGroup->setExclusive(true);
861 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
863 QWidget * actionWidget;
864 int max = toolbar->iconSizeDefault() + 2;
865 actionWidget = toolbar->widgetForAction(m_normalEditTool);
866 actionWidget->setMaximumWidth(max);
867 actionWidget->setMaximumHeight(max - 4);
869 actionWidget = toolbar->widgetForAction(m_insertEditTool);
870 actionWidget->setMaximumWidth(max);
871 actionWidget->setMaximumHeight(max - 4);
873 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
874 actionWidget->setMaximumWidth(max);
875 actionWidget->setMaximumHeight(max - 4);
877 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
878 actionWidget->setMaximumWidth(max);
879 actionWidget->setMaximumHeight(max - 4);
881 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
882 actionWidget->setMaximumWidth(max);
883 actionWidget->setMaximumHeight(max - 4);
885 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
886 actionWidget->setMaximumWidth(max);
887 actionWidget->setMaximumHeight(max - 4);
889 toolbar->setStyleSheet(style1);
890 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
892 toolbar->addSeparator();
893 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
894 toolbar->addAction(m_buttonFitZoom);
895 m_buttonFitZoom->setCheckable(false);
897 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
898 toolbar->addAction(m_zoomOut);
899 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
901 m_zoomSlider = new QSlider(Qt::Horizontal, this);
902 m_zoomSlider->setMaximum(13);
903 m_zoomSlider->setPageStep(1);
904 m_zoomSlider->setInvertedAppearance(true);
906 m_zoomSlider->setMaximumWidth(150);
907 m_zoomSlider->setMinimumWidth(100);
908 toolbar->addWidget(m_zoomSlider);
910 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
911 toolbar->addAction(m_zoomIn);
912 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
914 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
915 actionWidget->setMaximumWidth(max);
916 actionWidget->setMaximumHeight(max - 4);
917 actionWidget->setStyleSheet(styleBorderless);
919 actionWidget = toolbar->widgetForAction(m_zoomIn);
920 actionWidget->setMaximumWidth(max);
921 actionWidget->setMaximumHeight(max - 4);
922 actionWidget->setStyleSheet(styleBorderless);
924 actionWidget = toolbar->widgetForAction(m_zoomOut);
925 actionWidget->setMaximumWidth(max);
926 actionWidget->setMaximumHeight(max - 4);
927 actionWidget->setStyleSheet(styleBorderless);
929 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
930 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
931 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
932 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
933 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
935 toolbar->addSeparator();
937 //create automatic audio split button
938 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
939 toolbar->addAction(m_buttonAutomaticSplitAudio);
940 m_buttonAutomaticSplitAudio->setCheckable(true);
941 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
942 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
944 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
945 toolbar->addAction(m_buttonVideoThumbs);
946 m_buttonVideoThumbs->setCheckable(true);
947 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
948 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
950 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
951 toolbar->addAction(m_buttonAudioThumbs);
952 m_buttonAudioThumbs->setCheckable(true);
953 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
954 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
956 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
957 toolbar->addAction(m_buttonShowMarkers);
958 m_buttonShowMarkers->setCheckable(true);
959 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
960 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
962 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
963 toolbar->addAction(m_buttonSnap);
964 m_buttonSnap->setCheckable(true);
965 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
966 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
968 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
969 actionWidget->setMaximumWidth(max);
970 actionWidget->setMaximumHeight(max - 4);
972 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
973 actionWidget->setMaximumWidth(max);
974 actionWidget->setMaximumHeight(max - 4);
976 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
977 actionWidget->setMaximumWidth(max);
978 actionWidget->setMaximumHeight(max - 4);
980 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
981 actionWidget->setMaximumWidth(max);
982 actionWidget->setMaximumHeight(max - 4);
984 actionWidget = toolbar->widgetForAction(m_buttonSnap);
985 actionWidget->setMaximumWidth(max);
986 actionWidget->setMaximumHeight(max - 4);
988 m_messageLabel = new StatusBarMessageLabel(this);
989 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
991 statusBar()->addWidget(m_messageLabel, 10);
992 statusBar()->addWidget(m_statusProgressBar, 0);
993 statusBar()->addPermanentWidget(toolbar);
994 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
995 statusBar()->addPermanentWidget(m_timecodeFormat);
996 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
998 collection->addAction("normal_mode", m_normalEditTool);
999 collection->addAction("overwrite_mode", m_overwriteEditTool);
1000 collection->addAction("insert_mode", m_insertEditTool);
1001 collection->addAction("select_tool", m_buttonSelectTool);
1002 collection->addAction("razor_tool", m_buttonRazorTool);
1003 collection->addAction("spacer_tool", m_buttonSpacerTool);
1005 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1006 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1007 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1008 collection->addAction("show_markers", m_buttonShowMarkers);
1009 collection->addAction("snap", m_buttonSnap);
1010 collection->addAction("zoom_fit", m_buttonFitZoom);
1011 collection->addAction("zoom_in", m_zoomIn);
1012 collection->addAction("zoom_out", m_zoomOut);
1014 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1015 collection->addAction("project_find", m_projectSearch);
1016 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1017 m_projectSearch->setShortcut(Qt::Key_Slash);
1019 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1020 collection->addAction("project_find_next", m_projectSearchNext);
1021 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1022 m_projectSearchNext->setShortcut(Qt::Key_F3);
1023 m_projectSearchNext->setEnabled(false);
1025 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1026 collection->addAction("manage_profiles", profilesAction);
1027 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1029 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1030 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1031 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1032 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1034 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1035 collection->addAction("run_wizard", wizAction);
1036 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1038 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1039 collection->addAction("project_settings", projectAction);
1040 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1042 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1043 collection->addAction("project_render", projectRender);
1044 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1045 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1047 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1048 collection->addAction("project_clean", projectClean);
1049 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1051 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1052 KShortcut playShortcut;
1053 playShortcut.setPrimary(Qt::Key_Space);
1054 playShortcut.setAlternate(Qt::Key_K);
1055 monitorPlay->setShortcut(playShortcut);
1056 collection->addAction("monitor_play", monitorPlay);
1057 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1059 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1060 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1061 collection->addAction("monitor_play_zone", m_playZone);
1062 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1064 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1065 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1066 collection->addAction("monitor_loop_zone", m_loopZone);
1067 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1069 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1070 collection->addAction("dvd_wizard", dvdWizard);
1071 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1073 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1074 collection->addAction("transcode_clip", transcodeClip);
1075 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1077 KAction *markIn = collection->addAction("mark_in");
1078 markIn->setText(i18n("Set Zone In"));
1079 markIn->setShortcut(Qt::Key_I);
1080 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1082 KAction *markOut = collection->addAction("mark_out");
1083 markOut->setText(i18n("Set Zone Out"));
1084 markOut->setShortcut(Qt::Key_O);
1085 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1087 KAction *switchMon = collection->addAction("switch_monitor");
1088 switchMon->setText(i18n("Switch monitor"));
1089 switchMon->setShortcut(Qt::Key_T);
1090 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1092 KAction *insertTree = collection->addAction("insert_project_tree");
1093 insertTree->setText(i18n("Insert zone in project tree"));
1094 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1095 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1097 KAction *insertTimeline = collection->addAction("insert_timeline");
1098 insertTimeline->setText(i18n("Insert zone in timeline"));
1099 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1100 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1102 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1103 collection->addAction("resize_timeline_clip_start", resizeStart);
1104 resizeStart->setShortcut(Qt::Key_1);
1105 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1107 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1108 collection->addAction("resize_timeline_clip_end", resizeEnd);
1109 resizeEnd->setShortcut(Qt::Key_2);
1110 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1112 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1113 monitorSeekBackward->setShortcut(Qt::Key_J);
1114 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1115 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1117 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1118 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1119 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1120 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1122 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1123 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1124 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1125 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1127 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1128 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1129 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1130 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1132 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1133 monitorSeekForward->setShortcut(Qt::Key_L);
1134 collection->addAction("monitor_seek_forward", monitorSeekForward);
1135 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1137 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1138 clipStart->setShortcut(Qt::Key_Home);
1139 collection->addAction("seek_clip_start", clipStart);
1140 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1142 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1143 clipEnd->setShortcut(Qt::Key_End);
1144 collection->addAction("seek_clip_end", clipEnd);
1145 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1147 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1148 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1149 collection->addAction("seek_zone_start", zoneStart);
1150 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1152 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1153 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1154 collection->addAction("seek_zone_end", zoneEnd);
1155 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1157 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1158 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1159 collection->addAction("seek_start", projectStart);
1160 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1162 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1163 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1164 collection->addAction("seek_end", projectEnd);
1165 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1167 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1168 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1169 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1170 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1172 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1173 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1174 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1175 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1177 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1178 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1179 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1180 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1182 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1183 deleteItem->setShortcut(Qt::Key_Delete);
1184 collection->addAction("delete_timeline_clip", deleteItem);
1185 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1187 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1188 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1189 editTimelineClipSpeed->setData("change_speed");
1190 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1192 KAction *stickTransition = collection->addAction("auto_transition");
1193 stickTransition->setData(QString("auto"));
1194 stickTransition->setCheckable(true);
1195 stickTransition->setEnabled(false);
1196 stickTransition->setText(i18n("Automatic Transition"));
1197 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1199 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1200 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1201 collection->addAction("group_clip", groupClip);
1202 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1204 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1205 collection->addAction("ungroup_clip", ungroupClip);
1206 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1207 ungroupClip->setData("ungroup_clip");
1208 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1210 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1211 collection->addAction("edit_item_duration", editItemDuration);
1212 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1214 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1215 collection->addAction("clip_in_project_tree", clipInProjectTree);
1216 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1218 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1219 collection->addAction("clip_to_project_tree", clipToProjectTree);
1220 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1222 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1223 insertOvertwrite->setShortcut(Qt::Key_V);
1224 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1225 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1227 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1228 selectTimelineClip->setShortcut(Qt::Key_Plus);
1229 collection->addAction("select_timeline_clip", selectTimelineClip);
1230 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1232 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1233 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1234 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1235 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1237 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1238 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1239 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1240 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1242 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1243 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1244 collection->addAction("select_timeline_transition", selectTimelineTransition);
1245 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1247 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1248 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1249 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1250 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1252 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1253 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1254 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1255 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1257 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1258 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1259 collection->addAction("cut_timeline_clip", cutTimelineClip);
1260 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1262 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1263 collection->addAction("add_clip_marker", addClipMarker);
1264 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1266 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1267 collection->addAction("delete_clip_marker", deleteClipMarker);
1268 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1270 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1271 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1272 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1274 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1275 collection->addAction("edit_clip_marker", editClipMarker);
1276 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1278 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1279 collection->addAction("split_audio", splitAudio);
1280 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1282 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1283 collection->addAction("clip_audio_only", audioOnly);
1284 audioOnly->setData("clip_audio_only");
1285 audioOnly->setCheckable(true);
1287 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1288 collection->addAction("clip_video_only", videoOnly);
1289 videoOnly->setData("clip_video_only");
1290 videoOnly->setCheckable(true);
1292 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1293 collection->addAction("clip_audio_and_video", audioAndVideo);
1294 audioAndVideo->setData("clip_audio_and_video");
1295 audioAndVideo->setCheckable(true);
1297 m_clipTypeGroup = new QActionGroup(this);
1298 m_clipTypeGroup->addAction(audioOnly);
1299 m_clipTypeGroup->addAction(videoOnly);
1300 m_clipTypeGroup->addAction(audioAndVideo);
1301 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1302 m_clipTypeGroup->setEnabled(false);
1304 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1305 collection->addAction("insert_space", insertSpace);
1306 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1308 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1309 collection->addAction("delete_space", removeSpace);
1310 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1312 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1313 collection->addAction("insert_track", insertTrack);
1314 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1316 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1317 collection->addAction("delete_track", deleteTrack);
1318 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1320 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1321 collection->addAction("config_tracks", configTracks);
1322 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1324 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1325 collection->addAction("add_guide", addGuide);
1326 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1328 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1329 collection->addAction("delete_guide", delGuide);
1330 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1332 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1333 collection->addAction("edit_guide", editGuide);
1334 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1336 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1337 collection->addAction("delete_all_guides", delAllGuides);
1338 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1340 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1341 collection->addAction("paste_effects", pasteEffects);
1342 pasteEffects->setData("paste_effects");
1343 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1345 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1346 collection->addAction("show_timeline", showTimeline);
1347 showTimeline->setCheckable(true);
1348 showTimeline->setChecked(true);
1349 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1351 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1352 collection->addAction("show_titlebars", showTitleBar);
1353 showTitleBar->setCheckable(true);
1354 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1355 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1356 slotShowTitleBars(KdenliveSettings::showtitlebars());
1358 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1359 collection->addAction("maximize_current", maxCurrent);
1360 maxCurrent->setCheckable(true);
1361 maxCurrent->setChecked(false);
1362 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1364 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1365 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1366 KStandardAction::open(this, SLOT(openFile()), collection);
1367 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1368 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1369 KStandardAction::openNew(this, SLOT(newFile()), collection);
1370 // TODO: make the following connection to slotEditKeys work
1371 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1372 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1373 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1374 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1375 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1376 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1378 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1379 undo->setEnabled(false);
1380 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1382 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1383 redo->setEnabled(false);
1384 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1387 //TODO: Add status tooltip to actions ?
1388 connect(collection, SIGNAL(actionHovered(QAction*)),
1389 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1392 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1393 collection->addAction("add_clip", addClip);
1394 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1396 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1397 collection->addAction("add_color_clip", addColorClip);
1398 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1400 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1401 collection->addAction("add_slide_clip", addSlideClip);
1402 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1404 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1405 collection->addAction("add_text_clip", addTitleClip);
1406 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1408 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1409 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1410 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1412 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1413 collection->addAction("add_folder", addFolderButton);
1414 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1416 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1417 collection->addAction("clip_properties", clipProperties);
1418 clipProperties->setData("clip_properties");
1419 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1420 clipProperties->setEnabled(false);
1422 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1423 collection->addAction("edit_clip", openClip);
1424 openClip->setData("edit_clip");
1425 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1426 openClip->setEnabled(false);
1428 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1429 collection->addAction("delete_clip", deleteClip);
1430 deleteClip->setData("delete_clip");
1431 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1432 deleteClip->setEnabled(false);
1434 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1435 collection->addAction("reload_clip", reloadClip);
1436 reloadClip->setData("reload_clip");
1437 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1438 reloadClip->setEnabled(false);
1440 QMenu *addClips = new QMenu();
1441 addClips->addAction(addClip);
1442 addClips->addAction(addColorClip);
1443 addClips->addAction(addSlideClip);
1444 addClips->addAction(addTitleClip);
1445 addClips->addAction(addTitleTemplateClip);
1446 addClips->addAction(addFolderButton);
1448 addClips->addAction(reloadClip);
1449 addClips->addAction(clipProperties);
1450 addClips->addAction(openClip);
1451 addClips->addAction(deleteClip);
1452 m_projectList->setupMenu(addClips, addClip);
1454 // Setup effects and transitions actions.
1455 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1456 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1457 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1458 m_videoEffects = new KAction*[videoEffects.count()];
1459 for (int i = 0; i < videoEffects.count(); ++i) {
1460 QStringList effectInfo = videoEffects.effectIdInfo(i);
1461 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1462 m_videoEffects[i]->setData(effectInfo);
1463 m_videoEffects[i]->setIconVisibleInMenu(false);
1464 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1466 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1467 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1468 m_audioEffects = new KAction*[audioEffects.count()];
1469 for (int i = 0; i < audioEffects.count(); ++i) {
1470 QStringList effectInfo = audioEffects.effectIdInfo(i);
1471 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1472 m_audioEffects[i]->setData(effectInfo);
1473 m_audioEffects[i]->setIconVisibleInMenu(false);
1474 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1476 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1477 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1478 m_customEffects = new KAction*[customEffects.count()];
1479 for (int i = 0; i < customEffects.count(); ++i) {
1480 QStringList effectInfo = customEffects.effectIdInfo(i);
1481 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1482 m_customEffects[i]->setData(effectInfo);
1483 m_customEffects[i]->setIconVisibleInMenu(false);
1484 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1486 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1487 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1488 m_transitions = new KAction*[transitions.count()];
1489 for (int i = 0; i < transitions.count(); i++) {
1490 QStringList effectInfo = transitions.effectIdInfo(i);
1491 m_transitions[i] = new KAction(effectInfo.at(0), this);
1492 m_transitions[i]->setData(effectInfo);
1493 m_transitions[i]->setIconVisibleInMenu(false);
1494 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1496 m_effectsActionCollection->readSettings();
1498 //connect(collection, SIGNAL( clearStatusText() ),
1499 //statusBar(), SLOT( clear() ) );
1502 void MainWindow::slotDisplayActionMessage(QAction *a)
1504 statusBar()->showMessage(a->data().toString(), 3000);
1507 void MainWindow::saveOptions()
1509 KdenliveSettings::self()->writeConfig();
1510 KSharedConfigPtr config = KGlobal::config();
1511 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1512 KConfigGroup treecolumns(config, "Project Tree");
1513 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1517 void MainWindow::readOptions()
1519 KSharedConfigPtr config = KGlobal::config();
1520 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1521 KConfigGroup initialGroup(config, "version");
1522 bool upgrade = false;
1523 if (initialGroup.exists()) {
1524 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1528 if (initialGroup.readEntry("version") == "0.7") {
1529 //Add new settings from 0.7.1
1530 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1531 QString path = QDir::homePath() + "/kdenlive";
1532 if (KStandardDirs::makeDir(path) == false) {
1533 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1534 } else KdenliveSettings::setDefaultprojectfolder(path);
1540 if (!initialGroup.exists() || upgrade) {
1541 // this is our first run, show Wizard
1542 Wizard *w = new Wizard(upgrade, this);
1543 if (w->exec() == QDialog::Accepted && w->isOk()) {
1544 w->adjustSettings();
1545 initialGroup.writeEntry("version", version);
1551 KConfigGroup treecolumns(config, "Project Tree");
1552 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1553 if (!state.isEmpty())
1554 m_projectList->setHeaderInfo(state);
1557 void MainWindow::slotRunWizard()
1559 Wizard *w = new Wizard(false, this);
1560 if (w->exec() == QDialog::Accepted && w->isOk()) {
1561 w->adjustSettings();
1566 void MainWindow::newFile(bool showProjectSettings, bool force)
1568 if (!m_timelineArea->isEnabled() && !force) return;
1569 m_fileRevert->setEnabled(false);
1570 QString profileName;
1572 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1573 if (!showProjectSettings) {
1574 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1575 profileName = KdenliveSettings::default_profile();
1576 projectFolder = KdenliveSettings::defaultprojectfolder();
1578 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1579 if (w->exec() != QDialog::Accepted) return;
1580 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1581 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1582 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1583 profileName = w->selectedProfile();
1584 projectFolder = w->selectedFolder();
1585 projectTracks = w->tracks();
1588 m_timelineArea->setEnabled(true);
1589 m_projectList->setEnabled(true);
1590 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1591 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1593 TrackView *trackView = new TrackView(doc, &ok, this);
1594 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1597 //m_timelineArea->setEnabled(false);
1598 //m_projectList->setEnabled(false);
1602 if (m_timelineArea->count() == 1) {
1603 connectDocumentInfo(doc);
1604 connectDocument(trackView, doc);
1605 } else m_timelineArea->setTabBarHidden(false);
1606 m_monitorManager->activateMonitor("clip");
1607 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1610 void MainWindow::activateDocument()
1612 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1613 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1614 KdenliveDoc *currentDoc = currentTab->document();
1615 connectDocumentInfo(currentDoc);
1616 connectDocument(currentTab, currentDoc);
1619 void MainWindow::closeCurrentDocument(bool saveChanges)
1621 QWidget *w = m_timelineArea->currentWidget();
1623 // closing current document
1624 int ix = m_timelineArea->currentIndex() + 1;
1625 if (ix == m_timelineArea->count()) ix = 0;
1626 m_timelineArea->setCurrentIndex(ix);
1627 TrackView *tabToClose = (TrackView *) w;
1628 KdenliveDoc *docToClose = tabToClose->document();
1629 if (docToClose && docToClose->isModified() && saveChanges) {
1631 if (m_activeDocument->url().fileName().isEmpty())
1632 message = i18n("Save changes to document?");
1634 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1635 switch (KMessageBox::warningYesNoCancel(this, message)) {
1636 case KMessageBox::Yes :
1637 // save document here. If saving fails, return false;
1638 if (saveFile() == false) return;
1640 case KMessageBox::Cancel :
1647 m_clipMonitor->slotSetXml(NULL);
1648 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1649 if (m_timelineArea->count() == 1) {
1650 m_timelineArea->setTabBarHidden(true);
1651 m_closeAction->setEnabled(false);
1653 if (docToClose == m_activeDocument) {
1654 delete m_activeDocument;
1655 m_activeDocument = NULL;
1656 m_effectStack->clear();
1657 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1661 if (w == m_activeTimeline) {
1662 delete m_activeTimeline;
1663 m_activeTimeline = NULL;
1669 bool MainWindow::saveFileAs(const QString &outputFileName)
1671 QString currentSceneList;
1672 m_monitorManager->stopActiveMonitor();
1673 if (KdenliveSettings::dropbframes()) {
1674 KdenliveSettings::setDropbframes(false);
1675 m_activeDocument->clipManager()->updatePreviewSettings();
1676 currentSceneList = m_projectMonitor->sceneList();
1677 KdenliveSettings::setDropbframes(true);
1678 m_activeDocument->clipManager()->updatePreviewSettings();
1679 } else currentSceneList = m_projectMonitor->sceneList();
1681 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1684 // Save timeline thumbnails
1685 m_activeTimeline->projectView()->saveThumbnails();
1686 m_activeDocument->setUrl(KUrl(outputFileName));
1687 if (m_activeDocument->m_autosave == NULL) {
1688 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1689 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1690 setCaption(m_activeDocument->description());
1691 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1692 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1693 m_activeDocument->setModified(false);
1694 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1695 m_fileRevert->setEnabled(true);
1699 bool MainWindow::saveFileAs()
1701 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1702 if (outputFile.isEmpty()) {
1705 if (QFile::exists(outputFile)) {
1706 // Show the file dialog again if the user does not want to overwrite the file
1707 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1708 return saveFileAs();
1710 return saveFileAs(outputFile);
1713 bool MainWindow::saveFile()
1715 if (!m_activeDocument) return true;
1716 if (m_activeDocument->url().isEmpty()) {
1717 return saveFileAs();
1719 bool result = saveFileAs(m_activeDocument->url().path());
1720 m_activeDocument->m_autosave->resize(0);
1725 void MainWindow::openFile()
1727 if (!m_startUrl.isEmpty()) {
1728 openFile(m_startUrl);
1729 m_startUrl = KUrl();
1732 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1733 if (url.isEmpty()) return;
1734 m_fileOpenRecent->addUrl(url);
1738 void MainWindow::openLastFile()
1740 KSharedConfigPtr config = KGlobal::config();
1741 KUrl::List urls = m_fileOpenRecent->urls();
1742 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1743 if (urls.isEmpty()) newFile(false);
1744 else openFile(urls.last());
1747 void MainWindow::openFile(const KUrl &url)
1749 // Check if the document is already opened
1750 const int ct = m_timelineArea->count();
1751 bool isOpened = false;
1753 for (i = 0; i < ct; i++) {
1754 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1755 KdenliveDoc *doc = tab->document();
1756 if (doc->url() == url) {
1762 m_timelineArea->setCurrentIndex(i);
1766 // Check for backup file
1767 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1768 if (!staleFiles.isEmpty()) {
1769 if (KMessageBox::questionYesNo(this,
1770 i18n("Auto-saved files exist. Do you want to recover them now?"),
1771 i18n("File Recovery"),
1772 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1773 recoverFiles(staleFiles);
1776 // remove the stale files
1777 foreach(KAutoSaveFile *stale, staleFiles) {
1778 stale->open(QIODevice::ReadWrite);
1783 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1784 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1785 m_messageLabel->repaint();
1786 doOpenFile(url, NULL);
1789 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1791 if (!m_timelineArea->isEnabled()) return;
1792 m_fileRevert->setEnabled(true);
1793 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1794 if (stale == NULL) {
1795 stale = new KAutoSaveFile(url, doc);
1796 doc->m_autosave = stale;
1798 doc->m_autosave = stale;
1799 doc->setUrl(stale->managedFile());
1800 doc->setModified(true);
1801 stale->setParent(doc);
1803 connectDocumentInfo(doc);
1805 TrackView *trackView = new TrackView(doc, &ok, this);
1806 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1808 m_timelineArea->setEnabled(false);
1809 m_projectList->setEnabled(false);
1810 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1811 slotGotProgressInfo(QString(), -1);
1812 newFile(false, true);
1815 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1816 trackView->setDuration(trackView->duration());
1817 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1819 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1820 slotGotProgressInfo(QString(), -1);
1821 m_projectMonitor->adjustRulerSize(trackView->duration());
1822 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1823 m_clipMonitor->refreshMonitor(true);
1826 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1828 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1829 foreach(KAutoSaveFile *stale, staleFiles) {
1830 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1831 // show an error message; we could not steal the lockfile
1832 // maybe another application got to the file before us?
1836 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1837 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1838 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1839 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1843 void MainWindow::parseProfiles(const QString &mltPath)
1845 //KdenliveSettings::setDefaulttmpfolder();
1846 if (!mltPath.isEmpty()) {
1847 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1848 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1851 if (KdenliveSettings::mltpath().isEmpty())
1852 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1854 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1855 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1856 if (!QFile::exists(meltPath))
1857 meltPath = KStandardDirs::findExe("melt");
1858 KdenliveSettings::setRendererpath(meltPath);
1861 if (KdenliveSettings::rendererpath().isEmpty()) {
1862 // Cannot find the MLT melt renderer, ask for location
1863 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1864 if (getUrl->exec() == QDialog::Rejected) {
1867 KUrl rendererPath = getUrl->selectedUrl();
1869 if (rendererPath.isEmpty()) ::exit(0);
1870 KdenliveSettings::setRendererpath(rendererPath.path());
1873 QStringList profilesFilter;
1874 profilesFilter << "*";
1875 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1876 if (profilesList.isEmpty()) {
1877 // Cannot find MLT path, try finding melt
1878 QString profilePath = KdenliveSettings::rendererpath();
1879 if (!profilePath.isEmpty()) {
1880 profilePath = profilePath.section('/', 0, -3);
1881 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1882 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1884 if (profilesList.isEmpty()) {
1885 // Cannot find the MLT profiles, ask for location
1886 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1887 getUrl->fileDialog()->setMode(KFile::Directory);
1888 if (getUrl->exec() == QDialog::Rejected) {
1891 KUrl mltPath = getUrl->selectedUrl();
1893 if (mltPath.isEmpty()) ::exit(0);
1894 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1895 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1899 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1901 // Parse again MLT profiles to build a list of available video formats
1902 if (profilesList.isEmpty()) parseProfiles();
1906 void MainWindow::slotEditProfiles()
1908 ProfilesDialog *w = new ProfilesDialog;
1909 if (w->exec() == QDialog::Accepted) {
1910 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1911 if (d) d->checkProfile();
1916 void MainWindow::slotDetectAudioDriver()
1918 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1919 leading to no audio output, see bug #934 */
1921 //decide which audio driver is really best, in some cases SDL is wrong
1922 if (KdenliveSettings::audiodrivername().isEmpty()) {
1924 KProcess readProcess;
1925 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1926 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1927 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1928 readProcess.setProgram("pactl", QStringList() << "stat");
1929 readProcess.execute(2000); // Kill it after 2 seconds
1931 QString result = QString(readProcess.readAllStandardOutput());
1932 kDebug() << "// / / / / / READING PACTL: ";
1934 if (!result.isEmpty()) {
1936 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1940 KdenliveSettings::setAutoaudiodrivername(driver);
1944 void MainWindow::slotEditProjectSettings()
1946 QPoint p = m_activeDocument->getTracksCount();
1947 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1949 if (w->exec() == QDialog::Accepted) {
1950 QString profile = w->selectedProfile();
1951 m_activeDocument->setProjectFolder(w->selectedFolder());
1952 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1953 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1954 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1955 if (m_activeDocument->profilePath() != profile) {
1956 // Profile was changed
1957 double dar = m_activeDocument->dar();
1959 // Deselect current effect / transition
1960 m_effectStack->slotClipItemSelected(NULL, 0);
1961 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1962 m_clipMonitor->slotSetXml(NULL);
1963 bool updateFps = m_activeDocument->setProfilePath(profile);
1964 KdenliveSettings::setCurrent_profile(profile);
1965 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1966 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1968 m_activeDocument->clipManager()->clearUnusedProducers();
1969 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1971 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1972 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1973 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1974 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1975 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1976 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1977 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1978 if (updateFps) m_activeTimeline->updateProjectFps();
1979 m_activeDocument->setModified(true);
1980 m_commandStack->activeStack()->clear();
1981 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1982 slotUpdateMousePosition(0);
1983 // We need to desactivate & reactivate monitors to get a refresh
1984 //m_monitorManager->switchMonitors();
1991 void MainWindow::slotRenderProject()
1993 if (!m_renderWidget) {
1994 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1995 m_renderWidget = new RenderWidget(projectfolder, this);
1996 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1997 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
1998 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1999 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2000 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2001 if (m_activeDocument) {
2002 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2003 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2004 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2005 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2008 slotCheckRenderStatus();
2009 m_renderWidget->show();
2010 m_renderWidget->showNormal();
2012 // What are the following lines supposed to do?
2013 //m_activeTimeline->tracksNumber();
2014 //m_renderWidget->enableAudio(false);
2015 //m_renderWidget->export_audio;
2018 void MainWindow::slotCheckRenderStatus()
2020 // Make sure there are no missing clips
2022 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2025 void MainWindow::setRenderingProgress(const QString &url, int progress)
2028 m_renderWidget->setRenderJob(url, progress);
2031 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2034 m_renderWidget->setRenderStatus(url, status, error);
2037 void MainWindow::slotCleanProject()
2039 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2040 m_projectList->cleanup();
2043 void MainWindow::slotUpdateMousePosition(int pos)
2045 if (m_activeDocument)
2046 switch (m_timecodeFormat->currentIndex()) {
2048 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2051 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2055 void MainWindow::slotUpdateDocumentState(bool modified)
2057 if (!m_activeDocument) return;
2058 setCaption(m_activeDocument->description(), modified);
2059 m_saveAction->setEnabled(modified);
2061 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2062 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2064 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2065 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2069 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2071 if (m_activeDocument) {
2072 if (m_activeDocument == doc) return;
2073 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2075 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2078 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2080 //m_projectMonitor->stop();
2081 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2082 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2083 if (m_activeDocument) {
2084 if (m_activeDocument == doc) return;
2085 if (m_activeTimeline) {
2086 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2087 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2088 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2089 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2090 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2091 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2092 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2094 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2095 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2096 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2097 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2098 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2099 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2100 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2101 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2102 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2103 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2104 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2105 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2106 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2107 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2108 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2109 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2110 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2111 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2112 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2113 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2114 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2115 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2116 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2117 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2118 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2119 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2120 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2121 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2122 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2123 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2124 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2125 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2126 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2127 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2128 m_effectStack->clear();
2130 //m_activeDocument->setRenderer(NULL);
2131 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2132 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2133 m_clipMonitor->stop();
2135 KdenliveSettings::setCurrent_profile(doc->profilePath());
2136 KdenliveSettings::setProject_fps(doc->fps());
2137 m_monitorManager->resetProfiles(doc->timecode());
2138 m_projectList->setDocument(doc);
2139 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2140 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2141 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2142 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2143 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2145 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2146 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2148 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2151 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2152 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2153 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2154 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2155 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2156 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2157 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2158 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2159 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2160 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2161 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2162 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2163 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2164 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2166 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2167 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2168 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2169 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2170 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2172 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2173 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2174 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2177 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2178 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2179 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2180 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2182 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2183 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2184 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2185 m_zoomSlider->setValue(doc->zoom().x());
2186 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2187 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2188 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2189 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2191 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2192 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2195 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2196 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2197 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2198 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2199 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2200 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2201 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2202 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2203 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2204 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2205 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2207 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2208 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2209 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2210 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2211 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2214 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2215 m_activeTimeline = trackView;
2216 if (m_renderWidget) {
2217 slotCheckRenderStatus();
2218 m_renderWidget->setProfile(doc->mltProfile());
2219 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2220 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2221 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2223 //doc->setRenderer(m_projectMonitor->render);
2224 m_commandStack->setActiveStack(doc->commandStack());
2225 KdenliveSettings::setProject_display_ratio(doc->dar());
2226 //doc->clipManager()->checkAudioThumbs();
2228 //m_overView->setScene(trackView->projectScene());
2229 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2230 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2232 setCaption(doc->description(), doc->isModified());
2233 m_saveAction->setEnabled(doc->isModified());
2234 m_normalEditTool->setChecked(true);
2235 m_activeDocument = doc;
2236 m_activeTimeline->updateProjectFps();
2237 m_activeDocument->checkProjectClips();
2238 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2239 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2240 slotUpdateMousePosition(0);
2241 // set tool to select tool
2242 m_buttonSelectTool->setChecked(true);
2245 void MainWindow::slotZoneMoved(int start, int end)
2247 m_activeDocument->setZone(start, end);
2248 m_projectMonitor->slotZoneMoved(start, end);
2251 void MainWindow::slotGuidesUpdated()
2254 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2257 void MainWindow::slotEditKeys()
2259 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2260 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2261 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2265 void MainWindow::slotPreferences(int page, int option)
2267 //An instance of your dialog could be already created and could be
2268 // cached, in which case you want to display the cached dialog
2269 // instead of creating another one
2270 if (KConfigDialog::showDialog("settings")) {
2271 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2272 if (page != -1) d->showPage(page, option);
2276 // KConfigDialog didn't find an instance of this dialog, so lets
2278 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2279 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2280 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2281 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2282 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2284 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2286 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2288 if (page != -1) dialog->showPage(page, option);
2291 void MainWindow::slotUpdatePreviewSettings()
2293 if (m_activeDocument) {
2294 m_clipMonitor->slotSetXml(NULL);
2295 m_activeDocument->updatePreviewSettings();
2299 void MainWindow::updateConfiguration()
2301 //TODO: we should apply settings to all projects, not only the current one
2302 if (m_activeTimeline) {
2303 m_activeTimeline->refresh();
2304 m_activeTimeline->projectView()->checkAutoScroll();
2305 m_activeTimeline->projectView()->checkTrackHeight();
2306 if (m_activeDocument)
2307 m_activeDocument->clipManager()->checkAudioThumbs();
2309 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2310 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2311 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2312 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2314 // Update list of transcoding profiles
2316 #ifndef NO_JOGSHUTTLE
2317 activateShuttleDevice();
2318 #endif /* NO_JOGSHUTTLE */
2322 void MainWindow::slotSwitchSplitAudio()
2324 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2325 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2328 void MainWindow::slotSwitchVideoThumbs()
2330 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2331 if (m_activeTimeline)
2332 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2333 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2336 void MainWindow::slotSwitchAudioThumbs()
2338 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2339 if (m_activeTimeline) {
2340 m_activeTimeline->refresh();
2341 m_activeTimeline->projectView()->checkAutoScroll();
2342 if (m_activeDocument)
2343 m_activeDocument->clipManager()->checkAudioThumbs();
2345 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2348 void MainWindow::slotSwitchMarkersComments()
2350 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2351 if (m_activeTimeline)
2352 m_activeTimeline->refresh();
2353 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2356 void MainWindow::slotSwitchSnap()
2358 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2359 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2363 void MainWindow::slotDeleteItem()
2365 if (QApplication::focusWidget() &&
2366 QApplication::focusWidget()->parentWidget() &&
2367 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2368 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2369 m_projectList->slotRemoveClip();
2372 QWidget *widget = QApplication::focusWidget();
2374 if (widget == m_effectStackDock) {
2375 m_effectStack->slotItemDel();
2378 widget = widget->parentWidget();
2381 // effect stack has no focus
2382 if (m_activeTimeline)
2383 m_activeTimeline->projectView()->deleteSelectedClips();
2387 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2389 if (m_clipMonitor->isActive())
2390 m_clipMonitor->checkOverlay();
2391 m_clipMonitor->updateMarkers(clip);
2394 void MainWindow::slotAddClipMarker()
2396 DocClipBase *clip = NULL;
2398 if (m_projectMonitor->isActive()) {
2399 if (m_activeTimeline) {
2400 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2402 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2403 clip = item->baseClip();
2407 clip = m_clipMonitor->activeClip();
2408 pos = m_clipMonitor->position();
2411 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2414 QString id = clip->getId();
2415 CommentedTime marker(pos, i18n("Marker"));
2416 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2417 if (d.exec() == QDialog::Accepted)
2418 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2421 void MainWindow::slotDeleteClipMarker()
2423 DocClipBase *clip = NULL;
2425 if (m_projectMonitor->isActive()) {
2426 if (m_activeTimeline) {
2427 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2429 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2430 clip = item->baseClip();
2434 clip = m_clipMonitor->activeClip();
2435 pos = m_clipMonitor->position();
2438 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2442 QString id = clip->getId();
2443 QString comment = clip->markerComment(pos);
2444 if (comment.isEmpty()) {
2445 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2448 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2451 void MainWindow::slotDeleteAllClipMarkers()
2453 DocClipBase *clip = NULL;
2454 if (m_projectMonitor->isActive()) {
2455 if (m_activeTimeline) {
2456 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2458 clip = item->baseClip();
2462 clip = m_clipMonitor->activeClip();
2465 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2468 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2471 void MainWindow::slotEditClipMarker()
2473 DocClipBase *clip = NULL;
2475 if (m_projectMonitor->isActive()) {
2476 if (m_activeTimeline) {
2477 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2479 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2480 clip = item->baseClip();
2484 clip = m_clipMonitor->activeClip();
2485 pos = m_clipMonitor->position();
2488 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2492 QString id = clip->getId();
2493 QString oldcomment = clip->markerComment(pos);
2494 if (oldcomment.isEmpty()) {
2495 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2499 CommentedTime marker(pos, oldcomment);
2500 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2501 if (d.exec() == QDialog::Accepted) {
2502 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2503 if (d.newMarker().time() != pos) {
2504 // remove old marker
2505 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2510 void MainWindow::slotAddGuide()
2512 if (m_activeTimeline)
2513 m_activeTimeline->projectView()->slotAddGuide();
2516 void MainWindow::slotInsertSpace()
2518 if (m_activeTimeline)
2519 m_activeTimeline->projectView()->slotInsertSpace();
2522 void MainWindow::slotRemoveSpace()
2524 if (m_activeTimeline)
2525 m_activeTimeline->projectView()->slotRemoveSpace();
2528 void MainWindow::slotInsertTrack(int ix)
2530 m_projectMonitor->activateMonitor();
2531 if (m_activeTimeline)
2532 m_activeTimeline->projectView()->slotInsertTrack(ix);
2533 if (m_activeDocument)
2534 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2537 void MainWindow::slotDeleteTrack(int ix)
2539 m_projectMonitor->activateMonitor();
2540 if (m_activeTimeline)
2541 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2542 if (m_activeDocument)
2543 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2546 void MainWindow::slotConfigTrack(int ix)
2548 m_projectMonitor->activateMonitor();
2549 if (m_activeTimeline)
2550 m_activeTimeline->projectView()->slotConfigTracks(ix);
2551 if (m_activeDocument)
2552 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2555 void MainWindow::slotEditGuide()
2557 if (m_activeTimeline)
2558 m_activeTimeline->projectView()->slotEditGuide();
2561 void MainWindow::slotDeleteGuide()
2563 if (m_activeTimeline)
2564 m_activeTimeline->projectView()->slotDeleteGuide();
2567 void MainWindow::slotDeleteAllGuides()
2569 if (m_activeTimeline)
2570 m_activeTimeline->projectView()->slotDeleteAllGuides();
2573 void MainWindow::slotCutTimelineClip()
2575 if (m_activeTimeline)
2576 m_activeTimeline->projectView()->cutSelectedClips();
2579 void MainWindow::slotInsertClipOverwrite()
2581 if (m_activeTimeline) {
2582 QStringList data = m_clipMonitor->getZoneInfo();
2583 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2587 void MainWindow::slotSelectTimelineClip()
2589 if (m_activeTimeline)
2590 m_activeTimeline->projectView()->selectClip(true);
2593 void MainWindow::slotSelectTimelineTransition()
2595 if (m_activeTimeline)
2596 m_activeTimeline->projectView()->selectTransition(true);
2599 void MainWindow::slotDeselectTimelineClip()
2601 if (m_activeTimeline)
2602 m_activeTimeline->projectView()->selectClip(false, true);
2605 void MainWindow::slotDeselectTimelineTransition()
2607 if (m_activeTimeline)
2608 m_activeTimeline->projectView()->selectTransition(false, true);
2611 void MainWindow::slotSelectAddTimelineClip()
2613 if (m_activeTimeline)
2614 m_activeTimeline->projectView()->selectClip(true, true);
2617 void MainWindow::slotSelectAddTimelineTransition()
2619 if (m_activeTimeline)
2620 m_activeTimeline->projectView()->selectTransition(true, true);
2623 void MainWindow::slotGroupClips()
2625 if (m_activeTimeline)
2626 m_activeTimeline->projectView()->groupClips();
2629 void MainWindow::slotUnGroupClips()
2631 if (m_activeTimeline)
2632 m_activeTimeline->projectView()->groupClips(false);
2635 void MainWindow::slotEditItemDuration()
2637 if (m_activeTimeline)
2638 m_activeTimeline->projectView()->editItemDuration();
2641 void MainWindow::slotAddProjectClip(KUrl url)
2643 if (m_activeDocument)
2644 m_activeDocument->slotAddClipFile(url, QString());
2647 void MainWindow::slotAddTransition(QAction *result)
2649 if (!result) return;
2650 QStringList info = result->data().toStringList();
2651 if (info.isEmpty()) return;
2652 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2653 if (m_activeTimeline && !transition.isNull()) {
2654 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2658 void MainWindow::slotAddVideoEffect(QAction *result)
2660 if (!result) return;
2661 QStringList info = result->data().toStringList();
2662 if (info.isEmpty()) return;
2663 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2664 slotAddEffect(effect);
2667 void MainWindow::slotAddAudioEffect(QAction *result)
2669 if (!result) return;
2670 QStringList info = result->data().toStringList();
2671 if (info.isEmpty()) return;
2672 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2673 slotAddEffect(effect);
2676 void MainWindow::slotAddCustomEffect(QAction *result)
2678 if (!result) return;
2679 QStringList info = result->data().toStringList();
2680 if (info.isEmpty()) return;
2681 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2682 slotAddEffect(effect);
2685 void MainWindow::slotZoomIn()
2687 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2688 slotShowZoomSliderToolTip();
2691 void MainWindow::slotZoomOut()
2693 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2694 slotShowZoomSliderToolTip();
2697 void MainWindow::slotFitZoom()
2699 if (m_activeTimeline)
2700 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2703 void MainWindow::slotSetZoom(int value)
2705 if (m_activeTimeline)
2706 m_activeTimeline->slotChangeZoom(value);
2708 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2709 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2710 slotUpdateZoomSliderToolTip(value);
2712 m_zoomSlider->blockSignals(true);
2713 m_zoomSlider->setValue(value);
2714 m_zoomSlider->blockSignals(false);
2717 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2719 if (zoomlevel != -1)
2720 slotUpdateZoomSliderToolTip(zoomlevel);
2722 QPoint global = m_zoomSlider->rect().topLeft();
2723 global.ry() += m_zoomSlider->height() / 2;
2724 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2725 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2728 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2730 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2733 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2735 m_statusProgressBar->setValue(progress);
2736 if (progress >= 0) {
2737 if (!message.isEmpty())
2738 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2739 m_statusProgressBar->setVisible(true);
2740 } else if (progress == -2) {
2741 if (!message.isEmpty())
2742 m_messageLabel->setMessage(message, ErrorMessage);
2743 m_statusProgressBar->setVisible(false);
2745 m_messageLabel->setMessage(QString(), DefaultMessage);
2746 m_statusProgressBar->setVisible(false);
2750 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2752 if (clip->clipType() == TEXT) {
2753 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2754 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2755 // template text clip
2757 // Get the list of existing templates
2759 filter << "*.kdenlivetitle";
2760 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2762 QDialog *dia = new QDialog(this);
2763 Ui::TemplateClip_UI dia_ui;
2764 dia_ui.setupUi(dia);
2766 const QString templatePath = clip->getProperty("resource");
2767 for (int i = 0; i < templateFiles.size(); ++i) {
2768 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2769 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2771 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2772 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2773 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2774 //warning: setting base directory doesn't work??
2775 KUrl startDir(titlepath);
2776 dia_ui.template_list->fileDialog()->setUrl(startDir);
2777 dia_ui.description->setText(clip->getProperty("description"));
2778 if (dia->exec() == QDialog::Accepted) {
2779 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2780 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2782 QMap <QString, QString> newprops;
2784 if (KUrl(textTemplate).path() != templatePath) {
2785 // The template was changed
2786 newprops.insert("resource", textTemplate);
2789 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2790 newprops.insert("description", dia_ui.description->toPlainText());
2793 QString newtemplate = newprops.value("xmltemplate");
2794 if (newtemplate.isEmpty()) newtemplate = templatePath;
2796 // template modified we need to update xmldata
2797 QString description = newprops.value("description");
2798 if (description.isEmpty()) description = clip->getProperty("description");
2799 else newprops.insert("templatetext", description);
2800 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2801 if (!newprops.isEmpty()) {
2802 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2803 m_activeDocument->commandStack()->push(command);
2809 QString path = clip->getProperty("resource");
2810 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2812 doc.setContent(clip->getProperty("xmldata"));
2813 dia_ui->setXml(doc);
2814 if (dia_ui->exec() == QDialog::Accepted) {
2815 QMap <QString, QString> newprops;
2816 newprops.insert("xmldata", dia_ui->xml().toString());
2817 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2818 // duration changed, we need to update duration
2819 newprops.insert("out", QString::number(dia_ui->outPoint()));
2821 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2822 m_activeDocument->commandStack()->push(command);
2823 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2824 m_activeDocument->setModified(true);
2828 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2831 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2832 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2833 if (dia.exec() == QDialog::Accepted) {
2834 QMap <QString, QString> newprops = dia.properties();
2835 if (newprops.isEmpty()) return;
2836 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2837 m_activeDocument->commandStack()->push(command);
2839 if (dia.needsTimelineRefresh()) {
2840 // update clip occurences in timeline
2841 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2847 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2849 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2850 if (dia.exec() == QDialog::Accepted) {
2851 QUndoCommand *command = new QUndoCommand();
2852 command->setText(i18n("Edit clips"));
2853 for (int i = 0; i < cliplist.count(); i++) {
2854 DocClipBase *clip = cliplist.at(i);
2855 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2857 m_activeDocument->commandStack()->push(command);
2858 for (int i = 0; i < cliplist.count(); i++)
2859 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2863 void MainWindow::customEvent(QEvent* e)
2865 if (e->type() == QEvent::User)
2866 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2868 void MainWindow::slotActivateEffectStackView()
2870 m_effectStack->raiseWindow(m_effectStackDock);
2873 void MainWindow::slotActivateTransitionView(Transition *t)
2876 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2879 void MainWindow::slotSnapRewind()
2881 if (m_projectMonitor->isActive()) {
2882 if (m_activeTimeline)
2883 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2885 m_clipMonitor->slotSeekToPreviousSnap();
2889 void MainWindow::slotSnapForward()
2891 if (m_projectMonitor->isActive()) {
2892 if (m_activeTimeline)
2893 m_activeTimeline->projectView()->slotSeekToNextSnap();
2895 m_clipMonitor->slotSeekToNextSnap();
2899 void MainWindow::slotClipStart()
2901 if (m_projectMonitor->isActive()) {
2902 if (m_activeTimeline)
2903 m_activeTimeline->projectView()->clipStart();
2907 void MainWindow::slotClipEnd()
2909 if (m_projectMonitor->isActive()) {
2910 if (m_activeTimeline)
2911 m_activeTimeline->projectView()->clipEnd();
2915 void MainWindow::slotZoneStart()
2917 if (m_projectMonitor->isActive())
2918 m_projectMonitor->slotZoneStart();
2920 m_clipMonitor->slotZoneStart();
2923 void MainWindow::slotZoneEnd()
2925 if (m_projectMonitor->isActive())
2926 m_projectMonitor->slotZoneEnd();
2928 m_clipMonitor->slotZoneEnd();
2931 void MainWindow::slotChangeTool(QAction * action)
2933 if (action == m_buttonSelectTool)
2934 slotSetTool(SELECTTOOL);
2935 else if (action == m_buttonRazorTool)
2936 slotSetTool(RAZORTOOL);
2937 else if (action == m_buttonSpacerTool)
2938 slotSetTool(SPACERTOOL);
2941 void MainWindow::slotChangeEdit(QAction * action)
2943 if (!m_activeTimeline)
2946 if (action == m_overwriteEditTool)
2947 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2948 else if (action == m_insertEditTool)
2949 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2951 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2954 void MainWindow::slotSetTool(PROJECTTOOL tool)
2956 if (m_activeDocument && m_activeTimeline) {
2957 //m_activeDocument->setTool(tool);
2961 message = i18n("Ctrl + click to use spacer on current track only");
2964 message = i18n("Click on a clip to cut it");
2967 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2970 m_messageLabel->setMessage(message, InformationMessage);
2971 m_activeTimeline->projectView()->setTool(tool);
2975 void MainWindow::slotCopy()
2977 if (m_activeDocument && m_activeTimeline)
2978 m_activeTimeline->projectView()->copyClip();
2981 void MainWindow::slotPaste()
2983 if (m_activeDocument && m_activeTimeline)
2984 m_activeTimeline->projectView()->pasteClip();
2987 void MainWindow::slotPasteEffects()
2989 if (m_activeDocument && m_activeTimeline)
2990 m_activeTimeline->projectView()->pasteClipEffects();
2993 void MainWindow::slotFind()
2995 if (!m_activeDocument || !m_activeTimeline) return;
2996 m_projectSearch->setEnabled(false);
2997 m_findActivated = true;
2998 m_findString.clear();
2999 m_activeTimeline->projectView()->initSearchStrings();
3000 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3001 m_findTimer.start(5000);
3002 qApp->installEventFilter(this);
3005 void MainWindow::slotFindNext()
3007 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3008 statusBar()->showMessage(i18n("Found: %1", m_findString));
3010 statusBar()->showMessage(i18n("Reached end of project"));
3011 m_findTimer.start(4000);
3014 void MainWindow::findAhead()
3016 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3017 m_projectSearchNext->setEnabled(true);
3018 statusBar()->showMessage(i18n("Found: %1", m_findString));
3020 m_projectSearchNext->setEnabled(false);
3021 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3025 void MainWindow::findTimeout()
3027 m_projectSearchNext->setEnabled(false);
3028 m_findActivated = false;
3029 m_findString.clear();
3030 statusBar()->showMessage(i18n("Find stopped"), 3000);
3031 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3032 m_projectSearch->setEnabled(true);
3033 removeEventFilter(this);
3036 void MainWindow::slotClipInTimeline(const QString &clipId)
3038 if (m_activeTimeline && m_activeDocument) {
3039 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3041 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3042 inTimelineMenu->clear();
3044 QList <QAction *> actionList;
3046 for (int i = 0; i < matching.count(); ++i) {
3047 QString track = QString::number(matching.at(i).track);
3048 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3050 QAction *a = new QAction(track + ": " + start, this);
3051 a->setData(QStringList() << track << start);
3052 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3053 while (j < actionList.count()) {
3054 if (actionList.at(j)->text() > a->text()) break;
3057 actionList.insert(j, a);
3059 inTimelineMenu->addActions(actionList);
3061 if (matching.empty())
3062 inTimelineMenu->setEnabled(false);
3064 inTimelineMenu->setEnabled(true);
3068 void MainWindow::slotClipInProjectTree()
3070 if (m_activeTimeline) {
3071 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3072 if (clipIds.isEmpty())
3074 m_projectListDock->raise();
3075 for (int i = 0; i < clipIds.count(); i++)
3076 m_projectList->selectItemById(clipIds.at(i));
3077 if (m_projectMonitor->isActive())
3078 slotSwitchMonitors();
3082 /*void MainWindow::slotClipToProjectTree()
3084 if (m_activeTimeline) {
3085 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3086 if (clips.isEmpty()) return;
3087 for (int i = 0; i < clips.count(); i++) {
3088 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3090 //m_projectList->selectItemById(clipIds.at(i));
3094 void MainWindow::slotSelectClipInTimeline()
3096 if (m_activeTimeline) {
3097 QAction *action = qobject_cast<QAction *>(sender());
3098 QStringList data = action->data().toStringList();
3099 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3103 void MainWindow::keyPressEvent(QKeyEvent *ke)
3105 if (m_findActivated) {
3106 if (ke->key() == Qt::Key_Backspace) {
3107 m_findString = m_findString.left(m_findString.length() - 1);
3109 if (!m_findString.isEmpty())
3114 m_findTimer.start(4000);
3117 } else if (ke->key() == Qt::Key_Escape) {
3121 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3122 m_findString += ke->text();
3126 m_findTimer.start(4000);
3131 KXmlGuiWindow::keyPressEvent(ke);
3136 /** Gets called when the window gets hidden */
3137 void MainWindow::hideEvent(QHideEvent */*event*/)
3140 if (m_monitorManager)
3141 m_monitorManager->stopActiveMonitor();
3144 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3146 if (m_findActivated) {
3147 if (event->type() == QEvent::ShortcutOverride) {
3148 QKeyEvent* ke = (QKeyEvent*) event;
3149 if (ke->text().trimmed().isEmpty()) return false;
3156 // pass the event on to the parent class
3157 return QMainWindow::eventFilter(obj, event);
3162 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3164 KDialog *dialog = new KDialog(this);
3165 dialog->setCaption("Save clip zone");
3166 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3168 QWidget *widget = new QWidget(dialog);
3169 dialog->setMainWidget(widget);
3171 QVBoxLayout *vbox = new QVBoxLayout(widget);
3172 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3173 QString path = m_activeDocument->projectFolder().path();
3175 path.append("untitled.mlt");
3176 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3177 url->setFilter("video/mlt-playlist");
3178 QLabel *label2 = new QLabel(i18n("Description:"), this);
3179 KLineEdit *edit = new KLineEdit(this);
3180 vbox->addWidget(label1);
3181 vbox->addWidget(url);
3182 vbox->addWidget(label2);
3183 vbox->addWidget(edit);
3184 if (dialog->exec() == QDialog::Accepted)
3185 render->saveZone(url->url(), edit->text(), zone);
3189 void MainWindow::slotSetInPoint()
3191 if (m_clipMonitor->isActive())
3192 m_clipMonitor->slotSetZoneStart();
3194 m_projectMonitor->slotSetZoneStart();
3195 //else m_activeTimeline->projectView()->setInPoint();
3198 void MainWindow::slotSetOutPoint()
3200 if (m_clipMonitor->isActive())
3201 m_clipMonitor->slotSetZoneEnd();
3203 m_projectMonitor->slotSetZoneEnd();
3204 // else m_activeTimeline->projectView()->setOutPoint();
3207 void MainWindow::slotResizeItemStart()
3209 if (m_activeTimeline)
3210 m_activeTimeline->projectView()->setInPoint();
3213 void MainWindow::slotResizeItemEnd()
3215 if (m_activeTimeline)
3216 m_activeTimeline->projectView()->setOutPoint();
3219 int MainWindow::getNewStuff(const QString &configFile)
3221 KNS3::Entry::List entries;
3222 #if KDE_IS_VERSION(4,3,80)
3223 KNS3::DownloadDialog dialog(configFile);
3225 entries = dialog.changedEntries();
3226 foreach(const KNS3::Entry &entry, entries) {
3227 if (entry.status() == KNS3::Entry::Installed)
3228 kDebug() << "// Installed files: " << entry.installedFiles();
3231 KNS::Engine engine(0);
3232 if (engine.init(configFile))
3233 entries = engine.downloadDialogModal(this);
3234 foreach(KNS::Entry *entry, entries) {
3235 if (entry->status() == KNS::Entry::Installed)
3236 kDebug() << "// Installed files: " << entry->installedFiles();
3238 #endif /* KDE_IS_VERSION(4,3,80) */
3239 return entries.size();
3242 void MainWindow::slotGetNewTitleStuff()
3244 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3245 TitleWidget::refreshTitleTemplates();
3248 void MainWindow::slotGetNewLumaStuff()
3250 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3251 initEffects::refreshLumas();
3252 m_activeTimeline->projectView()->reloadTransitionLumas();
3256 void MainWindow::slotGetNewRenderStuff()
3258 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3260 m_renderWidget->reloadProfiles();
3263 void MainWindow::slotGetNewMltProfileStuff()
3265 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3266 // update the list of profiles in settings dialog
3267 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3273 void MainWindow::slotAutoTransition()
3275 if (m_activeTimeline)
3276 m_activeTimeline->projectView()->autoTransition();
3279 void MainWindow::slotSplitAudio()
3281 if (m_activeTimeline)
3282 m_activeTimeline->projectView()->splitAudio();
3285 void MainWindow::slotUpdateClipType(QAction *action)
3287 if (m_activeTimeline) {
3288 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3289 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3290 else m_activeTimeline->projectView()->setAudioAndVideo();
3294 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3296 // We must stop the monitors since we create a new on in the dvd wizard
3297 m_clipMonitor->stop();
3298 m_projectMonitor->stop();
3299 DvdWizard w(url, profile, this);
3301 m_projectMonitor->start();
3304 void MainWindow::slotShowTimeline(bool show)
3306 if (show == false) {
3307 m_timelineState = saveState();
3308 centralWidget()->setHidden(true);
3310 centralWidget()->setHidden(false);
3311 restoreState(m_timelineState);
3315 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3317 //TODO: is there a way to maximize current widget?
3320 m_timelineState = saveState();
3321 QWidget *par = focusWidget()->parentWidget();
3322 while (par->parentWidget() && par->parentWidget() != this)
3323 par = par->parentWidget();
3324 kDebug() << "CURRENT WIDGET: " << par->objectName();
3327 //centralWidget()->setHidden(false);
3328 //restoreState(m_timelineState);
3332 void MainWindow::loadTranscoders()
3334 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3337 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3338 KConfigGroup transConfig(config, "Transcoding");
3340 QMap< QString, QString > profiles = transConfig.entryMap();
3341 QMapIterator<QString, QString> i(profiles);
3342 while (i.hasNext()) {
3344 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3345 QAction *a = transMenu->addAction(i.key());
3347 if (data.count() > 1)
3348 a->setToolTip(data.at(1));
3349 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3353 void MainWindow::slotTranscode(KUrl::List urls)
3358 if (urls.isEmpty()) {
3359 QAction *action = qobject_cast<QAction *>(sender());
3360 QStringList data = action->data().toStringList();
3361 params = data.at(0);
3362 if (data.count() > 1) desc = data.at(1);
3363 if (data.count() > 2) condition = data.at(2);
3364 urls << m_projectList->getConditionalUrls(condition);
3365 urls.removeAll(KUrl());
3367 if (urls.isEmpty()) {
3368 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3371 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3372 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3374 //QProcess::startDetached("ffmpeg", parameters);
3377 void MainWindow::slotTranscodeClip()
3379 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3380 if (urls.isEmpty()) return;
3381 slotTranscode(urls);
3384 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3386 if (m_activeDocument == NULL) return;
3387 QMapIterator<QString, QString> i(props);
3388 while (i.hasNext()) {
3390 m_activeDocument->setDocumentProperty(i.key(), i.value());
3392 m_activeDocument->setModified(true);
3396 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3398 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3400 QString playlistPath;
3403 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3404 QString path = m_renderWidget->getFreeScriptName();
3405 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3406 if (!ok || scriptPath.isEmpty()) return;
3407 scriptPath.prepend(scriptsFolder);
3408 QFile f(scriptPath);
3410 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3413 playlistPath = scriptPath + ".mlt";
3414 m_projectMonitor->saveSceneList(playlistPath);
3416 KTemporaryFile temp;
3417 temp.setAutoRemove(false);
3418 temp.setSuffix(".mlt");
3420 playlistPath = temp.fileName();
3421 m_projectMonitor->saveSceneList(playlistPath);
3424 if (!chapterFile.isEmpty()) {
3427 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3429 in = m_activeTimeline->inPoint();
3430 out = m_activeTimeline->outPoint();
3433 QDomElement chapters = doc.createElement("chapters");
3434 chapters.setAttribute("fps", m_activeDocument->fps());
3435 doc.appendChild(chapters);
3437 QDomElement guidesxml = m_activeDocument->guidesXml();
3438 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3439 for (int i = 0; i < nodes.count(); i++) {
3440 QDomElement e = nodes.item(i).toElement();
3442 QString comment = e.attribute("comment");
3443 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3444 if (time >= in && time < out) {
3445 if (zoneOnly) time = time - in;
3446 QDomElement chapter = doc.createElement("chapter");
3447 chapters.appendChild(chapter);
3448 chapter.setAttribute("title", comment);
3449 chapter.setAttribute("time", time);
3453 if (chapters.childNodes().count() > 0) {
3454 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3455 // Always insert a guide in pos 0
3456 QDomElement chapter = doc.createElement("chapter");
3457 chapters.insertBefore(chapter, QDomNode());
3458 chapter.setAttribute("title", i18n("Start"));
3459 chapter.setAttribute("time", "0");
3461 // save chapters file
3462 QFile file(chapterFile);
3463 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3464 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3466 file.write(doc.toString().toUtf8());
3467 if (file.error() != QFile::NoError) {
3468 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3475 if (m_renderWidget->automaticAudioExport()) {
3476 exportAudio = m_activeTimeline->checkProjectAudio();
3477 } else exportAudio = m_renderWidget->selectedAudioExport();
3478 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3481 void MainWindow::slotUpdateTimecodeFormat(int ix)
3483 KdenliveSettings::setFrametimecode(ix == 1);
3484 m_clipMonitor->updateTimecodeFormat();
3485 m_projectMonitor->updateTimecodeFormat();
3486 m_transitionConfig->updateTimecodeFormat();
3487 m_effectStack->updateTimecodeFormat();
3488 //m_activeTimeline->projectView()->clearSelection();
3489 m_activeTimeline->updateRuler();
3492 void MainWindow::slotRemoveFocus()
3494 statusBar()->setFocus();
3495 statusBar()->clearFocus();
3498 void MainWindow::slotRevert()
3500 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;
3501 KUrl url = m_activeDocument->url();
3502 closeCurrentDocument(false);
3503 doOpenFile(url, NULL);
3507 void MainWindow::slotShutdown()
3509 if (m_activeDocument) m_activeDocument->setModified(false);
3511 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3512 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3513 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3514 smserver.call("logout", 1, 2, 2);
3515 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3516 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3517 smserver.call("Shutdown");
3521 void MainWindow::slotUpdateTrackInfo()
3523 if (m_activeDocument)
3524 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3527 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3529 // Load the theme file
3531 if (action == NULL) theme = themename;
3532 else theme = action->data().toString();
3533 KdenliveSettings::setColortheme(theme);
3534 // Make palette for all widgets.
3536 if (theme.isEmpty())
3537 plt = QApplication::desktop()->palette();
3539 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3540 plt = KGlobalSettings::createApplicationPalette(config);
3543 kapp->setPalette(plt);
3544 const QObjectList children = statusBar()->children();
3546 foreach(QObject *child, children) {
3547 if (child->isWidgetType())
3548 ((QWidget*)child)->setPalette(plt);
3549 const QObjectList subchildren = child->children();
3550 foreach(QObject *subchild, subchildren) {
3551 if (subchild->isWidgetType())
3552 ((QWidget*)subchild)->setPalette(plt);
3555 if (m_activeTimeline)
3556 m_activeTimeline->projectView()->updatePalette();
3560 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3562 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3563 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3564 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3565 const QSize bitsSize(24, 2);
3566 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3567 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3569 QPixmap pixmap(23, 16);
3570 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3572 KConfigGroup group(config, "WM");
3573 QPainter p(&pixmap);
3574 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3575 p.fillRect(1, 1, 7, 7, windowScheme.background());
3576 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3578 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3579 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3580 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3582 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3583 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3585 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3586 p.fillRect(1, 8, 7, 7, viewScheme.background());
3587 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3589 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3590 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3591 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3593 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3594 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3600 void MainWindow::slotSwitchMonitors()
3602 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3603 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3604 else m_projectList->focusTree();
3607 void MainWindow::slotInsertZoneToTree()
3609 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3610 QStringList info = m_clipMonitor->getZoneInfo();
3611 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3614 void MainWindow::slotInsertZoneToTimeline()
3616 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3617 QStringList info = m_clipMonitor->getZoneInfo();
3618 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3622 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3624 if (m_activeDocument && m_activeTimeline) {
3625 if (!ids.isEmpty()) {
3626 for (int i = 0; i < ids.size(); ++i) {
3627 m_activeTimeline->slotDeleteClip(ids.at(i));
3629 m_activeDocument->clipManager()->slotDeleteClips(ids);
3631 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3632 m_activeDocument->setModified(true);
3636 void MainWindow::slotShowTitleBars(bool show)
3639 m_effectStackDock->setTitleBarWidget(0);
3640 m_clipMonitorDock->setTitleBarWidget(0);
3641 m_projectMonitorDock->setTitleBarWidget(0);
3643 m_recMonitorDock->setTitleBarWidget(0);
3645 m_effectListDock->setTitleBarWidget(0);
3646 m_transitionConfigDock->setTitleBarWidget(0);
3647 m_projectListDock->setTitleBarWidget(0);
3648 m_undoViewDock->setTitleBarWidget(0);
3649 m_vectorscopeDock->setTitleBarWidget(0);
3650 m_waveformDock->setTitleBarWidget(0);
3651 m_RGBParadeDock->setTitleBarWidget(0);
3652 m_histogramDock->setTitleBarWidget(0);
3654 if (!m_effectStackDock->isFloating()) {
3655 m_effectStackDock->setTitleBarWidget(new QWidget);
3657 if (!m_clipMonitorDock->isFloating()) {
3658 m_clipMonitorDock->setTitleBarWidget(new QWidget);
3660 if (!m_projectMonitorDock->isFloating()) {
3661 m_projectMonitorDock->setTitleBarWidget(new QWidget);
3664 if (!m_recMonitorDock->isFloating()) {
3665 m_recMonitorDock->setTitleBarWidget(new QWidget);
3668 if (!m_effectListDock->isFloating()) {
3669 m_effectListDock->setTitleBarWidget(new QWidget);
3671 if (!m_transitionConfigDock->isFloating()) {
3672 m_transitionConfigDock->setTitleBarWidget(new QWidget);
3674 if (!m_projectListDock->isFloating()) {
3675 m_projectListDock->setTitleBarWidget(new QWidget);
3677 if (!m_undoViewDock->isFloating()) {
3678 m_undoViewDock->setTitleBarWidget(new QWidget);
3680 if (!m_vectorscopeDock->isFloating()) {
3681 m_vectorscopeDock->setTitleBarWidget(new QWidget);
3683 if (!m_waveformDock->isFloating()) {
3684 m_waveformDock->setTitleBarWidget(new QWidget);
3686 if (!m_RGBParadeDock->isFloating()) {
3687 m_RGBParadeDock->setTitleBarWidget(new QWidget(this));
3689 if (!m_histogramDock->isFloating()) {
3690 m_histogramDock->setTitleBarWidget(new QWidget(this));
3693 KdenliveSettings::setShowtitlebars(show);
3696 void MainWindow::slotSwitchTitles()
3698 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3701 QString MainWindow::getMimeType()
3703 QString mimetype = "application/x-kdenlive";
3704 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3705 if (!mime) mimetype = "*.kdenlive";
3709 #include "mainwindow.moc"