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 // build effects menus
210 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
212 QStringList effectInfo;
213 QMap<QString, QStringList> effectsList;
214 for (int ix = 0; ix < videoEffects.count(); ix++) {
215 effectInfo = videoEffects.effectIdInfo(ix);
216 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
219 foreach(QStringList value, effectsList) {
220 action = new QAction(value.at(0), this);
221 action->setData(value);
222 videoEffectsMenu->addAction(action);
225 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
229 for (int ix = 0; ix < audioEffects.count(); ix++) {
230 effectInfo = audioEffects.effectIdInfo(ix);
231 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
234 foreach(QStringList value, effectsList) {
235 action = new QAction(value.at(0), this);
236 action->setData(value);
237 audioEffectsMenu->addAction(action);
240 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
242 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
243 else m_customEffectsMenu->setEnabled(true);
246 for (int ix = 0; ix < customEffects.count(); ix++) {
247 effectInfo = customEffects.effectIdInfo(ix);
248 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
251 foreach(QStringList value, effectsList) {
252 action = new QAction(value.at(0), this);
253 action->setData(value);
254 m_customEffectsMenu->addAction(action);
257 QMenu *newEffect = new QMenu(this);
258 newEffect->addMenu(videoEffectsMenu);
259 newEffect->addMenu(audioEffectsMenu);
260 newEffect->addMenu(m_customEffectsMenu);
261 effectStack->setMenu(newEffect);
264 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
265 const QList<QAction *> viewActions = createPopupMenu()->actions();
266 viewMenu->insertActions(NULL, viewActions);
268 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
269 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
270 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
272 m_timelineContextMenu = new QMenu(this);
273 m_timelineContextClipMenu = new QMenu(this);
274 m_timelineContextTransitionMenu = new QMenu(this);
277 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
278 QStringList effects = transitions.effectNames();
279 foreach(const QString &name, effects) {
280 action = new QAction(name, this);
281 action->setData(name);
282 transitionsMenu->addAction(action);
284 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
286 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
288 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
289 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
290 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
291 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
292 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
294 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
295 m_timelineContextClipMenu->addMenu(markersMenu);
296 m_timelineContextClipMenu->addMenu(transitionsMenu);
297 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
298 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
299 //TODO: re-enable custom effects menu when it is implemented
300 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
302 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
303 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
305 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
306 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
307 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
308 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
309 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
310 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
312 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
313 slotConnectMonitors();
315 setAutoSaveSettings();
317 if (KdenliveSettings::openlastproject()) {
320 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
321 if (!staleFiles.isEmpty()) {
322 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) {
323 recoverFiles(staleFiles);
331 activateShuttleDevice();
332 projectListDock->raise();
335 void MainWindow::queryQuit() {
336 kDebug() << "----- SAVING CONFUIG";
337 if (queryClose()) kapp->quit();
341 bool MainWindow::queryClose() {
343 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
344 if (m_activeDocument && m_activeDocument->isModified()) {
345 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
346 case KMessageBox::Yes :
347 // save document here. If saving fails, return false;
350 case KMessageBox::No :
359 void MainWindow::saveProperties(KConfig*) {
360 // save properties here,used by session management
365 void MainWindow::readProperties(KConfig *config) {
366 // read properties here,used by session management
367 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
368 openFile(KUrl(Lastproject));
371 void MainWindow::slotReloadEffects() {
372 initEffects::parseCustomEffectsFile();
373 m_customEffectsMenu->clear();
374 const QStringList effects = customEffects.effectNames();
376 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
377 else m_customEffectsMenu->setEnabled(true);
379 foreach(const QString &name, effects) {
380 action = new QAction(name, this);
381 action->setData(name);
382 m_customEffectsMenu->addAction(action);
384 m_effectList->reloadEffectList();
387 void MainWindow::activateShuttleDevice() {
388 if (m_jogProcess) delete m_jogProcess;
390 if (KdenliveSettings::enableshuttle() == false) return;
391 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
392 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
393 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
394 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
395 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
396 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
397 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
400 void MainWindow::slotShuttleButton(int code) {
403 slotShuttleAction(KdenliveSettings::shuttle1());
406 slotShuttleAction(KdenliveSettings::shuttle2());
409 slotShuttleAction(KdenliveSettings::shuttle3());
412 slotShuttleAction(KdenliveSettings::shuttle4());
415 slotShuttleAction(KdenliveSettings::shuttle5());
420 void MainWindow::slotShuttleAction(int code) {
425 m_monitorManager->slotPlay();
428 m_monitorManager->slotPlay();
433 void MainWindow::configureNotifications() {
434 KNotifyConfigWidget::configure(this);
437 void MainWindow::slotFullScreen() {
438 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
441 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
442 if (!m_activeDocument) return;
443 if (effect.isNull()) {
444 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
447 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
448 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
451 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
452 if (clipMonitor) clipMonitorDock->raise();
453 else projectMonitorDock->raise();
456 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
457 if (!m_activeDocument) return;
458 m_activeDocument->setProducerDuration(id, duration);
461 void MainWindow::slotConnectMonitors() {
463 m_projectList->setRenderer(m_clipMonitor->render);
464 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
465 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
466 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
467 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
468 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 > &)));
470 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
472 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
474 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
475 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
477 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
478 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
481 void MainWindow::slotAdjustClipMonitor() {
482 clipMonitorDock->updateGeometry();
483 clipMonitorDock->adjustSize();
484 m_clipMonitor->resetSize();
487 void MainWindow::slotAdjustProjectMonitor() {
488 projectMonitorDock->updateGeometry();
489 projectMonitorDock->adjustSize();
490 m_projectMonitor->resetSize();
493 void MainWindow::setupActions() {
495 KActionCollection* collection = actionCollection();
496 m_timecodeFormat = new KComboBox(this);
497 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
498 m_timecodeFormat->addItem(i18n("Frames"));
500 statusProgressBar = new QProgressBar(this);
501 statusProgressBar->setMinimum(0);
502 statusProgressBar->setMaximum(100);
503 statusProgressBar->setMaximumWidth(150);
504 statusProgressBar->setVisible(false);
506 QWidget *w = new QWidget;
508 QHBoxLayout *layout = new QHBoxLayout;
509 w->setLayout(layout);
510 layout->setContentsMargins(5, 0, 5, 0);
511 QToolBar *toolbar = new QToolBar("statusToolBar", this);
514 m_toolGroup = new QActionGroup(this);
516 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;}";
518 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
519 m_buttonSelectTool->setCheckable(true);
520 m_buttonSelectTool->setChecked(true);
522 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
523 m_buttonRazorTool->setCheckable(true);
524 m_buttonRazorTool->setChecked(false);
526 m_toolGroup->addAction(m_buttonSelectTool);
527 m_toolGroup->addAction(m_buttonRazorTool);
528 m_toolGroup->setExclusive(true);
529 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
531 QWidget * actionWidget;
532 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
533 actionWidget->setMaximumWidth(24);
534 actionWidget->setMinimumHeight(17);
536 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
537 actionWidget->setMaximumWidth(24);
538 actionWidget->setMinimumHeight(17);
540 toolbar->setStyleSheet(style1);
541 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
543 toolbar->addSeparator();
544 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
545 m_buttonFitZoom->setCheckable(false);
546 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
548 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
549 actionWidget->setMaximumWidth(24);
550 actionWidget->setMinimumHeight(17);
552 m_zoomSlider = new QSlider(Qt::Horizontal, this);
553 m_zoomSlider->setMaximum(13);
554 m_zoomSlider->setPageStep(1);
556 m_zoomSlider->setMaximumWidth(150);
557 m_zoomSlider->setMinimumWidth(100);
559 const int contentHeight = QFontMetrics(w->font()).height() + 8;
561 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
562 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
564 m_zoomSlider->setStyleSheet(style);
566 //m_zoomSlider->height() + 5;
567 statusBar()->setMinimumHeight(contentHeight);
570 toolbar->addWidget(m_zoomSlider);
572 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
573 m_buttonVideoThumbs->setCheckable(true);
574 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
575 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
577 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
578 m_buttonAudioThumbs->setCheckable(true);
579 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
580 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
582 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
583 m_buttonShowMarkers->setCheckable(true);
584 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
585 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
587 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
588 m_buttonSnap->setCheckable(true);
589 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
590 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
591 layout->addWidget(toolbar);
594 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
595 actionWidget->setMaximumWidth(24);
596 actionWidget->setMinimumHeight(17);
598 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
599 actionWidget->setMaximumWidth(24);
600 actionWidget->setMinimumHeight(17);
602 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
603 actionWidget->setMaximumWidth(24);
604 actionWidget->setMinimumHeight(17);
606 actionWidget = toolbar->widgetForAction(m_buttonSnap);
607 actionWidget->setMaximumWidth(24);
608 actionWidget->setMinimumHeight(17);
610 m_messageLabel = new StatusBarMessageLabel(this);
611 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
613 statusBar()->addWidget(m_messageLabel, 10);
614 statusBar()->addWidget(statusProgressBar, 0);
615 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
616 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
617 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
618 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
619 m_messageLabel->hide();
621 collection->addAction("select_tool", m_buttonSelectTool);
622 collection->addAction("razor_tool", m_buttonRazorTool);
624 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
625 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
626 collection->addAction("show_markers", m_buttonShowMarkers);
627 collection->addAction("snap", m_buttonSnap);
628 collection->addAction("zoom_fit", m_buttonFitZoom);
630 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
631 collection->addAction("project_find", m_projectSearch);
632 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
633 m_projectSearch->setShortcut(Qt::Key_Slash);
635 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
636 collection->addAction("project_find_next", m_projectSearchNext);
637 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
638 m_projectSearchNext->setShortcut(Qt::Key_F3);
639 m_projectSearchNext->setEnabled(false);
641 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
642 collection->addAction("manage_profiles", profilesAction);
643 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
645 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
646 collection->addAction("project_settings", projectAction);
647 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
649 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
650 collection->addAction("project_render", projectRender);
651 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
653 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
654 KShortcut playShortcut;
655 playShortcut.setPrimary(Qt::Key_Space);
656 playShortcut.setAlternate(Qt::Key_K);
657 monitorPlay->setShortcut(playShortcut);
658 collection->addAction("monitor_play", monitorPlay);
659 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
661 KAction *markIn = collection->addAction("mark_in");
662 markIn->setText(i18n("Set In Point"));
663 markIn->setShortcut(Qt::Key_I);
664 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
666 KAction *markOut = collection->addAction("mark_out");
667 markOut->setText(i18n("Set Out Point"));
668 markOut->setShortcut(Qt::Key_O);
669 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
671 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
672 monitorSeekBackward->setShortcut(Qt::Key_J);
673 collection->addAction("monitor_seek_backward", monitorSeekBackward);
674 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
676 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
677 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
678 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
679 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
681 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
682 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
683 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
684 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
686 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
687 monitorSeekForward->setShortcut(Qt::Key_L);
688 collection->addAction("monitor_seek_forward", monitorSeekForward);
689 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
691 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
692 clipStart->setShortcut(Qt::Key_Home);
693 collection->addAction("seek_clip_start", clipStart);
694 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
696 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
697 clipEnd->setShortcut(Qt::Key_End);
698 collection->addAction("seek_clip_end", clipEnd);
699 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
701 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
702 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
703 collection->addAction("seek_start", projectStart);
704 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
706 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
707 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
708 collection->addAction("seek_end", projectEnd);
709 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
711 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
712 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
713 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
714 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
716 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
717 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
718 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
719 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
721 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
722 deleteTimelineClip->setShortcut(Qt::Key_Delete);
723 collection->addAction("delete_timeline_clip", deleteTimelineClip);
724 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
726 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
727 collection->addAction("change_clip_speed", editTimelineClipSpeed);
728 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
730 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
731 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
732 collection->addAction("cut_timeline_clip", cutTimelineClip);
733 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
735 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
736 collection->addAction("add_clip_marker", addClipMarker);
737 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
739 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
740 collection->addAction("delete_clip_marker", deleteClipMarker);
741 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
743 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
744 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
745 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
747 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
748 collection->addAction("edit_clip_marker", editClipMarker);
749 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
751 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
752 collection->addAction("add_guide", addGuide);
753 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
755 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
756 collection->addAction("delete_guide", delGuide);
757 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
759 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
760 collection->addAction("edit_guide", editGuide);
761 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
763 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
764 collection->addAction("delete_all_guides", delAllGuides);
765 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
767 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
768 collection->addAction("paste_effects", pasteEffects);
769 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
771 KStandardAction::quit(this, SLOT(queryQuit()),
774 KStandardAction::open(this, SLOT(openFile()),
777 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
780 KStandardAction::saveAs(this, SLOT(saveFileAs()),
783 KStandardAction::openNew(this, SLOT(newFile()),
786 KStandardAction::preferences(this, SLOT(slotPreferences()),
789 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
791 KStandardAction::copy(this, SLOT(slotCopy()),
794 KStandardAction::paste(this, SLOT(slotPaste()),
797 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
799 undo->setEnabled(false);
800 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
802 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
804 redo->setEnabled(false);
805 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
807 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
809 connect(collection, SIGNAL(actionHovered(QAction*)),
810 this, SLOT(slotDisplayActionMessage(QAction*)));
811 //connect(collection, SIGNAL( clearStatusText() ),
812 //statusBar(), SLOT( clear() ) );
815 void MainWindow::slotDisplayActionMessage(QAction *a) {
816 statusBar()->showMessage(a->data().toString(), 3000);
819 void MainWindow::saveOptions() {
820 KdenliveSettings::self()->writeConfig();
821 KSharedConfigPtr config = KGlobal::config();
822 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
826 void MainWindow::readOptions() {
827 KSharedConfigPtr config = KGlobal::config();
828 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
829 KConfigGroup initialGroup(config, "version");
830 if (!initialGroup.exists()) {
831 // this is our first run, show Wizard
832 Wizard *w = new Wizard(this);
833 if (w->exec() == QDialog::Accepted && w->isOk()) {
835 initialGroup.writeEntry("version", "0.7");
843 void MainWindow::newFile() {
846 QPoint projectTracks(3, 2);
847 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
849 ProjectSettings *w = new ProjectSettings;
850 if (w->exec() != QDialog::Accepted) return;
851 profileName = w->selectedProfile();
852 projectFolder = w->selectedFolder();
853 projectTracks = w->tracks();
856 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
857 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
858 TrackView *trackView = new TrackView(doc, this);
859 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
860 if (m_timelineArea->count() == 1) {
861 connectDocumentInfo(doc);
862 connectDocument(trackView, doc);
863 } else m_timelineArea->setTabBarHidden(false);
866 void MainWindow::activateDocument() {
867 if (m_timelineArea->currentWidget() == NULL) return;
868 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
869 KdenliveDoc *currentDoc = currentTab->document();
870 connectDocumentInfo(currentDoc);
871 connectDocument(currentTab, currentDoc);
874 void MainWindow::closeCurrentDocument() {
875 QWidget *w = m_timelineArea->currentWidget();
876 // closing current document
877 int ix = m_timelineArea->currentIndex() + 1;
878 if (ix == m_timelineArea->count()) ix = 0;
879 m_timelineArea->setCurrentIndex(ix);
880 TrackView *tabToClose = (TrackView *) w;
881 KdenliveDoc *docToClose = tabToClose->document();
882 if (docToClose && docToClose->isModified()) {
883 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
884 case KMessageBox::Yes :
885 // save document here. If saving fails, return false;
888 case KMessageBox::Cancel :
894 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
895 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
898 if (m_timelineArea->count() == 0) {
899 m_activeDocument = NULL;
900 effectStack->clear();
901 transitionConfig->slotTransitionItemSelected(NULL);
905 void MainWindow::saveFileAs(const QString &outputFileName) {
906 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
907 m_activeDocument->setUrl(KUrl(outputFileName));
908 if (m_activeDocument->m_autosave == NULL) {
909 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
910 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
911 setCaption(m_activeDocument->description());
912 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
913 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
914 m_activeDocument->setModified(false);
915 m_fileOpenRecent->addUrl(KUrl(outputFileName));
918 void MainWindow::saveFileAs() {
919 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
920 if (QFile::exists(outputFile)) {
921 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
923 saveFileAs(outputFile);
926 void MainWindow::saveFile() {
927 if (!m_activeDocument) return;
928 if (m_activeDocument->url().isEmpty()) {
931 saveFileAs(m_activeDocument->url().path());
932 m_activeDocument->m_autosave->resize(0);
936 void MainWindow::openFile() {
937 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
938 if (url.isEmpty()) return;
939 m_fileOpenRecent->addUrl(url);
943 void MainWindow::openLastFile() {
944 KSharedConfigPtr config = KGlobal::config();
945 KUrl::List urls = m_fileOpenRecent->urls();
946 if (urls.isEmpty()) newFile();
947 else openFile(urls.last());
950 void MainWindow::openFile(const KUrl &url) {
951 // Check if the document is already opened
952 const int ct = m_timelineArea->count();
953 bool isOpened = false;
955 for (i = 0; i < ct; i++) {
956 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
957 KdenliveDoc *doc = tab->document();
958 if (doc->url() == url) {
964 m_timelineArea->setCurrentIndex(i);
968 // Check for backup file
969 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
970 if (!staleFiles.isEmpty()) {
971 if (KMessageBox::questionYesNo(this,
972 i18n("Auto-saved files exist. Do you want to recover them now?"),
973 i18n("File Recovery"),
974 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
975 recoverFiles(staleFiles);
978 // remove the stale files
979 foreach(KAutoSaveFile *stale, staleFiles) {
980 stale->open(QIODevice::ReadWrite);
985 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
986 doOpenFile(url, NULL);
989 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
991 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
993 stale = new KAutoSaveFile(url, doc);
994 doc->m_autosave = stale;
996 doc->m_autosave = stale;
997 doc->setUrl(stale->managedFile());
998 doc->setModified(true);
999 stale->setParent(doc);
1001 connectDocumentInfo(doc);
1002 TrackView *trackView = new TrackView(doc, this);
1003 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1004 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1005 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1006 slotGotProgressInfo(QString(), -1);
1007 m_clipMonitor->refreshMonitor(true);
1010 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1011 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1012 foreach(KAutoSaveFile *stale, staleFiles) {
1013 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1014 // show an error message; we could not steal the lockfile
1015 // maybe another application got to the file before us?
1019 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1020 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1021 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1022 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1027 void MainWindow::parseProfiles(const QString &mltPath) {
1028 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1030 //KdenliveSettings::setDefaulttmpfolder();
1031 if (!mltPath.isEmpty()) {
1032 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1033 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1036 if (KdenliveSettings::mltpath().isEmpty()) {
1037 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1039 if (KdenliveSettings::rendererpath().isEmpty()) {
1040 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1041 if (!QFile::exists(inigoPath))
1042 inigoPath = KStandardDirs::findExe("inigo");
1043 else KdenliveSettings::setRendererpath(inigoPath);
1045 QStringList profilesFilter;
1046 profilesFilter << "*";
1047 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1049 if (profilesList.isEmpty()) {
1050 // Cannot find MLT path, try finding inigo
1051 QString profilePath = KdenliveSettings::rendererpath();
1052 if (!profilePath.isEmpty()) {
1053 profilePath = profilePath.section('/', 0, -3);
1054 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1055 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1058 if (profilesList.isEmpty()) {
1059 // Cannot find the MLT profiles, ask for location
1060 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1061 getUrl->fileDialog()->setMode(KFile::Directory);
1062 if (getUrl->exec() == QDialog::Rejected) {
1065 KUrl mltPath = getUrl->selectedUrl();
1067 if (mltPath.isEmpty()) ::exit(0);
1068 KdenliveSettings::setMltpath(mltPath.path());
1069 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1073 if (KdenliveSettings::rendererpath().isEmpty()) {
1074 // Cannot find the MLT inigo renderer, ask for location
1075 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1076 if (getUrl->exec() == QDialog::Rejected) {
1079 KUrl rendererPath = getUrl->selectedUrl();
1081 if (rendererPath.isEmpty()) ::exit(0);
1082 KdenliveSettings::setRendererpath(rendererPath.path());
1085 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1087 // Parse MLT profiles to build a list of available video formats
1088 if (profilesList.isEmpty()) parseProfiles();
1092 void MainWindow::slotEditProfiles() {
1093 ProfilesDialog *w = new ProfilesDialog;
1098 void MainWindow::slotEditProjectSettings() {
1099 ProjectSettings *w = new ProjectSettings;
1100 if (w->exec() == QDialog::Accepted) {
1101 QString profile = w->selectedProfile();
1102 m_activeDocument->setProfilePath(profile);
1103 KdenliveSettings::setCurrent_profile(profile);
1104 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1105 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1106 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1107 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1108 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1110 // We need to desactivate & reactivate monitors to get a refresh
1111 m_monitorManager->switchMonitors();
1116 void MainWindow::slotRenderProject() {
1117 if (!m_renderWidget) {
1118 m_renderWidget = new RenderWidget(this);
1119 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)));
1120 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1122 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1123 if (currentTab) m_renderWidget->setTimeline(currentTab);
1124 m_renderWidget->setDocument(m_activeDocument);*/
1125 m_renderWidget->show();
1128 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) {
1129 if (dest.isEmpty()) return;
1132 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1133 if (currentTab && zoneOnly) {
1134 in = currentTab->inPoint();
1135 out = currentTab->outPoint();
1137 KTemporaryFile temp;
1138 temp.setAutoRemove(false);
1139 temp.setSuffix(".westley");
1141 m_projectMonitor->saveSceneList(temp.fileName());
1144 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1145 else if (guideStart != -1) {
1146 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1148 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1149 QString videoPlayer = "-";
1151 videoPlayer = KdenliveSettings::defaultplayerapp();
1152 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."));
1154 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1155 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1158 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1159 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1160 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1161 QProcess::startDetached(renderer, args);
1163 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1167 void MainWindow::slotUpdateMousePosition(int pos) {
1168 if (m_activeDocument)
1169 switch (m_timecodeFormat->currentIndex()) {
1171 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1174 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1178 void MainWindow::slotUpdateDocumentState(bool modified) {
1179 setCaption(m_activeDocument->description(), modified);
1180 m_saveAction->setEnabled(modified);
1182 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1183 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1185 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1186 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1190 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1191 if (m_activeDocument) {
1192 if (m_activeDocument == doc) return;
1193 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1195 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1198 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1199 //m_projectMonitor->stop();
1200 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1201 if (m_activeDocument) {
1202 if (m_activeDocument == doc) return;
1203 m_activeDocument->backupMltPlaylist();
1204 if (m_activeTimeline) {
1205 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1206 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1207 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1208 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1209 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1210 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1211 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1212 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1213 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1214 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1215 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1216 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1217 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1218 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1219 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1220 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1221 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1222 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1224 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1225 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1226 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1227 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1228 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1229 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1230 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1231 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1232 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1233 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1234 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1235 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1236 effectStack->clear();
1238 m_activeDocument->setRenderer(NULL);
1239 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1240 m_clipMonitor->stop();
1242 KdenliveSettings::setCurrent_profile(doc->profilePath());
1243 KdenliveSettings::setProject_fps(doc->fps());
1244 m_monitorManager->resetProfiles(doc->timecode());
1245 m_projectList->setDocument(doc);
1246 transitionConfig->updateProjectFormat(doc->mltProfile());
1247 effectStack->updateProjectFormat(doc->mltProfile());
1248 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1249 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1250 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1251 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1252 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1253 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1254 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1255 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1256 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1257 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1258 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1259 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1261 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1262 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1263 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1266 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1267 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1268 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1269 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1270 m_zoomSlider->setValue(doc->zoom());
1271 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1272 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1273 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1274 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1276 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1279 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1280 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1281 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1282 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1283 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1284 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1285 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1286 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1288 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1289 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1290 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1292 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1293 m_activeTimeline = trackView;
1294 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1295 doc->setRenderer(m_projectMonitor->render);
1296 m_commandStack->setActiveStack(doc->commandStack());
1297 KdenliveSettings::setProject_display_ratio(doc->dar());
1298 m_projectList->updateAllClips();
1299 //doc->clipManager()->checkAudioThumbs();
1301 //m_overView->setScene(trackView->projectScene());
1302 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1303 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1305 setCaption(doc->description(), doc->isModified());
1306 m_saveAction->setEnabled(doc->isModified());
1307 m_activeDocument = doc;
1310 void MainWindow::slotGuidesUpdated() {
1311 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1314 void MainWindow::slotPreferences(int page, int option) {
1315 //An instance of your dialog could be already created and could be
1316 // cached, in which case you want to display the cached dialog
1317 // instead of creating another one
1318 if (KConfigDialog::showDialog("settings")) {
1319 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1323 // KConfigDialog didn't find an instance of this dialog, so lets
1325 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1326 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1327 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1329 if (page != -1) dialog->showPage(page, option);
1332 void MainWindow::updateConfiguration() {
1333 //TODO: we should apply settings to all projects, not only the current one
1334 if (m_activeTimeline) {
1335 m_activeTimeline->refresh();
1336 m_activeTimeline->projectView()->checkAutoScroll();
1337 m_activeTimeline->projectView()->checkTrackHeight();
1338 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1340 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1341 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1342 activateShuttleDevice();
1346 void MainWindow::slotSwitchVideoThumbs() {
1347 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1348 if (m_activeTimeline) {
1349 m_activeTimeline->refresh();
1351 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1354 void MainWindow::slotSwitchAudioThumbs() {
1355 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1356 if (m_activeTimeline) {
1357 m_activeTimeline->refresh();
1358 m_activeTimeline->projectView()->checkAutoScroll();
1359 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1361 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1364 void MainWindow::slotSwitchMarkersComments() {
1365 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1366 if (m_activeTimeline) {
1367 m_activeTimeline->refresh();
1369 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1372 void MainWindow::slotSwitchSnap() {
1373 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1374 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1378 void MainWindow::slotDeleteTimelineClip() {
1379 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1380 else if (m_activeTimeline) {
1381 m_activeTimeline->projectView()->deleteSelectedClips();
1385 void MainWindow::slotChangeClipSpeed() {
1386 if (m_activeTimeline) {
1387 m_activeTimeline->projectView()->changeClipSpeed();
1391 void MainWindow::slotAddClipMarker() {
1392 if (m_activeTimeline) {
1393 m_activeTimeline->projectView()->slotAddClipMarker();
1397 void MainWindow::slotDeleteClipMarker() {
1398 if (m_activeTimeline) {
1399 m_activeTimeline->projectView()->slotDeleteClipMarker();
1403 void MainWindow::slotDeleteAllClipMarkers() {
1404 if (m_activeTimeline) {
1405 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1409 void MainWindow::slotEditClipMarker() {
1410 if (m_activeTimeline) {
1411 m_activeTimeline->projectView()->slotEditClipMarker();
1415 void MainWindow::slotAddGuide() {
1416 if (m_activeTimeline)
1417 m_activeTimeline->projectView()->slotAddGuide();
1420 void MainWindow::slotEditGuide() {
1421 if (m_activeTimeline)
1422 m_activeTimeline->projectView()->slotEditGuide();
1425 void MainWindow::slotDeleteGuide() {
1426 if (m_activeTimeline)
1427 m_activeTimeline->projectView()->slotDeleteGuide();
1430 void MainWindow::slotDeleteAllGuides() {
1431 if (m_activeTimeline)
1432 m_activeTimeline->projectView()->slotDeleteAllGuides();
1435 void MainWindow::slotCutTimelineClip() {
1436 if (m_activeTimeline) {
1437 m_activeTimeline->projectView()->cutSelectedClips();
1441 void MainWindow::slotAddProjectClip(KUrl url) {
1442 if (m_activeDocument)
1443 m_activeDocument->slotAddClipFile(url, QString());
1446 void MainWindow::slotAddTransition(QAction *result) {
1447 if (!result) return;
1448 QDomElement effect = transitions.getEffectByName(result->data().toString());
1449 if (m_activeTimeline) {
1450 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1454 void MainWindow::slotAddVideoEffect(QAction *result) {
1455 if (!result) return;
1456 QStringList info = result->data().toStringList();
1457 if (info.isEmpty()) return;
1458 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1459 slotAddEffect(effect);
1462 void MainWindow::slotAddAudioEffect(QAction *result) {
1463 if (!result) return;
1464 QStringList info = result->data().toStringList();
1465 if (info.isEmpty()) return;
1466 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1467 slotAddEffect(effect);
1470 void MainWindow::slotAddCustomEffect(QAction *result) {
1471 if (!result) return;
1472 QStringList info = result->data().toStringList();
1473 if (info.isEmpty()) return;
1474 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1475 slotAddEffect(effect);
1478 void MainWindow::slotZoomIn() {
1479 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1482 void MainWindow::slotZoomOut() {
1483 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1486 void MainWindow::slotFitZoom() {
1487 if (m_activeTimeline) {
1488 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1492 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1493 statusProgressBar->setValue(progress);
1494 if (progress >= 0) {
1495 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1496 statusProgressBar->setVisible(true);
1498 m_messageLabel->setMessage(QString(), DefaultMessage);
1499 statusProgressBar->setVisible(false);
1503 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1504 if (clip->clipType() == TEXT) {
1505 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1506 QString path = clip->getProperty("resource");
1507 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1509 doc.setContent(clip->getProperty("xmldata"));
1510 dia_ui->setXml(doc);
1511 if (dia_ui->exec() == QDialog::Accepted) {
1512 QPixmap pix = dia_ui->renderedPixmap();
1514 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1515 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1516 QMap <QString, QString> newprops;
1517 newprops.insert("xmldata", dia_ui->xml().toString());
1518 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1519 m_activeDocument->commandStack()->push(command);
1520 m_clipMonitor->refreshMonitor(true);
1521 m_activeDocument->setModified(true);
1525 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1528 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1529 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1530 if (dia.exec() == QDialog::Accepted) {
1531 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1532 m_activeDocument->commandStack()->push(command);
1534 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1535 if (dia.needsTimelineRefresh()) {
1536 // update clip occurences in timeline
1537 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1542 void MainWindow::customEvent(QEvent* e) {
1543 if (e->type() == QEvent::User) {
1544 // The timeline playing position changed...
1545 kDebug() << "RECIEVED JOG EVEMNT!!!";
1548 void MainWindow::slotActivateEffectStackView() {
1549 effectStack->raiseWindow(effectStackDock);
1552 void MainWindow::slotActivateTransitionView() {
1553 transitionConfig->raiseWindow(transitionConfigDock);
1556 void MainWindow::slotSnapRewind() {
1557 if (m_projectMonitor->isActive()) {
1558 if (m_activeTimeline)
1559 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1563 void MainWindow::slotSnapForward() {
1564 if (m_projectMonitor->isActive()) {
1565 if (m_activeTimeline)
1566 m_activeTimeline->projectView()->slotSeekToNextSnap();
1570 void MainWindow::slotClipStart() {
1571 if (m_projectMonitor->isActive()) {
1572 if (m_activeTimeline)
1573 m_activeTimeline->projectView()->clipStart();
1577 void MainWindow::slotClipEnd() {
1578 if (m_projectMonitor->isActive()) {
1579 if (m_activeTimeline)
1580 m_activeTimeline->projectView()->clipEnd();
1584 void MainWindow::slotChangeTool(QAction * action) {
1585 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1586 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1589 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1590 if (m_activeDocument && m_activeTimeline) {
1591 //m_activeDocument->setTool(tool);
1592 m_activeTimeline->projectView()->setTool(tool);
1596 void MainWindow::slotCopy() {
1597 if (!m_activeDocument || !m_activeTimeline) return;
1598 m_activeTimeline->projectView()->copyClip();
1601 void MainWindow::slotPaste() {
1602 if (!m_activeDocument || !m_activeTimeline) return;
1603 m_activeTimeline->projectView()->pasteClip();
1606 void MainWindow::slotPasteEffects() {
1607 if (!m_activeDocument || !m_activeTimeline) return;
1608 m_activeTimeline->projectView()->pasteClipEffects();
1611 void MainWindow::slotFind() {
1612 if (!m_activeDocument || !m_activeTimeline) return;
1613 m_projectSearch->setEnabled(false);
1614 m_findActivated = true;
1615 m_findString = QString();
1616 m_activeTimeline->projectView()->initSearchStrings();
1617 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1618 m_findTimer.start(5000);
1619 qApp->installEventFilter(this);
1622 void MainWindow::slotFindNext() {
1623 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1624 statusBar()->showMessage(i18n("Found : %1", m_findString));
1626 statusBar()->showMessage(i18n("Reached end of project"));
1628 m_findTimer.start(4000);
1631 void MainWindow::findAhead() {
1632 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1633 m_projectSearchNext->setEnabled(true);
1634 statusBar()->showMessage(i18n("Found : %1", m_findString));
1636 m_projectSearchNext->setEnabled(false);
1637 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1641 void MainWindow::findTimeout() {
1642 m_projectSearchNext->setEnabled(false);
1643 m_findActivated = false;
1644 m_findString = QString();
1645 statusBar()->showMessage(i18n("Find stopped"), 3000);
1646 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1647 m_projectSearch->setEnabled(true);
1648 removeEventFilter(this);
1651 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1652 if (m_findActivated) {
1653 if (ke->key() == Qt::Key_Backspace) {
1654 m_findString = m_findString.left(m_findString.length() - 1);
1656 if (!m_findString.isEmpty()) {
1662 m_findTimer.start(4000);
1665 } else if (ke->key() == Qt::Key_Escape) {
1669 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1670 m_findString += ke->text();
1674 m_findTimer.start(4000);
1678 } else KXmlGuiWindow::keyPressEvent(ke);
1681 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1682 if (m_findActivated) {
1683 if (event->type() == QEvent::ShortcutOverride) {
1684 QKeyEvent* ke = (QKeyEvent*) event;
1685 if (ke->text().trimmed().isEmpty()) return false;
1688 } else return false;
1690 // pass the event on to the parent class
1691 return QMainWindow::eventFilter(obj, event);
1695 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1696 KDialog *dialog = new KDialog(this);
1697 dialog->setCaption("Save clip zone");
1698 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1700 QWidget *widget = new QWidget(dialog);
1701 dialog->setMainWidget(widget);
1703 QVBoxLayout *vbox = new QVBoxLayout(widget);
1704 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1705 QString path = m_activeDocument->projectFolder().path();
1707 path.append("untitled.westley");
1708 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1709 url->setFilter("video/mlt-playlist");
1710 QLabel *label2 = new QLabel(i18n("Description:"), this);
1711 KLineEdit *edit = new KLineEdit(this);
1712 vbox->addWidget(label1);
1713 vbox->addWidget(url);
1714 vbox->addWidget(label2);
1715 vbox->addWidget(edit);
1716 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1720 void MainWindow::slotSetInPoint() {
1721 if (m_clipMonitor->isActive()) {
1722 m_clipMonitor->slotSetZoneStart();
1723 } else m_activeTimeline->projectView()->setInPoint();
1726 void MainWindow::slotSetOutPoint() {
1727 if (m_clipMonitor->isActive()) {
1728 m_clipMonitor->slotSetZoneEnd();
1729 } else m_activeTimeline->projectView()->setOutPoint();
1732 #include "mainwindow.moc"