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);
1075 //TODO: Add status tooltip to actions ?
1076 connect(collection, SIGNAL(actionHovered(QAction*)),
1077 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1080 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1081 collection->addAction("add_clip", addClip);
1082 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1084 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1085 collection->addAction("add_color_clip", addColorClip);
1086 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1088 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1089 collection->addAction("add_slide_clip", addSlideClip);
1090 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1092 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1093 collection->addAction("add_text_clip", addTitleClip);
1094 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1096 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1097 collection->addAction("add_folder", addFolderButton);
1098 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1100 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1101 collection->addAction("clip_properties", clipProperties);
1102 clipProperties->setData("clip_properties");
1103 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1104 clipProperties->setEnabled(false);
1106 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1107 collection->addAction("edit_clip", openClip);
1108 openClip->setData("edit_clip");
1109 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1110 openClip->setEnabled(false);
1112 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1113 collection->addAction("delete_clip", deleteClip);
1114 deleteClip->setData("delete_clip");
1115 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1116 deleteClip->setEnabled(false);
1118 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1119 collection->addAction("reload_clip", reloadClip);
1120 reloadClip->setData("reload_clip");
1121 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1122 reloadClip->setEnabled(false);
1124 QMenu *addClips = new QMenu();
1125 addClips->addAction(addClip);
1126 addClips->addAction(addColorClip);
1127 addClips->addAction(addSlideClip);
1128 addClips->addAction(addTitleClip);
1129 addClips->addAction(addFolderButton);
1131 addClips->addAction(reloadClip);
1132 addClips->addAction(clipProperties);
1133 addClips->addAction(openClip);
1134 addClips->addAction(deleteClip);
1135 m_projectList->setupMenu(addClips, addClip);
1137 //connect(collection, SIGNAL( clearStatusText() ),
1138 //statusBar(), SLOT( clear() ) );
1141 void MainWindow::slotDisplayActionMessage(QAction *a)
1143 statusBar()->showMessage(a->data().toString(), 3000);
1146 void MainWindow::saveOptions()
1148 KdenliveSettings::self()->writeConfig();
1149 KSharedConfigPtr config = KGlobal::config();
1150 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1151 KConfigGroup treecolumns(config, "Project Tree");
1152 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1156 void MainWindow::readOptions()
1158 KSharedConfigPtr config = KGlobal::config();
1159 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1160 KConfigGroup initialGroup(config, "version");
1161 bool upgrade = false;
1162 if (initialGroup.exists()) {
1163 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1166 if (initialGroup.readEntry("version") == "0.7") {
1167 //Add new settings from 0.7.1
1168 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1169 QString path = QDir::homePath() + "/kdenlive";
1170 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1171 KdenliveSettings::setDefaultprojectfolder(path);
1177 if (!initialGroup.exists() || upgrade) {
1178 // this is our first run, show Wizard
1179 Wizard *w = new Wizard(upgrade, this);
1180 if (w->exec() == QDialog::Accepted && w->isOk()) {
1181 w->adjustSettings();
1182 initialGroup.writeEntry("version", version);
1188 KConfigGroup treecolumns(config, "Project Tree");
1189 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1190 if (!state.isEmpty())
1191 m_projectList->setHeaderInfo(state);
1194 void MainWindow::slotRunWizard()
1196 Wizard *w = new Wizard(this);
1197 if (w->exec() == QDialog::Accepted && w->isOk()) {
1198 w->adjustSettings();
1203 void MainWindow::newFile(bool showProjectSettings)
1205 QString profileName;
1207 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1208 if (!showProjectSettings && m_timelineArea->count() == 0) {
1209 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1210 profileName = KdenliveSettings::default_profile();
1212 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1213 if (w->exec() != QDialog::Accepted) return;
1214 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1215 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1216 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1217 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1218 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1219 profileName = w->selectedProfile();
1220 projectFolder = w->selectedFolder();
1221 projectTracks = w->tracks();
1224 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1225 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1226 TrackView *trackView = new TrackView(doc, this);
1227 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1228 if (m_timelineArea->count() == 1) {
1229 connectDocumentInfo(doc);
1230 connectDocument(trackView, doc);
1231 } else m_timelineArea->setTabBarHidden(false);
1232 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1235 void MainWindow::activateDocument()
1237 if (m_timelineArea->currentWidget() == NULL) return;
1238 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1239 KdenliveDoc *currentDoc = currentTab->document();
1240 connectDocumentInfo(currentDoc);
1241 connectDocument(currentTab, currentDoc);
1244 void MainWindow::closeCurrentDocument()
1246 QWidget *w = m_timelineArea->currentWidget();
1248 // closing current document
1249 int ix = m_timelineArea->currentIndex() + 1;
1250 if (ix == m_timelineArea->count()) ix = 0;
1251 m_timelineArea->setCurrentIndex(ix);
1252 TrackView *tabToClose = (TrackView *) w;
1253 KdenliveDoc *docToClose = tabToClose->document();
1254 if (docToClose && docToClose->isModified()) {
1255 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1256 case KMessageBox::Yes :
1257 // save document here. If saving fails, return false;
1258 if (saveFile() == false) return;
1260 case KMessageBox::Cancel :
1266 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1267 if (m_timelineArea->count() == 1) {
1268 m_timelineArea->setTabBarHidden(true);
1269 m_closeAction->setEnabled(false);
1273 if (m_timelineArea->count() == 0) {
1274 m_activeDocument = NULL;
1275 effectStack->clear();
1276 transitionConfig->slotTransitionItemSelected(NULL, false);
1280 bool MainWindow::saveFileAs(const QString &outputFileName)
1282 QString currentSceneList;
1283 if (KdenliveSettings::dropbframes()) {
1284 KdenliveSettings::setDropbframes(false);
1285 m_activeDocument->clipManager()->updatePreviewSettings();
1286 currentSceneList = m_projectMonitor->sceneList();
1287 KdenliveSettings::setDropbframes(true);
1288 m_activeDocument->clipManager()->updatePreviewSettings();
1289 } else currentSceneList = m_projectMonitor->sceneList();
1291 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1294 // Save timeline thumbnails
1295 m_activeTimeline->projectView()->saveThumbnails();
1296 m_activeDocument->setUrl(KUrl(outputFileName));
1297 if (m_activeDocument->m_autosave == NULL) {
1298 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1299 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1300 setCaption(m_activeDocument->description());
1301 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1302 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1303 m_activeDocument->setModified(false);
1304 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1308 bool MainWindow::saveFileAs()
1310 // Check that the Kdenlive mime type is correctly installed
1311 QString mimetype = "application/x-kdenlive";
1312 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1313 if (!mime) mimetype = "*.kdenlive";
1315 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1316 if (outputFile.isEmpty()) return false;
1317 if (QFile::exists(outputFile)) {
1318 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1320 return saveFileAs(outputFile);
1323 bool MainWindow::saveFile()
1325 if (!m_activeDocument) return true;
1326 if (m_activeDocument->url().isEmpty()) {
1327 return saveFileAs();
1329 bool result = saveFileAs(m_activeDocument->url().path());
1330 m_activeDocument->m_autosave->resize(0);
1335 void MainWindow::openFile()
1337 // Check that the Kdenlive mime type is correctly installed
1338 QString mimetype = "application/x-kdenlive";
1339 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1340 if (!mime) mimetype = "*.kdenlive";
1342 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1343 if (url.isEmpty()) return;
1344 m_fileOpenRecent->addUrl(url);
1348 void MainWindow::openLastFile()
1350 KSharedConfigPtr config = KGlobal::config();
1351 KUrl::List urls = m_fileOpenRecent->urls();
1352 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1353 if (urls.isEmpty()) newFile(false);
1354 else openFile(urls.last());
1357 void MainWindow::openFile(const KUrl &url)
1359 // Check if the document is already opened
1360 const int ct = m_timelineArea->count();
1361 bool isOpened = false;
1363 for (i = 0; i < ct; i++) {
1364 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1365 KdenliveDoc *doc = tab->document();
1366 if (doc->url() == url) {
1372 m_timelineArea->setCurrentIndex(i);
1376 // Check for backup file
1377 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1378 if (!staleFiles.isEmpty()) {
1379 if (KMessageBox::questionYesNo(this,
1380 i18n("Auto-saved files exist. Do you want to recover them now?"),
1381 i18n("File Recovery"),
1382 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1383 recoverFiles(staleFiles);
1386 // remove the stale files
1387 foreach(KAutoSaveFile *stale, staleFiles) {
1388 stale->open(QIODevice::ReadWrite);
1393 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1394 doOpenFile(url, NULL);
1397 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1399 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1400 if (stale == NULL) {
1401 stale = new KAutoSaveFile(url, doc);
1402 doc->m_autosave = stale;
1404 doc->m_autosave = stale;
1405 doc->setUrl(stale->managedFile());
1406 doc->setModified(true);
1407 stale->setParent(doc);
1409 connectDocumentInfo(doc);
1410 TrackView *trackView = new TrackView(doc, this);
1411 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1412 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1413 trackView->setDuration(trackView->duration());
1414 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1416 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1417 slotGotProgressInfo(QString(), -1);
1418 m_clipMonitor->refreshMonitor(true);
1419 m_projectMonitor->adjustRulerSize(trackView->duration());
1420 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1423 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1425 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1426 foreach(KAutoSaveFile *stale, staleFiles) {
1427 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1428 // show an error message; we could not steal the lockfile
1429 // maybe another application got to the file before us?
1433 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1434 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1435 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1436 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1441 void MainWindow::parseProfiles(const QString &mltPath)
1443 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1445 //KdenliveSettings::setDefaulttmpfolder();
1446 if (!mltPath.isEmpty()) {
1447 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1448 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1451 if (KdenliveSettings::mltpath().isEmpty()) {
1452 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1454 if (KdenliveSettings::rendererpath().isEmpty()) {
1455 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1456 if (!QFile::exists(inigoPath))
1457 inigoPath = KStandardDirs::findExe("inigo");
1458 else KdenliveSettings::setRendererpath(inigoPath);
1460 QStringList profilesFilter;
1461 profilesFilter << "*";
1462 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1464 if (profilesList.isEmpty()) {
1465 // Cannot find MLT path, try finding inigo
1466 QString profilePath = KdenliveSettings::rendererpath();
1467 if (!profilePath.isEmpty()) {
1468 profilePath = profilePath.section('/', 0, -3);
1469 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1470 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1473 if (profilesList.isEmpty()) {
1474 // Cannot find the MLT profiles, ask for location
1475 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1476 getUrl->fileDialog()->setMode(KFile::Directory);
1477 if (getUrl->exec() == QDialog::Rejected) {
1480 KUrl mltPath = getUrl->selectedUrl();
1482 if (mltPath.isEmpty()) ::exit(0);
1483 KdenliveSettings::setMltpath(mltPath.path());
1484 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1488 if (KdenliveSettings::rendererpath().isEmpty()) {
1489 // Cannot find the MLT inigo renderer, ask for location
1490 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1491 if (getUrl->exec() == QDialog::Rejected) {
1494 KUrl rendererPath = getUrl->selectedUrl();
1496 if (rendererPath.isEmpty()) ::exit(0);
1497 KdenliveSettings::setRendererpath(rendererPath.path());
1500 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1502 // Parse MLT profiles to build a list of available video formats
1503 if (profilesList.isEmpty()) parseProfiles();
1507 void MainWindow::slotEditProfiles()
1509 ProfilesDialog *w = new ProfilesDialog;
1510 if (w->exec() == QDialog::Accepted) {
1511 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1512 if (d) d->checkProfile();
1517 void MainWindow::slotEditProjectSettings()
1519 QPoint p = m_activeDocument->getTracksCount();
1520 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1522 if (w->exec() == QDialog::Accepted) {
1523 QString profile = w->selectedProfile();
1524 m_activeDocument->setProjectFolder(w->selectedFolder());
1525 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1526 if (m_activeDocument->profilePath() != profile) {
1527 // Profile was changed
1528 m_activeDocument->setProfilePath(profile);
1529 KdenliveSettings::setCurrent_profile(profile);
1530 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1531 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1532 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1533 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1534 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1535 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1537 // We need to desactivate & reactivate monitors to get a refresh
1538 m_monitorManager->switchMonitors();
1544 void MainWindow::slotRenderProject()
1546 if (!m_renderWidget) {
1547 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1548 m_renderWidget = new RenderWidget(projectfolder, this);
1549 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 &)));
1550 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1551 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1552 if (m_activeDocument) {
1553 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1554 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1557 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1558 if (currentTab) m_renderWidget->setTimeline(currentTab);
1559 m_renderWidget->setDocument(m_activeDocument);*/
1560 m_renderWidget->show();
1563 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)
1565 kDebug() << "// SCRIPT EXPORT: " << scriptExport;
1566 if (dest.isEmpty()) return;
1569 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1570 if (currentTab && zoneOnly) {
1571 in = currentTab->inPoint();
1572 out = currentTab->outPoint();
1574 KTemporaryFile temp;
1575 temp.setAutoRemove(false);
1576 temp.setSuffix(".westley");
1577 if (!scriptExport.isEmpty() || temp.open()) {
1578 if (KdenliveSettings::dropbframes()) {
1579 KdenliveSettings::setDropbframes(false);
1580 m_activeDocument->clipManager()->updatePreviewSettings();
1581 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1582 else m_projectMonitor->saveSceneList(temp.fileName());
1583 KdenliveSettings::setDropbframes(true);
1584 m_activeDocument->clipManager()->updatePreviewSettings();
1586 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1587 else m_projectMonitor->saveSceneList(temp.fileName());
1591 if (scriptExport.isEmpty()) args << "-erase";
1592 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1593 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1594 else if (guideStart != -1) {
1595 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1597 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1598 QString videoPlayer = "-";
1600 videoPlayer = KdenliveSettings::defaultplayerapp();
1601 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."));
1603 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1604 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1605 setRenderingProgress(dest, -3);
1608 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1610 for (int i = 0; i < avformat_args.count(); i++) {
1611 if (avformat_args.at(i).startsWith("profile=")) {
1612 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1617 if (resizeProfile) {
1618 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1619 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1620 else args << "consumer:$SOURCE";
1622 if (scriptExport.isEmpty()) args << temp.fileName();
1623 else args << "$SOURCE";
1625 if (scriptExport.isEmpty()) args << dest;
1626 else args << "$TARGET";
1627 args << avformat_args;
1628 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1629 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1630 if (scriptExport.isEmpty()) {
1631 QProcess::startDetached(renderer, args);
1632 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1634 // Generate script file
1635 QFile file(scriptExport);
1636 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1637 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1641 QTextStream out(&file);
1642 out << "#! /bin/sh" << "\n" << "\n";
1643 out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
1644 out << "TARGET=" << "\"" + dest + "\"" << "\n";
1645 out << renderer << " " << args.join(" ") << "\n" << "\n";
1646 if (file.error() != QFile::NoError) {
1647 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1652 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1657 void MainWindow::setRenderingProgress(const QString &url, int progress)
1659 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1662 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1664 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1667 void MainWindow::slotUpdateMousePosition(int pos)
1669 if (m_activeDocument)
1670 switch (m_timecodeFormat->currentIndex()) {
1672 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1675 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1679 void MainWindow::slotUpdateDocumentState(bool modified)
1681 if (!m_activeDocument) return;
1682 setCaption(m_activeDocument->description(), modified);
1683 m_saveAction->setEnabled(modified);
1685 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1686 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1688 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1689 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1693 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1695 if (m_activeDocument) {
1696 if (m_activeDocument == doc) return;
1697 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1699 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1702 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1704 //m_projectMonitor->stop();
1705 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1706 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1707 if (m_activeDocument) {
1708 if (m_activeDocument == doc) return;
1709 if (m_activeTimeline) {
1710 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1711 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1712 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1713 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1714 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1717 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1718 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1719 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1720 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1721 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1722 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1723 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1724 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1725 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1726 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1727 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1728 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1729 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1730 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1731 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1732 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1733 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1734 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1735 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1736 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1737 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1738 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1739 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1740 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1741 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1742 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1743 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1744 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1745 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1746 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1747 effectStack->clear();
1749 //m_activeDocument->setRenderer(NULL);
1750 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1751 m_clipMonitor->stop();
1753 KdenliveSettings::setCurrent_profile(doc->profilePath());
1754 KdenliveSettings::setProject_fps(doc->fps());
1755 m_monitorManager->resetProfiles(doc->timecode());
1756 m_projectList->setDocument(doc);
1757 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1758 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1759 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1760 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1761 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1764 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1765 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1766 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1767 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1768 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1769 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1770 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1771 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1772 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1773 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1774 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1775 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1776 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1777 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1779 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1780 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1781 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1784 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1785 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1786 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1787 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1788 m_zoomSlider->setValue(doc->zoom());
1789 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1790 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1791 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1792 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1794 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1797 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1798 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1799 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1800 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1801 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1802 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1803 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1804 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1806 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1807 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1808 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1810 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1811 m_activeTimeline = trackView;
1812 if (m_renderWidget) {
1813 m_renderWidget->setProfile(doc->mltProfile());
1814 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1816 //doc->setRenderer(m_projectMonitor->render);
1817 m_commandStack->setActiveStack(doc->commandStack());
1818 KdenliveSettings::setProject_display_ratio(doc->dar());
1819 m_projectList->updateAllClips();
1820 //doc->clipManager()->checkAudioThumbs();
1822 //m_overView->setScene(trackView->projectScene());
1823 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1824 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1826 setCaption(doc->description(), doc->isModified());
1827 m_saveAction->setEnabled(doc->isModified());
1828 m_activeDocument = doc;
1829 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1831 // set tool to select tool
1832 m_buttonSelectTool->setChecked(true);
1835 void MainWindow::slotZoneMoved(int start, int end)
1837 m_activeDocument->setZone(start, end);
1838 m_projectMonitor->slotZoneMoved(start, end);
1841 void MainWindow::slotGuidesUpdated()
1843 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1846 void MainWindow::slotPreferences(int page, int option)
1848 //An instance of your dialog could be already created and could be
1849 // cached, in which case you want to display the cached dialog
1850 // instead of creating another one
1851 if (KConfigDialog::showDialog("settings")) {
1852 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1853 if (page != -1) d->showPage(page, option);
1857 // KConfigDialog didn't find an instance of this dialog, so lets
1859 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1860 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1861 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1862 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1863 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1864 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1866 if (page != -1) dialog->showPage(page, option);
1869 void MainWindow::slotUpdatePreviewSettings()
1871 if (m_activeDocument) {
1872 m_clipMonitor->slotSetXml(NULL, 0);
1873 m_activeDocument->updatePreviewSettings();
1877 void MainWindow::updateConfiguration()
1879 //TODO: we should apply settings to all projects, not only the current one
1880 if (m_activeTimeline) {
1881 m_activeTimeline->refresh();
1882 m_activeTimeline->projectView()->checkAutoScroll();
1883 m_activeTimeline->projectView()->checkTrackHeight();
1884 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1886 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1887 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1888 #ifndef NO_JOGSHUTTLE
1889 activateShuttleDevice();
1890 #endif /* NO_JOGSHUTTLE */
1895 void MainWindow::slotSwitchVideoThumbs()
1897 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1898 if (m_activeTimeline) {
1899 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1901 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1904 void MainWindow::slotSwitchAudioThumbs()
1906 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1907 if (m_activeTimeline) {
1908 m_activeTimeline->refresh();
1909 m_activeTimeline->projectView()->checkAutoScroll();
1910 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1912 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1915 void MainWindow::slotSwitchMarkersComments()
1917 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1918 if (m_activeTimeline) {
1919 m_activeTimeline->refresh();
1921 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1924 void MainWindow::slotSwitchSnap()
1926 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1927 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1931 void MainWindow::slotDeleteTimelineClip()
1933 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1934 else if (m_activeTimeline) {
1935 m_activeTimeline->projectView()->deleteSelectedClips();
1939 void MainWindow::slotChangeClipSpeed()
1941 if (m_activeTimeline) {
1942 m_activeTimeline->projectView()->changeClipSpeed();
1946 void MainWindow::slotAddClipMarker()
1948 DocClipBase *clip = NULL;
1950 if (m_projectMonitor->isActive()) {
1951 if (m_activeTimeline) {
1952 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1954 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1955 clip = item->baseClip();
1959 clip = m_clipMonitor->activeClip();
1960 pos = m_clipMonitor->position();
1963 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1966 QString id = clip->getId();
1967 CommentedTime marker(pos, i18n("Marker"));
1968 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1969 if (d.exec() == QDialog::Accepted) {
1970 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1972 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1975 void MainWindow::slotDeleteClipMarker()
1977 DocClipBase *clip = NULL;
1979 if (m_projectMonitor->isActive()) {
1980 if (m_activeTimeline) {
1981 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1983 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1984 clip = item->baseClip();
1988 clip = m_clipMonitor->activeClip();
1989 pos = m_clipMonitor->position();
1992 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1996 QString id = clip->getId();
1997 QString comment = clip->markerComment(pos);
1998 if (comment.isEmpty()) {
1999 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2002 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2003 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2007 void MainWindow::slotDeleteAllClipMarkers()
2009 DocClipBase *clip = NULL;
2010 if (m_projectMonitor->isActive()) {
2011 if (m_activeTimeline) {
2012 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2014 clip = item->baseClip();
2018 clip = m_clipMonitor->activeClip();
2021 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2024 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2025 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2028 void MainWindow::slotEditClipMarker()
2030 DocClipBase *clip = NULL;
2032 if (m_projectMonitor->isActive()) {
2033 if (m_activeTimeline) {
2034 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2036 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2037 clip = item->baseClip();
2041 clip = m_clipMonitor->activeClip();
2042 pos = m_clipMonitor->position();
2045 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2049 QString id = clip->getId();
2050 QString oldcomment = clip->markerComment(pos);
2051 if (oldcomment.isEmpty()) {
2052 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2056 CommentedTime marker(pos, oldcomment);
2057 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2058 if (d.exec() == QDialog::Accepted) {
2059 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2060 if (d.newMarker().time() != pos) {
2061 // remove old marker
2062 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2064 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2068 void MainWindow::slotAddGuide()
2070 if (m_activeTimeline)
2071 m_activeTimeline->projectView()->slotAddGuide();
2074 void MainWindow::slotInsertSpace()
2076 if (m_activeTimeline)
2077 m_activeTimeline->projectView()->slotInsertSpace();
2080 void MainWindow::slotRemoveSpace()
2082 if (m_activeTimeline)
2083 m_activeTimeline->projectView()->slotRemoveSpace();
2086 void MainWindow::slotInsertTrack(int ix)
2088 m_projectMonitor->activateMonitor();
2089 if (m_activeTimeline)
2090 m_activeTimeline->projectView()->slotInsertTrack(ix);
2093 void MainWindow::slotDeleteTrack(int ix)
2095 m_projectMonitor->activateMonitor();
2096 if (m_activeTimeline)
2097 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2100 void MainWindow::slotChangeTrack(int ix)
2102 m_projectMonitor->activateMonitor();
2103 if (m_activeTimeline)
2104 m_activeTimeline->projectView()->slotChangeTrack(ix);
2107 void MainWindow::slotEditGuide()
2109 if (m_activeTimeline)
2110 m_activeTimeline->projectView()->slotEditGuide();
2113 void MainWindow::slotDeleteGuide()
2115 if (m_activeTimeline)
2116 m_activeTimeline->projectView()->slotDeleteGuide();
2119 void MainWindow::slotDeleteAllGuides()
2121 if (m_activeTimeline)
2122 m_activeTimeline->projectView()->slotDeleteAllGuides();
2125 void MainWindow::slotCutTimelineClip()
2127 if (m_activeTimeline) {
2128 m_activeTimeline->projectView()->cutSelectedClips();
2132 void MainWindow::slotGroupClips()
2134 if (m_activeTimeline) {
2135 m_activeTimeline->projectView()->groupClips();
2139 void MainWindow::slotUnGroupClips()
2141 if (m_activeTimeline) {
2142 m_activeTimeline->projectView()->groupClips(false);
2146 void MainWindow::slotAddProjectClip(KUrl url)
2148 if (m_activeDocument)
2149 m_activeDocument->slotAddClipFile(url, QString());
2152 void MainWindow::slotAddTransition(QAction *result)
2154 if (!result) return;
2155 QStringList info = result->data().toStringList();
2156 if (info.isEmpty()) return;
2157 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2158 if (m_activeTimeline && !transition.isNull()) {
2159 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2163 void MainWindow::slotAddVideoEffect(QAction *result)
2165 if (!result) return;
2166 QStringList info = result->data().toStringList();
2167 if (info.isEmpty()) return;
2168 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2169 slotAddEffect(effect);
2172 void MainWindow::slotAddAudioEffect(QAction *result)
2174 if (!result) return;
2175 QStringList info = result->data().toStringList();
2176 if (info.isEmpty()) return;
2177 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2178 slotAddEffect(effect);
2181 void MainWindow::slotAddCustomEffect(QAction *result)
2183 if (!result) return;
2184 QStringList info = result->data().toStringList();
2185 if (info.isEmpty()) return;
2186 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2187 slotAddEffect(effect);
2190 void MainWindow::slotZoomIn()
2192 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2195 void MainWindow::slotZoomOut()
2197 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2200 void MainWindow::slotFitZoom()
2202 if (m_activeTimeline) {
2203 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2207 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2209 statusProgressBar->setValue(progress);
2210 if (progress >= 0) {
2211 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2212 statusProgressBar->setVisible(true);
2214 m_messageLabel->setMessage(QString(), DefaultMessage);
2215 statusProgressBar->setVisible(false);
2219 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2221 if (clip->clipType() == TEXT) {
2222 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2223 QString path = clip->getProperty("resource");
2224 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2226 doc.setContent(clip->getProperty("xmldata"));
2227 dia_ui->setXml(doc);
2228 if (dia_ui->exec() == QDialog::Accepted) {
2229 QImage pix = dia_ui->renderedPixmap();
2231 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2232 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2233 QMap <QString, QString> newprops;
2234 newprops.insert("xmldata", dia_ui->xml().toString());
2235 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2236 m_activeDocument->commandStack()->push(command);
2237 m_clipMonitor->refreshMonitor(true);
2238 m_activeDocument->setModified(true);
2242 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2245 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2246 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2247 if (dia.exec() == QDialog::Accepted) {
2248 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2249 m_activeDocument->commandStack()->push(command);
2251 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2252 if (dia.needsTimelineRefresh()) {
2253 // update clip occurences in timeline
2254 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2259 void MainWindow::customEvent(QEvent* e)
2261 if (e->type() == QEvent::User) {
2262 // The timeline playing position changed...
2263 kDebug() << "RECEIVED JOG EVEMNT!!!";
2266 void MainWindow::slotActivateEffectStackView()
2268 effectStack->raiseWindow(effectStackDock);
2271 void MainWindow::slotActivateTransitionView(Transition *t)
2273 if (t) transitionConfig->raiseWindow(transitionConfigDock);
2276 void MainWindow::slotSnapRewind()
2278 if (m_projectMonitor->isActive()) {
2279 if (m_activeTimeline)
2280 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2281 } else m_clipMonitor->slotSeekToPreviousSnap();
2284 void MainWindow::slotSnapForward()
2286 if (m_projectMonitor->isActive()) {
2287 if (m_activeTimeline)
2288 m_activeTimeline->projectView()->slotSeekToNextSnap();
2289 } else m_clipMonitor->slotSeekToNextSnap();
2292 void MainWindow::slotClipStart()
2294 if (m_projectMonitor->isActive()) {
2295 if (m_activeTimeline)
2296 m_activeTimeline->projectView()->clipStart();
2300 void MainWindow::slotClipEnd()
2302 if (m_projectMonitor->isActive()) {
2303 if (m_activeTimeline)
2304 m_activeTimeline->projectView()->clipEnd();
2308 void MainWindow::slotChangeTool(QAction * action)
2310 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2311 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2312 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2315 void MainWindow::slotSetTool(PROJECTTOOL tool)
2317 if (m_activeDocument && m_activeTimeline) {
2318 //m_activeDocument->setTool(tool);
2319 m_activeTimeline->projectView()->setTool(tool);
2323 void MainWindow::slotCopy()
2325 if (!m_activeDocument || !m_activeTimeline) return;
2326 m_activeTimeline->projectView()->copyClip();
2329 void MainWindow::slotPaste()
2331 if (!m_activeDocument || !m_activeTimeline) return;
2332 m_activeTimeline->projectView()->pasteClip();
2335 void MainWindow::slotPasteEffects()
2337 if (!m_activeDocument || !m_activeTimeline) return;
2338 m_activeTimeline->projectView()->pasteClipEffects();
2341 void MainWindow::slotFind()
2343 if (!m_activeDocument || !m_activeTimeline) return;
2344 m_projectSearch->setEnabled(false);
2345 m_findActivated = true;
2346 m_findString.clear();
2347 m_activeTimeline->projectView()->initSearchStrings();
2348 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2349 m_findTimer.start(5000);
2350 qApp->installEventFilter(this);
2353 void MainWindow::slotFindNext()
2355 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2356 statusBar()->showMessage(i18n("Found : %1", m_findString));
2358 statusBar()->showMessage(i18n("Reached end of project"));
2360 m_findTimer.start(4000);
2363 void MainWindow::findAhead()
2365 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2366 m_projectSearchNext->setEnabled(true);
2367 statusBar()->showMessage(i18n("Found : %1", m_findString));
2369 m_projectSearchNext->setEnabled(false);
2370 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2374 void MainWindow::findTimeout()
2376 m_projectSearchNext->setEnabled(false);
2377 m_findActivated = false;
2378 m_findString.clear();
2379 statusBar()->showMessage(i18n("Find stopped"), 3000);
2380 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2381 m_projectSearch->setEnabled(true);
2382 removeEventFilter(this);
2385 void MainWindow::keyPressEvent(QKeyEvent *ke)
2387 if (m_findActivated) {
2388 if (ke->key() == Qt::Key_Backspace) {
2389 m_findString = m_findString.left(m_findString.length() - 1);
2391 if (!m_findString.isEmpty()) {
2397 m_findTimer.start(4000);
2400 } else if (ke->key() == Qt::Key_Escape) {
2404 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2405 m_findString += ke->text();
2409 m_findTimer.start(4000);
2413 } else KXmlGuiWindow::keyPressEvent(ke);
2417 /** Gets called when the window gets hidden */
2418 void MainWindow::hideEvent(QHideEvent */*event*/)
2420 // kDebug() << "I was hidden";
2421 // issue http://www.kdenlive.org/mantis/view.php?id=231
2422 if (isMinimized()) {
2423 // kDebug() << "I am minimized";
2424 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2428 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2430 if (m_findActivated) {
2431 if (event->type() == QEvent::ShortcutOverride) {
2432 QKeyEvent* ke = (QKeyEvent*) event;
2433 if (ke->text().trimmed().isEmpty()) return false;
2436 } else return false;
2438 // pass the event on to the parent class
2439 return QMainWindow::eventFilter(obj, event);
2443 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2445 KDialog *dialog = new KDialog(this);
2446 dialog->setCaption("Save clip zone");
2447 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2449 QWidget *widget = new QWidget(dialog);
2450 dialog->setMainWidget(widget);
2452 QVBoxLayout *vbox = new QVBoxLayout(widget);
2453 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2454 QString path = m_activeDocument->projectFolder().path();
2456 path.append("untitled.westley");
2457 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2458 url->setFilter("video/mlt-playlist");
2459 QLabel *label2 = new QLabel(i18n("Description:"), this);
2460 KLineEdit *edit = new KLineEdit(this);
2461 vbox->addWidget(label1);
2462 vbox->addWidget(url);
2463 vbox->addWidget(label2);
2464 vbox->addWidget(edit);
2465 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2469 void MainWindow::slotSetInPoint()
2471 if (m_clipMonitor->isActive()) {
2472 m_clipMonitor->slotSetZoneStart();
2473 } else m_activeTimeline->projectView()->setInPoint();
2476 void MainWindow::slotSetOutPoint()
2478 if (m_clipMonitor->isActive()) {
2479 m_clipMonitor->slotSetZoneEnd();
2480 } else m_activeTimeline->projectView()->setOutPoint();
2483 void MainWindow::slotGetNewLumaStuff()
2485 //KNS::Entry::List download();
2486 KNS::Entry::List entries = KNS::Engine::download();
2487 // list of changed entries
2488 kDebug() << "// PARSING KNS";
2489 foreach(KNS::Entry* entry, entries) {
2490 // care only about installed ones
2491 if (entry->status() == KNS::Entry::Installed) {
2492 foreach(const QString &file, entry->installedFiles()) {
2493 kDebug() << "// CURRENTLY INSTALLED: " << file;
2497 qDeleteAll(entries);
2498 initEffects::refreshLumas();
2501 void MainWindow::slotGetNewRenderStuff()
2503 //KNS::Entry::List download();
2505 KNS::Engine engine(0);
2506 if (engine.init("kdenlive_render.knsrc")) {
2507 KNS::Entry::List entries = engine.downloadDialogModal(this);
2509 if (entries.size() > 0) {
2510 foreach(KNS::Entry* entry, entries) {
2511 // care only about installed ones
2512 if (entry->status() == KNS::Entry::Installed) {
2513 foreach(const QString &file, entry->installedFiles()) {
2514 kDebug() << "// CURRENTLY INSTALLED: " << file;
2519 if (m_renderWidget) m_renderWidget->reloadProfiles();
2523 void MainWindow::slotGetNewMltProfileStuff()
2525 //KNS::Entry::List download();
2527 KNS::Engine engine(0);
2528 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2529 KNS::Entry::List entries = engine.downloadDialogModal(this);
2531 if (entries.size() > 0) {
2532 foreach(KNS::Entry* entry, entries) {
2533 // care only about installed ones
2534 if (entry->status() == KNS::Entry::Installed) {
2535 foreach(const QString &file, entry->installedFiles()) {
2536 kDebug() << "// CURRENTLY INSTALLED: " << file;
2541 // update the list of profiles in settings dialog
2542 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2543 if (d) d->checkProfile();
2548 void MainWindow::slotAutoTransition()
2550 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2553 void MainWindow::slotSplitAudio()
2555 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2558 void MainWindow::slotUpdateClipType(QAction *action)
2560 if (m_activeTimeline) {
2561 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2562 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2563 else m_activeTimeline->projectView()->setAudioAndVideo();
2567 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2569 DvdWizard *w = new DvdWizard(url, profile, this);
2573 void MainWindow::slotShowTimeline(bool show)
2575 if (show == false) {
2576 m_timelineState = saveState();
2577 centralWidget()->setHidden(true);
2579 centralWidget()->setHidden(false);
2580 restoreState(m_timelineState);
2584 void MainWindow::slotMaximizeCurrent(bool show)
2586 //TODO: is there a way to maximize current widget?
2589 m_timelineState = saveState();
2590 QWidget *par = focusWidget()->parentWidget();
2591 while (par->parentWidget() && par->parentWidget() != this) {
2592 par = par->parentWidget();
2594 kDebug() << "CURRENT WIDGET: " << par->objectName();
2597 //centralWidget()->setHidden(false);
2598 //restoreState(m_timelineState);
2602 #include "mainwindow.moc"