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_STATUS_MSG = 1;
92 static const int ID_EDITMODE_MSG = 2;
93 static const int ID_TIMELINE_MSG = 3;
94 static const int ID_TIMELINE_BUTTONS = 5;
95 static const int ID_TIMELINE_POS = 6;
96 static const int ID_TIMELINE_FORMAT = 7;
103 EffectsList MainWindow::videoEffects;
104 EffectsList MainWindow::audioEffects;
105 EffectsList MainWindow::customEffects;
106 EffectsList MainWindow::transitions;
108 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
109 KXmlGuiWindow(parent),
110 m_activeDocument(NULL),
111 m_activeTimeline(NULL),
112 m_renderWidget(NULL),
113 #ifndef NO_JOGSHUTTLE
115 #endif /* NO_JOGSHUTTLE */
116 m_findActivated(false),
120 // Create DBus interface
121 new MainWindowAdaptor(this);
122 QDBusConnection dbus = QDBusConnection::sessionBus();
123 dbus.registerObject("/MainWindow", this);
125 setlocale(LC_NUMERIC, "POSIX");
126 setFont(KGlobalSettings::toolBarFont());
127 parseProfiles(MltPath);
128 m_commandStack = new QUndoGroup;
129 m_timelineArea = new KTabWidget(this);
130 m_timelineArea->setTabReorderingEnabled(true);
131 m_timelineArea->setTabBarHidden(true);
133 QToolButton *closeTabButton = new QToolButton;
134 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
135 closeTabButton->setIcon(KIcon("tab-close"));
136 closeTabButton->adjustSize();
137 closeTabButton->setToolTip(i18n("Close the current tab"));
138 m_timelineArea->setCornerWidget(closeTabButton);
139 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
141 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
142 m_findTimer.setSingleShot(true);
144 initEffects::parseEffectFiles();
145 //initEffects::parseCustomEffectsFile();
147 m_monitorManager = new MonitorManager();
149 projectListDock = new QDockWidget(i18n("Project Tree"), this);
150 projectListDock->setObjectName("project_tree");
151 m_projectList = new ProjectList(this);
152 projectListDock->setWidget(m_projectList);
153 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
155 effectListDock = new QDockWidget(i18n("Effect List"), this);
156 effectListDock->setObjectName("effect_list");
157 m_effectList = new EffectsListView();
159 //m_effectList = new KListWidget(this);
160 effectListDock->setWidget(m_effectList);
161 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
163 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
164 effectStackDock->setObjectName("effect_stack");
165 effectStack = new EffectStackView(this);
166 effectStackDock->setWidget(effectStack);
167 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
169 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
170 transitionConfigDock->setObjectName("transition");
171 transitionConfig = new TransitionSettings(this);
172 transitionConfigDock->setWidget(transitionConfig);
173 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
175 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
176 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
180 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
181 clipMonitorDock->setObjectName("clip_monitor");
182 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
183 clipMonitorDock->setWidget(m_clipMonitor);
184 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
185 //m_clipMonitor->stop();
187 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
188 projectMonitorDock->setObjectName("project_monitor");
189 m_projectMonitor = new Monitor("project", m_monitorManager, this);
190 projectMonitorDock->setWidget(m_projectMonitor);
191 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
193 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
194 recMonitorDock->setObjectName("record_monitor");
195 m_recMonitor = new RecMonitor("record", this);
196 recMonitorDock->setWidget(m_recMonitor);
197 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
199 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
200 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
202 undoViewDock = new QDockWidget(i18n("Undo History"), this);
203 undoViewDock->setObjectName("undo_history");
204 m_undoView = new QUndoView(this);
205 m_undoView->setCleanIcon(KIcon("edit-clear"));
206 m_undoView->setEmptyLabel(i18n("Clean"));
207 undoViewDock->setWidget(m_undoView);
208 m_undoView->setGroup(m_commandStack);
209 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
211 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
212 //overviewDock->setObjectName("project_overview");
213 //m_overView = new CustomTrackView(NULL, NULL, this);
214 //overviewDock->setWidget(m_overView);
215 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
218 //tabifyDockWidget(projectListDock, effectListDock);
219 tabifyDockWidget(projectListDock, effectStackDock);
220 tabifyDockWidget(projectListDock, transitionConfigDock);
221 //tabifyDockWidget(projectListDock, undoViewDock);
224 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
225 tabifyDockWidget(clipMonitorDock, recMonitorDock);
226 setCentralWidget(m_timelineArea);
230 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
231 guiFactory()->addClient(sp);*/
234 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
236 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
237 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
238 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)));
240 // build effects menus
242 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
244 QStringList effectInfo;
245 QMap<QString, QStringList> effectsList;
246 for (int ix = 0; ix < videoEffects.count(); ix++) {
247 effectInfo = videoEffects.effectIdInfo(ix);
248 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
251 foreach(const QStringList &value, effectsList) {
252 action = new QAction(value.at(0), this);
253 action->setData(value);
254 videoEffectsMenu->addAction(action);
257 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
261 for (int ix = 0; ix < audioEffects.count(); ix++) {
262 effectInfo = audioEffects.effectIdInfo(ix);
263 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
266 foreach(const QStringList &value, effectsList) {
267 action = new QAction(value.at(0), this);
268 action->setData(value);
269 audioEffectsMenu->addAction(action);
272 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
274 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
275 else m_customEffectsMenu->setEnabled(true);
278 for (int ix = 0; ix < customEffects.count(); ix++) {
279 effectInfo = customEffects.effectIdInfo(ix);
280 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
283 foreach(const QStringList &value, effectsList) {
284 action = new QAction(value.at(0), this);
285 action->setData(value);
286 m_customEffectsMenu->addAction(action);
289 QMenu *newEffect = new QMenu(this);
290 newEffect->addMenu(videoEffectsMenu);
291 newEffect->addMenu(audioEffectsMenu);
292 newEffect->addMenu(m_customEffectsMenu);
293 effectStack->setMenu(newEffect);
296 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
297 const QList<QAction *> viewActions = createPopupMenu()->actions();
298 viewMenu->insertActions(NULL, viewActions);
300 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
301 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
302 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
304 m_timelineContextMenu = new QMenu(this);
305 m_timelineContextClipMenu = new QMenu(this);
306 m_timelineContextTransitionMenu = new QMenu(this);
309 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
310 QStringList effects = transitions.effectNames();
313 for (int ix = 0; ix < transitions.count(); ix++) {
314 effectInfo = transitions.effectIdInfo(ix);
315 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
317 foreach(const QStringList &value, effectsList) {
318 action = new QAction(value.at(0), this);
319 action->setData(value);
320 transitionsMenu->addAction(action);
322 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
324 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
325 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
326 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
328 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
329 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
330 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
331 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
332 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
333 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
334 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
335 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
337 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
338 m_timelineContextClipMenu->addMenu(markersMenu);
339 m_timelineContextClipMenu->addMenu(transitionsMenu);
340 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
341 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
342 //TODO: re-enable custom effects menu when it is implemented
343 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
345 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
346 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
348 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
350 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
351 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
352 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
353 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
354 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
355 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
357 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
358 slotConnectMonitors();
360 // Open or create a file. Command line argument passed in Url has
361 // precedence, then "openlastproject", then just a plain empty file.
362 // If opening Url fails, openlastproject will _not_ be used.
363 if (!Url.isEmpty()) {
366 if (KdenliveSettings::openlastproject()) {
370 if (m_timelineArea->count() == 0) {
374 #ifndef NO_JOGSHUTTLE
375 activateShuttleDevice();
376 #endif /* NO_JOGSHUTTLE */
377 projectListDock->raise();
380 void MainWindow::queryQuit()
382 kDebug() << "----- SAVING CONFUIG";
383 if (queryClose()) kapp->quit();
387 bool MainWindow::queryClose()
390 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
391 if (m_activeDocument && m_activeDocument->isModified()) {
392 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
393 case KMessageBox::Yes :
394 // save document here. If saving fails, return false;
396 case KMessageBox::No :
406 void MainWindow::loadPlugins()
408 foreach(QObject *plugin, QPluginLoader::staticInstances())
409 populateMenus(plugin);
411 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
413 filters << "libkdenlive*";
414 foreach(const QString &folder, directories) {
415 kDebug() << "// PARSING FIOLER: " << folder;
416 QDir pluginsDir(folder);
417 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
418 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
419 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
420 QObject *plugin = loader.instance();
422 populateMenus(plugin);
423 m_pluginFileNames += fileName;
424 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
430 void MainWindow::populateMenus(QObject *plugin)
432 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
433 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
435 addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
439 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
440 QMenu *menu, const char *member,
441 QActionGroup *actionGroup)
443 kDebug() << "// ADD to MENU" << texts;
444 foreach(const QString &text, texts) {
445 QAction *action = new QAction(text, plugin);
446 action->setData(text);
447 connect(action, SIGNAL(triggered()), this, member);
448 menu->addAction(action);
451 action->setCheckable(true);
452 actionGroup->addAction(action);
457 void MainWindow::aboutPlugins()
459 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
464 void MainWindow::generateClip()
466 QAction *action = qobject_cast<QAction *>(sender());
467 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
469 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
470 if (!clipUrl.isEmpty()) {
471 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
475 void MainWindow::saveProperties(KConfig*)
477 // save properties here,used by session management
482 void MainWindow::readProperties(KConfig *config)
484 // read properties here,used by session management
485 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
486 openFile(KUrl(Lastproject));
489 void MainWindow::slotReloadEffects()
491 initEffects::parseCustomEffectsFile();
492 m_customEffectsMenu->clear();
493 const QStringList effects = customEffects.effectNames();
495 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
496 else m_customEffectsMenu->setEnabled(true);
498 foreach(const QString &name, effects) {
499 action = new QAction(name, this);
500 action->setData(name);
501 m_customEffectsMenu->addAction(action);
503 m_effectList->reloadEffectList();
506 #ifndef NO_JOGSHUTTLE
507 void MainWindow::activateShuttleDevice()
509 if (m_jogProcess) delete m_jogProcess;
511 if (KdenliveSettings::enableshuttle() == false) return;
512 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
513 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
514 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
515 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
516 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
517 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
518 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
521 void MainWindow::slotShuttleButton(int code)
525 slotShuttleAction(KdenliveSettings::shuttle1());
528 slotShuttleAction(KdenliveSettings::shuttle2());
531 slotShuttleAction(KdenliveSettings::shuttle3());
534 slotShuttleAction(KdenliveSettings::shuttle4());
537 slotShuttleAction(KdenliveSettings::shuttle5());
542 void MainWindow::slotShuttleAction(int code)
548 m_monitorManager->slotPlay();
551 m_monitorManager->slotPlay();
555 #endif /* NO_JOGSHUTTLE */
557 void MainWindow::configureNotifications()
559 KNotifyConfigWidget::configure(this);
562 void MainWindow::slotFullScreen()
564 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
567 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
569 if (!m_activeDocument) return;
570 if (effect.isNull()) {
571 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
574 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
575 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
578 void MainWindow::slotRaiseMonitor(bool clipMonitor)
580 if (clipMonitor) clipMonitorDock->raise();
581 else projectMonitorDock->raise();
584 void MainWindow::slotSetClipDuration(const QString &id, int duration)
586 if (!m_activeDocument) return;
587 m_activeDocument->setProducerDuration(id, duration);
590 void MainWindow::slotConnectMonitors()
593 m_projectList->setRenderer(m_projectMonitor->render);
594 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
595 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
596 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
597 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
598 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)));
600 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
602 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
604 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
605 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
607 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
608 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
611 void MainWindow::slotAdjustClipMonitor()
613 clipMonitorDock->updateGeometry();
614 clipMonitorDock->adjustSize();
615 m_clipMonitor->resetSize();
618 void MainWindow::slotAdjustProjectMonitor()
620 projectMonitorDock->updateGeometry();
621 projectMonitorDock->adjustSize();
622 m_projectMonitor->resetSize();
625 void MainWindow::setupActions()
628 KActionCollection* collection = actionCollection();
629 m_timecodeFormat = new KComboBox(this);
630 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
631 m_timecodeFormat->addItem(i18n("Frames"));
633 statusProgressBar = new QProgressBar(this);
634 statusProgressBar->setMinimum(0);
635 statusProgressBar->setMaximum(100);
636 statusProgressBar->setMaximumWidth(150);
637 statusProgressBar->setVisible(false);
639 QWidget *w = new QWidget;
641 QHBoxLayout *layout = new QHBoxLayout;
642 w->setLayout(layout);
643 layout->setContentsMargins(5, 0, 5, 0);
644 QToolBar *toolbar = new QToolBar("statusToolBar", this);
647 m_toolGroup = new QActionGroup(this);
649 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;}";
651 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
652 toolbar->addAction(m_buttonSelectTool);
653 m_buttonSelectTool->setCheckable(true);
654 m_buttonSelectTool->setChecked(true);
656 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
657 toolbar->addAction(m_buttonRazorTool);
658 m_buttonRazorTool->setCheckable(true);
659 m_buttonRazorTool->setChecked(false);
661 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
662 toolbar->addAction(m_buttonSpacerTool);
663 m_buttonSpacerTool->setCheckable(true);
664 m_buttonSpacerTool->setChecked(false);
666 m_toolGroup->addAction(m_buttonSelectTool);
667 m_toolGroup->addAction(m_buttonRazorTool);
668 m_toolGroup->addAction(m_buttonSpacerTool);
669 m_toolGroup->setExclusive(true);
670 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
672 QWidget * actionWidget;
673 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
674 actionWidget->setMaximumWidth(24);
675 actionWidget->setMinimumHeight(17);
677 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
678 actionWidget->setMaximumWidth(24);
679 actionWidget->setMinimumHeight(17);
681 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
682 actionWidget->setMaximumWidth(24);
683 actionWidget->setMinimumHeight(17);
685 toolbar->setStyleSheet(style1);
686 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
688 toolbar->addSeparator();
689 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
690 toolbar->addAction(m_buttonFitZoom);
691 m_buttonFitZoom->setCheckable(false);
692 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
694 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
695 actionWidget->setMaximumWidth(24);
696 actionWidget->setMinimumHeight(17);
698 m_zoomSlider = new QSlider(Qt::Horizontal, this);
699 m_zoomSlider->setMaximum(13);
700 m_zoomSlider->setPageStep(1);
702 m_zoomSlider->setMaximumWidth(150);
703 m_zoomSlider->setMinimumWidth(100);
705 const int contentHeight = QFontMetrics(w->font()).height() + 8;
707 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
708 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
710 m_zoomSlider->setStyleSheet(style);
712 //m_zoomSlider->height() + 5;
713 statusBar()->setMinimumHeight(contentHeight);
716 toolbar->addWidget(m_zoomSlider);
718 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
719 toolbar->addAction(m_buttonVideoThumbs);
720 m_buttonVideoThumbs->setCheckable(true);
721 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
722 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
724 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
725 toolbar->addAction(m_buttonAudioThumbs);
726 m_buttonAudioThumbs->setCheckable(true);
727 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
728 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
730 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
731 toolbar->addAction(m_buttonShowMarkers);
732 m_buttonShowMarkers->setCheckable(true);
733 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
734 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
736 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
737 toolbar->addAction(m_buttonSnap);
738 m_buttonSnap->setCheckable(true);
739 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
740 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
741 layout->addWidget(toolbar);
744 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
745 actionWidget->setMaximumWidth(24);
746 actionWidget->setMinimumHeight(17);
748 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
749 actionWidget->setMaximumWidth(24);
750 actionWidget->setMinimumHeight(17);
752 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
753 actionWidget->setMaximumWidth(24);
754 actionWidget->setMinimumHeight(17);
756 actionWidget = toolbar->widgetForAction(m_buttonSnap);
757 actionWidget->setMaximumWidth(24);
758 actionWidget->setMinimumHeight(17);
760 m_messageLabel = new StatusBarMessageLabel(this);
761 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
763 statusBar()->addWidget(m_messageLabel, 10);
764 statusBar()->addWidget(statusProgressBar, 0);
765 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
766 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
767 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
768 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
769 m_messageLabel->hide();
771 collection->addAction("select_tool", m_buttonSelectTool);
772 collection->addAction("razor_tool", m_buttonRazorTool);
773 collection->addAction("spacer_tool", m_buttonSpacerTool);
775 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
776 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
777 collection->addAction("show_markers", m_buttonShowMarkers);
778 collection->addAction("snap", m_buttonSnap);
779 collection->addAction("zoom_fit", m_buttonFitZoom);
781 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
782 collection->addAction("zoom_in", zoomIn);
783 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
784 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
786 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
787 collection->addAction("zoom_out", zoomOut);
788 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
789 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
791 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
792 collection->addAction("project_find", m_projectSearch);
793 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
794 m_projectSearch->setShortcut(Qt::Key_Slash);
796 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
797 collection->addAction("project_find_next", m_projectSearchNext);
798 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
799 m_projectSearchNext->setShortcut(Qt::Key_F3);
800 m_projectSearchNext->setEnabled(false);
802 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
803 collection->addAction("manage_profiles", profilesAction);
804 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
806 KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
808 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
810 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
812 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
813 collection->addAction("run_wizard", wizAction);
814 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
816 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
817 collection->addAction("project_settings", projectAction);
818 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
820 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
821 collection->addAction("project_render", projectRender);
822 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
823 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
825 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
826 KShortcut playShortcut;
827 playShortcut.setPrimary(Qt::Key_Space);
828 playShortcut.setAlternate(Qt::Key_K);
829 monitorPlay->setShortcut(playShortcut);
830 collection->addAction("monitor_play", monitorPlay);
831 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
833 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
834 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
835 collection->addAction("monitor_play_zone", m_playZone);
836 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
838 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
839 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
840 collection->addAction("monitor_loop_zone", m_loopZone);
841 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
843 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
844 collection->addAction("dvd_wizard", dvdWizard);
845 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
847 KAction *markIn = collection->addAction("mark_in");
848 markIn->setText(i18n("Set In Point"));
849 markIn->setShortcut(Qt::Key_I);
850 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
852 KAction *markOut = collection->addAction("mark_out");
853 markOut->setText(i18n("Set Out Point"));
854 markOut->setShortcut(Qt::Key_O);
855 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
857 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
858 monitorSeekBackward->setShortcut(Qt::Key_J);
859 collection->addAction("monitor_seek_backward", monitorSeekBackward);
860 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
862 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
863 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
864 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
865 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
867 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
868 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
869 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
870 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
872 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
873 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
874 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
875 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
877 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
878 monitorSeekForward->setShortcut(Qt::Key_L);
879 collection->addAction("monitor_seek_forward", monitorSeekForward);
880 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
882 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
883 clipStart->setShortcut(Qt::Key_Home);
884 collection->addAction("seek_clip_start", clipStart);
885 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
887 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
888 clipEnd->setShortcut(Qt::Key_End);
889 collection->addAction("seek_clip_end", clipEnd);
890 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
892 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
893 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
894 collection->addAction("seek_start", projectStart);
895 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
897 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
898 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
899 collection->addAction("seek_end", projectEnd);
900 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
902 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
903 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
904 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
905 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
907 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
908 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
909 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
910 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
912 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
913 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
914 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
915 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
917 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
918 deleteTimelineClip->setShortcut(Qt::Key_Delete);
919 collection->addAction("delete_timeline_clip", deleteTimelineClip);
920 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
922 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
923 collection->addAction("change_clip_speed", editTimelineClipSpeed);
924 editTimelineClipSpeed->setData("change_speed");
925 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
927 KAction *stickTransition = collection->addAction("auto_transition");
928 stickTransition->setData(QString("auto"));
929 stickTransition->setCheckable(true);
930 stickTransition->setEnabled(false);
931 stickTransition->setText(i18n("Automatic Transition"));
932 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
934 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
935 collection->addAction("group_clip", groupClip);
936 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
938 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
939 collection->addAction("ungroup_clip", ungroupClip);
940 ungroupClip->setData("ungroup_clip");
941 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
943 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
944 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
945 collection->addAction("cut_timeline_clip", cutTimelineClip);
946 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
948 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
949 collection->addAction("add_clip_marker", addClipMarker);
950 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
952 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
953 collection->addAction("delete_clip_marker", deleteClipMarker);
954 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
956 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
957 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
958 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
960 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
961 collection->addAction("edit_clip_marker", editClipMarker);
962 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
964 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
965 collection->addAction("split_audio", splitAudio);
966 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
968 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
969 collection->addAction("clip_audio_only", audioOnly);
970 audioOnly->setData("clip_audio_only");
971 audioOnly->setCheckable(true);
973 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
974 collection->addAction("clip_video_only", videoOnly);
975 videoOnly->setData("clip_video_only");
976 videoOnly->setCheckable(true);
978 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
979 collection->addAction("clip_audio_and_video", audioAndVideo);
980 audioAndVideo->setData("clip_audio_and_video");
981 audioAndVideo->setCheckable(true);
983 m_clipTypeGroup = new QActionGroup(this);
984 m_clipTypeGroup->addAction(audioOnly);
985 m_clipTypeGroup->addAction(videoOnly);
986 m_clipTypeGroup->addAction(audioAndVideo);
987 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
988 m_clipTypeGroup->setEnabled(false);
990 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
991 collection->addAction("insert_space", insertSpace);
992 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
994 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
995 collection->addAction("delete_space", removeSpace);
996 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
998 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
999 collection->addAction("insert_track", insertTrack);
1000 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1002 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1003 collection->addAction("delete_track", deleteTrack);
1004 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1006 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1007 collection->addAction("change_track", changeTrack);
1008 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1010 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1011 collection->addAction("add_guide", addGuide);
1012 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1014 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1015 collection->addAction("delete_guide", delGuide);
1016 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1018 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1019 collection->addAction("edit_guide", editGuide);
1020 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1022 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1023 collection->addAction("delete_all_guides", delAllGuides);
1024 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1026 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1027 collection->addAction("paste_effects", pasteEffects);
1028 pasteEffects->setData("paste_effects");
1029 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1031 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1032 collection->addAction("show_timeline", showTimeline);
1033 showTimeline->setCheckable(true);
1034 showTimeline->setChecked(true);
1035 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1037 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1038 collection->addAction("maximize_current", maxCurrent);
1039 maxCurrent->setCheckable(true);
1040 maxCurrent->setChecked(false);
1041 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1044 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1046 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1048 KStandardAction::open(this, SLOT(openFile()), collection);
1050 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1052 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1054 KStandardAction::openNew(this, SLOT(newFile()), collection);
1056 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1058 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1060 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1062 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1064 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1065 undo->setEnabled(false);
1066 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1068 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1069 redo->setEnabled(false);
1070 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1072 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1074 connect(collection, SIGNAL(actionHovered(QAction*)),
1075 this, SLOT(slotDisplayActionMessage(QAction*)));
1078 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1079 collection->addAction("add_clip", addClip);
1080 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1082 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1083 collection->addAction("add_color_clip", addColorClip);
1084 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1086 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1087 collection->addAction("add_slide_clip", addSlideClip);
1088 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1090 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1091 collection->addAction("add_text_clip", addTitleClip);
1092 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1094 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1095 collection->addAction("add_folder", addFolderButton);
1096 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1098 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1099 collection->addAction("clip_properties", clipProperties);
1100 clipProperties->setData("clip_properties");
1101 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1102 clipProperties->setEnabled(false);
1104 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1105 collection->addAction("edit_clip", openClip);
1106 openClip->setData("edit_clip");
1107 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1108 openClip->setEnabled(false);
1110 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1111 collection->addAction("delete_clip", deleteClip);
1112 deleteClip->setData("delete_clip");
1113 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1114 deleteClip->setEnabled(false);
1116 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1117 collection->addAction("reload_clip", reloadClip);
1118 reloadClip->setData("reload_clip");
1119 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1120 reloadClip->setEnabled(false);
1122 QMenu *addClips = new QMenu();
1123 addClips->addAction(addClip);
1124 addClips->addAction(addColorClip);
1125 addClips->addAction(addSlideClip);
1126 addClips->addAction(addTitleClip);
1127 addClips->addAction(addFolderButton);
1129 addClips->addAction(reloadClip);
1130 addClips->addAction(clipProperties);
1131 addClips->addAction(openClip);
1132 addClips->addAction(deleteClip);
1133 m_projectList->setupMenu(addClips, addClip);
1135 //connect(collection, SIGNAL( clearStatusText() ),
1136 //statusBar(), SLOT( clear() ) );
1139 void MainWindow::slotDisplayActionMessage(QAction *a)
1141 statusBar()->showMessage(a->data().toString(), 3000);
1144 void MainWindow::saveOptions()
1146 KdenliveSettings::self()->writeConfig();
1147 KSharedConfigPtr config = KGlobal::config();
1148 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1149 KConfigGroup treecolumns(config, "Project Tree");
1150 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1154 void MainWindow::readOptions()
1156 KSharedConfigPtr config = KGlobal::config();
1157 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1158 KConfigGroup initialGroup(config, "version");
1159 bool upgrade = false;
1160 if (initialGroup.exists()) {
1161 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1164 if (initialGroup.readEntry("version") == "0.7") {
1165 //Add new settings from 0.7.1
1166 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1167 QString path = QDir::homePath() + "/kdenlive";
1168 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1169 KdenliveSettings::setDefaultprojectfolder(path);
1175 if (!initialGroup.exists() || upgrade) {
1176 // this is our first run, show Wizard
1177 Wizard *w = new Wizard(upgrade, this);
1178 if (w->exec() == QDialog::Accepted && w->isOk()) {
1179 w->adjustSettings();
1180 initialGroup.writeEntry("version", version);
1186 KConfigGroup treecolumns(config, "Project Tree");
1187 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1188 if (!state.isEmpty())
1189 m_projectList->setHeaderInfo(state);
1192 void MainWindow::slotRunWizard()
1194 Wizard *w = new Wizard(this);
1195 if (w->exec() == QDialog::Accepted && w->isOk()) {
1196 w->adjustSettings();
1201 void MainWindow::newFile(bool showProjectSettings)
1203 QString profileName;
1205 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1206 if (!showProjectSettings && m_timelineArea->count() == 0) {
1207 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1208 profileName = KdenliveSettings::default_profile();
1210 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1211 if (w->exec() != QDialog::Accepted) return;
1212 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1213 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1214 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1215 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1216 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1217 profileName = w->selectedProfile();
1218 projectFolder = w->selectedFolder();
1219 projectTracks = w->tracks();
1222 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1223 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1224 TrackView *trackView = new TrackView(doc, this);
1225 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1226 if (m_timelineArea->count() == 1) {
1227 connectDocumentInfo(doc);
1228 connectDocument(trackView, doc);
1229 } else m_timelineArea->setTabBarHidden(false);
1230 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1233 void MainWindow::activateDocument()
1235 if (m_timelineArea->currentWidget() == NULL) return;
1236 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1237 KdenliveDoc *currentDoc = currentTab->document();
1238 connectDocumentInfo(currentDoc);
1239 connectDocument(currentTab, currentDoc);
1242 void MainWindow::closeCurrentDocument()
1244 QWidget *w = m_timelineArea->currentWidget();
1246 // closing current document
1247 int ix = m_timelineArea->currentIndex() + 1;
1248 if (ix == m_timelineArea->count()) ix = 0;
1249 m_timelineArea->setCurrentIndex(ix);
1250 TrackView *tabToClose = (TrackView *) w;
1251 KdenliveDoc *docToClose = tabToClose->document();
1252 if (docToClose && docToClose->isModified()) {
1253 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1254 case KMessageBox::Yes :
1255 // save document here. If saving fails, return false;
1256 if (saveFile() == false) return;
1258 case KMessageBox::Cancel :
1264 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1265 if (m_timelineArea->count() == 1) {
1266 m_timelineArea->setTabBarHidden(true);
1267 m_closeAction->setEnabled(false);
1271 if (m_timelineArea->count() == 0) {
1272 m_activeDocument = NULL;
1273 effectStack->clear();
1274 transitionConfig->slotTransitionItemSelected(NULL, false);
1278 bool MainWindow::saveFileAs(const QString &outputFileName)
1280 QString currentSceneList;
1281 if (KdenliveSettings::dropbframes()) {
1282 KdenliveSettings::setDropbframes(false);
1283 m_activeDocument->clipManager()->updatePreviewSettings();
1284 currentSceneList = m_projectMonitor->sceneList();
1285 KdenliveSettings::setDropbframes(true);
1286 m_activeDocument->clipManager()->updatePreviewSettings();
1287 } else currentSceneList = m_projectMonitor->sceneList();
1289 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1292 // Save timeline thumbnails
1293 m_activeTimeline->projectView()->saveThumbnails();
1294 m_activeDocument->setUrl(KUrl(outputFileName));
1295 if (m_activeDocument->m_autosave == NULL) {
1296 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1297 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1298 setCaption(m_activeDocument->description());
1299 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1300 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1301 m_activeDocument->setModified(false);
1302 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1306 bool MainWindow::saveFileAs()
1308 // Check that the Kdenlive mime type is correctly installed
1309 QString mimetype = "application/x-kdenlive";
1310 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1311 if (!mime) mimetype = "*.kdenlive";
1313 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1314 if (outputFile.isEmpty()) return false;
1315 if (QFile::exists(outputFile)) {
1316 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1318 return saveFileAs(outputFile);
1321 bool MainWindow::saveFile()
1323 if (!m_activeDocument) return true;
1324 if (m_activeDocument->url().isEmpty()) {
1325 return saveFileAs();
1327 bool result = saveFileAs(m_activeDocument->url().path());
1328 m_activeDocument->m_autosave->resize(0);
1333 void MainWindow::openFile()
1335 // Check that the Kdenlive mime type is correctly installed
1336 QString mimetype = "application/x-kdenlive";
1337 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1338 if (!mime) mimetype = "*.kdenlive";
1340 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1341 if (url.isEmpty()) return;
1342 m_fileOpenRecent->addUrl(url);
1346 void MainWindow::openLastFile()
1348 KSharedConfigPtr config = KGlobal::config();
1349 KUrl::List urls = m_fileOpenRecent->urls();
1350 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1351 if (urls.isEmpty()) newFile(false);
1352 else openFile(urls.last());
1355 void MainWindow::openFile(const KUrl &url)
1357 // Check if the document is already opened
1358 const int ct = m_timelineArea->count();
1359 bool isOpened = false;
1361 for (i = 0; i < ct; i++) {
1362 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1363 KdenliveDoc *doc = tab->document();
1364 if (doc->url() == url) {
1370 m_timelineArea->setCurrentIndex(i);
1374 // Check for backup file
1375 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1376 if (!staleFiles.isEmpty()) {
1377 if (KMessageBox::questionYesNo(this,
1378 i18n("Auto-saved files exist. Do you want to recover them now?"),
1379 i18n("File Recovery"),
1380 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1381 recoverFiles(staleFiles);
1384 // remove the stale files
1385 foreach(KAutoSaveFile *stale, staleFiles) {
1386 stale->open(QIODevice::ReadWrite);
1391 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1392 doOpenFile(url, NULL);
1395 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1397 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1398 if (stale == NULL) {
1399 stale = new KAutoSaveFile(url, doc);
1400 doc->m_autosave = stale;
1402 doc->m_autosave = stale;
1403 doc->setUrl(stale->managedFile());
1404 doc->setModified(true);
1405 stale->setParent(doc);
1407 connectDocumentInfo(doc);
1408 TrackView *trackView = new TrackView(doc, this);
1409 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1410 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1411 trackView->setDuration(trackView->duration());
1412 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1414 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1415 slotGotProgressInfo(QString(), -1);
1416 m_clipMonitor->refreshMonitor(true);
1417 m_projectMonitor->adjustRulerSize(trackView->duration());
1418 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1421 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1423 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1424 foreach(KAutoSaveFile *stale, staleFiles) {
1425 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1426 // show an error message; we could not steal the lockfile
1427 // maybe another application got to the file before us?
1431 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1432 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1433 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1434 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1439 void MainWindow::parseProfiles(const QString &mltPath)
1441 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1443 //KdenliveSettings::setDefaulttmpfolder();
1444 if (!mltPath.isEmpty()) {
1445 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1446 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1449 if (KdenliveSettings::mltpath().isEmpty()) {
1450 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1452 if (KdenliveSettings::rendererpath().isEmpty()) {
1453 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1454 if (!QFile::exists(inigoPath))
1455 inigoPath = KStandardDirs::findExe("inigo");
1456 else KdenliveSettings::setRendererpath(inigoPath);
1458 QStringList profilesFilter;
1459 profilesFilter << "*";
1460 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1462 if (profilesList.isEmpty()) {
1463 // Cannot find MLT path, try finding inigo
1464 QString profilePath = KdenliveSettings::rendererpath();
1465 if (!profilePath.isEmpty()) {
1466 profilePath = profilePath.section('/', 0, -3);
1467 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1468 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1471 if (profilesList.isEmpty()) {
1472 // Cannot find the MLT profiles, ask for location
1473 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1474 getUrl->fileDialog()->setMode(KFile::Directory);
1475 if (getUrl->exec() == QDialog::Rejected) {
1478 KUrl mltPath = getUrl->selectedUrl();
1480 if (mltPath.isEmpty()) ::exit(0);
1481 KdenliveSettings::setMltpath(mltPath.path());
1482 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1486 if (KdenliveSettings::rendererpath().isEmpty()) {
1487 // Cannot find the MLT inigo renderer, ask for location
1488 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1489 if (getUrl->exec() == QDialog::Rejected) {
1492 KUrl rendererPath = getUrl->selectedUrl();
1494 if (rendererPath.isEmpty()) ::exit(0);
1495 KdenliveSettings::setRendererpath(rendererPath.path());
1498 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1500 // Parse MLT profiles to build a list of available video formats
1501 if (profilesList.isEmpty()) parseProfiles();
1505 void MainWindow::slotEditProfiles()
1507 ProfilesDialog *w = new ProfilesDialog;
1508 if (w->exec() == QDialog::Accepted) {
1509 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1510 if (d) d->checkProfile();
1515 void MainWindow::slotEditProjectSettings()
1517 QPoint p = m_activeDocument->getTracksCount();
1518 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1520 if (w->exec() == QDialog::Accepted) {
1521 QString profile = w->selectedProfile();
1522 m_activeDocument->setProjectFolder(w->selectedFolder());
1523 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1524 if (m_activeDocument->profilePath() != profile) {
1525 // Profile was changed
1526 m_activeDocument->setProfilePath(profile);
1527 KdenliveSettings::setCurrent_profile(profile);
1528 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1529 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1530 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1531 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1532 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1533 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1535 // We need to desactivate & reactivate monitors to get a refresh
1536 m_monitorManager->switchMonitors();
1542 void MainWindow::slotRenderProject()
1544 if (!m_renderWidget) {
1545 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1546 m_renderWidget = new RenderWidget(projectfolder, this);
1547 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 &)));
1548 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1549 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1550 if (m_activeDocument) {
1551 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1552 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1555 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1556 if (currentTab) m_renderWidget->setTimeline(currentTab);
1557 m_renderWidget->setDocument(m_activeDocument);*/
1558 m_renderWidget->show();
1561 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)
1563 kDebug() << "// SCRIPT EXPORT: " << scriptExport;
1564 if (dest.isEmpty()) return;
1567 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1568 if (currentTab && zoneOnly) {
1569 in = currentTab->inPoint();
1570 out = currentTab->outPoint();
1572 KTemporaryFile temp;
1573 temp.setAutoRemove(false);
1574 temp.setSuffix(".westley");
1575 if (!scriptExport.isEmpty() || temp.open()) {
1576 if (KdenliveSettings::dropbframes()) {
1577 KdenliveSettings::setDropbframes(false);
1578 m_activeDocument->clipManager()->updatePreviewSettings();
1579 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1580 else m_projectMonitor->saveSceneList(temp.fileName());
1581 KdenliveSettings::setDropbframes(true);
1582 m_activeDocument->clipManager()->updatePreviewSettings();
1584 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1585 else m_projectMonitor->saveSceneList(temp.fileName());
1589 if (scriptExport.isEmpty()) args << "-erase";
1590 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1591 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1592 else if (guideStart != -1) {
1593 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1595 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1596 QString videoPlayer = "-";
1598 videoPlayer = KdenliveSettings::defaultplayerapp();
1599 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."));
1601 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1602 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1603 setRenderingProgress(dest, -3);
1606 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1608 for (int i = 0; i < avformat_args.count(); i++) {
1609 if (avformat_args.at(i).startsWith("profile=")) {
1610 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1615 if (resizeProfile) {
1616 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1617 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1618 else args << "consumer:$SOURCE";
1620 if (scriptExport.isEmpty()) args << temp.fileName();
1621 else args << "$SOURCE";
1623 if (scriptExport.isEmpty()) args << dest;
1624 else args << "$TARGET";
1625 args << avformat_args;
1626 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1627 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1628 if (scriptExport.isEmpty()) {
1629 QProcess::startDetached(renderer, args);
1630 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1632 // Generate script file
1633 QFile file(scriptExport);
1634 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1635 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1639 QTextStream out(&file);
1640 out << "#! /bin/sh" << "\n" << "\n";
1641 out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
1642 out << "TARGET=" << "\"" + dest + "\"" << "\n";
1643 out << renderer << " " << args.join(" ") << "\n" << "\n";
1644 if (file.error() != QFile::NoError) {
1645 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1650 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1655 void MainWindow::setRenderingProgress(const QString &url, int progress)
1657 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1660 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1662 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1665 void MainWindow::slotUpdateMousePosition(int pos)
1667 if (m_activeDocument)
1668 switch (m_timecodeFormat->currentIndex()) {
1670 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1673 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1677 void MainWindow::slotUpdateDocumentState(bool modified)
1679 if (!m_activeDocument) return;
1680 setCaption(m_activeDocument->description(), modified);
1681 m_saveAction->setEnabled(modified);
1683 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1684 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1686 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1687 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1691 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1693 if (m_activeDocument) {
1694 if (m_activeDocument == doc) return;
1695 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1697 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1700 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1702 //m_projectMonitor->stop();
1703 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1704 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1705 if (m_activeDocument) {
1706 if (m_activeDocument == doc) return;
1707 if (m_activeTimeline) {
1708 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1709 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1710 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1711 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
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)), 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)), 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(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1734 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1735 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1736 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1737 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1738 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1739 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1740 disconnect(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 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 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1755 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(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1770 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1771 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1772 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1773 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1775 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1776 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1777 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1780 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1781 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1782 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1783 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1784 m_zoomSlider->setValue(doc->zoom());
1785 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1786 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1787 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1788 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1790 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1793 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1794 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1795 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1796 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1797 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1798 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1799 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1800 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1802 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1803 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1804 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1806 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1807 m_activeTimeline = trackView;
1808 if (m_renderWidget) {
1809 m_renderWidget->setProfile(doc->mltProfile());
1810 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1812 //doc->setRenderer(m_projectMonitor->render);
1813 m_commandStack->setActiveStack(doc->commandStack());
1814 KdenliveSettings::setProject_display_ratio(doc->dar());
1815 m_projectList->updateAllClips();
1816 //doc->clipManager()->checkAudioThumbs();
1818 //m_overView->setScene(trackView->projectScene());
1819 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1820 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1822 setCaption(doc->description(), doc->isModified());
1823 m_saveAction->setEnabled(doc->isModified());
1824 m_activeDocument = doc;
1825 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1827 // set tool to select tool
1828 m_buttonSelectTool->setChecked(true);
1831 void MainWindow::slotZoneMoved(int start, int end)
1833 m_activeDocument->setZone(start, end);
1834 m_projectMonitor->slotZoneMoved(start, end);
1837 void MainWindow::slotGuidesUpdated()
1839 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1842 void MainWindow::slotPreferences(int page, int option)
1844 //An instance of your dialog could be already created and could be
1845 // cached, in which case you want to display the cached dialog
1846 // instead of creating another one
1847 if (KConfigDialog::showDialog("settings")) {
1848 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1849 if (page != -1) d->showPage(page, option);
1853 // KConfigDialog didn't find an instance of this dialog, so lets
1855 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1856 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1857 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1858 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1859 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1860 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1862 if (page != -1) dialog->showPage(page, option);
1865 void MainWindow::slotUpdatePreviewSettings()
1867 if (m_activeDocument) {
1868 m_clipMonitor->slotSetXml(NULL, 0);
1869 m_activeDocument->updatePreviewSettings();
1873 void MainWindow::updateConfiguration()
1875 //TODO: we should apply settings to all projects, not only the current one
1876 if (m_activeTimeline) {
1877 m_activeTimeline->refresh();
1878 m_activeTimeline->projectView()->checkAutoScroll();
1879 m_activeTimeline->projectView()->checkTrackHeight();
1880 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1882 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1883 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1884 #ifndef NO_JOGSHUTTLE
1885 activateShuttleDevice();
1886 #endif /* NO_JOGSHUTTLE */
1891 void MainWindow::slotSwitchVideoThumbs()
1893 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1894 if (m_activeTimeline) {
1895 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1897 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1900 void MainWindow::slotSwitchAudioThumbs()
1902 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1903 if (m_activeTimeline) {
1904 m_activeTimeline->refresh();
1905 m_activeTimeline->projectView()->checkAutoScroll();
1906 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1908 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1911 void MainWindow::slotSwitchMarkersComments()
1913 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1914 if (m_activeTimeline) {
1915 m_activeTimeline->refresh();
1917 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1920 void MainWindow::slotSwitchSnap()
1922 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1923 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1927 void MainWindow::slotDeleteTimelineClip()
1929 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1930 else if (m_activeTimeline) {
1931 m_activeTimeline->projectView()->deleteSelectedClips();
1935 void MainWindow::slotChangeClipSpeed()
1937 if (m_activeTimeline) {
1938 m_activeTimeline->projectView()->changeClipSpeed();
1942 void MainWindow::slotAddClipMarker()
1944 DocClipBase *clip = NULL;
1946 if (m_projectMonitor->isActive()) {
1947 if (m_activeTimeline) {
1948 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1950 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1951 clip = item->baseClip();
1955 clip = m_clipMonitor->activeClip();
1956 pos = m_clipMonitor->position();
1959 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1962 QString id = clip->getId();
1963 CommentedTime marker(pos, i18n("Marker"));
1964 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1965 if (d.exec() == QDialog::Accepted) {
1966 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1968 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1971 void MainWindow::slotDeleteClipMarker()
1973 DocClipBase *clip = NULL;
1975 if (m_projectMonitor->isActive()) {
1976 if (m_activeTimeline) {
1977 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1979 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1980 clip = item->baseClip();
1984 clip = m_clipMonitor->activeClip();
1985 pos = m_clipMonitor->position();
1988 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1992 QString id = clip->getId();
1993 QString comment = clip->markerComment(pos);
1994 if (comment.isEmpty()) {
1995 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1998 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1999 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2003 void MainWindow::slotDeleteAllClipMarkers()
2005 DocClipBase *clip = NULL;
2006 if (m_projectMonitor->isActive()) {
2007 if (m_activeTimeline) {
2008 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2010 clip = item->baseClip();
2014 clip = m_clipMonitor->activeClip();
2017 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2020 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2021 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2024 void MainWindow::slotEditClipMarker()
2026 DocClipBase *clip = NULL;
2028 if (m_projectMonitor->isActive()) {
2029 if (m_activeTimeline) {
2030 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2032 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2033 clip = item->baseClip();
2037 clip = m_clipMonitor->activeClip();
2038 pos = m_clipMonitor->position();
2041 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2045 QString id = clip->getId();
2046 QString oldcomment = clip->markerComment(pos);
2047 if (oldcomment.isEmpty()) {
2048 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2052 CommentedTime marker(pos, oldcomment);
2053 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2054 if (d.exec() == QDialog::Accepted) {
2055 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2056 if (d.newMarker().time() != pos) {
2057 // remove old marker
2058 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2060 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2064 void MainWindow::slotAddGuide()
2066 if (m_activeTimeline)
2067 m_activeTimeline->projectView()->slotAddGuide();
2070 void MainWindow::slotInsertSpace()
2072 if (m_activeTimeline)
2073 m_activeTimeline->projectView()->slotInsertSpace();
2076 void MainWindow::slotRemoveSpace()
2078 if (m_activeTimeline)
2079 m_activeTimeline->projectView()->slotRemoveSpace();
2082 void MainWindow::slotInsertTrack(int ix)
2084 m_projectMonitor->activateMonitor();
2085 if (m_activeTimeline)
2086 m_activeTimeline->projectView()->slotInsertTrack(ix);
2089 void MainWindow::slotDeleteTrack(int ix)
2091 m_projectMonitor->activateMonitor();
2092 if (m_activeTimeline)
2093 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2096 void MainWindow::slotChangeTrack(int ix)
2098 m_projectMonitor->activateMonitor();
2099 if (m_activeTimeline)
2100 m_activeTimeline->projectView()->slotChangeTrack(ix);
2103 void MainWindow::slotEditGuide()
2105 if (m_activeTimeline)
2106 m_activeTimeline->projectView()->slotEditGuide();
2109 void MainWindow::slotDeleteGuide()
2111 if (m_activeTimeline)
2112 m_activeTimeline->projectView()->slotDeleteGuide();
2115 void MainWindow::slotDeleteAllGuides()
2117 if (m_activeTimeline)
2118 m_activeTimeline->projectView()->slotDeleteAllGuides();
2121 void MainWindow::slotCutTimelineClip()
2123 if (m_activeTimeline) {
2124 m_activeTimeline->projectView()->cutSelectedClips();
2128 void MainWindow::slotGroupClips()
2130 if (m_activeTimeline) {
2131 m_activeTimeline->projectView()->groupClips();
2135 void MainWindow::slotUnGroupClips()
2137 if (m_activeTimeline) {
2138 m_activeTimeline->projectView()->groupClips(false);
2142 void MainWindow::slotAddProjectClip(KUrl url)
2144 if (m_activeDocument)
2145 m_activeDocument->slotAddClipFile(url, QString());
2148 void MainWindow::slotAddTransition(QAction *result)
2150 if (!result) return;
2151 QStringList info = result->data().toStringList();
2152 if (info.isEmpty()) return;
2153 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2154 if (m_activeTimeline && !transition.isNull()) {
2155 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2159 void MainWindow::slotAddVideoEffect(QAction *result)
2161 if (!result) return;
2162 QStringList info = result->data().toStringList();
2163 if (info.isEmpty()) return;
2164 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2165 slotAddEffect(effect);
2168 void MainWindow::slotAddAudioEffect(QAction *result)
2170 if (!result) return;
2171 QStringList info = result->data().toStringList();
2172 if (info.isEmpty()) return;
2173 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2174 slotAddEffect(effect);
2177 void MainWindow::slotAddCustomEffect(QAction *result)
2179 if (!result) return;
2180 QStringList info = result->data().toStringList();
2181 if (info.isEmpty()) return;
2182 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2183 slotAddEffect(effect);
2186 void MainWindow::slotZoomIn()
2188 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2191 void MainWindow::slotZoomOut()
2193 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2196 void MainWindow::slotFitZoom()
2198 if (m_activeTimeline) {
2199 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2203 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2205 statusProgressBar->setValue(progress);
2206 if (progress >= 0) {
2207 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2208 statusProgressBar->setVisible(true);
2210 m_messageLabel->setMessage(QString(), DefaultMessage);
2211 statusProgressBar->setVisible(false);
2215 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2217 if (clip->clipType() == TEXT) {
2218 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2219 QString path = clip->getProperty("resource");
2220 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2222 doc.setContent(clip->getProperty("xmldata"));
2223 dia_ui->setXml(doc);
2224 if (dia_ui->exec() == QDialog::Accepted) {
2225 QImage pix = dia_ui->renderedPixmap();
2227 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2228 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2229 QMap <QString, QString> newprops;
2230 newprops.insert("xmldata", dia_ui->xml().toString());
2231 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2232 m_activeDocument->commandStack()->push(command);
2233 m_clipMonitor->refreshMonitor(true);
2234 m_activeDocument->setModified(true);
2238 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2241 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2242 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2243 if (dia.exec() == QDialog::Accepted) {
2244 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2245 m_activeDocument->commandStack()->push(command);
2247 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2248 if (dia.needsTimelineRefresh()) {
2249 // update clip occurences in timeline
2250 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2255 void MainWindow::customEvent(QEvent* e)
2257 if (e->type() == QEvent::User) {
2258 // The timeline playing position changed...
2259 kDebug() << "RECEIVED JOG EVEMNT!!!";
2262 void MainWindow::slotActivateEffectStackView()
2264 effectStack->raiseWindow(effectStackDock);
2267 void MainWindow::slotActivateTransitionView(Transition *t)
2269 if (t) transitionConfig->raiseWindow(transitionConfigDock);
2272 void MainWindow::slotSnapRewind()
2274 if (m_projectMonitor->isActive()) {
2275 if (m_activeTimeline)
2276 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2277 } else m_clipMonitor->slotSeekToPreviousSnap();
2280 void MainWindow::slotSnapForward()
2282 if (m_projectMonitor->isActive()) {
2283 if (m_activeTimeline)
2284 m_activeTimeline->projectView()->slotSeekToNextSnap();
2285 } else m_clipMonitor->slotSeekToNextSnap();
2288 void MainWindow::slotClipStart()
2290 if (m_projectMonitor->isActive()) {
2291 if (m_activeTimeline)
2292 m_activeTimeline->projectView()->clipStart();
2296 void MainWindow::slotClipEnd()
2298 if (m_projectMonitor->isActive()) {
2299 if (m_activeTimeline)
2300 m_activeTimeline->projectView()->clipEnd();
2304 void MainWindow::slotChangeTool(QAction * action)
2306 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2307 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2308 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2311 void MainWindow::slotSetTool(PROJECTTOOL tool)
2313 if (m_activeDocument && m_activeTimeline) {
2314 //m_activeDocument->setTool(tool);
2315 m_activeTimeline->projectView()->setTool(tool);
2319 void MainWindow::slotCopy()
2321 if (!m_activeDocument || !m_activeTimeline) return;
2322 m_activeTimeline->projectView()->copyClip();
2325 void MainWindow::slotPaste()
2327 if (!m_activeDocument || !m_activeTimeline) return;
2328 m_activeTimeline->projectView()->pasteClip();
2331 void MainWindow::slotPasteEffects()
2333 if (!m_activeDocument || !m_activeTimeline) return;
2334 m_activeTimeline->projectView()->pasteClipEffects();
2337 void MainWindow::slotFind()
2339 if (!m_activeDocument || !m_activeTimeline) return;
2340 m_projectSearch->setEnabled(false);
2341 m_findActivated = true;
2342 m_findString.clear();
2343 m_activeTimeline->projectView()->initSearchStrings();
2344 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2345 m_findTimer.start(5000);
2346 qApp->installEventFilter(this);
2349 void MainWindow::slotFindNext()
2351 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2352 statusBar()->showMessage(i18n("Found : %1", m_findString));
2354 statusBar()->showMessage(i18n("Reached end of project"));
2356 m_findTimer.start(4000);
2359 void MainWindow::findAhead()
2361 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2362 m_projectSearchNext->setEnabled(true);
2363 statusBar()->showMessage(i18n("Found : %1", m_findString));
2365 m_projectSearchNext->setEnabled(false);
2366 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2370 void MainWindow::findTimeout()
2372 m_projectSearchNext->setEnabled(false);
2373 m_findActivated = false;
2374 m_findString.clear();
2375 statusBar()->showMessage(i18n("Find stopped"), 3000);
2376 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2377 m_projectSearch->setEnabled(true);
2378 removeEventFilter(this);
2381 void MainWindow::keyPressEvent(QKeyEvent *ke)
2383 if (m_findActivated) {
2384 if (ke->key() == Qt::Key_Backspace) {
2385 m_findString = m_findString.left(m_findString.length() - 1);
2387 if (!m_findString.isEmpty()) {
2393 m_findTimer.start(4000);
2396 } else if (ke->key() == Qt::Key_Escape) {
2400 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2401 m_findString += ke->text();
2405 m_findTimer.start(4000);
2409 } else KXmlGuiWindow::keyPressEvent(ke);
2413 /** Gets called when the window gets hidden */
2414 void MainWindow::hideEvent(QHideEvent */*event*/)
2416 // kDebug() << "I was hidden";
2417 // issue http://www.kdenlive.org/mantis/view.php?id=231
2418 if (isMinimized()) {
2419 // kDebug() << "I am minimized";
2420 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2424 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2426 if (m_findActivated) {
2427 if (event->type() == QEvent::ShortcutOverride) {
2428 QKeyEvent* ke = (QKeyEvent*) event;
2429 if (ke->text().trimmed().isEmpty()) return false;
2432 } else return false;
2434 // pass the event on to the parent class
2435 return QMainWindow::eventFilter(obj, event);
2439 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2441 KDialog *dialog = new KDialog(this);
2442 dialog->setCaption("Save clip zone");
2443 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2445 QWidget *widget = new QWidget(dialog);
2446 dialog->setMainWidget(widget);
2448 QVBoxLayout *vbox = new QVBoxLayout(widget);
2449 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2450 QString path = m_activeDocument->projectFolder().path();
2452 path.append("untitled.westley");
2453 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2454 url->setFilter("video/mlt-playlist");
2455 QLabel *label2 = new QLabel(i18n("Description:"), this);
2456 KLineEdit *edit = new KLineEdit(this);
2457 vbox->addWidget(label1);
2458 vbox->addWidget(url);
2459 vbox->addWidget(label2);
2460 vbox->addWidget(edit);
2461 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2465 void MainWindow::slotSetInPoint()
2467 if (m_clipMonitor->isActive()) {
2468 m_clipMonitor->slotSetZoneStart();
2469 } else m_activeTimeline->projectView()->setInPoint();
2472 void MainWindow::slotSetOutPoint()
2474 if (m_clipMonitor->isActive()) {
2475 m_clipMonitor->slotSetZoneEnd();
2476 } else m_activeTimeline->projectView()->setOutPoint();
2479 void MainWindow::slotGetNewLumaStuff()
2481 //KNS::Entry::List download();
2482 KNS::Entry::List entries = KNS::Engine::download();
2483 // list of changed entries
2484 kDebug() << "// PARSING KNS";
2485 foreach(KNS::Entry* entry, entries) {
2486 // care only about installed ones
2487 if (entry->status() == KNS::Entry::Installed) {
2488 foreach(const QString &file, entry->installedFiles()) {
2489 kDebug() << "// CURRENTLY INSTALLED: " << file;
2493 qDeleteAll(entries);
2494 initEffects::refreshLumas();
2497 void MainWindow::slotGetNewRenderStuff()
2499 //KNS::Entry::List download();
2501 KNS::Engine engine(0);
2502 if (engine.init("kdenlive_render.knsrc")) {
2503 KNS::Entry::List entries = engine.downloadDialogModal(this);
2505 if (entries.size() > 0) {
2506 foreach(KNS::Entry* entry, entries) {
2507 // care only about installed ones
2508 if (entry->status() == KNS::Entry::Installed) {
2509 foreach(const QString &file, entry->installedFiles()) {
2510 kDebug() << "// CURRENTLY INSTALLED: " << file;
2515 if (m_renderWidget) m_renderWidget->reloadProfiles();
2519 void MainWindow::slotGetNewMltProfileStuff()
2521 //KNS::Entry::List download();
2523 KNS::Engine engine(0);
2524 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2525 KNS::Entry::List entries = engine.downloadDialogModal(this);
2527 if (entries.size() > 0) {
2528 foreach(KNS::Entry* entry, entries) {
2529 // care only about installed ones
2530 if (entry->status() == KNS::Entry::Installed) {
2531 foreach(const QString &file, entry->installedFiles()) {
2532 kDebug() << "// CURRENTLY INSTALLED: " << file;
2537 // update the list of profiles in settings dialog
2538 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2539 if (d) d->checkProfile();
2544 void MainWindow::slotAutoTransition()
2546 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2549 void MainWindow::slotSplitAudio()
2551 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2554 void MainWindow::slotUpdateClipType(QAction *action)
2556 if (m_activeTimeline) {
2557 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2558 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2559 else m_activeTimeline->projectView()->setAudioAndVideo();
2563 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2565 DvdWizard *w = new DvdWizard(url, profile, this);
2569 void MainWindow::slotShowTimeline(bool show)
2571 if (show == false) {
2572 m_timelineState = saveState();
2573 centralWidget()->setHidden(true);
2575 centralWidget()->setHidden(false);
2576 restoreState(m_timelineState);
2580 void MainWindow::slotMaximizeCurrent(bool show)
2582 //TODO: is there a way to maximize current widget?
2585 m_timelineState = saveState();
2586 QWidget *par = focusWidget()->parentWidget();
2587 while (par->parentWidget() && par->parentWidget() != this) {
2588 par = par->parentWidget();
2590 kDebug() << "CURRENT WIDGET: " << par->objectName();
2593 //centralWidget()->setHidden(false);
2594 //restoreState(m_timelineState);
2598 #include "mainwindow.moc"