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);
205 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
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 setAutoSaveSettings();
320 if (KdenliveSettings::openlastproject()) {
323 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
324 if (!staleFiles.isEmpty()) {
325 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) {
326 recoverFiles(staleFiles);
334 activateShuttleDevice();
335 projectListDock->raise();
338 void MainWindow::queryQuit() {
339 kDebug() << "----- SAVING CONFUIG";
340 if (queryClose()) kapp->quit();
344 bool MainWindow::queryClose() {
346 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
347 if (m_activeDocument && m_activeDocument->isModified()) {
348 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
349 case KMessageBox::Yes :
350 // save document here. If saving fails, return false;
353 case KMessageBox::No :
362 void MainWindow::saveProperties(KConfig*) {
363 // save properties here,used by session management
368 void MainWindow::readProperties(KConfig *config) {
369 // read properties here,used by session management
370 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
371 openFile(KUrl(Lastproject));
374 void MainWindow::slotReloadEffects() {
375 initEffects::parseCustomEffectsFile();
376 m_customEffectsMenu->clear();
377 const QStringList effects = customEffects.effectNames();
379 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
380 else m_customEffectsMenu->setEnabled(true);
382 foreach(const QString &name, effects) {
383 action = new QAction(name, this);
384 action->setData(name);
385 m_customEffectsMenu->addAction(action);
387 m_effectList->reloadEffectList();
390 void MainWindow::activateShuttleDevice() {
391 if (m_jogProcess) delete m_jogProcess;
393 if (KdenliveSettings::enableshuttle() == false) return;
394 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
395 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
396 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
397 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
398 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
399 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
400 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
403 void MainWindow::slotShuttleButton(int code) {
406 slotShuttleAction(KdenliveSettings::shuttle1());
409 slotShuttleAction(KdenliveSettings::shuttle2());
412 slotShuttleAction(KdenliveSettings::shuttle3());
415 slotShuttleAction(KdenliveSettings::shuttle4());
418 slotShuttleAction(KdenliveSettings::shuttle5());
423 void MainWindow::slotShuttleAction(int code) {
428 m_monitorManager->slotPlay();
431 m_monitorManager->slotPlay();
436 void MainWindow::configureNotifications() {
437 KNotifyConfigWidget::configure(this);
440 void MainWindow::slotFullScreen() {
441 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
444 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
445 if (!m_activeDocument) return;
446 if (effect.isNull()) {
447 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
450 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
451 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
454 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
455 if (clipMonitor) clipMonitorDock->raise();
456 else projectMonitorDock->raise();
459 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
460 if (!m_activeDocument) return;
461 m_activeDocument->setProducerDuration(id, duration);
464 void MainWindow::slotConnectMonitors() {
466 m_projectList->setRenderer(m_clipMonitor->render);
467 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
468 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
469 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
470 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
471 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 > &)));
473 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
475 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
477 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
478 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
480 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
481 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
484 void MainWindow::slotAdjustClipMonitor() {
485 clipMonitorDock->updateGeometry();
486 clipMonitorDock->adjustSize();
487 m_clipMonitor->resetSize();
490 void MainWindow::slotAdjustProjectMonitor() {
491 projectMonitorDock->updateGeometry();
492 projectMonitorDock->adjustSize();
493 m_projectMonitor->resetSize();
496 void MainWindow::setupActions() {
498 KActionCollection* collection = actionCollection();
499 m_timecodeFormat = new KComboBox(this);
500 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
501 m_timecodeFormat->addItem(i18n("Frames"));
503 statusProgressBar = new QProgressBar(this);
504 statusProgressBar->setMinimum(0);
505 statusProgressBar->setMaximum(100);
506 statusProgressBar->setMaximumWidth(150);
507 statusProgressBar->setVisible(false);
509 QWidget *w = new QWidget;
511 QHBoxLayout *layout = new QHBoxLayout;
512 w->setLayout(layout);
513 layout->setContentsMargins(5, 0, 5, 0);
514 QToolBar *toolbar = new QToolBar("statusToolBar", this);
517 m_toolGroup = new QActionGroup(this);
519 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;}";
521 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
522 m_buttonSelectTool->setCheckable(true);
523 m_buttonSelectTool->setChecked(true);
525 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
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 = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
548 m_buttonFitZoom->setCheckable(false);
549 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
551 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
552 actionWidget->setMaximumWidth(24);
553 actionWidget->setMinimumHeight(17);
555 m_zoomSlider = new QSlider(Qt::Horizontal, this);
556 m_zoomSlider->setMaximum(13);
557 m_zoomSlider->setPageStep(1);
559 m_zoomSlider->setMaximumWidth(150);
560 m_zoomSlider->setMinimumWidth(100);
562 const int contentHeight = QFontMetrics(w->font()).height() + 8;
564 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
565 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
567 m_zoomSlider->setStyleSheet(style);
569 //m_zoomSlider->height() + 5;
570 statusBar()->setMinimumHeight(contentHeight);
573 toolbar->addWidget(m_zoomSlider);
575 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
576 m_buttonVideoThumbs->setCheckable(true);
577 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
578 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
580 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
581 m_buttonAudioThumbs->setCheckable(true);
582 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
583 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
585 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
586 m_buttonShowMarkers->setCheckable(true);
587 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
588 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
590 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
591 m_buttonSnap->setCheckable(true);
592 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
593 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
594 layout->addWidget(toolbar);
597 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
598 actionWidget->setMaximumWidth(24);
599 actionWidget->setMinimumHeight(17);
601 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
602 actionWidget->setMaximumWidth(24);
603 actionWidget->setMinimumHeight(17);
605 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
606 actionWidget->setMaximumWidth(24);
607 actionWidget->setMinimumHeight(17);
609 actionWidget = toolbar->widgetForAction(m_buttonSnap);
610 actionWidget->setMaximumWidth(24);
611 actionWidget->setMinimumHeight(17);
613 m_messageLabel = new StatusBarMessageLabel(this);
614 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
616 statusBar()->addWidget(m_messageLabel, 10);
617 statusBar()->addWidget(statusProgressBar, 0);
618 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
619 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
620 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
621 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
622 m_messageLabel->hide();
624 collection->addAction("select_tool", m_buttonSelectTool);
625 collection->addAction("razor_tool", m_buttonRazorTool);
627 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
628 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
629 collection->addAction("show_markers", m_buttonShowMarkers);
630 collection->addAction("snap", m_buttonSnap);
631 collection->addAction("zoom_fit", m_buttonFitZoom);
633 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
634 collection->addAction("project_find", m_projectSearch);
635 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
636 m_projectSearch->setShortcut(Qt::Key_Slash);
638 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
639 collection->addAction("project_find_next", m_projectSearchNext);
640 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
641 m_projectSearchNext->setShortcut(Qt::Key_F3);
642 m_projectSearchNext->setEnabled(false);
644 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
645 collection->addAction("manage_profiles", profilesAction);
646 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
648 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
649 collection->addAction("project_settings", projectAction);
650 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
652 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
653 collection->addAction("project_render", projectRender);
654 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
656 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
657 KShortcut playShortcut;
658 playShortcut.setPrimary(Qt::Key_Space);
659 playShortcut.setAlternate(Qt::Key_K);
660 monitorPlay->setShortcut(playShortcut);
661 collection->addAction("monitor_play", monitorPlay);
662 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
664 KAction *markIn = collection->addAction("mark_in");
665 markIn->setText(i18n("Set In Point"));
666 markIn->setShortcut(Qt::Key_I);
667 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
669 KAction *markOut = collection->addAction("mark_out");
670 markOut->setText(i18n("Set Out Point"));
671 markOut->setShortcut(Qt::Key_O);
672 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
674 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
675 monitorSeekBackward->setShortcut(Qt::Key_J);
676 collection->addAction("monitor_seek_backward", monitorSeekBackward);
677 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
679 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
680 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
681 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
682 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
684 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
685 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
686 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
687 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
689 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
690 monitorSeekForward->setShortcut(Qt::Key_L);
691 collection->addAction("monitor_seek_forward", monitorSeekForward);
692 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
694 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
695 clipStart->setShortcut(Qt::Key_Home);
696 collection->addAction("seek_clip_start", clipStart);
697 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
699 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
700 clipEnd->setShortcut(Qt::Key_End);
701 collection->addAction("seek_clip_end", clipEnd);
702 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
704 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
705 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
706 collection->addAction("seek_start", projectStart);
707 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
709 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
710 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
711 collection->addAction("seek_end", projectEnd);
712 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
714 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
715 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
716 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
717 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
719 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
720 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
721 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
722 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
724 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
725 deleteTimelineClip->setShortcut(Qt::Key_Delete);
726 collection->addAction("delete_timeline_clip", deleteTimelineClip);
727 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
729 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
730 collection->addAction("change_clip_speed", editTimelineClipSpeed);
731 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
733 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
734 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
735 collection->addAction("cut_timeline_clip", cutTimelineClip);
736 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
738 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
739 collection->addAction("add_clip_marker", addClipMarker);
740 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
742 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
743 collection->addAction("delete_clip_marker", deleteClipMarker);
744 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
746 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
747 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
748 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
750 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
751 collection->addAction("edit_clip_marker", editClipMarker);
752 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
754 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
755 collection->addAction("add_guide", addGuide);
756 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
758 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
759 collection->addAction("delete_guide", delGuide);
760 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
762 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
763 collection->addAction("edit_guide", editGuide);
764 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
766 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
767 collection->addAction("delete_all_guides", delAllGuides);
768 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
770 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
771 collection->addAction("paste_effects", pasteEffects);
772 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
774 KStandardAction::quit(this, SLOT(queryQuit()),
777 KStandardAction::open(this, SLOT(openFile()),
780 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
783 KStandardAction::saveAs(this, SLOT(saveFileAs()),
786 KStandardAction::openNew(this, SLOT(newFile()),
789 KStandardAction::preferences(this, SLOT(slotPreferences()),
792 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
794 KStandardAction::copy(this, SLOT(slotCopy()),
797 KStandardAction::paste(this, SLOT(slotPaste()),
800 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
802 undo->setEnabled(false);
803 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
805 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
807 redo->setEnabled(false);
808 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
810 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
812 connect(collection, SIGNAL(actionHovered(QAction*)),
813 this, SLOT(slotDisplayActionMessage(QAction*)));
814 //connect(collection, SIGNAL( clearStatusText() ),
815 //statusBar(), SLOT( clear() ) );
818 void MainWindow::slotDisplayActionMessage(QAction *a) {
819 statusBar()->showMessage(a->data().toString(), 3000);
822 void MainWindow::saveOptions() {
823 KdenliveSettings::self()->writeConfig();
824 KSharedConfigPtr config = KGlobal::config();
825 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
829 void MainWindow::readOptions() {
830 KSharedConfigPtr config = KGlobal::config();
831 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
832 KConfigGroup initialGroup(config, "version");
833 if (!initialGroup.exists()) {
834 // this is our first run, show Wizard
835 Wizard *w = new Wizard(this);
836 if (w->exec() == QDialog::Accepted && w->isOk()) {
838 initialGroup.writeEntry("version", "0.7");
846 void MainWindow::newFile() {
847 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
850 QPoint projectTracks(3, 2);
851 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
853 ProjectSettings *w = new ProjectSettings;
854 if (w->exec() != QDialog::Accepted) return;
855 profileName = w->selectedProfile();
856 projectFolder = w->selectedFolder();
857 projectTracks = w->tracks();
860 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
861 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
862 TrackView *trackView = new TrackView(doc, this);
863 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
864 if (m_timelineArea->count() == 1) {
865 connectDocumentInfo(doc);
866 connectDocument(trackView, doc);
867 } else m_timelineArea->setTabBarHidden(false);
870 void MainWindow::activateDocument() {
871 if (m_timelineArea->currentWidget() == NULL) return;
872 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
873 KdenliveDoc *currentDoc = currentTab->document();
874 connectDocumentInfo(currentDoc);
875 connectDocument(currentTab, currentDoc);
878 void MainWindow::closeCurrentDocument() {
879 QWidget *w = m_timelineArea->currentWidget();
881 // closing current document
882 int ix = m_timelineArea->currentIndex() + 1;
883 if (ix == m_timelineArea->count()) ix = 0;
884 m_timelineArea->setCurrentIndex(ix);
885 TrackView *tabToClose = (TrackView *) w;
886 KdenliveDoc *docToClose = tabToClose->document();
887 if (docToClose && docToClose->isModified()) {
888 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
889 case KMessageBox::Yes :
890 // save document here. If saving fails, return false;
893 case KMessageBox::Cancel :
899 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
900 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
903 if (m_timelineArea->count() == 0) {
904 m_activeDocument = NULL;
905 effectStack->clear();
906 transitionConfig->slotTransitionItemSelected(NULL);
910 void MainWindow::saveFileAs(const QString &outputFileName) {
911 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
912 m_activeDocument->setUrl(KUrl(outputFileName));
913 if (m_activeDocument->m_autosave == NULL) {
914 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
915 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
916 setCaption(m_activeDocument->description());
917 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
918 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
919 m_activeDocument->setModified(false);
920 m_fileOpenRecent->addUrl(KUrl(outputFileName));
923 void MainWindow::saveFileAs() {
924 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
925 if (QFile::exists(outputFile)) {
926 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
928 saveFileAs(outputFile);
931 void MainWindow::saveFile() {
932 if (!m_activeDocument) return;
933 if (m_activeDocument->url().isEmpty()) {
936 saveFileAs(m_activeDocument->url().path());
937 m_activeDocument->m_autosave->resize(0);
941 void MainWindow::openFile() {
942 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
943 if (url.isEmpty()) return;
944 m_fileOpenRecent->addUrl(url);
948 void MainWindow::openLastFile() {
949 KSharedConfigPtr config = KGlobal::config();
950 KUrl::List urls = m_fileOpenRecent->urls();
951 if (urls.isEmpty()) newFile();
952 else openFile(urls.last());
955 void MainWindow::openFile(const KUrl &url) {
956 // Check if the document is already opened
957 const int ct = m_timelineArea->count();
958 bool isOpened = false;
960 for (i = 0; i < ct; i++) {
961 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
962 KdenliveDoc *doc = tab->document();
963 if (doc->url() == url) {
969 m_timelineArea->setCurrentIndex(i);
973 // Check for backup file
974 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
975 if (!staleFiles.isEmpty()) {
976 if (KMessageBox::questionYesNo(this,
977 i18n("Auto-saved files exist. Do you want to recover them now?"),
978 i18n("File Recovery"),
979 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
980 recoverFiles(staleFiles);
983 // remove the stale files
984 foreach(KAutoSaveFile *stale, staleFiles) {
985 stale->open(QIODevice::ReadWrite);
990 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
991 doOpenFile(url, NULL);
994 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
996 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
998 stale = new KAutoSaveFile(url, doc);
999 doc->m_autosave = stale;
1001 doc->m_autosave = stale;
1002 doc->setUrl(stale->managedFile());
1003 doc->setModified(true);
1004 stale->setParent(doc);
1006 connectDocumentInfo(doc);
1007 TrackView *trackView = new TrackView(doc, this);
1008 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1009 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1010 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1011 slotGotProgressInfo(QString(), -1);
1012 m_clipMonitor->refreshMonitor(true);
1015 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1016 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1017 foreach(KAutoSaveFile *stale, staleFiles) {
1018 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1019 // show an error message; we could not steal the lockfile
1020 // maybe another application got to the file before us?
1024 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1025 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1026 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1027 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1032 void MainWindow::parseProfiles(const QString &mltPath) {
1033 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1035 //KdenliveSettings::setDefaulttmpfolder();
1036 if (!mltPath.isEmpty()) {
1037 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1038 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1041 if (KdenliveSettings::mltpath().isEmpty()) {
1042 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1044 if (KdenliveSettings::rendererpath().isEmpty()) {
1045 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1046 if (!QFile::exists(inigoPath))
1047 inigoPath = KStandardDirs::findExe("inigo");
1048 else KdenliveSettings::setRendererpath(inigoPath);
1050 QStringList profilesFilter;
1051 profilesFilter << "*";
1052 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1054 if (profilesList.isEmpty()) {
1055 // Cannot find MLT path, try finding inigo
1056 QString profilePath = KdenliveSettings::rendererpath();
1057 if (!profilePath.isEmpty()) {
1058 profilePath = profilePath.section('/', 0, -3);
1059 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1060 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1063 if (profilesList.isEmpty()) {
1064 // Cannot find the MLT profiles, ask for location
1065 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1066 getUrl->fileDialog()->setMode(KFile::Directory);
1067 if (getUrl->exec() == QDialog::Rejected) {
1070 KUrl mltPath = getUrl->selectedUrl();
1072 if (mltPath.isEmpty()) ::exit(0);
1073 KdenliveSettings::setMltpath(mltPath.path());
1074 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1078 if (KdenliveSettings::rendererpath().isEmpty()) {
1079 // Cannot find the MLT inigo renderer, ask for location
1080 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1081 if (getUrl->exec() == QDialog::Rejected) {
1084 KUrl rendererPath = getUrl->selectedUrl();
1086 if (rendererPath.isEmpty()) ::exit(0);
1087 KdenliveSettings::setRendererpath(rendererPath.path());
1090 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1092 // Parse MLT profiles to build a list of available video formats
1093 if (profilesList.isEmpty()) parseProfiles();
1097 void MainWindow::slotEditProfiles() {
1098 ProfilesDialog *w = new ProfilesDialog;
1103 void MainWindow::slotEditProjectSettings() {
1104 ProjectSettings *w = new ProjectSettings;
1105 if (w->exec() == QDialog::Accepted) {
1106 QString profile = w->selectedProfile();
1107 m_activeDocument->setProfilePath(profile);
1108 KdenliveSettings::setCurrent_profile(profile);
1109 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1110 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1111 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1112 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1113 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1115 // We need to desactivate & reactivate monitors to get a refresh
1116 m_monitorManager->switchMonitors();
1121 void MainWindow::slotRenderProject() {
1122 if (!m_renderWidget) {
1123 m_renderWidget = new RenderWidget(this);
1124 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)));
1125 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1127 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1128 if (currentTab) m_renderWidget->setTimeline(currentTab);
1129 m_renderWidget->setDocument(m_activeDocument);*/
1130 m_renderWidget->show();
1133 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) {
1134 if (dest.isEmpty()) return;
1137 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1138 if (currentTab && zoneOnly) {
1139 in = currentTab->inPoint();
1140 out = currentTab->outPoint();
1142 KTemporaryFile temp;
1143 temp.setAutoRemove(false);
1144 temp.setSuffix(".westley");
1146 m_projectMonitor->saveSceneList(temp.fileName());
1149 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1150 else if (guideStart != -1) {
1151 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1153 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1154 QString videoPlayer = "-";
1156 videoPlayer = KdenliveSettings::defaultplayerapp();
1157 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."));
1159 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1160 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1163 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1164 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1165 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1166 QProcess::startDetached(renderer, args);
1168 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1172 void MainWindow::slotUpdateMousePosition(int pos) {
1173 if (m_activeDocument)
1174 switch (m_timecodeFormat->currentIndex()) {
1176 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1179 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1183 void MainWindow::slotUpdateDocumentState(bool modified) {
1184 setCaption(m_activeDocument->description(), modified);
1185 m_saveAction->setEnabled(modified);
1187 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1188 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1190 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1191 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1195 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1196 if (m_activeDocument) {
1197 if (m_activeDocument == doc) return;
1198 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1200 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1203 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1204 //m_projectMonitor->stop();
1205 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1206 if (m_activeDocument) {
1207 if (m_activeDocument == doc) return;
1208 m_activeDocument->backupMltPlaylist();
1209 if (m_activeTimeline) {
1210 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1211 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1212 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1213 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1214 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1215 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1216 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1217 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1218 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1219 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1220 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1221 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1222 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1223 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1224 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1225 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1226 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1227 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1229 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1230 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1231 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1232 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1233 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1234 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1235 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1236 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1237 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1238 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1239 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1240 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1241 effectStack->clear();
1243 m_activeDocument->setRenderer(NULL);
1244 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1245 m_clipMonitor->stop();
1247 KdenliveSettings::setCurrent_profile(doc->profilePath());
1248 KdenliveSettings::setProject_fps(doc->fps());
1249 m_monitorManager->resetProfiles(doc->timecode());
1250 m_projectList->setDocument(doc);
1251 transitionConfig->updateProjectFormat(doc->mltProfile());
1252 effectStack->updateProjectFormat(doc->mltProfile());
1253 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1254 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1255 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1256 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1257 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1258 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1259 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1260 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1261 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1262 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1263 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1264 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1266 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1267 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1268 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1271 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1272 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1273 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1274 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1275 m_zoomSlider->setValue(doc->zoom());
1276 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1277 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1278 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1279 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1281 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1284 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1285 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1286 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1287 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1288 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1289 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1290 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1291 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1293 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1294 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1295 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1297 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1298 m_activeTimeline = trackView;
1299 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1300 doc->setRenderer(m_projectMonitor->render);
1301 m_commandStack->setActiveStack(doc->commandStack());
1302 KdenliveSettings::setProject_display_ratio(doc->dar());
1303 m_projectList->updateAllClips();
1304 //doc->clipManager()->checkAudioThumbs();
1306 //m_overView->setScene(trackView->projectScene());
1307 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1308 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1310 setCaption(doc->description(), doc->isModified());
1311 m_saveAction->setEnabled(doc->isModified());
1312 m_activeDocument = doc;
1315 void MainWindow::slotGuidesUpdated() {
1316 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1319 void MainWindow::slotPreferences(int page, int option) {
1320 //An instance of your dialog could be already created and could be
1321 // cached, in which case you want to display the cached dialog
1322 // instead of creating another one
1323 if (KConfigDialog::showDialog("settings")) {
1324 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1328 // KConfigDialog didn't find an instance of this dialog, so lets
1330 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1331 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1332 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1334 if (page != -1) dialog->showPage(page, option);
1337 void MainWindow::updateConfiguration() {
1338 //TODO: we should apply settings to all projects, not only the current one
1339 if (m_activeTimeline) {
1340 m_activeTimeline->refresh();
1341 m_activeTimeline->projectView()->checkAutoScroll();
1342 m_activeTimeline->projectView()->checkTrackHeight();
1343 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1345 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1346 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1347 activateShuttleDevice();
1351 void MainWindow::slotSwitchVideoThumbs() {
1352 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1353 if (m_activeTimeline) {
1354 m_activeTimeline->refresh();
1356 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1359 void MainWindow::slotSwitchAudioThumbs() {
1360 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1361 if (m_activeTimeline) {
1362 m_activeTimeline->refresh();
1363 m_activeTimeline->projectView()->checkAutoScroll();
1364 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1366 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1369 void MainWindow::slotSwitchMarkersComments() {
1370 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1371 if (m_activeTimeline) {
1372 m_activeTimeline->refresh();
1374 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1377 void MainWindow::slotSwitchSnap() {
1378 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1379 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1383 void MainWindow::slotDeleteTimelineClip() {
1384 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1385 else if (m_activeTimeline) {
1386 m_activeTimeline->projectView()->deleteSelectedClips();
1390 void MainWindow::slotChangeClipSpeed() {
1391 if (m_activeTimeline) {
1392 m_activeTimeline->projectView()->changeClipSpeed();
1396 void MainWindow::slotAddClipMarker() {
1397 if (m_activeTimeline) {
1398 m_activeTimeline->projectView()->slotAddClipMarker();
1402 void MainWindow::slotDeleteClipMarker() {
1403 if (m_activeTimeline) {
1404 m_activeTimeline->projectView()->slotDeleteClipMarker();
1408 void MainWindow::slotDeleteAllClipMarkers() {
1409 if (m_activeTimeline) {
1410 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1414 void MainWindow::slotEditClipMarker() {
1415 if (m_activeTimeline) {
1416 m_activeTimeline->projectView()->slotEditClipMarker();
1420 void MainWindow::slotAddGuide() {
1421 if (m_activeTimeline)
1422 m_activeTimeline->projectView()->slotAddGuide();
1425 void MainWindow::slotEditGuide() {
1426 if (m_activeTimeline)
1427 m_activeTimeline->projectView()->slotEditGuide();
1430 void MainWindow::slotDeleteGuide() {
1431 if (m_activeTimeline)
1432 m_activeTimeline->projectView()->slotDeleteGuide();
1435 void MainWindow::slotDeleteAllGuides() {
1436 if (m_activeTimeline)
1437 m_activeTimeline->projectView()->slotDeleteAllGuides();
1440 void MainWindow::slotCutTimelineClip() {
1441 if (m_activeTimeline) {
1442 m_activeTimeline->projectView()->cutSelectedClips();
1446 void MainWindow::slotAddProjectClip(KUrl url) {
1447 if (m_activeDocument)
1448 m_activeDocument->slotAddClipFile(url, QString());
1451 void MainWindow::slotAddTransition(QAction *result) {
1452 if (!result) return;
1453 QDomElement effect = transitions.getEffectByName(result->data().toString());
1454 if (m_activeTimeline) {
1455 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1459 void MainWindow::slotAddVideoEffect(QAction *result) {
1460 if (!result) return;
1461 QStringList info = result->data().toStringList();
1462 if (info.isEmpty()) return;
1463 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1464 slotAddEffect(effect);
1467 void MainWindow::slotAddAudioEffect(QAction *result) {
1468 if (!result) return;
1469 QStringList info = result->data().toStringList();
1470 if (info.isEmpty()) return;
1471 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1472 slotAddEffect(effect);
1475 void MainWindow::slotAddCustomEffect(QAction *result) {
1476 if (!result) return;
1477 QStringList info = result->data().toStringList();
1478 if (info.isEmpty()) return;
1479 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1480 slotAddEffect(effect);
1483 void MainWindow::slotZoomIn() {
1484 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1487 void MainWindow::slotZoomOut() {
1488 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1491 void MainWindow::slotFitZoom() {
1492 if (m_activeTimeline) {
1493 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1497 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1498 statusProgressBar->setValue(progress);
1499 if (progress >= 0) {
1500 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1501 statusProgressBar->setVisible(true);
1503 m_messageLabel->setMessage(QString(), DefaultMessage);
1504 statusProgressBar->setVisible(false);
1508 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1509 if (clip->clipType() == TEXT) {
1510 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1511 QString path = clip->getProperty("resource");
1512 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1514 doc.setContent(clip->getProperty("xmldata"));
1515 dia_ui->setXml(doc);
1516 if (dia_ui->exec() == QDialog::Accepted) {
1517 QPixmap pix = dia_ui->renderedPixmap();
1519 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1520 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1521 QMap <QString, QString> newprops;
1522 newprops.insert("xmldata", dia_ui->xml().toString());
1523 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1524 m_activeDocument->commandStack()->push(command);
1525 m_clipMonitor->refreshMonitor(true);
1526 m_activeDocument->setModified(true);
1530 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1533 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1534 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1535 if (dia.exec() == QDialog::Accepted) {
1536 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1537 m_activeDocument->commandStack()->push(command);
1539 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1540 if (dia.needsTimelineRefresh()) {
1541 // update clip occurences in timeline
1542 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1547 void MainWindow::customEvent(QEvent* e) {
1548 if (e->type() == QEvent::User) {
1549 // The timeline playing position changed...
1550 kDebug() << "RECIEVED JOG EVEMNT!!!";
1553 void MainWindow::slotActivateEffectStackView() {
1554 effectStack->raiseWindow(effectStackDock);
1557 void MainWindow::slotActivateTransitionView() {
1558 transitionConfig->raiseWindow(transitionConfigDock);
1561 void MainWindow::slotSnapRewind() {
1562 if (m_projectMonitor->isActive()) {
1563 if (m_activeTimeline)
1564 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1568 void MainWindow::slotSnapForward() {
1569 if (m_projectMonitor->isActive()) {
1570 if (m_activeTimeline)
1571 m_activeTimeline->projectView()->slotSeekToNextSnap();
1575 void MainWindow::slotClipStart() {
1576 if (m_projectMonitor->isActive()) {
1577 if (m_activeTimeline)
1578 m_activeTimeline->projectView()->clipStart();
1582 void MainWindow::slotClipEnd() {
1583 if (m_projectMonitor->isActive()) {
1584 if (m_activeTimeline)
1585 m_activeTimeline->projectView()->clipEnd();
1589 void MainWindow::slotChangeTool(QAction * action) {
1590 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1591 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1594 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1595 if (m_activeDocument && m_activeTimeline) {
1596 //m_activeDocument->setTool(tool);
1597 m_activeTimeline->projectView()->setTool(tool);
1601 void MainWindow::slotCopy() {
1602 if (!m_activeDocument || !m_activeTimeline) return;
1603 m_activeTimeline->projectView()->copyClip();
1606 void MainWindow::slotPaste() {
1607 if (!m_activeDocument || !m_activeTimeline) return;
1608 m_activeTimeline->projectView()->pasteClip();
1611 void MainWindow::slotPasteEffects() {
1612 if (!m_activeDocument || !m_activeTimeline) return;
1613 m_activeTimeline->projectView()->pasteClipEffects();
1616 void MainWindow::slotFind() {
1617 if (!m_activeDocument || !m_activeTimeline) return;
1618 m_projectSearch->setEnabled(false);
1619 m_findActivated = true;
1620 m_findString = QString();
1621 m_activeTimeline->projectView()->initSearchStrings();
1622 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1623 m_findTimer.start(5000);
1624 qApp->installEventFilter(this);
1627 void MainWindow::slotFindNext() {
1628 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1629 statusBar()->showMessage(i18n("Found : %1", m_findString));
1631 statusBar()->showMessage(i18n("Reached end of project"));
1633 m_findTimer.start(4000);
1636 void MainWindow::findAhead() {
1637 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1638 m_projectSearchNext->setEnabled(true);
1639 statusBar()->showMessage(i18n("Found : %1", m_findString));
1641 m_projectSearchNext->setEnabled(false);
1642 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1646 void MainWindow::findTimeout() {
1647 m_projectSearchNext->setEnabled(false);
1648 m_findActivated = false;
1649 m_findString = QString();
1650 statusBar()->showMessage(i18n("Find stopped"), 3000);
1651 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1652 m_projectSearch->setEnabled(true);
1653 removeEventFilter(this);
1656 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1657 if (m_findActivated) {
1658 if (ke->key() == Qt::Key_Backspace) {
1659 m_findString = m_findString.left(m_findString.length() - 1);
1661 if (!m_findString.isEmpty()) {
1667 m_findTimer.start(4000);
1670 } else if (ke->key() == Qt::Key_Escape) {
1674 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1675 m_findString += ke->text();
1679 m_findTimer.start(4000);
1683 } else KXmlGuiWindow::keyPressEvent(ke);
1686 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1687 if (m_findActivated) {
1688 if (event->type() == QEvent::ShortcutOverride) {
1689 QKeyEvent* ke = (QKeyEvent*) event;
1690 if (ke->text().trimmed().isEmpty()) return false;
1693 } else return false;
1695 // pass the event on to the parent class
1696 return QMainWindow::eventFilter(obj, event);
1700 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1701 KDialog *dialog = new KDialog(this);
1702 dialog->setCaption("Save clip zone");
1703 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1705 QWidget *widget = new QWidget(dialog);
1706 dialog->setMainWidget(widget);
1708 QVBoxLayout *vbox = new QVBoxLayout(widget);
1709 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1710 QString path = m_activeDocument->projectFolder().path();
1712 path.append("untitled.westley");
1713 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1714 url->setFilter("video/mlt-playlist");
1715 QLabel *label2 = new QLabel(i18n("Description:"), this);
1716 KLineEdit *edit = new KLineEdit(this);
1717 vbox->addWidget(label1);
1718 vbox->addWidget(url);
1719 vbox->addWidget(label2);
1720 vbox->addWidget(edit);
1721 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1725 void MainWindow::slotSetInPoint() {
1726 if (m_clipMonitor->isActive()) {
1727 m_clipMonitor->slotSetZoneStart();
1728 } else m_activeTimeline->projectView()->setInPoint();
1731 void MainWindow::slotSetOutPoint() {
1732 if (m_clipMonitor->isActive()) {
1733 m_clipMonitor->slotSetZoneEnd();
1734 } else m_activeTimeline->projectView()->setOutPoint();
1737 #include "mainwindow.moc"