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), m_activeTimeline(NULL), m_renderWidget(NULL),
111 #ifndef NO_JOGSHUTTLE
113 #endif /* NO_JOGSHUTTLE */
114 m_findActivated(false), m_initialized(false)
117 // Create DBus interface
118 new MainWindowAdaptor(this);
119 QDBusConnection dbus = QDBusConnection::sessionBus();
120 dbus.registerObject("/MainWindow", this);
122 setlocale(LC_NUMERIC, "POSIX");
123 setFont(KGlobalSettings::toolBarFont());
124 parseProfiles(MltPath);
125 m_commandStack = new QUndoGroup;
126 m_timelineArea = new KTabWidget(this);
127 m_timelineArea->setTabReorderingEnabled(true);
128 m_timelineArea->setTabBarHidden(true);
130 QToolButton *closeTabButton = new QToolButton;
131 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
132 closeTabButton->setIcon(KIcon("tab-close"));
133 closeTabButton->adjustSize();
134 closeTabButton->setToolTip(i18n("Close the current tab"));
135 m_timelineArea->setCornerWidget(closeTabButton);
136 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
138 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
139 m_findTimer.setSingleShot(true);
141 initEffects::parseEffectFiles();
142 //initEffects::parseCustomEffectsFile();
144 m_monitorManager = new MonitorManager();
146 projectListDock = new QDockWidget(i18n("Project Tree"), this);
147 projectListDock->setObjectName("project_tree");
148 m_projectList = new ProjectList(this);
149 projectListDock->setWidget(m_projectList);
150 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
152 effectListDock = new QDockWidget(i18n("Effect List"), this);
153 effectListDock->setObjectName("effect_list");
154 m_effectList = new EffectsListView();
156 //m_effectList = new KListWidget(this);
157 effectListDock->setWidget(m_effectList);
158 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
160 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
161 effectStackDock->setObjectName("effect_stack");
162 effectStack = new EffectStackView(this);
163 effectStackDock->setWidget(effectStack);
164 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
166 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
167 transitionConfigDock->setObjectName("transition");
168 transitionConfig = new TransitionSettings(this);
169 transitionConfigDock->setWidget(transitionConfig);
170 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
172 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
173 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
177 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
178 clipMonitorDock->setObjectName("clip_monitor");
179 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
180 clipMonitorDock->setWidget(m_clipMonitor);
181 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
182 //m_clipMonitor->stop();
184 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
185 projectMonitorDock->setObjectName("project_monitor");
186 m_projectMonitor = new Monitor("project", m_monitorManager, this);
187 projectMonitorDock->setWidget(m_projectMonitor);
188 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
190 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
191 recMonitorDock->setObjectName("record_monitor");
192 m_recMonitor = new RecMonitor("record", this);
193 recMonitorDock->setWidget(m_recMonitor);
194 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
196 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
197 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
199 undoViewDock = new QDockWidget(i18n("Undo History"), this);
200 undoViewDock->setObjectName("undo_history");
201 m_undoView = new QUndoView(this);
202 m_undoView->setCleanIcon(KIcon("edit-clear"));
203 m_undoView->setEmptyLabel(i18n("Clean"));
204 undoViewDock->setWidget(m_undoView);
205 m_undoView->setGroup(m_commandStack);
206 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
208 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
209 //overviewDock->setObjectName("project_overview");
210 //m_overView = new CustomTrackView(NULL, NULL, this);
211 //overviewDock->setWidget(m_overView);
212 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
215 //tabifyDockWidget(projectListDock, effectListDock);
216 tabifyDockWidget(projectListDock, effectStackDock);
217 tabifyDockWidget(projectListDock, transitionConfigDock);
218 //tabifyDockWidget(projectListDock, undoViewDock);
221 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
222 tabifyDockWidget(clipMonitorDock, recMonitorDock);
223 setCentralWidget(m_timelineArea);
227 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
228 guiFactory()->addClient(sp);*/
231 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
233 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
234 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
235 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)));
237 // build effects menus
239 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
241 QStringList effectInfo;
242 QMap<QString, QStringList> effectsList;
243 for (int ix = 0; ix < videoEffects.count(); ix++) {
244 effectInfo = videoEffects.effectIdInfo(ix);
245 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
248 foreach(const QStringList &value, effectsList) {
249 action = new QAction(value.at(0), this);
250 action->setData(value);
251 videoEffectsMenu->addAction(action);
254 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
258 for (int ix = 0; ix < audioEffects.count(); ix++) {
259 effectInfo = audioEffects.effectIdInfo(ix);
260 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
263 foreach(const QStringList &value, effectsList) {
264 action = new QAction(value.at(0), this);
265 action->setData(value);
266 audioEffectsMenu->addAction(action);
269 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
271 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
272 else m_customEffectsMenu->setEnabled(true);
275 for (int ix = 0; ix < customEffects.count(); ix++) {
276 effectInfo = customEffects.effectIdInfo(ix);
277 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
280 foreach(const QStringList &value, effectsList) {
281 action = new QAction(value.at(0), this);
282 action->setData(value);
283 m_customEffectsMenu->addAction(action);
286 QMenu *newEffect = new QMenu(this);
287 newEffect->addMenu(videoEffectsMenu);
288 newEffect->addMenu(audioEffectsMenu);
289 newEffect->addMenu(m_customEffectsMenu);
290 effectStack->setMenu(newEffect);
293 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
294 const QList<QAction *> viewActions = createPopupMenu()->actions();
295 viewMenu->insertActions(NULL, viewActions);
297 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
298 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
299 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
301 m_timelineContextMenu = new QMenu(this);
302 m_timelineContextClipMenu = new QMenu(this);
303 m_timelineContextTransitionMenu = new QMenu(this);
306 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
307 QStringList effects = transitions.effectNames();
310 for (int ix = 0; ix < transitions.count(); ix++) {
311 effectInfo = transitions.effectIdInfo(ix);
312 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
314 foreach(const QStringList &value, effectsList) {
315 action = new QAction(value.at(0), this);
316 action->setData(value);
317 transitionsMenu->addAction(action);
319 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
321 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
322 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
323 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
325 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
326 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
327 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
328 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
329 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
330 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
331 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
332 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
334 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
335 m_timelineContextClipMenu->addMenu(markersMenu);
336 m_timelineContextClipMenu->addMenu(transitionsMenu);
337 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
338 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
339 //TODO: re-enable custom effects menu when it is implemented
340 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
342 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
343 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
345 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
347 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
348 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
349 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
350 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
351 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
352 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
354 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
355 slotConnectMonitors();
357 // Open or create a file. Command line argument passed in Url has
358 // precedence, then "openlastproject", then just a plain empty file.
359 // If opening Url fails, openlastproject will _not_ be used.
360 if (!Url.isEmpty()) {
363 if (KdenliveSettings::openlastproject()) {
367 if (m_timelineArea->count() == 0) {
371 #ifndef NO_JOGSHUTTLE
372 activateShuttleDevice();
373 #endif /* NO_JOGSHUTTLE */
374 projectListDock->raise();
377 void MainWindow::queryQuit()
379 kDebug() << "----- SAVING CONFUIG";
380 if (queryClose()) kapp->quit();
384 bool MainWindow::queryClose()
387 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
388 if (m_activeDocument && m_activeDocument->isModified()) {
389 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
390 case KMessageBox::Yes :
391 // save document here. If saving fails, return false;
393 case KMessageBox::No :
403 void MainWindow::loadPlugins()
405 foreach(QObject *plugin, QPluginLoader::staticInstances())
406 populateMenus(plugin);
408 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
410 filters << "libkdenlive*";
411 foreach(const QString &folder, directories) {
412 kDebug() << "// PARSING FIOLER: " << folder;
413 QDir pluginsDir(folder);
414 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
415 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
416 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
417 QObject *plugin = loader.instance();
419 populateMenus(plugin);
420 m_pluginFileNames += fileName;
421 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
427 void MainWindow::populateMenus(QObject *plugin)
429 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
430 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
432 addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
436 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
437 QMenu *menu, const char *member,
438 QActionGroup *actionGroup)
440 kDebug() << "// ADD to MENU" << texts;
441 foreach(const QString &text, texts) {
442 QAction *action = new QAction(text, plugin);
443 action->setData(text);
444 connect(action, SIGNAL(triggered()), this, member);
445 menu->addAction(action);
448 action->setCheckable(true);
449 actionGroup->addAction(action);
454 void MainWindow::aboutPlugins()
456 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
461 void MainWindow::generateClip()
463 QAction *action = qobject_cast<QAction *>(sender());
464 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
466 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
467 if (!clipUrl.isEmpty()) {
468 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
472 void MainWindow::saveProperties(KConfig*)
474 // save properties here,used by session management
479 void MainWindow::readProperties(KConfig *config)
481 // read properties here,used by session management
482 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
483 openFile(KUrl(Lastproject));
486 void MainWindow::slotReloadEffects()
488 initEffects::parseCustomEffectsFile();
489 m_customEffectsMenu->clear();
490 const QStringList effects = customEffects.effectNames();
492 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
493 else m_customEffectsMenu->setEnabled(true);
495 foreach(const QString &name, effects) {
496 action = new QAction(name, this);
497 action->setData(name);
498 m_customEffectsMenu->addAction(action);
500 m_effectList->reloadEffectList();
503 #ifndef NO_JOGSHUTTLE
504 void MainWindow::activateShuttleDevice()
506 if (m_jogProcess) delete m_jogProcess;
508 if (KdenliveSettings::enableshuttle() == false) return;
509 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
510 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
511 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
512 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
513 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
514 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
515 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
518 void MainWindow::slotShuttleButton(int code)
522 slotShuttleAction(KdenliveSettings::shuttle1());
525 slotShuttleAction(KdenliveSettings::shuttle2());
528 slotShuttleAction(KdenliveSettings::shuttle3());
531 slotShuttleAction(KdenliveSettings::shuttle4());
534 slotShuttleAction(KdenliveSettings::shuttle5());
539 void MainWindow::slotShuttleAction(int code)
545 m_monitorManager->slotPlay();
548 m_monitorManager->slotPlay();
552 #endif /* NO_JOGSHUTTLE */
554 void MainWindow::configureNotifications()
556 KNotifyConfigWidget::configure(this);
559 void MainWindow::slotFullScreen()
561 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
564 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track)
566 if (!m_activeDocument) return;
567 if (effect.isNull()) {
568 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
571 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
572 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
575 void MainWindow::slotRaiseMonitor(bool clipMonitor)
577 if (clipMonitor) clipMonitorDock->raise();
578 else projectMonitorDock->raise();
581 void MainWindow::slotSetClipDuration(const QString &id, int duration)
583 if (!m_activeDocument) return;
584 m_activeDocument->setProducerDuration(id, duration);
587 void MainWindow::slotConnectMonitors()
590 m_projectList->setRenderer(m_projectMonitor->render);
591 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
592 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
593 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
594 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
595 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
597 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
599 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
601 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
602 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
604 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
605 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
608 void MainWindow::slotAdjustClipMonitor()
610 clipMonitorDock->updateGeometry();
611 clipMonitorDock->adjustSize();
612 m_clipMonitor->resetSize();
615 void MainWindow::slotAdjustProjectMonitor()
617 projectMonitorDock->updateGeometry();
618 projectMonitorDock->adjustSize();
619 m_projectMonitor->resetSize();
622 void MainWindow::setupActions()
625 KActionCollection* collection = actionCollection();
626 m_timecodeFormat = new KComboBox(this);
627 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
628 m_timecodeFormat->addItem(i18n("Frames"));
630 statusProgressBar = new QProgressBar(this);
631 statusProgressBar->setMinimum(0);
632 statusProgressBar->setMaximum(100);
633 statusProgressBar->setMaximumWidth(150);
634 statusProgressBar->setVisible(false);
636 QWidget *w = new QWidget;
638 QHBoxLayout *layout = new QHBoxLayout;
639 w->setLayout(layout);
640 layout->setContentsMargins(5, 0, 5, 0);
641 QToolBar *toolbar = new QToolBar("statusToolBar", this);
644 m_toolGroup = new QActionGroup(this);
646 QString style1 = "QToolButton {background-color: rgba(230, 230, 230, 220); border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}";
648 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
649 toolbar->addAction(m_buttonSelectTool);
650 m_buttonSelectTool->setCheckable(true);
651 m_buttonSelectTool->setChecked(true);
653 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
654 toolbar->addAction(m_buttonRazorTool);
655 m_buttonRazorTool->setCheckable(true);
656 m_buttonRazorTool->setChecked(false);
658 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
659 toolbar->addAction(m_buttonSpacerTool);
660 m_buttonSpacerTool->setCheckable(true);
661 m_buttonSpacerTool->setChecked(false);
663 m_toolGroup->addAction(m_buttonSelectTool);
664 m_toolGroup->addAction(m_buttonRazorTool);
665 m_toolGroup->addAction(m_buttonSpacerTool);
666 m_toolGroup->setExclusive(true);
667 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
669 QWidget * actionWidget;
670 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
671 actionWidget->setMaximumWidth(24);
672 actionWidget->setMinimumHeight(17);
674 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
675 actionWidget->setMaximumWidth(24);
676 actionWidget->setMinimumHeight(17);
678 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
679 actionWidget->setMaximumWidth(24);
680 actionWidget->setMinimumHeight(17);
682 toolbar->setStyleSheet(style1);
683 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
685 toolbar->addSeparator();
686 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
687 toolbar->addAction(m_buttonFitZoom);
688 m_buttonFitZoom->setCheckable(false);
689 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
691 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
692 actionWidget->setMaximumWidth(24);
693 actionWidget->setMinimumHeight(17);
695 m_zoomSlider = new QSlider(Qt::Horizontal, this);
696 m_zoomSlider->setMaximum(13);
697 m_zoomSlider->setPageStep(1);
699 m_zoomSlider->setMaximumWidth(150);
700 m_zoomSlider->setMinimumWidth(100);
702 const int contentHeight = QFontMetrics(w->font()).height() + 8;
704 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
705 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
707 m_zoomSlider->setStyleSheet(style);
709 //m_zoomSlider->height() + 5;
710 statusBar()->setMinimumHeight(contentHeight);
713 toolbar->addWidget(m_zoomSlider);
715 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
716 toolbar->addAction(m_buttonVideoThumbs);
717 m_buttonVideoThumbs->setCheckable(true);
718 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
719 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
721 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
722 toolbar->addAction(m_buttonAudioThumbs);
723 m_buttonAudioThumbs->setCheckable(true);
724 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
725 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
727 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
728 toolbar->addAction(m_buttonShowMarkers);
729 m_buttonShowMarkers->setCheckable(true);
730 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
731 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
733 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
734 toolbar->addAction(m_buttonSnap);
735 m_buttonSnap->setCheckable(true);
736 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
737 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
738 layout->addWidget(toolbar);
741 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
742 actionWidget->setMaximumWidth(24);
743 actionWidget->setMinimumHeight(17);
745 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
746 actionWidget->setMaximumWidth(24);
747 actionWidget->setMinimumHeight(17);
749 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
750 actionWidget->setMaximumWidth(24);
751 actionWidget->setMinimumHeight(17);
753 actionWidget = toolbar->widgetForAction(m_buttonSnap);
754 actionWidget->setMaximumWidth(24);
755 actionWidget->setMinimumHeight(17);
757 m_messageLabel = new StatusBarMessageLabel(this);
758 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
760 statusBar()->addWidget(m_messageLabel, 10);
761 statusBar()->addWidget(statusProgressBar, 0);
762 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
763 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
764 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
765 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
766 m_messageLabel->hide();
768 collection->addAction("select_tool", m_buttonSelectTool);
769 collection->addAction("razor_tool", m_buttonRazorTool);
770 collection->addAction("spacer_tool", m_buttonSpacerTool);
772 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
773 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
774 collection->addAction("show_markers", m_buttonShowMarkers);
775 collection->addAction("snap", m_buttonSnap);
776 collection->addAction("zoom_fit", m_buttonFitZoom);
778 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
779 collection->addAction("zoom_in", zoomIn);
780 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
781 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
783 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
784 collection->addAction("zoom_out", zoomOut);
785 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
786 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
788 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
789 collection->addAction("project_find", m_projectSearch);
790 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
791 m_projectSearch->setShortcut(Qt::Key_Slash);
793 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
794 collection->addAction("project_find_next", m_projectSearchNext);
795 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
796 m_projectSearchNext->setShortcut(Qt::Key_F3);
797 m_projectSearchNext->setEnabled(false);
799 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
800 collection->addAction("manage_profiles", profilesAction);
801 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
803 KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
805 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
807 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
809 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
810 collection->addAction("run_wizard", wizAction);
811 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
813 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
814 collection->addAction("project_settings", projectAction);
815 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
817 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
818 collection->addAction("project_render", projectRender);
819 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
820 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
822 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
823 KShortcut playShortcut;
824 playShortcut.setPrimary(Qt::Key_Space);
825 playShortcut.setAlternate(Qt::Key_K);
826 monitorPlay->setShortcut(playShortcut);
827 collection->addAction("monitor_play", monitorPlay);
828 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
830 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
831 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
832 collection->addAction("monitor_play_zone", m_playZone);
833 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
835 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
836 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
837 collection->addAction("monitor_loop_zone", m_loopZone);
838 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
840 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
841 collection->addAction("dvd_wizard", dvdWizard);
842 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
844 KAction *markIn = collection->addAction("mark_in");
845 markIn->setText(i18n("Set In Point"));
846 markIn->setShortcut(Qt::Key_I);
847 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
849 KAction *markOut = collection->addAction("mark_out");
850 markOut->setText(i18n("Set Out Point"));
851 markOut->setShortcut(Qt::Key_O);
852 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
854 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
855 monitorSeekBackward->setShortcut(Qt::Key_J);
856 collection->addAction("monitor_seek_backward", monitorSeekBackward);
857 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
859 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
860 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
861 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
862 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
864 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
865 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
866 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
867 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
869 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
870 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
871 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
872 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
874 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
875 monitorSeekForward->setShortcut(Qt::Key_L);
876 collection->addAction("monitor_seek_forward", monitorSeekForward);
877 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
879 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
880 clipStart->setShortcut(Qt::Key_Home);
881 collection->addAction("seek_clip_start", clipStart);
882 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
884 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
885 clipEnd->setShortcut(Qt::Key_End);
886 collection->addAction("seek_clip_end", clipEnd);
887 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
889 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
890 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
891 collection->addAction("seek_start", projectStart);
892 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
894 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
895 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
896 collection->addAction("seek_end", projectEnd);
897 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
899 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
900 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
901 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
902 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
904 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
905 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
906 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
907 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
909 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
910 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
911 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
912 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
914 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
915 deleteTimelineClip->setShortcut(Qt::Key_Delete);
916 collection->addAction("delete_timeline_clip", deleteTimelineClip);
917 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
919 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
920 collection->addAction("change_clip_speed", editTimelineClipSpeed);
921 editTimelineClipSpeed->setData("change_speed");
922 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
924 KAction *stickTransition = collection->addAction("auto_transition");
925 stickTransition->setData(QString("auto"));
926 stickTransition->setCheckable(true);
927 stickTransition->setEnabled(false);
928 stickTransition->setText(i18n("Automatic Transition"));
929 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
931 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
932 collection->addAction("group_clip", groupClip);
933 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
935 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
936 collection->addAction("ungroup_clip", ungroupClip);
937 ungroupClip->setData("ungroup_clip");
938 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
940 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
941 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
942 collection->addAction("cut_timeline_clip", cutTimelineClip);
943 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
945 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
946 collection->addAction("add_clip_marker", addClipMarker);
947 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
949 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
950 collection->addAction("delete_clip_marker", deleteClipMarker);
951 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
953 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
954 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
955 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
957 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
958 collection->addAction("edit_clip_marker", editClipMarker);
959 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
961 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
962 collection->addAction("split_audio", splitAudio);
963 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
965 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
966 collection->addAction("clip_audio_only", audioOnly);
967 audioOnly->setData("clip_audio_only");
968 audioOnly->setCheckable(true);
970 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
971 collection->addAction("clip_video_only", videoOnly);
972 videoOnly->setData("clip_video_only");
973 videoOnly->setCheckable(true);
975 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
976 collection->addAction("clip_audio_and_video", audioAndVideo);
977 audioAndVideo->setData("clip_audio_and_video");
978 audioAndVideo->setCheckable(true);
980 m_clipTypeGroup = new QActionGroup(this);
981 m_clipTypeGroup->addAction(audioOnly);
982 m_clipTypeGroup->addAction(videoOnly);
983 m_clipTypeGroup->addAction(audioAndVideo);
984 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
985 m_clipTypeGroup->setEnabled(false);
987 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
988 collection->addAction("insert_space", insertSpace);
989 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
991 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
992 collection->addAction("delete_space", removeSpace);
993 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
995 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
996 collection->addAction("insert_track", insertTrack);
997 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
999 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1000 collection->addAction("delete_track", deleteTrack);
1001 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1003 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1004 collection->addAction("change_track", changeTrack);
1005 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1007 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1008 collection->addAction("add_guide", addGuide);
1009 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1011 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1012 collection->addAction("delete_guide", delGuide);
1013 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1015 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1016 collection->addAction("edit_guide", editGuide);
1017 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1019 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1020 collection->addAction("delete_all_guides", delAllGuides);
1021 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1023 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1024 collection->addAction("paste_effects", pasteEffects);
1025 pasteEffects->setData("paste_effects");
1026 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1028 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1029 collection->addAction("show_timeline", showTimeline);
1030 showTimeline->setCheckable(true);
1031 showTimeline->setChecked(true);
1032 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1034 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1035 collection->addAction("maximize_current", maxCurrent);
1036 maxCurrent->setCheckable(true);
1037 maxCurrent->setChecked(false);
1038 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1041 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1043 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1045 KStandardAction::open(this, SLOT(openFile()), collection);
1047 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1049 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1051 KStandardAction::openNew(this, SLOT(newFile()), collection);
1053 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1055 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1057 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1059 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1061 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1062 undo->setEnabled(false);
1063 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1065 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1066 redo->setEnabled(false);
1067 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1069 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1071 connect(collection, SIGNAL(actionHovered(QAction*)),
1072 this, SLOT(slotDisplayActionMessage(QAction*)));
1075 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1076 collection->addAction("add_clip", addClip);
1077 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1079 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1080 collection->addAction("add_color_clip", addColorClip);
1081 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1083 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1084 collection->addAction("add_slide_clip", addSlideClip);
1085 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1087 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1088 collection->addAction("add_text_clip", addTitleClip);
1089 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1091 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1092 collection->addAction("add_folder", addFolderButton);
1093 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1095 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1096 collection->addAction("clip_properties", clipProperties);
1097 clipProperties->setData("clip_properties");
1098 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1099 clipProperties->setEnabled(false);
1101 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1102 collection->addAction("edit_clip", openClip);
1103 openClip->setData("edit_clip");
1104 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1105 openClip->setEnabled(false);
1107 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1108 collection->addAction("delete_clip", deleteClip);
1109 deleteClip->setData("delete_clip");
1110 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1111 deleteClip->setEnabled(false);
1113 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1114 collection->addAction("reload_clip", reloadClip);
1115 reloadClip->setData("reload_clip");
1116 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1117 reloadClip->setEnabled(false);
1119 QMenu *addClips = new QMenu();
1120 addClips->addAction(addClip);
1121 addClips->addAction(addColorClip);
1122 addClips->addAction(addSlideClip);
1123 addClips->addAction(addTitleClip);
1124 addClips->addAction(addFolderButton);
1126 addClips->addAction(reloadClip);
1127 addClips->addAction(clipProperties);
1128 addClips->addAction(openClip);
1129 addClips->addAction(deleteClip);
1130 m_projectList->setupMenu(addClips, addClip);
1132 //connect(collection, SIGNAL( clearStatusText() ),
1133 //statusBar(), SLOT( clear() ) );
1136 void MainWindow::slotDisplayActionMessage(QAction *a)
1138 statusBar()->showMessage(a->data().toString(), 3000);
1141 void MainWindow::saveOptions()
1143 KdenliveSettings::self()->writeConfig();
1144 KSharedConfigPtr config = KGlobal::config();
1145 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1146 KConfigGroup treecolumns(config, "Project Tree");
1147 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1151 void MainWindow::readOptions()
1153 KSharedConfigPtr config = KGlobal::config();
1154 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1155 KConfigGroup initialGroup(config, "version");
1156 bool upgrade = false;
1157 if (initialGroup.exists()) {
1158 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0))
1161 if (initialGroup.readEntry("version") == "0.7") {
1162 //Add new settings from 0.7.1
1163 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1164 QString path = QDir::homePath() + "/kdenlive";
1165 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1166 KdenliveSettings::setDefaultprojectfolder(path);
1172 if (!initialGroup.exists() || upgrade) {
1173 // this is our first run, show Wizard
1174 Wizard *w = new Wizard(upgrade, this);
1175 if (w->exec() == QDialog::Accepted && w->isOk()) {
1176 w->adjustSettings();
1177 initialGroup.writeEntry("version", version);
1183 KConfigGroup treecolumns(config, "Project Tree");
1184 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1185 if (!state.isEmpty())
1186 m_projectList->setHeaderInfo(state);
1189 void MainWindow::slotRunWizard()
1191 Wizard *w = new Wizard(this);
1192 if (w->exec() == QDialog::Accepted && w->isOk()) {
1193 w->adjustSettings();
1198 void MainWindow::newFile(bool showProjectSettings)
1200 QString profileName;
1202 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1203 if (!showProjectSettings && m_timelineArea->count() == 0) {
1204 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1205 profileName = KdenliveSettings::default_profile();
1207 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1208 if (w->exec() != QDialog::Accepted) return;
1209 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1210 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1211 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1212 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1213 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1214 profileName = w->selectedProfile();
1215 projectFolder = w->selectedFolder();
1216 projectTracks = w->tracks();
1219 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1220 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1221 TrackView *trackView = new TrackView(doc, this);
1222 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1223 if (m_timelineArea->count() == 1) {
1224 connectDocumentInfo(doc);
1225 connectDocument(trackView, doc);
1226 } else m_timelineArea->setTabBarHidden(false);
1227 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1230 void MainWindow::activateDocument()
1232 if (m_timelineArea->currentWidget() == NULL) return;
1233 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1234 KdenliveDoc *currentDoc = currentTab->document();
1235 connectDocumentInfo(currentDoc);
1236 connectDocument(currentTab, currentDoc);
1239 void MainWindow::closeCurrentDocument()
1241 QWidget *w = m_timelineArea->currentWidget();
1243 // closing current document
1244 int ix = m_timelineArea->currentIndex() + 1;
1245 if (ix == m_timelineArea->count()) ix = 0;
1246 m_timelineArea->setCurrentIndex(ix);
1247 TrackView *tabToClose = (TrackView *) w;
1248 KdenliveDoc *docToClose = tabToClose->document();
1249 if (docToClose && docToClose->isModified()) {
1250 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1251 case KMessageBox::Yes :
1252 // save document here. If saving fails, return false;
1253 if (saveFile() == false) return;
1255 case KMessageBox::Cancel :
1261 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1262 if (m_timelineArea->count() == 1) {
1263 m_timelineArea->setTabBarHidden(true);
1264 m_closeAction->setEnabled(false);
1268 if (m_timelineArea->count() == 0) {
1269 m_activeDocument = NULL;
1270 effectStack->clear();
1271 transitionConfig->slotTransitionItemSelected(NULL, false);
1275 bool MainWindow::saveFileAs(const QString &outputFileName)
1277 QString currentSceneList;
1278 if (KdenliveSettings::dropbframes()) {
1279 KdenliveSettings::setDropbframes(false);
1280 m_activeDocument->clipManager()->updatePreviewSettings();
1281 currentSceneList = m_projectMonitor->sceneList();
1282 KdenliveSettings::setDropbframes(true);
1283 m_activeDocument->clipManager()->updatePreviewSettings();
1284 } else currentSceneList = m_projectMonitor->sceneList();
1286 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1289 // Save timeline thumbnails
1290 m_activeTimeline->projectView()->saveThumbnails();
1291 m_activeDocument->setUrl(KUrl(outputFileName));
1292 if (m_activeDocument->m_autosave == NULL) {
1293 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1294 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1295 setCaption(m_activeDocument->description());
1296 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1297 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1298 m_activeDocument->setModified(false);
1299 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1303 bool MainWindow::saveFileAs()
1305 // Check that the Kdenlive mime type is correctly installed
1306 QString mimetype = "application/x-kdenlive";
1307 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1308 if (!mime) mimetype = "*.kdenlive";
1310 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1311 if (outputFile.isEmpty()) return false;
1312 if (QFile::exists(outputFile)) {
1313 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1315 return saveFileAs(outputFile);
1318 bool MainWindow::saveFile()
1320 if (!m_activeDocument) return true;
1321 if (m_activeDocument->url().isEmpty()) {
1322 return saveFileAs();
1324 bool result = saveFileAs(m_activeDocument->url().path());
1325 m_activeDocument->m_autosave->resize(0);
1330 void MainWindow::openFile()
1332 // Check that the Kdenlive mime type is correctly installed
1333 QString mimetype = "application/x-kdenlive";
1334 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1335 if (!mime) mimetype = "*.kdenlive";
1337 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1338 if (url.isEmpty()) return;
1339 m_fileOpenRecent->addUrl(url);
1343 void MainWindow::openLastFile()
1345 KSharedConfigPtr config = KGlobal::config();
1346 KUrl::List urls = m_fileOpenRecent->urls();
1347 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1348 if (urls.isEmpty()) newFile(false);
1349 else openFile(urls.last());
1352 void MainWindow::openFile(const KUrl &url)
1354 // Check if the document is already opened
1355 const int ct = m_timelineArea->count();
1356 bool isOpened = false;
1358 for (i = 0; i < ct; i++) {
1359 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1360 KdenliveDoc *doc = tab->document();
1361 if (doc->url() == url) {
1367 m_timelineArea->setCurrentIndex(i);
1371 // Check for backup file
1372 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1373 if (!staleFiles.isEmpty()) {
1374 if (KMessageBox::questionYesNo(this,
1375 i18n("Auto-saved files exist. Do you want to recover them now?"),
1376 i18n("File Recovery"),
1377 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1378 recoverFiles(staleFiles);
1381 // remove the stale files
1382 foreach(KAutoSaveFile *stale, staleFiles) {
1383 stale->open(QIODevice::ReadWrite);
1388 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1389 doOpenFile(url, NULL);
1392 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1394 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1395 if (stale == NULL) {
1396 stale = new KAutoSaveFile(url, doc);
1397 doc->m_autosave = stale;
1399 doc->m_autosave = stale;
1400 doc->setUrl(stale->managedFile());
1401 doc->setModified(true);
1402 stale->setParent(doc);
1404 connectDocumentInfo(doc);
1405 TrackView *trackView = new TrackView(doc, this);
1406 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1407 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1408 trackView->setDuration(trackView->duration());
1409 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1411 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1412 slotGotProgressInfo(QString(), -1);
1413 m_clipMonitor->refreshMonitor(true);
1414 m_projectMonitor->adjustRulerSize(trackView->duration());
1415 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1418 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1420 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1421 foreach(KAutoSaveFile *stale, staleFiles) {
1422 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1423 // show an error message; we could not steal the lockfile
1424 // maybe another application got to the file before us?
1428 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1429 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1430 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1431 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1436 void MainWindow::parseProfiles(const QString &mltPath)
1438 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1440 //KdenliveSettings::setDefaulttmpfolder();
1441 if (!mltPath.isEmpty()) {
1442 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1443 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1446 if (KdenliveSettings::mltpath().isEmpty()) {
1447 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1449 if (KdenliveSettings::rendererpath().isEmpty()) {
1450 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1451 if (!QFile::exists(inigoPath))
1452 inigoPath = KStandardDirs::findExe("inigo");
1453 else KdenliveSettings::setRendererpath(inigoPath);
1455 QStringList profilesFilter;
1456 profilesFilter << "*";
1457 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1459 if (profilesList.isEmpty()) {
1460 // Cannot find MLT path, try finding inigo
1461 QString profilePath = KdenliveSettings::rendererpath();
1462 if (!profilePath.isEmpty()) {
1463 profilePath = profilePath.section('/', 0, -3);
1464 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1465 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1468 if (profilesList.isEmpty()) {
1469 // Cannot find the MLT profiles, ask for location
1470 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1471 getUrl->fileDialog()->setMode(KFile::Directory);
1472 if (getUrl->exec() == QDialog::Rejected) {
1475 KUrl mltPath = getUrl->selectedUrl();
1477 if (mltPath.isEmpty()) ::exit(0);
1478 KdenliveSettings::setMltpath(mltPath.path());
1479 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1483 if (KdenliveSettings::rendererpath().isEmpty()) {
1484 // Cannot find the MLT inigo renderer, ask for location
1485 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1486 if (getUrl->exec() == QDialog::Rejected) {
1489 KUrl rendererPath = getUrl->selectedUrl();
1491 if (rendererPath.isEmpty()) ::exit(0);
1492 KdenliveSettings::setRendererpath(rendererPath.path());
1495 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1497 // Parse MLT profiles to build a list of available video formats
1498 if (profilesList.isEmpty()) parseProfiles();
1502 void MainWindow::slotEditProfiles()
1504 ProfilesDialog *w = new ProfilesDialog;
1505 if (w->exec() == QDialog::Accepted) {
1506 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1507 if (d) d->checkProfile();
1512 void MainWindow::slotEditProjectSettings()
1514 QPoint p = m_activeDocument->getTracksCount();
1515 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1517 if (w->exec() == QDialog::Accepted) {
1518 QString profile = w->selectedProfile();
1519 m_activeDocument->setProjectFolder(w->selectedFolder());
1520 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1521 if (m_activeDocument->profilePath() != profile) {
1522 // Profile was changed
1523 m_activeDocument->setProfilePath(profile);
1524 KdenliveSettings::setCurrent_profile(profile);
1525 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1526 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1527 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1528 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1529 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1530 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1532 // We need to desactivate & reactivate monitors to get a refresh
1533 m_monitorManager->switchMonitors();
1539 void MainWindow::slotRenderProject()
1541 if (!m_renderWidget) {
1542 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1543 m_renderWidget = new RenderWidget(projectfolder, this);
1544 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool, const QString &)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool, const QString &)));
1545 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1546 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1547 if (m_activeDocument) {
1548 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1549 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1552 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1553 if (currentTab) m_renderWidget->setTimeline(currentTab);
1554 m_renderWidget->setDocument(m_activeDocument);*/
1555 m_renderWidget->show();
1558 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd, bool resizeProfile, const QString &scriptExport)
1560 kDebug() << "// SCRIPT EXPORT: " << scriptExport;
1561 if (dest.isEmpty()) return;
1564 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1565 if (currentTab && zoneOnly) {
1566 in = currentTab->inPoint();
1567 out = currentTab->outPoint();
1569 KTemporaryFile temp;
1570 temp.setAutoRemove(false);
1571 temp.setSuffix(".westley");
1572 if (!scriptExport.isEmpty() || temp.open()) {
1573 if (KdenliveSettings::dropbframes()) {
1574 KdenliveSettings::setDropbframes(false);
1575 m_activeDocument->clipManager()->updatePreviewSettings();
1576 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1577 else m_projectMonitor->saveSceneList(temp.fileName());
1578 KdenliveSettings::setDropbframes(true);
1579 m_activeDocument->clipManager()->updatePreviewSettings();
1581 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1582 else m_projectMonitor->saveSceneList(temp.fileName());
1586 if (scriptExport.isEmpty()) args << "-erase";
1587 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1588 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1589 else if (guideStart != -1) {
1590 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1592 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1593 QString videoPlayer = "-";
1595 videoPlayer = KdenliveSettings::defaultplayerapp();
1596 if (videoPlayer.isEmpty()) KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
1598 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1599 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1600 setRenderingProgress(dest, -3);
1603 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1605 for (int i = 0; i < avformat_args.count(); i++) {
1606 if (avformat_args.at(i).startsWith("profile=")) {
1607 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1612 if (resizeProfile) {
1613 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1614 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1615 else args << "consumer:$SOURCE";
1617 if (scriptExport.isEmpty()) args << temp.fileName();
1618 else args << "$SOURCE";
1620 if (scriptExport.isEmpty()) args << dest;
1621 else args << "$TARGET";
1622 args << avformat_args;
1623 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1624 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1625 if (scriptExport.isEmpty()) {
1626 QProcess::startDetached(renderer, args);
1627 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1629 // Generate script file
1630 QFile file(scriptExport);
1631 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1632 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1636 QTextStream out(&file);
1637 out << "#! /bin/sh" << "\n" << "\n";
1638 out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
1639 out << "TARGET=" << "\"" + dest + "\"" << "\n";
1640 out << renderer << " " << args.join(" ") << "\n" << "\n";
1641 if (file.error() != QFile::NoError) {
1642 KMessageBox::error(this, i18n("Cannot write to file %1", scriptExport));
1647 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1652 void MainWindow::setRenderingProgress(const QString &url, int progress)
1654 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1657 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1659 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1662 void MainWindow::slotUpdateMousePosition(int pos)
1664 if (m_activeDocument)
1665 switch (m_timecodeFormat->currentIndex()) {
1667 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1670 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1674 void MainWindow::slotUpdateDocumentState(bool modified)
1676 if (!m_activeDocument) return;
1677 setCaption(m_activeDocument->description(), modified);
1678 m_saveAction->setEnabled(modified);
1680 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1681 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1683 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1684 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1688 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1690 if (m_activeDocument) {
1691 if (m_activeDocument == doc) return;
1692 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1694 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1697 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1699 //m_projectMonitor->stop();
1700 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1701 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1702 if (m_activeDocument) {
1703 if (m_activeDocument == doc) return;
1704 if (m_activeTimeline) {
1705 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1706 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1707 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1708 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1711 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1712 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1713 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1714 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1715 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1716 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1717 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1718 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1719 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1720 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1721 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1722 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1723 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1724 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1725 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1726 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1727 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1728 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1729 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1730 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1731 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1732 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1733 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1734 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1735 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1736 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1737 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1738 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1739 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1740 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1741 effectStack->clear();
1743 //m_activeDocument->setRenderer(NULL);
1744 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1745 m_clipMonitor->stop();
1747 KdenliveSettings::setCurrent_profile(doc->profilePath());
1748 KdenliveSettings::setProject_fps(doc->fps());
1749 m_monitorManager->resetProfiles(doc->timecode());
1750 m_projectList->setDocument(doc);
1751 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1752 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1753 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1754 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1755 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1758 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1759 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1760 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1761 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1762 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1763 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1764 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1765 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1766 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1767 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1768 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1769 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1770 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1772 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1773 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1774 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1777 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1778 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1779 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1780 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1781 m_zoomSlider->setValue(doc->zoom());
1782 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1783 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1784 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1785 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1787 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1790 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1791 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1792 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1793 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1794 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1795 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1796 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1797 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1799 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1800 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1801 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1803 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
1804 m_activeTimeline = trackView;
1805 if (m_renderWidget) {
1806 m_renderWidget->setProfile(doc->mltProfile());
1807 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1809 //doc->setRenderer(m_projectMonitor->render);
1810 m_commandStack->setActiveStack(doc->commandStack());
1811 KdenliveSettings::setProject_display_ratio(doc->dar());
1812 m_projectList->updateAllClips();
1813 //doc->clipManager()->checkAudioThumbs();
1815 //m_overView->setScene(trackView->projectScene());
1816 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1817 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1819 setCaption(doc->description(), doc->isModified());
1820 m_saveAction->setEnabled(doc->isModified());
1821 m_activeDocument = doc;
1822 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1824 // set tool to select tool
1825 m_buttonSelectTool->setChecked(true);
1828 void MainWindow::slotZoneMoved(int start, int end)
1830 m_activeDocument->setZone(start, end);
1831 m_projectMonitor->slotZoneMoved(start, end);
1834 void MainWindow::slotGuidesUpdated()
1836 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1839 void MainWindow::slotPreferences(int page, int option)
1841 //An instance of your dialog could be already created and could be
1842 // cached, in which case you want to display the cached dialog
1843 // instead of creating another one
1844 if (KConfigDialog::showDialog("settings")) {
1845 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1846 if (page != -1) d->showPage(page, option);
1850 // KConfigDialog didn't find an instance of this dialog, so lets
1852 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1853 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1854 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1855 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1856 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
1857 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1859 if (page != -1) dialog->showPage(page, option);
1862 void MainWindow::slotUpdatePreviewSettings()
1864 if (m_activeDocument) {
1865 m_clipMonitor->slotSetXml(NULL, 0);
1866 m_activeDocument->updatePreviewSettings();
1870 void MainWindow::updateConfiguration()
1872 //TODO: we should apply settings to all projects, not only the current one
1873 if (m_activeTimeline) {
1874 m_activeTimeline->refresh();
1875 m_activeTimeline->projectView()->checkAutoScroll();
1876 m_activeTimeline->projectView()->checkTrackHeight();
1877 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1879 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1880 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1881 #ifndef NO_JOGSHUTTLE
1882 activateShuttleDevice();
1883 #endif /* NO_JOGSHUTTLE */
1888 void MainWindow::slotSwitchVideoThumbs()
1890 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1891 if (m_activeTimeline) {
1892 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1894 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1897 void MainWindow::slotSwitchAudioThumbs()
1899 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1900 if (m_activeTimeline) {
1901 m_activeTimeline->refresh();
1902 m_activeTimeline->projectView()->checkAutoScroll();
1903 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1905 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1908 void MainWindow::slotSwitchMarkersComments()
1910 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1911 if (m_activeTimeline) {
1912 m_activeTimeline->refresh();
1914 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1917 void MainWindow::slotSwitchSnap()
1919 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1920 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1924 void MainWindow::slotDeleteTimelineClip()
1926 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1927 else if (m_activeTimeline) {
1928 m_activeTimeline->projectView()->deleteSelectedClips();
1932 void MainWindow::slotChangeClipSpeed()
1934 if (m_activeTimeline) {
1935 m_activeTimeline->projectView()->changeClipSpeed();
1939 void MainWindow::slotAddClipMarker()
1941 DocClipBase *clip = NULL;
1943 if (m_projectMonitor->isActive()) {
1944 if (m_activeTimeline) {
1945 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1947 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1948 clip = item->baseClip();
1952 clip = m_clipMonitor->activeClip();
1953 pos = m_clipMonitor->position();
1956 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1959 QString id = clip->getId();
1960 CommentedTime marker(pos, i18n("Marker"));
1961 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1962 if (d.exec() == QDialog::Accepted) {
1963 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1965 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1968 void MainWindow::slotDeleteClipMarker()
1970 DocClipBase *clip = NULL;
1972 if (m_projectMonitor->isActive()) {
1973 if (m_activeTimeline) {
1974 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1976 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1977 clip = item->baseClip();
1981 clip = m_clipMonitor->activeClip();
1982 pos = m_clipMonitor->position();
1985 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1989 QString id = clip->getId();
1990 QString comment = clip->markerComment(pos);
1991 if (comment.isEmpty()) {
1992 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1995 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1996 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2000 void MainWindow::slotDeleteAllClipMarkers()
2002 DocClipBase *clip = NULL;
2003 if (m_projectMonitor->isActive()) {
2004 if (m_activeTimeline) {
2005 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2007 clip = item->baseClip();
2011 clip = m_clipMonitor->activeClip();
2014 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2017 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2018 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2021 void MainWindow::slotEditClipMarker()
2023 DocClipBase *clip = NULL;
2025 if (m_projectMonitor->isActive()) {
2026 if (m_activeTimeline) {
2027 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2029 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
2030 clip = item->baseClip();
2034 clip = m_clipMonitor->activeClip();
2035 pos = m_clipMonitor->position();
2038 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2042 QString id = clip->getId();
2043 QString oldcomment = clip->markerComment(pos);
2044 if (oldcomment.isEmpty()) {
2045 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2049 CommentedTime marker(pos, oldcomment);
2050 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2051 if (d.exec() == QDialog::Accepted) {
2052 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2053 if (d.newMarker().time() != pos) {
2054 // remove old marker
2055 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2057 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2061 void MainWindow::slotAddGuide()
2063 if (m_activeTimeline)
2064 m_activeTimeline->projectView()->slotAddGuide();
2067 void MainWindow::slotInsertSpace()
2069 if (m_activeTimeline)
2070 m_activeTimeline->projectView()->slotInsertSpace();
2073 void MainWindow::slotRemoveSpace()
2075 if (m_activeTimeline)
2076 m_activeTimeline->projectView()->slotRemoveSpace();
2079 void MainWindow::slotInsertTrack(int ix)
2081 m_projectMonitor->activateMonitor();
2082 if (m_activeTimeline)
2083 m_activeTimeline->projectView()->slotInsertTrack(ix);
2086 void MainWindow::slotDeleteTrack(int ix)
2088 m_projectMonitor->activateMonitor();
2089 if (m_activeTimeline)
2090 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2093 void MainWindow::slotChangeTrack(int ix)
2095 m_projectMonitor->activateMonitor();
2096 if (m_activeTimeline)
2097 m_activeTimeline->projectView()->slotChangeTrack(ix);
2100 void MainWindow::slotEditGuide()
2102 if (m_activeTimeline)
2103 m_activeTimeline->projectView()->slotEditGuide();
2106 void MainWindow::slotDeleteGuide()
2108 if (m_activeTimeline)
2109 m_activeTimeline->projectView()->slotDeleteGuide();
2112 void MainWindow::slotDeleteAllGuides()
2114 if (m_activeTimeline)
2115 m_activeTimeline->projectView()->slotDeleteAllGuides();
2118 void MainWindow::slotCutTimelineClip()
2120 if (m_activeTimeline) {
2121 m_activeTimeline->projectView()->cutSelectedClips();
2125 void MainWindow::slotGroupClips()
2127 if (m_activeTimeline) {
2128 m_activeTimeline->projectView()->groupClips();
2132 void MainWindow::slotUnGroupClips()
2134 if (m_activeTimeline) {
2135 m_activeTimeline->projectView()->groupClips(false);
2139 void MainWindow::slotAddProjectClip(KUrl url)
2141 if (m_activeDocument)
2142 m_activeDocument->slotAddClipFile(url, QString());
2145 void MainWindow::slotAddTransition(QAction *result)
2147 if (!result) return;
2148 QStringList info = result->data().toStringList();
2149 if (info.isEmpty()) return;
2150 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2151 if (m_activeTimeline && !transition.isNull()) {
2152 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2156 void MainWindow::slotAddVideoEffect(QAction *result)
2158 if (!result) return;
2159 QStringList info = result->data().toStringList();
2160 if (info.isEmpty()) return;
2161 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2162 slotAddEffect(effect);
2165 void MainWindow::slotAddAudioEffect(QAction *result)
2167 if (!result) return;
2168 QStringList info = result->data().toStringList();
2169 if (info.isEmpty()) return;
2170 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2171 slotAddEffect(effect);
2174 void MainWindow::slotAddCustomEffect(QAction *result)
2176 if (!result) return;
2177 QStringList info = result->data().toStringList();
2178 if (info.isEmpty()) return;
2179 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2180 slotAddEffect(effect);
2183 void MainWindow::slotZoomIn()
2185 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2188 void MainWindow::slotZoomOut()
2190 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2193 void MainWindow::slotFitZoom()
2195 if (m_activeTimeline) {
2196 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2200 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2202 statusProgressBar->setValue(progress);
2203 if (progress >= 0) {
2204 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2205 statusProgressBar->setVisible(true);
2207 m_messageLabel->setMessage(QString(), DefaultMessage);
2208 statusProgressBar->setVisible(false);
2212 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2214 if (clip->clipType() == TEXT) {
2215 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2216 QString path = clip->getProperty("resource");
2217 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2219 doc.setContent(clip->getProperty("xmldata"));
2220 dia_ui->setXml(doc);
2221 if (dia_ui->exec() == QDialog::Accepted) {
2222 QImage pix = dia_ui->renderedPixmap();
2224 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2225 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2226 QMap <QString, QString> newprops;
2227 newprops.insert("xmldata", dia_ui->xml().toString());
2228 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2229 m_activeDocument->commandStack()->push(command);
2230 m_clipMonitor->refreshMonitor(true);
2231 m_activeDocument->setModified(true);
2235 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2238 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2239 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2240 if (dia.exec() == QDialog::Accepted) {
2241 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2242 m_activeDocument->commandStack()->push(command);
2244 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2245 if (dia.needsTimelineRefresh()) {
2246 // update clip occurences in timeline
2247 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2252 void MainWindow::customEvent(QEvent* e)
2254 if (e->type() == QEvent::User) {
2255 // The timeline playing position changed...
2256 kDebug() << "RECEIVED JOG EVEMNT!!!";
2259 void MainWindow::slotActivateEffectStackView()
2261 effectStack->raiseWindow(effectStackDock);
2264 void MainWindow::slotActivateTransitionView(Transition *t)
2266 if (t) transitionConfig->raiseWindow(transitionConfigDock);
2269 void MainWindow::slotSnapRewind()
2271 if (m_projectMonitor->isActive()) {
2272 if (m_activeTimeline)
2273 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2274 } else m_clipMonitor->slotSeekToPreviousSnap();
2277 void MainWindow::slotSnapForward()
2279 if (m_projectMonitor->isActive()) {
2280 if (m_activeTimeline)
2281 m_activeTimeline->projectView()->slotSeekToNextSnap();
2282 } else m_clipMonitor->slotSeekToNextSnap();
2285 void MainWindow::slotClipStart()
2287 if (m_projectMonitor->isActive()) {
2288 if (m_activeTimeline)
2289 m_activeTimeline->projectView()->clipStart();
2293 void MainWindow::slotClipEnd()
2295 if (m_projectMonitor->isActive()) {
2296 if (m_activeTimeline)
2297 m_activeTimeline->projectView()->clipEnd();
2301 void MainWindow::slotChangeTool(QAction * action)
2303 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2304 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2305 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2308 void MainWindow::slotSetTool(PROJECTTOOL tool)
2310 if (m_activeDocument && m_activeTimeline) {
2311 //m_activeDocument->setTool(tool);
2312 m_activeTimeline->projectView()->setTool(tool);
2316 void MainWindow::slotCopy()
2318 if (!m_activeDocument || !m_activeTimeline) return;
2319 m_activeTimeline->projectView()->copyClip();
2322 void MainWindow::slotPaste()
2324 if (!m_activeDocument || !m_activeTimeline) return;
2325 m_activeTimeline->projectView()->pasteClip();
2328 void MainWindow::slotPasteEffects()
2330 if (!m_activeDocument || !m_activeTimeline) return;
2331 m_activeTimeline->projectView()->pasteClipEffects();
2334 void MainWindow::slotFind()
2336 if (!m_activeDocument || !m_activeTimeline) return;
2337 m_projectSearch->setEnabled(false);
2338 m_findActivated = true;
2339 m_findString.clear();
2340 m_activeTimeline->projectView()->initSearchStrings();
2341 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2342 m_findTimer.start(5000);
2343 qApp->installEventFilter(this);
2346 void MainWindow::slotFindNext()
2348 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2349 statusBar()->showMessage(i18n("Found : %1", m_findString));
2351 statusBar()->showMessage(i18n("Reached end of project"));
2353 m_findTimer.start(4000);
2356 void MainWindow::findAhead()
2358 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2359 m_projectSearchNext->setEnabled(true);
2360 statusBar()->showMessage(i18n("Found : %1", m_findString));
2362 m_projectSearchNext->setEnabled(false);
2363 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2367 void MainWindow::findTimeout()
2369 m_projectSearchNext->setEnabled(false);
2370 m_findActivated = false;
2371 m_findString.clear();
2372 statusBar()->showMessage(i18n("Find stopped"), 3000);
2373 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2374 m_projectSearch->setEnabled(true);
2375 removeEventFilter(this);
2378 void MainWindow::keyPressEvent(QKeyEvent *ke)
2380 if (m_findActivated) {
2381 if (ke->key() == Qt::Key_Backspace) {
2382 m_findString = m_findString.left(m_findString.length() - 1);
2384 if (!m_findString.isEmpty()) {
2390 m_findTimer.start(4000);
2393 } else if (ke->key() == Qt::Key_Escape) {
2397 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2398 m_findString += ke->text();
2402 m_findTimer.start(4000);
2406 } else KXmlGuiWindow::keyPressEvent(ke);
2410 /** Gets called when the window gets hidden */
2411 void MainWindow::hideEvent(QHideEvent */*event*/)
2413 // kDebug() << "I was hidden";
2414 // issue http://www.kdenlive.org/mantis/view.php?id=231
2415 if (isMinimized()) {
2416 // kDebug() << "I am minimized";
2417 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2421 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2423 if (m_findActivated) {
2424 if (event->type() == QEvent::ShortcutOverride) {
2425 QKeyEvent* ke = (QKeyEvent*) event;
2426 if (ke->text().trimmed().isEmpty()) return false;
2429 } else return false;
2431 // pass the event on to the parent class
2432 return QMainWindow::eventFilter(obj, event);
2436 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2438 KDialog *dialog = new KDialog(this);
2439 dialog->setCaption("Save clip zone");
2440 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2442 QWidget *widget = new QWidget(dialog);
2443 dialog->setMainWidget(widget);
2445 QVBoxLayout *vbox = new QVBoxLayout(widget);
2446 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2447 QString path = m_activeDocument->projectFolder().path();
2449 path.append("untitled.westley");
2450 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2451 url->setFilter("video/mlt-playlist");
2452 QLabel *label2 = new QLabel(i18n("Description:"), this);
2453 KLineEdit *edit = new KLineEdit(this);
2454 vbox->addWidget(label1);
2455 vbox->addWidget(url);
2456 vbox->addWidget(label2);
2457 vbox->addWidget(edit);
2458 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2462 void MainWindow::slotSetInPoint()
2464 if (m_clipMonitor->isActive()) {
2465 m_clipMonitor->slotSetZoneStart();
2466 } else m_activeTimeline->projectView()->setInPoint();
2469 void MainWindow::slotSetOutPoint()
2471 if (m_clipMonitor->isActive()) {
2472 m_clipMonitor->slotSetZoneEnd();
2473 } else m_activeTimeline->projectView()->setOutPoint();
2476 void MainWindow::slotGetNewLumaStuff()
2478 //KNS::Entry::List download();
2479 KNS::Entry::List entries = KNS::Engine::download();
2480 // list of changed entries
2481 kDebug() << "// PARSING KNS";
2482 foreach(KNS::Entry* entry, entries) {
2483 // care only about installed ones
2484 if (entry->status() == KNS::Entry::Installed) {
2485 foreach(const QString &file, entry->installedFiles()) {
2486 kDebug() << "// CURRENTLY INSTALLED: " << file;
2490 qDeleteAll(entries);
2491 initEffects::refreshLumas();
2494 void MainWindow::slotGetNewRenderStuff()
2496 //KNS::Entry::List download();
2498 KNS::Engine engine(0);
2499 if (engine.init("kdenlive_render.knsrc")) {
2500 KNS::Entry::List entries = engine.downloadDialogModal(this);
2502 if (entries.size() > 0) {
2503 foreach(KNS::Entry* entry, entries) {
2504 // care only about installed ones
2505 if (entry->status() == KNS::Entry::Installed) {
2506 foreach(const QString &file, entry->installedFiles()) {
2507 kDebug() << "// CURRENTLY INSTALLED: " << file;
2512 if (m_renderWidget) m_renderWidget->reloadProfiles();
2516 void MainWindow::slotGetNewMltProfileStuff()
2518 //KNS::Entry::List download();
2520 KNS::Engine engine(0);
2521 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2522 KNS::Entry::List entries = engine.downloadDialogModal(this);
2524 if (entries.size() > 0) {
2525 foreach(KNS::Entry* entry, entries) {
2526 // care only about installed ones
2527 if (entry->status() == KNS::Entry::Installed) {
2528 foreach(const QString &file, entry->installedFiles()) {
2529 kDebug() << "// CURRENTLY INSTALLED: " << file;
2534 // update the list of profiles in settings dialog
2535 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2536 if (d) d->checkProfile();
2541 void MainWindow::slotAutoTransition()
2543 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2546 void MainWindow::slotSplitAudio()
2548 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2551 void MainWindow::slotUpdateClipType(QAction *action)
2553 if (m_activeTimeline) {
2554 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2555 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2556 else m_activeTimeline->projectView()->setAudioAndVideo();
2560 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2562 DvdWizard *w = new DvdWizard(url, profile, this);
2566 void MainWindow::slotShowTimeline(bool show)
2568 if (show == false) {
2569 m_timelineState = saveState();
2570 centralWidget()->setHidden(true);
2572 centralWidget()->setHidden(false);
2573 restoreState(m_timelineState);
2577 void MainWindow::slotMaximizeCurrent(bool show)
2579 //TODO: is there a way to maximize current widget?
2582 m_timelineState = saveState();
2583 QWidget *par = focusWidget()->parentWidget();
2584 while (par->parentWidget() && par->parentWidget() != this) {
2585 par = par->parentWidget();
2587 kDebug() << "CURRENT WIDGET: " << par->objectName();
2590 //centralWidget()->setHidden(false);
2591 //restoreState(m_timelineState);
2595 #include "mainwindow.moc"