1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include <QTextStream>
29 #include <KApplication>
33 #include <KActionCollection>
34 #include <KStandardAction>
35 #include <KFileDialog>
36 #include <KMessageBox>
38 #include <KIO/NetAccess>
41 #include <KConfigDialog>
42 #include <KXMLGUIFactory>
44 #include <kstandarddirs.h>
45 #include <KUrlRequesterDialog>
46 #include <KTemporaryFile>
47 #include <KActionMenu>
50 #include <ktogglefullscreenaction.h>
52 #include <KNotification>
53 #include <KNotifyConfigWidget>
55 #include <mlt++/Mlt.h>
57 #include "mainwindow.h"
58 #include "kdenlivesettings.h"
59 #include "kdenlivesettingsdialog.h"
60 #include "initeffects.h"
61 #include "profilesdialog.h"
62 #include "projectsettings.h"
64 #include "clipmanager.h"
65 #include "projectlist.h"
67 #include "recmonitor.h"
68 #include "monitormanager.h"
69 #include "kdenlivedoc.h"
70 #include "trackview.h"
71 #include "customtrackview.h"
72 #include "effectslistview.h"
73 #include "effectstackview.h"
74 #include "transitionsettings.h"
75 #include "renderwidget.h"
77 #include "jogshuttle.h"
78 #include "clipproperties.h"
80 #include "editclipcommand.h"
81 #include "titlewidget.h"
83 static const int ID_STATUS_MSG = 1;
84 static const int ID_EDITMODE_MSG = 2;
85 static const int ID_TIMELINE_MSG = 3;
86 static const int ID_TIMELINE_BUTTONS = 5;
87 static const int ID_TIMELINE_POS = 6;
88 static const int ID_TIMELINE_FORMAT = 7;
94 EffectsList MainWindow::videoEffects;
95 EffectsList MainWindow::audioEffects;
96 EffectsList MainWindow::customEffects;
97 EffectsList MainWindow::transitions;
99 MainWindow::MainWindow(QWidget *parent)
100 : KXmlGuiWindow(parent),
101 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
102 setlocale(LC_NUMERIC, "POSIX");
103 setFont(KGlobalSettings::toolBarFont());
105 m_commandStack = new QUndoGroup;
106 m_timelineArea = new KTabWidget(this);
107 m_timelineArea->setTabReorderingEnabled(true);
108 m_timelineArea->setTabBarHidden(true);
110 QToolButton *closeTabButton = new QToolButton;
111 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
112 closeTabButton->setIcon(KIcon("tab-close"));
113 closeTabButton->adjustSize();
114 closeTabButton->setToolTip(i18n("Close the current tab"));
115 m_timelineArea->setCornerWidget(closeTabButton);
116 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
118 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
119 m_findTimer.setSingleShot(true);
121 initEffects::parseEffectFiles();
122 m_monitorManager = new MonitorManager();
124 projectListDock = new QDockWidget(i18n("Project Tree"), this);
125 projectListDock->setObjectName("project_tree");
126 m_projectList = new ProjectList(this);
127 projectListDock->setWidget(m_projectList);
128 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
130 effectListDock = new QDockWidget(i18n("Effect List"), this);
131 effectListDock->setObjectName("effect_list");
132 m_effectList = new EffectsListView();
134 //m_effectList = new KListWidget(this);
135 effectListDock->setWidget(m_effectList);
136 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
138 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
139 effectStackDock->setObjectName("effect_stack");
140 effectStack = new EffectStackView(this);
141 effectStackDock->setWidget(effectStack);
142 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
144 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
145 transitionConfigDock->setObjectName("transition");
146 transitionConfig = new TransitionSettings(this);
147 transitionConfigDock->setWidget(transitionConfig);
148 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
150 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
151 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
155 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
156 clipMonitorDock->setObjectName("clip_monitor");
157 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
158 clipMonitorDock->setWidget(m_clipMonitor);
159 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
160 //m_clipMonitor->stop();
162 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
163 projectMonitorDock->setObjectName("project_monitor");
164 m_projectMonitor = new Monitor("project", m_monitorManager, this);
165 projectMonitorDock->setWidget(m_projectMonitor);
166 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
168 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
169 recMonitorDock->setObjectName("record_monitor");
170 m_recMonitor = new RecMonitor("record", this);
171 recMonitorDock->setWidget(m_recMonitor);
172 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
174 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
175 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
177 undoViewDock = new QDockWidget(i18n("Undo History"), this);
178 undoViewDock->setObjectName("undo_history");
179 m_undoView = new QUndoView(this);
180 m_undoView->setCleanIcon(KIcon("edit-clear"));
181 m_undoView->setEmptyLabel(i18n("Clean"));
182 undoViewDock->setWidget(m_undoView);
183 m_undoView->setGroup(m_commandStack);
184 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
186 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
187 //overviewDock->setObjectName("project_overview");
188 //m_overView = new CustomTrackView(NULL, NULL, this);
189 //overviewDock->setWidget(m_overView);
190 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
193 //tabifyDockWidget(projectListDock, effectListDock);
194 tabifyDockWidget(projectListDock, effectStackDock);
195 tabifyDockWidget(projectListDock, transitionConfigDock);
196 //tabifyDockWidget(projectListDock, undoViewDock);
199 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
200 tabifyDockWidget(clipMonitorDock, recMonitorDock);
201 setCentralWidget(m_timelineArea);
203 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
204 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
206 // build effects menus
208 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
209 QStringList effects = videoEffects.effectNames();
210 foreach(const QString &name, effects) {
211 action = new QAction(name, this);
212 action->setData(name);
213 videoEffectsMenu->addAction(action);
215 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
216 effects = audioEffects.effectNames();
217 foreach(const QString &name, effects) {
218 action = new QAction(name, this);
219 action->setData(name);
220 audioEffectsMenu->addAction(action);
222 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
223 effects = customEffects.effectNames();
224 foreach(const QString &name, effects) {
225 action = new QAction(name, this);
226 action->setData(name);
227 m_customEffectsMenu->addAction(action);
230 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
231 const QList<QAction *> viewActions = createPopupMenu()->actions();
232 viewMenu->insertActions(NULL, viewActions);
234 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
235 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
236 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
238 m_timelineContextMenu = new QMenu(this);
239 m_timelineContextClipMenu = new QMenu(this);
240 m_timelineContextTransitionMenu = new QMenu(this);
243 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
244 effects = transitions.effectNames();
245 foreach(const QString &name, effects) {
246 action = new QAction(name, this);
247 action->setData(name);
248 transitionsMenu->addAction(action);
250 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
252 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
254 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
255 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
256 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
257 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
258 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
260 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
261 m_timelineContextClipMenu->addMenu(markersMenu);
262 m_timelineContextClipMenu->addMenu(transitionsMenu);
263 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
264 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
265 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
267 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
268 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
270 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
271 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
272 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
273 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
274 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
275 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
277 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
278 slotConnectMonitors();
280 setAutoSaveSettings();
282 if (KdenliveSettings::openlastproject()) {
285 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
286 if (!staleFiles.isEmpty()) {
287 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) {
288 recoverFiles(staleFiles);
296 activateShuttleDevice();
297 projectListDock->raise();
300 void MainWindow::queryQuit() {
301 kDebug() << "----- SAVING CONFUIG";
302 if (queryClose()) kapp->quit();
306 bool MainWindow::queryClose() {
308 if (m_activeDocument && m_activeDocument->isModified()) {
309 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
310 case KMessageBox::Yes :
311 // save document here. If saving fails, return false;
314 case KMessageBox::No :
323 void MainWindow::saveProperties(KConfig*) {
324 // save properties here,used by session management
329 void MainWindow::readProperties(KConfig *config) {
330 // read properties here,used by session management
331 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
332 openFile(KUrl(Lastproject));
335 void MainWindow::slotReloadEffects() {
336 initEffects::parseCustomEffectsFile();
337 m_customEffectsMenu->clear();
338 const QStringList effects = customEffects.effectNames();
340 foreach(const QString &name, effects) {
341 action = new QAction(name, this);
342 action->setData(name);
343 m_customEffectsMenu->addAction(action);
345 m_effectList->reloadEffectList();
348 void MainWindow::activateShuttleDevice() {
349 if (m_jogProcess) delete m_jogProcess;
351 if (KdenliveSettings::enableshuttle() == false) return;
352 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
353 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
354 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
355 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
356 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
357 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
358 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
361 void MainWindow::slotShuttleButton(int code) {
364 slotShuttleAction(KdenliveSettings::shuttle1());
367 slotShuttleAction(KdenliveSettings::shuttle2());
370 slotShuttleAction(KdenliveSettings::shuttle3());
373 slotShuttleAction(KdenliveSettings::shuttle4());
376 slotShuttleAction(KdenliveSettings::shuttle5());
381 void MainWindow::slotShuttleAction(int code) {
386 m_monitorManager->slotPlay();
389 m_monitorManager->slotPlay();
394 void MainWindow::configureNotifications() {
395 KNotifyConfigWidget::configure(this);
398 void MainWindow::slotFullScreen() {
399 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
402 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
403 if (!m_activeDocument) return;
404 if (effect.isNull()) {
405 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
408 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
409 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
412 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
413 if (clipMonitor) clipMonitorDock->raise();
414 else projectMonitorDock->raise();
417 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
418 if (!m_activeDocument) return;
419 m_activeDocument->setProducerDuration(id, duration);
422 void MainWindow::slotConnectMonitors() {
424 m_projectList->setRenderer(m_clipMonitor->render);
425 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
426 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
427 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
428 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
429 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 > &)));
431 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
433 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
435 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
436 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
438 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
439 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
442 void MainWindow::slotAdjustClipMonitor() {
443 clipMonitorDock->updateGeometry();
444 clipMonitorDock->adjustSize();
445 m_clipMonitor->resetSize();
448 void MainWindow::slotAdjustProjectMonitor() {
449 projectMonitorDock->updateGeometry();
450 projectMonitorDock->adjustSize();
451 m_projectMonitor->resetSize();
454 void MainWindow::setupActions() {
456 KActionCollection* collection = actionCollection();
457 m_timecodeFormat = new KComboBox(this);
458 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
459 m_timecodeFormat->addItem(i18n("Frames"));
461 statusProgressBar = new QProgressBar(this);
462 statusProgressBar->setMinimum(0);
463 statusProgressBar->setMaximum(100);
464 statusProgressBar->setMaximumWidth(150);
465 statusProgressBar->setVisible(false);
467 QWidget *w = new QWidget;
469 QHBoxLayout *layout = new QHBoxLayout;
470 w->setLayout(layout);
471 layout->setContentsMargins(5, 0, 5, 0);
472 QToolBar *toolbar = new QToolBar("statusToolBar", this);
475 m_toolGroup = new QActionGroup(this);
477 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;}";
479 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
480 m_buttonSelectTool->setCheckable(true);
481 m_buttonSelectTool->setChecked(true);
483 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
484 m_buttonRazorTool->setCheckable(true);
485 m_buttonRazorTool->setChecked(false);
487 m_toolGroup->addAction(m_buttonSelectTool);
488 m_toolGroup->addAction(m_buttonRazorTool);
489 m_toolGroup->setExclusive(true);
490 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
492 QWidget * actionWidget;
493 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
494 actionWidget->setMaximumWidth(24);
495 actionWidget->setMinimumHeight(17);
497 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
498 actionWidget->setMaximumWidth(24);
499 actionWidget->setMinimumHeight(17);
501 toolbar->setStyleSheet(style1);
502 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
504 toolbar->addSeparator();
505 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
506 m_buttonFitZoom->setCheckable(false);
507 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
509 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
510 actionWidget->setMaximumWidth(24);
511 actionWidget->setMinimumHeight(17);
513 m_zoomSlider = new QSlider(Qt::Horizontal, this);
514 m_zoomSlider->setMaximum(13);
515 m_zoomSlider->setPageStep(1);
517 m_zoomSlider->setMaximumWidth(150);
518 m_zoomSlider->setMinimumWidth(100);
520 const int contentHeight = QFontMetrics(w->font()).height() + 8;
522 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
523 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
525 m_zoomSlider->setStyleSheet(style);
527 //m_zoomSlider->height() + 5;
528 statusBar()->setMinimumHeight(contentHeight);
531 toolbar->addWidget(m_zoomSlider);
533 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
534 m_buttonVideoThumbs->setCheckable(true);
535 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
536 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
538 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
539 m_buttonAudioThumbs->setCheckable(true);
540 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
541 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
543 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
544 m_buttonShowMarkers->setCheckable(true);
545 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
546 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
548 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
549 m_buttonSnap->setCheckable(true);
550 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
551 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
552 layout->addWidget(toolbar);
555 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
556 actionWidget->setMaximumWidth(24);
557 actionWidget->setMinimumHeight(17);
559 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
560 actionWidget->setMaximumWidth(24);
561 actionWidget->setMinimumHeight(17);
563 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
564 actionWidget->setMaximumWidth(24);
565 actionWidget->setMinimumHeight(17);
567 actionWidget = toolbar->widgetForAction(m_buttonSnap);
568 actionWidget->setMaximumWidth(24);
569 actionWidget->setMinimumHeight(17);
571 m_messageLabel = new StatusBarMessageLabel(this);
572 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
574 statusBar()->addWidget(m_messageLabel, 10);
575 statusBar()->addWidget(statusProgressBar, 0);
576 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
577 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
578 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
579 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
580 m_messageLabel->hide();
582 collection->addAction("select_tool", m_buttonSelectTool);
583 collection->addAction("razor_tool", m_buttonRazorTool);
585 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
586 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
587 collection->addAction("show_markers", m_buttonShowMarkers);
588 collection->addAction("snap", m_buttonSnap);
589 collection->addAction("zoom_fit", m_buttonFitZoom);
591 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
592 collection->addAction("project_find", m_projectSearch);
593 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
594 m_projectSearch->setShortcut(Qt::Key_Slash);
596 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
597 collection->addAction("project_find_next", m_projectSearchNext);
598 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
599 m_projectSearchNext->setShortcut(Qt::Key_F3);
600 m_projectSearchNext->setEnabled(false);
602 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
603 collection->addAction("manage_profiles", profilesAction);
604 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
606 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
607 collection->addAction("project_settings", projectAction);
608 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
610 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
611 collection->addAction("project_render", projectRender);
612 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
614 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
615 KShortcut playShortcut;
616 playShortcut.setPrimary(Qt::Key_Space);
617 playShortcut.setAlternate(Qt::Key_K);
618 monitorPlay->setShortcut(playShortcut);
619 collection->addAction("monitor_play", monitorPlay);
620 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
622 KAction *markIn = collection->addAction("mark_in");
623 markIn->setText(i18n("Set in point"));
624 markIn->setShortcut(Qt::Key_I);
625 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
627 KAction *markOut = collection->addAction("mark_out");
628 markOut->setText(i18n("Set in point"));
629 markOut->setShortcut(Qt::Key_O);
630 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
632 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
633 monitorSeekBackward->setShortcut(Qt::Key_J);
634 collection->addAction("monitor_seek_backward", monitorSeekBackward);
635 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
637 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
638 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
639 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
640 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
642 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
643 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
644 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
645 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
647 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
648 monitorSeekForward->setShortcut(Qt::Key_L);
649 collection->addAction("monitor_seek_forward", monitorSeekForward);
650 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
652 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
653 clipStart->setShortcut(Qt::Key_Home);
654 collection->addAction("seek_clip_start", clipStart);
655 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
657 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
658 clipEnd->setShortcut(Qt::Key_End);
659 collection->addAction("seek_clip_end", clipEnd);
660 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
662 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
663 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
664 collection->addAction("seek_start", projectStart);
665 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
667 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
668 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
669 collection->addAction("seek_end", projectEnd);
670 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
672 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
673 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
674 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
675 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
677 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
678 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
679 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
680 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
682 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
683 deleteTimelineClip->setShortcut(Qt::Key_Delete);
684 collection->addAction("delete_timeline_clip", deleteTimelineClip);
685 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
687 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
688 collection->addAction("change_clip_speed", editTimelineClipSpeed);
689 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
691 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
692 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
693 collection->addAction("cut_timeline_clip", cutTimelineClip);
694 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
696 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
697 collection->addAction("add_clip_marker", addClipMarker);
698 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
700 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
701 collection->addAction("delete_clip_marker", deleteClipMarker);
702 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
704 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
705 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
706 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
708 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
709 collection->addAction("edit_clip_marker", editClipMarker);
710 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
712 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
713 collection->addAction("add_guide", addGuide);
714 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
716 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
717 collection->addAction("delete_guide", delGuide);
718 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
720 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
721 collection->addAction("edit_guide", editGuide);
722 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
724 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
725 collection->addAction("delete_all_guides", delAllGuides);
726 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
728 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
729 collection->addAction("paste_effects", pasteEffects);
730 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
732 KStandardAction::quit(this, SLOT(queryQuit()),
735 KStandardAction::open(this, SLOT(openFile()),
738 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
741 KStandardAction::saveAs(this, SLOT(saveFileAs()),
744 KStandardAction::openNew(this, SLOT(newFile()),
747 KStandardAction::preferences(this, SLOT(slotPreferences()),
750 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
752 KStandardAction::copy(this, SLOT(slotCopy()),
755 KStandardAction::paste(this, SLOT(slotPaste()),
758 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
760 undo->setEnabled(false);
761 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
763 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
765 redo->setEnabled(false);
766 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
768 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
770 connect(collection, SIGNAL(actionHovered(QAction*)),
771 this, SLOT(slotDisplayActionMessage(QAction*)));
772 //connect(collection, SIGNAL( clearStatusText() ),
773 //statusBar(), SLOT( clear() ) );
776 void MainWindow::slotDisplayActionMessage(QAction *a) {
777 statusBar()->showMessage(a->data().toString(), 3000);
780 void MainWindow::saveOptions() {
781 KdenliveSettings::self()->writeConfig();
782 KSharedConfigPtr config = KGlobal::config();
783 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
787 void MainWindow::readOptions() {
788 KSharedConfigPtr config = KGlobal::config();
789 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
790 KConfigGroup initialGroup(config, "version");
791 if (!initialGroup.exists()) {
792 // this is our first run, show Wizard
793 Wizard *w = new Wizard(this);
794 if (w->exec() == QDialog::Accepted && w->isOk()) {
796 initialGroup.writeEntry("version", "0.7");
800 // TODO: find a better way to exit application faster
801 QTimer::singleShot(1000, this, SLOT(queryQuit()));
806 void MainWindow::newFile() {
809 QPoint projectTracks(3, 2);
810 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
812 ProjectSettings *w = new ProjectSettings;
813 if (w->exec() != QDialog::Accepted) return;
814 profileName = w->selectedProfile();
815 projectFolder = w->selectedFolder();
816 projectTracks = w->tracks();
819 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
820 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
821 TrackView *trackView = new TrackView(doc, this);
822 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
823 if (m_timelineArea->count() == 1) {
824 connectDocumentInfo(doc);
825 connectDocument(trackView, doc);
826 } else m_timelineArea->setTabBarHidden(false);
829 void MainWindow::activateDocument() {
830 if (m_timelineArea->currentWidget() == NULL) return;
831 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
832 KdenliveDoc *currentDoc = currentTab->document();
833 connectDocumentInfo(currentDoc);
834 connectDocument(currentTab, currentDoc);
837 void MainWindow::closeCurrentDocument() {
838 QWidget *w = m_timelineArea->currentWidget();
839 // closing current document
840 int ix = m_timelineArea->currentIndex() + 1;
841 if (ix == m_timelineArea->count()) ix = 0;
842 m_timelineArea->setCurrentIndex(ix);
843 TrackView *tabToClose = (TrackView *) w;
844 KdenliveDoc *docToClose = tabToClose->document();
845 if (docToClose && docToClose->isModified()) {
846 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
847 case KMessageBox::Yes :
848 // save document here. If saving fails, return false;
851 case KMessageBox::Cancel :
857 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
858 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
861 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
864 void MainWindow::saveFileAs(const QString &outputFileName) {
865 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
866 m_activeDocument->setUrl(KUrl(outputFileName));
867 if (m_activeDocument->m_autosave == NULL) {
868 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
869 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
870 setCaption(m_activeDocument->description());
871 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
872 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
873 m_activeDocument->setModified(false);
874 m_fileOpenRecent->addUrl(KUrl(outputFileName));
877 void MainWindow::saveFileAs() {
878 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
879 if (QFile::exists(outputFile)) {
880 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
882 saveFileAs(outputFile);
885 void MainWindow::saveFile() {
886 if (!m_activeDocument) return;
887 if (m_activeDocument->url().isEmpty()) {
890 saveFileAs(m_activeDocument->url().path());
891 m_activeDocument->m_autosave->resize(0);
895 void MainWindow::openFile() {
896 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
897 if (url.isEmpty()) return;
898 m_fileOpenRecent->addUrl(url);
902 void MainWindow::openLastFile() {
903 KSharedConfigPtr config = KGlobal::config();
904 KUrl::List urls = m_fileOpenRecent->urls();
905 if (urls.isEmpty()) newFile();
906 else openFile(urls.last());
909 void MainWindow::openFile(const KUrl &url) {
910 // Check for backup file
911 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
912 if (!staleFiles.isEmpty()) {
913 if (KMessageBox::questionYesNo(this,
914 i18n("Auto-saved files exist. Do you want to recover them now?"),
915 i18n("File Recovery"),
916 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
917 recoverFiles(staleFiles);
920 // remove the stale files
921 foreach(KAutoSaveFile *stale, staleFiles) {
922 stale->open(QIODevice::ReadWrite);
927 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
928 doOpenFile(url, NULL);
931 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
933 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
935 stale = new KAutoSaveFile(url, doc);
936 doc->m_autosave = stale;
938 doc->m_autosave = stale;
939 doc->setUrl(stale->managedFile());
940 doc->setModified(true);
941 stale->setParent(doc);
943 connectDocumentInfo(doc);
944 TrackView *trackView = new TrackView(doc, this);
945 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
946 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
947 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
948 slotGotProgressInfo(QString(), -1);
949 m_clipMonitor->refreshMonitor(true);
952 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
953 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
954 foreach(KAutoSaveFile *stale, staleFiles) {
955 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
956 // show an error message; we could not steal the lockfile
957 // maybe another application got to the file before us?
961 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
962 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
963 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
964 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
969 void MainWindow::parseProfiles() {
970 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
972 //KdenliveSettings::setDefaulttmpfolder();
973 if (KdenliveSettings::mltpath().isEmpty()) {
974 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
976 if (KdenliveSettings::rendererpath().isEmpty()) {
977 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
978 if (!QFile::exists(inigoPath))
979 inigoPath = KStandardDirs::findExe("inigo");
980 else KdenliveSettings::setRendererpath(inigoPath);
982 QStringList profilesFilter;
983 profilesFilter << "*";
984 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
986 if (profilesList.isEmpty()) {
987 // Cannot find MLT path, try finding inigo
988 QString profilePath = KdenliveSettings::rendererpath();
989 if (!profilePath.isEmpty()) {
990 profilePath = profilePath.section('/', 0, -3);
991 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
992 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
995 if (profilesList.isEmpty()) {
996 // Cannot find the MLT profiles, ask for location
997 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
998 getUrl->fileDialog()->setMode(KFile::Directory);
1000 KUrl mltPath = getUrl->selectedUrl();
1002 if (mltPath.isEmpty()) kapp->quit();
1003 KdenliveSettings::setMltpath(mltPath.path());
1004 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1008 if (KdenliveSettings::rendererpath().isEmpty()) {
1009 // Cannot find the MLT inigo renderer, ask for location
1010 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1012 KUrl rendererPath = getUrl->selectedUrl();
1014 if (rendererPath.isEmpty()) kapp->quit();
1015 KdenliveSettings::setRendererpath(rendererPath.path());
1018 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1020 // Parse MLT profiles to build a list of available video formats
1021 if (profilesList.isEmpty()) parseProfiles();
1025 void MainWindow::slotEditProfiles() {
1026 ProfilesDialog *w = new ProfilesDialog;
1031 void MainWindow::slotEditProjectSettings() {
1032 ProjectSettings *w = new ProjectSettings;
1033 if (w->exec() == QDialog::Accepted) {
1034 QString profile = w->selectedProfile();
1035 m_activeDocument->setProfilePath(profile);
1036 KdenliveSettings::setCurrent_profile(profile);
1037 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1038 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1039 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1040 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1041 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1043 // We need to desactivate & reactivate monitors to get a refresh
1044 m_monitorManager->switchMonitors();
1049 void MainWindow::slotRenderProject() {
1050 if (!m_renderWidget) {
1051 m_renderWidget = new RenderWidget(this);
1052 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)));
1053 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1055 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1056 if (currentTab) m_renderWidget->setTimeline(currentTab);
1057 m_renderWidget->setDocument(m_activeDocument);*/
1058 m_renderWidget->show();
1061 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) {
1062 if (dest.isEmpty()) return;
1065 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1066 if (currentTab && zoneOnly) {
1067 in = currentTab->inPoint();
1068 out = currentTab->outPoint();
1070 KTemporaryFile temp;
1071 temp.setAutoRemove(false);
1072 temp.setSuffix(".westley");
1074 m_projectMonitor->saveSceneList(temp.fileName());
1077 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1078 else if (guideStart != -1) {
1079 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1081 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1082 QString videoPlayer = "-";
1084 videoPlayer = KdenliveSettings::defaultplayerapp();
1085 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."));
1087 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1088 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1089 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1090 QProcess::startDetached(renderer, args);
1092 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1096 void MainWindow::slotUpdateMousePosition(int pos) {
1097 if (m_activeDocument)
1098 switch (m_timecodeFormat->currentIndex()) {
1100 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1103 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1107 void MainWindow::slotUpdateDocumentState(bool modified) {
1108 setCaption(m_activeDocument->description(), modified);
1109 m_saveAction->setEnabled(modified);
1111 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1112 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1114 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1115 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1119 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1120 if (m_activeDocument) {
1121 if (m_activeDocument == doc) return;
1122 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1124 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1127 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1128 //m_projectMonitor->stop();
1129 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1130 if (m_activeDocument) {
1131 if (m_activeDocument == doc) return;
1132 m_activeDocument->backupMltPlaylist();
1133 if (m_activeTimeline) {
1134 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1135 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1136 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1137 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1138 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1139 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1140 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1141 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1142 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1143 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1144 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1145 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1146 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1147 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1148 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1149 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1150 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1151 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1153 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1154 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1155 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1156 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1157 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1158 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1159 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1160 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1161 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1162 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1163 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1164 effectStack->clear();
1166 m_activeDocument->setRenderer(NULL);
1167 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1168 m_clipMonitor->stop();
1170 KdenliveSettings::setCurrent_profile(doc->profilePath());
1171 KdenliveSettings::setProject_fps(doc->fps());
1172 m_monitorManager->resetProfiles(doc->timecode());
1173 m_projectList->setDocument(doc);
1174 transitionConfig->updateProjectFormat(doc->mltProfile());
1175 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1176 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1177 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1178 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1179 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1180 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1181 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1182 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1183 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1184 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1185 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1186 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1188 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1189 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1190 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1193 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1194 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1195 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1196 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1197 m_zoomSlider->setValue(doc->zoom());
1198 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1199 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1200 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1201 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1203 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1206 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1207 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1208 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1209 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1210 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1211 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1212 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1213 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1215 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1216 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1218 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1219 m_activeTimeline = trackView;
1220 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1221 doc->setRenderer(m_projectMonitor->render);
1222 m_commandStack->setActiveStack(doc->commandStack());
1223 KdenliveSettings::setProject_display_ratio(doc->dar());
1224 m_projectList->updateAllClips();
1225 trackView->projectView()->updateAllThumbs();
1228 //m_overView->setScene(trackView->projectScene());
1229 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1230 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1232 setCaption(doc->description(), doc->isModified());
1233 m_saveAction->setEnabled(doc->isModified());
1234 m_activeDocument = doc;
1237 void MainWindow::slotGuidesUpdated() {
1238 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1241 void MainWindow::slotPreferences(int page, int option) {
1242 //An instance of your dialog could be already created and could be
1243 // cached, in which case you want to display the cached dialog
1244 // instead of creating another one
1245 if (KConfigDialog::showDialog("settings")) {
1246 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1250 // KConfigDialog didn't find an instance of this dialog, so lets
1252 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1253 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1254 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1256 if (page != -1) dialog->showPage(page, option);
1259 void MainWindow::updateConfiguration() {
1260 //TODO: we should apply settings to all projects, not only the current one
1261 if (m_activeTimeline) {
1262 m_activeTimeline->refresh();
1263 m_activeTimeline->projectView()->checkAutoScroll();
1264 m_activeTimeline->projectView()->checkTrackHeight();
1265 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1267 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1268 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1269 activateShuttleDevice();
1273 void MainWindow::slotSwitchVideoThumbs() {
1274 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1275 if (m_activeTimeline) {
1276 m_activeTimeline->refresh();
1278 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1281 void MainWindow::slotSwitchAudioThumbs() {
1282 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1283 if (m_activeTimeline) {
1284 m_activeTimeline->refresh();
1285 m_activeTimeline->projectView()->checkAutoScroll();
1286 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1288 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1291 void MainWindow::slotSwitchMarkersComments() {
1292 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1293 if (m_activeTimeline) {
1294 m_activeTimeline->refresh();
1296 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1299 void MainWindow::slotSwitchSnap() {
1300 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1301 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1305 void MainWindow::slotDeleteTimelineClip() {
1306 if (m_activeTimeline) {
1307 m_activeTimeline->projectView()->deleteSelectedClips();
1311 void MainWindow::slotChangeClipSpeed() {
1312 if (m_activeTimeline) {
1313 m_activeTimeline->projectView()->changeClipSpeed();
1317 void MainWindow::slotAddClipMarker() {
1318 if (m_activeTimeline) {
1319 m_activeTimeline->projectView()->slotAddClipMarker();
1323 void MainWindow::slotDeleteClipMarker() {
1324 if (m_activeTimeline) {
1325 m_activeTimeline->projectView()->slotDeleteClipMarker();
1329 void MainWindow::slotDeleteAllClipMarkers() {
1330 if (m_activeTimeline) {
1331 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1335 void MainWindow::slotEditClipMarker() {
1336 if (m_activeTimeline) {
1337 m_activeTimeline->projectView()->slotEditClipMarker();
1341 void MainWindow::slotAddGuide() {
1342 if (m_activeTimeline)
1343 m_activeTimeline->projectView()->slotAddGuide();
1346 void MainWindow::slotEditGuide() {
1347 if (m_activeTimeline)
1348 m_activeTimeline->projectView()->slotEditGuide();
1351 void MainWindow::slotDeleteGuide() {
1352 if (m_activeTimeline)
1353 m_activeTimeline->projectView()->slotDeleteGuide();
1356 void MainWindow::slotDeleteAllGuides() {
1357 if (m_activeTimeline)
1358 m_activeTimeline->projectView()->slotDeleteAllGuides();
1361 void MainWindow::slotCutTimelineClip() {
1362 if (m_activeTimeline) {
1363 m_activeTimeline->projectView()->cutSelectedClips();
1367 void MainWindow::slotAddProjectClip(KUrl url) {
1368 if (m_activeDocument)
1369 m_activeDocument->slotAddClipFile(url, QString());
1372 void MainWindow::slotAddTransition(QAction *result) {
1373 if (!result) return;
1374 QDomElement effect = transitions.getEffectByName(result->data().toString());
1375 if (m_activeTimeline) {
1376 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1380 void MainWindow::slotAddVideoEffect(QAction *result) {
1381 if (!result) return;
1382 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1383 slotAddEffect(effect);
1386 void MainWindow::slotAddAudioEffect(QAction *result) {
1387 if (!result) return;
1388 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1389 slotAddEffect(effect);
1392 void MainWindow::slotAddCustomEffect(QAction *result) {
1393 if (!result) return;
1394 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1395 slotAddEffect(effect);
1398 void MainWindow::slotZoomIn() {
1399 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1402 void MainWindow::slotZoomOut() {
1403 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1406 void MainWindow::slotFitZoom() {
1407 if (m_activeTimeline) {
1408 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1412 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1413 statusProgressBar->setValue(progress);
1414 if (progress >= 0) {
1415 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1416 statusProgressBar->setVisible(true);
1418 m_messageLabel->setMessage(QString(), DefaultMessage);
1419 statusProgressBar->setVisible(false);
1423 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1424 if (clip->clipType() == TEXT) {
1425 QString path = clip->getProperty("xml");
1426 TitleWidget *dia_ui = new TitleWidget(KUrl()/*path + ".kdenlivetitle")*/, path, m_projectMonitor->render, this);
1428 doc.setContent(clip->getProperty("xmldata"));
1429 dia_ui->setXml(doc);
1430 if (dia_ui->exec() == QDialog::Accepted) {
1431 kDebug() << "// UPDATUING CLIP TITLE: " << path;
1432 QPixmap pix = dia_ui->renderedPixmap();
1433 pix.save(path + ".png");
1434 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1435 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1436 QMap <QString, QString> newprops;
1437 newprops.insert("xmldata", dia_ui->xml().toString());
1438 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1439 m_activeDocument->commandStack()->push(command);
1440 //setModified(true);
1444 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1447 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1448 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1449 if (dia.exec() == QDialog::Accepted) {
1450 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1451 m_activeDocument->commandStack()->push(command);
1453 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1454 if (dia.needsTimelineRefresh()) {
1455 // update clip occurences in timeline
1456 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1461 void MainWindow::customEvent(QEvent* e) {
1462 if (e->type() == QEvent::User) {
1463 // The timeline playing position changed...
1464 kDebug() << "RECIEVED JOG EVEMNT!!!";
1467 void MainWindow::slotActivateEffectStackView() {
1468 effectStack->raiseWindow(effectStackDock);
1471 void MainWindow::slotActivateTransitionView() {
1472 transitionConfig->raiseWindow(transitionConfigDock);
1475 void MainWindow::slotSnapRewind() {
1476 if (m_projectMonitor->isActive()) {
1477 if (m_activeTimeline)
1478 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1482 void MainWindow::slotSnapForward() {
1483 if (m_projectMonitor->isActive()) {
1484 if (m_activeTimeline)
1485 m_activeTimeline->projectView()->slotSeekToNextSnap();
1489 void MainWindow::slotClipStart() {
1490 if (m_projectMonitor->isActive()) {
1491 if (m_activeTimeline)
1492 m_activeTimeline->projectView()->clipStart();
1496 void MainWindow::slotClipEnd() {
1497 if (m_projectMonitor->isActive()) {
1498 if (m_activeTimeline)
1499 m_activeTimeline->projectView()->clipEnd();
1503 void MainWindow::slotChangeTool(QAction * action) {
1504 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1505 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1508 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1509 if (m_activeDocument && m_activeTimeline) {
1510 //m_activeDocument->setTool(tool);
1511 m_activeTimeline->projectView()->setTool(tool);
1515 void MainWindow::slotCopy() {
1516 if (!m_activeDocument || !m_activeTimeline) return;
1517 m_activeTimeline->projectView()->copyClip();
1520 void MainWindow::slotPaste() {
1521 if (!m_activeDocument || !m_activeTimeline) return;
1522 m_activeTimeline->projectView()->pasteClip();
1525 void MainWindow::slotPasteEffects() {
1526 if (!m_activeDocument || !m_activeTimeline) return;
1527 m_activeTimeline->projectView()->pasteClipEffects();
1530 void MainWindow::slotFind() {
1531 if (!m_activeDocument || !m_activeTimeline) return;
1532 m_projectSearch->setEnabled(false);
1533 m_findActivated = true;
1534 m_findString = QString();
1535 m_activeTimeline->projectView()->initSearchStrings();
1536 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1537 m_findTimer.start(5000);
1538 qApp->installEventFilter(this);
1541 void MainWindow::slotFindNext() {
1542 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1543 statusBar()->showMessage(i18n("Found : %1", m_findString));
1545 statusBar()->showMessage(i18n("Reached end of project"));
1547 m_findTimer.start(4000);
1550 void MainWindow::findAhead() {
1551 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1552 m_projectSearchNext->setEnabled(true);
1553 statusBar()->showMessage(i18n("Found : %1", m_findString));
1555 m_projectSearchNext->setEnabled(false);
1556 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1560 void MainWindow::findTimeout() {
1561 m_projectSearchNext->setEnabled(false);
1562 m_findActivated = false;
1563 m_findString = QString();
1564 statusBar()->showMessage(i18n("Find stopped"), 3000);
1565 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1566 m_projectSearch->setEnabled(true);
1567 removeEventFilter(this);
1570 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1571 if (m_findActivated) {
1572 if (ke->key() == Qt::Key_Backspace) {
1573 m_findString = m_findString.left(m_findString.length() - 1);
1575 if (!m_findString.isEmpty()) {
1581 m_findTimer.start(4000);
1584 } else if (ke->key() == Qt::Key_Escape) {
1588 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1589 m_findString += ke->text();
1593 m_findTimer.start(4000);
1597 } else KXmlGuiWindow::keyPressEvent(ke);
1600 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1601 if (m_findActivated) {
1602 if (event->type() == QEvent::ShortcutOverride) {
1603 QKeyEvent* ke = (QKeyEvent*) event;
1604 if (ke->text().trimmed().isEmpty()) return false;
1607 } else return false;
1609 // pass the event on to the parent class
1610 return QMainWindow::eventFilter(obj, event);
1614 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1615 KDialog *dialog = new KDialog(this);
1616 dialog->setCaption("Save clip zone");
1617 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1619 QWidget *widget = new QWidget(dialog);
1620 dialog->setMainWidget(widget);
1622 QVBoxLayout *vbox = new QVBoxLayout(widget);
1623 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1624 QString path = m_activeDocument->projectFolder().path();
1626 path.append("untitled.westley");
1627 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1628 url->setFilter("video/mlt-playlist");
1629 QLabel *label2 = new QLabel(i18n("Description:"), this);
1630 KLineEdit *edit = new KLineEdit(this);
1631 vbox->addWidget(label1);
1632 vbox->addWidget(url);
1633 vbox->addWidget(label2);
1634 vbox->addWidget(edit);
1635 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1639 void MainWindow::slotSetInPoint() {
1640 if (m_clipMonitor->isActive()) {
1641 m_clipMonitor->slotSetZoneStart();
1642 } else m_activeTimeline->projectView()->setInPoint();
1645 void MainWindow::slotSetOutPoint() {
1646 if (m_clipMonitor->isActive()) {
1647 m_clipMonitor->slotSetZoneEnd();
1648 } else m_activeTimeline->projectView()->setOutPoint();
1651 #include "mainwindow.moc"