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 ***************************************************************************/
22 #include <QTextStream>
29 #include <KApplication>
33 #include <KActionCollection>
34 #include <KStandardAction>
35 #include <KFileDialog>
36 #include <KMessageBox>
38 #include <KIO/NetAccess>
41 #include <KConfigDialog>
42 #include <KXMLGUIFactory>
44 #include <kstandarddirs.h>
45 #include <KUrlRequesterDialog>
46 #include <KTemporaryFile>
47 #include <KActionMenu>
50 #include <ktogglefullscreenaction.h>
52 #include <KNotification>
53 #include <KNotifyConfigWidget>
55 #include <mlt++/Mlt.h>
57 #include "mainwindow.h"
58 #include "kdenlivesettings.h"
59 #include "kdenlivesettingsdialog.h"
60 #include "initeffects.h"
61 #include "profilesdialog.h"
62 #include "projectsettings.h"
64 #include "clipmanager.h"
65 #include "projectlist.h"
67 #include "recmonitor.h"
68 #include "monitormanager.h"
69 #include "kdenlivedoc.h"
70 #include "trackview.h"
71 #include "customtrackview.h"
72 #include "effectslistview.h"
73 #include "effectstackview.h"
74 #include "transitionsettings.h"
75 #include "renderwidget.h"
77 #include "jogshuttle.h"
78 #include "clipproperties.h"
80 #include "editclipcommand.h"
81 #include "titlewidget.h"
83 static const int ID_STATUS_MSG = 1;
84 static const int ID_EDITMODE_MSG = 2;
85 static const int ID_TIMELINE_MSG = 3;
86 static const int ID_TIMELINE_BUTTONS = 5;
87 static const int ID_TIMELINE_POS = 6;
88 static const int ID_TIMELINE_FORMAT = 7;
94 EffectsList MainWindow::videoEffects;
95 EffectsList MainWindow::audioEffects;
96 EffectsList MainWindow::customEffects;
97 EffectsList MainWindow::transitions;
99 MainWindow::MainWindow(const QString &MltPath, QWidget *parent)
100 : KXmlGuiWindow(parent),
101 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
102 setlocale(LC_NUMERIC, "POSIX");
103 setFont(KGlobalSettings::toolBarFont());
104 parseProfiles(MltPath);
105 m_commandStack = new QUndoGroup;
106 m_timelineArea = new KTabWidget(this);
107 m_timelineArea->setTabReorderingEnabled(true);
108 m_timelineArea->setTabBarHidden(true);
110 QToolButton *closeTabButton = new QToolButton;
111 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
112 closeTabButton->setIcon(KIcon("tab-close"));
113 closeTabButton->adjustSize();
114 closeTabButton->setToolTip(i18n("Close the current tab"));
115 m_timelineArea->setCornerWidget(closeTabButton);
116 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
118 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
119 m_findTimer.setSingleShot(true);
121 initEffects::parseEffectFiles();
122 //initEffects::parseCustomEffectsFile();
124 m_monitorManager = new MonitorManager();
126 projectListDock = new QDockWidget(i18n("Project Tree"), this);
127 projectListDock->setObjectName("project_tree");
128 m_projectList = new ProjectList(this);
129 projectListDock->setWidget(m_projectList);
130 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
132 effectListDock = new QDockWidget(i18n("Effect List"), this);
133 effectListDock->setObjectName("effect_list");
134 m_effectList = new EffectsListView();
136 //m_effectList = new KListWidget(this);
137 effectListDock->setWidget(m_effectList);
138 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
140 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
141 effectStackDock->setObjectName("effect_stack");
142 effectStack = new EffectStackView(this);
143 effectStackDock->setWidget(effectStack);
144 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
146 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
147 transitionConfigDock->setObjectName("transition");
148 transitionConfig = new TransitionSettings(this);
149 transitionConfigDock->setWidget(transitionConfig);
150 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
152 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
153 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
157 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
158 clipMonitorDock->setObjectName("clip_monitor");
159 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
160 clipMonitorDock->setWidget(m_clipMonitor);
161 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
162 //m_clipMonitor->stop();
164 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
165 projectMonitorDock->setObjectName("project_monitor");
166 m_projectMonitor = new Monitor("project", m_monitorManager, this);
167 projectMonitorDock->setWidget(m_projectMonitor);
168 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
170 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
171 recMonitorDock->setObjectName("record_monitor");
172 m_recMonitor = new RecMonitor("record", this);
173 recMonitorDock->setWidget(m_recMonitor);
174 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
176 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
177 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
179 undoViewDock = new QDockWidget(i18n("Undo History"), this);
180 undoViewDock->setObjectName("undo_history");
181 m_undoView = new QUndoView(this);
182 m_undoView->setCleanIcon(KIcon("edit-clear"));
183 m_undoView->setEmptyLabel(i18n("Clean"));
184 undoViewDock->setWidget(m_undoView);
185 m_undoView->setGroup(m_commandStack);
186 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
188 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
189 //overviewDock->setObjectName("project_overview");
190 //m_overView = new CustomTrackView(NULL, NULL, this);
191 //overviewDock->setWidget(m_overView);
192 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
195 //tabifyDockWidget(projectListDock, effectListDock);
196 tabifyDockWidget(projectListDock, effectStackDock);
197 tabifyDockWidget(projectListDock, transitionConfigDock);
198 //tabifyDockWidget(projectListDock, undoViewDock);
201 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
202 tabifyDockWidget(clipMonitorDock, recMonitorDock);
203 setCentralWidget(m_timelineArea);
206 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
208 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)));
209 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)));
211 // build effects menus
213 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
215 QStringList effectInfo;
216 QMap<QString, QStringList> effectsList;
217 for (int ix = 0; ix < videoEffects.count(); ix++) {
218 effectInfo = videoEffects.effectIdInfo(ix);
219 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
222 foreach(QStringList value, effectsList) {
223 action = new QAction(value.at(0), this);
224 action->setData(value);
225 videoEffectsMenu->addAction(action);
228 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
232 for (int ix = 0; ix < audioEffects.count(); ix++) {
233 effectInfo = audioEffects.effectIdInfo(ix);
234 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
237 foreach(QStringList value, effectsList) {
238 action = new QAction(value.at(0), this);
239 action->setData(value);
240 audioEffectsMenu->addAction(action);
243 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
245 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
246 else m_customEffectsMenu->setEnabled(true);
249 for (int ix = 0; ix < customEffects.count(); ix++) {
250 effectInfo = customEffects.effectIdInfo(ix);
251 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
254 foreach(QStringList value, effectsList) {
255 action = new QAction(value.at(0), this);
256 action->setData(value);
257 m_customEffectsMenu->addAction(action);
260 QMenu *newEffect = new QMenu(this);
261 newEffect->addMenu(videoEffectsMenu);
262 newEffect->addMenu(audioEffectsMenu);
263 newEffect->addMenu(m_customEffectsMenu);
264 effectStack->setMenu(newEffect);
267 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
268 const QList<QAction *> viewActions = createPopupMenu()->actions();
269 viewMenu->insertActions(NULL, viewActions);
271 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
272 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
273 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
275 m_timelineContextMenu = new QMenu(this);
276 m_timelineContextClipMenu = new QMenu(this);
277 m_timelineContextTransitionMenu = new QMenu(this);
280 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
281 QStringList effects = transitions.effectNames();
282 foreach(const QString &name, effects) {
283 action = new QAction(name, this);
284 action->setData(name);
285 transitionsMenu->addAction(action);
287 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
289 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
291 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
292 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
293 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
294 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
295 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
297 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
298 m_timelineContextClipMenu->addMenu(markersMenu);
299 m_timelineContextClipMenu->addMenu(transitionsMenu);
300 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
301 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
302 //TODO: re-enable custom effects menu when it is implemented
303 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
305 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
306 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
308 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
309 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
310 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
311 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
312 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
313 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
315 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
316 slotConnectMonitors();
318 if (KdenliveSettings::openlastproject()) {
321 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
322 if (!staleFiles.isEmpty()) {
323 if (KMessageBox::questionYesNo(this, i18n("Auto-saved files exist. Do you want to recover them now?"), i18n("File Recovery"), KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
324 recoverFiles(staleFiles);
332 activateShuttleDevice();
333 projectListDock->raise();
336 void MainWindow::queryQuit() {
337 kDebug() << "----- SAVING CONFUIG";
338 if (queryClose()) kapp->quit();
342 bool MainWindow::queryClose() {
344 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
345 if (m_activeDocument && m_activeDocument->isModified()) {
346 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
347 case KMessageBox::Yes :
348 // save document here. If saving fails, return false;
351 case KMessageBox::No :
360 void MainWindow::saveProperties(KConfig*) {
361 // save properties here,used by session management
366 void MainWindow::readProperties(KConfig *config) {
367 // read properties here,used by session management
368 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
369 openFile(KUrl(Lastproject));
372 void MainWindow::slotReloadEffects() {
373 initEffects::parseCustomEffectsFile();
374 m_customEffectsMenu->clear();
375 const QStringList effects = customEffects.effectNames();
377 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
378 else m_customEffectsMenu->setEnabled(true);
380 foreach(const QString &name, effects) {
381 action = new QAction(name, this);
382 action->setData(name);
383 m_customEffectsMenu->addAction(action);
385 m_effectList->reloadEffectList();
388 void MainWindow::activateShuttleDevice() {
389 if (m_jogProcess) delete m_jogProcess;
391 if (KdenliveSettings::enableshuttle() == false) return;
392 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
393 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
394 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
395 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
396 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
397 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
398 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
401 void MainWindow::slotShuttleButton(int code) {
404 slotShuttleAction(KdenliveSettings::shuttle1());
407 slotShuttleAction(KdenliveSettings::shuttle2());
410 slotShuttleAction(KdenliveSettings::shuttle3());
413 slotShuttleAction(KdenliveSettings::shuttle4());
416 slotShuttleAction(KdenliveSettings::shuttle5());
421 void MainWindow::slotShuttleAction(int code) {
426 m_monitorManager->slotPlay();
429 m_monitorManager->slotPlay();
434 void MainWindow::configureNotifications() {
435 KNotifyConfigWidget::configure(this);
438 void MainWindow::slotFullScreen() {
439 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
442 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
443 if (!m_activeDocument) return;
444 if (effect.isNull()) {
445 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
448 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
449 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
452 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
453 if (clipMonitor) clipMonitorDock->raise();
454 else projectMonitorDock->raise();
457 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
458 if (!m_activeDocument) return;
459 m_activeDocument->setProducerDuration(id, duration);
462 void MainWindow::slotConnectMonitors() {
464 m_projectList->setRenderer(m_clipMonitor->render);
465 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
466 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
467 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
468 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
469 connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
471 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
473 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
475 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
476 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
478 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
479 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
482 void MainWindow::slotAdjustClipMonitor() {
483 clipMonitorDock->updateGeometry();
484 clipMonitorDock->adjustSize();
485 m_clipMonitor->resetSize();
488 void MainWindow::slotAdjustProjectMonitor() {
489 projectMonitorDock->updateGeometry();
490 projectMonitorDock->adjustSize();
491 m_projectMonitor->resetSize();
494 void MainWindow::setupActions() {
496 KActionCollection* collection = actionCollection();
497 m_timecodeFormat = new KComboBox(this);
498 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
499 m_timecodeFormat->addItem(i18n("Frames"));
501 statusProgressBar = new QProgressBar(this);
502 statusProgressBar->setMinimum(0);
503 statusProgressBar->setMaximum(100);
504 statusProgressBar->setMaximumWidth(150);
505 statusProgressBar->setVisible(false);
507 QWidget *w = new QWidget;
509 QHBoxLayout *layout = new QHBoxLayout;
510 w->setLayout(layout);
511 layout->setContentsMargins(5, 0, 5, 0);
512 QToolBar *toolbar = new QToolBar("statusToolBar", this);
515 m_toolGroup = new QActionGroup(this);
517 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;}";
519 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
520 toolbar->addAction(m_buttonSelectTool);
521 m_buttonSelectTool->setCheckable(true);
522 m_buttonSelectTool->setChecked(true);
524 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
525 toolbar->addAction(m_buttonRazorTool);
526 m_buttonRazorTool->setCheckable(true);
527 m_buttonRazorTool->setChecked(false);
529 m_toolGroup->addAction(m_buttonSelectTool);
530 m_toolGroup->addAction(m_buttonRazorTool);
531 m_toolGroup->setExclusive(true);
532 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
534 QWidget * actionWidget;
535 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
536 actionWidget->setMaximumWidth(24);
537 actionWidget->setMinimumHeight(17);
539 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
540 actionWidget->setMaximumWidth(24);
541 actionWidget->setMinimumHeight(17);
543 toolbar->setStyleSheet(style1);
544 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
546 toolbar->addSeparator();
547 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
548 toolbar->addAction(m_buttonFitZoom);
549 m_buttonFitZoom->setCheckable(false);
550 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
552 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
553 actionWidget->setMaximumWidth(24);
554 actionWidget->setMinimumHeight(17);
556 m_zoomSlider = new QSlider(Qt::Horizontal, this);
557 m_zoomSlider->setMaximum(13);
558 m_zoomSlider->setPageStep(1);
560 m_zoomSlider->setMaximumWidth(150);
561 m_zoomSlider->setMinimumWidth(100);
563 const int contentHeight = QFontMetrics(w->font()).height() + 8;
565 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
566 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
568 m_zoomSlider->setStyleSheet(style);
570 //m_zoomSlider->height() + 5;
571 statusBar()->setMinimumHeight(contentHeight);
574 toolbar->addWidget(m_zoomSlider);
576 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
577 toolbar->addAction(m_buttonVideoThumbs);
578 m_buttonVideoThumbs->setCheckable(true);
579 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
580 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
582 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
583 toolbar->addAction(m_buttonAudioThumbs);
584 m_buttonAudioThumbs->setCheckable(true);
585 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
586 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
588 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
589 toolbar->addAction(m_buttonShowMarkers);
590 m_buttonShowMarkers->setCheckable(true);
591 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
592 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
594 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
595 toolbar->addAction(m_buttonSnap);
596 m_buttonSnap->setCheckable(true);
597 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
598 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
599 layout->addWidget(toolbar);
602 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
603 actionWidget->setMaximumWidth(24);
604 actionWidget->setMinimumHeight(17);
606 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
607 actionWidget->setMaximumWidth(24);
608 actionWidget->setMinimumHeight(17);
610 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
611 actionWidget->setMaximumWidth(24);
612 actionWidget->setMinimumHeight(17);
614 actionWidget = toolbar->widgetForAction(m_buttonSnap);
615 actionWidget->setMaximumWidth(24);
616 actionWidget->setMinimumHeight(17);
618 m_messageLabel = new StatusBarMessageLabel(this);
619 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
621 statusBar()->addWidget(m_messageLabel, 10);
622 statusBar()->addWidget(statusProgressBar, 0);
623 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
624 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
625 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
626 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
627 m_messageLabel->hide();
629 collection->addAction("select_tool", m_buttonSelectTool);
630 collection->addAction("razor_tool", m_buttonRazorTool);
632 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
633 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
634 collection->addAction("show_markers", m_buttonShowMarkers);
635 collection->addAction("snap", m_buttonSnap);
636 collection->addAction("zoom_fit", m_buttonFitZoom);
638 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
639 collection->addAction("project_find", m_projectSearch);
640 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
641 m_projectSearch->setShortcut(Qt::Key_Slash);
643 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
644 collection->addAction("project_find_next", m_projectSearchNext);
645 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
646 m_projectSearchNext->setShortcut(Qt::Key_F3);
647 m_projectSearchNext->setEnabled(false);
649 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
650 collection->addAction("manage_profiles", profilesAction);
651 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
653 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
654 collection->addAction("project_settings", projectAction);
655 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
657 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
658 collection->addAction("project_render", projectRender);
659 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
661 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
662 KShortcut playShortcut;
663 playShortcut.setPrimary(Qt::Key_Space);
664 playShortcut.setAlternate(Qt::Key_K);
665 monitorPlay->setShortcut(playShortcut);
666 collection->addAction("monitor_play", monitorPlay);
667 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
669 KAction *markIn = collection->addAction("mark_in");
670 markIn->setText(i18n("Set In Point"));
671 markIn->setShortcut(Qt::Key_I);
672 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
674 KAction *markOut = collection->addAction("mark_out");
675 markOut->setText(i18n("Set Out Point"));
676 markOut->setShortcut(Qt::Key_O);
677 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
679 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
680 monitorSeekBackward->setShortcut(Qt::Key_J);
681 collection->addAction("monitor_seek_backward", monitorSeekBackward);
682 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
684 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
685 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
686 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
687 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
689 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
690 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
691 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
692 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
694 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
695 monitorSeekForward->setShortcut(Qt::Key_L);
696 collection->addAction("monitor_seek_forward", monitorSeekForward);
697 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
699 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
700 clipStart->setShortcut(Qt::Key_Home);
701 collection->addAction("seek_clip_start", clipStart);
702 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
704 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
705 clipEnd->setShortcut(Qt::Key_End);
706 collection->addAction("seek_clip_end", clipEnd);
707 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
709 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
710 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
711 collection->addAction("seek_start", projectStart);
712 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
714 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
715 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
716 collection->addAction("seek_end", projectEnd);
717 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
719 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
720 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
721 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
722 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
724 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
725 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
726 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
727 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
729 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
730 deleteTimelineClip->setShortcut(Qt::Key_Delete);
731 collection->addAction("delete_timeline_clip", deleteTimelineClip);
732 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
734 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
735 collection->addAction("change_clip_speed", editTimelineClipSpeed);
736 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
738 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
739 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
740 collection->addAction("cut_timeline_clip", cutTimelineClip);
741 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
743 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
744 collection->addAction("add_clip_marker", addClipMarker);
745 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
747 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
748 collection->addAction("delete_clip_marker", deleteClipMarker);
749 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
751 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
752 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
753 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
755 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
756 collection->addAction("edit_clip_marker", editClipMarker);
757 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
759 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
760 collection->addAction("add_guide", addGuide);
761 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
763 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
764 collection->addAction("delete_guide", delGuide);
765 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
767 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
768 collection->addAction("edit_guide", editGuide);
769 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
771 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
772 collection->addAction("delete_all_guides", delAllGuides);
773 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
775 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
776 collection->addAction("paste_effects", pasteEffects);
777 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
779 KStandardAction::quit(this, SLOT(queryQuit()),
782 KStandardAction::open(this, SLOT(openFile()),
785 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
788 KStandardAction::saveAs(this, SLOT(saveFileAs()),
791 KStandardAction::openNew(this, SLOT(newFile()),
794 KStandardAction::preferences(this, SLOT(slotPreferences()),
797 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
799 KStandardAction::copy(this, SLOT(slotCopy()),
802 KStandardAction::paste(this, SLOT(slotPaste()),
805 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
807 undo->setEnabled(false);
808 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
810 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
812 redo->setEnabled(false);
813 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
815 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
817 connect(collection, SIGNAL(actionHovered(QAction*)),
818 this, SLOT(slotDisplayActionMessage(QAction*)));
819 //connect(collection, SIGNAL( clearStatusText() ),
820 //statusBar(), SLOT( clear() ) );
823 void MainWindow::slotDisplayActionMessage(QAction *a) {
824 statusBar()->showMessage(a->data().toString(), 3000);
827 void MainWindow::saveOptions() {
828 KdenliveSettings::self()->writeConfig();
829 KSharedConfigPtr config = KGlobal::config();
830 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
834 void MainWindow::readOptions() {
835 KSharedConfigPtr config = KGlobal::config();
836 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
837 KConfigGroup initialGroup(config, "version");
838 if (!initialGroup.exists()) {
839 // this is our first run, show Wizard
840 Wizard *w = new Wizard(this);
841 if (w->exec() == QDialog::Accepted && w->isOk()) {
843 initialGroup.writeEntry("version", "0.7");
851 void MainWindow::newFile(bool showProjectSettings) {
854 QPoint projectTracks(3, 2);
855 if (!showProjectSettings && m_timelineArea->count() == 0) {
856 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
857 profileName = KdenliveSettings::default_profile();
859 ProjectSettings *w = new ProjectSettings;
860 if (w->exec() != QDialog::Accepted) return;
861 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
862 profileName = w->selectedProfile();
863 projectFolder = w->selectedFolder();
864 projectTracks = w->tracks();
867 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
868 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
869 TrackView *trackView = new TrackView(doc, this);
870 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
871 if (m_timelineArea->count() == 1) {
872 connectDocumentInfo(doc);
873 connectDocument(trackView, doc);
874 } else m_timelineArea->setTabBarHidden(false);
877 void MainWindow::activateDocument() {
878 if (m_timelineArea->currentWidget() == NULL) return;
879 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
880 KdenliveDoc *currentDoc = currentTab->document();
881 connectDocumentInfo(currentDoc);
882 connectDocument(currentTab, currentDoc);
885 void MainWindow::closeCurrentDocument() {
886 QWidget *w = m_timelineArea->currentWidget();
888 // closing current document
889 int ix = m_timelineArea->currentIndex() + 1;
890 if (ix == m_timelineArea->count()) ix = 0;
891 m_timelineArea->setCurrentIndex(ix);
892 TrackView *tabToClose = (TrackView *) w;
893 KdenliveDoc *docToClose = tabToClose->document();
894 if (docToClose && docToClose->isModified()) {
895 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
896 case KMessageBox::Yes :
897 // save document here. If saving fails, return false;
900 case KMessageBox::Cancel :
906 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
907 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
910 if (m_timelineArea->count() == 0) {
911 m_activeDocument = NULL;
912 effectStack->clear();
913 transitionConfig->slotTransitionItemSelected(NULL);
917 void MainWindow::saveFileAs(const QString &outputFileName) {
918 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
919 m_activeDocument->setUrl(KUrl(outputFileName));
920 if (m_activeDocument->m_autosave == NULL) {
921 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
922 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
923 setCaption(m_activeDocument->description());
924 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
925 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
926 m_activeDocument->setModified(false);
927 m_fileOpenRecent->addUrl(KUrl(outputFileName));
930 void MainWindow::saveFileAs() {
931 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
932 if (QFile::exists(outputFile)) {
933 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
935 saveFileAs(outputFile);
938 void MainWindow::saveFile() {
939 if (!m_activeDocument) return;
940 if (m_activeDocument->url().isEmpty()) {
943 saveFileAs(m_activeDocument->url().path());
944 m_activeDocument->m_autosave->resize(0);
948 void MainWindow::openFile() {
949 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
950 if (url.isEmpty()) return;
951 m_fileOpenRecent->addUrl(url);
955 void MainWindow::openLastFile() {
956 KSharedConfigPtr config = KGlobal::config();
957 KUrl::List urls = m_fileOpenRecent->urls();
958 if (urls.isEmpty()) newFile(false);
959 else openFile(urls.last());
962 void MainWindow::openFile(const KUrl &url) {
963 // Check if the document is already opened
964 const int ct = m_timelineArea->count();
965 bool isOpened = false;
967 for (i = 0; i < ct; i++) {
968 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
969 KdenliveDoc *doc = tab->document();
970 if (doc->url() == url) {
976 m_timelineArea->setCurrentIndex(i);
980 // Check for backup file
981 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
982 if (!staleFiles.isEmpty()) {
983 if (KMessageBox::questionYesNo(this,
984 i18n("Auto-saved files exist. Do you want to recover them now?"),
985 i18n("File Recovery"),
986 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
987 recoverFiles(staleFiles);
990 // remove the stale files
991 foreach(KAutoSaveFile *stale, staleFiles) {
992 stale->open(QIODevice::ReadWrite);
997 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
998 doOpenFile(url, NULL);
1001 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1003 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
1004 if (stale == NULL) {
1005 stale = new KAutoSaveFile(url, doc);
1006 doc->m_autosave = stale;
1008 doc->m_autosave = stale;
1009 doc->setUrl(stale->managedFile());
1010 doc->setModified(true);
1011 stale->setParent(doc);
1013 connectDocumentInfo(doc);
1014 TrackView *trackView = new TrackView(doc, this);
1015 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1016 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1017 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1018 slotGotProgressInfo(QString(), -1);
1019 m_clipMonitor->refreshMonitor(true);
1022 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1023 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1024 foreach(KAutoSaveFile *stale, staleFiles) {
1025 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1026 // show an error message; we could not steal the lockfile
1027 // maybe another application got to the file before us?
1031 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1032 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1033 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1034 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1039 void MainWindow::parseProfiles(const QString &mltPath) {
1040 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1042 //KdenliveSettings::setDefaulttmpfolder();
1043 if (!mltPath.isEmpty()) {
1044 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1045 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1048 if (KdenliveSettings::mltpath().isEmpty()) {
1049 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1051 if (KdenliveSettings::rendererpath().isEmpty()) {
1052 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1053 if (!QFile::exists(inigoPath))
1054 inigoPath = KStandardDirs::findExe("inigo");
1055 else KdenliveSettings::setRendererpath(inigoPath);
1057 QStringList profilesFilter;
1058 profilesFilter << "*";
1059 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1061 if (profilesList.isEmpty()) {
1062 // Cannot find MLT path, try finding inigo
1063 QString profilePath = KdenliveSettings::rendererpath();
1064 if (!profilePath.isEmpty()) {
1065 profilePath = profilePath.section('/', 0, -3);
1066 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1067 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1070 if (profilesList.isEmpty()) {
1071 // Cannot find the MLT profiles, ask for location
1072 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1073 getUrl->fileDialog()->setMode(KFile::Directory);
1074 if (getUrl->exec() == QDialog::Rejected) {
1077 KUrl mltPath = getUrl->selectedUrl();
1079 if (mltPath.isEmpty()) ::exit(0);
1080 KdenliveSettings::setMltpath(mltPath.path());
1081 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1085 if (KdenliveSettings::rendererpath().isEmpty()) {
1086 // Cannot find the MLT inigo renderer, ask for location
1087 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1088 if (getUrl->exec() == QDialog::Rejected) {
1091 KUrl rendererPath = getUrl->selectedUrl();
1093 if (rendererPath.isEmpty()) ::exit(0);
1094 KdenliveSettings::setRendererpath(rendererPath.path());
1097 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1099 // Parse MLT profiles to build a list of available video formats
1100 if (profilesList.isEmpty()) parseProfiles();
1104 void MainWindow::slotEditProfiles() {
1105 ProfilesDialog *w = new ProfilesDialog;
1110 void MainWindow::slotEditProjectSettings() {
1111 ProjectSettings *w = new ProjectSettings;
1112 if (w->exec() == QDialog::Accepted) {
1113 QString profile = w->selectedProfile();
1114 m_activeDocument->setProfilePath(profile);
1115 KdenliveSettings::setCurrent_profile(profile);
1116 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1117 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1118 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1119 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1120 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1122 // We need to desactivate & reactivate monitors to get a refresh
1123 m_monitorManager->switchMonitors();
1128 void MainWindow::slotRenderProject() {
1129 if (!m_renderWidget) {
1130 m_renderWidget = new RenderWidget(this);
1131 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)));
1132 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1134 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1135 if (currentTab) m_renderWidget->setTimeline(currentTab);
1136 m_renderWidget->setDocument(m_activeDocument);*/
1137 m_renderWidget->show();
1140 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) {
1141 if (dest.isEmpty()) return;
1144 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1145 if (currentTab && zoneOnly) {
1146 in = currentTab->inPoint();
1147 out = currentTab->outPoint();
1149 KTemporaryFile temp;
1150 temp.setAutoRemove(false);
1151 temp.setSuffix(".westley");
1153 m_projectMonitor->saveSceneList(temp.fileName());
1156 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1157 else if (guideStart != -1) {
1158 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1160 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1161 QString videoPlayer = "-";
1163 videoPlayer = KdenliveSettings::defaultplayerapp();
1164 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."));
1166 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1167 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1170 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1171 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1172 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1173 QProcess::startDetached(renderer, args);
1175 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1179 void MainWindow::slotUpdateMousePosition(int pos) {
1180 if (m_activeDocument)
1181 switch (m_timecodeFormat->currentIndex()) {
1183 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1186 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1190 void MainWindow::slotUpdateDocumentState(bool modified) {
1191 setCaption(m_activeDocument->description(), modified);
1192 m_saveAction->setEnabled(modified);
1194 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1195 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1197 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1198 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1202 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1203 if (m_activeDocument) {
1204 if (m_activeDocument == doc) return;
1205 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1207 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1210 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1211 //m_projectMonitor->stop();
1212 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1213 if (m_activeDocument) {
1214 if (m_activeDocument == doc) return;
1215 m_activeDocument->backupMltPlaylist();
1216 if (m_activeTimeline) {
1217 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1218 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1219 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1220 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1221 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1222 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1223 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1224 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1225 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1226 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1227 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1228 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1229 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1230 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1231 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1232 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1233 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1234 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1236 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1237 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1238 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1239 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1240 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1241 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1242 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1243 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1244 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1245 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1246 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1247 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1248 effectStack->clear();
1250 m_activeDocument->setRenderer(NULL);
1251 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1252 m_clipMonitor->stop();
1254 KdenliveSettings::setCurrent_profile(doc->profilePath());
1255 KdenliveSettings::setProject_fps(doc->fps());
1256 m_monitorManager->resetProfiles(doc->timecode());
1257 m_projectList->setDocument(doc);
1258 transitionConfig->updateProjectFormat(doc->mltProfile());
1259 effectStack->updateProjectFormat(doc->mltProfile());
1260 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1261 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1262 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1263 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1264 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1265 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1266 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1267 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1268 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1269 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1270 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1271 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1273 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1274 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1275 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1278 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1279 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1280 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1281 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1282 m_zoomSlider->setValue(doc->zoom());
1283 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1284 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1285 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1286 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1288 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1291 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1292 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1293 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1294 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1295 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1296 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1297 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1298 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1300 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1301 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1302 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1304 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1305 m_activeTimeline = trackView;
1306 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1307 doc->setRenderer(m_projectMonitor->render);
1308 m_commandStack->setActiveStack(doc->commandStack());
1309 KdenliveSettings::setProject_display_ratio(doc->dar());
1310 m_projectList->updateAllClips();
1311 //doc->clipManager()->checkAudioThumbs();
1313 //m_overView->setScene(trackView->projectScene());
1314 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1315 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1317 setCaption(doc->description(), doc->isModified());
1318 m_saveAction->setEnabled(doc->isModified());
1319 m_activeDocument = doc;
1322 void MainWindow::slotGuidesUpdated() {
1323 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1326 void MainWindow::slotPreferences(int page, int option) {
1327 //An instance of your dialog could be already created and could be
1328 // cached, in which case you want to display the cached dialog
1329 // instead of creating another one
1330 if (KConfigDialog::showDialog("settings")) {
1331 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1335 // KConfigDialog didn't find an instance of this dialog, so lets
1337 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1338 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1339 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1341 if (page != -1) dialog->showPage(page, option);
1344 void MainWindow::updateConfiguration() {
1345 //TODO: we should apply settings to all projects, not only the current one
1346 if (m_activeTimeline) {
1347 m_activeTimeline->refresh();
1348 m_activeTimeline->projectView()->checkAutoScroll();
1349 m_activeTimeline->projectView()->checkTrackHeight();
1350 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1352 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1353 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1354 activateShuttleDevice();
1358 void MainWindow::slotSwitchVideoThumbs() {
1359 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1360 if (m_activeTimeline) {
1361 m_activeTimeline->refresh();
1363 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1366 void MainWindow::slotSwitchAudioThumbs() {
1367 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1368 if (m_activeTimeline) {
1369 m_activeTimeline->refresh();
1370 m_activeTimeline->projectView()->checkAutoScroll();
1371 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1373 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1376 void MainWindow::slotSwitchMarkersComments() {
1377 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1378 if (m_activeTimeline) {
1379 m_activeTimeline->refresh();
1381 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1384 void MainWindow::slotSwitchSnap() {
1385 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1386 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1390 void MainWindow::slotDeleteTimelineClip() {
1391 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1392 else if (m_activeTimeline) {
1393 m_activeTimeline->projectView()->deleteSelectedClips();
1397 void MainWindow::slotChangeClipSpeed() {
1398 if (m_activeTimeline) {
1399 m_activeTimeline->projectView()->changeClipSpeed();
1403 void MainWindow::slotAddClipMarker() {
1404 if (m_activeTimeline) {
1405 m_activeTimeline->projectView()->slotAddClipMarker();
1409 void MainWindow::slotDeleteClipMarker() {
1410 if (m_activeTimeline) {
1411 m_activeTimeline->projectView()->slotDeleteClipMarker();
1415 void MainWindow::slotDeleteAllClipMarkers() {
1416 if (m_activeTimeline) {
1417 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1421 void MainWindow::slotEditClipMarker() {
1422 if (m_activeTimeline) {
1423 m_activeTimeline->projectView()->slotEditClipMarker();
1427 void MainWindow::slotAddGuide() {
1428 if (m_activeTimeline)
1429 m_activeTimeline->projectView()->slotAddGuide();
1432 void MainWindow::slotEditGuide() {
1433 if (m_activeTimeline)
1434 m_activeTimeline->projectView()->slotEditGuide();
1437 void MainWindow::slotDeleteGuide() {
1438 if (m_activeTimeline)
1439 m_activeTimeline->projectView()->slotDeleteGuide();
1442 void MainWindow::slotDeleteAllGuides() {
1443 if (m_activeTimeline)
1444 m_activeTimeline->projectView()->slotDeleteAllGuides();
1447 void MainWindow::slotCutTimelineClip() {
1448 if (m_activeTimeline) {
1449 m_activeTimeline->projectView()->cutSelectedClips();
1453 void MainWindow::slotAddProjectClip(KUrl url) {
1454 if (m_activeDocument)
1455 m_activeDocument->slotAddClipFile(url, QString());
1458 void MainWindow::slotAddTransition(QAction *result) {
1459 if (!result) return;
1460 QDomElement effect = transitions.getEffectByName(result->data().toString());
1461 if (m_activeTimeline) {
1462 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1466 void MainWindow::slotAddVideoEffect(QAction *result) {
1467 if (!result) return;
1468 QStringList info = result->data().toStringList();
1469 if (info.isEmpty()) return;
1470 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1471 slotAddEffect(effect);
1474 void MainWindow::slotAddAudioEffect(QAction *result) {
1475 if (!result) return;
1476 QStringList info = result->data().toStringList();
1477 if (info.isEmpty()) return;
1478 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1479 slotAddEffect(effect);
1482 void MainWindow::slotAddCustomEffect(QAction *result) {
1483 if (!result) return;
1484 QStringList info = result->data().toStringList();
1485 if (info.isEmpty()) return;
1486 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1487 slotAddEffect(effect);
1490 void MainWindow::slotZoomIn() {
1491 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1494 void MainWindow::slotZoomOut() {
1495 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1498 void MainWindow::slotFitZoom() {
1499 if (m_activeTimeline) {
1500 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1504 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1505 statusProgressBar->setValue(progress);
1506 if (progress >= 0) {
1507 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1508 statusProgressBar->setVisible(true);
1510 m_messageLabel->setMessage(QString(), DefaultMessage);
1511 statusProgressBar->setVisible(false);
1515 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1516 if (clip->clipType() == TEXT) {
1517 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1518 QString path = clip->getProperty("resource");
1519 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1521 doc.setContent(clip->getProperty("xmldata"));
1522 dia_ui->setXml(doc);
1523 if (dia_ui->exec() == QDialog::Accepted) {
1524 QPixmap pix = dia_ui->renderedPixmap();
1526 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1527 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1528 QMap <QString, QString> newprops;
1529 newprops.insert("xmldata", dia_ui->xml().toString());
1530 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1531 m_activeDocument->commandStack()->push(command);
1532 m_clipMonitor->refreshMonitor(true);
1533 m_activeDocument->setModified(true);
1537 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1540 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1541 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1542 if (dia.exec() == QDialog::Accepted) {
1543 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1544 m_activeDocument->commandStack()->push(command);
1546 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1547 if (dia.needsTimelineRefresh()) {
1548 // update clip occurences in timeline
1549 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1554 void MainWindow::customEvent(QEvent* e) {
1555 if (e->type() == QEvent::User) {
1556 // The timeline playing position changed...
1557 kDebug() << "RECIEVED JOG EVEMNT!!!";
1560 void MainWindow::slotActivateEffectStackView() {
1561 effectStack->raiseWindow(effectStackDock);
1564 void MainWindow::slotActivateTransitionView() {
1565 transitionConfig->raiseWindow(transitionConfigDock);
1568 void MainWindow::slotSnapRewind() {
1569 if (m_projectMonitor->isActive()) {
1570 if (m_activeTimeline)
1571 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1575 void MainWindow::slotSnapForward() {
1576 if (m_projectMonitor->isActive()) {
1577 if (m_activeTimeline)
1578 m_activeTimeline->projectView()->slotSeekToNextSnap();
1582 void MainWindow::slotClipStart() {
1583 if (m_projectMonitor->isActive()) {
1584 if (m_activeTimeline)
1585 m_activeTimeline->projectView()->clipStart();
1589 void MainWindow::slotClipEnd() {
1590 if (m_projectMonitor->isActive()) {
1591 if (m_activeTimeline)
1592 m_activeTimeline->projectView()->clipEnd();
1596 void MainWindow::slotChangeTool(QAction * action) {
1597 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1598 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1601 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1602 if (m_activeDocument && m_activeTimeline) {
1603 //m_activeDocument->setTool(tool);
1604 m_activeTimeline->projectView()->setTool(tool);
1608 void MainWindow::slotCopy() {
1609 if (!m_activeDocument || !m_activeTimeline) return;
1610 m_activeTimeline->projectView()->copyClip();
1613 void MainWindow::slotPaste() {
1614 if (!m_activeDocument || !m_activeTimeline) return;
1615 m_activeTimeline->projectView()->pasteClip();
1618 void MainWindow::slotPasteEffects() {
1619 if (!m_activeDocument || !m_activeTimeline) return;
1620 m_activeTimeline->projectView()->pasteClipEffects();
1623 void MainWindow::slotFind() {
1624 if (!m_activeDocument || !m_activeTimeline) return;
1625 m_projectSearch->setEnabled(false);
1626 m_findActivated = true;
1627 m_findString = QString();
1628 m_activeTimeline->projectView()->initSearchStrings();
1629 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1630 m_findTimer.start(5000);
1631 qApp->installEventFilter(this);
1634 void MainWindow::slotFindNext() {
1635 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1636 statusBar()->showMessage(i18n("Found : %1", m_findString));
1638 statusBar()->showMessage(i18n("Reached end of project"));
1640 m_findTimer.start(4000);
1643 void MainWindow::findAhead() {
1644 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1645 m_projectSearchNext->setEnabled(true);
1646 statusBar()->showMessage(i18n("Found : %1", m_findString));
1648 m_projectSearchNext->setEnabled(false);
1649 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1653 void MainWindow::findTimeout() {
1654 m_projectSearchNext->setEnabled(false);
1655 m_findActivated = false;
1656 m_findString = QString();
1657 statusBar()->showMessage(i18n("Find stopped"), 3000);
1658 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1659 m_projectSearch->setEnabled(true);
1660 removeEventFilter(this);
1663 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1664 if (m_findActivated) {
1665 if (ke->key() == Qt::Key_Backspace) {
1666 m_findString = m_findString.left(m_findString.length() - 1);
1668 if (!m_findString.isEmpty()) {
1674 m_findTimer.start(4000);
1677 } else if (ke->key() == Qt::Key_Escape) {
1681 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1682 m_findString += ke->text();
1686 m_findTimer.start(4000);
1690 } else KXmlGuiWindow::keyPressEvent(ke);
1693 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1694 if (m_findActivated) {
1695 if (event->type() == QEvent::ShortcutOverride) {
1696 QKeyEvent* ke = (QKeyEvent*) event;
1697 if (ke->text().trimmed().isEmpty()) return false;
1700 } else return false;
1702 // pass the event on to the parent class
1703 return QMainWindow::eventFilter(obj, event);
1707 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1708 KDialog *dialog = new KDialog(this);
1709 dialog->setCaption("Save clip zone");
1710 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1712 QWidget *widget = new QWidget(dialog);
1713 dialog->setMainWidget(widget);
1715 QVBoxLayout *vbox = new QVBoxLayout(widget);
1716 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1717 QString path = m_activeDocument->projectFolder().path();
1719 path.append("untitled.westley");
1720 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1721 url->setFilter("video/mlt-playlist");
1722 QLabel *label2 = new QLabel(i18n("Description:"), this);
1723 KLineEdit *edit = new KLineEdit(this);
1724 vbox->addWidget(label1);
1725 vbox->addWidget(url);
1726 vbox->addWidget(label2);
1727 vbox->addWidget(edit);
1728 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1732 void MainWindow::slotSetInPoint() {
1733 if (m_clipMonitor->isActive()) {
1734 m_clipMonitor->slotSetZoneStart();
1735 } else m_activeTimeline->projectView()->setInPoint();
1738 void MainWindow::slotSetOutPoint() {
1739 if (m_clipMonitor->isActive()) {
1740 m_clipMonitor->slotSetZoneEnd();
1741 } else m_activeTimeline->projectView()->setOutPoint();
1744 #include "mainwindow.moc"