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 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));
211 QStringList effects = videoEffects.effectNames();
212 foreach(const QString &name, effects) {
213 action = new QAction(name, this);
214 action->setData(name);
215 videoEffectsMenu->addAction(action);
217 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
218 effects = audioEffects.effectNames();
219 foreach(const QString &name, effects) {
220 action = new QAction(name, this);
221 action->setData(name);
222 audioEffectsMenu->addAction(action);
224 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
225 effects = customEffects.effectNames();
226 if (effects.isEmpty()) {
227 action = new QAction(i18n("No Custom Effects"), this);
228 action->setEnabled(false);
229 m_customEffectsMenu->addAction(action);
231 foreach(const QString &name, effects) {
232 action = new QAction(name, this);
233 action->setData(name);
234 m_customEffectsMenu->addAction(action);
237 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
238 const QList<QAction *> viewActions = createPopupMenu()->actions();
239 viewMenu->insertActions(NULL, viewActions);
241 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
242 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
243 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
245 m_timelineContextMenu = new QMenu(this);
246 m_timelineContextClipMenu = new QMenu(this);
247 m_timelineContextTransitionMenu = new QMenu(this);
250 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
251 effects = transitions.effectNames();
252 foreach(const QString &name, effects) {
253 action = new QAction(name, this);
254 action->setData(name);
255 transitionsMenu->addAction(action);
257 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
259 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
261 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
262 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
263 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
264 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
265 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
267 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
268 m_timelineContextClipMenu->addMenu(markersMenu);
269 m_timelineContextClipMenu->addMenu(transitionsMenu);
270 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
271 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
272 //TODO: re-enable custom effects menu when it is implemented
273 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
275 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
276 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
278 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
279 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
280 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
281 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
282 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
283 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
285 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
286 slotConnectMonitors();
288 setAutoSaveSettings();
290 if (KdenliveSettings::openlastproject()) {
293 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
294 if (!staleFiles.isEmpty()) {
295 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) {
296 recoverFiles(staleFiles);
304 activateShuttleDevice();
305 projectListDock->raise();
308 void MainWindow::queryQuit() {
309 kDebug() << "----- SAVING CONFUIG";
310 if (queryClose()) kapp->quit();
314 bool MainWindow::queryClose() {
316 if (m_activeDocument && m_activeDocument->isModified()) {
317 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
318 case KMessageBox::Yes :
319 // save document here. If saving fails, return false;
322 case KMessageBox::No :
331 void MainWindow::saveProperties(KConfig*) {
332 // save properties here,used by session management
337 void MainWindow::readProperties(KConfig *config) {
338 // read properties here,used by session management
339 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
340 openFile(KUrl(Lastproject));
343 void MainWindow::slotReloadEffects() {
344 initEffects::parseCustomEffectsFile();
345 m_customEffectsMenu->clear();
346 const QStringList effects = customEffects.effectNames();
348 if (effects.isEmpty()) {
349 action = new QAction(i18n("No Custom Effects"), this);
350 action->setEnabled(false);
351 m_customEffectsMenu->addAction(action);
353 foreach(const QString &name, effects) {
354 action = new QAction(name, this);
355 action->setData(name);
356 m_customEffectsMenu->addAction(action);
358 m_effectList->reloadEffectList();
361 void MainWindow::activateShuttleDevice() {
362 if (m_jogProcess) delete m_jogProcess;
364 if (KdenliveSettings::enableshuttle() == false) return;
365 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
366 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
367 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
368 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
369 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
370 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
371 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
374 void MainWindow::slotShuttleButton(int code) {
377 slotShuttleAction(KdenliveSettings::shuttle1());
380 slotShuttleAction(KdenliveSettings::shuttle2());
383 slotShuttleAction(KdenliveSettings::shuttle3());
386 slotShuttleAction(KdenliveSettings::shuttle4());
389 slotShuttleAction(KdenliveSettings::shuttle5());
394 void MainWindow::slotShuttleAction(int code) {
399 m_monitorManager->slotPlay();
402 m_monitorManager->slotPlay();
407 void MainWindow::configureNotifications() {
408 KNotifyConfigWidget::configure(this);
411 void MainWindow::slotFullScreen() {
412 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
415 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
416 if (!m_activeDocument) return;
417 if (effect.isNull()) {
418 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
421 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
422 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
425 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
426 if (clipMonitor) clipMonitorDock->raise();
427 else projectMonitorDock->raise();
430 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
431 if (!m_activeDocument) return;
432 m_activeDocument->setProducerDuration(id, duration);
435 void MainWindow::slotConnectMonitors() {
437 m_projectList->setRenderer(m_clipMonitor->render);
438 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
439 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
440 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
441 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
442 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 > &)));
444 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
446 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
448 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
449 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
451 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
452 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
455 void MainWindow::slotAdjustClipMonitor() {
456 clipMonitorDock->updateGeometry();
457 clipMonitorDock->adjustSize();
458 m_clipMonitor->resetSize();
461 void MainWindow::slotAdjustProjectMonitor() {
462 projectMonitorDock->updateGeometry();
463 projectMonitorDock->adjustSize();
464 m_projectMonitor->resetSize();
467 void MainWindow::setupActions() {
469 KActionCollection* collection = actionCollection();
470 m_timecodeFormat = new KComboBox(this);
471 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
472 m_timecodeFormat->addItem(i18n("Frames"));
474 statusProgressBar = new QProgressBar(this);
475 statusProgressBar->setMinimum(0);
476 statusProgressBar->setMaximum(100);
477 statusProgressBar->setMaximumWidth(150);
478 statusProgressBar->setVisible(false);
480 QWidget *w = new QWidget;
482 QHBoxLayout *layout = new QHBoxLayout;
483 w->setLayout(layout);
484 layout->setContentsMargins(5, 0, 5, 0);
485 QToolBar *toolbar = new QToolBar("statusToolBar", this);
488 m_toolGroup = new QActionGroup(this);
490 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;}";
492 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
493 m_buttonSelectTool->setCheckable(true);
494 m_buttonSelectTool->setChecked(true);
496 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
497 m_buttonRazorTool->setCheckable(true);
498 m_buttonRazorTool->setChecked(false);
500 m_toolGroup->addAction(m_buttonSelectTool);
501 m_toolGroup->addAction(m_buttonRazorTool);
502 m_toolGroup->setExclusive(true);
503 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
505 QWidget * actionWidget;
506 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
507 actionWidget->setMaximumWidth(24);
508 actionWidget->setMinimumHeight(17);
510 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
511 actionWidget->setMaximumWidth(24);
512 actionWidget->setMinimumHeight(17);
514 toolbar->setStyleSheet(style1);
515 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
517 toolbar->addSeparator();
518 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
519 m_buttonFitZoom->setCheckable(false);
520 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
522 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
523 actionWidget->setMaximumWidth(24);
524 actionWidget->setMinimumHeight(17);
526 m_zoomSlider = new QSlider(Qt::Horizontal, this);
527 m_zoomSlider->setMaximum(13);
528 m_zoomSlider->setPageStep(1);
530 m_zoomSlider->setMaximumWidth(150);
531 m_zoomSlider->setMinimumWidth(100);
533 const int contentHeight = QFontMetrics(w->font()).height() + 8;
535 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
536 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
538 m_zoomSlider->setStyleSheet(style);
540 //m_zoomSlider->height() + 5;
541 statusBar()->setMinimumHeight(contentHeight);
544 toolbar->addWidget(m_zoomSlider);
546 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
547 m_buttonVideoThumbs->setCheckable(true);
548 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
549 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
551 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
552 m_buttonAudioThumbs->setCheckable(true);
553 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
554 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
556 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
557 m_buttonShowMarkers->setCheckable(true);
558 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
559 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
561 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
562 m_buttonSnap->setCheckable(true);
563 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
564 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
565 layout->addWidget(toolbar);
568 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
569 actionWidget->setMaximumWidth(24);
570 actionWidget->setMinimumHeight(17);
572 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
573 actionWidget->setMaximumWidth(24);
574 actionWidget->setMinimumHeight(17);
576 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
577 actionWidget->setMaximumWidth(24);
578 actionWidget->setMinimumHeight(17);
580 actionWidget = toolbar->widgetForAction(m_buttonSnap);
581 actionWidget->setMaximumWidth(24);
582 actionWidget->setMinimumHeight(17);
584 m_messageLabel = new StatusBarMessageLabel(this);
585 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
587 statusBar()->addWidget(m_messageLabel, 10);
588 statusBar()->addWidget(statusProgressBar, 0);
589 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
590 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
591 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
592 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
593 m_messageLabel->hide();
595 collection->addAction("select_tool", m_buttonSelectTool);
596 collection->addAction("razor_tool", m_buttonRazorTool);
598 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
599 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
600 collection->addAction("show_markers", m_buttonShowMarkers);
601 collection->addAction("snap", m_buttonSnap);
602 collection->addAction("zoom_fit", m_buttonFitZoom);
604 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
605 collection->addAction("project_find", m_projectSearch);
606 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
607 m_projectSearch->setShortcut(Qt::Key_Slash);
609 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
610 collection->addAction("project_find_next", m_projectSearchNext);
611 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
612 m_projectSearchNext->setShortcut(Qt::Key_F3);
613 m_projectSearchNext->setEnabled(false);
615 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
616 collection->addAction("manage_profiles", profilesAction);
617 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
619 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
620 collection->addAction("project_settings", projectAction);
621 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
623 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
624 collection->addAction("project_render", projectRender);
625 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
627 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
628 KShortcut playShortcut;
629 playShortcut.setPrimary(Qt::Key_Space);
630 playShortcut.setAlternate(Qt::Key_K);
631 monitorPlay->setShortcut(playShortcut);
632 collection->addAction("monitor_play", monitorPlay);
633 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
635 KAction *markIn = collection->addAction("mark_in");
636 markIn->setText(i18n("Set In Point"));
637 markIn->setShortcut(Qt::Key_I);
638 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
640 KAction *markOut = collection->addAction("mark_out");
641 markOut->setText(i18n("Set Out Point"));
642 markOut->setShortcut(Qt::Key_O);
643 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
645 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
646 monitorSeekBackward->setShortcut(Qt::Key_J);
647 collection->addAction("monitor_seek_backward", monitorSeekBackward);
648 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
650 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
651 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
652 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
653 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
655 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
656 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
657 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
658 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
660 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
661 monitorSeekForward->setShortcut(Qt::Key_L);
662 collection->addAction("monitor_seek_forward", monitorSeekForward);
663 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
665 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
666 clipStart->setShortcut(Qt::Key_Home);
667 collection->addAction("seek_clip_start", clipStart);
668 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
670 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
671 clipEnd->setShortcut(Qt::Key_End);
672 collection->addAction("seek_clip_end", clipEnd);
673 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
675 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
676 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
677 collection->addAction("seek_start", projectStart);
678 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
680 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
681 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
682 collection->addAction("seek_end", projectEnd);
683 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
685 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
686 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
687 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
688 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
690 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
691 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
692 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
693 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
695 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
696 deleteTimelineClip->setShortcut(Qt::Key_Delete);
697 collection->addAction("delete_timeline_clip", deleteTimelineClip);
698 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
700 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
701 collection->addAction("change_clip_speed", editTimelineClipSpeed);
702 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
704 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
705 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
706 collection->addAction("cut_timeline_clip", cutTimelineClip);
707 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
709 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
710 collection->addAction("add_clip_marker", addClipMarker);
711 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
713 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
714 collection->addAction("delete_clip_marker", deleteClipMarker);
715 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
717 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
718 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
719 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
721 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
722 collection->addAction("edit_clip_marker", editClipMarker);
723 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
725 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
726 collection->addAction("add_guide", addGuide);
727 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
729 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
730 collection->addAction("delete_guide", delGuide);
731 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
733 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
734 collection->addAction("edit_guide", editGuide);
735 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
737 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
738 collection->addAction("delete_all_guides", delAllGuides);
739 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
741 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
742 collection->addAction("paste_effects", pasteEffects);
743 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
745 KStandardAction::quit(this, SLOT(queryQuit()),
748 KStandardAction::open(this, SLOT(openFile()),
751 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
754 KStandardAction::saveAs(this, SLOT(saveFileAs()),
757 KStandardAction::openNew(this, SLOT(newFile()),
760 KStandardAction::preferences(this, SLOT(slotPreferences()),
763 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
765 KStandardAction::copy(this, SLOT(slotCopy()),
768 KStandardAction::paste(this, SLOT(slotPaste()),
771 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
773 undo->setEnabled(false);
774 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
776 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
778 redo->setEnabled(false);
779 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
781 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
783 connect(collection, SIGNAL(actionHovered(QAction*)),
784 this, SLOT(slotDisplayActionMessage(QAction*)));
785 //connect(collection, SIGNAL( clearStatusText() ),
786 //statusBar(), SLOT( clear() ) );
789 void MainWindow::slotDisplayActionMessage(QAction *a) {
790 statusBar()->showMessage(a->data().toString(), 3000);
793 void MainWindow::saveOptions() {
794 KdenliveSettings::self()->writeConfig();
795 KSharedConfigPtr config = KGlobal::config();
796 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
800 void MainWindow::readOptions() {
801 KSharedConfigPtr config = KGlobal::config();
802 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
803 KConfigGroup initialGroup(config, "version");
804 if (!initialGroup.exists()) {
805 // this is our first run, show Wizard
806 Wizard *w = new Wizard(this);
807 if (w->exec() == QDialog::Accepted && w->isOk()) {
809 initialGroup.writeEntry("version", "0.7");
817 void MainWindow::newFile() {
820 QPoint projectTracks(3, 2);
821 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
823 ProjectSettings *w = new ProjectSettings;
824 if (w->exec() != QDialog::Accepted) return;
825 profileName = w->selectedProfile();
826 projectFolder = w->selectedFolder();
827 projectTracks = w->tracks();
830 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
831 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
832 TrackView *trackView = new TrackView(doc, this);
833 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
834 if (m_timelineArea->count() == 1) {
835 connectDocumentInfo(doc);
836 connectDocument(trackView, doc);
837 } else m_timelineArea->setTabBarHidden(false);
840 void MainWindow::activateDocument() {
841 if (m_timelineArea->currentWidget() == NULL) return;
842 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
843 KdenliveDoc *currentDoc = currentTab->document();
844 connectDocumentInfo(currentDoc);
845 connectDocument(currentTab, currentDoc);
848 void MainWindow::closeCurrentDocument() {
849 QWidget *w = m_timelineArea->currentWidget();
850 // closing current document
851 int ix = m_timelineArea->currentIndex() + 1;
852 if (ix == m_timelineArea->count()) ix = 0;
853 m_timelineArea->setCurrentIndex(ix);
854 TrackView *tabToClose = (TrackView *) w;
855 KdenliveDoc *docToClose = tabToClose->document();
856 if (docToClose && docToClose->isModified()) {
857 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
858 case KMessageBox::Yes :
859 // save document here. If saving fails, return false;
862 case KMessageBox::Cancel :
868 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
869 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
872 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
875 void MainWindow::saveFileAs(const QString &outputFileName) {
876 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
877 m_activeDocument->setUrl(KUrl(outputFileName));
878 if (m_activeDocument->m_autosave == NULL) {
879 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
880 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
881 setCaption(m_activeDocument->description());
882 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
883 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
884 m_activeDocument->setModified(false);
885 m_fileOpenRecent->addUrl(KUrl(outputFileName));
888 void MainWindow::saveFileAs() {
889 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
890 if (QFile::exists(outputFile)) {
891 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
893 saveFileAs(outputFile);
896 void MainWindow::saveFile() {
897 if (!m_activeDocument) return;
898 if (m_activeDocument->url().isEmpty()) {
901 saveFileAs(m_activeDocument->url().path());
902 m_activeDocument->m_autosave->resize(0);
906 void MainWindow::openFile() {
907 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
908 if (url.isEmpty()) return;
909 m_fileOpenRecent->addUrl(url);
913 void MainWindow::openLastFile() {
914 KSharedConfigPtr config = KGlobal::config();
915 KUrl::List urls = m_fileOpenRecent->urls();
916 if (urls.isEmpty()) newFile();
917 else openFile(urls.last());
920 void MainWindow::openFile(const KUrl &url) {
921 // Check for backup file
922 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
923 if (!staleFiles.isEmpty()) {
924 if (KMessageBox::questionYesNo(this,
925 i18n("Auto-saved files exist. Do you want to recover them now?"),
926 i18n("File Recovery"),
927 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
928 recoverFiles(staleFiles);
931 // remove the stale files
932 foreach(KAutoSaveFile *stale, staleFiles) {
933 stale->open(QIODevice::ReadWrite);
938 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
939 doOpenFile(url, NULL);
942 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
944 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
946 stale = new KAutoSaveFile(url, doc);
947 doc->m_autosave = stale;
949 doc->m_autosave = stale;
950 doc->setUrl(stale->managedFile());
951 doc->setModified(true);
952 stale->setParent(doc);
954 connectDocumentInfo(doc);
955 TrackView *trackView = new TrackView(doc, this);
956 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
957 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
958 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
959 slotGotProgressInfo(QString(), -1);
960 m_clipMonitor->refreshMonitor(true);
963 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
964 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
965 foreach(KAutoSaveFile *stale, staleFiles) {
966 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
967 // show an error message; we could not steal the lockfile
968 // maybe another application got to the file before us?
972 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
973 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
974 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
975 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
980 void MainWindow::parseProfiles() {
981 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
983 //KdenliveSettings::setDefaulttmpfolder();
984 if (KdenliveSettings::mltpath().isEmpty()) {
985 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
987 if (KdenliveSettings::rendererpath().isEmpty()) {
988 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
989 if (!QFile::exists(inigoPath))
990 inigoPath = KStandardDirs::findExe("inigo");
991 else KdenliveSettings::setRendererpath(inigoPath);
993 QStringList profilesFilter;
994 profilesFilter << "*";
995 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
997 if (profilesList.isEmpty()) {
998 // Cannot find MLT path, try finding inigo
999 QString profilePath = KdenliveSettings::rendererpath();
1000 if (!profilePath.isEmpty()) {
1001 profilePath = profilePath.section('/', 0, -3);
1002 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1003 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1006 if (profilesList.isEmpty()) {
1007 // Cannot find the MLT profiles, ask for location
1008 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1009 getUrl->fileDialog()->setMode(KFile::Directory);
1010 if (getUrl->exec() == QDialog::Rejected) {
1013 KUrl mltPath = getUrl->selectedUrl();
1015 if (mltPath.isEmpty()) ::exit(0);
1016 KdenliveSettings::setMltpath(mltPath.path());
1017 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1021 if (KdenliveSettings::rendererpath().isEmpty()) {
1022 // Cannot find the MLT inigo renderer, ask for location
1023 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1024 if (getUrl->exec() == QDialog::Rejected) {
1027 KUrl rendererPath = getUrl->selectedUrl();
1029 if (rendererPath.isEmpty()) ::exit(0);
1030 KdenliveSettings::setRendererpath(rendererPath.path());
1033 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1035 // Parse MLT profiles to build a list of available video formats
1036 if (profilesList.isEmpty()) parseProfiles();
1040 void MainWindow::slotEditProfiles() {
1041 ProfilesDialog *w = new ProfilesDialog;
1046 void MainWindow::slotEditProjectSettings() {
1047 ProjectSettings *w = new ProjectSettings;
1048 if (w->exec() == QDialog::Accepted) {
1049 QString profile = w->selectedProfile();
1050 m_activeDocument->setProfilePath(profile);
1051 KdenliveSettings::setCurrent_profile(profile);
1052 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1053 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1054 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1055 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1056 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1058 // We need to desactivate & reactivate monitors to get a refresh
1059 m_monitorManager->switchMonitors();
1064 void MainWindow::slotRenderProject() {
1065 if (!m_renderWidget) {
1066 m_renderWidget = new RenderWidget(this);
1067 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)));
1068 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1070 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1071 if (currentTab) m_renderWidget->setTimeline(currentTab);
1072 m_renderWidget->setDocument(m_activeDocument);*/
1073 m_renderWidget->show();
1076 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) {
1077 if (dest.isEmpty()) return;
1080 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1081 if (currentTab && zoneOnly) {
1082 in = currentTab->inPoint();
1083 out = currentTab->outPoint();
1085 KTemporaryFile temp;
1086 temp.setAutoRemove(false);
1087 temp.setSuffix(".westley");
1089 m_projectMonitor->saveSceneList(temp.fileName());
1092 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1093 else if (guideStart != -1) {
1094 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1096 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1097 QString videoPlayer = "-";
1099 videoPlayer = KdenliveSettings::defaultplayerapp();
1100 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."));
1102 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1103 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1104 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1105 QProcess::startDetached(renderer, args);
1107 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1111 void MainWindow::slotUpdateMousePosition(int pos) {
1112 if (m_activeDocument)
1113 switch (m_timecodeFormat->currentIndex()) {
1115 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1118 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1122 void MainWindow::slotUpdateDocumentState(bool modified) {
1123 setCaption(m_activeDocument->description(), modified);
1124 m_saveAction->setEnabled(modified);
1126 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1127 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1129 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1130 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1134 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1135 if (m_activeDocument) {
1136 if (m_activeDocument == doc) return;
1137 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1139 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1142 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1143 //m_projectMonitor->stop();
1144 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1145 if (m_activeDocument) {
1146 if (m_activeDocument == doc) return;
1147 m_activeDocument->backupMltPlaylist();
1148 if (m_activeTimeline) {
1149 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1150 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1151 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1152 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1153 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1154 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1155 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1156 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1157 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1158 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1159 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1160 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1161 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1162 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1163 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1164 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1165 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1166 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1168 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1169 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1170 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1171 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1172 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1173 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1174 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1175 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1176 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1177 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1178 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1179 effectStack->clear();
1181 m_activeDocument->setRenderer(NULL);
1182 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1183 m_clipMonitor->stop();
1185 KdenliveSettings::setCurrent_profile(doc->profilePath());
1186 KdenliveSettings::setProject_fps(doc->fps());
1187 m_monitorManager->resetProfiles(doc->timecode());
1188 m_projectList->setDocument(doc);
1189 transitionConfig->updateProjectFormat(doc->mltProfile());
1190 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1191 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1192 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1193 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1194 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1195 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1196 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1197 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1198 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1199 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1200 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1201 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1203 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1204 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1205 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1208 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1209 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1210 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1211 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1212 m_zoomSlider->setValue(doc->zoom());
1213 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1214 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1215 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1216 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1218 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1221 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1222 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1223 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1224 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1225 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1226 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1227 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1228 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1230 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1231 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1233 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1234 m_activeTimeline = trackView;
1235 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1236 doc->setRenderer(m_projectMonitor->render);
1237 m_commandStack->setActiveStack(doc->commandStack());
1238 KdenliveSettings::setProject_display_ratio(doc->dar());
1239 m_projectList->updateAllClips();
1240 trackView->projectView()->updateAllThumbs();
1243 //m_overView->setScene(trackView->projectScene());
1244 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1245 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1247 setCaption(doc->description(), doc->isModified());
1248 m_saveAction->setEnabled(doc->isModified());
1249 m_activeDocument = doc;
1252 void MainWindow::slotGuidesUpdated() {
1253 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1256 void MainWindow::slotPreferences(int page, int option) {
1257 //An instance of your dialog could be already created and could be
1258 // cached, in which case you want to display the cached dialog
1259 // instead of creating another one
1260 if (KConfigDialog::showDialog("settings")) {
1261 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1265 // KConfigDialog didn't find an instance of this dialog, so lets
1267 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1268 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1269 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1271 if (page != -1) dialog->showPage(page, option);
1274 void MainWindow::updateConfiguration() {
1275 //TODO: we should apply settings to all projects, not only the current one
1276 if (m_activeTimeline) {
1277 m_activeTimeline->refresh();
1278 m_activeTimeline->projectView()->checkAutoScroll();
1279 m_activeTimeline->projectView()->checkTrackHeight();
1280 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1282 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1283 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1284 activateShuttleDevice();
1288 void MainWindow::slotSwitchVideoThumbs() {
1289 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1290 if (m_activeTimeline) {
1291 m_activeTimeline->refresh();
1293 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1296 void MainWindow::slotSwitchAudioThumbs() {
1297 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1298 if (m_activeTimeline) {
1299 m_activeTimeline->refresh();
1300 m_activeTimeline->projectView()->checkAutoScroll();
1301 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1303 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1306 void MainWindow::slotSwitchMarkersComments() {
1307 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1308 if (m_activeTimeline) {
1309 m_activeTimeline->refresh();
1311 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1314 void MainWindow::slotSwitchSnap() {
1315 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1316 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1320 void MainWindow::slotDeleteTimelineClip() {
1321 if (m_activeTimeline) {
1322 m_activeTimeline->projectView()->deleteSelectedClips();
1326 void MainWindow::slotChangeClipSpeed() {
1327 if (m_activeTimeline) {
1328 m_activeTimeline->projectView()->changeClipSpeed();
1332 void MainWindow::slotAddClipMarker() {
1333 if (m_activeTimeline) {
1334 m_activeTimeline->projectView()->slotAddClipMarker();
1338 void MainWindow::slotDeleteClipMarker() {
1339 if (m_activeTimeline) {
1340 m_activeTimeline->projectView()->slotDeleteClipMarker();
1344 void MainWindow::slotDeleteAllClipMarkers() {
1345 if (m_activeTimeline) {
1346 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1350 void MainWindow::slotEditClipMarker() {
1351 if (m_activeTimeline) {
1352 m_activeTimeline->projectView()->slotEditClipMarker();
1356 void MainWindow::slotAddGuide() {
1357 if (m_activeTimeline)
1358 m_activeTimeline->projectView()->slotAddGuide();
1361 void MainWindow::slotEditGuide() {
1362 if (m_activeTimeline)
1363 m_activeTimeline->projectView()->slotEditGuide();
1366 void MainWindow::slotDeleteGuide() {
1367 if (m_activeTimeline)
1368 m_activeTimeline->projectView()->slotDeleteGuide();
1371 void MainWindow::slotDeleteAllGuides() {
1372 if (m_activeTimeline)
1373 m_activeTimeline->projectView()->slotDeleteAllGuides();
1376 void MainWindow::slotCutTimelineClip() {
1377 if (m_activeTimeline) {
1378 m_activeTimeline->projectView()->cutSelectedClips();
1382 void MainWindow::slotAddProjectClip(KUrl url) {
1383 if (m_activeDocument)
1384 m_activeDocument->slotAddClipFile(url, QString());
1387 void MainWindow::slotAddTransition(QAction *result) {
1388 if (!result) return;
1389 QDomElement effect = transitions.getEffectByName(result->data().toString());
1390 if (m_activeTimeline) {
1391 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1395 void MainWindow::slotAddVideoEffect(QAction *result) {
1396 if (!result) return;
1397 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1398 slotAddEffect(effect);
1401 void MainWindow::slotAddAudioEffect(QAction *result) {
1402 if (!result) return;
1403 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1404 slotAddEffect(effect);
1407 void MainWindow::slotAddCustomEffect(QAction *result) {
1408 if (!result) return;
1409 if (result->data().toString().isEmpty()) return;
1410 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1411 slotAddEffect(effect);
1414 void MainWindow::slotZoomIn() {
1415 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1418 void MainWindow::slotZoomOut() {
1419 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1422 void MainWindow::slotFitZoom() {
1423 if (m_activeTimeline) {
1424 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1428 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1429 statusProgressBar->setValue(progress);
1430 if (progress >= 0) {
1431 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1432 statusProgressBar->setVisible(true);
1434 m_messageLabel->setMessage(QString(), DefaultMessage);
1435 statusProgressBar->setVisible(false);
1439 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1440 if (clip->clipType() == TEXT) {
1441 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1442 QString path = clip->getProperty("resource");
1443 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1445 doc.setContent(clip->getProperty("xmldata"));
1446 dia_ui->setXml(doc);
1447 if (dia_ui->exec() == QDialog::Accepted) {
1448 QPixmap pix = dia_ui->renderedPixmap();
1450 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1451 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1452 QMap <QString, QString> newprops;
1453 newprops.insert("xmldata", dia_ui->xml().toString());
1454 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1455 m_activeDocument->commandStack()->push(command);
1456 m_clipMonitor->refreshMonitor(true);
1457 m_activeDocument->setModified(true);
1461 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1464 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1465 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1466 if (dia.exec() == QDialog::Accepted) {
1467 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1468 m_activeDocument->commandStack()->push(command);
1470 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1471 if (dia.needsTimelineRefresh()) {
1472 // update clip occurences in timeline
1473 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1478 void MainWindow::customEvent(QEvent* e) {
1479 if (e->type() == QEvent::User) {
1480 // The timeline playing position changed...
1481 kDebug() << "RECIEVED JOG EVEMNT!!!";
1484 void MainWindow::slotActivateEffectStackView() {
1485 effectStack->raiseWindow(effectStackDock);
1488 void MainWindow::slotActivateTransitionView() {
1489 transitionConfig->raiseWindow(transitionConfigDock);
1492 void MainWindow::slotSnapRewind() {
1493 if (m_projectMonitor->isActive()) {
1494 if (m_activeTimeline)
1495 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1499 void MainWindow::slotSnapForward() {
1500 if (m_projectMonitor->isActive()) {
1501 if (m_activeTimeline)
1502 m_activeTimeline->projectView()->slotSeekToNextSnap();
1506 void MainWindow::slotClipStart() {
1507 if (m_projectMonitor->isActive()) {
1508 if (m_activeTimeline)
1509 m_activeTimeline->projectView()->clipStart();
1513 void MainWindow::slotClipEnd() {
1514 if (m_projectMonitor->isActive()) {
1515 if (m_activeTimeline)
1516 m_activeTimeline->projectView()->clipEnd();
1520 void MainWindow::slotChangeTool(QAction * action) {
1521 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1522 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1525 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1526 if (m_activeDocument && m_activeTimeline) {
1527 //m_activeDocument->setTool(tool);
1528 m_activeTimeline->projectView()->setTool(tool);
1532 void MainWindow::slotCopy() {
1533 if (!m_activeDocument || !m_activeTimeline) return;
1534 m_activeTimeline->projectView()->copyClip();
1537 void MainWindow::slotPaste() {
1538 if (!m_activeDocument || !m_activeTimeline) return;
1539 m_activeTimeline->projectView()->pasteClip();
1542 void MainWindow::slotPasteEffects() {
1543 if (!m_activeDocument || !m_activeTimeline) return;
1544 m_activeTimeline->projectView()->pasteClipEffects();
1547 void MainWindow::slotFind() {
1548 if (!m_activeDocument || !m_activeTimeline) return;
1549 m_projectSearch->setEnabled(false);
1550 m_findActivated = true;
1551 m_findString = QString();
1552 m_activeTimeline->projectView()->initSearchStrings();
1553 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1554 m_findTimer.start(5000);
1555 qApp->installEventFilter(this);
1558 void MainWindow::slotFindNext() {
1559 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1560 statusBar()->showMessage(i18n("Found : %1", m_findString));
1562 statusBar()->showMessage(i18n("Reached end of project"));
1564 m_findTimer.start(4000);
1567 void MainWindow::findAhead() {
1568 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1569 m_projectSearchNext->setEnabled(true);
1570 statusBar()->showMessage(i18n("Found : %1", m_findString));
1572 m_projectSearchNext->setEnabled(false);
1573 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1577 void MainWindow::findTimeout() {
1578 m_projectSearchNext->setEnabled(false);
1579 m_findActivated = false;
1580 m_findString = QString();
1581 statusBar()->showMessage(i18n("Find stopped"), 3000);
1582 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1583 m_projectSearch->setEnabled(true);
1584 removeEventFilter(this);
1587 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1588 if (m_findActivated) {
1589 if (ke->key() == Qt::Key_Backspace) {
1590 m_findString = m_findString.left(m_findString.length() - 1);
1592 if (!m_findString.isEmpty()) {
1598 m_findTimer.start(4000);
1601 } else if (ke->key() == Qt::Key_Escape) {
1605 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1606 m_findString += ke->text();
1610 m_findTimer.start(4000);
1614 } else KXmlGuiWindow::keyPressEvent(ke);
1617 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1618 if (m_findActivated) {
1619 if (event->type() == QEvent::ShortcutOverride) {
1620 QKeyEvent* ke = (QKeyEvent*) event;
1621 if (ke->text().trimmed().isEmpty()) return false;
1624 } else return false;
1626 // pass the event on to the parent class
1627 return QMainWindow::eventFilter(obj, event);
1631 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1632 KDialog *dialog = new KDialog(this);
1633 dialog->setCaption("Save clip zone");
1634 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1636 QWidget *widget = new QWidget(dialog);
1637 dialog->setMainWidget(widget);
1639 QVBoxLayout *vbox = new QVBoxLayout(widget);
1640 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1641 QString path = m_activeDocument->projectFolder().path();
1643 path.append("untitled.westley");
1644 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1645 url->setFilter("video/mlt-playlist");
1646 QLabel *label2 = new QLabel(i18n("Description:"), this);
1647 KLineEdit *edit = new KLineEdit(this);
1648 vbox->addWidget(label1);
1649 vbox->addWidget(url);
1650 vbox->addWidget(label2);
1651 vbox->addWidget(edit);
1652 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1656 void MainWindow::slotSetInPoint() {
1657 if (m_clipMonitor->isActive()) {
1658 m_clipMonitor->slotSetZoneStart();
1659 } else m_activeTimeline->projectView()->setInPoint();
1662 void MainWindow::slotSetOutPoint() {
1663 if (m_clipMonitor->isActive()) {
1664 m_clipMonitor->slotSetZoneEnd();
1665 } else m_activeTimeline->projectView()->setOutPoint();
1668 #include "mainwindow.moc"