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(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());
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 m_monitorManager = new MonitorManager();
124 projectListDock = new QDockWidget(i18n("Project Tree"), this);
125 projectListDock->setObjectName("project_tree");
126 m_projectList = new ProjectList(this);
127 projectListDock->setWidget(m_projectList);
128 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
130 effectListDock = new QDockWidget(i18n("Effect List"), this);
131 effectListDock->setObjectName("effect_list");
132 m_effectList = new EffectsListView();
134 //m_effectList = new KListWidget(this);
135 effectListDock->setWidget(m_effectList);
136 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
138 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
139 effectStackDock->setObjectName("effect_stack");
140 effectStack = new EffectStackView(this);
141 effectStackDock->setWidget(effectStack);
142 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
144 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
145 transitionConfigDock->setObjectName("transition");
146 transitionConfig = new TransitionSettings(this);
147 transitionConfigDock->setWidget(transitionConfig);
148 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
150 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
151 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
155 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
156 clipMonitorDock->setObjectName("clip_monitor");
157 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
158 clipMonitorDock->setWidget(m_clipMonitor);
159 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
160 //m_clipMonitor->stop();
162 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
163 projectMonitorDock->setObjectName("project_monitor");
164 m_projectMonitor = new Monitor("project", m_monitorManager, this);
165 projectMonitorDock->setWidget(m_projectMonitor);
166 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
168 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
169 recMonitorDock->setObjectName("record_monitor");
170 m_recMonitor = new RecMonitor("record", this);
171 recMonitorDock->setWidget(m_recMonitor);
172 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
174 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
175 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
177 undoViewDock = new QDockWidget(i18n("Undo History"), this);
178 undoViewDock->setObjectName("undo_history");
179 m_undoView = new QUndoView(this);
180 m_undoView->setCleanIcon(KIcon("edit-clear"));
181 m_undoView->setEmptyLabel(i18n("Clean"));
182 undoViewDock->setWidget(m_undoView);
183 m_undoView->setGroup(m_commandStack);
184 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
186 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
187 //overviewDock->setObjectName("project_overview");
188 //m_overView = new CustomTrackView(NULL, NULL, this);
189 //overviewDock->setWidget(m_overView);
190 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
193 //tabifyDockWidget(projectListDock, effectListDock);
194 tabifyDockWidget(projectListDock, effectStackDock);
195 tabifyDockWidget(projectListDock, transitionConfigDock);
196 //tabifyDockWidget(projectListDock, undoViewDock);
199 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
200 tabifyDockWidget(clipMonitorDock, recMonitorDock);
201 setCentralWidget(m_timelineArea);
203 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
204 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
206 // build effects menus
208 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
209 QStringList effects = videoEffects.effectNames();
210 foreach(const QString &name, effects) {
211 action = new QAction(name, this);
212 action->setData(name);
213 videoEffectsMenu->addAction(action);
215 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
216 effects = audioEffects.effectNames();
217 foreach(const QString &name, effects) {
218 action = new QAction(name, this);
219 action->setData(name);
220 audioEffectsMenu->addAction(action);
222 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
223 effects = customEffects.effectNames();
224 foreach(const QString &name, effects) {
225 action = new QAction(name, this);
226 action->setData(name);
227 m_customEffectsMenu->addAction(action);
230 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
231 const QList<QAction *> viewActions = createPopupMenu()->actions();
232 viewMenu->insertActions(NULL, viewActions);
234 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
235 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
236 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
238 m_timelineContextMenu = new QMenu(this);
239 m_timelineContextClipMenu = new QMenu(this);
240 m_timelineContextTransitionMenu = new QMenu(this);
243 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
244 effects = transitions.effectNames();
245 foreach(const QString &name, effects) {
246 action = new QAction(name, this);
247 action->setData(name);
248 transitionsMenu->addAction(action);
250 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
252 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
254 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
255 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
256 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
257 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
258 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
260 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
261 m_timelineContextClipMenu->addMenu(markersMenu);
262 m_timelineContextClipMenu->addMenu(transitionsMenu);
263 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
264 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
265 //TODO: re-enable custom effects menu when it is implemented
266 //m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
268 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
269 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
271 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
272 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
273 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
274 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
275 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
276 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
278 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
279 slotConnectMonitors();
281 setAutoSaveSettings();
283 if (KdenliveSettings::openlastproject()) {
286 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
287 if (!staleFiles.isEmpty()) {
288 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) {
289 recoverFiles(staleFiles);
297 activateShuttleDevice();
298 projectListDock->raise();
301 void MainWindow::queryQuit() {
302 kDebug() << "----- SAVING CONFUIG";
303 if (queryClose()) kapp->quit();
307 bool MainWindow::queryClose() {
309 if (m_activeDocument && m_activeDocument->isModified()) {
310 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
311 case KMessageBox::Yes :
312 // save document here. If saving fails, return false;
315 case KMessageBox::No :
324 void MainWindow::saveProperties(KConfig*) {
325 // save properties here,used by session management
330 void MainWindow::readProperties(KConfig *config) {
331 // read properties here,used by session management
332 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
333 openFile(KUrl(Lastproject));
336 void MainWindow::slotReloadEffects() {
337 initEffects::parseCustomEffectsFile();
338 m_customEffectsMenu->clear();
339 const QStringList effects = customEffects.effectNames();
341 foreach(const QString &name, effects) {
342 action = new QAction(name, this);
343 action->setData(name);
344 m_customEffectsMenu->addAction(action);
346 m_effectList->reloadEffectList();
349 void MainWindow::activateShuttleDevice() {
350 if (m_jogProcess) delete m_jogProcess;
352 if (KdenliveSettings::enableshuttle() == false) return;
353 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
354 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
355 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
356 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
357 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
358 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
359 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
362 void MainWindow::slotShuttleButton(int code) {
365 slotShuttleAction(KdenliveSettings::shuttle1());
368 slotShuttleAction(KdenliveSettings::shuttle2());
371 slotShuttleAction(KdenliveSettings::shuttle3());
374 slotShuttleAction(KdenliveSettings::shuttle4());
377 slotShuttleAction(KdenliveSettings::shuttle5());
382 void MainWindow::slotShuttleAction(int code) {
387 m_monitorManager->slotPlay();
390 m_monitorManager->slotPlay();
395 void MainWindow::configureNotifications() {
396 KNotifyConfigWidget::configure(this);
399 void MainWindow::slotFullScreen() {
400 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
403 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
404 if (!m_activeDocument) return;
405 if (effect.isNull()) {
406 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
409 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
410 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
413 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
414 if (clipMonitor) clipMonitorDock->raise();
415 else projectMonitorDock->raise();
418 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
419 if (!m_activeDocument) return;
420 m_activeDocument->setProducerDuration(id, duration);
423 void MainWindow::slotConnectMonitors() {
425 m_projectList->setRenderer(m_clipMonitor->render);
426 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
427 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
428 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
429 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
430 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 > &)));
432 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
434 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
436 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
437 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
439 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
440 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
443 void MainWindow::slotAdjustClipMonitor() {
444 clipMonitorDock->updateGeometry();
445 clipMonitorDock->adjustSize();
446 m_clipMonitor->resetSize();
449 void MainWindow::slotAdjustProjectMonitor() {
450 projectMonitorDock->updateGeometry();
451 projectMonitorDock->adjustSize();
452 m_projectMonitor->resetSize();
455 void MainWindow::setupActions() {
457 KActionCollection* collection = actionCollection();
458 m_timecodeFormat = new KComboBox(this);
459 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
460 m_timecodeFormat->addItem(i18n("Frames"));
462 statusProgressBar = new QProgressBar(this);
463 statusProgressBar->setMinimum(0);
464 statusProgressBar->setMaximum(100);
465 statusProgressBar->setMaximumWidth(150);
466 statusProgressBar->setVisible(false);
468 QWidget *w = new QWidget;
470 QHBoxLayout *layout = new QHBoxLayout;
471 w->setLayout(layout);
472 layout->setContentsMargins(5, 0, 5, 0);
473 QToolBar *toolbar = new QToolBar("statusToolBar", this);
476 m_toolGroup = new QActionGroup(this);
478 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;}";
480 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
481 m_buttonSelectTool->setCheckable(true);
482 m_buttonSelectTool->setChecked(true);
484 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
485 m_buttonRazorTool->setCheckable(true);
486 m_buttonRazorTool->setChecked(false);
488 m_toolGroup->addAction(m_buttonSelectTool);
489 m_toolGroup->addAction(m_buttonRazorTool);
490 m_toolGroup->setExclusive(true);
491 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
493 QWidget * actionWidget;
494 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
495 actionWidget->setMaximumWidth(24);
496 actionWidget->setMinimumHeight(17);
498 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
499 actionWidget->setMaximumWidth(24);
500 actionWidget->setMinimumHeight(17);
502 toolbar->setStyleSheet(style1);
503 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
505 toolbar->addSeparator();
506 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
507 m_buttonFitZoom->setCheckable(false);
508 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
510 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
511 actionWidget->setMaximumWidth(24);
512 actionWidget->setMinimumHeight(17);
514 m_zoomSlider = new QSlider(Qt::Horizontal, this);
515 m_zoomSlider->setMaximum(13);
516 m_zoomSlider->setPageStep(1);
518 m_zoomSlider->setMaximumWidth(150);
519 m_zoomSlider->setMinimumWidth(100);
521 const int contentHeight = QFontMetrics(w->font()).height() + 8;
523 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
524 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
526 m_zoomSlider->setStyleSheet(style);
528 //m_zoomSlider->height() + 5;
529 statusBar()->setMinimumHeight(contentHeight);
532 toolbar->addWidget(m_zoomSlider);
534 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
535 m_buttonVideoThumbs->setCheckable(true);
536 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
537 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
539 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
540 m_buttonAudioThumbs->setCheckable(true);
541 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
542 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
544 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
545 m_buttonShowMarkers->setCheckable(true);
546 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
547 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
549 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
550 m_buttonSnap->setCheckable(true);
551 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
552 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
553 layout->addWidget(toolbar);
556 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
557 actionWidget->setMaximumWidth(24);
558 actionWidget->setMinimumHeight(17);
560 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
561 actionWidget->setMaximumWidth(24);
562 actionWidget->setMinimumHeight(17);
564 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
565 actionWidget->setMaximumWidth(24);
566 actionWidget->setMinimumHeight(17);
568 actionWidget = toolbar->widgetForAction(m_buttonSnap);
569 actionWidget->setMaximumWidth(24);
570 actionWidget->setMinimumHeight(17);
572 m_messageLabel = new StatusBarMessageLabel(this);
573 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
575 statusBar()->addWidget(m_messageLabel, 10);
576 statusBar()->addWidget(statusProgressBar, 0);
577 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
578 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
579 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
580 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
581 m_messageLabel->hide();
583 collection->addAction("select_tool", m_buttonSelectTool);
584 collection->addAction("razor_tool", m_buttonRazorTool);
586 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
587 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
588 collection->addAction("show_markers", m_buttonShowMarkers);
589 collection->addAction("snap", m_buttonSnap);
590 collection->addAction("zoom_fit", m_buttonFitZoom);
592 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
593 collection->addAction("project_find", m_projectSearch);
594 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
595 m_projectSearch->setShortcut(Qt::Key_Slash);
597 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
598 collection->addAction("project_find_next", m_projectSearchNext);
599 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
600 m_projectSearchNext->setShortcut(Qt::Key_F3);
601 m_projectSearchNext->setEnabled(false);
603 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
604 collection->addAction("manage_profiles", profilesAction);
605 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
607 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
608 collection->addAction("project_settings", projectAction);
609 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
611 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
612 collection->addAction("project_render", projectRender);
613 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
615 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
616 KShortcut playShortcut;
617 playShortcut.setPrimary(Qt::Key_Space);
618 playShortcut.setAlternate(Qt::Key_K);
619 monitorPlay->setShortcut(playShortcut);
620 collection->addAction("monitor_play", monitorPlay);
621 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
623 KAction *markIn = collection->addAction("mark_in");
624 markIn->setText(i18n("Set in point"));
625 markIn->setShortcut(Qt::Key_I);
626 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
628 KAction *markOut = collection->addAction("mark_out");
629 markOut->setText(i18n("Set in point"));
630 markOut->setShortcut(Qt::Key_O);
631 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
633 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
634 monitorSeekBackward->setShortcut(Qt::Key_J);
635 collection->addAction("monitor_seek_backward", monitorSeekBackward);
636 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
638 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
639 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
640 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
641 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
643 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
644 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
645 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
646 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
648 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
649 monitorSeekForward->setShortcut(Qt::Key_L);
650 collection->addAction("monitor_seek_forward", monitorSeekForward);
651 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
653 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
654 clipStart->setShortcut(Qt::Key_Home);
655 collection->addAction("seek_clip_start", clipStart);
656 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
658 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
659 clipEnd->setShortcut(Qt::Key_End);
660 collection->addAction("seek_clip_end", clipEnd);
661 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
663 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
664 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
665 collection->addAction("seek_start", projectStart);
666 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
668 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
669 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
670 collection->addAction("seek_end", projectEnd);
671 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
673 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
674 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
675 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
676 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
678 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
679 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
680 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
681 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
683 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
684 deleteTimelineClip->setShortcut(Qt::Key_Delete);
685 collection->addAction("delete_timeline_clip", deleteTimelineClip);
686 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
688 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
689 collection->addAction("change_clip_speed", editTimelineClipSpeed);
690 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
692 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
693 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
694 collection->addAction("cut_timeline_clip", cutTimelineClip);
695 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
697 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
698 collection->addAction("add_clip_marker", addClipMarker);
699 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
701 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
702 collection->addAction("delete_clip_marker", deleteClipMarker);
703 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
705 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
706 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
707 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
709 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
710 collection->addAction("edit_clip_marker", editClipMarker);
711 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
713 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
714 collection->addAction("add_guide", addGuide);
715 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
717 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
718 collection->addAction("delete_guide", delGuide);
719 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
721 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
722 collection->addAction("edit_guide", editGuide);
723 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
725 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
726 collection->addAction("delete_all_guides", delAllGuides);
727 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
729 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
730 collection->addAction("paste_effects", pasteEffects);
731 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
733 KStandardAction::quit(this, SLOT(queryQuit()),
736 KStandardAction::open(this, SLOT(openFile()),
739 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
742 KStandardAction::saveAs(this, SLOT(saveFileAs()),
745 KStandardAction::openNew(this, SLOT(newFile()),
748 KStandardAction::preferences(this, SLOT(slotPreferences()),
751 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
753 KStandardAction::copy(this, SLOT(slotCopy()),
756 KStandardAction::paste(this, SLOT(slotPaste()),
759 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
761 undo->setEnabled(false);
762 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
764 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
766 redo->setEnabled(false);
767 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
769 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
771 connect(collection, SIGNAL(actionHovered(QAction*)),
772 this, SLOT(slotDisplayActionMessage(QAction*)));
773 //connect(collection, SIGNAL( clearStatusText() ),
774 //statusBar(), SLOT( clear() ) );
777 void MainWindow::slotDisplayActionMessage(QAction *a) {
778 statusBar()->showMessage(a->data().toString(), 3000);
781 void MainWindow::saveOptions() {
782 KdenliveSettings::self()->writeConfig();
783 KSharedConfigPtr config = KGlobal::config();
784 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
788 void MainWindow::readOptions() {
789 KSharedConfigPtr config = KGlobal::config();
790 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
791 KConfigGroup initialGroup(config, "version");
792 if (!initialGroup.exists()) {
793 // this is our first run, show Wizard
794 Wizard *w = new Wizard(this);
795 if (w->exec() == QDialog::Accepted && w->isOk()) {
797 initialGroup.writeEntry("version", "0.7");
805 void MainWindow::newFile() {
808 QPoint projectTracks(3, 2);
809 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
811 ProjectSettings *w = new ProjectSettings;
812 if (w->exec() != QDialog::Accepted) return;
813 profileName = w->selectedProfile();
814 projectFolder = w->selectedFolder();
815 projectTracks = w->tracks();
818 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
819 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
820 TrackView *trackView = new TrackView(doc, this);
821 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
822 if (m_timelineArea->count() == 1) {
823 connectDocumentInfo(doc);
824 connectDocument(trackView, doc);
825 } else m_timelineArea->setTabBarHidden(false);
828 void MainWindow::activateDocument() {
829 if (m_timelineArea->currentWidget() == NULL) return;
830 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
831 KdenliveDoc *currentDoc = currentTab->document();
832 connectDocumentInfo(currentDoc);
833 connectDocument(currentTab, currentDoc);
836 void MainWindow::closeCurrentDocument() {
837 QWidget *w = m_timelineArea->currentWidget();
838 // closing current document
839 int ix = m_timelineArea->currentIndex() + 1;
840 if (ix == m_timelineArea->count()) ix = 0;
841 m_timelineArea->setCurrentIndex(ix);
842 TrackView *tabToClose = (TrackView *) w;
843 KdenliveDoc *docToClose = tabToClose->document();
844 if (docToClose && docToClose->isModified()) {
845 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
846 case KMessageBox::Yes :
847 // save document here. If saving fails, return false;
850 case KMessageBox::Cancel :
856 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
857 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
860 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
863 void MainWindow::saveFileAs(const QString &outputFileName) {
864 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
865 m_activeDocument->setUrl(KUrl(outputFileName));
866 if (m_activeDocument->m_autosave == NULL) {
867 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
868 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
869 setCaption(m_activeDocument->description());
870 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
871 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
872 m_activeDocument->setModified(false);
873 m_fileOpenRecent->addUrl(KUrl(outputFileName));
876 void MainWindow::saveFileAs() {
877 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
878 if (QFile::exists(outputFile)) {
879 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
881 saveFileAs(outputFile);
884 void MainWindow::saveFile() {
885 if (!m_activeDocument) return;
886 if (m_activeDocument->url().isEmpty()) {
889 saveFileAs(m_activeDocument->url().path());
890 m_activeDocument->m_autosave->resize(0);
894 void MainWindow::openFile() {
895 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
896 if (url.isEmpty()) return;
897 m_fileOpenRecent->addUrl(url);
901 void MainWindow::openLastFile() {
902 KSharedConfigPtr config = KGlobal::config();
903 KUrl::List urls = m_fileOpenRecent->urls();
904 if (urls.isEmpty()) newFile();
905 else openFile(urls.last());
908 void MainWindow::openFile(const KUrl &url) {
909 // Check for backup file
910 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
911 if (!staleFiles.isEmpty()) {
912 if (KMessageBox::questionYesNo(this,
913 i18n("Auto-saved files exist. Do you want to recover them now?"),
914 i18n("File Recovery"),
915 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
916 recoverFiles(staleFiles);
919 // remove the stale files
920 foreach(KAutoSaveFile *stale, staleFiles) {
921 stale->open(QIODevice::ReadWrite);
926 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
927 doOpenFile(url, NULL);
930 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
932 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
934 stale = new KAutoSaveFile(url, doc);
935 doc->m_autosave = stale;
937 doc->m_autosave = stale;
938 doc->setUrl(stale->managedFile());
939 doc->setModified(true);
940 stale->setParent(doc);
942 connectDocumentInfo(doc);
943 TrackView *trackView = new TrackView(doc, this);
944 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
945 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
946 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
947 slotGotProgressInfo(QString(), -1);
948 m_clipMonitor->refreshMonitor(true);
951 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
952 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
953 foreach(KAutoSaveFile *stale, staleFiles) {
954 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
955 // show an error message; we could not steal the lockfile
956 // maybe another application got to the file before us?
960 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
961 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
962 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
963 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
968 void MainWindow::parseProfiles() {
969 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
971 //KdenliveSettings::setDefaulttmpfolder();
972 if (KdenliveSettings::mltpath().isEmpty()) {
973 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
975 if (KdenliveSettings::rendererpath().isEmpty()) {
976 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
977 if (!QFile::exists(inigoPath))
978 inigoPath = KStandardDirs::findExe("inigo");
979 else KdenliveSettings::setRendererpath(inigoPath);
981 QStringList profilesFilter;
982 profilesFilter << "*";
983 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
985 if (profilesList.isEmpty()) {
986 // Cannot find MLT path, try finding inigo
987 QString profilePath = KdenliveSettings::rendererpath();
988 if (!profilePath.isEmpty()) {
989 profilePath = profilePath.section('/', 0, -3);
990 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
991 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
994 if (profilesList.isEmpty()) {
995 // Cannot find the MLT profiles, ask for location
996 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
997 getUrl->fileDialog()->setMode(KFile::Directory);
998 if (getUrl->exec() == QDialog::Rejected) {
1001 KUrl mltPath = getUrl->selectedUrl();
1003 if (mltPath.isEmpty()) ::exit(0);
1004 KdenliveSettings::setMltpath(mltPath.path());
1005 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1009 if (KdenliveSettings::rendererpath().isEmpty()) {
1010 // Cannot find the MLT inigo renderer, ask for location
1011 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1012 if (getUrl->exec() == QDialog::Rejected) {
1015 KUrl rendererPath = getUrl->selectedUrl();
1017 if (rendererPath.isEmpty()) ::exit(0);
1018 KdenliveSettings::setRendererpath(rendererPath.path());
1021 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1023 // Parse MLT profiles to build a list of available video formats
1024 if (profilesList.isEmpty()) parseProfiles();
1028 void MainWindow::slotEditProfiles() {
1029 ProfilesDialog *w = new ProfilesDialog;
1034 void MainWindow::slotEditProjectSettings() {
1035 ProjectSettings *w = new ProjectSettings;
1036 if (w->exec() == QDialog::Accepted) {
1037 QString profile = w->selectedProfile();
1038 m_activeDocument->setProfilePath(profile);
1039 KdenliveSettings::setCurrent_profile(profile);
1040 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1041 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1042 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1043 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1044 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1046 // We need to desactivate & reactivate monitors to get a refresh
1047 m_monitorManager->switchMonitors();
1052 void MainWindow::slotRenderProject() {
1053 if (!m_renderWidget) {
1054 m_renderWidget = new RenderWidget(this);
1055 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)));
1056 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1058 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1059 if (currentTab) m_renderWidget->setTimeline(currentTab);
1060 m_renderWidget->setDocument(m_activeDocument);*/
1061 m_renderWidget->show();
1064 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) {
1065 if (dest.isEmpty()) return;
1068 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1069 if (currentTab && zoneOnly) {
1070 in = currentTab->inPoint();
1071 out = currentTab->outPoint();
1073 KTemporaryFile temp;
1074 temp.setAutoRemove(false);
1075 temp.setSuffix(".westley");
1077 m_projectMonitor->saveSceneList(temp.fileName());
1080 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1081 else if (guideStart != -1) {
1082 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1084 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1085 QString videoPlayer = "-";
1087 videoPlayer = KdenliveSettings::defaultplayerapp();
1088 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."));
1090 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1091 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1092 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1093 QProcess::startDetached(renderer, args);
1095 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1099 void MainWindow::slotUpdateMousePosition(int pos) {
1100 if (m_activeDocument)
1101 switch (m_timecodeFormat->currentIndex()) {
1103 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1106 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1110 void MainWindow::slotUpdateDocumentState(bool modified) {
1111 setCaption(m_activeDocument->description(), modified);
1112 m_saveAction->setEnabled(modified);
1114 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1115 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1117 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1118 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1122 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1123 if (m_activeDocument) {
1124 if (m_activeDocument == doc) return;
1125 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1127 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1130 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1131 //m_projectMonitor->stop();
1132 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1133 if (m_activeDocument) {
1134 if (m_activeDocument == doc) return;
1135 m_activeDocument->backupMltPlaylist();
1136 if (m_activeTimeline) {
1137 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1138 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1139 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1140 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1141 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1142 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1143 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1144 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1145 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1146 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1147 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1148 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1149 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1150 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1151 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1152 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1153 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1154 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1156 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1157 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1158 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1159 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1160 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1161 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1162 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1163 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1164 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1165 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1166 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1167 effectStack->clear();
1169 m_activeDocument->setRenderer(NULL);
1170 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1171 m_clipMonitor->stop();
1173 KdenliveSettings::setCurrent_profile(doc->profilePath());
1174 KdenliveSettings::setProject_fps(doc->fps());
1175 m_monitorManager->resetProfiles(doc->timecode());
1176 m_projectList->setDocument(doc);
1177 transitionConfig->updateProjectFormat(doc->mltProfile());
1178 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1179 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1180 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1181 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1182 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1183 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1184 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1185 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1186 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1187 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1188 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1189 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1191 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1192 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1193 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1196 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1197 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1198 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1199 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1200 m_zoomSlider->setValue(doc->zoom());
1201 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1202 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1203 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1204 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1206 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1209 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1210 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1211 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1212 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1213 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1214 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1215 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1216 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1218 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1219 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1221 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1222 m_activeTimeline = trackView;
1223 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1224 doc->setRenderer(m_projectMonitor->render);
1225 m_commandStack->setActiveStack(doc->commandStack());
1226 KdenliveSettings::setProject_display_ratio(doc->dar());
1227 m_projectList->updateAllClips();
1228 trackView->projectView()->updateAllThumbs();
1231 //m_overView->setScene(trackView->projectScene());
1232 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1233 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1235 setCaption(doc->description(), doc->isModified());
1236 m_saveAction->setEnabled(doc->isModified());
1237 m_activeDocument = doc;
1240 void MainWindow::slotGuidesUpdated() {
1241 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1244 void MainWindow::slotPreferences(int page, int option) {
1245 //An instance of your dialog could be already created and could be
1246 // cached, in which case you want to display the cached dialog
1247 // instead of creating another one
1248 if (KConfigDialog::showDialog("settings")) {
1249 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1253 // KConfigDialog didn't find an instance of this dialog, so lets
1255 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1256 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1257 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1259 if (page != -1) dialog->showPage(page, option);
1262 void MainWindow::updateConfiguration() {
1263 //TODO: we should apply settings to all projects, not only the current one
1264 if (m_activeTimeline) {
1265 m_activeTimeline->refresh();
1266 m_activeTimeline->projectView()->checkAutoScroll();
1267 m_activeTimeline->projectView()->checkTrackHeight();
1268 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1270 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1271 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1272 activateShuttleDevice();
1276 void MainWindow::slotSwitchVideoThumbs() {
1277 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1278 if (m_activeTimeline) {
1279 m_activeTimeline->refresh();
1281 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1284 void MainWindow::slotSwitchAudioThumbs() {
1285 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1286 if (m_activeTimeline) {
1287 m_activeTimeline->refresh();
1288 m_activeTimeline->projectView()->checkAutoScroll();
1289 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1291 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1294 void MainWindow::slotSwitchMarkersComments() {
1295 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1296 if (m_activeTimeline) {
1297 m_activeTimeline->refresh();
1299 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1302 void MainWindow::slotSwitchSnap() {
1303 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1304 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1308 void MainWindow::slotDeleteTimelineClip() {
1309 if (m_activeTimeline) {
1310 m_activeTimeline->projectView()->deleteSelectedClips();
1314 void MainWindow::slotChangeClipSpeed() {
1315 if (m_activeTimeline) {
1316 m_activeTimeline->projectView()->changeClipSpeed();
1320 void MainWindow::slotAddClipMarker() {
1321 if (m_activeTimeline) {
1322 m_activeTimeline->projectView()->slotAddClipMarker();
1326 void MainWindow::slotDeleteClipMarker() {
1327 if (m_activeTimeline) {
1328 m_activeTimeline->projectView()->slotDeleteClipMarker();
1332 void MainWindow::slotDeleteAllClipMarkers() {
1333 if (m_activeTimeline) {
1334 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1338 void MainWindow::slotEditClipMarker() {
1339 if (m_activeTimeline) {
1340 m_activeTimeline->projectView()->slotEditClipMarker();
1344 void MainWindow::slotAddGuide() {
1345 if (m_activeTimeline)
1346 m_activeTimeline->projectView()->slotAddGuide();
1349 void MainWindow::slotEditGuide() {
1350 if (m_activeTimeline)
1351 m_activeTimeline->projectView()->slotEditGuide();
1354 void MainWindow::slotDeleteGuide() {
1355 if (m_activeTimeline)
1356 m_activeTimeline->projectView()->slotDeleteGuide();
1359 void MainWindow::slotDeleteAllGuides() {
1360 if (m_activeTimeline)
1361 m_activeTimeline->projectView()->slotDeleteAllGuides();
1364 void MainWindow::slotCutTimelineClip() {
1365 if (m_activeTimeline) {
1366 m_activeTimeline->projectView()->cutSelectedClips();
1370 void MainWindow::slotAddProjectClip(KUrl url) {
1371 if (m_activeDocument)
1372 m_activeDocument->slotAddClipFile(url, QString());
1375 void MainWindow::slotAddTransition(QAction *result) {
1376 if (!result) return;
1377 QDomElement effect = transitions.getEffectByName(result->data().toString());
1378 if (m_activeTimeline) {
1379 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1383 void MainWindow::slotAddVideoEffect(QAction *result) {
1384 if (!result) return;
1385 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1386 slotAddEffect(effect);
1389 void MainWindow::slotAddAudioEffect(QAction *result) {
1390 if (!result) return;
1391 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1392 slotAddEffect(effect);
1395 void MainWindow::slotAddCustomEffect(QAction *result) {
1396 if (!result) return;
1397 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1398 slotAddEffect(effect);
1401 void MainWindow::slotZoomIn() {
1402 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1405 void MainWindow::slotZoomOut() {
1406 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1409 void MainWindow::slotFitZoom() {
1410 if (m_activeTimeline) {
1411 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1415 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1416 statusProgressBar->setValue(progress);
1417 if (progress >= 0) {
1418 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1419 statusProgressBar->setVisible(true);
1421 m_messageLabel->setMessage(QString(), DefaultMessage);
1422 statusProgressBar->setVisible(false);
1426 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1427 if (clip->clipType() == TEXT) {
1428 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1429 QString path = clip->getProperty("resource");
1430 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1432 doc.setContent(clip->getProperty("xmldata"));
1433 dia_ui->setXml(doc);
1434 if (dia_ui->exec() == QDialog::Accepted) {
1435 QPixmap pix = dia_ui->renderedPixmap();
1437 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1438 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1439 QMap <QString, QString> newprops;
1440 newprops.insert("xmldata", dia_ui->xml().toString());
1441 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1442 m_activeDocument->commandStack()->push(command);
1443 m_clipMonitor->refreshMonitor(true);
1444 m_activeDocument->setModified(true);
1448 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1451 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1452 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1453 if (dia.exec() == QDialog::Accepted) {
1454 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1455 m_activeDocument->commandStack()->push(command);
1457 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1458 if (dia.needsTimelineRefresh()) {
1459 // update clip occurences in timeline
1460 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1465 void MainWindow::customEvent(QEvent* e) {
1466 if (e->type() == QEvent::User) {
1467 // The timeline playing position changed...
1468 kDebug() << "RECIEVED JOG EVEMNT!!!";
1471 void MainWindow::slotActivateEffectStackView() {
1472 effectStack->raiseWindow(effectStackDock);
1475 void MainWindow::slotActivateTransitionView() {
1476 transitionConfig->raiseWindow(transitionConfigDock);
1479 void MainWindow::slotSnapRewind() {
1480 if (m_projectMonitor->isActive()) {
1481 if (m_activeTimeline)
1482 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1486 void MainWindow::slotSnapForward() {
1487 if (m_projectMonitor->isActive()) {
1488 if (m_activeTimeline)
1489 m_activeTimeline->projectView()->slotSeekToNextSnap();
1493 void MainWindow::slotClipStart() {
1494 if (m_projectMonitor->isActive()) {
1495 if (m_activeTimeline)
1496 m_activeTimeline->projectView()->clipStart();
1500 void MainWindow::slotClipEnd() {
1501 if (m_projectMonitor->isActive()) {
1502 if (m_activeTimeline)
1503 m_activeTimeline->projectView()->clipEnd();
1507 void MainWindow::slotChangeTool(QAction * action) {
1508 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1509 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1512 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1513 if (m_activeDocument && m_activeTimeline) {
1514 //m_activeDocument->setTool(tool);
1515 m_activeTimeline->projectView()->setTool(tool);
1519 void MainWindow::slotCopy() {
1520 if (!m_activeDocument || !m_activeTimeline) return;
1521 m_activeTimeline->projectView()->copyClip();
1524 void MainWindow::slotPaste() {
1525 if (!m_activeDocument || !m_activeTimeline) return;
1526 m_activeTimeline->projectView()->pasteClip();
1529 void MainWindow::slotPasteEffects() {
1530 if (!m_activeDocument || !m_activeTimeline) return;
1531 m_activeTimeline->projectView()->pasteClipEffects();
1534 void MainWindow::slotFind() {
1535 if (!m_activeDocument || !m_activeTimeline) return;
1536 m_projectSearch->setEnabled(false);
1537 m_findActivated = true;
1538 m_findString = QString();
1539 m_activeTimeline->projectView()->initSearchStrings();
1540 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1541 m_findTimer.start(5000);
1542 qApp->installEventFilter(this);
1545 void MainWindow::slotFindNext() {
1546 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1547 statusBar()->showMessage(i18n("Found : %1", m_findString));
1549 statusBar()->showMessage(i18n("Reached end of project"));
1551 m_findTimer.start(4000);
1554 void MainWindow::findAhead() {
1555 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1556 m_projectSearchNext->setEnabled(true);
1557 statusBar()->showMessage(i18n("Found : %1", m_findString));
1559 m_projectSearchNext->setEnabled(false);
1560 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1564 void MainWindow::findTimeout() {
1565 m_projectSearchNext->setEnabled(false);
1566 m_findActivated = false;
1567 m_findString = QString();
1568 statusBar()->showMessage(i18n("Find stopped"), 3000);
1569 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1570 m_projectSearch->setEnabled(true);
1571 removeEventFilter(this);
1574 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1575 if (m_findActivated) {
1576 if (ke->key() == Qt::Key_Backspace) {
1577 m_findString = m_findString.left(m_findString.length() - 1);
1579 if (!m_findString.isEmpty()) {
1585 m_findTimer.start(4000);
1588 } else if (ke->key() == Qt::Key_Escape) {
1592 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1593 m_findString += ke->text();
1597 m_findTimer.start(4000);
1601 } else KXmlGuiWindow::keyPressEvent(ke);
1604 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1605 if (m_findActivated) {
1606 if (event->type() == QEvent::ShortcutOverride) {
1607 QKeyEvent* ke = (QKeyEvent*) event;
1608 if (ke->text().trimmed().isEmpty()) return false;
1611 } else return false;
1613 // pass the event on to the parent class
1614 return QMainWindow::eventFilter(obj, event);
1618 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1619 KDialog *dialog = new KDialog(this);
1620 dialog->setCaption("Save clip zone");
1621 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1623 QWidget *widget = new QWidget(dialog);
1624 dialog->setMainWidget(widget);
1626 QVBoxLayout *vbox = new QVBoxLayout(widget);
1627 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1628 QString path = m_activeDocument->projectFolder().path();
1630 path.append("untitled.westley");
1631 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1632 url->setFilter("video/mlt-playlist");
1633 QLabel *label2 = new QLabel(i18n("Description:"), this);
1634 KLineEdit *edit = new KLineEdit(this);
1635 vbox->addWidget(label1);
1636 vbox->addWidget(url);
1637 vbox->addWidget(label2);
1638 vbox->addWidget(edit);
1639 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1643 void MainWindow::slotSetInPoint() {
1644 if (m_clipMonitor->isActive()) {
1645 m_clipMonitor->slotSetZoneStart();
1646 } else m_activeTimeline->projectView()->setInPoint();
1649 void MainWindow::slotSetOutPoint() {
1650 if (m_clipMonitor->isActive()) {
1651 m_clipMonitor->slotSetZoneEnd();
1652 } else m_activeTimeline->projectView()->setOutPoint();
1655 #include "mainwindow.moc"