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 :
392 // User does not want to save the changes, clear recovery files
393 m_activeDocument->m_autosave->resize(0);
403 void MainWindow::loadPlugins()
405 foreach(QObject *plugin, QPluginLoader::staticInstances())
406 populateMenus(plugin);
408 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
410 filters << "libkdenlive*";
411 foreach(const QString &folder, directories) {
412 kDebug() << "// PARSING FIOLER: " << folder;
413 QDir pluginsDir(folder);
414 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
415 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
416 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
417 QObject *plugin = loader.instance();
419 populateMenus(plugin);
420 m_pluginFileNames += fileName;
421 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
427 void MainWindow::populateMenus(QObject *plugin)
429 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
430 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
432 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
436 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
437 QMenu *menu, const char *member,
438 QActionGroup *actionGroup)
440 kDebug() << "// ADD to MENU" << texts;
441 foreach(const QString &text, texts) {
442 QAction *action = new QAction(text, plugin);
443 action->setData(text);
444 connect(action, SIGNAL(triggered()), this, member);
445 menu->addAction(action);
448 action->setCheckable(true);
449 actionGroup->addAction(action);
454 void MainWindow::aboutPlugins()
456 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
461 void MainWindow::generateClip()
463 QAction *action = qobject_cast<QAction *>(sender());
464 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
466 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
467 if (!clipUrl.isEmpty()) {
468 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
472 void MainWindow::saveProperties(KConfig*)
474 // save properties here,used by session management
479 void MainWindow::readProperties(KConfig *config)
481 // read properties here,used by session management
482 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
483 openFile(KUrl(Lastproject));
486 void MainWindow::slotReloadEffects()
488 initEffects::parseCustomEffectsFile();
489 m_customEffectsMenu->clear();
490 const QStringList effects = customEffects.effectNames();
492 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
493 else m_customEffectsMenu->setEnabled(true);
495 foreach(const QString &name, effects) {
496 action = new QAction(name, this);
497 action->setData(name);
498 m_customEffectsMenu->addAction(action);
500 m_effectList->reloadEffectList();
503 #ifndef NO_JOGSHUTTLE
504 void MainWindow::activateShuttleDevice()
508 if (KdenliveSettings::enableshuttle() == false) return;
509 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
510 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
511 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
512 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
513 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
514 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
515 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
518 void MainWindow::slotShuttleButton(int code)
522 slotShuttleAction(KdenliveSettings::shuttle1());
525 slotShuttleAction(KdenliveSettings::shuttle2());
528 slotShuttleAction(KdenliveSettings::shuttle3());
531 slotShuttleAction(KdenliveSettings::shuttle4());
534 slotShuttleAction(KdenliveSettings::shuttle5());
539 void MainWindow::slotShuttleAction(int code)
545 m_monitorManager->slotPlay();
548 m_monitorManager->slotPlay();
552 #endif /* NO_JOGSHUTTLE */
554 void MainWindow::configureNotifications()
556 KNotifyConfigWidget::configure(this);
559 void MainWindow::slotFullScreen()
561 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
564 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
566 if (!m_activeDocument) return;
567 if (effect.isNull()) {
568 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
571 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
572 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
575 void MainWindow::slotRaiseMonitor(bool clipMonitor)
577 if (clipMonitor) m_clipMonitorDock->raise();
578 else m_projectMonitorDock->raise();
581 void MainWindow::slotSetClipDuration(const QString &id, int duration)
583 if (!m_activeDocument) return;
584 m_activeDocument->setProducerDuration(id, duration);
587 void MainWindow::slotConnectMonitors()
590 m_projectList->setRenderer(m_projectMonitor->render);
591 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
592 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
593 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
594 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
595 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)));
597 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
599 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
601 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
602 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
604 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
605 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
608 void MainWindow::slotAdjustClipMonitor()
610 m_clipMonitorDock->updateGeometry();
611 m_clipMonitorDock->adjustSize();
612 m_clipMonitor->resetSize();
615 void MainWindow::slotAdjustProjectMonitor()
617 m_projectMonitorDock->updateGeometry();
618 m_projectMonitorDock->adjustSize();
619 m_projectMonitor->resetSize();
622 void MainWindow::setupActions()
625 KActionCollection* collection = actionCollection();
626 m_timecodeFormat = new KComboBox(this);
627 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
628 m_timecodeFormat->addItem(i18n("Frames"));
630 m_statusProgressBar = new QProgressBar(this);
631 m_statusProgressBar->setMinimum(0);
632 m_statusProgressBar->setMaximum(100);
633 m_statusProgressBar->setMaximumWidth(150);
634 m_statusProgressBar->setVisible(false);
636 QWidget *w = new QWidget;
638 QHBoxLayout *layout = new QHBoxLayout;
639 w->setLayout(layout);
640 layout->setContentsMargins(5, 0, 5, 0);
641 QToolBar *toolbar = new QToolBar("statusToolBar", this);
644 m_toolGroup = new QActionGroup(this);
646 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;}";
648 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
649 toolbar->addAction(m_buttonSelectTool);
650 m_buttonSelectTool->setCheckable(true);
651 m_buttonSelectTool->setChecked(true);
653 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
654 toolbar->addAction(m_buttonRazorTool);
655 m_buttonRazorTool->setCheckable(true);
656 m_buttonRazorTool->setChecked(false);
658 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
659 toolbar->addAction(m_buttonSpacerTool);
660 m_buttonSpacerTool->setCheckable(true);
661 m_buttonSpacerTool->setChecked(false);
663 m_toolGroup->addAction(m_buttonSelectTool);
664 m_toolGroup->addAction(m_buttonRazorTool);
665 m_toolGroup->addAction(m_buttonSpacerTool);
666 m_toolGroup->setExclusive(true);
667 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
669 QWidget * actionWidget;
670 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
671 actionWidget->setMaximumWidth(24);
672 actionWidget->setMinimumHeight(17);
674 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
675 actionWidget->setMaximumWidth(24);
676 actionWidget->setMinimumHeight(17);
678 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
679 actionWidget->setMaximumWidth(24);
680 actionWidget->setMinimumHeight(17);
682 toolbar->setStyleSheet(style1);
683 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
685 toolbar->addSeparator();
686 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
687 toolbar->addAction(m_buttonFitZoom);
688 m_buttonFitZoom->setCheckable(false);
689 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
691 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
692 actionWidget->setMaximumWidth(24);
693 actionWidget->setMinimumHeight(17);
695 m_zoomSlider = new QSlider(Qt::Horizontal, this);
696 m_zoomSlider->setMaximum(13);
697 m_zoomSlider->setPageStep(1);
699 m_zoomSlider->setMaximumWidth(150);
700 m_zoomSlider->setMinimumWidth(100);
702 const int contentHeight = QFontMetrics(w->font()).height() + 8;
704 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
705 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
707 m_zoomSlider->setStyleSheet(style);
709 //m_zoomSlider->height() + 5;
710 statusBar()->setMinimumHeight(contentHeight);
713 toolbar->addWidget(m_zoomSlider);
715 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
716 toolbar->addAction(m_buttonVideoThumbs);
717 m_buttonVideoThumbs->setCheckable(true);
718 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
719 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
721 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
722 toolbar->addAction(m_buttonAudioThumbs);
723 m_buttonAudioThumbs->setCheckable(true);
724 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
725 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
727 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
728 toolbar->addAction(m_buttonShowMarkers);
729 m_buttonShowMarkers->setCheckable(true);
730 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
731 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
733 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
734 toolbar->addAction(m_buttonSnap);
735 m_buttonSnap->setCheckable(true);
736 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
737 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
738 layout->addWidget(toolbar);
741 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
742 actionWidget->setMaximumWidth(24);
743 actionWidget->setMinimumHeight(17);
745 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
746 actionWidget->setMaximumWidth(24);
747 actionWidget->setMinimumHeight(17);
749 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
750 actionWidget->setMaximumWidth(24);
751 actionWidget->setMinimumHeight(17);
753 actionWidget = toolbar->widgetForAction(m_buttonSnap);
754 actionWidget->setMaximumWidth(24);
755 actionWidget->setMinimumHeight(17);
757 m_messageLabel = new StatusBarMessageLabel(this);
758 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
760 statusBar()->addWidget(m_messageLabel, 10);
761 statusBar()->addWidget(m_statusProgressBar, 0);
762 statusBar()->addPermanentWidget(w);
763 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
764 statusBar()->addPermanentWidget(m_timecodeFormat);
765 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
766 m_messageLabel->hide();
768 collection->addAction("select_tool", m_buttonSelectTool);
769 collection->addAction("razor_tool", m_buttonRazorTool);
770 collection->addAction("spacer_tool", m_buttonSpacerTool);
772 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
773 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
774 collection->addAction("show_markers", m_buttonShowMarkers);
775 collection->addAction("snap", m_buttonSnap);
776 collection->addAction("zoom_fit", m_buttonFitZoom);
778 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
779 collection->addAction("zoom_in", zoomIn);
780 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
781 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
783 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
784 collection->addAction("zoom_out", zoomOut);
785 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
786 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
788 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
789 collection->addAction("project_find", m_projectSearch);
790 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
791 m_projectSearch->setShortcut(Qt::Key_Slash);
793 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
794 collection->addAction("project_find_next", m_projectSearchNext);
795 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
796 m_projectSearchNext->setShortcut(Qt::Key_F3);
797 m_projectSearchNext->setEnabled(false);
799 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
800 collection->addAction("manage_profiles", profilesAction);
801 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
803 KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
805 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
807 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
809 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
810 collection->addAction("run_wizard", wizAction);
811 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
813 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
814 collection->addAction("project_settings", projectAction);
815 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
817 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
818 collection->addAction("project_render", projectRender);
819 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
820 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
822 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
823 KShortcut playShortcut;
824 playShortcut.setPrimary(Qt::Key_Space);
825 playShortcut.setAlternate(Qt::Key_K);
826 monitorPlay->setShortcut(playShortcut);
827 collection->addAction("monitor_play", monitorPlay);
828 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
830 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
831 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
832 collection->addAction("monitor_play_zone", m_playZone);
833 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
835 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
836 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
837 collection->addAction("monitor_loop_zone", m_loopZone);
838 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
840 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
841 collection->addAction("dvd_wizard", dvdWizard);
842 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
844 KAction *markIn = collection->addAction("mark_in");
845 markIn->setText(i18n("Set In Point"));
846 markIn->setShortcut(Qt::Key_I);
847 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
849 KAction *markOut = collection->addAction("mark_out");
850 markOut->setText(i18n("Set Out Point"));
851 markOut->setShortcut(Qt::Key_O);
852 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
854 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
855 monitorSeekBackward->setShortcut(Qt::Key_J);
856 collection->addAction("monitor_seek_backward", monitorSeekBackward);
857 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
859 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
860 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
861 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
862 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
864 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
865 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
866 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
867 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
869 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
870 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
871 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
872 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
874 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
875 monitorSeekForward->setShortcut(Qt::Key_L);
876 collection->addAction("monitor_seek_forward", monitorSeekForward);
877 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
879 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
880 clipStart->setShortcut(Qt::Key_Home);
881 collection->addAction("seek_clip_start", clipStart);
882 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
884 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
885 clipEnd->setShortcut(Qt::Key_End);
886 collection->addAction("seek_clip_end", clipEnd);
887 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
889 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
890 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
891 collection->addAction("seek_start", projectStart);
892 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
894 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
895 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
896 collection->addAction("seek_end", projectEnd);
897 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
899 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
900 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
901 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
902 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
904 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
905 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
906 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
907 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
909 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
910 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
911 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
912 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
914 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
915 deleteTimelineClip->setShortcut(Qt::Key_Delete);
916 collection->addAction("delete_timeline_clip", deleteTimelineClip);
917 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
919 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
920 collection->addAction("change_clip_speed", editTimelineClipSpeed);
921 editTimelineClipSpeed->setData("change_speed");
922 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
924 KAction *stickTransition = collection->addAction("auto_transition");
925 stickTransition->setData(QString("auto"));
926 stickTransition->setCheckable(true);
927 stickTransition->setEnabled(false);
928 stickTransition->setText(i18n("Automatic Transition"));
929 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
931 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
932 collection->addAction("group_clip", groupClip);
933 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
935 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
936 collection->addAction("ungroup_clip", ungroupClip);
937 ungroupClip->setData("ungroup_clip");
938 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
940 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
941 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
942 collection->addAction("cut_timeline_clip", cutTimelineClip);
943 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
945 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
946 collection->addAction("add_clip_marker", addClipMarker);
947 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
949 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
950 collection->addAction("delete_clip_marker", deleteClipMarker);
951 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
953 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
954 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
955 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
957 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
958 collection->addAction("edit_clip_marker", editClipMarker);
959 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
961 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
962 collection->addAction("split_audio", splitAudio);
963 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
965 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
966 collection->addAction("clip_audio_only", audioOnly);
967 audioOnly->setData("clip_audio_only");
968 audioOnly->setCheckable(true);
970 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
971 collection->addAction("clip_video_only", videoOnly);
972 videoOnly->setData("clip_video_only");
973 videoOnly->setCheckable(true);
975 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
976 collection->addAction("clip_audio_and_video", audioAndVideo);
977 audioAndVideo->setData("clip_audio_and_video");
978 audioAndVideo->setCheckable(true);
980 m_clipTypeGroup = new QActionGroup(this);
981 m_clipTypeGroup->addAction(audioOnly);
982 m_clipTypeGroup->addAction(videoOnly);
983 m_clipTypeGroup->addAction(audioAndVideo);
984 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
985 m_clipTypeGroup->setEnabled(false);
987 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
988 collection->addAction("insert_space", insertSpace);
989 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
991 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
992 collection->addAction("delete_space", removeSpace);
993 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
995 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
996 collection->addAction("insert_track", insertTrack);
997 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
999 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1000 collection->addAction("delete_track", deleteTrack);
1001 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1003 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1004 collection->addAction("change_track", changeTrack);
1005 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1007 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1008 collection->addAction("add_guide", addGuide);
1009 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1011 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1012 collection->addAction("delete_guide", delGuide);
1013 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1015 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1016 collection->addAction("edit_guide", editGuide);
1017 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1019 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1020 collection->addAction("delete_all_guides", delAllGuides);
1021 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1023 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1024 collection->addAction("paste_effects", pasteEffects);
1025 pasteEffects->setData("paste_effects");
1026 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1028 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1029 collection->addAction("show_timeline", showTimeline);
1030 showTimeline->setCheckable(true);
1031 showTimeline->setChecked(true);
1032 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1034 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1035 collection->addAction("maximize_current", maxCurrent);
1036 maxCurrent->setCheckable(true);
1037 maxCurrent->setChecked(false);
1038 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1041 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1043 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1045 KStandardAction::open(this, SLOT(openFile()), collection);
1047 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1049 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1051 KStandardAction::openNew(this, SLOT(newFile()), collection);
1053 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1055 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1057 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1059 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1061 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1062 undo->setEnabled(false);
1063 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1065 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1066 redo->setEnabled(false);
1067 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1069 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1072 //TODO: Add status tooltip to actions ?
1073 connect(collection, SIGNAL(actionHovered(QAction*)),
1074 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1077 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1078 collection->addAction("add_clip", addClip);
1079 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1081 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1082 collection->addAction("add_color_clip", addColorClip);
1083 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1085 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1086 collection->addAction("add_slide_clip", addSlideClip);
1087 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1089 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1090 collection->addAction("add_text_clip", addTitleClip);
1091 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1093 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1094 collection->addAction("add_folder", addFolderButton);
1095 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1097 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1098 collection->addAction("clip_properties", clipProperties);
1099 clipProperties->setData("clip_properties");
1100 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1101 clipProperties->setEnabled(false);
1103 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1104 collection->addAction("edit_clip", openClip);
1105 openClip->setData("edit_clip");
1106 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1107 openClip->setEnabled(false);
1109 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1110 collection->addAction("delete_clip", deleteClip);
1111 deleteClip->setData("delete_clip");
1112 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1113 deleteClip->setEnabled(false);
1115 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1116 collection->addAction("reload_clip", reloadClip);
1117 reloadClip->setData("reload_clip");
1118 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1119 reloadClip->setEnabled(false);
1121 QMenu *addClips = new QMenu();
1122 addClips->addAction(addClip);
1123 addClips->addAction(addColorClip);
1124 addClips->addAction(addSlideClip);
1125 addClips->addAction(addTitleClip);
1126 addClips->addAction(addFolderButton);
1128 addClips->addAction(reloadClip);
1129 addClips->addAction(clipProperties);
1130 addClips->addAction(openClip);
1131 addClips->addAction(deleteClip);
1132 m_projectList->setupMenu(addClips, addClip);
1134 //connect(collection, SIGNAL( clearStatusText() ),
1135 //statusBar(), SLOT( clear() ) );
1138 void MainWindow::slotDisplayActionMessage(QAction *a)
1140 statusBar()->showMessage(a->data().toString(), 3000);
1143 void MainWindow::saveOptions()
1145 KdenliveSettings::self()->writeConfig();
1146 KSharedConfigPtr config = KGlobal::config();
1147 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1148 KConfigGroup treecolumns(config, "Project Tree");
1149 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1153 void MainWindow::readOptions()
1155 KSharedConfigPtr config = KGlobal::config();
1156 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1157 KConfigGroup initialGroup(config, "version");
1158 bool upgrade = false;
1159 if (initialGroup.exists()) {
1160 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1163 if (initialGroup.readEntry("version") == "0.7") {
1164 //Add new settings from 0.7.1
1165 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1166 QString path = QDir::homePath() + "/kdenlive";
1167 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1168 KdenliveSettings::setDefaultprojectfolder(path);
1174 if (!initialGroup.exists() || upgrade) {
1175 // this is our first run, show Wizard
1176 Wizard *w = new Wizard(upgrade, this);
1177 if (w->exec() == QDialog::Accepted && w->isOk()) {
1178 w->adjustSettings();
1179 initialGroup.writeEntry("version", version);
1185 KConfigGroup treecolumns(config, "Project Tree");
1186 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1187 if (!state.isEmpty())
1188 m_projectList->setHeaderInfo(state);
1191 void MainWindow::slotRunWizard()
1193 Wizard *w = new Wizard(false, this);
1194 if (w->exec() == QDialog::Accepted && w->isOk()) {
1195 w->adjustSettings();
1200 void MainWindow::newFile(bool showProjectSettings)
1202 QString profileName;
1204 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1205 if (!showProjectSettings && m_timelineArea->count() == 0) {
1206 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1207 profileName = KdenliveSettings::default_profile();
1209 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1210 if (w->exec() != QDialog::Accepted) return;
1211 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1212 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1213 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1214 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1215 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1216 profileName = w->selectedProfile();
1217 projectFolder = w->selectedFolder();
1218 projectTracks = w->tracks();
1221 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1222 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1223 TrackView *trackView = new TrackView(doc, this);
1224 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1225 if (m_timelineArea->count() == 1) {
1226 connectDocumentInfo(doc);
1227 connectDocument(trackView, doc);
1228 } else m_timelineArea->setTabBarHidden(false);
1229 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1232 void MainWindow::activateDocument()
1234 if (m_timelineArea->currentWidget() == NULL) return;
1235 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1236 KdenliveDoc *currentDoc = currentTab->document();
1237 connectDocumentInfo(currentDoc);
1238 connectDocument(currentTab, currentDoc);
1241 void MainWindow::closeCurrentDocument()
1243 QWidget *w = m_timelineArea->currentWidget();
1245 // closing current document
1246 int ix = m_timelineArea->currentIndex() + 1;
1247 if (ix == m_timelineArea->count()) ix = 0;
1248 m_timelineArea->setCurrentIndex(ix);
1249 TrackView *tabToClose = (TrackView *) w;
1250 KdenliveDoc *docToClose = tabToClose->document();
1251 if (docToClose && docToClose->isModified()) {
1252 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1253 case KMessageBox::Yes :
1254 // save document here. If saving fails, return false;
1255 if (saveFile() == false) return;
1257 case KMessageBox::Cancel :
1263 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1264 if (m_timelineArea->count() == 1) {
1265 m_timelineArea->setTabBarHidden(true);
1266 m_closeAction->setEnabled(false);
1270 if (m_timelineArea->count() == 0) {
1271 m_activeDocument = NULL;
1272 m_effectStack->clear();
1273 m_transitionConfig->slotTransitionItemSelected(NULL, false);
1277 bool MainWindow::saveFileAs(const QString &outputFileName)
1279 QString currentSceneList;
1280 if (KdenliveSettings::dropbframes()) {
1281 KdenliveSettings::setDropbframes(false);
1282 m_activeDocument->clipManager()->updatePreviewSettings();
1283 currentSceneList = m_projectMonitor->sceneList();
1284 KdenliveSettings::setDropbframes(true);
1285 m_activeDocument->clipManager()->updatePreviewSettings();
1286 } else currentSceneList = m_projectMonitor->sceneList();
1288 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1291 // Save timeline thumbnails
1292 m_activeTimeline->projectView()->saveThumbnails();
1293 m_activeDocument->setUrl(KUrl(outputFileName));
1294 if (m_activeDocument->m_autosave == NULL) {
1295 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1296 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1297 setCaption(m_activeDocument->description());
1298 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1299 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1300 m_activeDocument->setModified(false);
1301 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1305 bool MainWindow::saveFileAs()
1307 // Check that the Kdenlive mime type is correctly installed
1308 QString mimetype = "application/x-kdenlive";
1309 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1310 if (!mime) mimetype = "*.kdenlive";
1312 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1313 if (outputFile.isEmpty()) return false;
1314 if (QFile::exists(outputFile)) {
1315 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1317 return saveFileAs(outputFile);
1320 bool MainWindow::saveFile()
1322 if (!m_activeDocument) return true;
1323 if (m_activeDocument->url().isEmpty()) {
1324 return saveFileAs();
1326 bool result = saveFileAs(m_activeDocument->url().path());
1327 m_activeDocument->m_autosave->resize(0);
1332 void MainWindow::openFile()
1334 // Check that the Kdenlive mime type is correctly installed
1335 QString mimetype = "application/x-kdenlive";
1336 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1337 if (!mime) mimetype = "*.kdenlive";
1339 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1340 if (url.isEmpty()) return;
1341 m_fileOpenRecent->addUrl(url);
1345 void MainWindow::openLastFile()
1347 KSharedConfigPtr config = KGlobal::config();
1348 KUrl::List urls = m_fileOpenRecent->urls();
1349 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1350 if (urls.isEmpty()) newFile(false);
1351 else openFile(urls.last());
1354 void MainWindow::openFile(const KUrl &url)
1356 // Check if the document is already opened
1357 const int ct = m_timelineArea->count();
1358 bool isOpened = false;
1360 for (i = 0; i < ct; i++) {
1361 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1362 KdenliveDoc *doc = tab->document();
1363 if (doc->url() == url) {
1369 m_timelineArea->setCurrentIndex(i);
1373 // Check for backup file
1374 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1375 if (!staleFiles.isEmpty()) {
1376 if (KMessageBox::questionYesNo(this,
1377 i18n("Auto-saved files exist. Do you want to recover them now?"),
1378 i18n("File Recovery"),
1379 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1380 recoverFiles(staleFiles);
1383 // remove the stale files
1384 foreach(KAutoSaveFile *stale, staleFiles) {
1385 stale->open(QIODevice::ReadWrite);
1390 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1391 doOpenFile(url, NULL);
1394 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1396 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1397 if (stale == NULL) {
1398 stale = new KAutoSaveFile(url, doc);
1399 doc->m_autosave = stale;
1401 doc->m_autosave = stale;
1402 doc->setUrl(stale->managedFile());
1403 doc->setModified(true);
1404 stale->setParent(doc);
1406 connectDocumentInfo(doc);
1407 TrackView *trackView = new TrackView(doc, this);
1408 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1409 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1410 trackView->setDuration(trackView->duration());
1411 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1413 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1414 slotGotProgressInfo(QString(), -1);
1415 m_clipMonitor->refreshMonitor(true);
1416 m_projectMonitor->adjustRulerSize(trackView->duration());
1417 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1420 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1422 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1423 foreach(KAutoSaveFile *stale, staleFiles) {
1424 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1425 // show an error message; we could not steal the lockfile
1426 // maybe another application got to the file before us?
1430 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1431 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1432 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1433 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1438 void MainWindow::parseProfiles(const QString &mltPath)
1440 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1442 //KdenliveSettings::setDefaulttmpfolder();
1443 if (!mltPath.isEmpty()) {
1444 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1445 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1448 if (KdenliveSettings::mltpath().isEmpty()) {
1449 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1451 if (KdenliveSettings::rendererpath().isEmpty()) {
1452 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1453 if (!QFile::exists(inigoPath))
1454 inigoPath = KStandardDirs::findExe("inigo");
1455 else KdenliveSettings::setRendererpath(inigoPath);
1457 QStringList profilesFilter;
1458 profilesFilter << "*";
1459 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1461 if (profilesList.isEmpty()) {
1462 // Cannot find MLT path, try finding inigo
1463 QString profilePath = KdenliveSettings::rendererpath();
1464 if (!profilePath.isEmpty()) {
1465 profilePath = profilePath.section('/', 0, -3);
1466 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1467 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1470 if (profilesList.isEmpty()) {
1471 // Cannot find the MLT profiles, ask for location
1472 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1473 getUrl->fileDialog()->setMode(KFile::Directory);
1474 if (getUrl->exec() == QDialog::Rejected) {
1477 KUrl mltPath = getUrl->selectedUrl();
1479 if (mltPath.isEmpty()) ::exit(0);
1480 KdenliveSettings::setMltpath(mltPath.path());
1481 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1485 if (KdenliveSettings::rendererpath().isEmpty()) {
1486 // Cannot find the MLT inigo renderer, ask for location
1487 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1488 if (getUrl->exec() == QDialog::Rejected) {
1491 KUrl rendererPath = getUrl->selectedUrl();
1493 if (rendererPath.isEmpty()) ::exit(0);
1494 KdenliveSettings::setRendererpath(rendererPath.path());
1497 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1499 // Parse MLT profiles to build a list of available video formats
1500 if (profilesList.isEmpty()) parseProfiles();
1504 void MainWindow::slotEditProfiles()
1506 ProfilesDialog *w = new ProfilesDialog;
1507 if (w->exec() == QDialog::Accepted) {
1508 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1509 if (d) d->checkProfile();
1514 void MainWindow::slotEditProjectSettings()
1516 QPoint p = m_activeDocument->getTracksCount();
1517 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1519 if (w->exec() == QDialog::Accepted) {
1520 QString profile = w->selectedProfile();
1521 m_activeDocument->setProjectFolder(w->selectedFolder());
1522 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1523 if (m_activeDocument->profilePath() != profile) {
1524 // Profile was changed
1525 m_activeDocument->setProfilePath(profile);
1526 KdenliveSettings::setCurrent_profile(profile);
1527 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1528 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1529 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1530 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1531 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1532 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1534 // We need to desactivate & reactivate monitors to get a refresh
1535 m_monitorManager->switchMonitors();
1541 void MainWindow::slotRenderProject()
1543 if (!m_renderWidget) {
1544 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1545 m_renderWidget = new RenderWidget(projectfolder, this);
1546 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 &)));
1547 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1548 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1549 if (m_activeDocument) {
1550 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1551 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1554 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1555 if (currentTab) m_renderWidget->setTimeline(currentTab);
1556 m_renderWidget->setDocument(m_activeDocument);*/
1557 m_renderWidget->show();
1560 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)
1562 kDebug() << "// SCRIPT EXPORT: " << scriptExport;
1563 if (dest.isEmpty()) return;
1566 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1567 if (currentTab && zoneOnly) {
1568 in = currentTab->inPoint();
1569 out = currentTab->outPoint();
1571 KTemporaryFile temp;
1572 temp.setAutoRemove(false);
1573 temp.setSuffix(".westley");
1574 if (!scriptExport.isEmpty() || temp.open()) {
1575 if (KdenliveSettings::dropbframes()) {
1576 KdenliveSettings::setDropbframes(false);
1577 m_activeDocument->clipManager()->updatePreviewSettings();
1578 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1579 else m_projectMonitor->saveSceneList(temp.fileName());
1580 KdenliveSettings::setDropbframes(true);
1581 m_activeDocument->clipManager()->updatePreviewSettings();
1583 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1584 else m_projectMonitor->saveSceneList(temp.fileName());
1588 if (scriptExport.isEmpty()) args << "-erase";
1589 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1590 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1591 else if (guideStart != -1) {
1592 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1594 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1595 QString videoPlayer = "-";
1597 videoPlayer = KdenliveSettings::defaultplayerapp();
1598 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."));
1600 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1601 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1602 setRenderingProgress(dest, -3);
1605 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1607 for (int i = 0; i < avformat_args.count(); i++) {
1608 if (avformat_args.at(i).startsWith("profile=")) {
1609 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1614 if (resizeProfile) {
1615 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1616 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1617 else args << "consumer:$SOURCE";
1619 if (scriptExport.isEmpty()) args << temp.fileName();
1620 else args << "$SOURCE";
1622 if (scriptExport.isEmpty()) args << dest;
1623 else args << "$TARGET";
1624 args << avformat_args;
1625 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1626 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1627 if (scriptExport.isEmpty()) {
1628 QProcess::startDetached(renderer, args);
1629 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1631 // Generate script file
1632 QFile file(scriptExport);
1633 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1634 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1638 QTextStream out(&file);
1639 out << "#! /bin/sh" << "\n" << "\n";
1640 out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
1641 out << "TARGET=" << "\"" + dest + "\"" << "\n";
1642 out << renderer << " " << args.join(" ") << "\n" << "\n";
1643 if (file.error() != QFile::NoError) {
1644 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1649 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1654 void MainWindow::setRenderingProgress(const QString &url, int progress)
1656 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1659 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1661 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1664 void MainWindow::slotUpdateMousePosition(int pos)
1666 if (m_activeDocument)
1667 switch (m_timecodeFormat->currentIndex()) {
1669 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1672 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1676 void MainWindow::slotUpdateDocumentState(bool modified)
1678 if (!m_activeDocument) return;
1679 setCaption(m_activeDocument->description(), modified);
1680 m_saveAction->setEnabled(modified);
1682 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1683 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1685 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1686 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1690 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1692 if (m_activeDocument) {
1693 if (m_activeDocument == doc) return;
1694 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1696 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1699 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1701 //m_projectMonitor->stop();
1702 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1703 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1704 if (m_activeDocument) {
1705 if (m_activeDocument == doc) return;
1706 if (m_activeTimeline) {
1707 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1708 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1709 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1710 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1711 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1714 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1715 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1716 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1717 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1718 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1719 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1720 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1721 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1722 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1723 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1724 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1725 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1726 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1727 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1728 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1729 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1730 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1731 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1732 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1733 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1734 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1735 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1736 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1737 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1738 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1739 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1740 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1741 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1742 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1743 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1744 m_effectStack->clear();
1746 //m_activeDocument->setRenderer(NULL);
1747 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1748 m_clipMonitor->stop();
1750 KdenliveSettings::setCurrent_profile(doc->profilePath());
1751 KdenliveSettings::setProject_fps(doc->fps());
1752 m_monitorManager->resetProfiles(doc->timecode());
1753 m_projectList->setDocument(doc);
1754 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1755 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1756 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1757 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1758 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1761 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1762 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1763 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1764 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1765 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1766 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1767 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1768 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1769 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1770 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1771 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1772 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1773 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1774 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1776 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1777 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1778 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1781 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1782 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1783 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1784 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1785 m_zoomSlider->setValue(doc->zoom());
1786 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1787 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1788 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1789 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1791 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1794 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1795 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1796 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1797 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1798 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1799 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1800 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1801 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1803 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1804 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1805 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1807 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1808 m_activeTimeline = trackView;
1809 if (m_renderWidget) {
1810 m_renderWidget->setProfile(doc->mltProfile());
1811 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1813 //doc->setRenderer(m_projectMonitor->render);
1814 m_commandStack->setActiveStack(doc->commandStack());
1815 KdenliveSettings::setProject_display_ratio(doc->dar());
1816 m_projectList->updateAllClips();
1817 //doc->clipManager()->checkAudioThumbs();
1819 //m_overView->setScene(trackView->projectScene());
1820 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1821 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1823 setCaption(doc->description(), doc->isModified());
1824 m_saveAction->setEnabled(doc->isModified());
1825 m_activeDocument = doc;
1826 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1828 // set tool to select tool
1829 m_buttonSelectTool->setChecked(true);
1832 void MainWindow::slotZoneMoved(int start, int end)
1834 m_activeDocument->setZone(start, end);
1835 m_projectMonitor->slotZoneMoved(start, end);
1838 void MainWindow::slotGuidesUpdated()
1840 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1843 void MainWindow::slotPreferences(int page, int option)
1845 //An instance of your dialog could be already created and could be
1846 // cached, in which case you want to display the cached dialog
1847 // instead of creating another one
1848 if (KConfigDialog::showDialog("settings")) {
1849 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1850 if (page != -1) d->showPage(page, option);
1854 // KConfigDialog didn't find an instance of this dialog, so lets
1856 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1857 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1858 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1859 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1860 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1861 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1863 if (page != -1) dialog->showPage(page, option);
1866 void MainWindow::slotUpdatePreviewSettings()
1868 if (m_activeDocument) {
1869 m_clipMonitor->slotSetXml(NULL, 0);
1870 m_activeDocument->updatePreviewSettings();
1874 void MainWindow::updateConfiguration()
1876 //TODO: we should apply settings to all projects, not only the current one
1877 if (m_activeTimeline) {
1878 m_activeTimeline->refresh();
1879 m_activeTimeline->projectView()->checkAutoScroll();
1880 m_activeTimeline->projectView()->checkTrackHeight();
1881 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1883 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1884 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1885 #ifndef NO_JOGSHUTTLE
1886 activateShuttleDevice();
1887 #endif /* NO_JOGSHUTTLE */
1892 void MainWindow::slotSwitchVideoThumbs()
1894 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1895 if (m_activeTimeline) {
1896 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1898 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1901 void MainWindow::slotSwitchAudioThumbs()
1903 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1904 if (m_activeTimeline) {
1905 m_activeTimeline->refresh();
1906 m_activeTimeline->projectView()->checkAutoScroll();
1907 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1909 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1912 void MainWindow::slotSwitchMarkersComments()
1914 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1915 if (m_activeTimeline) {
1916 m_activeTimeline->refresh();
1918 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1921 void MainWindow::slotSwitchSnap()
1923 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1924 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1928 void MainWindow::slotDeleteTimelineClip()
1930 if (QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
1931 else if (m_activeTimeline) {
1932 m_activeTimeline->projectView()->deleteSelectedClips();
1936 void MainWindow::slotChangeClipSpeed()
1938 if (m_activeTimeline) {
1939 m_activeTimeline->projectView()->changeClipSpeed();
1943 void MainWindow::slotAddClipMarker()
1945 DocClipBase *clip = NULL;
1947 if (m_projectMonitor->isActive()) {
1948 if (m_activeTimeline) {
1949 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1951 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1952 clip = item->baseClip();
1956 clip = m_clipMonitor->activeClip();
1957 pos = m_clipMonitor->position();
1960 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1963 QString id = clip->getId();
1964 CommentedTime marker(pos, i18n("Marker"));
1965 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1966 if (d.exec() == QDialog::Accepted) {
1967 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1969 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1972 void MainWindow::slotDeleteClipMarker()
1974 DocClipBase *clip = NULL;
1976 if (m_projectMonitor->isActive()) {
1977 if (m_activeTimeline) {
1978 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1980 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1981 clip = item->baseClip();
1985 clip = m_clipMonitor->activeClip();
1986 pos = m_clipMonitor->position();
1989 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1993 QString id = clip->getId();
1994 QString comment = clip->markerComment(pos);
1995 if (comment.isEmpty()) {
1996 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1999 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2000 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2004 void MainWindow::slotDeleteAllClipMarkers()
2006 DocClipBase *clip = NULL;
2007 if (m_projectMonitor->isActive()) {
2008 if (m_activeTimeline) {
2009 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2011 clip = item->baseClip();
2015 clip = m_clipMonitor->activeClip();
2018 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2021 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2022 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2025 void MainWindow::slotEditClipMarker()
2027 DocClipBase *clip = NULL;
2029 if (m_projectMonitor->isActive()) {
2030 if (m_activeTimeline) {
2031 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2033 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2034 clip = item->baseClip();
2038 clip = m_clipMonitor->activeClip();
2039 pos = m_clipMonitor->position();
2042 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2046 QString id = clip->getId();
2047 QString oldcomment = clip->markerComment(pos);
2048 if (oldcomment.isEmpty()) {
2049 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2053 CommentedTime marker(pos, oldcomment);
2054 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2055 if (d.exec() == QDialog::Accepted) {
2056 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2057 if (d.newMarker().time() != pos) {
2058 // remove old marker
2059 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2061 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2065 void MainWindow::slotAddGuide()
2067 if (m_activeTimeline)
2068 m_activeTimeline->projectView()->slotAddGuide();
2071 void MainWindow::slotInsertSpace()
2073 if (m_activeTimeline)
2074 m_activeTimeline->projectView()->slotInsertSpace();
2077 void MainWindow::slotRemoveSpace()
2079 if (m_activeTimeline)
2080 m_activeTimeline->projectView()->slotRemoveSpace();
2083 void MainWindow::slotInsertTrack(int ix)
2085 m_projectMonitor->activateMonitor();
2086 if (m_activeTimeline)
2087 m_activeTimeline->projectView()->slotInsertTrack(ix);
2090 void MainWindow::slotDeleteTrack(int ix)
2092 m_projectMonitor->activateMonitor();
2093 if (m_activeTimeline)
2094 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2097 void MainWindow::slotChangeTrack(int ix)
2099 m_projectMonitor->activateMonitor();
2100 if (m_activeTimeline)
2101 m_activeTimeline->projectView()->slotChangeTrack(ix);
2104 void MainWindow::slotEditGuide()
2106 if (m_activeTimeline)
2107 m_activeTimeline->projectView()->slotEditGuide();
2110 void MainWindow::slotDeleteGuide()
2112 if (m_activeTimeline)
2113 m_activeTimeline->projectView()->slotDeleteGuide();
2116 void MainWindow::slotDeleteAllGuides()
2118 if (m_activeTimeline)
2119 m_activeTimeline->projectView()->slotDeleteAllGuides();
2122 void MainWindow::slotCutTimelineClip()
2124 if (m_activeTimeline) {
2125 m_activeTimeline->projectView()->cutSelectedClips();
2129 void MainWindow::slotGroupClips()
2131 if (m_activeTimeline) {
2132 m_activeTimeline->projectView()->groupClips();
2136 void MainWindow::slotUnGroupClips()
2138 if (m_activeTimeline) {
2139 m_activeTimeline->projectView()->groupClips(false);
2143 void MainWindow::slotAddProjectClip(KUrl url)
2145 if (m_activeDocument)
2146 m_activeDocument->slotAddClipFile(url, QString());
2149 void MainWindow::slotAddTransition(QAction *result)
2151 if (!result) return;
2152 QStringList info = result->data().toStringList();
2153 if (info.isEmpty()) return;
2154 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2155 if (m_activeTimeline && !transition.isNull()) {
2156 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2160 void MainWindow::slotAddVideoEffect(QAction *result)
2162 if (!result) return;
2163 QStringList info = result->data().toStringList();
2164 if (info.isEmpty()) return;
2165 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2166 slotAddEffect(effect);
2169 void MainWindow::slotAddAudioEffect(QAction *result)
2171 if (!result) return;
2172 QStringList info = result->data().toStringList();
2173 if (info.isEmpty()) return;
2174 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2175 slotAddEffect(effect);
2178 void MainWindow::slotAddCustomEffect(QAction *result)
2180 if (!result) return;
2181 QStringList info = result->data().toStringList();
2182 if (info.isEmpty()) return;
2183 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2184 slotAddEffect(effect);
2187 void MainWindow::slotZoomIn()
2189 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2192 void MainWindow::slotZoomOut()
2194 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2197 void MainWindow::slotFitZoom()
2199 if (m_activeTimeline) {
2200 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2204 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2206 m_statusProgressBar->setValue(progress);
2207 if (progress >= 0) {
2208 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2209 m_statusProgressBar->setVisible(true);
2211 m_messageLabel->setMessage(QString(), DefaultMessage);
2212 m_statusProgressBar->setVisible(false);
2216 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2218 if (clip->clipType() == TEXT) {
2219 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2220 QString path = clip->getProperty("resource");
2221 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2223 doc.setContent(clip->getProperty("xmldata"));
2224 dia_ui->setXml(doc);
2225 if (dia_ui->exec() == QDialog::Accepted) {
2226 QImage pix = dia_ui->renderedPixmap();
2228 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2229 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2230 QMap <QString, QString> newprops;
2231 newprops.insert("xmldata", dia_ui->xml().toString());
2232 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2233 m_activeDocument->commandStack()->push(command);
2234 m_clipMonitor->refreshMonitor(true);
2235 m_activeDocument->setModified(true);
2239 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2242 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2243 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2244 if (dia.exec() == QDialog::Accepted) {
2245 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2246 m_activeDocument->commandStack()->push(command);
2248 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2249 if (dia.needsTimelineRefresh()) {
2250 // update clip occurences in timeline
2251 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2256 void MainWindow::customEvent(QEvent* e)
2258 if (e->type() == QEvent::User) {
2259 // The timeline playing position changed...
2260 kDebug() << "RECEIVED JOG EVEMNT!!!";
2263 void MainWindow::slotActivateEffectStackView()
2265 m_effectStack->raiseWindow(m_effectStackDock);
2268 void MainWindow::slotActivateTransitionView(Transition *t)
2270 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2273 void MainWindow::slotSnapRewind()
2275 if (m_projectMonitor->isActive()) {
2276 if (m_activeTimeline)
2277 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2278 } else m_clipMonitor->slotSeekToPreviousSnap();
2281 void MainWindow::slotSnapForward()
2283 if (m_projectMonitor->isActive()) {
2284 if (m_activeTimeline)
2285 m_activeTimeline->projectView()->slotSeekToNextSnap();
2286 } else m_clipMonitor->slotSeekToNextSnap();
2289 void MainWindow::slotClipStart()
2291 if (m_projectMonitor->isActive()) {
2292 if (m_activeTimeline)
2293 m_activeTimeline->projectView()->clipStart();
2297 void MainWindow::slotClipEnd()
2299 if (m_projectMonitor->isActive()) {
2300 if (m_activeTimeline)
2301 m_activeTimeline->projectView()->clipEnd();
2305 void MainWindow::slotChangeTool(QAction * action)
2307 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2308 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2309 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2312 void MainWindow::slotSetTool(PROJECTTOOL tool)
2314 if (m_activeDocument && m_activeTimeline) {
2315 //m_activeDocument->setTool(tool);
2316 m_activeTimeline->projectView()->setTool(tool);
2320 void MainWindow::slotCopy()
2322 if (!m_activeDocument || !m_activeTimeline) return;
2323 m_activeTimeline->projectView()->copyClip();
2326 void MainWindow::slotPaste()
2328 if (!m_activeDocument || !m_activeTimeline) return;
2329 m_activeTimeline->projectView()->pasteClip();
2332 void MainWindow::slotPasteEffects()
2334 if (!m_activeDocument || !m_activeTimeline) return;
2335 m_activeTimeline->projectView()->pasteClipEffects();
2338 void MainWindow::slotFind()
2340 if (!m_activeDocument || !m_activeTimeline) return;
2341 m_projectSearch->setEnabled(false);
2342 m_findActivated = true;
2343 m_findString.clear();
2344 m_activeTimeline->projectView()->initSearchStrings();
2345 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2346 m_findTimer.start(5000);
2347 qApp->installEventFilter(this);
2350 void MainWindow::slotFindNext()
2352 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2353 statusBar()->showMessage(i18n("Found : %1", m_findString));
2355 statusBar()->showMessage(i18n("Reached end of project"));
2357 m_findTimer.start(4000);
2360 void MainWindow::findAhead()
2362 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2363 m_projectSearchNext->setEnabled(true);
2364 statusBar()->showMessage(i18n("Found : %1", m_findString));
2366 m_projectSearchNext->setEnabled(false);
2367 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2371 void MainWindow::findTimeout()
2373 m_projectSearchNext->setEnabled(false);
2374 m_findActivated = false;
2375 m_findString.clear();
2376 statusBar()->showMessage(i18n("Find stopped"), 3000);
2377 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2378 m_projectSearch->setEnabled(true);
2379 removeEventFilter(this);
2382 void MainWindow::keyPressEvent(QKeyEvent *ke)
2384 if (m_findActivated) {
2385 if (ke->key() == Qt::Key_Backspace) {
2386 m_findString = m_findString.left(m_findString.length() - 1);
2388 if (!m_findString.isEmpty()) {
2394 m_findTimer.start(4000);
2397 } else if (ke->key() == Qt::Key_Escape) {
2401 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2402 m_findString += ke->text();
2406 m_findTimer.start(4000);
2410 } else KXmlGuiWindow::keyPressEvent(ke);
2414 /** Gets called when the window gets hidden */
2415 void MainWindow::hideEvent(QHideEvent */*event*/)
2417 // kDebug() << "I was hidden";
2418 // issue http://www.kdenlive.org/mantis/view.php?id=231
2419 if (isMinimized()) {
2420 // kDebug() << "I am minimized";
2421 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2425 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2427 if (m_findActivated) {
2428 if (event->type() == QEvent::ShortcutOverride) {
2429 QKeyEvent* ke = (QKeyEvent*) event;
2430 if (ke->text().trimmed().isEmpty()) return false;
2433 } else return false;
2435 // pass the event on to the parent class
2436 return QMainWindow::eventFilter(obj, event);
2440 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2442 KDialog *dialog = new KDialog(this);
2443 dialog->setCaption("Save clip zone");
2444 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2446 QWidget *widget = new QWidget(dialog);
2447 dialog->setMainWidget(widget);
2449 QVBoxLayout *vbox = new QVBoxLayout(widget);
2450 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2451 QString path = m_activeDocument->projectFolder().path();
2453 path.append("untitled.westley");
2454 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2455 url->setFilter("video/mlt-playlist");
2456 QLabel *label2 = new QLabel(i18n("Description:"), this);
2457 KLineEdit *edit = new KLineEdit(this);
2458 vbox->addWidget(label1);
2459 vbox->addWidget(url);
2460 vbox->addWidget(label2);
2461 vbox->addWidget(edit);
2462 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2466 void MainWindow::slotSetInPoint()
2468 if (m_clipMonitor->isActive()) {
2469 m_clipMonitor->slotSetZoneStart();
2470 } else m_activeTimeline->projectView()->setInPoint();
2473 void MainWindow::slotSetOutPoint()
2475 if (m_clipMonitor->isActive()) {
2476 m_clipMonitor->slotSetZoneEnd();
2477 } else m_activeTimeline->projectView()->setOutPoint();
2480 void MainWindow::slotGetNewLumaStuff()
2482 //KNS::Entry::List download();
2483 KNS::Entry::List entries = KNS::Engine::download();
2484 // list of changed entries
2485 kDebug() << "// PARSING KNS";
2486 foreach(KNS::Entry* entry, entries) {
2487 // care only about installed ones
2488 if (entry->status() == KNS::Entry::Installed) {
2489 foreach(const QString &file, entry->installedFiles()) {
2490 kDebug() << "// CURRENTLY INSTALLED: " << file;
2494 qDeleteAll(entries);
2495 initEffects::refreshLumas();
2498 void MainWindow::slotGetNewRenderStuff()
2500 //KNS::Entry::List download();
2502 KNS::Engine engine(0);
2503 if (engine.init("kdenlive_render.knsrc")) {
2504 KNS::Entry::List entries = engine.downloadDialogModal(this);
2506 if (entries.size() > 0) {
2507 foreach(KNS::Entry* entry, entries) {
2508 // care only about installed ones
2509 if (entry->status() == KNS::Entry::Installed) {
2510 foreach(const QString &file, entry->installedFiles()) {
2511 kDebug() << "// CURRENTLY INSTALLED: " << file;
2516 if (m_renderWidget) m_renderWidget->reloadProfiles();
2520 void MainWindow::slotGetNewMltProfileStuff()
2522 //KNS::Entry::List download();
2524 KNS::Engine engine(0);
2525 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2526 KNS::Entry::List entries = engine.downloadDialogModal(this);
2528 if (entries.size() > 0) {
2529 foreach(KNS::Entry* entry, entries) {
2530 // care only about installed ones
2531 if (entry->status() == KNS::Entry::Installed) {
2532 foreach(const QString &file, entry->installedFiles()) {
2533 kDebug() << "// CURRENTLY INSTALLED: " << file;
2538 // update the list of profiles in settings dialog
2539 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2540 if (d) d->checkProfile();
2545 void MainWindow::slotAutoTransition()
2547 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2550 void MainWindow::slotSplitAudio()
2552 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2555 void MainWindow::slotUpdateClipType(QAction *action)
2557 if (m_activeTimeline) {
2558 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2559 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2560 else m_activeTimeline->projectView()->setAudioAndVideo();
2564 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2566 DvdWizard *w = new DvdWizard(url, profile, this);
2570 void MainWindow::slotShowTimeline(bool show)
2572 if (show == false) {
2573 m_timelineState = saveState();
2574 centralWidget()->setHidden(true);
2576 centralWidget()->setHidden(false);
2577 restoreState(m_timelineState);
2581 void MainWindow::slotMaximizeCurrent(bool show)
2583 //TODO: is there a way to maximize current widget?
2586 m_timelineState = saveState();
2587 QWidget *par = focusWidget()->parentWidget();
2588 while (par->parentWidget() && par->parentWidget() != this) {
2589 par = par->parentWidget();
2591 kDebug() << "CURRENT WIDGET: " << par->objectName();
2594 //centralWidget()->setHidden(false);
2595 //restoreState(m_timelineState);
2599 #include "mainwindow.moc"