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"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #if KDE_IS_VERSION(4,3,80)
83 #include <knewstuff3/downloaddialog.h>
84 #include <knewstuff3/knewstuffaction.h>
86 #include <knewstuff2/engine.h>
87 #include <knewstuff2/ui/knewstuffaction.h>
89 #endif /* KDE_IS_VERSION(4,3,80) */
91 #include <KColorScheme>
93 #include <QTextStream>
97 #include <QInputDialog>
98 #include <QDesktopWidget>
103 static const char version[] = VERSION;
105 static const int ID_TIMELINE_POS = 0;
112 EffectsList MainWindow::videoEffects;
113 EffectsList MainWindow::audioEffects;
114 EffectsList MainWindow::customEffects;
115 EffectsList MainWindow::transitions;
117 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
118 KXmlGuiWindow(parent),
119 m_activeDocument(NULL),
120 m_activeTimeline(NULL),
121 m_renderWidget(NULL),
122 #ifndef NO_JOGSHUTTLE
124 #endif /* NO_JOGSHUTTLE */
125 m_findActivated(false)
128 // Create DBus interface
129 new MainWindowAdaptor(this);
130 QDBusConnection dbus = QDBusConnection::sessionBus();
131 dbus.registerObject("/MainWindow", this);
133 setlocale(LC_NUMERIC, "POSIX");
134 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
135 setFont(KGlobalSettings::toolBarFont());
136 parseProfiles(MltPath);
137 m_commandStack = new QUndoGroup;
138 m_timelineArea = new KTabWidget(this);
139 m_timelineArea->setTabReorderingEnabled(true);
140 m_timelineArea->setTabBarHidden(true);
142 QToolButton *closeTabButton = new QToolButton;
143 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
144 closeTabButton->setIcon(KIcon("tab-close"));
145 closeTabButton->adjustSize();
146 closeTabButton->setToolTip(i18n("Close the current tab"));
147 m_timelineArea->setCornerWidget(closeTabButton);
148 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
150 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
151 m_findTimer.setSingleShot(true);
153 // FIXME: the next call returns a newly allocated object, which leaks
154 initEffects::parseEffectFiles();
155 //initEffects::parseCustomEffectsFile();
157 m_monitorManager = new MonitorManager();
159 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
160 m_projectListDock->setObjectName("project_tree");
161 m_projectList = new ProjectList(this);
162 m_projectListDock->setWidget(m_projectList);
163 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
165 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
166 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
168 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
169 m_effectListDock->setObjectName("effect_list");
170 m_effectList = new EffectsListView();
172 //m_effectList = new KListWidget(this);
173 m_effectListDock->setWidget(m_effectList);
174 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
176 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
177 m_effectStackDock->setObjectName("effect_stack");
178 m_effectStack = new EffectStackView(this);
179 m_effectStackDock->setWidget(m_effectStack);
180 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
182 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
183 m_transitionConfigDock->setObjectName("transition");
184 m_transitionConfig = new TransitionSettings(this);
185 m_transitionConfigDock->setWidget(m_transitionConfig);
186 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
188 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
189 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
191 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
192 m_fileRevert->setEnabled(false);
194 //slotDetectAudioDriver();
196 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
197 m_clipMonitorDock->setObjectName("clip_monitor");
198 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
199 m_clipMonitorDock->setWidget(m_clipMonitor);
200 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
201 //m_clipMonitor->stop();
203 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
204 m_projectMonitorDock->setObjectName("project_monitor");
205 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
206 m_projectMonitorDock->setWidget(m_projectMonitor);
207 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
210 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
211 m_recMonitorDock->setObjectName("record_monitor");
212 m_recMonitor = new RecMonitor("record", this);
213 m_recMonitorDock->setWidget(m_recMonitor);
214 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
216 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
217 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
220 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
221 m_undoViewDock->setObjectName("undo_history");
222 m_undoView = new QUndoView(this);
223 m_undoView->setCleanIcon(KIcon("edit-clear"));
224 m_undoView->setEmptyLabel(i18n("Clean"));
225 m_undoViewDock->setWidget(m_undoView);
226 m_undoView->setGroup(m_commandStack);
227 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
229 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
230 //overviewDock->setObjectName("project_overview");
231 //m_overView = new CustomTrackView(NULL, NULL, this);
232 //overviewDock->setWidget(m_overView);
233 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
236 //tabifyDockWidget(projectListDock, effectListDock);
237 tabifyDockWidget(m_projectListDock, m_effectStackDock);
238 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
239 //tabifyDockWidget(projectListDock, undoViewDock);
242 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
244 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
246 setCentralWidget(m_timelineArea);
249 // Find QDockWidget tab bars and show / hide widget title bars on right click
250 QList <QTabBar *> tabs = findChildren<QTabBar *>();
251 for (int i = 0; i < tabs.count(); i++) {
252 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
253 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
256 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
257 guiFactory()->addClient(sp);*/
261 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
263 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
264 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
266 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
267 clipInTimeline->setIcon(KIcon("go-jump"));
268 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
269 static_cast<QMenu*>(factory()->container("transcoders", this)),
273 // build themes menus
274 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
275 QActionGroup *themegroup = new QActionGroup(this);
276 themegroup->setExclusive(true);
277 action = new KAction(i18n("Default"), this);
278 action->setCheckable(true);
279 themegroup->addAction(action);
280 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
282 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
284 for (int i = 0; i < schemeFiles.size(); ++i) {
286 const QString filename = schemeFiles.at(i);
287 const QFileInfo info(filename);
290 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
291 QIcon icon = createSchemePreviewIcon(config);
292 KConfigGroup group(config, "General");
293 const QString name = group.readEntry("Name", info.baseName());
294 action = new KAction(name, this);
295 action->setData(filename);
296 action->setIcon(icon);
297 action->setCheckable(true);
298 themegroup->addAction(action);
299 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
302 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
303 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
304 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
307 action = new QAction(fi.fileName(), this);
308 action->setData(*it);
309 action->setCheckable(true);
310 themegroup->addAction(action);
311 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
313 themesMenu->addActions(themegroup->actions());
314 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
316 // Setup and fill effects and transitions menus.
317 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
318 for (int i = 0; i < videoEffects.count(); ++i)
319 m_videoEffectsMenu->addAction(m_videoEffects[i]);
320 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
321 for (int i = 0; i < audioEffects.count(); ++i)
322 m_audioEffectsMenu->addAction(m_audioEffects[i]);
323 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
324 if (customEffects.isEmpty())
325 m_customEffectsMenu->setEnabled(false);
327 m_customEffectsMenu->setEnabled(true);
328 for (int i = 0; i < customEffects.count(); ++i)
329 m_customEffectsMenu->addAction(m_customEffects[i]);
330 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
331 for (int i = 0; i < transitions.count(); ++i)
332 m_transitionsMenu->addAction(m_transitions[i]);
334 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
335 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
336 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
337 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
339 QMenu *newEffect = new QMenu(this);
340 newEffect->addMenu(m_videoEffectsMenu);
341 newEffect->addMenu(m_audioEffectsMenu);
342 newEffect->addMenu(m_customEffectsMenu);
343 m_effectStack->setMenu(newEffect);
345 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
346 const QList<QAction *> viewActions = createPopupMenu()->actions();
347 viewMenu->insertActions(NULL, viewActions);
349 m_timelineContextMenu = new QMenu(this);
350 m_timelineContextClipMenu = new QMenu(this);
351 m_timelineContextTransitionMenu = new QMenu(this);
353 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
354 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
355 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
357 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
358 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
359 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
360 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
361 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
362 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
363 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
364 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
365 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
367 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
368 m_timelineContextClipMenu->addMenu(markersMenu);
369 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
370 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
371 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
372 //TODO: re-enable custom effects menu when it is implemented
373 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
375 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
376 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
377 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
379 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
381 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
382 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
383 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
384 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
385 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
386 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
388 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
389 slotConnectMonitors();
391 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
392 KdenliveSettings::setDropbframes(false);
394 // Open or create a file. Command line argument passed in Url has
395 // precedence, then "openlastproject", then just a plain empty file.
396 // If opening Url fails, openlastproject will _not_ be used.
397 if (!Url.isEmpty()) {
398 // delay loading so that the window shows up
400 QTimer::singleShot(500, this, SLOT(openFile()));
401 } else if (KdenliveSettings::openlastproject()) {
402 QTimer::singleShot(500, this, SLOT(openLastFile()));
403 } else { //if (m_timelineArea->count() == 0) {
407 #ifndef NO_JOGSHUTTLE
408 activateShuttleDevice();
409 #endif /* NO_JOGSHUTTLE */
410 m_projectListDock->raise();
413 void MainWindow::queryQuit()
416 if (m_projectMonitor) m_projectMonitor->stop();
417 if (m_clipMonitor) m_clipMonitor->stop();
418 delete m_effectStack;
419 delete m_activeTimeline;
421 // This sometimes causes crash on exit on OS X for some reason.
422 delete m_projectMonitor;
423 delete m_clipMonitor;
425 delete m_activeDocument;
426 delete m_shortcutRemoveFocus;
427 Mlt::Factory::close();
433 bool MainWindow::queryClose()
435 if (m_renderWidget) {
436 int waitingJobs = m_renderWidget->waitingJobsCount();
437 if (waitingJobs > 0) {
438 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")))) {
439 case KMessageBox::Yes :
440 // create script with waiting jobs and start it
441 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
443 case KMessageBox::No :
444 // Don't do anything, jobs will be deleted
452 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
453 if (m_activeDocument && m_activeDocument->isModified()) {
454 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
455 case KMessageBox::Yes :
456 // save document here. If saving fails, return false;
458 case KMessageBox::No :
459 // User does not want to save the changes, clear recovery files
460 m_activeDocument->m_autosave->resize(0);
470 void MainWindow::loadPlugins()
472 foreach(QObject *plugin, QPluginLoader::staticInstances())
473 populateMenus(plugin);
475 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
477 filters << "libkdenlive*";
478 foreach(const QString &folder, directories) {
479 kDebug() << "// PARSING FIOLER: " << folder;
480 QDir pluginsDir(folder);
481 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
482 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
483 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
484 QObject *plugin = loader.instance();
486 populateMenus(plugin);
487 m_pluginFileNames += fileName;
488 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
494 void MainWindow::populateMenus(QObject *plugin)
496 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
497 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
499 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
503 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
504 QMenu *menu, const char *member,
505 QActionGroup *actionGroup)
507 kDebug() << "// ADD to MENU" << texts;
508 foreach(const QString &text, texts) {
509 QAction *action = new QAction(text, plugin);
510 action->setData(text);
511 connect(action, SIGNAL(triggered()), this, member);
512 menu->addAction(action);
515 action->setCheckable(true);
516 actionGroup->addAction(action);
521 void MainWindow::aboutPlugins()
523 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
528 void MainWindow::generateClip()
530 QAction *action = qobject_cast<QAction *>(sender());
531 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
533 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
534 if (!clipUrl.isEmpty()) {
535 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
539 void MainWindow::saveProperties(KConfigGroup &config)
541 // save properties here,used by session management
543 KMainWindow::saveProperties(config);
547 void MainWindow::readProperties(const KConfigGroup &config)
549 // read properties here,used by session management
550 KMainWindow::readProperties(config);
551 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
552 openFile(KUrl(Lastproject));
555 void MainWindow::slotReloadEffects()
557 m_customEffectsMenu->clear();
558 initEffects::parseCustomEffectsFile();
560 QStringList effectInfo;
561 QMap<QString, QStringList> effectsList;
563 for (int ix = 0; ix < customEffects.count(); ix++) {
564 effectInfo = customEffects.effectIdInfo(ix);
565 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
567 if (effectsList.isEmpty()) {
568 m_customEffectsMenu->setEnabled(false);
570 } else m_customEffectsMenu->setEnabled(true);
572 foreach(const QStringList &value, effectsList) {
573 action = new QAction(value.at(0), this);
574 action->setData(value);
575 m_customEffectsMenu->addAction(action);
577 m_effectList->reloadEffectList();
580 #ifndef NO_JOGSHUTTLE
581 void MainWindow::activateShuttleDevice()
585 if (KdenliveSettings::enableshuttle() == false) return;
586 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
587 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
588 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
589 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
590 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
591 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
592 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
595 void MainWindow::slotShuttleButton(int code)
599 slotShuttleAction(KdenliveSettings::shuttle1());
602 slotShuttleAction(KdenliveSettings::shuttle2());
605 slotShuttleAction(KdenliveSettings::shuttle3());
608 slotShuttleAction(KdenliveSettings::shuttle4());
611 slotShuttleAction(KdenliveSettings::shuttle5());
616 void MainWindow::slotShuttleAction(int code)
622 m_monitorManager->slotPlay();
625 m_monitorManager->slotPlay();
629 #endif /* NO_JOGSHUTTLE */
631 void MainWindow::configureNotifications()
633 KNotifyConfigWidget::configure(this);
636 void MainWindow::slotFullScreen()
638 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
641 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
643 if (!m_activeDocument) return;
644 if (effect.isNull()) {
645 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
648 QDomElement effectToAdd = effect.cloneNode().toElement();
649 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
652 void MainWindow::slotRaiseMonitor(bool clipMonitor)
654 if (clipMonitor) m_clipMonitorDock->raise();
655 else m_projectMonitorDock->raise();
658 void MainWindow::slotUpdateClip(const QString &id)
660 if (!m_activeDocument) return;
661 m_activeTimeline->projectView()->slotUpdateClip(id);
664 void MainWindow::slotConnectMonitors()
667 m_projectList->setRenderer(m_projectMonitor->render);
668 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
669 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
670 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
671 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
672 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
673 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
674 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)));
676 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
678 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
680 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
681 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
683 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
684 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
687 void MainWindow::slotAdjustClipMonitor()
689 m_clipMonitorDock->updateGeometry();
690 m_clipMonitorDock->adjustSize();
691 m_clipMonitor->resetSize();
694 void MainWindow::slotAdjustProjectMonitor()
696 m_projectMonitorDock->updateGeometry();
697 m_projectMonitorDock->adjustSize();
698 m_projectMonitor->resetSize();
701 void MainWindow::setupActions()
704 KActionCollection* collection = actionCollection();
705 m_timecodeFormat = new KComboBox(this);
706 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
707 m_timecodeFormat->addItem(i18n("Frames"));
708 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
709 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
711 m_statusProgressBar = new QProgressBar(this);
712 m_statusProgressBar->setMinimum(0);
713 m_statusProgressBar->setMaximum(100);
714 m_statusProgressBar->setMaximumWidth(150);
715 m_statusProgressBar->setVisible(false);
717 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
718 toolbar->setMovable(false);
719 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
720 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;}";
721 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
723 //create edit mode buttons
724 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
725 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
726 toolbar->addAction(m_normalEditTool);
727 m_normalEditTool->setCheckable(true);
728 m_normalEditTool->setChecked(true);
730 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
731 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
732 toolbar->addAction(m_overwriteEditTool);
733 m_overwriteEditTool->setCheckable(true);
734 m_overwriteEditTool->setChecked(false);
736 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
737 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
738 toolbar->addAction(m_insertEditTool);
739 m_insertEditTool->setCheckable(true);
740 m_insertEditTool->setChecked(false);
741 // not implemented yet
742 m_insertEditTool->setEnabled(false);
744 QActionGroup *editGroup = new QActionGroup(this);
745 editGroup->addAction(m_normalEditTool);
746 editGroup->addAction(m_overwriteEditTool);
747 editGroup->addAction(m_insertEditTool);
748 editGroup->setExclusive(true);
749 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
750 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
752 toolbar->addSeparator();
754 // create tools buttons
755 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
756 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
757 toolbar->addAction(m_buttonSelectTool);
758 m_buttonSelectTool->setCheckable(true);
759 m_buttonSelectTool->setChecked(true);
761 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
762 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
763 toolbar->addAction(m_buttonRazorTool);
764 m_buttonRazorTool->setCheckable(true);
765 m_buttonRazorTool->setChecked(false);
767 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
768 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
769 toolbar->addAction(m_buttonSpacerTool);
770 m_buttonSpacerTool->setCheckable(true);
771 m_buttonSpacerTool->setChecked(false);
773 QActionGroup *toolGroup = new QActionGroup(this);
774 toolGroup->addAction(m_buttonSelectTool);
775 toolGroup->addAction(m_buttonRazorTool);
776 toolGroup->addAction(m_buttonSpacerTool);
777 toolGroup->setExclusive(true);
778 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
780 QWidget * actionWidget;
781 int max = toolbar->iconSizeDefault() + 2;
782 actionWidget = toolbar->widgetForAction(m_normalEditTool);
783 actionWidget->setMaximumWidth(max);
784 actionWidget->setMaximumHeight(max - 4);
786 actionWidget = toolbar->widgetForAction(m_insertEditTool);
787 actionWidget->setMaximumWidth(max);
788 actionWidget->setMaximumHeight(max - 4);
790 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
791 actionWidget->setMaximumWidth(max);
792 actionWidget->setMaximumHeight(max - 4);
794 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
795 actionWidget->setMaximumWidth(max);
796 actionWidget->setMaximumHeight(max - 4);
798 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
799 actionWidget->setMaximumWidth(max);
800 actionWidget->setMaximumHeight(max - 4);
802 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
803 actionWidget->setMaximumWidth(max);
804 actionWidget->setMaximumHeight(max - 4);
806 toolbar->setStyleSheet(style1);
807 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
809 toolbar->addSeparator();
810 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
811 toolbar->addAction(m_buttonFitZoom);
812 m_buttonFitZoom->setCheckable(false);
813 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
815 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
816 toolbar->addAction(m_zoomIn);
817 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
818 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
820 m_zoomSlider = new QSlider(Qt::Horizontal, this);
821 m_zoomSlider->setMaximum(13);
822 m_zoomSlider->setPageStep(1);
824 m_zoomSlider->setMaximumWidth(150);
825 m_zoomSlider->setMinimumWidth(100);
826 toolbar->addWidget(m_zoomSlider);
828 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
829 toolbar->addAction(m_zoomOut);
830 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
831 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
833 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
834 actionWidget->setMaximumWidth(max);
835 actionWidget->setMaximumHeight(max - 4);
836 actionWidget->setStyleSheet(styleBorderless);
838 actionWidget = toolbar->widgetForAction(m_zoomIn);
839 actionWidget->setMaximumWidth(max);
840 actionWidget->setMaximumHeight(max - 4);
841 actionWidget->setStyleSheet(styleBorderless);
843 actionWidget = toolbar->widgetForAction(m_zoomOut);
844 actionWidget->setMaximumWidth(max);
845 actionWidget->setMaximumHeight(max - 4);
846 actionWidget->setStyleSheet(styleBorderless);
848 toolbar->addSeparator();
850 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
851 toolbar->addAction(m_buttonVideoThumbs);
852 m_buttonVideoThumbs->setCheckable(true);
853 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
854 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
856 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
857 toolbar->addAction(m_buttonAudioThumbs);
858 m_buttonAudioThumbs->setCheckable(true);
859 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
860 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
862 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
863 toolbar->addAction(m_buttonShowMarkers);
864 m_buttonShowMarkers->setCheckable(true);
865 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
866 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
868 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
869 toolbar->addAction(m_buttonSnap);
870 m_buttonSnap->setCheckable(true);
871 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
872 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
874 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
875 actionWidget->setMaximumWidth(max);
876 actionWidget->setMaximumHeight(max - 4);
878 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
879 actionWidget->setMaximumWidth(max);
880 actionWidget->setMaximumHeight(max - 4);
882 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
883 actionWidget->setMaximumWidth(max);
884 actionWidget->setMaximumHeight(max - 4);
886 actionWidget = toolbar->widgetForAction(m_buttonSnap);
887 actionWidget->setMaximumWidth(max);
888 actionWidget->setMaximumHeight(max - 4);
890 m_messageLabel = new StatusBarMessageLabel(this);
891 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
893 statusBar()->addWidget(m_messageLabel, 10);
894 statusBar()->addWidget(m_statusProgressBar, 0);
895 statusBar()->addPermanentWidget(toolbar);
896 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
897 statusBar()->addPermanentWidget(m_timecodeFormat);
898 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
900 collection->addAction("normal_mode", m_normalEditTool);
901 collection->addAction("overwrite_mode", m_overwriteEditTool);
902 collection->addAction("insert_mode", m_insertEditTool);
903 collection->addAction("select_tool", m_buttonSelectTool);
904 collection->addAction("razor_tool", m_buttonRazorTool);
905 collection->addAction("spacer_tool", m_buttonSpacerTool);
907 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
908 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
909 collection->addAction("show_markers", m_buttonShowMarkers);
910 collection->addAction("snap", m_buttonSnap);
911 collection->addAction("zoom_fit", m_buttonFitZoom);
912 collection->addAction("zoom_in", m_zoomIn);
913 collection->addAction("zoom_out", m_zoomOut);
915 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
916 collection->addAction("project_find", m_projectSearch);
917 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
918 m_projectSearch->setShortcut(Qt::Key_Slash);
920 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
921 collection->addAction("project_find_next", m_projectSearchNext);
922 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
923 m_projectSearchNext->setShortcut(Qt::Key_F3);
924 m_projectSearchNext->setEnabled(false);
926 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
927 collection->addAction("manage_profiles", profilesAction);
928 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
930 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
932 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
934 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
936 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
938 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
939 collection->addAction("run_wizard", wizAction);
940 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
942 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
943 collection->addAction("project_settings", projectAction);
944 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
946 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
947 collection->addAction("project_render", projectRender);
948 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
949 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
951 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
952 collection->addAction("project_clean", projectClean);
953 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
955 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
956 KShortcut playShortcut;
957 playShortcut.setPrimary(Qt::Key_Space);
958 playShortcut.setAlternate(Qt::Key_K);
959 monitorPlay->setShortcut(playShortcut);
960 collection->addAction("monitor_play", monitorPlay);
961 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
963 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
964 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
965 collection->addAction("monitor_play_zone", m_playZone);
966 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
968 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
969 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
970 collection->addAction("monitor_loop_zone", m_loopZone);
971 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
973 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
974 collection->addAction("dvd_wizard", dvdWizard);
975 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
977 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
978 collection->addAction("transcode_clip", transcodeClip);
979 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
981 KAction *markIn = collection->addAction("mark_in");
982 markIn->setText(i18n("Set Zone In"));
983 markIn->setShortcut(Qt::Key_I);
984 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
986 KAction *markOut = collection->addAction("mark_out");
987 markOut->setText(i18n("Set Zone Out"));
988 markOut->setShortcut(Qt::Key_O);
989 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
991 KAction *switchMon = collection->addAction("switch_monitor");
992 switchMon->setText(i18n("Switch monitor"));
993 switchMon->setShortcut(Qt::Key_T);
994 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
996 KAction *insertTree = collection->addAction("insert_project_tree");
997 insertTree->setText(i18n("Insert zone in project tree"));
998 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
999 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1001 KAction *insertTimeline = collection->addAction("insert_timeline");
1002 insertTimeline->setText(i18n("Insert zone in timeline"));
1003 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1004 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1006 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1007 collection->addAction("resize_timeline_clip_start", resizeStart);
1008 resizeStart->setShortcut(Qt::Key_1);
1009 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1011 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1012 collection->addAction("resize_timeline_clip_end", resizeEnd);
1013 resizeEnd->setShortcut(Qt::Key_2);
1014 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1016 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1017 monitorSeekBackward->setShortcut(Qt::Key_J);
1018 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1019 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1021 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1022 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1023 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1024 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1026 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1027 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1028 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1029 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1031 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1032 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1033 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1034 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1036 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1037 monitorSeekForward->setShortcut(Qt::Key_L);
1038 collection->addAction("monitor_seek_forward", monitorSeekForward);
1039 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1041 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1042 clipStart->setShortcut(Qt::Key_Home);
1043 collection->addAction("seek_clip_start", clipStart);
1044 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1046 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1047 clipEnd->setShortcut(Qt::Key_End);
1048 collection->addAction("seek_clip_end", clipEnd);
1049 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1051 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1052 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1053 collection->addAction("seek_zone_start", zoneStart);
1054 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1056 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1057 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1058 collection->addAction("seek_zone_end", zoneEnd);
1059 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1061 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1062 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1063 collection->addAction("seek_start", projectStart);
1064 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1066 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1067 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1068 collection->addAction("seek_end", projectEnd);
1069 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1071 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1072 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1073 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1074 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1076 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1077 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1078 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1079 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1081 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1082 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1083 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1084 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1086 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1087 deleteItem->setShortcut(Qt::Key_Delete);
1088 collection->addAction("delete_timeline_clip", deleteItem);
1089 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1091 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1092 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1093 editTimelineClipSpeed->setData("change_speed");
1094 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1096 KAction *stickTransition = collection->addAction("auto_transition");
1097 stickTransition->setData(QString("auto"));
1098 stickTransition->setCheckable(true);
1099 stickTransition->setEnabled(false);
1100 stickTransition->setText(i18n("Automatic Transition"));
1101 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1103 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1104 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1105 collection->addAction("group_clip", groupClip);
1106 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1108 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1109 collection->addAction("ungroup_clip", ungroupClip);
1110 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1111 ungroupClip->setData("ungroup_clip");
1112 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1114 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1115 collection->addAction("edit_item_duration", editItemDuration);
1116 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1118 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1119 collection->addAction("clip_in_project_tree", clipInProjectTree);
1120 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1122 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1123 insertOvertwrite->setShortcut(Qt::Key_V);
1124 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1125 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1127 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1128 selectTimelineClip->setShortcut(Qt::Key_Plus);
1129 collection->addAction("select_timeline_clip", selectTimelineClip);
1130 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1132 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1133 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1134 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1135 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1137 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1138 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1139 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1140 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1142 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1143 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1144 collection->addAction("select_timeline_transition", selectTimelineTransition);
1145 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1147 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1148 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1149 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1150 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1152 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1153 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1154 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1155 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1157 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1158 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1159 collection->addAction("cut_timeline_clip", cutTimelineClip);
1160 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1162 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1163 collection->addAction("add_clip_marker", addClipMarker);
1164 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1166 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1167 collection->addAction("delete_clip_marker", deleteClipMarker);
1168 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1170 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1171 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1172 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1174 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1175 collection->addAction("edit_clip_marker", editClipMarker);
1176 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1178 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1179 collection->addAction("split_audio", splitAudio);
1180 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1182 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1183 collection->addAction("clip_audio_only", audioOnly);
1184 audioOnly->setData("clip_audio_only");
1185 audioOnly->setCheckable(true);
1187 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1188 collection->addAction("clip_video_only", videoOnly);
1189 videoOnly->setData("clip_video_only");
1190 videoOnly->setCheckable(true);
1192 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1193 collection->addAction("clip_audio_and_video", audioAndVideo);
1194 audioAndVideo->setData("clip_audio_and_video");
1195 audioAndVideo->setCheckable(true);
1197 m_clipTypeGroup = new QActionGroup(this);
1198 m_clipTypeGroup->addAction(audioOnly);
1199 m_clipTypeGroup->addAction(videoOnly);
1200 m_clipTypeGroup->addAction(audioAndVideo);
1201 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1202 m_clipTypeGroup->setEnabled(false);
1204 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1205 collection->addAction("insert_space", insertSpace);
1206 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1208 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1209 collection->addAction("delete_space", removeSpace);
1210 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1212 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1213 collection->addAction("insert_track", insertTrack);
1214 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1216 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1217 collection->addAction("delete_track", deleteTrack);
1218 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1220 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1221 collection->addAction("change_track", changeTrack);
1222 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1224 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1225 collection->addAction("add_guide", addGuide);
1226 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1228 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1229 collection->addAction("delete_guide", delGuide);
1230 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1232 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1233 collection->addAction("edit_guide", editGuide);
1234 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1236 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1237 collection->addAction("delete_all_guides", delAllGuides);
1238 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1240 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1241 collection->addAction("paste_effects", pasteEffects);
1242 pasteEffects->setData("paste_effects");
1243 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1245 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1246 collection->addAction("show_timeline", showTimeline);
1247 showTimeline->setCheckable(true);
1248 showTimeline->setChecked(true);
1249 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1251 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1252 collection->addAction("show_titlebars", showTitleBar);
1253 showTitleBar->setCheckable(true);
1254 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1255 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1256 slotShowTitleBars(KdenliveSettings::showtitlebars());
1258 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1259 collection->addAction("maximize_current", maxCurrent);
1260 maxCurrent->setCheckable(true);
1261 maxCurrent->setChecked(false);
1262 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1265 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1267 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1269 KStandardAction::open(this, SLOT(openFile()), collection);
1271 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1273 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1275 KStandardAction::openNew(this, SLOT(newFile()), collection);
1277 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1279 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1281 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1283 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1285 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1286 undo->setEnabled(false);
1287 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1289 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1290 redo->setEnabled(false);
1291 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1293 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1296 //TODO: Add status tooltip to actions ?
1297 connect(collection, SIGNAL(actionHovered(QAction*)),
1298 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1301 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1302 collection->addAction("add_clip", addClip);
1303 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1305 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1306 collection->addAction("add_color_clip", addColorClip);
1307 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1309 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1310 collection->addAction("add_slide_clip", addSlideClip);
1311 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1313 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1314 collection->addAction("add_text_clip", addTitleClip);
1315 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1317 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1318 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1319 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1321 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1322 collection->addAction("add_folder", addFolderButton);
1323 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1325 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1326 collection->addAction("clip_properties", clipProperties);
1327 clipProperties->setData("clip_properties");
1328 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1329 clipProperties->setEnabled(false);
1331 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1332 collection->addAction("edit_clip", openClip);
1333 openClip->setData("edit_clip");
1334 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1335 openClip->setEnabled(false);
1337 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1338 collection->addAction("delete_clip", deleteClip);
1339 deleteClip->setData("delete_clip");
1340 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1341 deleteClip->setEnabled(false);
1343 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1344 collection->addAction("reload_clip", reloadClip);
1345 reloadClip->setData("reload_clip");
1346 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1347 reloadClip->setEnabled(false);
1349 QMenu *addClips = new QMenu();
1350 addClips->addAction(addClip);
1351 addClips->addAction(addColorClip);
1352 addClips->addAction(addSlideClip);
1353 addClips->addAction(addTitleClip);
1354 addClips->addAction(addTitleTemplateClip);
1355 addClips->addAction(addFolderButton);
1357 addClips->addAction(reloadClip);
1358 addClips->addAction(clipProperties);
1359 addClips->addAction(openClip);
1360 addClips->addAction(deleteClip);
1361 m_projectList->setupMenu(addClips, addClip);
1363 // Setup effects and transitions actions.
1364 m_videoEffects = new KAction*[videoEffects.count()];
1365 for (int i = 0; i < videoEffects.count(); ++i) {
1366 QStringList effectInfo = videoEffects.effectIdInfo(i);
1367 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1368 m_videoEffects[i]->setData(effectInfo);
1369 m_videoEffects[i]->setIconVisibleInMenu(false);
1370 collection->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1372 m_audioEffects = new KAction*[audioEffects.count()];
1373 for (int i = 0; i < audioEffects.count(); ++i) {
1374 QStringList effectInfo = audioEffects.effectIdInfo(i);
1375 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1376 m_audioEffects[i]->setData(effectInfo);
1377 m_audioEffects[i]->setIconVisibleInMenu(false);
1378 collection->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1380 m_customEffects = new KAction*[customEffects.count()];
1381 for (int i = 0; i < customEffects.count(); ++i) {
1382 QStringList effectInfo = customEffects.effectIdInfo(i);
1383 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1384 m_customEffects[i]->setData(effectInfo);
1385 m_customEffects[i]->setIconVisibleInMenu(false);
1386 collection->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1388 m_transitions = new KAction*[transitions.count()];
1389 for (int i = 0; i < transitions.count(); i++) {
1390 QStringList effectInfo = transitions.effectIdInfo(i);
1391 m_transitions[i] = new KAction(effectInfo.at(0), this);
1392 m_transitions[i]->setData(effectInfo);
1393 m_transitions[i]->setIconVisibleInMenu(false);
1394 collection->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1397 //connect(collection, SIGNAL( clearStatusText() ),
1398 //statusBar(), SLOT( clear() ) );
1401 void MainWindow::slotDisplayActionMessage(QAction *a)
1403 statusBar()->showMessage(a->data().toString(), 3000);
1406 void MainWindow::saveOptions()
1408 KdenliveSettings::self()->writeConfig();
1409 KSharedConfigPtr config = KGlobal::config();
1410 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1411 KConfigGroup treecolumns(config, "Project Tree");
1412 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1416 void MainWindow::readOptions()
1418 KSharedConfigPtr config = KGlobal::config();
1419 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1420 KConfigGroup initialGroup(config, "version");
1421 bool upgrade = false;
1422 if (initialGroup.exists()) {
1423 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1427 if (initialGroup.readEntry("version") == "0.7") {
1428 //Add new settings from 0.7.1
1429 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1430 QString path = QDir::homePath() + "/kdenlive";
1431 if (KStandardDirs::makeDir(path) == false) {
1432 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1433 } else KdenliveSettings::setDefaultprojectfolder(path);
1439 if (!initialGroup.exists() || upgrade) {
1440 // this is our first run, show Wizard
1441 Wizard *w = new Wizard(upgrade, this);
1442 if (w->exec() == QDialog::Accepted && w->isOk()) {
1443 w->adjustSettings();
1444 initialGroup.writeEntry("version", version);
1450 KConfigGroup treecolumns(config, "Project Tree");
1451 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1452 if (!state.isEmpty())
1453 m_projectList->setHeaderInfo(state);
1456 void MainWindow::slotRunWizard()
1458 Wizard *w = new Wizard(false, this);
1459 if (w->exec() == QDialog::Accepted && w->isOk()) {
1460 w->adjustSettings();
1465 void MainWindow::newFile(bool showProjectSettings, bool force)
1467 if (!m_timelineArea->isEnabled() && !force) return;
1468 m_fileRevert->setEnabled(false);
1469 QString profileName;
1471 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1472 if (!showProjectSettings) {
1473 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1474 profileName = KdenliveSettings::default_profile();
1475 projectFolder = KdenliveSettings::defaultprojectfolder();
1477 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1478 if (w->exec() != QDialog::Accepted) return;
1479 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1480 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1481 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1482 profileName = w->selectedProfile();
1483 projectFolder = w->selectedFolder();
1484 projectTracks = w->tracks();
1487 m_timelineArea->setEnabled(true);
1488 m_projectList->setEnabled(true);
1489 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1490 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1492 TrackView *trackView = new TrackView(doc, &ok, this);
1493 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1496 //m_timelineArea->setEnabled(false);
1497 //m_projectList->setEnabled(false);
1501 if (m_timelineArea->count() == 1) {
1502 connectDocumentInfo(doc);
1503 connectDocument(trackView, doc);
1504 } else m_timelineArea->setTabBarHidden(false);
1505 m_monitorManager->activateMonitor("clip");
1506 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1509 void MainWindow::activateDocument()
1511 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1512 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1513 KdenliveDoc *currentDoc = currentTab->document();
1514 connectDocumentInfo(currentDoc);
1515 connectDocument(currentTab, currentDoc);
1518 void MainWindow::closeCurrentDocument(bool saveChanges)
1520 QWidget *w = m_timelineArea->currentWidget();
1522 // closing current document
1523 int ix = m_timelineArea->currentIndex() + 1;
1524 if (ix == m_timelineArea->count()) ix = 0;
1525 m_timelineArea->setCurrentIndex(ix);
1526 TrackView *tabToClose = (TrackView *) w;
1527 KdenliveDoc *docToClose = tabToClose->document();
1528 if (docToClose && docToClose->isModified() && saveChanges) {
1529 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1530 case KMessageBox::Yes :
1531 // save document here. If saving fails, return false;
1532 if (saveFile() == false) return;
1534 case KMessageBox::Cancel :
1541 m_clipMonitor->slotSetXml(NULL);
1542 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1543 if (m_timelineArea->count() == 1) {
1544 m_timelineArea->setTabBarHidden(true);
1545 m_closeAction->setEnabled(false);
1547 if (docToClose == m_activeDocument) {
1548 delete m_activeDocument;
1549 m_activeDocument = NULL;
1550 m_effectStack->clear();
1551 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1552 } else delete docToClose;
1553 if (w == m_activeTimeline) {
1554 delete m_activeTimeline;
1555 m_activeTimeline = NULL;
1559 bool MainWindow::saveFileAs(const QString &outputFileName)
1561 QString currentSceneList;
1562 m_monitorManager->stopActiveMonitor();
1563 if (KdenliveSettings::dropbframes()) {
1564 KdenliveSettings::setDropbframes(false);
1565 m_activeDocument->clipManager()->updatePreviewSettings();
1566 currentSceneList = m_projectMonitor->sceneList();
1567 KdenliveSettings::setDropbframes(true);
1568 m_activeDocument->clipManager()->updatePreviewSettings();
1569 } else currentSceneList = m_projectMonitor->sceneList();
1571 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1574 // Save timeline thumbnails
1575 m_activeTimeline->projectView()->saveThumbnails();
1576 m_activeDocument->setUrl(KUrl(outputFileName));
1577 if (m_activeDocument->m_autosave == NULL) {
1578 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1579 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1580 setCaption(m_activeDocument->description());
1581 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1582 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1583 m_activeDocument->setModified(false);
1584 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1585 m_fileRevert->setEnabled(true);
1589 bool MainWindow::saveFileAs()
1591 // Check that the Kdenlive mime type is correctly installed
1592 QString mimetype = "application/x-kdenlive";
1593 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1594 if (!mime) mimetype = "*.kdenlive";
1596 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1597 if (outputFile.isEmpty()) return false;
1598 if (QFile::exists(outputFile)) {
1599 // Show the file dialog again if the user does not want to overwrite the file
1600 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No)
1601 return saveFileAs();
1603 return saveFileAs(outputFile);
1606 bool MainWindow::saveFile()
1608 if (!m_activeDocument) return true;
1609 if (m_activeDocument->url().isEmpty()) {
1610 return saveFileAs();
1612 bool result = saveFileAs(m_activeDocument->url().path());
1613 m_activeDocument->m_autosave->resize(0);
1618 void MainWindow::openFile()
1620 if (!m_startUrl.isEmpty()) {
1621 openFile(m_startUrl);
1622 m_startUrl = KUrl();
1625 // Check that the Kdenlive mime type is correctly installed
1626 QString mimetype = "application/x-kdenlive";
1627 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1628 if (!mime) mimetype = "*.kdenlive";
1630 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1631 if (url.isEmpty()) return;
1632 m_fileOpenRecent->addUrl(url);
1636 void MainWindow::openLastFile()
1638 KSharedConfigPtr config = KGlobal::config();
1639 KUrl::List urls = m_fileOpenRecent->urls();
1640 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1641 if (urls.isEmpty()) newFile(false);
1642 else openFile(urls.last());
1645 void MainWindow::openFile(const KUrl &url)
1647 // Check if the document is already opened
1648 const int ct = m_timelineArea->count();
1649 bool isOpened = false;
1651 for (i = 0; i < ct; i++) {
1652 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1653 KdenliveDoc *doc = tab->document();
1654 if (doc->url() == url) {
1660 m_timelineArea->setCurrentIndex(i);
1664 // Check for backup file
1665 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1666 if (!staleFiles.isEmpty()) {
1667 if (KMessageBox::questionYesNo(this,
1668 i18n("Auto-saved files exist. Do you want to recover them now?"),
1669 i18n("File Recovery"),
1670 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1671 recoverFiles(staleFiles);
1674 // remove the stale files
1675 foreach(KAutoSaveFile *stale, staleFiles) {
1676 stale->open(QIODevice::ReadWrite);
1681 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1682 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1683 m_messageLabel->repaint();
1684 doOpenFile(url, NULL);
1687 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1689 if (!m_timelineArea->isEnabled()) return;
1690 m_fileRevert->setEnabled(true);
1691 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1692 if (stale == NULL) {
1693 stale = new KAutoSaveFile(url, doc);
1694 doc->m_autosave = stale;
1696 doc->m_autosave = stale;
1697 doc->setUrl(stale->managedFile());
1698 doc->setModified(true);
1699 stale->setParent(doc);
1701 connectDocumentInfo(doc);
1703 TrackView *trackView = new TrackView(doc, &ok, this);
1704 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1706 m_timelineArea->setEnabled(false);
1707 m_projectList->setEnabled(false);
1708 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1709 slotGotProgressInfo(QString(), -1);
1710 newFile(false, true);
1713 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1714 trackView->setDuration(trackView->duration());
1715 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1717 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1718 slotGotProgressInfo(QString(), -1);
1719 m_projectMonitor->adjustRulerSize(trackView->duration());
1720 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1721 m_clipMonitor->refreshMonitor(true);
1724 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1726 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1727 foreach(KAutoSaveFile *stale, staleFiles) {
1728 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1729 // show an error message; we could not steal the lockfile
1730 // maybe another application got to the file before us?
1734 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1735 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1736 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1737 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1741 void MainWindow::parseProfiles(const QString &mltPath)
1743 //KdenliveSettings::setDefaulttmpfolder();
1744 if (!mltPath.isEmpty()) {
1745 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1746 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1749 if (KdenliveSettings::mltpath().isEmpty()) {
1750 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1753 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1754 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1755 if (!QFile::exists(meltPath))
1756 meltPath = KStandardDirs::findExe("melt");
1757 KdenliveSettings::setRendererpath(meltPath);
1760 if (KdenliveSettings::rendererpath().isEmpty()) {
1761 // Cannot find the MLT melt renderer, ask for location
1762 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1763 if (getUrl->exec() == QDialog::Rejected) {
1766 KUrl rendererPath = getUrl->selectedUrl();
1768 if (rendererPath.isEmpty()) ::exit(0);
1769 KdenliveSettings::setRendererpath(rendererPath.path());
1772 QStringList profilesFilter;
1773 profilesFilter << "*";
1774 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1775 if (profilesList.isEmpty()) {
1776 // Cannot find MLT path, try finding melt
1777 QString profilePath = KdenliveSettings::rendererpath();
1778 if (!profilePath.isEmpty()) {
1779 profilePath = profilePath.section('/', 0, -3);
1780 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1781 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1783 if (profilesList.isEmpty()) {
1784 // Cannot find the MLT profiles, ask for location
1785 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1786 getUrl->fileDialog()->setMode(KFile::Directory);
1787 if (getUrl->exec() == QDialog::Rejected) {
1790 KUrl mltPath = getUrl->selectedUrl();
1792 if (mltPath.isEmpty()) ::exit(0);
1793 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1794 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1798 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1800 // Parse again MLT profiles to build a list of available video formats
1801 if (profilesList.isEmpty()) parseProfiles();
1805 void MainWindow::slotEditProfiles()
1807 ProfilesDialog *w = new ProfilesDialog;
1808 if (w->exec() == QDialog::Accepted) {
1809 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1810 if (d) d->checkProfile();
1815 void MainWindow::slotDetectAudioDriver()
1817 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1818 leading to no audio output, see bug #934 */
1820 //decide which audio driver is really best, in some cases SDL is wrong
1821 if (KdenliveSettings::audiodrivername().isEmpty()) {
1823 KProcess readProcess;
1824 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1825 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1826 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1827 readProcess.setProgram("pactl", QStringList() << "stat");
1828 readProcess.execute(2000); // Kill it after 2 seconds
1830 QString result = QString(readProcess.readAllStandardOutput());
1831 kDebug() << "// / / / / / READING PACTL: ";
1833 if (!result.isEmpty()) {
1835 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1839 KdenliveSettings::setAutoaudiodrivername(driver);
1843 void MainWindow::slotEditProjectSettings()
1845 QPoint p = m_activeDocument->getTracksCount();
1846 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1848 if (w->exec() == QDialog::Accepted) {
1849 QString profile = w->selectedProfile();
1850 m_activeDocument->setProjectFolder(w->selectedFolder());
1851 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1852 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1853 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1854 if (m_activeDocument->profilePath() != profile) {
1855 // Profile was changed
1856 double dar = m_activeDocument->dar();
1858 // Deselect current effect / transition
1859 m_effectStack->slotClipItemSelected(NULL, 0);
1860 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1861 m_clipMonitor->slotSetXml(NULL);
1862 bool updateFps = m_activeDocument->setProfilePath(profile);
1863 KdenliveSettings::setCurrent_profile(profile);
1864 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1865 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1867 m_activeDocument->clipManager()->clearUnusedProducers();
1868 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1870 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1871 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1872 m_projectList->updateProjectFormat(m_activeDocument->timecode());
1873 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1874 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1875 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1876 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1877 if (updateFps) m_activeTimeline->updateProjectFps();
1878 m_activeDocument->setModified(true);
1879 m_commandStack->activeStack()->clear();
1880 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
1881 slotUpdateMousePosition(0);
1882 // We need to desactivate & reactivate monitors to get a refresh
1883 //m_monitorManager->switchMonitors();
1890 void MainWindow::slotRenderProject()
1892 if (!m_renderWidget) {
1893 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1894 m_renderWidget = new RenderWidget(projectfolder, this);
1895 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1896 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString &, const QString&)));
1897 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1898 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1899 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1900 if (m_activeDocument) {
1901 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1902 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1903 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1904 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1907 slotCheckRenderStatus();
1908 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1909 if (currentTab) m_renderWidget->setTimeline(currentTab);
1910 m_renderWidget->setDocument(m_activeDocument);*/
1911 m_renderWidget->show();
1912 m_renderWidget->showNormal();
1915 void MainWindow::slotCheckRenderStatus()
1917 // Make sure there are no missing clips
1918 if (m_renderWidget) m_renderWidget->missingClips(m_projectList->hasMissingClips());
1921 void MainWindow::setRenderingProgress(const QString &url, int progress)
1923 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1926 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1928 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1931 void MainWindow::slotCleanProject()
1933 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1934 m_projectList->cleanup();
1937 void MainWindow::slotUpdateMousePosition(int pos)
1939 if (m_activeDocument)
1940 switch (m_timecodeFormat->currentIndex()) {
1942 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1945 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1949 void MainWindow::slotUpdateDocumentState(bool modified)
1951 if (!m_activeDocument) return;
1952 setCaption(m_activeDocument->description(), modified);
1953 m_saveAction->setEnabled(modified);
1955 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1956 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1958 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1959 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1963 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1965 if (m_activeDocument) {
1966 if (m_activeDocument == doc) return;
1967 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1969 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1972 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1974 //m_projectMonitor->stop();
1975 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1976 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1977 if (m_activeDocument) {
1978 if (m_activeDocument == doc) return;
1979 if (m_activeTimeline) {
1980 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1981 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1982 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1983 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1984 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1986 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1987 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1988 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1989 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1990 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1991 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1992 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1993 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1994 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1995 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1996 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1997 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
1998 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1999 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2000 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2001 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2002 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2003 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2004 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
2005 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2006 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2007 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2008 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2009 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2010 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2011 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2012 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2013 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2014 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2015 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2016 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2017 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2018 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2019 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2020 m_effectStack->clear();
2022 //m_activeDocument->setRenderer(NULL);
2023 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2024 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2025 m_clipMonitor->stop();
2027 KdenliveSettings::setCurrent_profile(doc->profilePath());
2028 KdenliveSettings::setProject_fps(doc->fps());
2029 m_monitorManager->resetProfiles(doc->timecode());
2030 m_projectList->setDocument(doc);
2031 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2032 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2033 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2034 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2035 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2037 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2038 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2040 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2043 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2044 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2045 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2046 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
2047 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2048 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2049 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2050 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2051 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2052 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2053 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2055 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2056 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2057 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2058 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2059 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2061 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2062 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2063 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2066 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2067 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2069 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2070 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2071 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2072 m_zoomSlider->setValue(doc->zoom().x());
2073 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
2074 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2075 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2076 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2077 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2079 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2080 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2083 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
2084 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
2085 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
2086 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2087 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2088 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2089 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2090 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2091 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2093 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2094 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2095 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2096 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2097 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2100 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2101 m_activeTimeline = trackView;
2102 if (m_renderWidget) {
2103 slotCheckRenderStatus();
2104 m_renderWidget->setProfile(doc->mltProfile());
2105 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2106 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2107 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("rendercategory"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2109 //doc->setRenderer(m_projectMonitor->render);
2110 m_commandStack->setActiveStack(doc->commandStack());
2111 KdenliveSettings::setProject_display_ratio(doc->dar());
2112 //doc->clipManager()->checkAudioThumbs();
2114 //m_overView->setScene(trackView->projectScene());
2115 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2116 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2118 setCaption(doc->description(), doc->isModified());
2119 m_saveAction->setEnabled(doc->isModified());
2120 m_normalEditTool->setChecked(true);
2121 m_activeDocument = doc;
2122 m_activeTimeline->updateProjectFps();
2123 m_activeDocument->checkProjectClips();
2124 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2125 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2126 slotUpdateMousePosition(0);
2127 // set tool to select tool
2128 m_buttonSelectTool->setChecked(true);
2131 void MainWindow::slotZoneMoved(int start, int end)
2133 m_activeDocument->setZone(start, end);
2134 m_projectMonitor->slotZoneMoved(start, end);
2137 void MainWindow::slotGuidesUpdated()
2139 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2142 void MainWindow::slotPreferences(int page, int option)
2144 //An instance of your dialog could be already created and could be
2145 // cached, in which case you want to display the cached dialog
2146 // instead of creating another one
2147 if (KConfigDialog::showDialog("settings")) {
2148 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2149 if (page != -1) d->showPage(page, option);
2153 // KConfigDialog didn't find an instance of this dialog, so lets
2155 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2156 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2157 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2158 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2159 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2161 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2163 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2165 if (page != -1) dialog->showPage(page, option);
2168 void MainWindow::slotUpdatePreviewSettings()
2170 if (m_activeDocument) {
2171 m_clipMonitor->slotSetXml(NULL);
2172 m_activeDocument->updatePreviewSettings();
2176 void MainWindow::updateConfiguration()
2178 //TODO: we should apply settings to all projects, not only the current one
2179 if (m_activeTimeline) {
2180 m_activeTimeline->refresh();
2181 m_activeTimeline->projectView()->checkAutoScroll();
2182 m_activeTimeline->projectView()->checkTrackHeight();
2183 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2185 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2186 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2188 // Update list of transcoding profiles
2190 #ifndef NO_JOGSHUTTLE
2191 activateShuttleDevice();
2192 #endif /* NO_JOGSHUTTLE */
2197 void MainWindow::slotSwitchVideoThumbs()
2199 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2200 if (m_activeTimeline) {
2201 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2203 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2206 void MainWindow::slotSwitchAudioThumbs()
2208 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2209 if (m_activeTimeline) {
2210 m_activeTimeline->refresh();
2211 m_activeTimeline->projectView()->checkAutoScroll();
2212 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2214 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2217 void MainWindow::slotSwitchMarkersComments()
2219 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2220 if (m_activeTimeline) {
2221 m_activeTimeline->refresh();
2223 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2226 void MainWindow::slotSwitchSnap()
2228 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2229 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2233 void MainWindow::slotDeleteItem()
2235 if (QApplication::focusWidget()
2236 && QApplication::focusWidget()->parentWidget()
2237 && QApplication::focusWidget()->parentWidget()->parentWidget()
2238 && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2239 m_projectList->slotRemoveClip();
2241 } else if (QApplication::focusWidget()
2242 && QApplication::focusWidget()->parentWidget()
2243 && QApplication::focusWidget()->parentWidget()->parentWidget()
2244 && QApplication::focusWidget()->parentWidget()->parentWidget()->parentWidget()
2245 && QApplication::focusWidget()->parentWidget()->parentWidget()->parentWidget()->parentWidget()
2246 && QApplication::focusWidget()->parentWidget()->parentWidget()->parentWidget()->parentWidget() == m_effectStackDock) {
2247 // TODO: also delete effect when an effect widget (slider, geomtryval, ...) has focus
2248 m_effectStack->slotItemDel();
2250 } else if (m_activeTimeline) {
2251 m_activeTimeline->projectView()->deleteSelectedClips();
2255 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2257 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2258 m_clipMonitor->updateMarkers(clip);
2261 void MainWindow::slotAddClipMarker()
2263 DocClipBase *clip = NULL;
2265 if (m_projectMonitor->isActive()) {
2266 if (m_activeTimeline) {
2267 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2269 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2270 clip = item->baseClip();
2274 clip = m_clipMonitor->activeClip();
2275 pos = m_clipMonitor->position();
2278 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2281 QString id = clip->getId();
2282 CommentedTime marker(pos, i18n("Marker"));
2283 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2284 if (d.exec() == QDialog::Accepted) {
2285 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2289 void MainWindow::slotDeleteClipMarker()
2291 DocClipBase *clip = NULL;
2293 if (m_projectMonitor->isActive()) {
2294 if (m_activeTimeline) {
2295 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2297 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2298 clip = item->baseClip();
2302 clip = m_clipMonitor->activeClip();
2303 pos = m_clipMonitor->position();
2306 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2310 QString id = clip->getId();
2311 QString comment = clip->markerComment(pos);
2312 if (comment.isEmpty()) {
2313 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2316 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2319 void MainWindow::slotDeleteAllClipMarkers()
2321 DocClipBase *clip = NULL;
2322 if (m_projectMonitor->isActive()) {
2323 if (m_activeTimeline) {
2324 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2326 clip = item->baseClip();
2330 clip = m_clipMonitor->activeClip();
2333 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2336 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2339 void MainWindow::slotEditClipMarker()
2341 DocClipBase *clip = NULL;
2343 if (m_projectMonitor->isActive()) {
2344 if (m_activeTimeline) {
2345 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2347 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2348 clip = item->baseClip();
2352 clip = m_clipMonitor->activeClip();
2353 pos = m_clipMonitor->position();
2356 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2360 QString id = clip->getId();
2361 QString oldcomment = clip->markerComment(pos);
2362 if (oldcomment.isEmpty()) {
2363 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2367 CommentedTime marker(pos, oldcomment);
2368 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2369 if (d.exec() == QDialog::Accepted) {
2370 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2371 if (d.newMarker().time() != pos) {
2372 // remove old marker
2373 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2378 void MainWindow::slotAddGuide()
2380 if (m_activeTimeline)
2381 m_activeTimeline->projectView()->slotAddGuide();
2384 void MainWindow::slotInsertSpace()
2386 if (m_activeTimeline)
2387 m_activeTimeline->projectView()->slotInsertSpace();
2390 void MainWindow::slotRemoveSpace()
2392 if (m_activeTimeline)
2393 m_activeTimeline->projectView()->slotRemoveSpace();
2396 void MainWindow::slotInsertTrack(int ix)
2398 m_projectMonitor->activateMonitor();
2399 if (m_activeTimeline)
2400 m_activeTimeline->projectView()->slotInsertTrack(ix);
2401 if (m_activeDocument)
2402 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2405 void MainWindow::slotDeleteTrack(int ix)
2407 m_projectMonitor->activateMonitor();
2408 if (m_activeTimeline)
2409 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2410 if (m_activeDocument)
2411 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2414 void MainWindow::slotChangeTrack(int ix)
2416 m_projectMonitor->activateMonitor();
2417 if (m_activeTimeline)
2418 m_activeTimeline->projectView()->slotChangeTrack(ix);
2421 void MainWindow::slotEditGuide()
2423 if (m_activeTimeline)
2424 m_activeTimeline->projectView()->slotEditGuide();
2427 void MainWindow::slotDeleteGuide()
2429 if (m_activeTimeline)
2430 m_activeTimeline->projectView()->slotDeleteGuide();
2433 void MainWindow::slotDeleteAllGuides()
2435 if (m_activeTimeline)
2436 m_activeTimeline->projectView()->slotDeleteAllGuides();
2439 void MainWindow::slotCutTimelineClip()
2441 if (m_activeTimeline) {
2442 m_activeTimeline->projectView()->cutSelectedClips();
2446 void MainWindow::slotInsertClipOverwrite()
2448 if (m_activeTimeline) {
2449 QStringList data = m_clipMonitor->getZoneInfo();
2450 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2454 void MainWindow::slotSelectTimelineClip()
2456 if (m_activeTimeline) {
2457 m_activeTimeline->projectView()->selectClip(true);
2461 void MainWindow::slotSelectTimelineTransition()
2463 if (m_activeTimeline) {
2464 m_activeTimeline->projectView()->selectTransition(true);
2468 void MainWindow::slotDeselectTimelineClip()
2470 if (m_activeTimeline) {
2471 m_activeTimeline->projectView()->selectClip(false, true);
2475 void MainWindow::slotDeselectTimelineTransition()
2477 if (m_activeTimeline) {
2478 m_activeTimeline->projectView()->selectTransition(false, true);
2482 void MainWindow::slotSelectAddTimelineClip()
2484 if (m_activeTimeline) {
2485 m_activeTimeline->projectView()->selectClip(true, true);
2489 void MainWindow::slotSelectAddTimelineTransition()
2491 if (m_activeTimeline) {
2492 m_activeTimeline->projectView()->selectTransition(true, true);
2496 void MainWindow::slotGroupClips()
2498 if (m_activeTimeline) {
2499 m_activeTimeline->projectView()->groupClips();
2503 void MainWindow::slotUnGroupClips()
2505 if (m_activeTimeline) {
2506 m_activeTimeline->projectView()->groupClips(false);
2510 void MainWindow::slotEditItemDuration()
2512 if (m_activeTimeline) {
2513 m_activeTimeline->projectView()->editItemDuration();
2517 void MainWindow::slotAddProjectClip(KUrl url)
2519 if (m_activeDocument)
2520 m_activeDocument->slotAddClipFile(url, QString());
2523 void MainWindow::slotAddTransition(QAction *result)
2525 if (!result) return;
2526 QStringList info = result->data().toStringList();
2527 if (info.isEmpty()) return;
2528 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2529 if (m_activeTimeline && !transition.isNull()) {
2530 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2534 void MainWindow::slotAddVideoEffect(QAction *result)
2536 if (!result) return;
2537 QStringList info = result->data().toStringList();
2538 if (info.isEmpty()) return;
2539 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2540 slotAddEffect(effect);
2543 void MainWindow::slotAddAudioEffect(QAction *result)
2545 if (!result) return;
2546 QStringList info = result->data().toStringList();
2547 if (info.isEmpty()) return;
2548 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2549 slotAddEffect(effect);
2552 void MainWindow::slotAddCustomEffect(QAction *result)
2554 if (!result) return;
2555 QStringList info = result->data().toStringList();
2556 if (info.isEmpty()) return;
2557 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2558 slotAddEffect(effect);
2561 void MainWindow::slotZoomIn()
2563 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2566 void MainWindow::slotZoomOut()
2568 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2571 void MainWindow::slotFitZoom()
2573 if (m_activeTimeline) {
2574 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2578 void MainWindow::slotSetZoom(int value)
2580 m_zoomSlider->setValue(value);
2583 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2585 m_statusProgressBar->setValue(progress);
2586 if (progress >= 0) {
2587 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2588 m_statusProgressBar->setVisible(true);
2589 } else if (progress == -2) {
2590 if (!message.isEmpty()) m_messageLabel->setMessage(message, ErrorMessage);
2591 m_statusProgressBar->setVisible(false);
2593 m_messageLabel->setMessage(QString(), DefaultMessage);
2594 m_statusProgressBar->setVisible(false);
2598 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2600 if (clip->clipType() == TEXT) {
2601 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2602 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2603 // template text clip
2605 // Get the list of existing templates
2607 filter << "*.kdenlivetitle";
2608 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2610 QDialog *dia = new QDialog(this);
2611 Ui::TemplateClip_UI dia_ui;
2612 dia_ui.setupUi(dia);
2614 const QString templatePath = clip->getProperty("resource");
2615 for (int i = 0; i < templateFiles.size(); ++i) {
2616 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2617 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2619 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2620 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2621 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2622 //warning: setting base directory doesn't work??
2623 KUrl startDir(titlepath);
2624 dia_ui.template_list->fileDialog()->setUrl(startDir);
2625 dia_ui.description->setText(clip->getProperty("description"));
2626 if (dia->exec() == QDialog::Accepted) {
2627 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2628 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2630 QMap <QString, QString> newprops;
2632 if (KUrl(textTemplate).path() != templatePath) {
2633 // The template was changed
2634 newprops.insert("resource", textTemplate);
2637 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2638 newprops.insert("description", dia_ui.description->toPlainText());
2641 QString newtemplate = newprops.value("xmltemplate");
2642 if (newtemplate.isEmpty()) newtemplate = templatePath;
2644 // template modified we need to update xmldata
2645 QString description = newprops.value("description");
2646 if (description.isEmpty()) description = clip->getProperty("description");
2647 else newprops.insert("templatetext", description);
2648 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2649 if (!newprops.isEmpty()) {
2650 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2651 m_activeDocument->commandStack()->push(command);
2657 QString path = clip->getProperty("resource");
2658 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2660 doc.setContent(clip->getProperty("xmldata"));
2661 dia_ui->setXml(doc);
2662 if (dia_ui->exec() == QDialog::Accepted) {
2663 QMap <QString, QString> newprops;
2664 newprops.insert("xmldata", dia_ui->xml().toString());
2665 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2666 // duration changed, we need to update duration
2667 newprops.insert("out", QString::number(dia_ui->outPoint()));
2669 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2670 m_activeDocument->commandStack()->push(command);
2671 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2672 m_activeDocument->setModified(true);
2676 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2679 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2680 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2681 if (dia.exec() == QDialog::Accepted) {
2682 QMap <QString, QString> newprops = dia.properties();
2683 if (newprops.isEmpty()) return;
2684 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2685 m_activeDocument->commandStack()->push(command);
2687 if (dia.needsTimelineRefresh()) {
2688 // update clip occurences in timeline
2689 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2695 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2697 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2698 if (dia.exec() == QDialog::Accepted) {
2699 QUndoCommand *command = new QUndoCommand();
2700 command->setText(i18n("Edit clips"));
2701 for (int i = 0; i < cliplist.count(); i++) {
2702 DocClipBase *clip = cliplist.at(i);
2703 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2705 m_activeDocument->commandStack()->push(command);
2706 for (int i = 0; i < cliplist.count(); i++) {
2707 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2712 void MainWindow::customEvent(QEvent* e)
2714 if (e->type() == QEvent::User) {
2715 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2718 void MainWindow::slotActivateEffectStackView()
2720 m_effectStack->raiseWindow(m_effectStackDock);
2723 void MainWindow::slotActivateTransitionView(Transition *t)
2725 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2728 void MainWindow::slotSnapRewind()
2730 if (m_projectMonitor->isActive()) {
2731 if (m_activeTimeline)
2732 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2733 } else m_clipMonitor->slotSeekToPreviousSnap();
2736 void MainWindow::slotSnapForward()
2738 if (m_projectMonitor->isActive()) {
2739 if (m_activeTimeline)
2740 m_activeTimeline->projectView()->slotSeekToNextSnap();
2741 } else m_clipMonitor->slotSeekToNextSnap();
2744 void MainWindow::slotClipStart()
2746 if (m_projectMonitor->isActive()) {
2747 if (m_activeTimeline)
2748 m_activeTimeline->projectView()->clipStart();
2752 void MainWindow::slotClipEnd()
2754 if (m_projectMonitor->isActive()) {
2755 if (m_activeTimeline)
2756 m_activeTimeline->projectView()->clipEnd();
2760 void MainWindow::slotZoneStart()
2762 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2763 else m_clipMonitor->slotZoneStart();
2766 void MainWindow::slotZoneEnd()
2768 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2769 else m_clipMonitor->slotZoneEnd();
2772 void MainWindow::slotChangeTool(QAction * action)
2774 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2775 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2776 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2779 void MainWindow::slotChangeEdit(QAction * action)
2781 if (!m_activeTimeline) return;
2782 if (action == m_overwriteEditTool) m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2783 else if (action == m_insertEditTool) m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2784 else m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2787 void MainWindow::slotSetTool(PROJECTTOOL tool)
2789 if (m_activeDocument && m_activeTimeline) {
2790 //m_activeDocument->setTool(tool);
2794 message = i18n("Ctrl + click to use spacer on current track only");
2797 message = i18n("Click on a clip to cut it");
2800 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2803 m_messageLabel->setMessage(message, InformationMessage);
2804 m_activeTimeline->projectView()->setTool(tool);
2808 void MainWindow::slotCopy()
2810 if (!m_activeDocument || !m_activeTimeline) return;
2811 m_activeTimeline->projectView()->copyClip();
2814 void MainWindow::slotPaste()
2816 if (!m_activeDocument || !m_activeTimeline) return;
2817 m_activeTimeline->projectView()->pasteClip();
2820 void MainWindow::slotPasteEffects()
2822 if (!m_activeDocument || !m_activeTimeline) return;
2823 m_activeTimeline->projectView()->pasteClipEffects();
2826 void MainWindow::slotFind()
2828 if (!m_activeDocument || !m_activeTimeline) return;
2829 m_projectSearch->setEnabled(false);
2830 m_findActivated = true;
2831 m_findString.clear();
2832 m_activeTimeline->projectView()->initSearchStrings();
2833 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2834 m_findTimer.start(5000);
2835 qApp->installEventFilter(this);
2838 void MainWindow::slotFindNext()
2840 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2841 statusBar()->showMessage(i18n("Found: %1", m_findString));
2843 statusBar()->showMessage(i18n("Reached end of project"));
2845 m_findTimer.start(4000);
2848 void MainWindow::findAhead()
2850 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2851 m_projectSearchNext->setEnabled(true);
2852 statusBar()->showMessage(i18n("Found: %1", m_findString));
2854 m_projectSearchNext->setEnabled(false);
2855 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2859 void MainWindow::findTimeout()
2861 m_projectSearchNext->setEnabled(false);
2862 m_findActivated = false;
2863 m_findString.clear();
2864 statusBar()->showMessage(i18n("Find stopped"), 3000);
2865 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2866 m_projectSearch->setEnabled(true);
2867 removeEventFilter(this);
2870 void MainWindow::slotClipInTimeline(const QString &clipId)
2872 if (m_activeTimeline && m_activeDocument) {
2873 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
2875 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
2876 inTimelineMenu->clear();
2878 QList <QAction *> actionList;
2880 for (int i = 0; i < matching.count(); ++i) {
2881 QString track = QString::number(matching.at(i).track);
2882 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
2884 QAction *a = new QAction(track + ": " + start, this);
2885 a->setData(QStringList() << track << start);
2886 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
2887 while (j < actionList.count()) {
2888 if (actionList.at(j)->text() > a->text()) break;
2891 actionList.insert(j, a);
2894 inTimelineMenu->addActions(actionList);
2896 if (matching.empty())
2897 inTimelineMenu->setEnabled(false);
2899 inTimelineMenu->setEnabled(true);
2903 void MainWindow::slotClipInProjectTree()
2905 if (m_activeTimeline) {
2906 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
2907 if (clipIds.isEmpty()) return;
2908 m_projectListDock->raise();
2909 for (int i = 0; i < clipIds.count(); i++) {
2910 m_projectList->selectItemById(clipIds.at(i));
2912 if (m_projectMonitor->isActive())
2913 slotSwitchMonitors();
2917 void MainWindow::slotSelectClipInTimeline()
2919 if (m_activeTimeline) {
2920 QAction *action = qobject_cast<QAction *>(sender());
2921 QStringList data = action->data().toStringList();
2922 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
2926 void MainWindow::keyPressEvent(QKeyEvent *ke)
2928 if (m_findActivated) {
2929 if (ke->key() == Qt::Key_Backspace) {
2930 m_findString = m_findString.left(m_findString.length() - 1);
2932 if (!m_findString.isEmpty()) {
2938 m_findTimer.start(4000);
2941 } else if (ke->key() == Qt::Key_Escape) {
2945 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2946 m_findString += ke->text();
2950 m_findTimer.start(4000);
2954 } else KXmlGuiWindow::keyPressEvent(ke);
2958 /** Gets called when the window gets hidden */
2959 void MainWindow::hideEvent(QHideEvent */*event*/)
2962 if (m_monitorManager)
2963 m_monitorManager->stopActiveMonitor();
2966 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2968 if (m_findActivated) {
2969 if (event->type() == QEvent::ShortcutOverride) {
2970 QKeyEvent* ke = (QKeyEvent*) event;
2971 if (ke->text().trimmed().isEmpty()) return false;
2974 } else return false;
2976 // pass the event on to the parent class
2977 return QMainWindow::eventFilter(obj, event);
2982 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2984 KDialog *dialog = new KDialog(this);
2985 dialog->setCaption("Save clip zone");
2986 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2988 QWidget *widget = new QWidget(dialog);
2989 dialog->setMainWidget(widget);
2991 QVBoxLayout *vbox = new QVBoxLayout(widget);
2992 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2993 QString path = m_activeDocument->projectFolder().path();
2995 path.append("untitled.mlt");
2996 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2997 url->setFilter("video/mlt-playlist");
2998 QLabel *label2 = new QLabel(i18n("Description:"), this);
2999 KLineEdit *edit = new KLineEdit(this);
3000 vbox->addWidget(label1);
3001 vbox->addWidget(url);
3002 vbox->addWidget(label2);
3003 vbox->addWidget(edit);
3004 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
3008 void MainWindow::slotSetInPoint()
3010 if (m_clipMonitor->isActive()) {
3011 m_clipMonitor->slotSetZoneStart();
3012 } else m_projectMonitor->slotSetZoneStart();
3013 //else m_activeTimeline->projectView()->setInPoint();
3016 void MainWindow::slotSetOutPoint()
3018 if (m_clipMonitor->isActive()) {
3019 m_clipMonitor->slotSetZoneEnd();
3020 } else m_projectMonitor->slotSetZoneEnd();
3021 // else m_activeTimeline->projectView()->setOutPoint();
3024 void MainWindow::slotResizeItemStart()
3026 if (m_activeTimeline) m_activeTimeline->projectView()->setInPoint();
3029 void MainWindow::slotResizeItemEnd()
3031 if (m_activeTimeline) m_activeTimeline->projectView()->setOutPoint();
3034 int MainWindow::getNewStuff(const QString &configFile)
3036 KNS3::Entry::List entries;
3037 #if KDE_IS_VERSION(4,3,80)
3038 KNS3::DownloadDialog dialog(configFile);
3040 entries = dialog.changedEntries();
3041 foreach(const KNS3::Entry &entry, entries) {
3042 if (entry.status() == KNS3::Entry::Installed)
3043 kDebug() << "// Installed files: " << entry.installedFiles();
3046 KNS::Engine engine(0);
3047 if (engine.init(configFile))
3048 entries = engine.downloadDialogModal(this);
3049 foreach(KNS::Entry *entry, entries) {
3050 if (entry->status() == KNS::Entry::Installed)
3051 kDebug() << "// Installed files: " << entry->installedFiles();
3053 #endif /* KDE_IS_VERSION(4,3,80) */
3054 return entries.size();
3057 void MainWindow::slotGetNewTitleStuff()
3059 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3060 TitleWidget::refreshTitleTemplates();
3063 void MainWindow::slotGetNewLumaStuff()
3065 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3066 initEffects::refreshLumas();
3067 m_activeTimeline->projectView()->reloadTransitionLumas();
3071 void MainWindow::slotGetNewRenderStuff()
3073 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3075 m_renderWidget->reloadProfiles();
3078 void MainWindow::slotGetNewMltProfileStuff()
3080 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3081 // update the list of profiles in settings dialog
3082 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3088 void MainWindow::slotAutoTransition()
3090 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
3093 void MainWindow::slotSplitAudio()
3095 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
3098 void MainWindow::slotUpdateClipType(QAction *action)
3100 if (m_activeTimeline) {
3101 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3102 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3103 else m_activeTimeline->projectView()->setAudioAndVideo();
3107 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3109 // We must stop the monitors since we create a new on in the dvd wizard
3110 m_clipMonitor->stop();
3111 m_projectMonitor->stop();
3112 DvdWizard w(url, profile, this);
3114 m_projectMonitor->start();
3117 void MainWindow::slotShowTimeline(bool show)
3119 if (show == false) {
3120 m_timelineState = saveState();
3121 centralWidget()->setHidden(true);
3123 centralWidget()->setHidden(false);
3124 restoreState(m_timelineState);
3128 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3130 //TODO: is there a way to maximize current widget?
3133 m_timelineState = saveState();
3134 QWidget *par = focusWidget()->parentWidget();
3135 while (par->parentWidget() && par->parentWidget() != this) {
3136 par = par->parentWidget();
3138 kDebug() << "CURRENT WIDGET: " << par->objectName();
3141 //centralWidget()->setHidden(false);
3142 //restoreState(m_timelineState);
3146 void MainWindow::loadTranscoders()
3148 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3151 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3152 KConfigGroup transConfig(config, "Transcoding");
3154 QMap< QString, QString > profiles = transConfig.entryMap();
3155 QMapIterator<QString, QString> i(profiles);
3156 while (i.hasNext()) {
3158 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3159 QAction *a = transMenu->addAction(i.key());
3161 if (data.count() > 1) {
3162 a->setToolTip(data.at(1));
3164 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3168 void MainWindow::slotTranscode(KUrl::List urls)
3173 if (urls.isEmpty()) {
3174 QAction *action = qobject_cast<QAction *>(sender());
3175 QStringList data = action->data().toStringList();
3176 params = data.at(0);
3177 if (data.count() > 1) desc = data.at(1);
3178 if (data.count() > 2) condition = data.at(2);
3179 urls << m_projectList->getConditionalUrls(condition);
3180 urls.removeAll(KUrl());
3182 if (urls.isEmpty()) {
3183 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3186 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3187 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3189 //QProcess::startDetached("ffmpeg", parameters);
3192 void MainWindow::slotTranscodeClip()
3194 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3195 if (urls.isEmpty()) return;
3196 slotTranscode(urls);
3199 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &group, const QString &name, const QString &file)
3201 if (m_activeDocument == NULL) return;
3202 m_activeDocument->setDocumentProperty("renderdestination", dest);
3203 m_activeDocument->setDocumentProperty("rendercategory", group);
3204 m_activeDocument->setDocumentProperty("renderprofile", name);
3205 m_activeDocument->setDocumentProperty("renderurl", file);
3206 m_activeDocument->setModified(true);
3210 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3212 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3214 QString playlistPath;
3217 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3218 QString path = m_renderWidget->getFreeScriptName();
3219 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3220 if (!ok || scriptPath.isEmpty()) return;
3221 scriptPath.prepend(scriptsFolder);
3222 QFile f(scriptPath);
3224 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3227 playlistPath = scriptPath + ".mlt";
3228 m_projectMonitor->saveSceneList(playlistPath);
3230 KTemporaryFile temp;
3231 temp.setAutoRemove(false);
3232 temp.setSuffix(".mlt");
3234 playlistPath = temp.fileName();
3235 m_projectMonitor->saveSceneList(playlistPath);
3238 if (!chapterFile.isEmpty()) {
3241 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3243 in = m_activeTimeline->inPoint();
3244 out = m_activeTimeline->outPoint();
3247 QDomElement chapters = doc.createElement("chapters");
3248 chapters.setAttribute("fps", m_activeDocument->fps());
3249 doc.appendChild(chapters);
3251 QDomElement guidesxml = m_activeDocument->guidesXml();
3252 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3253 for (int i = 0; i < nodes.count(); i++) {
3254 QDomElement e = nodes.item(i).toElement();
3256 QString comment = e.attribute("comment");
3257 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3258 if (time >= in && time < out) {
3259 if (zoneOnly) time = time - in;
3260 QDomElement chapter = doc.createElement("chapter");
3261 chapters.appendChild(chapter);
3262 chapter.setAttribute("title", comment);
3263 chapter.setAttribute("time", time);
3267 if (chapters.childNodes().count() > 0) {
3268 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3269 // Always insert a guide in pos 0
3270 QDomElement chapter = doc.createElement("chapter");
3271 chapters.insertBefore(chapter, QDomNode());
3272 chapter.setAttribute("title", i18n("Start"));
3273 chapter.setAttribute("time", "0");
3275 // save chapters file
3276 QFile file(chapterFile);
3277 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3278 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3280 file.write(doc.toString().toUtf8());
3281 if (file.error() != QFile::NoError) {
3282 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3289 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3292 void MainWindow::slotUpdateTimecodeFormat(int ix)
3294 KdenliveSettings::setFrametimecode(ix == 1);
3295 m_clipMonitor->updateTimecodeFormat();
3296 m_projectMonitor->updateTimecodeFormat();
3297 m_activeTimeline->projectView()->clearSelection();
3300 void MainWindow::slotRemoveFocus()
3302 statusBar()->setFocus();
3303 statusBar()->clearFocus();
3306 void MainWindow::slotRevert()
3308 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;
3309 KUrl url = m_activeDocument->url();
3310 closeCurrentDocument(false);
3311 doOpenFile(url, NULL);
3315 void MainWindow::slotShutdown()
3317 if (m_activeDocument) m_activeDocument->setModified(false);
3319 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3320 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3321 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3322 smserver.call("logout", 1, 2, 2);
3323 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3324 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3325 smserver.call("Shutdown");
3329 void MainWindow::slotUpdateTrackInfo()
3331 if (m_activeDocument)
3332 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3335 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3337 // Load the theme file
3339 if (action == NULL) theme = themename;
3340 else theme = action->data().toString();
3341 KdenliveSettings::setColortheme(theme);
3342 // Make palette for all widgets.
3344 if (theme.isEmpty())
3345 plt = QApplication::desktop()->palette();
3347 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3348 plt = KGlobalSettings::createApplicationPalette(config);
3351 kapp->setPalette(plt);
3352 const QObjectList children = statusBar()->children();
3354 foreach(QObject *child, children) {
3355 if (child->isWidgetType())
3356 ((QWidget*)child)->setPalette(plt);
3357 const QObjectList subchildren = child->children();
3358 foreach(QObject *subchild, subchildren) {
3359 if (subchild->isWidgetType())
3360 ((QWidget*)subchild)->setPalette(plt);
3366 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3368 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3369 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3370 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3371 const QSize bitsSize(24, 2);
3372 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3373 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3375 QPixmap pixmap(23, 16);
3376 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3378 KConfigGroup group(config, "WM");
3379 QPainter p(&pixmap);
3380 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3381 p.fillRect(1, 1, 7, 7, windowScheme.background());
3382 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3384 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3385 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3386 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3388 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3389 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3391 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3392 p.fillRect(1, 8, 7, 7, viewScheme.background());
3393 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3395 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3396 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3397 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3399 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3400 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3406 void MainWindow::slotSwitchMonitors()
3408 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3409 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3410 else m_projectList->focusTree();
3413 void MainWindow::slotInsertZoneToTree()
3415 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3416 QStringList info = m_clipMonitor->getZoneInfo();
3417 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3420 void MainWindow::slotInsertZoneToTimeline()
3422 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3423 QStringList info = m_clipMonitor->getZoneInfo();
3424 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3428 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3430 for (int i = 0; i < ids.size(); ++i) {
3431 m_activeTimeline->slotDeleteClip(ids.at(i));
3433 m_activeDocument->clipManager()->slotDeleteClips(ids);
3434 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3438 void MainWindow::slotShowTitleBars(bool show)
3441 m_effectStackDock->setTitleBarWidget(0);
3442 m_clipMonitorDock->setTitleBarWidget(0);
3443 m_projectMonitorDock->setTitleBarWidget(0);
3445 m_recMonitorDock->setTitleBarWidget(0);
3447 m_effectListDock->setTitleBarWidget(0);
3448 m_transitionConfigDock->setTitleBarWidget(0);
3449 m_projectListDock->setTitleBarWidget(0);
3450 m_undoViewDock->setTitleBarWidget(0);
3452 if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this));
3453 if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this));
3454 if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this));
3456 if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this));
3458 if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this));
3459 if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this));
3460 if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this));
3461 if (!m_undoViewDock->isFloating()) m_undoViewDock->setTitleBarWidget(new QWidget(this));
3463 KdenliveSettings::setShowtitlebars(show);
3466 void MainWindow::slotSwitchTitles()
3468 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3471 #include "mainwindow.moc"