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>
53 #include <mlt++/Mlt.h>
55 #include "mainwindow.h"
56 #include "kdenlivesettings.h"
57 #include "kdenlivesettingsdialog.h"
58 #include "initeffects.h"
59 #include "profilesdialog.h"
60 #include "projectsettings.h"
62 #include "renderjob.h"
63 #include "clipmanager.h"
64 #include "projectlist.h"
66 #include "recmonitor.h"
67 #include "monitormanager.h"
68 #include "kdenlivedoc.h"
69 #include "trackview.h"
70 #include "customtrackview.h"
71 #include "effectslistview.h"
72 #include "effectstackview.h"
73 #include "transitionsettings.h"
74 #include "renderwidget.h"
76 #include "jogshuttle.h"
77 #include "clipproperties.h"
79 #include "editclipcommand.h"
80 #include "titlewidget.h"
82 static const int ID_STATUS_MSG = 1;
83 static const int ID_EDITMODE_MSG = 2;
84 static const int ID_TIMELINE_MSG = 3;
85 static const int ID_TIMELINE_BUTTONS = 5;
86 static const int ID_TIMELINE_POS = 6;
87 static const int ID_TIMELINE_FORMAT = 7;
93 EffectsList MainWindow::videoEffects;
94 EffectsList MainWindow::audioEffects;
95 EffectsList MainWindow::customEffects;
96 EffectsList MainWindow::transitions;
98 MainWindow::MainWindow(QWidget *parent)
99 : KXmlGuiWindow(parent),
100 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
101 setlocale(LC_NUMERIC, "POSIX");
102 setFont(KGlobalSettings::toolBarFont());
104 m_commandStack = new QUndoGroup;
105 m_timelineArea = new KTabWidget(this);
106 m_timelineArea->setTabReorderingEnabled(true);
107 m_timelineArea->setTabBarHidden(true);
109 QToolButton *closeTabButton = new QToolButton;
110 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
111 closeTabButton->setIcon(KIcon("tab-close"));
112 closeTabButton->adjustSize();
113 closeTabButton->setToolTip(i18n("Close the current tab"));
114 m_timelineArea->setCornerWidget(closeTabButton);
115 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
117 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
118 m_findTimer.setSingleShot(true);
120 initEffects::parseEffectFiles();
121 m_monitorManager = new MonitorManager();
123 projectListDock = new QDockWidget(i18n("Project Tree"), this);
124 projectListDock->setObjectName("project_tree");
125 m_projectList = new ProjectList(this);
126 projectListDock->setWidget(m_projectList);
127 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
129 effectListDock = new QDockWidget(i18n("Effect List"), this);
130 effectListDock->setObjectName("effect_list");
131 m_effectList = new EffectsListView();
133 //m_effectList = new KListWidget(this);
134 effectListDock->setWidget(m_effectList);
135 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
137 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
138 effectStackDock->setObjectName("effect_stack");
139 effectStack = new EffectStackView(this);
140 effectStackDock->setWidget(effectStack);
141 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
143 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
144 transitionConfigDock->setObjectName("transition");
145 transitionConfig = new TransitionSettings(this);
146 transitionConfigDock->setWidget(transitionConfig);
147 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
149 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
150 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
154 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
155 clipMonitorDock->setObjectName("clip_monitor");
156 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
157 clipMonitorDock->setWidget(m_clipMonitor);
158 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
159 //m_clipMonitor->stop();
161 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
162 projectMonitorDock->setObjectName("project_monitor");
163 m_projectMonitor = new Monitor("project", m_monitorManager, this);
164 projectMonitorDock->setWidget(m_projectMonitor);
165 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
167 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
168 recMonitorDock->setObjectName("record_monitor");
169 m_recMonitor = new RecMonitor("record", this);
170 recMonitorDock->setWidget(m_recMonitor);
171 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
173 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
174 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
176 undoViewDock = new QDockWidget(i18n("Undo History"), this);
177 undoViewDock->setObjectName("undo_history");
178 m_undoView = new QUndoView(this);
179 m_undoView->setCleanIcon(KIcon("edit-clear"));
180 m_undoView->setEmptyLabel(i18n("Clean"));
181 undoViewDock->setWidget(m_undoView);
182 m_undoView->setGroup(m_commandStack);
183 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
185 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
186 //overviewDock->setObjectName("project_overview");
187 //m_overView = new CustomTrackView(NULL, NULL, this);
188 //overviewDock->setWidget(m_overView);
189 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
192 //tabifyDockWidget(projectListDock, effectListDock);
193 tabifyDockWidget(projectListDock, effectStackDock);
194 tabifyDockWidget(projectListDock, transitionConfigDock);
195 //tabifyDockWidget(projectListDock, undoViewDock);
198 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
199 tabifyDockWidget(clipMonitorDock, recMonitorDock);
200 setCentralWidget(m_timelineArea);
202 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
203 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
205 // build effects menus
207 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
208 QStringList effects = videoEffects.effectNames();
209 foreach(const QString &name, effects) {
210 action = new QAction(name, this);
211 action->setData(name);
212 videoEffectsMenu->addAction(action);
214 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
215 effects = audioEffects.effectNames();
216 foreach(const QString &name, effects) {
217 action = new QAction(name, this);
218 action->setData(name);
219 audioEffectsMenu->addAction(action);
221 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
222 effects = customEffects.effectNames();
223 foreach(const QString &name, effects) {
224 action = new QAction(name, this);
225 action->setData(name);
226 m_customEffectsMenu->addAction(action);
229 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
230 const QList<QAction *> viewActions = createPopupMenu()->actions();
231 viewMenu->insertActions(NULL, viewActions);
233 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
234 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
235 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
237 m_timelineContextMenu = new QMenu(this);
238 m_timelineContextClipMenu = new QMenu(this);
239 m_timelineContextTransitionMenu = new QMenu(this);
242 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
243 effects = transitions.effectNames();
244 foreach(const QString &name, effects) {
245 action = new QAction(name, this);
246 action->setData(name);
247 transitionsMenu->addAction(action);
249 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
251 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
253 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
254 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
255 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
256 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
257 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
259 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
260 m_timelineContextClipMenu->addMenu(markersMenu);
261 m_timelineContextClipMenu->addMenu(transitionsMenu);
262 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
263 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
264 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
266 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
267 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
269 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
270 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
271 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
272 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
273 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
274 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
276 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
277 slotConnectMonitors();
279 setAutoSaveSettings();
281 if (KdenliveSettings::openlastproject()) {
284 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
285 if (!staleFiles.isEmpty()) {
286 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) {
287 recoverFiles(staleFiles);
295 activateShuttleDevice();
296 projectListDock->raise();
299 void MainWindow::queryQuit() {
300 kDebug() << "----- SAVING CONFUIG";
301 if (queryClose()) kapp->quit();
305 bool MainWindow::queryClose() {
307 if (m_activeDocument && m_activeDocument->isModified()) {
308 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
309 case KMessageBox::Yes :
310 // save document here. If saving fails, return false;
313 case KMessageBox::No :
322 void MainWindow::saveProperties(KConfig*) {
323 // save properties here,used by session management
328 void MainWindow::readProperties(KConfig *config) {
329 // read properties here,used by session management
330 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
331 openFile(KUrl(Lastproject));
334 void MainWindow::slotReloadEffects() {
335 initEffects::parseCustomEffectsFile();
336 m_customEffectsMenu->clear();
337 const QStringList effects = customEffects.effectNames();
339 foreach(const QString &name, effects) {
340 action = new QAction(name, this);
341 action->setData(name);
342 m_customEffectsMenu->addAction(action);
344 m_effectList->reloadEffectList();
347 void MainWindow::activateShuttleDevice() {
348 if (m_jogProcess) delete m_jogProcess;
350 if (KdenliveSettings::enableshuttle() == false) return;
351 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
352 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
353 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
354 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
355 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
356 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
357 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
360 void MainWindow::slotShuttleButton(int code) {
363 slotShuttleAction(KdenliveSettings::shuttle1());
366 slotShuttleAction(KdenliveSettings::shuttle2());
369 slotShuttleAction(KdenliveSettings::shuttle3());
372 slotShuttleAction(KdenliveSettings::shuttle4());
375 slotShuttleAction(KdenliveSettings::shuttle5());
380 void MainWindow::slotShuttleAction(int code) {
385 m_monitorManager->slotPlay();
388 m_monitorManager->slotPlay();
393 void MainWindow::slotFullScreen() {
394 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
397 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
398 if (!m_activeDocument) return;
399 if (effect.isNull()) {
400 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
403 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
404 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
407 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
408 if (clipMonitor) clipMonitorDock->raise();
409 else projectMonitorDock->raise();
412 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
413 if (!m_activeDocument) return;
414 m_activeDocument->setProducerDuration(id, duration);
417 void MainWindow::slotConnectMonitors() {
419 m_projectList->setRenderer(m_clipMonitor->render);
420 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
421 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
422 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
423 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
424 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 > &)));
426 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
428 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
430 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
431 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
433 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
434 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
437 void MainWindow::slotAdjustClipMonitor() {
438 clipMonitorDock->updateGeometry();
439 clipMonitorDock->adjustSize();
440 m_clipMonitor->resetSize();
443 void MainWindow::slotAdjustProjectMonitor() {
444 projectMonitorDock->updateGeometry();
445 projectMonitorDock->adjustSize();
446 m_projectMonitor->resetSize();
449 void MainWindow::setupActions() {
451 m_timecodeFormat = new KComboBox(this);
452 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
453 m_timecodeFormat->addItem(i18n("Frames"));
455 statusProgressBar = new QProgressBar(this);
456 statusProgressBar->setMinimum(0);
457 statusProgressBar->setMaximum(100);
458 statusProgressBar->setMaximumWidth(150);
459 statusProgressBar->setVisible(false);
461 QWidget *w = new QWidget;
463 QHBoxLayout *layout = new QHBoxLayout;
464 w->setLayout(layout);
465 layout->setContentsMargins(5, 0, 5, 0);
466 QToolBar *toolbar = new QToolBar("statusToolBar", this);
469 m_toolGroup = new QActionGroup(this);
471 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;}";
473 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
474 m_buttonSelectTool->setCheckable(true);
475 m_buttonSelectTool->setChecked(true);
477 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
478 m_buttonRazorTool->setCheckable(true);
479 m_buttonRazorTool->setChecked(false);
481 m_toolGroup->addAction(m_buttonSelectTool);
482 m_toolGroup->addAction(m_buttonRazorTool);
483 m_toolGroup->setExclusive(true);
484 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
486 QWidget * actionWidget;
487 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
488 actionWidget->setMaximumWidth(24);
489 actionWidget->setMinimumHeight(17);
491 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
492 actionWidget->setMaximumWidth(24);
493 actionWidget->setMinimumHeight(17);
495 toolbar->setStyleSheet(style1);
496 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
498 toolbar->addSeparator();
499 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
500 m_buttonFitZoom->setCheckable(false);
501 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
503 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
504 actionWidget->setMaximumWidth(24);
505 actionWidget->setMinimumHeight(17);
507 m_zoomSlider = new QSlider(Qt::Horizontal, this);
508 m_zoomSlider->setMaximum(13);
509 m_zoomSlider->setPageStep(1);
511 m_zoomSlider->setMaximumWidth(150);
512 m_zoomSlider->setMinimumWidth(100);
514 const int contentHeight = QFontMetrics(w->font()).height() + 8;
515 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
516 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
517 m_zoomSlider->setStyleSheet(style);
519 //m_zoomSlider->setMaximumHeight(contentHeight);
520 //m_zoomSlider->height() + 5;
521 statusBar()->setMinimumHeight(contentHeight);
524 toolbar->addWidget(m_zoomSlider);
526 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
527 m_buttonVideoThumbs->setCheckable(true);
528 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
529 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
531 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
532 m_buttonAudioThumbs->setCheckable(true);
533 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
534 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
536 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
537 m_buttonShowMarkers->setCheckable(true);
538 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
539 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
541 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
542 m_buttonSnap->setCheckable(true);
543 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
544 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
545 layout->addWidget(toolbar);
548 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
549 actionWidget->setMaximumWidth(24);
550 actionWidget->setMinimumHeight(17);
552 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
553 actionWidget->setMaximumWidth(24);
554 actionWidget->setMinimumHeight(17);
556 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
557 actionWidget->setMaximumWidth(24);
558 actionWidget->setMinimumHeight(17);
560 actionWidget = toolbar->widgetForAction(m_buttonSnap);
561 actionWidget->setMaximumWidth(24);
562 actionWidget->setMinimumHeight(17);
564 m_messageLabel = new StatusBarMessageLabel(this);
565 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
567 statusBar()->addWidget(m_messageLabel, 10);
568 statusBar()->addWidget(statusProgressBar, 0);
569 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
570 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
571 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
572 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
573 m_messageLabel->hide();
575 actionCollection()->addAction("select_tool", m_buttonSelectTool);
576 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
578 actionCollection()->addAction("show_video_thumbs", m_buttonVideoThumbs);
579 actionCollection()->addAction("show_audio_thumbs", m_buttonAudioThumbs);
580 actionCollection()->addAction("show_markers", m_buttonShowMarkers);
581 actionCollection()->addAction("snap", m_buttonSnap);
582 actionCollection()->addAction("zoom_fit", m_buttonFitZoom);
584 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
585 actionCollection()->addAction("project_find", m_projectSearch);
586 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
587 m_projectSearch->setShortcut(Qt::Key_Slash);
589 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
590 actionCollection()->addAction("project_find_next", m_projectSearchNext);
591 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
592 m_projectSearchNext->setShortcut(Qt::Key_F3);
593 m_projectSearchNext->setEnabled(false);
595 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
596 actionCollection()->addAction("manage_profiles", profilesAction);
597 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
599 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
600 actionCollection()->addAction("project_settings", projectAction);
601 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
603 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
604 actionCollection()->addAction("project_render", projectRender);
605 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
607 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
608 monitorPlay->setShortcut(Qt::Key_Space);
609 actionCollection()->addAction("monitor_play", monitorPlay);
610 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
612 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
613 monitorSeekBackward->setShortcut(Qt::Key_J);
614 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
615 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
617 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
618 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
619 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
620 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
622 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
623 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
624 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
625 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
627 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
628 monitorSeekForward->setShortcut(Qt::Key_L);
629 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
630 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
632 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
633 clipStart->setShortcut(Qt::Key_Home);
634 actionCollection()->addAction("seek_clip_start", clipStart);
635 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
637 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
638 clipEnd->setShortcut(Qt::Key_End);
639 actionCollection()->addAction("seek_clip_end", clipEnd);
640 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
642 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
643 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
644 actionCollection()->addAction("seek_start", projectStart);
645 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
647 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
648 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
649 actionCollection()->addAction("seek_end", projectEnd);
650 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
652 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
653 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
654 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
655 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
657 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
658 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
659 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
660 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
662 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
663 deleteTimelineClip->setShortcut(Qt::Key_Delete);
664 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
665 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
667 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
668 actionCollection()->addAction("change_clip_speed", editTimelineClipSpeed);
669 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
671 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
672 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
673 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
674 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
676 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
677 actionCollection()->addAction("add_clip_marker", addClipMarker);
678 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
680 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
681 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
682 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
684 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
685 actionCollection()->addAction("delete_all_clip_markers", deleteAllClipMarkers);
686 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
688 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
689 actionCollection()->addAction("edit_clip_marker", editClipMarker);
690 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
692 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
693 actionCollection()->addAction("add_guide", addGuide);
694 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
696 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
697 actionCollection()->addAction("delete_guide", delGuide);
698 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
700 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
701 actionCollection()->addAction("edit_guide", editGuide);
702 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
704 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
705 actionCollection()->addAction("delete_all_guides", delAllGuides);
706 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
708 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
709 actionCollection()->addAction("paste_effects", pasteEffects);
710 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
712 KStandardAction::quit(this, SLOT(queryQuit()),
715 KStandardAction::open(this, SLOT(openFile()),
718 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
721 KStandardAction::saveAs(this, SLOT(saveFileAs()),
724 KStandardAction::openNew(this, SLOT(newFile()),
727 KStandardAction::preferences(this, SLOT(slotPreferences()),
730 KStandardAction::copy(this, SLOT(slotCopy()),
733 KStandardAction::paste(this, SLOT(slotPaste()),
736 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
738 undo->setEnabled(false);
739 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
741 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
743 redo->setEnabled(false);
744 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
746 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
748 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
749 this, SLOT(slotDisplayActionMessage(QAction*)));
750 //connect(actionCollection(), SIGNAL( clearStatusText() ),
751 //statusBar(), SLOT( clear() ) );
754 void MainWindow::slotDisplayActionMessage(QAction *a) {
755 statusBar()->showMessage(a->data().toString(), 3000);
758 void MainWindow::saveOptions() {
759 KdenliveSettings::self()->writeConfig();
760 KSharedConfigPtr config = KGlobal::config();
761 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
765 void MainWindow::readOptions() {
766 KSharedConfigPtr config = KGlobal::config();
767 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
768 KConfigGroup initialGroup(config, "version");
769 if (!initialGroup.exists()) {
770 // this is our first run, show Wizard
771 Wizard *w = new Wizard(this);
772 if (w->exec() == QDialog::Accepted && w->isOk()) {
774 initialGroup.writeEntry("version", "0.7");
778 // TODO: find a better way to exit application faster
779 QTimer::singleShot(1000, this, SLOT(queryQuit()));
784 void MainWindow::newFile() {
787 QPoint projectTracks(3, 2);
788 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
790 ProjectSettings *w = new ProjectSettings;
791 if (w->exec() != QDialog::Accepted) return;
792 profileName = w->selectedProfile();
793 projectFolder = w->selectedFolder();
794 projectTracks = w->tracks();
797 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
798 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
799 TrackView *trackView = new TrackView(doc, this);
800 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
801 if (m_timelineArea->count() == 1) {
802 connectDocumentInfo(doc);
803 connectDocument(trackView, doc);
804 } else m_timelineArea->setTabBarHidden(false);
807 void MainWindow::activateDocument() {
808 if (m_timelineArea->currentWidget() == NULL) return;
809 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
810 KdenliveDoc *currentDoc = currentTab->document();
811 connectDocumentInfo(currentDoc);
812 connectDocument(currentTab, currentDoc);
815 void MainWindow::closeCurrentDocument() {
816 QWidget *w = m_timelineArea->currentWidget();
817 // closing current document
818 int ix = m_timelineArea->currentIndex() + 1;
819 if (ix == m_timelineArea->count()) ix = 0;
820 m_timelineArea->setCurrentIndex(ix);
821 TrackView *tabToClose = (TrackView *) w;
822 KdenliveDoc *docToClose = tabToClose->document();
823 if (docToClose && docToClose->isModified()) {
824 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
825 case KMessageBox::Yes :
826 // save document here. If saving fails, return false;
829 case KMessageBox::Cancel :
835 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
836 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
839 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
842 void MainWindow::saveFileAs(const QString &outputFileName) {
843 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
844 m_activeDocument->setUrl(KUrl(outputFileName));
845 if (m_activeDocument->m_autosave == NULL) {
846 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
847 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
848 setCaption(m_activeDocument->description());
849 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
850 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
851 m_activeDocument->setModified(false);
852 m_fileOpenRecent->addUrl(KUrl(outputFileName));
855 void MainWindow::saveFileAs() {
856 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
857 if (QFile::exists(outputFile)) {
858 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
860 saveFileAs(outputFile);
863 void MainWindow::saveFile() {
864 if (!m_activeDocument) return;
865 if (m_activeDocument->url().isEmpty()) {
868 saveFileAs(m_activeDocument->url().path());
869 m_activeDocument->m_autosave->resize(0);
873 void MainWindow::openFile() {
874 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
875 if (url.isEmpty()) return;
876 m_fileOpenRecent->addUrl(url);
880 void MainWindow::openLastFile() {
881 KSharedConfigPtr config = KGlobal::config();
882 KUrl::List urls = m_fileOpenRecent->urls();
883 if (urls.isEmpty()) newFile();
884 else openFile(urls.last());
887 void MainWindow::openFile(const KUrl &url) {
888 // Check for backup file
889 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
890 if (!staleFiles.isEmpty()) {
891 if (KMessageBox::questionYesNo(this,
892 i18n("Auto-saved files exist. Do you want to recover them now?"),
893 i18n("File Recovery"),
894 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
895 recoverFiles(staleFiles);
898 // remove the stale files
899 foreach(KAutoSaveFile *stale, staleFiles) {
900 stale->open(QIODevice::ReadWrite);
905 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
906 doOpenFile(url, NULL);
909 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
911 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
913 stale = new KAutoSaveFile(url, doc);
914 doc->m_autosave = stale;
916 doc->m_autosave = stale;
917 doc->setUrl(stale->managedFile());
918 doc->setModified(true);
919 stale->setParent(doc);
921 connectDocumentInfo(doc);
922 TrackView *trackView = new TrackView(doc, this);
923 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
924 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
925 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
926 slotGotProgressInfo(QString(), -1);
927 m_clipMonitor->refreshMonitor(true);
930 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
931 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
932 foreach(KAutoSaveFile *stale, staleFiles) {
933 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
934 // show an error message; we could not steal the lockfile
935 // maybe another application got to the file before us?
939 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
940 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
941 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
942 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
947 void MainWindow::parseProfiles() {
948 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
950 //KdenliveSettings::setDefaulttmpfolder();
951 if (KdenliveSettings::mltpath().isEmpty()) {
952 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
954 if (KdenliveSettings::rendererpath().isEmpty()) {
955 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
957 QStringList profilesFilter;
958 profilesFilter << "*";
959 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
961 if (profilesList.isEmpty()) {
962 // Cannot find MLT path, try finding inigo
963 QString profilePath = KdenliveSettings::rendererpath();
964 if (!profilePath.isEmpty()) {
965 profilePath = profilePath.section('/', 0, -3);
966 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
967 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
970 if (profilesList.isEmpty()) {
971 // Cannot find the MLT profiles, ask for location
972 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
973 getUrl->fileDialog()->setMode(KFile::Directory);
975 KUrl mltPath = getUrl->selectedUrl();
977 if (mltPath.isEmpty()) kapp->quit();
978 KdenliveSettings::setMltpath(mltPath.path());
979 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
983 if (KdenliveSettings::rendererpath().isEmpty()) {
984 // Cannot find the MLT inigo renderer, ask for location
985 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
987 KUrl rendererPath = getUrl->selectedUrl();
989 if (rendererPath.isEmpty()) kapp->quit();
990 KdenliveSettings::setRendererpath(rendererPath.path());
993 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
995 // Parse MLT profiles to build a list of available video formats
996 if (profilesList.isEmpty()) parseProfiles();
1000 void MainWindow::slotEditProfiles() {
1001 ProfilesDialog *w = new ProfilesDialog;
1006 void MainWindow::slotEditProjectSettings() {
1007 ProjectSettings *w = new ProjectSettings;
1008 if (w->exec() == QDialog::Accepted) {
1009 QString profile = w->selectedProfile();
1010 m_activeDocument->setProfilePath(profile);
1011 KdenliveSettings::setCurrent_profile(profile);
1012 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1013 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1014 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1015 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1016 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1018 // We need to desactivate & reactivate monitors to get a refresh
1019 m_monitorManager->switchMonitors();
1024 void MainWindow::slotRenderProject() {
1025 if (!m_renderWidget) {
1026 m_renderWidget = new RenderWidget(this);
1027 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool)));
1029 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1030 if (currentTab) m_renderWidget->setTimeline(currentTab);
1031 m_renderWidget->setDocument(m_activeDocument);*/
1032 m_renderWidget->show();
1035 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
1036 if (dest.isEmpty()) return;
1039 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1040 if (currentTab && zoneOnly) {
1041 in = currentTab->inPoint();
1042 out = currentTab->outPoint();
1044 KTemporaryFile temp;
1045 temp.setAutoRemove(false);
1046 temp.setSuffix(".westley");
1048 m_projectMonitor->saveSceneList(temp.fileName());
1051 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1052 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1053 QString videoPlayer = "-";
1055 videoPlayer = KdenliveSettings::defaultplayerapp();
1056 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."));
1058 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1059 QProcess::startDetached("kdenlive_render", args);
1060 kDebug() << "/// STARTING RENDER PROCESS\n\nARGS:\n" << args;
1064 void MainWindow::slotUpdateMousePosition(int pos) {
1065 if (m_activeDocument)
1066 switch (m_timecodeFormat->currentIndex()) {
1068 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1071 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1075 void MainWindow::slotUpdateDocumentState(bool modified) {
1076 setCaption(m_activeDocument->description(), modified);
1077 m_saveAction->setEnabled(modified);
1079 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1080 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1082 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1083 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1087 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1088 if (m_activeDocument) {
1089 if (m_activeDocument == doc) return;
1090 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1092 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1095 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1096 //m_projectMonitor->stop();
1097 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1098 if (m_activeDocument) {
1099 if (m_activeDocument == doc) return;
1100 m_activeDocument->backupMltPlaylist();
1101 if (m_activeTimeline) {
1102 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1103 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1104 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1105 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1106 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1107 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1108 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1109 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1110 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1111 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1112 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1113 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1114 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1115 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1116 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1117 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1118 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1120 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1121 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1122 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1123 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1124 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1125 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1126 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1127 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1128 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1129 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1130 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1131 effectStack->clear();
1133 m_activeDocument->setRenderer(NULL);
1134 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1135 m_clipMonitor->stop();
1137 KdenliveSettings::setCurrent_profile(doc->profilePath());
1138 KdenliveSettings::setProject_fps(doc->fps());
1139 m_monitorManager->resetProfiles(doc->timecode());
1140 m_projectList->setDocument(doc);
1141 transitionConfig->updateProjectFormat(doc->mltProfile());
1142 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1143 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1144 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1145 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1146 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1147 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1148 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1149 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1150 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1151 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1152 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1153 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1155 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1156 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1160 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1161 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1162 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1163 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1164 m_zoomSlider->setValue(doc->zoom());
1165 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1166 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1167 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1168 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1170 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1173 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1174 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1175 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1176 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1177 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1178 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1179 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1180 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1182 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1183 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1185 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1186 m_activeTimeline = trackView;
1187 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1188 doc->setRenderer(m_projectMonitor->render);
1189 m_commandStack->setActiveStack(doc->commandStack());
1190 KdenliveSettings::setProject_display_ratio(doc->dar());
1191 doc->updateAllProjectClips();
1194 //m_overView->setScene(trackView->projectScene());
1195 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1196 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1198 setCaption(doc->description(), doc->isModified());
1199 m_saveAction->setEnabled(doc->isModified());
1200 m_activeDocument = doc;
1203 void MainWindow::slotPreferences(int page, int option) {
1204 //An instance of your dialog could be already created and could be
1205 // cached, in which case you want to display the cached dialog
1206 // instead of creating another one
1207 if (KConfigDialog::showDialog("settings")) {
1208 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1212 // KConfigDialog didn't find an instance of this dialog, so lets
1214 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1215 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1216 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1218 if (page != -1) dialog->showPage(page, option);
1221 void MainWindow::updateConfiguration() {
1222 //TODO: we should apply settings to all projects, not only the current one
1223 if (m_activeTimeline) {
1224 m_activeTimeline->refresh();
1225 m_activeTimeline->projectView()->checkAutoScroll();
1226 m_activeTimeline->projectView()->checkTrackHeight();
1227 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1229 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1230 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1231 activateShuttleDevice();
1235 void MainWindow::slotSwitchVideoThumbs() {
1236 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1237 if (m_activeTimeline) {
1238 m_activeTimeline->refresh();
1240 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1243 void MainWindow::slotSwitchAudioThumbs() {
1244 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1245 if (m_activeTimeline) {
1246 m_activeTimeline->refresh();
1247 m_activeTimeline->projectView()->checkAutoScroll();
1248 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1250 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1253 void MainWindow::slotSwitchMarkersComments() {
1254 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1255 if (m_activeTimeline) {
1256 m_activeTimeline->refresh();
1258 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1261 void MainWindow::slotSwitchSnap() {
1262 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1263 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1267 void MainWindow::slotDeleteTimelineClip() {
1268 if (m_activeTimeline) {
1269 m_activeTimeline->projectView()->deleteSelectedClips();
1273 void MainWindow::slotChangeClipSpeed() {
1274 if (m_activeTimeline) {
1275 m_activeTimeline->projectView()->changeClipSpeed();
1279 void MainWindow::slotAddClipMarker() {
1280 if (m_activeTimeline) {
1281 m_activeTimeline->projectView()->slotAddClipMarker();
1285 void MainWindow::slotDeleteClipMarker() {
1286 if (m_activeTimeline) {
1287 m_activeTimeline->projectView()->slotDeleteClipMarker();
1291 void MainWindow::slotDeleteAllClipMarkers() {
1292 if (m_activeTimeline) {
1293 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1297 void MainWindow::slotEditClipMarker() {
1298 if (m_activeTimeline) {
1299 m_activeTimeline->projectView()->slotEditClipMarker();
1303 void MainWindow::slotAddGuide() {
1304 if (m_activeTimeline)
1305 m_activeTimeline->projectView()->slotAddGuide();
1308 void MainWindow::slotEditGuide() {
1309 if (m_activeTimeline)
1310 m_activeTimeline->projectView()->slotEditGuide();
1313 void MainWindow::slotDeleteGuide() {
1314 if (m_activeTimeline)
1315 m_activeTimeline->projectView()->slotDeleteGuide();
1318 void MainWindow::slotDeleteAllGuides() {
1319 if (m_activeTimeline)
1320 m_activeTimeline->projectView()->slotDeleteAllGuides();
1323 void MainWindow::slotCutTimelineClip() {
1324 if (m_activeTimeline) {
1325 m_activeTimeline->projectView()->cutSelectedClips();
1329 void MainWindow::slotAddProjectClip(KUrl url) {
1330 if (m_activeDocument)
1331 m_activeDocument->slotAddClipFile(url, QString());
1334 void MainWindow::slotAddTransition(QAction *result) {
1335 if (!result) return;
1336 QDomElement effect = transitions.getEffectByName(result->data().toString());
1337 if (m_activeTimeline) {
1338 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1342 void MainWindow::slotAddVideoEffect(QAction *result) {
1343 if (!result) return;
1344 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1345 slotAddEffect(effect);
1348 void MainWindow::slotAddAudioEffect(QAction *result) {
1349 if (!result) return;
1350 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1351 slotAddEffect(effect);
1354 void MainWindow::slotAddCustomEffect(QAction *result) {
1355 if (!result) return;
1356 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1357 slotAddEffect(effect);
1360 void MainWindow::slotZoomIn() {
1361 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1364 void MainWindow::slotZoomOut() {
1365 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1368 void MainWindow::slotFitZoom() {
1369 if (m_activeTimeline) {
1370 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1374 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1375 statusProgressBar->setValue(progress);
1376 if (progress >= 0) {
1377 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1378 statusProgressBar->setVisible(true);
1380 m_messageLabel->setMessage(QString(), DefaultMessage);
1381 statusProgressBar->setVisible(false);
1385 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1386 if (clip->clipType() == TEXT) {
1387 QString path = clip->getProperty("xml");
1388 TitleWidget *dia_ui = new TitleWidget(KUrl()/*path + ".kdenlivetitle")*/, path, m_projectMonitor->render, this);
1390 doc.setContent(clip->getProperty("xmldata"));
1391 dia_ui->setXml(doc);
1392 if (dia_ui->exec() == QDialog::Accepted) {
1393 kDebug() << "// UPDATUING CLIP TITLE: " << path;
1394 QPixmap pix = dia_ui->renderedPixmap();
1395 pix.save(path + ".png");
1396 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1397 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1398 QMap <QString, QString> newprops;
1399 newprops.insert("xmldata", dia_ui->xml().toString());
1400 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1401 m_activeDocument->commandStack()->push(command);
1402 //setModified(true);
1406 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1409 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1410 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1411 if (dia.exec() == QDialog::Accepted) {
1412 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1413 m_activeDocument->commandStack()->push(command);
1415 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1416 if (dia.needsTimelineRefresh()) {
1417 // update clip occurences in timeline
1418 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1423 void MainWindow::customEvent(QEvent* e) {
1424 if (e->type() == QEvent::User) {
1425 // The timeline playing position changed...
1426 kDebug() << "RECIEVED JOG EVEMNT!!!";
1429 void MainWindow::slotActivateEffectStackView() {
1430 effectStack->raiseWindow(effectStackDock);
1433 void MainWindow::slotActivateTransitionView() {
1434 transitionConfig->raiseWindow(transitionConfigDock);
1437 void MainWindow::slotSnapRewind() {
1438 if (m_monitorManager->projectMonitorFocused()) {
1439 if (m_activeTimeline)
1440 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1444 void MainWindow::slotSnapForward() {
1445 if (m_monitorManager->projectMonitorFocused()) {
1446 if (m_activeTimeline)
1447 m_activeTimeline->projectView()->slotSeekToNextSnap();
1451 void MainWindow::slotClipStart() {
1452 if (m_monitorManager->projectMonitorFocused()) {
1453 if (m_activeTimeline)
1454 m_activeTimeline->projectView()->clipStart();
1458 void MainWindow::slotClipEnd() {
1459 if (m_monitorManager->projectMonitorFocused()) {
1460 if (m_activeTimeline)
1461 m_activeTimeline->projectView()->clipEnd();
1465 void MainWindow::slotChangeTool(QAction * action) {
1466 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1467 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1470 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1471 if (m_activeDocument && m_activeTimeline) {
1472 //m_activeDocument->setTool(tool);
1473 m_activeTimeline->projectView()->setTool(tool);
1477 void MainWindow::slotCopy() {
1478 if (!m_activeDocument || !m_activeTimeline) return;
1479 m_activeTimeline->projectView()->copyClip();
1482 void MainWindow::slotPaste() {
1483 if (!m_activeDocument || !m_activeTimeline) return;
1484 m_activeTimeline->projectView()->pasteClip();
1487 void MainWindow::slotPasteEffects() {
1488 if (!m_activeDocument || !m_activeTimeline) return;
1489 m_activeTimeline->projectView()->pasteClipEffects();
1492 void MainWindow::slotFind() {
1493 if (!m_activeDocument || !m_activeTimeline) return;
1494 m_projectSearch->setEnabled(false);
1495 m_findActivated = true;
1496 m_findString = QString();
1497 m_activeTimeline->projectView()->initSearchStrings();
1498 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1499 m_findTimer.start(5000);
1500 qApp->installEventFilter(this);
1503 void MainWindow::slotFindNext() {
1504 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1505 statusBar()->showMessage(i18n("Found : %1", m_findString));
1507 statusBar()->showMessage(i18n("Reached end of project"));
1509 m_findTimer.start(4000);
1512 void MainWindow::findAhead() {
1513 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1514 m_projectSearchNext->setEnabled(true);
1515 statusBar()->showMessage(i18n("Found : %1", m_findString));
1517 m_projectSearchNext->setEnabled(false);
1518 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1522 void MainWindow::findTimeout() {
1523 m_projectSearchNext->setEnabled(false);
1524 m_findActivated = false;
1525 m_findString = QString();
1526 statusBar()->showMessage(i18n("Find stopped"), 3000);
1527 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1528 m_projectSearch->setEnabled(true);
1529 removeEventFilter(this);
1532 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1533 if (m_findActivated) {
1534 if (ke->key() == Qt::Key_Backspace) {
1535 m_findString = m_findString.left(m_findString.length() - 1);
1537 if (!m_findString.isEmpty()) {
1543 m_findTimer.start(4000);
1546 } else if (ke->key() == Qt::Key_Escape) {
1550 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1551 m_findString += ke->text();
1555 m_findTimer.start(4000);
1559 } else KXmlGuiWindow::keyPressEvent(ke);
1562 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1563 if (m_findActivated) {
1564 if (event->type() == QEvent::ShortcutOverride) {
1565 QKeyEvent* ke = (QKeyEvent*) event;
1566 if (ke->text().trimmed().isEmpty()) return false;
1569 } else return false;
1571 // pass the event on to the parent class
1572 return QMainWindow::eventFilter(obj, event);
1576 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1577 KDialog *dialog = new KDialog(this);
1578 dialog->setCaption("Save clip zone");
1579 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1581 QWidget *widget = new QWidget(dialog);
1582 dialog->setMainWidget(widget);
1584 QVBoxLayout *vbox = new QVBoxLayout(widget);
1585 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1586 QString path = m_activeDocument->projectFolder().path();
1588 path.append("untitled.westley");
1589 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1590 url->setFilter("video/mlt-playlist");
1591 QLabel *label2 = new QLabel(i18n("Description:"), this);
1592 KLineEdit *edit = new KLineEdit(this);
1593 vbox->addWidget(label1);
1594 vbox->addWidget(url);
1595 vbox->addWidget(label2);
1596 vbox->addWidget(edit);
1597 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1601 #include "mainwindow.moc"