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"
53 #include <KApplication>
57 #include <KActionCollection>
58 #include <KStandardAction>
59 #include <KFileDialog>
60 #include <KMessageBox>
62 #include <KIO/NetAccess>
65 #include <KConfigDialog>
66 #include <KXMLGUIFactory>
68 #include <kstandarddirs.h>
69 #include <KUrlRequesterDialog>
70 #include <KTemporaryFile>
71 #include <KActionMenu>
74 #include <ktogglefullscreenaction.h>
76 #include <KNotification>
77 #include <KNotifyConfigWidget>
78 #include <knewstuff2/engine.h>
79 #include <knewstuff2/ui/knewstuffaction.h>
81 #include <QTextStream>
88 static const int ID_STATUS_MSG = 1;
89 static const int ID_EDITMODE_MSG = 2;
90 static const int ID_TIMELINE_MSG = 3;
91 static const int ID_TIMELINE_BUTTONS = 5;
92 static const int ID_TIMELINE_POS = 6;
93 static const int ID_TIMELINE_FORMAT = 7;
99 EffectsList MainWindow::videoEffects;
100 EffectsList MainWindow::audioEffects;
101 EffectsList MainWindow::customEffects;
102 EffectsList MainWindow::transitions;
104 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent)
105 : KXmlGuiWindow(parent),
106 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL),
107 #ifndef NO_JOGSHUTTLE
109 #endif /* NO_JOGSHUTTLE */
110 m_findActivated(false), m_initialized(false) {
112 // Create DBus interface
113 new MainWindowAdaptor(this);
114 QDBusConnection dbus = QDBusConnection::sessionBus();
115 dbus.registerObject("/MainWindow", this);
117 setlocale(LC_NUMERIC, "POSIX");
118 setFont(KGlobalSettings::toolBarFont());
119 parseProfiles(MltPath);
120 m_commandStack = new QUndoGroup;
121 m_timelineArea = new KTabWidget(this);
122 m_timelineArea->setTabReorderingEnabled(true);
123 m_timelineArea->setTabBarHidden(true);
125 QToolButton *closeTabButton = new QToolButton;
126 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
127 closeTabButton->setIcon(KIcon("tab-close"));
128 closeTabButton->adjustSize();
129 closeTabButton->setToolTip(i18n("Close the current tab"));
130 m_timelineArea->setCornerWidget(closeTabButton);
131 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
133 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
134 m_findTimer.setSingleShot(true);
136 initEffects::parseEffectFiles();
137 //initEffects::parseCustomEffectsFile();
139 m_monitorManager = new MonitorManager();
141 projectListDock = new QDockWidget(i18n("Project Tree"), this);
142 projectListDock->setObjectName("project_tree");
143 m_projectList = new ProjectList(this);
144 projectListDock->setWidget(m_projectList);
145 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
147 effectListDock = new QDockWidget(i18n("Effect List"), this);
148 effectListDock->setObjectName("effect_list");
149 m_effectList = new EffectsListView();
151 //m_effectList = new KListWidget(this);
152 effectListDock->setWidget(m_effectList);
153 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
155 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
156 effectStackDock->setObjectName("effect_stack");
157 effectStack = new EffectStackView(this);
158 effectStackDock->setWidget(effectStack);
159 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
161 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
162 transitionConfigDock->setObjectName("transition");
163 transitionConfig = new TransitionSettings(this);
164 transitionConfigDock->setWidget(transitionConfig);
165 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
167 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
168 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
172 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
173 clipMonitorDock->setObjectName("clip_monitor");
174 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
175 clipMonitorDock->setWidget(m_clipMonitor);
176 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
177 //m_clipMonitor->stop();
179 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
180 projectMonitorDock->setObjectName("project_monitor");
181 m_projectMonitor = new Monitor("project", m_monitorManager, this);
182 projectMonitorDock->setWidget(m_projectMonitor);
183 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
185 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
186 recMonitorDock->setObjectName("record_monitor");
187 m_recMonitor = new RecMonitor("record", this);
188 recMonitorDock->setWidget(m_recMonitor);
189 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
191 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
192 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
194 undoViewDock = new QDockWidget(i18n("Undo History"), this);
195 undoViewDock->setObjectName("undo_history");
196 m_undoView = new QUndoView(this);
197 m_undoView->setCleanIcon(KIcon("edit-clear"));
198 m_undoView->setEmptyLabel(i18n("Clean"));
199 undoViewDock->setWidget(m_undoView);
200 m_undoView->setGroup(m_commandStack);
201 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
203 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
204 //overviewDock->setObjectName("project_overview");
205 //m_overView = new CustomTrackView(NULL, NULL, this);
206 //overviewDock->setWidget(m_overView);
207 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
210 //tabifyDockWidget(projectListDock, effectListDock);
211 tabifyDockWidget(projectListDock, effectStackDock);
212 tabifyDockWidget(projectListDock, transitionConfigDock);
213 //tabifyDockWidget(projectListDock, undoViewDock);
216 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
217 tabifyDockWidget(clipMonitorDock, recMonitorDock);
218 setCentralWidget(m_timelineArea);
222 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
223 guiFactory()->addClient(sp);*/
226 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
228 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
229 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
230 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)));
232 // build effects menus
234 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
236 QStringList effectInfo;
237 QMap<QString, QStringList> effectsList;
238 for (int ix = 0; ix < videoEffects.count(); ix++) {
239 effectInfo = videoEffects.effectIdInfo(ix);
240 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
243 foreach(const QStringList &value, effectsList) {
244 action = new QAction(value.at(0), this);
245 action->setData(value);
246 videoEffectsMenu->addAction(action);
249 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
253 for (int ix = 0; ix < audioEffects.count(); ix++) {
254 effectInfo = audioEffects.effectIdInfo(ix);
255 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
258 foreach(const QStringList &value, effectsList) {
259 action = new QAction(value.at(0), this);
260 action->setData(value);
261 audioEffectsMenu->addAction(action);
264 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
266 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
267 else m_customEffectsMenu->setEnabled(true);
270 for (int ix = 0; ix < customEffects.count(); ix++) {
271 effectInfo = customEffects.effectIdInfo(ix);
272 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
275 foreach(const QStringList &value, effectsList) {
276 action = new QAction(value.at(0), this);
277 action->setData(value);
278 m_customEffectsMenu->addAction(action);
281 QMenu *newEffect = new QMenu(this);
282 newEffect->addMenu(videoEffectsMenu);
283 newEffect->addMenu(audioEffectsMenu);
284 newEffect->addMenu(m_customEffectsMenu);
285 effectStack->setMenu(newEffect);
288 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
289 const QList<QAction *> viewActions = createPopupMenu()->actions();
290 viewMenu->insertActions(NULL, viewActions);
292 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
293 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
294 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
296 m_timelineContextMenu = new QMenu(this);
297 m_timelineContextClipMenu = new QMenu(this);
298 m_timelineContextTransitionMenu = new QMenu(this);
301 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
302 QStringList effects = transitions.effectNames();
305 for (int ix = 0; ix < transitions.count(); ix++) {
306 effectInfo = transitions.effectIdInfo(ix);
307 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
309 foreach(const QStringList &value, effectsList) {
310 action = new QAction(value.at(0), this);
311 action->setData(value);
312 transitionsMenu->addAction(action);
314 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
316 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
317 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
318 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
320 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
321 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
322 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
323 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
324 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
326 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
327 m_timelineContextClipMenu->addMenu(markersMenu);
328 m_timelineContextClipMenu->addMenu(transitionsMenu);
329 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
330 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
331 //TODO: re-enable custom effects menu when it is implemented
332 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
334 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
335 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
337 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
339 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
340 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
341 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
342 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
343 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
344 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
346 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
347 slotConnectMonitors();
349 // Open or create a file. Command line argument passed in Url has
350 // precedence, then "openlastproject", then just a plain empty file.
351 // If opening Url fails, openlastproject will _not_ be used.
352 if (!Url.isEmpty()) {
355 if (KdenliveSettings::openlastproject()) {
359 if (m_timelineArea->count() == 0) {
363 #ifndef NO_JOGSHUTTLE
364 activateShuttleDevice();
365 #endif /* NO_JOGSHUTTLE */
366 projectListDock->raise();
369 void MainWindow::queryQuit() {
370 kDebug() << "----- SAVING CONFUIG";
371 if (queryClose()) kapp->quit();
375 bool MainWindow::queryClose() {
377 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
378 if (m_activeDocument && m_activeDocument->isModified()) {
379 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
380 case KMessageBox::Yes :
381 // save document here. If saving fails, return false;
383 case KMessageBox::No :
393 void MainWindow::loadPlugins() {
394 foreach(QObject *plugin, QPluginLoader::staticInstances())
395 populateMenus(plugin);
397 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
399 filters << "libkdenlive*";
400 foreach(const QString &folder, directories) {
401 kDebug() << "// PARSING FIOLER: " << folder;
402 QDir pluginsDir(folder);
403 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
404 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
405 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
406 QObject *plugin = loader.instance();
408 populateMenus(plugin);
409 m_pluginFileNames += fileName;
410 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
416 void MainWindow::populateMenus(QObject *plugin) {
417 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
418 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
420 addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
424 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
425 QMenu *menu, const char *member,
426 QActionGroup *actionGroup) {
427 kDebug() << "// ADD to MENU" << texts;
428 foreach(const QString &text, texts) {
429 QAction *action = new QAction(text, plugin);
430 action->setData(text);
431 connect(action, SIGNAL(triggered()), this, member);
432 menu->addAction(action);
435 action->setCheckable(true);
436 actionGroup->addAction(action);
441 void MainWindow::aboutPlugins() {
442 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
447 void MainWindow::generateClip() {
448 QAction *action = qobject_cast<QAction *>(sender());
449 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
451 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
452 if (!clipUrl.isEmpty()) {
453 m_projectList->slotAddClip(clipUrl);
457 void MainWindow::saveProperties(KConfig*) {
458 // save properties here,used by session management
463 void MainWindow::readProperties(KConfig *config) {
464 // read properties here,used by session management
465 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
466 openFile(KUrl(Lastproject));
469 void MainWindow::slotReloadEffects() {
470 initEffects::parseCustomEffectsFile();
471 m_customEffectsMenu->clear();
472 const QStringList effects = customEffects.effectNames();
474 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
475 else m_customEffectsMenu->setEnabled(true);
477 foreach(const QString &name, effects) {
478 action = new QAction(name, this);
479 action->setData(name);
480 m_customEffectsMenu->addAction(action);
482 m_effectList->reloadEffectList();
485 #ifndef NO_JOGSHUTTLE
486 void MainWindow::activateShuttleDevice() {
487 if (m_jogProcess) delete m_jogProcess;
489 if (KdenliveSettings::enableshuttle() == false) return;
490 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
491 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
492 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
493 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
494 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
495 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
496 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
499 void MainWindow::slotShuttleButton(int code) {
502 slotShuttleAction(KdenliveSettings::shuttle1());
505 slotShuttleAction(KdenliveSettings::shuttle2());
508 slotShuttleAction(KdenliveSettings::shuttle3());
511 slotShuttleAction(KdenliveSettings::shuttle4());
514 slotShuttleAction(KdenliveSettings::shuttle5());
519 void MainWindow::slotShuttleAction(int code) {
524 m_monitorManager->slotPlay();
527 m_monitorManager->slotPlay();
531 #endif /* NO_JOGSHUTTLE */
533 void MainWindow::configureNotifications() {
534 KNotifyConfigWidget::configure(this);
537 void MainWindow::slotFullScreen() {
538 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
541 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
542 if (!m_activeDocument) return;
543 if (effect.isNull()) {
544 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
547 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
548 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
551 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
552 if (clipMonitor) clipMonitorDock->raise();
553 else projectMonitorDock->raise();
556 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
557 if (!m_activeDocument) return;
558 m_activeDocument->setProducerDuration(id, duration);
561 void MainWindow::slotConnectMonitors() {
563 m_projectList->setRenderer(m_projectMonitor->render);
564 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
565 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
566 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
567 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
568 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)));
570 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
572 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
574 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
575 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
577 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
578 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
581 void MainWindow::slotAdjustClipMonitor() {
582 clipMonitorDock->updateGeometry();
583 clipMonitorDock->adjustSize();
584 m_clipMonitor->resetSize();
587 void MainWindow::slotAdjustProjectMonitor() {
588 projectMonitorDock->updateGeometry();
589 projectMonitorDock->adjustSize();
590 m_projectMonitor->resetSize();
593 void MainWindow::setupActions() {
595 KActionCollection* collection = actionCollection();
596 m_timecodeFormat = new KComboBox(this);
597 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
598 m_timecodeFormat->addItem(i18n("Frames"));
600 statusProgressBar = new QProgressBar(this);
601 statusProgressBar->setMinimum(0);
602 statusProgressBar->setMaximum(100);
603 statusProgressBar->setMaximumWidth(150);
604 statusProgressBar->setVisible(false);
606 QWidget *w = new QWidget;
608 QHBoxLayout *layout = new QHBoxLayout;
609 w->setLayout(layout);
610 layout->setContentsMargins(5, 0, 5, 0);
611 QToolBar *toolbar = new QToolBar("statusToolBar", this);
614 m_toolGroup = new QActionGroup(this);
616 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;}";
618 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
619 toolbar->addAction(m_buttonSelectTool);
620 m_buttonSelectTool->setCheckable(true);
621 m_buttonSelectTool->setChecked(true);
623 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
624 toolbar->addAction(m_buttonRazorTool);
625 m_buttonRazorTool->setCheckable(true);
626 m_buttonRazorTool->setChecked(false);
628 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
629 toolbar->addAction(m_buttonSpacerTool);
630 m_buttonSpacerTool->setCheckable(true);
631 m_buttonSpacerTool->setChecked(false);
633 m_toolGroup->addAction(m_buttonSelectTool);
634 m_toolGroup->addAction(m_buttonRazorTool);
635 m_toolGroup->addAction(m_buttonSpacerTool);
636 m_toolGroup->setExclusive(true);
637 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
639 QWidget * actionWidget;
640 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
641 actionWidget->setMaximumWidth(24);
642 actionWidget->setMinimumHeight(17);
644 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
645 actionWidget->setMaximumWidth(24);
646 actionWidget->setMinimumHeight(17);
648 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
649 actionWidget->setMaximumWidth(24);
650 actionWidget->setMinimumHeight(17);
652 toolbar->setStyleSheet(style1);
653 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
655 toolbar->addSeparator();
656 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
657 toolbar->addAction(m_buttonFitZoom);
658 m_buttonFitZoom->setCheckable(false);
659 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
661 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
662 actionWidget->setMaximumWidth(24);
663 actionWidget->setMinimumHeight(17);
665 m_zoomSlider = new QSlider(Qt::Horizontal, this);
666 m_zoomSlider->setMaximum(13);
667 m_zoomSlider->setPageStep(1);
669 m_zoomSlider->setMaximumWidth(150);
670 m_zoomSlider->setMinimumWidth(100);
672 const int contentHeight = QFontMetrics(w->font()).height() + 8;
674 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
675 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
677 m_zoomSlider->setStyleSheet(style);
679 //m_zoomSlider->height() + 5;
680 statusBar()->setMinimumHeight(contentHeight);
683 toolbar->addWidget(m_zoomSlider);
685 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
686 toolbar->addAction(m_buttonVideoThumbs);
687 m_buttonVideoThumbs->setCheckable(true);
688 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
689 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
691 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
692 toolbar->addAction(m_buttonAudioThumbs);
693 m_buttonAudioThumbs->setCheckable(true);
694 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
695 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
697 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
698 toolbar->addAction(m_buttonShowMarkers);
699 m_buttonShowMarkers->setCheckable(true);
700 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
701 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
703 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
704 toolbar->addAction(m_buttonSnap);
705 m_buttonSnap->setCheckable(true);
706 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
707 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
708 layout->addWidget(toolbar);
711 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
712 actionWidget->setMaximumWidth(24);
713 actionWidget->setMinimumHeight(17);
715 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
716 actionWidget->setMaximumWidth(24);
717 actionWidget->setMinimumHeight(17);
719 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
720 actionWidget->setMaximumWidth(24);
721 actionWidget->setMinimumHeight(17);
723 actionWidget = toolbar->widgetForAction(m_buttonSnap);
724 actionWidget->setMaximumWidth(24);
725 actionWidget->setMinimumHeight(17);
727 m_messageLabel = new StatusBarMessageLabel(this);
728 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
730 statusBar()->addWidget(m_messageLabel, 10);
731 statusBar()->addWidget(statusProgressBar, 0);
732 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
733 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
734 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
735 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
736 m_messageLabel->hide();
738 collection->addAction("select_tool", m_buttonSelectTool);
739 collection->addAction("razor_tool", m_buttonRazorTool);
740 collection->addAction("spacer_tool", m_buttonSpacerTool);
742 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
743 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
744 collection->addAction("show_markers", m_buttonShowMarkers);
745 collection->addAction("snap", m_buttonSnap);
746 collection->addAction("zoom_fit", m_buttonFitZoom);
748 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
749 collection->addAction("zoom_in", zoomIn);
750 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
751 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
753 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
754 collection->addAction("zoom_out", zoomOut);
755 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
756 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
758 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
759 collection->addAction("project_find", m_projectSearch);
760 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
761 m_projectSearch->setShortcut(Qt::Key_Slash);
763 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
764 collection->addAction("project_find_next", m_projectSearchNext);
765 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
766 m_projectSearchNext->setShortcut(Qt::Key_F3);
767 m_projectSearchNext->setEnabled(false);
769 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
770 collection->addAction("manage_profiles", profilesAction);
771 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
773 KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
775 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
777 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
779 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
780 collection->addAction("run_wizard", wizAction);
781 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
783 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
784 collection->addAction("project_settings", projectAction);
785 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
787 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
788 collection->addAction("project_render", projectRender);
789 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
790 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
792 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
793 KShortcut playShortcut;
794 playShortcut.setPrimary(Qt::Key_Space);
795 playShortcut.setAlternate(Qt::Key_K);
796 monitorPlay->setShortcut(playShortcut);
797 collection->addAction("monitor_play", monitorPlay);
798 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
800 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
801 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
802 collection->addAction("monitor_play_zone", m_playZone);
803 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
805 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
806 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
807 collection->addAction("monitor_loop_zone", m_loopZone);
808 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
810 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("Dvd Wizard"), this);
811 collection->addAction("dvd_wizard", dvdWizard);
812 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
814 KAction *markIn = collection->addAction("mark_in");
815 markIn->setText(i18n("Set In Point"));
816 markIn->setShortcut(Qt::Key_I);
817 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
819 KAction *markOut = collection->addAction("mark_out");
820 markOut->setText(i18n("Set Out Point"));
821 markOut->setShortcut(Qt::Key_O);
822 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
824 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
825 monitorSeekBackward->setShortcut(Qt::Key_J);
826 collection->addAction("monitor_seek_backward", monitorSeekBackward);
827 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
829 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
830 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
831 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
832 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
834 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
835 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
836 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
837 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
839 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
840 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
841 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
842 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
844 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
845 monitorSeekForward->setShortcut(Qt::Key_L);
846 collection->addAction("monitor_seek_forward", monitorSeekForward);
847 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
849 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
850 clipStart->setShortcut(Qt::Key_Home);
851 collection->addAction("seek_clip_start", clipStart);
852 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
854 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
855 clipEnd->setShortcut(Qt::Key_End);
856 collection->addAction("seek_clip_end", clipEnd);
857 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
859 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
860 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
861 collection->addAction("seek_start", projectStart);
862 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
864 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
865 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
866 collection->addAction("seek_end", projectEnd);
867 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
869 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
870 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
871 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
872 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
874 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
875 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
876 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
877 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
879 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
880 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
881 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
882 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
884 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
885 deleteTimelineClip->setShortcut(Qt::Key_Delete);
886 collection->addAction("delete_timeline_clip", deleteTimelineClip);
887 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
889 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
890 collection->addAction("change_clip_speed", editTimelineClipSpeed);
891 editTimelineClipSpeed->setData("change_speed");
892 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
894 KAction *stickTransition = collection->addAction("auto_transition");
895 stickTransition->setData(QString("auto"));
896 stickTransition->setCheckable(true);
897 stickTransition->setEnabled(false);
898 stickTransition->setText(i18n("Automatic Transition"));
899 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
901 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
902 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
903 collection->addAction("cut_timeline_clip", cutTimelineClip);
904 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
906 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
907 collection->addAction("add_clip_marker", addClipMarker);
908 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
910 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
911 collection->addAction("delete_clip_marker", deleteClipMarker);
912 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
914 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
915 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
916 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
918 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
919 collection->addAction("edit_clip_marker", editClipMarker);
920 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
922 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
923 collection->addAction("insert_space", insertSpace);
924 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
926 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
927 collection->addAction("delete_space", removeSpace);
928 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
930 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
931 collection->addAction("insert_track", insertTrack);
932 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
934 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
935 collection->addAction("delete_track", deleteTrack);
936 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
938 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
939 collection->addAction("change_track", changeTrack);
940 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
942 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
943 collection->addAction("add_guide", addGuide);
944 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
946 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
947 collection->addAction("delete_guide", delGuide);
948 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
950 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
951 collection->addAction("edit_guide", editGuide);
952 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
954 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
955 collection->addAction("delete_all_guides", delAllGuides);
956 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
958 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
959 collection->addAction("paste_effects", pasteEffects);
960 pasteEffects->setData("paste_effects");
961 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
963 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
965 KStandardAction::quit(this, SLOT(queryQuit()), collection);
967 KStandardAction::open(this, SLOT(openFile()), collection);
969 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
971 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
973 KStandardAction::openNew(this, SLOT(newFile()), collection);
975 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
977 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
979 KStandardAction::copy(this, SLOT(slotCopy()), collection);
981 KStandardAction::paste(this, SLOT(slotPaste()), collection);
983 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
984 undo->setEnabled(false);
985 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
987 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
988 redo->setEnabled(false);
989 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
991 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
993 connect(collection, SIGNAL(actionHovered(QAction*)),
994 this, SLOT(slotDisplayActionMessage(QAction*)));
997 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
998 collection->addAction("add_clip", addClip);
999 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1001 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1002 collection->addAction("add_color_clip", addColorClip);
1003 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1005 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1006 collection->addAction("add_slide_clip", addSlideClip);
1007 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1009 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1010 collection->addAction("add_text_clip", addTitleClip);
1011 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1013 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1014 collection->addAction("add_folder", addFolderButton);
1015 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1017 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1018 collection->addAction("clip_properties", clipProperties);
1019 clipProperties->setData("clip_properties");
1020 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1021 clipProperties->setEnabled(false);
1023 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1024 collection->addAction("edit_clip", openClip);
1025 openClip->setData("edit_clip");
1026 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1027 openClip->setEnabled(false);
1029 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1030 collection->addAction("delete_clip", deleteClip);
1031 deleteClip->setData("delete_clip");
1032 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1033 deleteClip->setEnabled(false);
1035 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1036 collection->addAction("reload_clip", reloadClip);
1037 reloadClip->setData("reload_clip");
1038 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1039 reloadClip->setEnabled(false);
1041 QMenu *addClips = new QMenu();
1042 addClips->addAction(addClip);
1043 addClips->addAction(addColorClip);
1044 addClips->addAction(addSlideClip);
1045 addClips->addAction(addTitleClip);
1046 addClips->addAction(addFolderButton);
1048 addClips->addAction(reloadClip);
1049 addClips->addAction(clipProperties);
1050 addClips->addAction(openClip);
1051 addClips->addAction(deleteClip);
1052 m_projectList->setupMenu(addClips, addClip);
1054 //connect(collection, SIGNAL( clearStatusText() ),
1055 //statusBar(), SLOT( clear() ) );
1058 void MainWindow::slotDisplayActionMessage(QAction *a) {
1059 statusBar()->showMessage(a->data().toString(), 3000);
1062 void MainWindow::saveOptions() {
1063 KdenliveSettings::self()->writeConfig();
1064 KSharedConfigPtr config = KGlobal::config();
1065 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1066 KConfigGroup treecolumns(config, "Project Tree");
1067 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1071 void MainWindow::readOptions() {
1072 KSharedConfigPtr config = KGlobal::config();
1073 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1074 KConfigGroup initialGroup(config, "version");
1075 if (!initialGroup.exists()) {
1076 // this is our first run, show Wizard
1077 Wizard *w = new Wizard(this);
1078 if (w->exec() == QDialog::Accepted && w->isOk()) {
1079 w->adjustSettings();
1080 initialGroup.writeEntry("version", "0.7");
1085 } else if (initialGroup.readEntry("version") == "0.7") {
1086 //Add new settings from 0.7.1
1087 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1088 QString path = QDir::homePath() + "/kdenlive";
1089 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERRORÂ CREATINGÂ PROJECTÂ FOLDER: " << path;
1090 KdenliveSettings::setDefaultprojectfolder(path);
1093 KConfigGroup treecolumns(config, "Project Tree");
1094 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1095 if (!state.isEmpty())
1096 m_projectList->setHeaderInfo(state);
1099 void MainWindow::slotRunWizard() {
1100 Wizard *w = new Wizard(this);
1101 if (w->exec() == QDialog::Accepted && w->isOk()) {
1102 w->adjustSettings();
1107 void MainWindow::newFile(bool showProjectSettings) {
1108 QString profileName;
1110 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1111 if (!showProjectSettings && m_timelineArea->count() == 0) {
1112 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1113 profileName = KdenliveSettings::default_profile();
1115 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1116 if (w->exec() != QDialog::Accepted) return;
1117 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1118 profileName = w->selectedProfile();
1119 projectFolder = w->selectedFolder();
1120 projectTracks = w->tracks();
1123 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1124 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1125 TrackView *trackView = new TrackView(doc, this);
1126 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1127 if (m_timelineArea->count() == 1) {
1128 connectDocumentInfo(doc);
1129 connectDocument(trackView, doc);
1130 } else m_timelineArea->setTabBarHidden(false);
1131 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1134 void MainWindow::activateDocument() {
1135 if (m_timelineArea->currentWidget() == NULL) return;
1136 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1137 KdenliveDoc *currentDoc = currentTab->document();
1138 connectDocumentInfo(currentDoc);
1139 connectDocument(currentTab, currentDoc);
1142 void MainWindow::closeCurrentDocument() {
1143 QWidget *w = m_timelineArea->currentWidget();
1145 // closing current document
1146 int ix = m_timelineArea->currentIndex() + 1;
1147 if (ix == m_timelineArea->count()) ix = 0;
1148 m_timelineArea->setCurrentIndex(ix);
1149 TrackView *tabToClose = (TrackView *) w;
1150 KdenliveDoc *docToClose = tabToClose->document();
1151 if (docToClose && docToClose->isModified()) {
1152 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1153 case KMessageBox::Yes :
1154 // save document here. If saving fails, return false;
1157 case KMessageBox::Cancel :
1163 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1164 if (m_timelineArea->count() == 1) {
1165 m_timelineArea->setTabBarHidden(true);
1166 m_closeAction->setEnabled(false);
1170 if (m_timelineArea->count() == 0) {
1171 m_activeDocument = NULL;
1172 effectStack->clear();
1173 transitionConfig->slotTransitionItemSelected(NULL, false);
1177 bool MainWindow::saveFileAs(const QString &outputFileName) {
1178 QString currentSceneList;
1179 if (KdenliveSettings::dropbframes()) {
1180 KdenliveSettings::setDropbframes(false);
1181 m_activeDocument->clipManager()->updatePreviewSettings();
1182 currentSceneList = m_projectMonitor->sceneList();
1183 KdenliveSettings::setDropbframes(true);
1184 m_activeDocument->clipManager()->updatePreviewSettings();
1185 } else currentSceneList = m_projectMonitor->sceneList();
1187 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1190 // Save timeline thumbnails
1191 m_activeTimeline->projectView()->saveThumbnails();
1192 m_activeDocument->setUrl(KUrl(outputFileName));
1193 if (m_activeDocument->m_autosave == NULL) {
1194 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1195 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1196 setCaption(m_activeDocument->description());
1197 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1198 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1199 m_activeDocument->setModified(false);
1200 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1204 bool MainWindow::saveFileAs() {
1205 // Check that the Kdenlive mime type is correctly installed
1206 QString mimetype = "application/x-kdenlive";
1207 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1208 if (!mime) mimetype = "*.kdenlive";
1210 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1211 if (outputFile.isEmpty()) return false;
1212 if (QFile::exists(outputFile)) {
1213 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1215 return saveFileAs(outputFile);
1218 bool MainWindow::saveFile() {
1219 if (!m_activeDocument) return true;
1220 if (m_activeDocument->url().isEmpty()) {
1221 return saveFileAs();
1223 bool result = saveFileAs(m_activeDocument->url().path());
1224 m_activeDocument->m_autosave->resize(0);
1229 void MainWindow::openFile() {
1230 // Check that the Kdenlive mime type is correctly installed
1231 QString mimetype = "application/x-kdenlive";
1232 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1233 if (!mime) mimetype = "*.kdenlive";
1235 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1236 if (url.isEmpty()) return;
1237 m_fileOpenRecent->addUrl(url);
1241 void MainWindow::openLastFile() {
1242 KSharedConfigPtr config = KGlobal::config();
1243 KUrl::List urls = m_fileOpenRecent->urls();
1244 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1245 if (urls.isEmpty()) newFile(false);
1246 else openFile(urls.last());
1249 void MainWindow::openFile(const KUrl &url) {
1250 // Check if the document is already opened
1251 const int ct = m_timelineArea->count();
1252 bool isOpened = false;
1254 for (i = 0; i < ct; i++) {
1255 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1256 KdenliveDoc *doc = tab->document();
1257 if (doc->url() == url) {
1263 m_timelineArea->setCurrentIndex(i);
1267 // Check for backup file
1268 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1269 if (!staleFiles.isEmpty()) {
1270 if (KMessageBox::questionYesNo(this,
1271 i18n("Auto-saved files exist. Do you want to recover them now?"),
1272 i18n("File Recovery"),
1273 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1274 recoverFiles(staleFiles);
1277 // remove the stale files
1278 foreach(KAutoSaveFile *stale, staleFiles) {
1279 stale->open(QIODevice::ReadWrite);
1284 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1285 doOpenFile(url, NULL);
1288 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1289 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1290 if (stale == NULL) {
1291 stale = new KAutoSaveFile(url, doc);
1292 doc->m_autosave = stale;
1294 doc->m_autosave = stale;
1295 doc->setUrl(stale->managedFile());
1296 doc->setModified(true);
1297 stale->setParent(doc);
1299 connectDocumentInfo(doc);
1300 TrackView *trackView = new TrackView(doc, this);
1301 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1302 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1303 trackView->setDuration(trackView->duration());
1304 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1306 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1307 slotGotProgressInfo(QString(), -1);
1308 m_clipMonitor->refreshMonitor(true);
1309 m_projectMonitor->adjustRulerSize(trackView->duration());
1310 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1313 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1314 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1315 foreach(KAutoSaveFile *stale, staleFiles) {
1316 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1317 // show an error message; we could not steal the lockfile
1318 // maybe another application got to the file before us?
1322 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1323 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1324 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1325 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1330 void MainWindow::parseProfiles(const QString &mltPath) {
1331 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1333 //KdenliveSettings::setDefaulttmpfolder();
1334 if (!mltPath.isEmpty()) {
1335 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1336 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1339 if (KdenliveSettings::mltpath().isEmpty()) {
1340 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1342 if (KdenliveSettings::rendererpath().isEmpty()) {
1343 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1344 if (!QFile::exists(inigoPath))
1345 inigoPath = KStandardDirs::findExe("inigo");
1346 else KdenliveSettings::setRendererpath(inigoPath);
1348 QStringList profilesFilter;
1349 profilesFilter << "*";
1350 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1352 if (profilesList.isEmpty()) {
1353 // Cannot find MLT path, try finding inigo
1354 QString profilePath = KdenliveSettings::rendererpath();
1355 if (!profilePath.isEmpty()) {
1356 profilePath = profilePath.section('/', 0, -3);
1357 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1358 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1361 if (profilesList.isEmpty()) {
1362 // Cannot find the MLT profiles, ask for location
1363 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1364 getUrl->fileDialog()->setMode(KFile::Directory);
1365 if (getUrl->exec() == QDialog::Rejected) {
1368 KUrl mltPath = getUrl->selectedUrl();
1370 if (mltPath.isEmpty()) ::exit(0);
1371 KdenliveSettings::setMltpath(mltPath.path());
1372 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1376 if (KdenliveSettings::rendererpath().isEmpty()) {
1377 // Cannot find the MLT inigo renderer, ask for location
1378 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1379 if (getUrl->exec() == QDialog::Rejected) {
1382 KUrl rendererPath = getUrl->selectedUrl();
1384 if (rendererPath.isEmpty()) ::exit(0);
1385 KdenliveSettings::setRendererpath(rendererPath.path());
1388 kDebug() << "RESULTINGÂ MLT PATH: " << KdenliveSettings::mltpath();
1390 // Parse MLT profiles to build a list of available video formats
1391 if (profilesList.isEmpty()) parseProfiles();
1395 void MainWindow::slotEditProfiles() {
1396 ProfilesDialog *w = new ProfilesDialog;
1397 if (w->exec() == QDialog::Accepted) {
1398 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1399 if (d) d->checkProfile();
1404 void MainWindow::slotEditProjectSettings() {
1405 QPoint p = m_activeDocument->getTracksCount();
1406 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1408 if (w->exec() == QDialog::Accepted) {
1409 QString profile = w->selectedProfile();
1410 m_activeDocument->setProjectFolder(w->selectedFolder());
1411 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path());
1412 if (m_activeDocument->profilePath() != profile) {
1413 // Profile was changed
1414 m_activeDocument->setProfilePath(profile);
1415 KdenliveSettings::setCurrent_profile(profile);
1416 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1417 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1418 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1419 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1420 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1421 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1423 // We need to desactivate & reactivate monitors to get a refresh
1424 m_monitorManager->switchMonitors();
1430 void MainWindow::slotRenderProject() {
1431 if (!m_renderWidget) {
1432 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path() : KdenliveSettings::defaultprojectfolder();
1433 m_renderWidget = new RenderWidget(projectfolder, this);
1434 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 &)));
1435 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1436 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1437 if (m_activeDocument) {
1438 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1439 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1442 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1443 if (currentTab) m_renderWidget->setTimeline(currentTab);
1444 m_renderWidget->setDocument(m_activeDocument);*/
1445 m_renderWidget->show();
1448 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) {
1449 kDebug() << "// SCRIPT EXPORT: " << scriptExport;
1450 if (dest.isEmpty()) return;
1453 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1454 if (currentTab && zoneOnly) {
1455 in = currentTab->inPoint();
1456 out = currentTab->outPoint();
1458 KTemporaryFile temp;
1459 temp.setAutoRemove(false);
1460 temp.setSuffix(".westley");
1461 if (!scriptExport.isEmpty() || temp.open()) {
1462 if (KdenliveSettings::dropbframes()) {
1463 KdenliveSettings::setDropbframes(false);
1464 m_activeDocument->clipManager()->updatePreviewSettings();
1465 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1466 else m_projectMonitor->saveSceneList(temp.fileName());
1467 KdenliveSettings::setDropbframes(true);
1468 m_activeDocument->clipManager()->updatePreviewSettings();
1470 if (!scriptExport.isEmpty()) m_projectMonitor->saveSceneList(scriptExport + ".westley");
1471 else m_projectMonitor->saveSceneList(temp.fileName());
1475 if (scriptExport.isEmpty()) args << "-erase";
1476 if (KdenliveSettings::usekuiserver()) args << "-kuiserver";
1477 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1478 else if (guideStart != -1) {
1479 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1481 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1482 QString videoPlayer = "-";
1484 videoPlayer = KdenliveSettings::defaultplayerapp();
1485 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."));
1487 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1488 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1489 setRenderingProgress(dest, -3);
1492 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1494 for (int i = 0; i < avformat_args.count(); i++) {
1495 if (avformat_args.at(i).startsWith("profile=")) {
1496 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1501 if (resizeProfile) {
1502 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1503 if (scriptExport.isEmpty()) args << "consumer:" + temp.fileName();
1504 else args << "consumer:$SOURCE";
1506 if (scriptExport.isEmpty()) args << temp.fileName();
1507 else args << "$SOURCE";
1509 if (scriptExport.isEmpty()) args << dest;
1510 else args << "$TARGET";
1511 args << avformat_args;
1512 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1513 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1514 if (scriptExport.isEmpty()) {
1515 QProcess::startDetached(renderer, args);
1516 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1518 // Generate script file
1519 QFile file(scriptExport);
1520 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1521 m_messageLabel->setMessage(i18n("Cannot write to file %1", scriptExport), ErrorMessage);
1525 QTextStream out(&file);
1526 out << "#! /bin/sh" << "\n" << "\n";
1527 out << "SOURCE=" << "\"" + scriptExport + ".westley\"" << "\n";
1528 out << "TARGET=" << "\"" + dest + "\"" << "\n";
1529 out << renderer << " " << args.join(" ") << "\n" << "\n";
1531 QFile::setPermissions(scriptExport, file.permissions() | QFile::ExeUser);
1536 void MainWindow::setRenderingProgress(const QString &url, int progress) {
1537 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1540 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error) {
1541 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1544 void MainWindow::slotUpdateMousePosition(int pos) {
1545 if (m_activeDocument)
1546 switch (m_timecodeFormat->currentIndex()) {
1548 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1551 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1555 void MainWindow::slotUpdateDocumentState(bool modified) {
1556 if (!m_activeDocument) return;
1557 setCaption(m_activeDocument->description(), modified);
1558 m_saveAction->setEnabled(modified);
1560 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1561 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1563 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1564 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1568 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1569 if (m_activeDocument) {
1570 if (m_activeDocument == doc) return;
1571 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1573 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1576 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1577 //m_projectMonitor->stop();
1578 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1579 kDebug() << "/////////////////// CONNECTINGÂ DOC TOÂ PROJECTÂ VIEW ////////////////";
1580 if (m_activeDocument) {
1581 if (m_activeDocument == doc) return;
1582 if (m_activeTimeline) {
1583 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1584 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1585 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1586 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1589 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1590 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1591 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1592 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1593 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1594 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1595 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1596 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1597 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1598 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1599 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1600 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1601 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1602 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1603 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1604 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1605 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1606 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1607 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1608 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1609 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1610 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1611 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1612 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1613 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1614 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1615 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1616 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1617 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1618 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1619 effectStack->clear();
1621 //m_activeDocument->setRenderer(NULL);
1622 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1623 m_clipMonitor->stop();
1625 KdenliveSettings::setCurrent_profile(doc->profilePath());
1626 KdenliveSettings::setProject_fps(doc->fps());
1627 m_monitorManager->resetProfiles(doc->timecode());
1628 m_projectList->setDocument(doc);
1629 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1630 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1631 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1632 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1633 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1636 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1637 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1638 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1639 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1640 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1641 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1642 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1643 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1644 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1645 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1646 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1647 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1648 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1650 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1651 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1652 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1655 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1656 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1657 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1658 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1659 m_zoomSlider->setValue(doc->zoom());
1660 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1661 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1662 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1663 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1665 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1668 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1669 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1670 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1671 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1672 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1673 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1674 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1675 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1677 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1678 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1679 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1681 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1682 m_activeTimeline = trackView;
1683 if (m_renderWidget) {
1684 m_renderWidget->setProfile(doc->mltProfile());
1685 m_renderWidget->setDocumentPath(doc->projectFolder().path());
1687 //doc->setRenderer(m_projectMonitor->render);
1688 m_commandStack->setActiveStack(doc->commandStack());
1689 KdenliveSettings::setProject_display_ratio(doc->dar());
1690 m_projectList->updateAllClips();
1691 //doc->clipManager()->checkAudioThumbs();
1693 //m_overView->setScene(trackView->projectScene());
1694 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1695 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1697 setCaption(doc->description(), doc->isModified());
1698 m_saveAction->setEnabled(doc->isModified());
1699 m_activeDocument = doc;
1700 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1702 // set tool to select tool
1703 m_buttonSelectTool->setChecked(true);
1706 void MainWindow::slotZoneMoved(int start, int end) {
1707 m_activeDocument->setZone(start, end);
1708 m_projectMonitor->slotZoneMoved(start, end);
1711 void MainWindow::slotGuidesUpdated() {
1712 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1715 void MainWindow::slotPreferences(int page, int option) {
1716 //An instance of your dialog could be already created and could be
1717 // cached, in which case you want to display the cached dialog
1718 // instead of creating another one
1719 if (KConfigDialog::showDialog("settings")) {
1720 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1721 if (page != -1) d->showPage(page, option);
1725 // KConfigDialog didn't find an instance of this dialog, so lets
1727 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1728 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1729 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1730 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1731 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1733 if (page != -1) dialog->showPage(page, option);
1736 void MainWindow::slotUpdatePreviewSettings() {
1737 if (m_activeDocument) {
1738 m_clipMonitor->slotSetXml(NULL, 0);
1739 m_activeDocument->updatePreviewSettings();
1743 void MainWindow::updateConfiguration() {
1744 //TODO: we should apply settings to all projects, not only the current one
1745 if (m_activeTimeline) {
1746 m_activeTimeline->refresh();
1747 m_activeTimeline->projectView()->checkAutoScroll();
1748 m_activeTimeline->projectView()->checkTrackHeight();
1749 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1751 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1752 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1753 #ifndef NO_JOGSHUTTLE
1754 activateShuttleDevice();
1755 #endif /* NO_JOGSHUTTLE */
1760 void MainWindow::slotSwitchVideoThumbs() {
1761 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1762 if (m_activeTimeline) {
1763 m_activeTimeline->projectView()->slotUpdateAllThumbs();
1765 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1768 void MainWindow::slotSwitchAudioThumbs() {
1769 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1770 if (m_activeTimeline) {
1771 m_activeTimeline->refresh();
1772 m_activeTimeline->projectView()->checkAutoScroll();
1773 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1775 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1778 void MainWindow::slotSwitchMarkersComments() {
1779 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1780 if (m_activeTimeline) {
1781 m_activeTimeline->refresh();
1783 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1786 void MainWindow::slotSwitchSnap() {
1787 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1788 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1792 void MainWindow::slotDeleteTimelineClip() {
1793 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1794 else if (m_activeTimeline) {
1795 m_activeTimeline->projectView()->deleteSelectedClips();
1799 void MainWindow::slotChangeClipSpeed() {
1800 if (m_activeTimeline) {
1801 m_activeTimeline->projectView()->changeClipSpeed();
1805 void MainWindow::slotAddClipMarker() {
1806 DocClipBase *clip = NULL;
1808 if (m_projectMonitor->isActive()) {
1809 if (m_activeTimeline) {
1810 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1812 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1813 clip = item->baseClip();
1817 clip = m_clipMonitor->activeClip();
1818 pos = m_clipMonitor->position();
1821 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1824 QString id = clip->getId();
1825 CommentedTime marker(pos, i18n("Marker"));
1826 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1827 if (d.exec() == QDialog::Accepted) {
1828 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1830 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1833 void MainWindow::slotDeleteClipMarker() {
1834 DocClipBase *clip = NULL;
1836 if (m_projectMonitor->isActive()) {
1837 if (m_activeTimeline) {
1838 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1840 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1841 clip = item->baseClip();
1845 clip = m_clipMonitor->activeClip();
1846 pos = m_clipMonitor->position();
1849 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1853 QString id = clip->getId();
1854 QString comment = clip->markerComment(pos);
1855 if (comment.isEmpty()) {
1856 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1859 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1860 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1864 void MainWindow::slotDeleteAllClipMarkers() {
1865 DocClipBase *clip = NULL;
1866 if (m_projectMonitor->isActive()) {
1867 if (m_activeTimeline) {
1868 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1870 clip = item->baseClip();
1874 clip = m_clipMonitor->activeClip();
1877 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1880 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
1881 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1884 void MainWindow::slotEditClipMarker() {
1885 DocClipBase *clip = NULL;
1887 if (m_projectMonitor->isActive()) {
1888 if (m_activeTimeline) {
1889 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1891 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1892 clip = item->baseClip();
1896 clip = m_clipMonitor->activeClip();
1897 pos = m_clipMonitor->position();
1900 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1904 QString id = clip->getId();
1905 QString oldcomment = clip->markerComment(pos);
1906 if (oldcomment.isEmpty()) {
1907 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1911 CommentedTime marker(pos, oldcomment);
1912 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
1913 if (d.exec() == QDialog::Accepted) {
1914 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1915 if (d.newMarker().time() != pos) {
1916 // remove old marker
1917 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
1919 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1923 void MainWindow::slotAddGuide() {
1924 if (m_activeTimeline)
1925 m_activeTimeline->projectView()->slotAddGuide();
1928 void MainWindow::slotInsertSpace() {
1929 if (m_activeTimeline)
1930 m_activeTimeline->projectView()->slotInsertSpace();
1933 void MainWindow::slotRemoveSpace() {
1934 if (m_activeTimeline)
1935 m_activeTimeline->projectView()->slotRemoveSpace();
1938 void MainWindow::slotInsertTrack(int ix) {
1939 m_projectMonitor->activateMonitor();
1940 if (m_activeTimeline)
1941 m_activeTimeline->projectView()->slotInsertTrack(ix);
1944 void MainWindow::slotDeleteTrack(int ix) {
1945 m_projectMonitor->activateMonitor();
1946 if (m_activeTimeline)
1947 m_activeTimeline->projectView()->slotDeleteTrack(ix);
1950 void MainWindow::slotChangeTrack(int ix) {
1951 m_projectMonitor->activateMonitor();
1952 if (m_activeTimeline)
1953 m_activeTimeline->projectView()->slotChangeTrack(ix);
1956 void MainWindow::slotEditGuide() {
1957 if (m_activeTimeline)
1958 m_activeTimeline->projectView()->slotEditGuide();
1961 void MainWindow::slotDeleteGuide() {
1962 if (m_activeTimeline)
1963 m_activeTimeline->projectView()->slotDeleteGuide();
1966 void MainWindow::slotDeleteAllGuides() {
1967 if (m_activeTimeline)
1968 m_activeTimeline->projectView()->slotDeleteAllGuides();
1971 void MainWindow::slotCutTimelineClip() {
1972 if (m_activeTimeline) {
1973 m_activeTimeline->projectView()->cutSelectedClips();
1977 void MainWindow::slotAddProjectClip(KUrl url) {
1978 if (m_activeDocument)
1979 m_activeDocument->slotAddClipFile(url, QString());
1982 void MainWindow::slotAddTransition(QAction *result) {
1983 if (!result) return;
1984 QStringList info = result->data().toStringList();
1985 if (info.isEmpty()) return;
1986 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
1987 if (m_activeTimeline && !transition.isNull()) {
1988 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
1992 void MainWindow::slotAddVideoEffect(QAction *result) {
1993 if (!result) return;
1994 QStringList info = result->data().toStringList();
1995 if (info.isEmpty()) return;
1996 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1997 slotAddEffect(effect);
2000 void MainWindow::slotAddAudioEffect(QAction *result) {
2001 if (!result) return;
2002 QStringList info = result->data().toStringList();
2003 if (info.isEmpty()) return;
2004 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2005 slotAddEffect(effect);
2008 void MainWindow::slotAddCustomEffect(QAction *result) {
2009 if (!result) return;
2010 QStringList info = result->data().toStringList();
2011 if (info.isEmpty()) return;
2012 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2013 slotAddEffect(effect);
2016 void MainWindow::slotZoomIn() {
2017 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2020 void MainWindow::slotZoomOut() {
2021 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2024 void MainWindow::slotFitZoom() {
2025 if (m_activeTimeline) {
2026 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2030 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
2031 statusProgressBar->setValue(progress);
2032 if (progress >= 0) {
2033 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2034 statusProgressBar->setVisible(true);
2036 m_messageLabel->setMessage(QString(), DefaultMessage);
2037 statusProgressBar->setVisible(false);
2041 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
2042 if (clip->clipType() == TEXT) {
2043 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
2044 QString path = clip->getProperty("resource");
2045 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
2047 doc.setContent(clip->getProperty("xmldata"));
2048 dia_ui->setXml(doc);
2049 if (dia_ui->exec() == QDialog::Accepted) {
2050 QImage pix = dia_ui->renderedPixmap();
2052 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
2053 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
2054 QMap <QString, QString> newprops;
2055 newprops.insert("xmldata", dia_ui->xml().toString());
2056 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2057 m_activeDocument->commandStack()->push(command);
2058 m_clipMonitor->refreshMonitor(true);
2059 m_activeDocument->setModified(true);
2063 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2066 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2067 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2068 if (dia.exec() == QDialog::Accepted) {
2069 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2070 m_activeDocument->commandStack()->push(command);
2072 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2073 if (dia.needsTimelineRefresh()) {
2074 // update clip occurences in timeline
2075 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2080 void MainWindow::customEvent(QEvent* e) {
2081 if (e->type() == QEvent::User) {
2082 // The timeline playing position changed...
2083 kDebug() << "RECEIVEDÂ JOG EVEMNT!!!";
2086 void MainWindow::slotActivateEffectStackView() {
2087 effectStack->raiseWindow(effectStackDock);
2090 void MainWindow::slotActivateTransitionView(Transition *t) {
2091 if (t) transitionConfig->raiseWindow(transitionConfigDock);
2094 void MainWindow::slotSnapRewind() {
2095 if (m_projectMonitor->isActive()) {
2096 if (m_activeTimeline)
2097 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2098 } else m_clipMonitor->slotSeekToPreviousSnap();
2101 void MainWindow::slotSnapForward() {
2102 if (m_projectMonitor->isActive()) {
2103 if (m_activeTimeline)
2104 m_activeTimeline->projectView()->slotSeekToNextSnap();
2105 } else m_clipMonitor->slotSeekToNextSnap();
2108 void MainWindow::slotClipStart() {
2109 if (m_projectMonitor->isActive()) {
2110 if (m_activeTimeline)
2111 m_activeTimeline->projectView()->clipStart();
2115 void MainWindow::slotClipEnd() {
2116 if (m_projectMonitor->isActive()) {
2117 if (m_activeTimeline)
2118 m_activeTimeline->projectView()->clipEnd();
2122 void MainWindow::slotChangeTool(QAction * action) {
2123 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2124 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2125 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2128 void MainWindow::slotSetTool(PROJECTTOOL tool) {
2129 if (m_activeDocument && m_activeTimeline) {
2130 //m_activeDocument->setTool(tool);
2131 m_activeTimeline->projectView()->setTool(tool);
2135 void MainWindow::slotCopy() {
2136 if (!m_activeDocument || !m_activeTimeline) return;
2137 m_activeTimeline->projectView()->copyClip();
2140 void MainWindow::slotPaste() {
2141 if (!m_activeDocument || !m_activeTimeline) return;
2142 m_activeTimeline->projectView()->pasteClip();
2145 void MainWindow::slotPasteEffects() {
2146 if (!m_activeDocument || !m_activeTimeline) return;
2147 m_activeTimeline->projectView()->pasteClipEffects();
2150 void MainWindow::slotFind() {
2151 if (!m_activeDocument || !m_activeTimeline) return;
2152 m_projectSearch->setEnabled(false);
2153 m_findActivated = true;
2154 m_findString.clear();
2155 m_activeTimeline->projectView()->initSearchStrings();
2156 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2157 m_findTimer.start(5000);
2158 qApp->installEventFilter(this);
2161 void MainWindow::slotFindNext() {
2162 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2163 statusBar()->showMessage(i18n("Found : %1", m_findString));
2165 statusBar()->showMessage(i18n("Reached end of project"));
2167 m_findTimer.start(4000);
2170 void MainWindow::findAhead() {
2171 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2172 m_projectSearchNext->setEnabled(true);
2173 statusBar()->showMessage(i18n("Found : %1", m_findString));
2175 m_projectSearchNext->setEnabled(false);
2176 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2180 void MainWindow::findTimeout() {
2181 m_projectSearchNext->setEnabled(false);
2182 m_findActivated = false;
2183 m_findString.clear();
2184 statusBar()->showMessage(i18n("Find stopped"), 3000);
2185 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2186 m_projectSearch->setEnabled(true);
2187 removeEventFilter(this);
2190 void MainWindow::keyPressEvent(QKeyEvent *ke) {
2191 if (m_findActivated) {
2192 if (ke->key() == Qt::Key_Backspace) {
2193 m_findString = m_findString.left(m_findString.length() - 1);
2195 if (!m_findString.isEmpty()) {
2201 m_findTimer.start(4000);
2204 } else if (ke->key() == Qt::Key_Escape) {
2208 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2209 m_findString += ke->text();
2213 m_findTimer.start(4000);
2217 } else KXmlGuiWindow::keyPressEvent(ke);
2221 /** Gets called when the window gets hidden */
2222 void MainWindow::hideEvent(QHideEvent */*event*/) {
2223 // kDebug() << "I was hidden";
2224 // issue http://www.kdenlive.org/mantis/view.php?id=231
2225 if (this->isMinimized()) {
2226 // kDebug() << "I am minimized";
2227 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2231 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
2232 if (m_findActivated) {
2233 if (event->type() == QEvent::ShortcutOverride) {
2234 QKeyEvent* ke = (QKeyEvent*) event;
2235 if (ke->text().trimmed().isEmpty()) return false;
2238 } else return false;
2240 // pass the event on to the parent class
2241 return QMainWindow::eventFilter(obj, event);
2245 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
2246 KDialog *dialog = new KDialog(this);
2247 dialog->setCaption("Save clip zone");
2248 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2250 QWidget *widget = new QWidget(dialog);
2251 dialog->setMainWidget(widget);
2253 QVBoxLayout *vbox = new QVBoxLayout(widget);
2254 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2255 QString path = m_activeDocument->projectFolder().path();
2257 path.append("untitled.westley");
2258 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2259 url->setFilter("video/mlt-playlist");
2260 QLabel *label2 = new QLabel(i18n("Description:"), this);
2261 KLineEdit *edit = new KLineEdit(this);
2262 vbox->addWidget(label1);
2263 vbox->addWidget(url);
2264 vbox->addWidget(label2);
2265 vbox->addWidget(edit);
2266 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2270 void MainWindow::slotSetInPoint() {
2271 if (m_clipMonitor->isActive()) {
2272 m_clipMonitor->slotSetZoneStart();
2273 } else m_activeTimeline->projectView()->setInPoint();
2276 void MainWindow::slotSetOutPoint() {
2277 if (m_clipMonitor->isActive()) {
2278 m_clipMonitor->slotSetZoneEnd();
2279 } else m_activeTimeline->projectView()->setOutPoint();
2282 void MainWindow::slotGetNewLumaStuff() {
2283 //KNS::Entry::List download();
2284 KNS::Entry::List entries = KNS::Engine::download();
2285 // list of changed entries
2286 kDebug() << "// PARSING KNS";
2287 foreach(KNS::Entry* entry, entries) {
2288 // care only about installed ones
2289 if (entry->status() == KNS::Entry::Installed) {
2290 foreach(const QString &file, entry->installedFiles()) {
2291 kDebug() << "// CURRENTLY INSTALLED: " << file;
2295 qDeleteAll(entries);
2296 initEffects::refreshLumas();
2299 void MainWindow::slotGetNewRenderStuff() {
2300 //KNS::Entry::List download();
2302 KNS::Engine engine(0);
2303 if (engine.init("kdenlive_render.knsrc")) {
2304 KNS::Entry::List entries = engine.downloadDialogModal(this);
2306 if (entries.size() > 0) {
2307 foreach(KNS::Entry* entry, entries) {
2308 // care only about installed ones
2309 if (entry->status() == KNS::Entry::Installed) {
2310 foreach(const QString &file, entry->installedFiles()) {
2311 kDebug() << "// CURRENTLY INSTALLED: " << file;
2316 if (m_renderWidget) m_renderWidget->reloadProfiles();
2320 void MainWindow::slotGetNewMltProfileStuff() {
2321 //KNS::Entry::List download();
2323 KNS::Engine engine(0);
2324 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2325 KNS::Entry::List entries = engine.downloadDialogModal(this);
2327 if (entries.size() > 0) {
2328 foreach(KNS::Entry* entry, entries) {
2329 // care only about installed ones
2330 if (entry->status() == KNS::Entry::Installed) {
2331 foreach(const QString &file, entry->installedFiles()) {
2332 kDebug() << "// CURRENTLY INSTALLED: " << file;
2337 // update the list of profiles in settings dialog
2338 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2339 if (d) d->checkProfile();
2344 void MainWindow::slotAutoTransition() {
2345 m_activeTimeline->projectView()->autoTransition();
2348 void MainWindow::slotDvdWizard(const QString &url, const QString &profile) {
2349 DvdWizard *w = new DvdWizard(url, profile, this);
2354 #include "mainwindow.moc"