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"
54 #include <KApplication>
58 #include <KActionCollection>
59 #include <KStandardAction>
60 #include <KFileDialog>
61 #include <KMessageBox>
63 #include <KIO/NetAccess>
66 #include <KConfigDialog>
67 #include <KXMLGUIFactory>
69 #include <kstandarddirs.h>
70 #include <KUrlRequesterDialog>
71 #include <KTemporaryFile>
72 #include <KActionMenu>
75 #include <ktogglefullscreenaction.h>
77 #include <KNotification>
78 #include <KNotifyConfigWidget>
79 #include <knewstuff2/engine.h>
80 #include <knewstuff2/ui/knewstuffaction.h>
82 #include <QTextStream>
89 static const char version[] = VERSION;
91 static const int ID_TIMELINE_POS = 0;
98 EffectsList MainWindow::videoEffects;
99 EffectsList MainWindow::audioEffects;
100 EffectsList MainWindow::customEffects;
101 EffectsList MainWindow::transitions;
103 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
104 KXmlGuiWindow(parent),
105 m_activeDocument(NULL),
106 m_activeTimeline(NULL),
107 m_renderWidget(NULL),
108 #ifndef NO_JOGSHUTTLE
110 #endif /* NO_JOGSHUTTLE */
111 m_findActivated(false)
114 // Create DBus interface
115 new MainWindowAdaptor(this);
116 QDBusConnection dbus = QDBusConnection::sessionBus();
117 dbus.registerObject("/MainWindow", this);
119 setlocale(LC_NUMERIC, "POSIX");
120 setFont(KGlobalSettings::toolBarFont());
121 parseProfiles(MltPath);
122 m_commandStack = new QUndoGroup;
123 m_timelineArea = new KTabWidget(this);
124 m_timelineArea->setTabReorderingEnabled(true);
125 m_timelineArea->setTabBarHidden(true);
127 QToolButton *closeTabButton = new QToolButton;
128 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
129 closeTabButton->setIcon(KIcon("tab-close"));
130 closeTabButton->adjustSize();
131 closeTabButton->setToolTip(i18n("Close the current tab"));
132 m_timelineArea->setCornerWidget(closeTabButton);
133 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
135 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
136 m_findTimer.setSingleShot(true);
138 // FIXME: the next call returns a newly allocated object, which leaks
139 initEffects::parseEffectFiles();
140 //initEffects::parseCustomEffectsFile();
142 m_monitorManager = new MonitorManager();
144 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
145 m_projectListDock->setObjectName("project_tree");
146 m_projectList = new ProjectList(this);
147 m_projectListDock->setWidget(m_projectList);
148 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
150 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
151 m_effectListDock->setObjectName("effect_list");
152 m_effectList = new EffectsListView();
154 //m_effectList = new KListWidget(this);
155 m_effectListDock->setWidget(m_effectList);
156 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
158 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
159 m_effectStackDock->setObjectName("effect_stack");
160 m_effectStack = new EffectStackView(this);
161 m_effectStackDock->setWidget(m_effectStack);
162 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
164 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
165 m_transitionConfigDock->setObjectName("transition");
166 m_transitionConfig = new TransitionSettings(this);
167 m_transitionConfigDock->setWidget(m_transitionConfig);
168 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
170 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
171 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
175 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
176 m_clipMonitorDock->setObjectName("clip_monitor");
177 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
178 m_clipMonitorDock->setWidget(m_clipMonitor);
179 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
180 //m_clipMonitor->stop();
182 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
183 m_projectMonitorDock->setObjectName("project_monitor");
184 m_projectMonitor = new Monitor("project", m_monitorManager, this);
185 m_projectMonitorDock->setWidget(m_projectMonitor);
186 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
188 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
189 m_recMonitorDock->setObjectName("record_monitor");
190 m_recMonitor = new RecMonitor("record", this);
191 m_recMonitorDock->setWidget(m_recMonitor);
192 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
194 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
195 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
197 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
198 m_undoViewDock->setObjectName("undo_history");
199 m_undoView = new QUndoView(this);
200 m_undoView->setCleanIcon(KIcon("edit-clear"));
201 m_undoView->setEmptyLabel(i18n("Clean"));
202 m_undoViewDock->setWidget(m_undoView);
203 m_undoView->setGroup(m_commandStack);
204 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
206 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
207 //overviewDock->setObjectName("project_overview");
208 //m_overView = new CustomTrackView(NULL, NULL, this);
209 //overviewDock->setWidget(m_overView);
210 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
213 //tabifyDockWidget(projectListDock, effectListDock);
214 tabifyDockWidget(m_projectListDock, m_effectStackDock);
215 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
216 //tabifyDockWidget(projectListDock, undoViewDock);
219 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
220 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
221 setCentralWidget(m_timelineArea);
225 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
226 guiFactory()->addClient(sp);*/
229 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
231 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
232 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
233 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)));
235 // build effects menus
237 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
239 QStringList effectInfo;
240 QMap<QString, QStringList> effectsList;
241 for (int ix = 0; ix < videoEffects.count(); ix++) {
242 effectInfo = videoEffects.effectIdInfo(ix);
243 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
246 foreach(const QStringList &value, effectsList) {
247 action = new QAction(value.at(0), this);
248 action->setData(value);
249 videoEffectsMenu->addAction(action);
252 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
256 for (int ix = 0; ix < audioEffects.count(); ix++) {
257 effectInfo = audioEffects.effectIdInfo(ix);
258 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
261 foreach(const QStringList &value, effectsList) {
262 action = new QAction(value.at(0), this);
263 action->setData(value);
264 audioEffectsMenu->addAction(action);
267 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
269 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
270 else m_customEffectsMenu->setEnabled(true);
273 for (int ix = 0; ix < customEffects.count(); ix++) {
274 effectInfo = customEffects.effectIdInfo(ix);
275 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
278 foreach(const QStringList &value, effectsList) {
279 action = new QAction(value.at(0), this);
280 action->setData(value);
281 m_customEffectsMenu->addAction(action);
284 QMenu *newEffect = new QMenu(this);
285 newEffect->addMenu(videoEffectsMenu);
286 newEffect->addMenu(audioEffectsMenu);
287 newEffect->addMenu(m_customEffectsMenu);
288 m_effectStack->setMenu(newEffect);
291 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
292 const QList<QAction *> viewActions = createPopupMenu()->actions();
293 viewMenu->insertActions(NULL, viewActions);
295 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
296 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
297 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
299 m_timelineContextMenu = new QMenu(this);
300 m_timelineContextClipMenu = new QMenu(this);
301 m_timelineContextTransitionMenu = new QMenu(this);
304 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
305 QStringList effects = transitions.effectNames();
308 for (int ix = 0; ix < transitions.count(); ix++) {
309 effectInfo = transitions.effectIdInfo(ix);
310 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
312 foreach(const QStringList &value, effectsList) {
313 action = new QAction(value.at(0), this);
314 action->setData(value);
315 transitionsMenu->addAction(action);
317 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
319 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
320 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
321 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
323 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
324 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
325 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
326 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
327 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
328 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
329 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
330 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
332 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
333 m_timelineContextClipMenu->addMenu(markersMenu);
334 m_timelineContextClipMenu->addMenu(transitionsMenu);
335 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
336 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
337 //TODO: re-enable custom effects menu when it is implemented
338 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
340 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
341 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
343 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
345 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
346 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
347 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
348 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
349 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
350 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
352 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
353 slotConnectMonitors();
355 // Open or create a file. Command line argument passed in Url has
356 // precedence, then "openlastproject", then just a plain empty file.
357 // If opening Url fails, openlastproject will _not_ be used.
358 if (!Url.isEmpty()) {
361 if (KdenliveSettings::openlastproject()) {
365 if (m_timelineArea->count() == 0) {
369 #ifndef NO_JOGSHUTTLE
370 activateShuttleDevice();
371 #endif /* NO_JOGSHUTTLE */
372 m_projectListDock->raise();
375 void MainWindow::queryQuit()
377 kDebug() << "----- SAVING CONFUIG";
378 if (queryClose()) kapp->quit();
382 bool MainWindow::queryClose()
385 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
386 if (m_activeDocument && m_activeDocument->isModified()) {
387 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
388 case KMessageBox::Yes :
389 // save document here. If saving fails, return false;
391 case KMessageBox::No :
401 void MainWindow::loadPlugins()
403 foreach(QObject *plugin, QPluginLoader::staticInstances())
404 populateMenus(plugin);
406 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
408 filters << "libkdenlive*";
409 foreach(const QString &folder, directories) {
410 kDebug() << "// PARSING FIOLER: " << folder;
411 QDir pluginsDir(folder);
412 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
413 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
414 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
415 QObject *plugin = loader.instance();
417 populateMenus(plugin);
418 m_pluginFileNames += fileName;
419 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
425 void MainWindow::populateMenus(QObject *plugin)
427 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
428 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
430 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
434 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
435 QMenu *menu, const char *member,
436 QActionGroup *actionGroup)
438 kDebug() << "// ADD to MENU" << texts;
439 foreach(const QString &text, texts) {
440 QAction *action = new QAction(text, plugin);
441 action->setData(text);
442 connect(action, SIGNAL(triggered()), this, member);
443 menu->addAction(action);
446 action->setCheckable(true);
447 actionGroup->addAction(action);
452 void MainWindow::aboutPlugins()
454 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
459 void MainWindow::generateClip()
461 QAction *action = qobject_cast<QAction *>(sender());
462 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
464 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
465 if (!clipUrl.isEmpty()) {
466 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
470 void MainWindow::saveProperties(KConfig*)
472 // save properties here,used by session management
477 void MainWindow::readProperties(KConfig *config)
479 // read properties here,used by session management
480 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
481 openFile(KUrl(Lastproject));
484 void MainWindow::slotReloadEffects()
486 initEffects::parseCustomEffectsFile();
487 m_customEffectsMenu->clear();
488 const QStringList effects = customEffects.effectNames();
490 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
491 else m_customEffectsMenu->setEnabled(true);
493 foreach(const QString &name, effects) {
494 action = new QAction(name, this);
495 action->setData(name);
496 m_customEffectsMenu->addAction(action);
498 m_effectList->reloadEffectList();
501 #ifndef NO_JOGSHUTTLE
502 void MainWindow::activateShuttleDevice()
506 if (KdenliveSettings::enableshuttle() == false) return;
507 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
508 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
509 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
510 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
511 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
512 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
513 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
516 void MainWindow::slotShuttleButton(int code)
520 slotShuttleAction(KdenliveSettings::shuttle1());
523 slotShuttleAction(KdenliveSettings::shuttle2());
526 slotShuttleAction(KdenliveSettings::shuttle3());
529 slotShuttleAction(KdenliveSettings::shuttle4());
532 slotShuttleAction(KdenliveSettings::shuttle5());
537 void MainWindow::slotShuttleAction(int code)
543 m_monitorManager->slotPlay();
546 m_monitorManager->slotPlay();
550 #endif /* NO_JOGSHUTTLE */
552 void MainWindow::configureNotifications()
554 KNotifyConfigWidget::configure(this);
557 void MainWindow::slotFullScreen()
559 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
562 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
564 if (!m_activeDocument) return;
565 if (effect.isNull()) {
566 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
569 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
570 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
573 void MainWindow::slotRaiseMonitor(bool clipMonitor)
575 if (clipMonitor) m_clipMonitorDock->raise();
576 else m_projectMonitorDock->raise();
579 void MainWindow::slotSetClipDuration(const QString &id, int duration)
581 if (!m_activeDocument) return;
582 m_activeDocument->setProducerDuration(id, duration);
585 void MainWindow::slotConnectMonitors()
588 m_projectList->setRenderer(m_projectMonitor->render);
589 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
590 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
591 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
592 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
593 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)));
595 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
597 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
599 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
600 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
602 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
603 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
606 void MainWindow::slotAdjustClipMonitor()
608 m_clipMonitorDock->updateGeometry();
609 m_clipMonitorDock->adjustSize();
610 m_clipMonitor->resetSize();
613 void MainWindow::slotAdjustProjectMonitor()
615 m_projectMonitorDock->updateGeometry();
616 m_projectMonitorDock->adjustSize();
617 m_projectMonitor->resetSize();
620 void MainWindow::setupActions()
623 KActionCollection* collection = actionCollection();
624 m_timecodeFormat = new KComboBox(this);
625 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
626 m_timecodeFormat->addItem(i18n("Frames"));
628 m_statusProgressBar = new QProgressBar(this);
629 m_statusProgressBar->setMinimum(0);
630 m_statusProgressBar->setMaximum(100);
631 m_statusProgressBar->setMaximumWidth(150);
632 m_statusProgressBar->setVisible(false);
634 QWidget *w = new QWidget;
636 QHBoxLayout *layout = new QHBoxLayout;
637 w->setLayout(layout);
638 layout->setContentsMargins(5, 0, 5, 0);
639 QToolBar *toolbar = new QToolBar("statusToolBar", this);
642 m_toolGroup = new QActionGroup(this);
644 QString style1 = "QToolButton {background-color: rgba(230, 230, 230, 220); 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;}";
646 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
647 toolbar->addAction(m_buttonSelectTool);
648 m_buttonSelectTool->setCheckable(true);
649 m_buttonSelectTool->setChecked(true);
651 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
652 toolbar->addAction(m_buttonRazorTool);
653 m_buttonRazorTool->setCheckable(true);
654 m_buttonRazorTool->setChecked(false);
656 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
657 toolbar->addAction(m_buttonSpacerTool);
658 m_buttonSpacerTool->setCheckable(true);
659 m_buttonSpacerTool->setChecked(false);
661 m_toolGroup->addAction(m_buttonSelectTool);
662 m_toolGroup->addAction(m_buttonRazorTool);
663 m_toolGroup->addAction(m_buttonSpacerTool);
664 m_toolGroup->setExclusive(true);
665 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
667 QWidget * actionWidget;
668 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
669 actionWidget->setMaximumWidth(24);
670 actionWidget->setMinimumHeight(17);
672 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
673 actionWidget->setMaximumWidth(24);
674 actionWidget->setMinimumHeight(17);
676 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
677 actionWidget->setMaximumWidth(24);
678 actionWidget->setMinimumHeight(17);
680 toolbar->setStyleSheet(style1);
681 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
683 toolbar->addSeparator();
684 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
685 toolbar->addAction(m_buttonFitZoom);
686 m_buttonFitZoom->setCheckable(false);
687 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
689 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
690 actionWidget->setMaximumWidth(24);
691 actionWidget->setMinimumHeight(17);
693 m_zoomSlider = new QSlider(Qt::Horizontal, this);
694 m_zoomSlider->setMaximum(13);
695 m_zoomSlider->setPageStep(1);
697 m_zoomSlider->setMaximumWidth(150);
698 m_zoomSlider->setMinimumWidth(100);
700 const int contentHeight = QFontMetrics(w->font()).height() + 8;
702 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
703 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
705 m_zoomSlider->setStyleSheet(style);
707 //m_zoomSlider->height() + 5;
708 statusBar()->setMinimumHeight(contentHeight);
711 toolbar->addWidget(m_zoomSlider);
713 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
714 toolbar->addAction(m_buttonVideoThumbs);
715 m_buttonVideoThumbs->setCheckable(true);
716 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
717 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
719 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
720 toolbar->addAction(m_buttonAudioThumbs);
721 m_buttonAudioThumbs->setCheckable(true);
722 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
723 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
725 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
726 toolbar->addAction(m_buttonShowMarkers);
727 m_buttonShowMarkers->setCheckable(true);
728 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
729 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
731 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
732 toolbar->addAction(m_buttonSnap);
733 m_buttonSnap->setCheckable(true);
734 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
735 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
736 layout->addWidget(toolbar);
739 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
740 actionWidget->setMaximumWidth(24);
741 actionWidget->setMinimumHeight(17);
743 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
744 actionWidget->setMaximumWidth(24);
745 actionWidget->setMinimumHeight(17);
747 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
748 actionWidget->setMaximumWidth(24);
749 actionWidget->setMinimumHeight(17);
751 actionWidget = toolbar->widgetForAction(m_buttonSnap);
752 actionWidget->setMaximumWidth(24);
753 actionWidget->setMinimumHeight(17);
755 m_messageLabel = new StatusBarMessageLabel(this);
756 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
758 statusBar()->addWidget(m_messageLabel, 10);
759 statusBar()->addWidget(m_statusProgressBar, 0);
760 statusBar()->addPermanentWidget(w);
761 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
762 statusBar()->addPermanentWidget(m_timecodeFormat);
763 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
764 m_messageLabel->hide();
766 collection->addAction("select_tool", m_buttonSelectTool);
767 collection->addAction("razor_tool", m_buttonRazorTool);
768 collection->addAction("spacer_tool", m_buttonSpacerTool);
770 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
771 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
772 collection->addAction("show_markers", m_buttonShowMarkers);
773 collection->addAction("snap", m_buttonSnap);
774 collection->addAction("zoom_fit", m_buttonFitZoom);
776 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
777 collection->addAction("zoom_in", zoomIn);
778 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
779 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
781 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
782 collection->addAction("zoom_out", zoomOut);
783 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
784 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
786 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
787 collection->addAction("project_find", m_projectSearch);
788 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
789 m_projectSearch->setShortcut(Qt::Key_Slash);
791 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
792 collection->addAction("project_find_next", m_projectSearchNext);
793 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
794 m_projectSearchNext->setShortcut(Qt::Key_F3);
795 m_projectSearchNext->setEnabled(false);
797 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
798 collection->addAction("manage_profiles", profilesAction);
799 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
801 KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
803 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
805 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
807 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
808 collection->addAction("run_wizard", wizAction);
809 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
811 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
812 collection->addAction("project_settings", projectAction);
813 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
815 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
816 collection->addAction("project_render", projectRender);
817 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
818 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
820 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
821 KShortcut playShortcut;
822 playShortcut.setPrimary(Qt::Key_Space);
823 playShortcut.setAlternate(Qt::Key_K);
824 monitorPlay->setShortcut(playShortcut);
825 collection->addAction("monitor_play", monitorPlay);
826 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
828 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
829 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
830 collection->addAction("monitor_play_zone", m_playZone);
831 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
833 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
834 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
835 collection->addAction("monitor_loop_zone", m_loopZone);
836 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
838 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
839 collection->addAction("dvd_wizard", dvdWizard);
840 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
842 KAction *markIn = collection->addAction("mark_in");
843 markIn->setText(i18n("Set In Point"));
844 markIn->setShortcut(Qt::Key_I);
845 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
847 KAction *markOut = collection->addAction("mark_out");
848 markOut->setText(i18n("Set Out Point"));
849 markOut->setShortcut(Qt::Key_O);
850 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
852 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
853 monitorSeekBackward->setShortcut(Qt::Key_J);
854 collection->addAction("monitor_seek_backward", monitorSeekBackward);
855 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
857 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
858 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
859 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
860 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
862 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
863 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
864 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
865 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
867 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
868 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
869 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
870 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
872 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
873 monitorSeekForward->setShortcut(Qt::Key_L);
874 collection->addAction("monitor_seek_forward", monitorSeekForward);
875 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
877 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
878 clipStart->setShortcut(Qt::Key_Home);
879 collection->addAction("seek_clip_start", clipStart);
880 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
882 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
883 clipEnd->setShortcut(Qt::Key_End);
884 collection->addAction("seek_clip_end", clipEnd);
885 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
887 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
888 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
889 collection->addAction("seek_start", projectStart);
890 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
892 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
893 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
894 collection->addAction("seek_end", projectEnd);
895 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
897 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
898 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
899 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
900 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
902 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
903 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
904 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
905 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
907 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
908 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
909 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
910 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
912 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
913 deleteTimelineClip->setShortcut(Qt::Key_Delete);
914 collection->addAction("delete_timeline_clip", deleteTimelineClip);
915 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
917 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
918 collection->addAction("change_clip_speed", editTimelineClipSpeed);
919 editTimelineClipSpeed->setData("change_speed");
920 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
922 KAction *stickTransition = collection->addAction("auto_transition");
923 stickTransition->setData(QString("auto"));
924 stickTransition->setCheckable(true);
925 stickTransition->setEnabled(false);
926 stickTransition->setText(i18n("Automatic Transition"));
927 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
929 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
930 collection->addAction("group_clip", groupClip);
931 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
933 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
934 collection->addAction("ungroup_clip", ungroupClip);
935 ungroupClip->setData("ungroup_clip");
936 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
938 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
939 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
940 collection->addAction("cut_timeline_clip", cutTimelineClip);
941 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
943 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
944 collection->addAction("add_clip_marker", addClipMarker);
945 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
947 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
948 collection->addAction("delete_clip_marker", deleteClipMarker);
949 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
951 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
952 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
953 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
955 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
956 collection->addAction("edit_clip_marker", editClipMarker);
957 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
959 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
960 collection->addAction("split_audio", splitAudio);
961 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
963 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
964 collection->addAction("clip_audio_only", audioOnly);
965 audioOnly->setData("clip_audio_only");
966 audioOnly->setCheckable(true);
968 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
969 collection->addAction("clip_video_only", videoOnly);
970 videoOnly->setData("clip_video_only");
971 videoOnly->setCheckable(true);
973 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
974 collection->addAction("clip_audio_and_video", audioAndVideo);
975 audioAndVideo->setData("clip_audio_and_video");
976 audioAndVideo->setCheckable(true);
978 m_clipTypeGroup = new QActionGroup(this);
979 m_clipTypeGroup->addAction(audioOnly);
980 m_clipTypeGroup->addAction(videoOnly);
981 m_clipTypeGroup->addAction(audioAndVideo);
982 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
983 m_clipTypeGroup->setEnabled(false);
985 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
986 collection->addAction("insert_space", insertSpace);
987 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
989 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
990 collection->addAction("delete_space", removeSpace);
991 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
993 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
994 collection->addAction("insert_track", insertTrack);
995 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
997 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
998 collection->addAction("delete_track", deleteTrack);
999 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1001 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1002 collection->addAction("change_track", changeTrack);
1003 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1005 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1006 collection->addAction("add_guide", addGuide);
1007 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1009 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1010 collection->addAction("delete_guide", delGuide);
1011 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1013 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1014 collection->addAction("edit_guide", editGuide);
1015 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1017 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1018 collection->addAction("delete_all_guides", delAllGuides);
1019 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1021 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1022 collection->addAction("paste_effects", pasteEffects);
1023 pasteEffects->setData("paste_effects");
1024 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1026 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1027 collection->addAction("show_timeline", showTimeline);
1028 showTimeline->setCheckable(true);
1029 showTimeline->setChecked(true);
1030 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1032 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1033 collection->addAction("maximize_current", maxCurrent);
1034 maxCurrent->setCheckable(true);
1035 maxCurrent->setChecked(false);
1036 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1039 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1041 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1043 KStandardAction::open(this, SLOT(openFile()), collection);
1045 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1047 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1049 KStandardAction::openNew(this, SLOT(newFile()), collection);
1051 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1053 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1055 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1057 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1059 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1060 undo->setEnabled(false);
1061 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1063 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1064 redo->setEnabled(false);
1065 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1067 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1070 //TODO: Add status tooltip to actions ?
1071 connect(collection, SIGNAL(actionHovered(QAction*)),
1072 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1075 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1076 collection->addAction("add_clip", addClip);
1077 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1079 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1080 collection->addAction("add_color_clip", addColorClip);
1081 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1083 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1084 collection->addAction("add_slide_clip", addSlideClip);
1085 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1087 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1088 collection->addAction("add_text_clip", addTitleClip);
1089 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1091 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1092 collection->addAction("add_folder", addFolderButton);
1093 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1095 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1096 collection->addAction("clip_properties", clipProperties);
1097 clipProperties->setData("clip_properties");
1098 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1099 clipProperties->setEnabled(false);
1101 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1102 collection->addAction("edit_clip", openClip);
1103 openClip->setData("edit_clip");
1104 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1105 openClip->setEnabled(false);
1107 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1108 collection->addAction("delete_clip", deleteClip);
1109 deleteClip->setData("delete_clip");
1110 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1111 deleteClip->setEnabled(false);
1113 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1114 collection->addAction("reload_clip", reloadClip);
1115 reloadClip->setData("reload_clip");
1116 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1117 reloadClip->setEnabled(false);
1119 QMenu *addClips = new QMenu();
1120 addClips->addAction(addClip);
1121 addClips->addAction(addColorClip);
1122 addClips->addAction(addSlideClip);
1123 addClips->addAction(addTitleClip);
1124 addClips->addAction(addFolderButton);
1126 addClips->addAction(reloadClip);
1127 addClips->addAction(clipProperties);
1128 addClips->addAction(openClip);
1129 addClips->addAction(deleteClip);
1130 m_projectList->setupMenu(addClips, addClip);
1132 //connect(collection, SIGNAL( clearStatusText() ),
1133 //statusBar(), SLOT( clear() ) );
1136 void MainWindow::slotDisplayActionMessage(QAction *a)
1138 statusBar()->showMessage(a->data().toString(), 3000);
1141 void MainWindow::saveOptions()
1143 KdenliveSettings::self()->writeConfig();
1144 KSharedConfigPtr config = KGlobal::config();
1145 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1146 KConfigGroup treecolumns(config, "Project Tree");
1147 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1151 void MainWindow::readOptions()
1153 KSharedConfigPtr config = KGlobal::config();
1154 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1155 KConfigGroup initialGroup(config, "version");
1156 bool upgrade = false;
1157 if (initialGroup.exists()) {
1158 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1161 if (initialGroup.readEntry("version") == "0.7") {
1162 //Add new settings from 0.7.1
1163 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1164 QString path = QDir::homePath() + "/kdenlive";
1165 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1166 KdenliveSettings::setDefaultprojectfolder(path);
1172 if (!initialGroup.exists() || upgrade) {
1173 // this is our first run, show Wizard
1174 Wizard *w = new Wizard(upgrade, this);
1175 if (w->exec() == QDialog::Accepted && w->isOk()) {
1176 w->adjustSettings();
1177 initialGroup.writeEntry("version", version);
1183 KConfigGroup treecolumns(config, "Project Tree");
1184 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1185 if (!state.isEmpty())
1186 m_projectList->setHeaderInfo(state);
1189 void MainWindow::slotRunWizard()
1191 Wizard *w = new Wizard(false, this);
1192 if (w->exec() == QDialog::Accepted && w->isOk()) {
1193 w->adjustSettings();
1198 void MainWindow::newFile(bool showProjectSettings)
1200 QString profileName;
1202 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1203 if (!showProjectSettings && m_timelineArea->count() == 0) {
1204 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1205 profileName = KdenliveSettings::default_profile();
1207 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1208 if (w->exec() != QDialog::Accepted) return;
1209 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1210 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1211 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1212 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1213 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1214 profileName = w->selectedProfile();
1215 projectFolder = w->selectedFolder();
1216 projectTracks = w->tracks();
1219 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1220 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1221 TrackView *trackView = new TrackView(doc, this);
1222 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1223 if (m_timelineArea->count() == 1) {
1224 connectDocumentInfo(doc);
1225 connectDocument(trackView, doc);
1226 } else m_timelineArea->setTabBarHidden(false);
1227 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1230 void MainWindow::activateDocument()
1232 if (m_timelineArea->currentWidget() == NULL) return;
1233 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1234 KdenliveDoc *currentDoc = currentTab->document();
1235 connectDocumentInfo(currentDoc);
1236 connectDocument(currentTab, currentDoc);
1239 void MainWindow::closeCurrentDocument()
1241 QWidget *w = m_timelineArea->currentWidget();
1243 // closing current document
1244 int ix = m_timelineArea->currentIndex() + 1;
1245 if (ix == m_timelineArea->count()) ix = 0;
1246 m_timelineArea->setCurrentIndex(ix);
1247 TrackView *tabToClose = (TrackView *) w;
1248 KdenliveDoc *docToClose = tabToClose->document();
1249 if (docToClose && docToClose->isModified()) {
1250 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1251 case KMessageBox::Yes :
1252 // save document here. If saving fails, return false;
1253 if (saveFile() == false) return;
1255 case KMessageBox::Cancel :
1261 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1262 if (m_timelineArea->count() == 1) {
1263 m_timelineArea->setTabBarHidden(true);
1264 m_closeAction->setEnabled(false);
1268 if (m_timelineArea->count() == 0) {
1269 m_activeDocument = NULL;
1270 m_effectStack->clear();
1271 m_transitionConfig->slotTransitionItemSelected(NULL, false);
1275 bool MainWindow::saveFileAs(const QString &outputFileName)
1277 QString currentSceneList;
1278 if (KdenliveSettings::dropbframes()) {
1279 KdenliveSettings::setDropbframes(false);
1280 m_activeDocument->clipManager()->updatePreviewSettings();
1281 currentSceneList = m_projectMonitor->sceneList();
1282 KdenliveSettings::setDropbframes(true);
1283 m_activeDocument->clipManager()->updatePreviewSettings();
1284 } else currentSceneList = m_projectMonitor->sceneList();
1286 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1289 // Save timeline thumbnails
1290 m_activeTimeline->projectView()->saveThumbnails();
1291 m_activeDocument->setUrl(KUrl(outputFileName));
1292 if (m_activeDocument->m_autosave == NULL) {
1293 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1294 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1295 setCaption(m_activeDocument->description());
1296 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1297 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1298 m_activeDocument->setModified(false);
1299 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1303 bool MainWindow::saveFileAs()
1305 // Check that the Kdenlive mime type is correctly installed
1306 QString mimetype = "application/x-kdenlive";
1307 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1308 if (!mime) mimetype = "*.kdenlive";
1310 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1311 if (outputFile.isEmpty()) return false;
1312 if (QFile::exists(outputFile)) {
1313 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1315 return saveFileAs(outputFile);
1318 bool MainWindow::saveFile()
1320 if (!m_activeDocument) return true;
1321 if (m_activeDocument->url().isEmpty()) {
1322 return saveFileAs();
1324 bool result = saveFileAs(m_activeDocument->url().path());
1325 m_activeDocument->m_autosave->resize(0);
1330 void MainWindow::openFile()
1332 // Check that the Kdenlive mime type is correctly installed
1333 QString mimetype = "application/x-kdenlive";
1334 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1335 if (!mime) mimetype = "*.kdenlive";
1337 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1338 if (url.isEmpty()) return;
1339 m_fileOpenRecent->addUrl(url);
1343 void MainWindow::openLastFile()
1345 KSharedConfigPtr config = KGlobal::config();
1346 KUrl::List urls = m_fileOpenRecent->urls();
1347 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1348 if (urls.isEmpty()) newFile(false);
1349 else openFile(urls.last());
1352 void MainWindow::openFile(const KUrl &url)
1354 // Check if the document is already opened
1355 const int ct = m_timelineArea->count();
1356 bool isOpened = false;
1358 for (i = 0; i < ct; i++) {
1359 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1360 KdenliveDoc *doc = tab->document();
1361 if (doc->url() == url) {
1367 m_timelineArea->setCurrentIndex(i);
1371 // Check for backup file
1372 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1373 if (!staleFiles.isEmpty()) {
1374 if (KMessageBox::questionYesNo(this,
1375 i18n("Auto-saved files exist. Do you want to recover them now?"),
1376 i18n("File Recovery"),
1377 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1378 recoverFiles(staleFiles);
1381 // remove the stale files
1382 foreach(KAutoSaveFile *stale, staleFiles) {
1383 stale->open(QIODevice::ReadWrite);
1388 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1389 doOpenFile(url, NULL);
1392 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1394 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1395 if (stale == NULL) {
1396 stale = new KAutoSaveFile(url, doc);
1397 doc->m_autosave = stale;
1399 doc->m_autosave = stale;
1400 doc->setUrl(stale->managedFile());
1401 doc->setModified(true);
1402 stale->setParent(doc);
1404 connectDocumentInfo(doc);
1405 TrackView *trackView = new TrackView(doc, this);
1406 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1407 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1408 trackView->setDuration(trackView->duration());
1409 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1411 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1412 slotGotProgressInfo(QString(), -1);
1413 m_clipMonitor->refreshMonitor(true);
1414 m_projectMonitor->adjustRulerSize(trackView->duration());
1415 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1418 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1420 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1421 foreach(KAutoSaveFile *stale, staleFiles) {
1422 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1423 // show an error message; we could not steal the lockfile
1424 // maybe another application got to the file before us?
1428 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1429 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1430 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1431 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1436 void MainWindow::parseProfiles(const QString &mltPath)
1438 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1440 //KdenliveSettings::setDefaulttmpfolder();
1441 if (!mltPath.isEmpty()) {
1442 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1443 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1446 if (KdenliveSettings::mltpath().isEmpty()) {
1447 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1449 if (KdenliveSettings::rendererpath().isEmpty()) {
1450 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1451 if (!QFile::exists(inigoPath))
1452 inigoPath = KStandardDirs::findExe("inigo");
1453 else KdenliveSettings::setRendererpath(inigoPath);
1455 QStringList profilesFilter;
1456 profilesFilter << "*";
1457 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1459 if (profilesList.isEmpty()) {
1460 // Cannot find MLT path, try finding inigo
1461 QString profilePath = KdenliveSettings::rendererpath();
1462 if (!profilePath.isEmpty()) {
1463 profilePath = profilePath.section('/', 0, -3);
1464 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1465 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1468 if (profilesList.isEmpty()) {
1469 // Cannot find the MLT profiles, ask for location
1470 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1471 getUrl->fileDialog()->setMode(KFile::Directory);
1472 if (getUrl->exec() == QDialog::Rejected) {
1475 KUrl mltPath = getUrl->selectedUrl();
1477 if (mltPath.isEmpty()) ::exit(0);
1478 KdenliveSettings::setMltpath(mltPath.path());
1479 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1483 if (KdenliveSettings::rendererpath().isEmpty()) {
1484 // Cannot find the MLT inigo renderer, ask for location
1485 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1486 if (getUrl->exec() == QDialog::Rejected) {
1489 KUrl rendererPath = getUrl->selectedUrl();
1491 if (rendererPath.isEmpty()) ::exit(0);
1492 KdenliveSettings::setRendererpath(rendererPath.path());
1495 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1497 // Parse MLT profiles to build a list of available video formats
1498 if (profilesList.isEmpty()) parseProfiles();
1502 void MainWindow::slotEditProfiles()
1504 ProfilesDialog *w = new ProfilesDialog;
1505 if (w->exec() == QDialog::Accepted) {
1506 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1507 if (d) d->checkProfile();
1512 void MainWindow::slotEditProjectSettings()
1514 QPoint p = m_activeDocument->getTracksCount();
1515 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1517 if (w->exec() == QDialog::Accepted) {
1518 QString profile = w->selectedProfile();
1519 m_activeDocument->setProjectFolder(w->selectedFolder());
1520 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1521 if (m_activeDocument->profilePath() != profile) {
1522 // Profile was changed
1523 m_activeDocument->setProfilePath(profile);
1524 KdenliveSettings::setCurrent_profile(profile);
1525 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1526 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1527 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1528 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1529 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1530 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1532 // We need to desactivate & reactivate monitors to get a refresh
1533 m_monitorManager->switchMonitors();
1539 void MainWindow::slotRenderProject()
1541 if (!m_renderWidget) {
1542 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1543 m_renderWidget = new RenderWidget(projectfolder, this);
1544 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool, const QString &)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool, const QString &)));
1545 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1546 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1547 if (m_activeDocument) {
1548 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1549 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1552 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1553 if (currentTab) m_renderWidget->setTimeline(currentTab);
1554 m_renderWidget->setDocument(m_activeDocument);*/
1555 m_renderWidget->show();
1558 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd, bool resizeProfile, const QString &scriptExport)
1560 kDebug() << "// SCRIPT EXPORT: " << scriptExport;
1561 if (dest.isEmpty()) return;
1564 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1565 if (currentTab && zoneOnly) {
1566 in = currentTab->inPoint();
1567 out = currentTab->outPoint();
1569 KTemporaryFile temp;
1570 temp.setAutoRemove(false);
1571 temp.setSuffix(".westley");
1572 if (!scriptExport.isEmpty() || temp.open()) {
1573 if (KdenliveSettings::dropbframes()) {
1574 KdenliveSettings::setDropbframes(false);
1575 m_activeDocument->clipManager()->updatePreviewSettings();
1576 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1577 else m_projectMonitor->saveSceneList(temp.fileName());
1578 KdenliveSettings::setDropbframes(true);
1579 m_activeDocument->clipManager()->updatePreviewSettings();
1581 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1582 else m_projectMonitor->saveSceneList(temp.fileName());
1586 if (scriptExport.isEmpty()) args << "-erase";
1587 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1588 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1589 else if (guideStart != -1) {
1590 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1592 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1593 QString videoPlayer = "-";
1595 videoPlayer = KdenliveSettings::defaultplayerapp();
1596 if (videoPlayer.isEmpty()) KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
1598 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1599 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1600 setRenderingProgress(dest, -3);
1603 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1605 for (int i = 0; i < avformat_args.count(); i++) {
1606 if (avformat_args.at(i).startsWith("profile=")) {
1607 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1612 if (resizeProfile) {
1613 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1614 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1615 else args << "consumer:$SOURCE";
1617 if (scriptExport.isEmpty()) args << temp.fileName();
1618 else args << "$SOURCE";
1620 if (scriptExport.isEmpty()) args << dest;
1621 else args << "$TARGET";
1622 args << avformat_args;
1623 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1624 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1625 if (scriptExport.isEmpty()) {
1626 QProcess::startDetached(renderer, args);
1627 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1629 // Generate script file
1630 QFile file(scriptExport);
1631 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1632 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1636 QTextStream out(&file);
1637 out << "#! /bin/sh" << "\n" << "\n";
1638 out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
1639 out << "TARGET=" << "\"" + dest + "\"" << "\n";
1640 out << renderer << " " << args.join(" ") << "\n" << "\n";
1641 if (file.error() != QFile::NoError) {
1642 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1647 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1652 void MainWindow::setRenderingProgress(const QString &url, int progress)
1654 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1657 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1659 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1662 void MainWindow::slotUpdateMousePosition(int pos)
1664 if (m_activeDocument)
1665 switch (m_timecodeFormat->currentIndex()) {
1667 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1670 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1674 void MainWindow::slotUpdateDocumentState(bool modified)
1676 if (!m_activeDocument) return;
1677 setCaption(m_activeDocument->description(), modified);
1678 m_saveAction->setEnabled(modified);
1680 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1681 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1683 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1684 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1688 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1690 if (m_activeDocument) {
1691 if (m_activeDocument == doc) return;
1692 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1694 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1697 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1699 //m_projectMonitor->stop();
1700 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1701 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1702 if (m_activeDocument) {
1703 if (m_activeDocument == doc) return;
1704 if (m_activeTimeline) {
1705 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1706 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1707 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1708 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1709 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1712 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1713 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1714 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1715 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1716 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1717 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1718 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1719 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1720 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1721 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1722 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1723 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1724 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1725 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1726 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1727 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1728 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1729 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1730 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1731 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1732 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1733 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1734 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1735 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1736 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1737 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1738 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1739 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1740 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1741 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1742 m_effectStack->clear();
1744 //m_activeDocument->setRenderer(NULL);
1745 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1746 m_clipMonitor->stop();
1748 KdenliveSettings::setCurrent_profile(doc->profilePath());
1749 KdenliveSettings::setProject_fps(doc->fps());
1750 m_monitorManager->resetProfiles(doc->timecode());
1751 m_projectList->setDocument(doc);
1752 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1753 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1754 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1755 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1756 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1759 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1760 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1761 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1762 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1763 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1764 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1765 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1766 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1767 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1768 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1769 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1770 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1771 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1772 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1774 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1775 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1776 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1779 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1780 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1781 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1782 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1783 m_zoomSlider->setValue(doc->zoom());
1784 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1785 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1786 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1787 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1789 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1792 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1793 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1794 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1795 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1796 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1797 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1798 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1799 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1801 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1802 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1803 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1805 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1806 m_activeTimeline = trackView;
1807 if (m_renderWidget) {
1808 m_renderWidget->setProfile(doc->mltProfile());
1809 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1811 //doc->setRenderer(m_projectMonitor->render);
1812 m_commandStack->setActiveStack(doc->commandStack());
1813 KdenliveSettings::setProject_display_ratio(doc->dar());
1814 m_projectList->updateAllClips();
1815 //doc->clipManager()->checkAudioThumbs();
1817 //m_overView->setScene(trackView->projectScene());
1818 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1819 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1821 setCaption(doc->description(), doc->isModified());
1822 m_saveAction->setEnabled(doc->isModified());
1823 m_activeDocument = doc;
1824 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1826 // set tool to select tool
1827 m_buttonSelectTool->setChecked(true);
1830 void MainWindow::slotZoneMoved(int start, int end)
1832 m_activeDocument->setZone(start, end);
1833 m_projectMonitor->slotZoneMoved(start, end);
1836 void MainWindow::slotGuidesUpdated()
1838 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1841 void MainWindow::slotPreferences(int page, int option)
1843 //An instance of your dialog could be already created and could be
1844 // cached, in which case you want to display the cached dialog
1845 // instead of creating another one
1846 if (KConfigDialog::showDialog("settings")) {
1847 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1848 if (page != -1) d->showPage(page, option);
1852 // KConfigDialog didn't find an instance of this dialog, so lets
1854 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1855 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1856 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1857 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1858 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1859 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1861 if (page != -1) dialog->showPage(page, option);
1864 void MainWindow::slotUpdatePreviewSettings()
1866 if (m_activeDocument) {
1867 m_clipMonitor->slotSetXml(NULL, 0);
1868 m_activeDocument->updatePreviewSettings();
1872 void MainWindow::updateConfiguration()
1874 //TODO: we should apply settings to all projects, not only the current one
1875 if (m_activeTimeline) {
1876 m_activeTimeline->refresh();
1877 m_activeTimeline->projectView()->checkAutoScroll();
1878 m_activeTimeline->projectView()->checkTrackHeight();
1879 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1881 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1882 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1883 #ifndef NO_JOGSHUTTLE
1884 activateShuttleDevice();
1885 #endif /* NO_JOGSHUTTLE */
1890 void MainWindow::slotSwitchVideoThumbs()
1892 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1893 if (m_activeTimeline) {
1894 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1896 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1899 void MainWindow::slotSwitchAudioThumbs()
1901 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1902 if (m_activeTimeline) {
1903 m_activeTimeline->refresh();
1904 m_activeTimeline->projectView()->checkAutoScroll();
1905 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1907 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1910 void MainWindow::slotSwitchMarkersComments()
1912 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1913 if (m_activeTimeline) {
1914 m_activeTimeline->refresh();
1916 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1919 void MainWindow::slotSwitchSnap()
1921 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1922 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1926 void MainWindow::slotDeleteTimelineClip()
1928 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1929 else if (m_activeTimeline) {
1930 m_activeTimeline->projectView()->deleteSelectedClips();
1934 void MainWindow::slotChangeClipSpeed()
1936 if (m_activeTimeline) {
1937 m_activeTimeline->projectView()->changeClipSpeed();
1941 void MainWindow::slotAddClipMarker()
1943 DocClipBase *clip = NULL;
1945 if (m_projectMonitor->isActive()) {
1946 if (m_activeTimeline) {
1947 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1949 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1950 clip = item->baseClip();
1954 clip = m_clipMonitor->activeClip();
1955 pos = m_clipMonitor->position();
1958 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1961 QString id = clip->getId();
1962 CommentedTime marker(pos, i18n("Marker"));
1963 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1964 if (d.exec() == QDialog::Accepted) {
1965 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1967 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1970 void MainWindow::slotDeleteClipMarker()
1972 DocClipBase *clip = NULL;
1974 if (m_projectMonitor->isActive()) {
1975 if (m_activeTimeline) {
1976 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1978 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1979 clip = item->baseClip();
1983 clip = m_clipMonitor->activeClip();
1984 pos = m_clipMonitor->position();
1987 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1991 QString id = clip->getId();
1992 QString comment = clip->markerComment(pos);
1993 if (comment.isEmpty()) {
1994 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1997 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1998 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2002 void MainWindow::slotDeleteAllClipMarkers()
2004 DocClipBase *clip = NULL;
2005 if (m_projectMonitor->isActive()) {
2006 if (m_activeTimeline) {
2007 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2009 clip = item->baseClip();
2013 clip = m_clipMonitor->activeClip();
2016 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2019 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2020 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2023 void MainWindow::slotEditClipMarker()
2025 DocClipBase *clip = NULL;
2027 if (m_projectMonitor->isActive()) {
2028 if (m_activeTimeline) {
2029 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2031 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2032 clip = item->baseClip();
2036 clip = m_clipMonitor->activeClip();
2037 pos = m_clipMonitor->position();
2040 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2044 QString id = clip->getId();
2045 QString oldcomment = clip->markerComment(pos);
2046 if (oldcomment.isEmpty()) {
2047 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2051 CommentedTime marker(pos, oldcomment);
2052 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2053 if (d.exec() == QDialog::Accepted) {
2054 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2055 if (d.newMarker().time() != pos) {
2056 // remove old marker
2057 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2059 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2063 void MainWindow::slotAddGuide()
2065 if (m_activeTimeline)
2066 m_activeTimeline->projectView()->slotAddGuide();
2069 void MainWindow::slotInsertSpace()
2071 if (m_activeTimeline)
2072 m_activeTimeline->projectView()->slotInsertSpace();
2075 void MainWindow::slotRemoveSpace()
2077 if (m_activeTimeline)
2078 m_activeTimeline->projectView()->slotRemoveSpace();
2081 void MainWindow::slotInsertTrack(int ix)
2083 m_projectMonitor->activateMonitor();
2084 if (m_activeTimeline)
2085 m_activeTimeline->projectView()->slotInsertTrack(ix);
2088 void MainWindow::slotDeleteTrack(int ix)
2090 m_projectMonitor->activateMonitor();
2091 if (m_activeTimeline)
2092 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2095 void MainWindow::slotChangeTrack(int ix)
2097 m_projectMonitor->activateMonitor();
2098 if (m_activeTimeline)
2099 m_activeTimeline->projectView()->slotChangeTrack(ix);
2102 void MainWindow::slotEditGuide()
2104 if (m_activeTimeline)
2105 m_activeTimeline->projectView()->slotEditGuide();
2108 void MainWindow::slotDeleteGuide()
2110 if (m_activeTimeline)
2111 m_activeTimeline->projectView()->slotDeleteGuide();
2114 void MainWindow::slotDeleteAllGuides()
2116 if (m_activeTimeline)
2117 m_activeTimeline->projectView()->slotDeleteAllGuides();
2120 void MainWindow::slotCutTimelineClip()
2122 if (m_activeTimeline) {
2123 m_activeTimeline->projectView()->cutSelectedClips();
2127 void MainWindow::slotGroupClips()
2129 if (m_activeTimeline) {
2130 m_activeTimeline->projectView()->groupClips();
2134 void MainWindow::slotUnGroupClips()
2136 if (m_activeTimeline) {
2137 m_activeTimeline->projectView()->groupClips(false);
2141 void MainWindow::slotAddProjectClip(KUrl url)
2143 if (m_activeDocument)
2144 m_activeDocument->slotAddClipFile(url, QString());
2147 void MainWindow::slotAddTransition(QAction *result)
2149 if (!result) return;
2150 QStringList info = result->data().toStringList();
2151 if (info.isEmpty()) return;
2152 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2153 if (m_activeTimeline && !transition.isNull()) {
2154 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2158 void MainWindow::slotAddVideoEffect(QAction *result)
2160 if (!result) return;
2161 QStringList info = result->data().toStringList();
2162 if (info.isEmpty()) return;
2163 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2164 slotAddEffect(effect);
2167 void MainWindow::slotAddAudioEffect(QAction *result)
2169 if (!result) return;
2170 QStringList info = result->data().toStringList();
2171 if (info.isEmpty()) return;
2172 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2173 slotAddEffect(effect);
2176 void MainWindow::slotAddCustomEffect(QAction *result)
2178 if (!result) return;
2179 QStringList info = result->data().toStringList();
2180 if (info.isEmpty()) return;
2181 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2182 slotAddEffect(effect);
2185 void MainWindow::slotZoomIn()
2187 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2190 void MainWindow::slotZoomOut()
2192 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2195 void MainWindow::slotFitZoom()
2197 if (m_activeTimeline) {
2198 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2202 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2204 m_statusProgressBar->setValue(progress);
2205 if (progress >= 0) {
2206 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2207 m_statusProgressBar->setVisible(true);
2209 m_messageLabel->setMessage(QString(), DefaultMessage);
2210 m_statusProgressBar->setVisible(false);
2214 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2216 if (clip->clipType() == TEXT) {
2217 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2218 QString path = clip->getProperty("resource");
2219 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2221 doc.setContent(clip->getProperty("xmldata"));
2222 dia_ui->setXml(doc);
2223 if (dia_ui->exec() == QDialog::Accepted) {
2224 QImage pix = dia_ui->renderedPixmap();
2226 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2227 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2228 QMap <QString, QString> newprops;
2229 newprops.insert("xmldata", dia_ui->xml().toString());
2230 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2231 m_activeDocument->commandStack()->push(command);
2232 m_clipMonitor->refreshMonitor(true);
2233 m_activeDocument->setModified(true);
2237 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2240 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2241 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2242 if (dia.exec() == QDialog::Accepted) {
2243 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2244 m_activeDocument->commandStack()->push(command);
2246 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2247 if (dia.needsTimelineRefresh()) {
2248 // update clip occurences in timeline
2249 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2254 void MainWindow::customEvent(QEvent* e)
2256 if (e->type() == QEvent::User) {
2257 // The timeline playing position changed...
2258 kDebug() << "RECEIVED JOG EVEMNT!!!";
2261 void MainWindow::slotActivateEffectStackView()
2263 m_effectStack->raiseWindow(m_effectStackDock);
2266 void MainWindow::slotActivateTransitionView(Transition *t)
2268 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2271 void MainWindow::slotSnapRewind()
2273 if (m_projectMonitor->isActive()) {
2274 if (m_activeTimeline)
2275 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2276 } else m_clipMonitor->slotSeekToPreviousSnap();
2279 void MainWindow::slotSnapForward()
2281 if (m_projectMonitor->isActive()) {
2282 if (m_activeTimeline)
2283 m_activeTimeline->projectView()->slotSeekToNextSnap();
2284 } else m_clipMonitor->slotSeekToNextSnap();
2287 void MainWindow::slotClipStart()
2289 if (m_projectMonitor->isActive()) {
2290 if (m_activeTimeline)
2291 m_activeTimeline->projectView()->clipStart();
2295 void MainWindow::slotClipEnd()
2297 if (m_projectMonitor->isActive()) {
2298 if (m_activeTimeline)
2299 m_activeTimeline->projectView()->clipEnd();
2303 void MainWindow::slotChangeTool(QAction * action)
2305 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2306 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2307 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2310 void MainWindow::slotSetTool(PROJECTTOOL tool)
2312 if (m_activeDocument && m_activeTimeline) {
2313 //m_activeDocument->setTool(tool);
2314 m_activeTimeline->projectView()->setTool(tool);
2318 void MainWindow::slotCopy()
2320 if (!m_activeDocument || !m_activeTimeline) return;
2321 m_activeTimeline->projectView()->copyClip();
2324 void MainWindow::slotPaste()
2326 if (!m_activeDocument || !m_activeTimeline) return;
2327 m_activeTimeline->projectView()->pasteClip();
2330 void MainWindow::slotPasteEffects()
2332 if (!m_activeDocument || !m_activeTimeline) return;
2333 m_activeTimeline->projectView()->pasteClipEffects();
2336 void MainWindow::slotFind()
2338 if (!m_activeDocument || !m_activeTimeline) return;
2339 m_projectSearch->setEnabled(false);
2340 m_findActivated = true;
2341 m_findString.clear();
2342 m_activeTimeline->projectView()->initSearchStrings();
2343 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2344 m_findTimer.start(5000);
2345 qApp->installEventFilter(this);
2348 void MainWindow::slotFindNext()
2350 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2351 statusBar()->showMessage(i18n("Found : %1", m_findString));
2353 statusBar()->showMessage(i18n("Reached end of project"));
2355 m_findTimer.start(4000);
2358 void MainWindow::findAhead()
2360 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2361 m_projectSearchNext->setEnabled(true);
2362 statusBar()->showMessage(i18n("Found : %1", m_findString));
2364 m_projectSearchNext->setEnabled(false);
2365 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2369 void MainWindow::findTimeout()
2371 m_projectSearchNext->setEnabled(false);
2372 m_findActivated = false;
2373 m_findString.clear();
2374 statusBar()->showMessage(i18n("Find stopped"), 3000);
2375 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2376 m_projectSearch->setEnabled(true);
2377 removeEventFilter(this);
2380 void MainWindow::keyPressEvent(QKeyEvent *ke)
2382 if (m_findActivated) {
2383 if (ke->key() == Qt::Key_Backspace) {
2384 m_findString = m_findString.left(m_findString.length() - 1);
2386 if (!m_findString.isEmpty()) {
2392 m_findTimer.start(4000);
2395 } else if (ke->key() == Qt::Key_Escape) {
2399 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2400 m_findString += ke->text();
2404 m_findTimer.start(4000);
2408 } else KXmlGuiWindow::keyPressEvent(ke);
2412 /** Gets called when the window gets hidden */
2413 void MainWindow::hideEvent(QHideEvent */*event*/)
2415 // kDebug() << "I was hidden";
2416 // issue http://www.kdenlive.org/mantis/view.php?id=231
2417 if (isMinimized()) {
2418 // kDebug() << "I am minimized";
2419 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2423 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2425 if (m_findActivated) {
2426 if (event->type() == QEvent::ShortcutOverride) {
2427 QKeyEvent* ke = (QKeyEvent*) event;
2428 if (ke->text().trimmed().isEmpty()) return false;
2431 } else return false;
2433 // pass the event on to the parent class
2434 return QMainWindow::eventFilter(obj, event);
2438 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2440 KDialog *dialog = new KDialog(this);
2441 dialog->setCaption("Save clip zone");
2442 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2444 QWidget *widget = new QWidget(dialog);
2445 dialog->setMainWidget(widget);
2447 QVBoxLayout *vbox = new QVBoxLayout(widget);
2448 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2449 QString path = m_activeDocument->projectFolder().path();
2451 path.append("untitled.westley");
2452 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2453 url->setFilter("video/mlt-playlist");
2454 QLabel *label2 = new QLabel(i18n("Description:"), this);
2455 KLineEdit *edit = new KLineEdit(this);
2456 vbox->addWidget(label1);
2457 vbox->addWidget(url);
2458 vbox->addWidget(label2);
2459 vbox->addWidget(edit);
2460 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2464 void MainWindow::slotSetInPoint()
2466 if (m_clipMonitor->isActive()) {
2467 m_clipMonitor->slotSetZoneStart();
2468 } else m_activeTimeline->projectView()->setInPoint();
2471 void MainWindow::slotSetOutPoint()
2473 if (m_clipMonitor->isActive()) {
2474 m_clipMonitor->slotSetZoneEnd();
2475 } else m_activeTimeline->projectView()->setOutPoint();
2478 void MainWindow::slotGetNewLumaStuff()
2480 //KNS::Entry::List download();
2481 KNS::Entry::List entries = KNS::Engine::download();
2482 // list of changed entries
2483 kDebug() << "// PARSING KNS";
2484 foreach(KNS::Entry* entry, entries) {
2485 // care only about installed ones
2486 if (entry->status() == KNS::Entry::Installed) {
2487 foreach(const QString &file, entry->installedFiles()) {
2488 kDebug() << "// CURRENTLY INSTALLED: " << file;
2492 qDeleteAll(entries);
2493 initEffects::refreshLumas();
2496 void MainWindow::slotGetNewRenderStuff()
2498 //KNS::Entry::List download();
2500 KNS::Engine engine(0);
2501 if (engine.init("kdenlive_render.knsrc")) {
2502 KNS::Entry::List entries = engine.downloadDialogModal(this);
2504 if (entries.size() > 0) {
2505 foreach(KNS::Entry* entry, entries) {
2506 // care only about installed ones
2507 if (entry->status() == KNS::Entry::Installed) {
2508 foreach(const QString &file, entry->installedFiles()) {
2509 kDebug() << "// CURRENTLY INSTALLED: " << file;
2514 if (m_renderWidget) m_renderWidget->reloadProfiles();
2518 void MainWindow::slotGetNewMltProfileStuff()
2520 //KNS::Entry::List download();
2522 KNS::Engine engine(0);
2523 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2524 KNS::Entry::List entries = engine.downloadDialogModal(this);
2526 if (entries.size() > 0) {
2527 foreach(KNS::Entry* entry, entries) {
2528 // care only about installed ones
2529 if (entry->status() == KNS::Entry::Installed) {
2530 foreach(const QString &file, entry->installedFiles()) {
2531 kDebug() << "// CURRENTLY INSTALLED: " << file;
2536 // update the list of profiles in settings dialog
2537 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2538 if (d) d->checkProfile();
2543 void MainWindow::slotAutoTransition()
2545 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2548 void MainWindow::slotSplitAudio()
2550 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2553 void MainWindow::slotUpdateClipType(QAction *action)
2555 if (m_activeTimeline) {
2556 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2557 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2558 else m_activeTimeline->projectView()->setAudioAndVideo();
2562 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2564 DvdWizard *w = new DvdWizard(url, profile, this);
2568 void MainWindow::slotShowTimeline(bool show)
2570 if (show == false) {
2571 m_timelineState = saveState();
2572 centralWidget()->setHidden(true);
2574 centralWidget()->setHidden(false);
2575 restoreState(m_timelineState);
2579 void MainWindow::slotMaximizeCurrent(bool show)
2581 //TODO: is there a way to maximize current widget?
2584 m_timelineState = saveState();
2585 QWidget *par = focusWidget()->parentWidget();
2586 while (par->parentWidget() && par->parentWidget() != this) {
2587 par = par->parentWidget();
2589 kDebug() << "CURRENT WIDGET: " << par->objectName();
2592 //centralWidget()->setHidden(false);
2593 //restoreState(m_timelineState);
2597 #include "mainwindow.moc"