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 "clipmanager.h"
63 #include "projectlist.h"
65 #include "recmonitor.h"
66 #include "monitormanager.h"
67 #include "kdenlivedoc.h"
68 #include "trackview.h"
69 #include "customtrackview.h"
70 #include "effectslistview.h"
71 #include "effectstackview.h"
72 #include "transitionsettings.h"
73 #include "renderwidget.h"
75 #include "jogshuttle.h"
76 #include "clipproperties.h"
78 #include "editclipcommand.h"
79 #include "titlewidget.h"
81 static const int ID_STATUS_MSG = 1;
82 static const int ID_EDITMODE_MSG = 2;
83 static const int ID_TIMELINE_MSG = 3;
84 static const int ID_TIMELINE_BUTTONS = 5;
85 static const int ID_TIMELINE_POS = 6;
86 static const int ID_TIMELINE_FORMAT = 7;
92 EffectsList MainWindow::videoEffects;
93 EffectsList MainWindow::audioEffects;
94 EffectsList MainWindow::customEffects;
95 EffectsList MainWindow::transitions;
97 MainWindow::MainWindow(QWidget *parent)
98 : KXmlGuiWindow(parent),
99 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
100 setlocale(LC_NUMERIC, "POSIX");
101 setFont(KGlobalSettings::toolBarFont());
103 m_commandStack = new QUndoGroup;
104 m_timelineArea = new KTabWidget(this);
105 m_timelineArea->setTabReorderingEnabled(true);
106 m_timelineArea->setTabBarHidden(true);
108 QToolButton *closeTabButton = new QToolButton;
109 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
110 closeTabButton->setIcon(KIcon("tab-close"));
111 closeTabButton->adjustSize();
112 closeTabButton->setToolTip(i18n("Close the current tab"));
113 m_timelineArea->setCornerWidget(closeTabButton);
114 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
116 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
117 m_findTimer.setSingleShot(true);
119 initEffects::parseEffectFiles();
120 m_monitorManager = new MonitorManager();
122 projectListDock = new QDockWidget(i18n("Project Tree"), this);
123 projectListDock->setObjectName("project_tree");
124 m_projectList = new ProjectList(this);
125 projectListDock->setWidget(m_projectList);
126 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
128 effectListDock = new QDockWidget(i18n("Effect List"), this);
129 effectListDock->setObjectName("effect_list");
130 m_effectList = new EffectsListView();
132 //m_effectList = new KListWidget(this);
133 effectListDock->setWidget(m_effectList);
134 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
136 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
137 effectStackDock->setObjectName("effect_stack");
138 effectStack = new EffectStackView(this);
139 effectStackDock->setWidget(effectStack);
140 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
142 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
143 transitionConfigDock->setObjectName("transition");
144 transitionConfig = new TransitionSettings(this);
145 transitionConfigDock->setWidget(transitionConfig);
146 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
148 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
149 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
153 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
154 clipMonitorDock->setObjectName("clip_monitor");
155 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
156 clipMonitorDock->setWidget(m_clipMonitor);
157 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
158 //m_clipMonitor->stop();
160 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
161 projectMonitorDock->setObjectName("project_monitor");
162 m_projectMonitor = new Monitor("project", m_monitorManager, this);
163 projectMonitorDock->setWidget(m_projectMonitor);
164 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
166 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
167 recMonitorDock->setObjectName("record_monitor");
168 m_recMonitor = new RecMonitor("record", this);
169 recMonitorDock->setWidget(m_recMonitor);
170 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
172 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
173 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
175 undoViewDock = new QDockWidget(i18n("Undo History"), this);
176 undoViewDock->setObjectName("undo_history");
177 m_undoView = new QUndoView(this);
178 m_undoView->setCleanIcon(KIcon("edit-clear"));
179 m_undoView->setEmptyLabel(i18n("Clean"));
180 undoViewDock->setWidget(m_undoView);
181 m_undoView->setGroup(m_commandStack);
182 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
184 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
185 //overviewDock->setObjectName("project_overview");
186 //m_overView = new CustomTrackView(NULL, NULL, this);
187 //overviewDock->setWidget(m_overView);
188 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
191 //tabifyDockWidget(projectListDock, effectListDock);
192 tabifyDockWidget(projectListDock, effectStackDock);
193 tabifyDockWidget(projectListDock, transitionConfigDock);
194 //tabifyDockWidget(projectListDock, undoViewDock);
197 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
198 tabifyDockWidget(clipMonitorDock, recMonitorDock);
199 setCentralWidget(m_timelineArea);
201 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
202 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
204 // build effects menus
206 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
207 QStringList effects = videoEffects.effectNames();
208 foreach(const QString &name, effects) {
209 action = new QAction(name, this);
210 action->setData(name);
211 videoEffectsMenu->addAction(action);
213 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
214 effects = audioEffects.effectNames();
215 foreach(const QString &name, effects) {
216 action = new QAction(name, this);
217 action->setData(name);
218 audioEffectsMenu->addAction(action);
220 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
221 effects = customEffects.effectNames();
222 foreach(const QString &name, effects) {
223 action = new QAction(name, this);
224 action->setData(name);
225 m_customEffectsMenu->addAction(action);
228 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
229 const QList<QAction *> viewActions = createPopupMenu()->actions();
230 viewMenu->insertActions(NULL, viewActions);
232 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
233 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
234 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
236 m_timelineContextMenu = new QMenu(this);
237 m_timelineContextClipMenu = new QMenu(this);
238 m_timelineContextTransitionMenu = new QMenu(this);
241 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
242 effects = transitions.effectNames();
243 foreach(const QString &name, effects) {
244 action = new QAction(name, this);
245 action->setData(name);
246 transitionsMenu->addAction(action);
248 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
250 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
252 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
253 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
254 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
255 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
256 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
258 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
259 m_timelineContextClipMenu->addMenu(markersMenu);
260 m_timelineContextClipMenu->addMenu(transitionsMenu);
261 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
262 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
263 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
265 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
266 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
268 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
269 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
270 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
271 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
272 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
273 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
275 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
276 slotConnectMonitors();
278 setAutoSaveSettings();
280 if (KdenliveSettings::openlastproject()) {
283 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
284 if (!staleFiles.isEmpty()) {
285 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) {
286 recoverFiles(staleFiles);
294 activateShuttleDevice();
295 projectListDock->raise();
298 void MainWindow::queryQuit() {
299 kDebug() << "----- SAVING CONFUIG";
300 if (queryClose()) kapp->quit();
304 bool MainWindow::queryClose() {
306 if (m_activeDocument && m_activeDocument->isModified()) {
307 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
308 case KMessageBox::Yes :
309 // save document here. If saving fails, return false;
312 case KMessageBox::No :
321 void MainWindow::saveProperties(KConfig*) {
322 // save properties here,used by session management
327 void MainWindow::readProperties(KConfig *config) {
328 // read properties here,used by session management
329 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
330 openFile(KUrl(Lastproject));
333 void MainWindow::slotReloadEffects() {
334 initEffects::parseCustomEffectsFile();
335 m_customEffectsMenu->clear();
336 const QStringList effects = customEffects.effectNames();
338 foreach(const QString &name, effects) {
339 action = new QAction(name, this);
340 action->setData(name);
341 m_customEffectsMenu->addAction(action);
343 m_effectList->reloadEffectList();
346 void MainWindow::activateShuttleDevice() {
347 if (m_jogProcess) delete m_jogProcess;
349 if (KdenliveSettings::enableshuttle() == false) return;
350 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
351 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
352 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
353 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
354 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
355 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
356 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
359 void MainWindow::slotShuttleButton(int code) {
362 slotShuttleAction(KdenliveSettings::shuttle1());
365 slotShuttleAction(KdenliveSettings::shuttle2());
368 slotShuttleAction(KdenliveSettings::shuttle3());
371 slotShuttleAction(KdenliveSettings::shuttle4());
374 slotShuttleAction(KdenliveSettings::shuttle5());
379 void MainWindow::slotShuttleAction(int code) {
384 m_monitorManager->slotPlay();
387 m_monitorManager->slotPlay();
392 void MainWindow::slotFullScreen() {
393 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
396 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
397 if (!m_activeDocument) return;
398 if (effect.isNull()) {
399 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
402 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
403 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
406 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
407 if (clipMonitor) clipMonitorDock->raise();
408 else projectMonitorDock->raise();
411 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
412 if (!m_activeDocument) return;
413 m_activeDocument->setProducerDuration(id, duration);
416 void MainWindow::slotConnectMonitors() {
418 m_projectList->setRenderer(m_clipMonitor->render);
419 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
420 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
421 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
422 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
423 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 > &)));
425 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
427 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
429 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
430 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
432 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
433 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
436 void MainWindow::slotAdjustClipMonitor() {
437 clipMonitorDock->updateGeometry();
438 clipMonitorDock->adjustSize();
439 m_clipMonitor->resetSize();
442 void MainWindow::slotAdjustProjectMonitor() {
443 projectMonitorDock->updateGeometry();
444 projectMonitorDock->adjustSize();
445 m_projectMonitor->resetSize();
448 void MainWindow::setupActions() {
450 m_timecodeFormat = new KComboBox(this);
451 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
452 m_timecodeFormat->addItem(i18n("Frames"));
454 statusProgressBar = new QProgressBar(this);
455 statusProgressBar->setMinimum(0);
456 statusProgressBar->setMaximum(100);
457 statusProgressBar->setMaximumWidth(150);
458 statusProgressBar->setVisible(false);
460 QWidget *w = new QWidget;
462 QHBoxLayout *layout = new QHBoxLayout;
463 w->setLayout(layout);
464 layout->setContentsMargins(5, 0, 5, 0);
465 QToolBar *toolbar = new QToolBar("statusToolBar", this);
468 m_toolGroup = new QActionGroup(this);
470 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;}";
472 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
473 m_buttonSelectTool->setCheckable(true);
474 m_buttonSelectTool->setChecked(true);
476 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
477 m_buttonRazorTool->setCheckable(true);
478 m_buttonRazorTool->setChecked(false);
480 m_toolGroup->addAction(m_buttonSelectTool);
481 m_toolGroup->addAction(m_buttonRazorTool);
482 m_toolGroup->setExclusive(true);
483 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
485 QWidget * actionWidget;
486 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
487 actionWidget->setMaximumWidth(24);
488 actionWidget->setMinimumHeight(17);
490 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
491 actionWidget->setMaximumWidth(24);
492 actionWidget->setMinimumHeight(17);
494 toolbar->setStyleSheet(style1);
495 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
497 toolbar->addSeparator();
498 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
499 m_buttonFitZoom->setCheckable(false);
500 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
502 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
503 actionWidget->setMaximumWidth(24);
504 actionWidget->setMinimumHeight(17);
506 m_zoomSlider = new QSlider(Qt::Horizontal, this);
507 m_zoomSlider->setMaximum(13);
508 m_zoomSlider->setPageStep(1);
510 m_zoomSlider->setMaximumWidth(150);
511 m_zoomSlider->setMinimumWidth(100);
513 const int contentHeight = QFontMetrics(w->font()).height() + 8;
514 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
515 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
516 m_zoomSlider->setStyleSheet(style);
518 //m_zoomSlider->setMaximumHeight(contentHeight);
519 //m_zoomSlider->height() + 5;
520 statusBar()->setMinimumHeight(contentHeight);
523 toolbar->addWidget(m_zoomSlider);
525 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
526 m_buttonVideoThumbs->setCheckable(true);
527 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
528 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
530 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
531 m_buttonAudioThumbs->setCheckable(true);
532 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
533 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
535 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
536 m_buttonShowMarkers->setCheckable(true);
537 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
538 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
540 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
541 m_buttonSnap->setCheckable(true);
542 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
543 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
544 layout->addWidget(toolbar);
547 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
548 actionWidget->setMaximumWidth(24);
549 actionWidget->setMinimumHeight(17);
551 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
552 actionWidget->setMaximumWidth(24);
553 actionWidget->setMinimumHeight(17);
555 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
556 actionWidget->setMaximumWidth(24);
557 actionWidget->setMinimumHeight(17);
559 actionWidget = toolbar->widgetForAction(m_buttonSnap);
560 actionWidget->setMaximumWidth(24);
561 actionWidget->setMinimumHeight(17);
563 m_messageLabel = new StatusBarMessageLabel(this);
564 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
566 statusBar()->addWidget(m_messageLabel, 10);
567 statusBar()->addWidget(statusProgressBar, 0);
568 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
569 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
570 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
571 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
572 m_messageLabel->hide();
574 actionCollection()->addAction("select_tool", m_buttonSelectTool);
575 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
577 actionCollection()->addAction("show_video_thumbs", m_buttonVideoThumbs);
578 actionCollection()->addAction("show_audio_thumbs", m_buttonAudioThumbs);
579 actionCollection()->addAction("show_markers", m_buttonShowMarkers);
580 actionCollection()->addAction("snap", m_buttonSnap);
581 actionCollection()->addAction("zoom_fit", m_buttonFitZoom);
583 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
584 actionCollection()->addAction("project_find", m_projectSearch);
585 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
586 m_projectSearch->setShortcut(Qt::Key_Slash);
588 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
589 actionCollection()->addAction("project_find_next", m_projectSearchNext);
590 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
591 m_projectSearchNext->setShortcut(Qt::Key_F3);
592 m_projectSearchNext->setEnabled(false);
594 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
595 actionCollection()->addAction("manage_profiles", profilesAction);
596 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
598 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
599 actionCollection()->addAction("project_settings", projectAction);
600 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
602 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
603 actionCollection()->addAction("project_render", projectRender);
604 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
606 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
607 KShortcut playShortcut;
608 playShortcut.setPrimary(Qt::Key_Space);
609 playShortcut.setAlternate(Qt::Key_K);
610 monitorPlay->setShortcut(playShortcut);
611 actionCollection()->addAction("monitor_play", monitorPlay);
612 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
614 KAction *markIn = actionCollection()->addAction("mark_in");
615 markIn->setText(i18n("Set in point"));
616 markIn->setShortcut(Qt::Key_I);
617 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
619 KAction *markOut = actionCollection()->addAction("mark_out");
620 markOut->setText(i18n("Set in point"));
621 markOut->setShortcut(Qt::Key_O);
622 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
624 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
625 monitorSeekBackward->setShortcut(Qt::Key_J);
626 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
627 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
629 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
630 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
631 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
632 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
634 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
635 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
636 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
637 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
639 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
640 monitorSeekForward->setShortcut(Qt::Key_L);
641 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
642 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
644 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
645 clipStart->setShortcut(Qt::Key_Home);
646 actionCollection()->addAction("seek_clip_start", clipStart);
647 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
649 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
650 clipEnd->setShortcut(Qt::Key_End);
651 actionCollection()->addAction("seek_clip_end", clipEnd);
652 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
654 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
655 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
656 actionCollection()->addAction("seek_start", projectStart);
657 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
659 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
660 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
661 actionCollection()->addAction("seek_end", projectEnd);
662 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
664 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
665 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
666 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
667 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
669 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
670 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
671 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
672 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
674 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
675 deleteTimelineClip->setShortcut(Qt::Key_Delete);
676 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
677 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
679 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
680 actionCollection()->addAction("change_clip_speed", editTimelineClipSpeed);
681 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
683 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
684 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
685 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
686 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
688 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
689 actionCollection()->addAction("add_clip_marker", addClipMarker);
690 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
692 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
693 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
694 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
696 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
697 actionCollection()->addAction("delete_all_clip_markers", deleteAllClipMarkers);
698 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
700 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
701 actionCollection()->addAction("edit_clip_marker", editClipMarker);
702 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
704 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
705 actionCollection()->addAction("add_guide", addGuide);
706 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
708 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
709 actionCollection()->addAction("delete_guide", delGuide);
710 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
712 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
713 actionCollection()->addAction("edit_guide", editGuide);
714 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
716 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
717 actionCollection()->addAction("delete_all_guides", delAllGuides);
718 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
720 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
721 actionCollection()->addAction("paste_effects", pasteEffects);
722 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
724 KStandardAction::quit(this, SLOT(queryQuit()),
727 KStandardAction::open(this, SLOT(openFile()),
730 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
733 KStandardAction::saveAs(this, SLOT(saveFileAs()),
736 KStandardAction::openNew(this, SLOT(newFile()),
739 KStandardAction::preferences(this, SLOT(slotPreferences()),
742 KStandardAction::copy(this, SLOT(slotCopy()),
745 KStandardAction::paste(this, SLOT(slotPaste()),
748 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
750 undo->setEnabled(false);
751 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
753 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
755 redo->setEnabled(false);
756 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
758 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
760 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
761 this, SLOT(slotDisplayActionMessage(QAction*)));
762 //connect(actionCollection(), SIGNAL( clearStatusText() ),
763 //statusBar(), SLOT( clear() ) );
766 void MainWindow::slotDisplayActionMessage(QAction *a) {
767 statusBar()->showMessage(a->data().toString(), 3000);
770 void MainWindow::saveOptions() {
771 KdenliveSettings::self()->writeConfig();
772 KSharedConfigPtr config = KGlobal::config();
773 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
777 void MainWindow::readOptions() {
778 KSharedConfigPtr config = KGlobal::config();
779 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
780 KConfigGroup initialGroup(config, "version");
781 if (!initialGroup.exists()) {
782 // this is our first run, show Wizard
783 Wizard *w = new Wizard(this);
784 if (w->exec() == QDialog::Accepted && w->isOk()) {
786 initialGroup.writeEntry("version", "0.7");
790 // TODO: find a better way to exit application faster
791 QTimer::singleShot(1000, this, SLOT(queryQuit()));
796 void MainWindow::newFile() {
799 QPoint projectTracks(3, 2);
800 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
802 ProjectSettings *w = new ProjectSettings;
803 if (w->exec() != QDialog::Accepted) return;
804 profileName = w->selectedProfile();
805 projectFolder = w->selectedFolder();
806 projectTracks = w->tracks();
809 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
810 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
811 TrackView *trackView = new TrackView(doc, this);
812 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
813 if (m_timelineArea->count() == 1) {
814 connectDocumentInfo(doc);
815 connectDocument(trackView, doc);
816 } else m_timelineArea->setTabBarHidden(false);
819 void MainWindow::activateDocument() {
820 if (m_timelineArea->currentWidget() == NULL) return;
821 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
822 KdenliveDoc *currentDoc = currentTab->document();
823 connectDocumentInfo(currentDoc);
824 connectDocument(currentTab, currentDoc);
827 void MainWindow::closeCurrentDocument() {
828 QWidget *w = m_timelineArea->currentWidget();
829 // closing current document
830 int ix = m_timelineArea->currentIndex() + 1;
831 if (ix == m_timelineArea->count()) ix = 0;
832 m_timelineArea->setCurrentIndex(ix);
833 TrackView *tabToClose = (TrackView *) w;
834 KdenliveDoc *docToClose = tabToClose->document();
835 if (docToClose && docToClose->isModified()) {
836 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
837 case KMessageBox::Yes :
838 // save document here. If saving fails, return false;
841 case KMessageBox::Cancel :
847 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
848 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
851 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
854 void MainWindow::saveFileAs(const QString &outputFileName) {
855 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
856 m_activeDocument->setUrl(KUrl(outputFileName));
857 if (m_activeDocument->m_autosave == NULL) {
858 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
859 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
860 setCaption(m_activeDocument->description());
861 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
862 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
863 m_activeDocument->setModified(false);
864 m_fileOpenRecent->addUrl(KUrl(outputFileName));
867 void MainWindow::saveFileAs() {
868 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
869 if (QFile::exists(outputFile)) {
870 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
872 saveFileAs(outputFile);
875 void MainWindow::saveFile() {
876 if (!m_activeDocument) return;
877 if (m_activeDocument->url().isEmpty()) {
880 saveFileAs(m_activeDocument->url().path());
881 m_activeDocument->m_autosave->resize(0);
885 void MainWindow::openFile() {
886 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
887 if (url.isEmpty()) return;
888 m_fileOpenRecent->addUrl(url);
892 void MainWindow::openLastFile() {
893 KSharedConfigPtr config = KGlobal::config();
894 KUrl::List urls = m_fileOpenRecent->urls();
895 if (urls.isEmpty()) newFile();
896 else openFile(urls.last());
899 void MainWindow::openFile(const KUrl &url) {
900 // Check for backup file
901 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
902 if (!staleFiles.isEmpty()) {
903 if (KMessageBox::questionYesNo(this,
904 i18n("Auto-saved files exist. Do you want to recover them now?"),
905 i18n("File Recovery"),
906 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
907 recoverFiles(staleFiles);
910 // remove the stale files
911 foreach(KAutoSaveFile *stale, staleFiles) {
912 stale->open(QIODevice::ReadWrite);
917 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
918 doOpenFile(url, NULL);
921 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
923 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
925 stale = new KAutoSaveFile(url, doc);
926 doc->m_autosave = stale;
928 doc->m_autosave = stale;
929 doc->setUrl(stale->managedFile());
930 doc->setModified(true);
931 stale->setParent(doc);
933 connectDocumentInfo(doc);
934 TrackView *trackView = new TrackView(doc, this);
935 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
936 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
937 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
938 slotGotProgressInfo(QString(), -1);
939 m_clipMonitor->refreshMonitor(true);
942 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
943 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
944 foreach(KAutoSaveFile *stale, staleFiles) {
945 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
946 // show an error message; we could not steal the lockfile
947 // maybe another application got to the file before us?
951 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
952 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
953 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
954 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
959 void MainWindow::parseProfiles() {
960 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
962 //KdenliveSettings::setDefaulttmpfolder();
963 if (KdenliveSettings::mltpath().isEmpty()) {
964 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
966 if (KdenliveSettings::rendererpath().isEmpty()) {
967 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
968 if (!QFile::exists(inigoPath))
969 inigoPath = KStandardDirs::findExe("inigo");
970 else KdenliveSettings::setRendererpath(inigoPath);
972 QStringList profilesFilter;
973 profilesFilter << "*";
974 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
976 if (profilesList.isEmpty()) {
977 // Cannot find MLT path, try finding inigo
978 QString profilePath = KdenliveSettings::rendererpath();
979 if (!profilePath.isEmpty()) {
980 profilePath = profilePath.section('/', 0, -3);
981 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
982 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
985 if (profilesList.isEmpty()) {
986 // Cannot find the MLT profiles, ask for location
987 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
988 getUrl->fileDialog()->setMode(KFile::Directory);
990 KUrl mltPath = getUrl->selectedUrl();
992 if (mltPath.isEmpty()) kapp->quit();
993 KdenliveSettings::setMltpath(mltPath.path());
994 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
998 if (KdenliveSettings::rendererpath().isEmpty()) {
999 // Cannot find the MLT inigo renderer, ask for location
1000 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1002 KUrl rendererPath = getUrl->selectedUrl();
1004 if (rendererPath.isEmpty()) kapp->quit();
1005 KdenliveSettings::setRendererpath(rendererPath.path());
1008 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1010 // Parse MLT profiles to build a list of available video formats
1011 if (profilesList.isEmpty()) parseProfiles();
1015 void MainWindow::slotEditProfiles() {
1016 ProfilesDialog *w = new ProfilesDialog;
1021 void MainWindow::slotEditProjectSettings() {
1022 ProjectSettings *w = new ProjectSettings;
1023 if (w->exec() == QDialog::Accepted) {
1024 QString profile = w->selectedProfile();
1025 m_activeDocument->setProfilePath(profile);
1026 KdenliveSettings::setCurrent_profile(profile);
1027 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1028 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1029 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1030 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1031 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1033 // We need to desactivate & reactivate monitors to get a refresh
1034 m_monitorManager->switchMonitors();
1039 void MainWindow::slotRenderProject() {
1040 if (!m_renderWidget) {
1041 m_renderWidget = new RenderWidget(this);
1042 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)));
1043 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1045 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1046 if (currentTab) m_renderWidget->setTimeline(currentTab);
1047 m_renderWidget->setDocument(m_activeDocument);*/
1048 m_renderWidget->show();
1051 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) {
1052 if (dest.isEmpty()) return;
1055 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1056 if (currentTab && zoneOnly) {
1057 in = currentTab->inPoint();
1058 out = currentTab->outPoint();
1060 KTemporaryFile temp;
1061 temp.setAutoRemove(false);
1062 temp.setSuffix(".westley");
1064 m_projectMonitor->saveSceneList(temp.fileName());
1067 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1068 else if (guideStart != -1) {
1069 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1071 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1072 QString videoPlayer = "-";
1074 videoPlayer = KdenliveSettings::defaultplayerapp();
1075 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."));
1077 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1078 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1079 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1080 QProcess::startDetached(renderer, args);
1084 void MainWindow::slotUpdateMousePosition(int pos) {
1085 if (m_activeDocument)
1086 switch (m_timecodeFormat->currentIndex()) {
1088 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1091 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1095 void MainWindow::slotUpdateDocumentState(bool modified) {
1096 setCaption(m_activeDocument->description(), modified);
1097 m_saveAction->setEnabled(modified);
1099 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1100 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1102 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1103 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1107 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1108 if (m_activeDocument) {
1109 if (m_activeDocument == doc) return;
1110 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1112 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1115 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1116 //m_projectMonitor->stop();
1117 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1118 if (m_activeDocument) {
1119 if (m_activeDocument == doc) return;
1120 m_activeDocument->backupMltPlaylist();
1121 if (m_activeTimeline) {
1122 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1123 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1124 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1125 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1126 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1127 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1128 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1129 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1130 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1131 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1132 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1133 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1134 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1135 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1136 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1137 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1138 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1139 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1141 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1142 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1143 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1144 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1145 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1146 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1147 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1148 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1149 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1150 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1151 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1152 effectStack->clear();
1154 m_activeDocument->setRenderer(NULL);
1155 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1156 m_clipMonitor->stop();
1158 KdenliveSettings::setCurrent_profile(doc->profilePath());
1159 KdenliveSettings::setProject_fps(doc->fps());
1160 m_monitorManager->resetProfiles(doc->timecode());
1161 m_projectList->setDocument(doc);
1162 transitionConfig->updateProjectFormat(doc->mltProfile());
1163 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1164 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1165 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1166 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1167 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1168 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1169 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1170 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1171 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1172 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1173 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1174 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1176 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1177 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1178 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1181 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1182 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1183 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1184 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1185 m_zoomSlider->setValue(doc->zoom());
1186 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1187 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1188 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1189 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1191 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1194 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1195 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1196 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1197 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1198 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1199 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1200 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1201 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1203 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1204 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1206 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1207 m_activeTimeline = trackView;
1208 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1209 doc->setRenderer(m_projectMonitor->render);
1210 m_commandStack->setActiveStack(doc->commandStack());
1211 KdenliveSettings::setProject_display_ratio(doc->dar());
1212 doc->updateAllProjectClips();
1215 //m_overView->setScene(trackView->projectScene());
1216 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1217 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1219 setCaption(doc->description(), doc->isModified());
1220 m_saveAction->setEnabled(doc->isModified());
1221 m_activeDocument = doc;
1224 void MainWindow::slotGuidesUpdated() {
1225 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1228 void MainWindow::slotPreferences(int page, int option) {
1229 //An instance of your dialog could be already created and could be
1230 // cached, in which case you want to display the cached dialog
1231 // instead of creating another one
1232 if (KConfigDialog::showDialog("settings")) {
1233 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1237 // KConfigDialog didn't find an instance of this dialog, so lets
1239 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1240 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1241 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1243 if (page != -1) dialog->showPage(page, option);
1246 void MainWindow::updateConfiguration() {
1247 //TODO: we should apply settings to all projects, not only the current one
1248 if (m_activeTimeline) {
1249 m_activeTimeline->refresh();
1250 m_activeTimeline->projectView()->checkAutoScroll();
1251 m_activeTimeline->projectView()->checkTrackHeight();
1252 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1254 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1255 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1256 activateShuttleDevice();
1260 void MainWindow::slotSwitchVideoThumbs() {
1261 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1262 if (m_activeTimeline) {
1263 m_activeTimeline->refresh();
1265 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1268 void MainWindow::slotSwitchAudioThumbs() {
1269 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1270 if (m_activeTimeline) {
1271 m_activeTimeline->refresh();
1272 m_activeTimeline->projectView()->checkAutoScroll();
1273 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1275 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1278 void MainWindow::slotSwitchMarkersComments() {
1279 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1280 if (m_activeTimeline) {
1281 m_activeTimeline->refresh();
1283 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1286 void MainWindow::slotSwitchSnap() {
1287 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1288 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1292 void MainWindow::slotDeleteTimelineClip() {
1293 if (m_activeTimeline) {
1294 m_activeTimeline->projectView()->deleteSelectedClips();
1298 void MainWindow::slotChangeClipSpeed() {
1299 if (m_activeTimeline) {
1300 m_activeTimeline->projectView()->changeClipSpeed();
1304 void MainWindow::slotAddClipMarker() {
1305 if (m_activeTimeline) {
1306 m_activeTimeline->projectView()->slotAddClipMarker();
1310 void MainWindow::slotDeleteClipMarker() {
1311 if (m_activeTimeline) {
1312 m_activeTimeline->projectView()->slotDeleteClipMarker();
1316 void MainWindow::slotDeleteAllClipMarkers() {
1317 if (m_activeTimeline) {
1318 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1322 void MainWindow::slotEditClipMarker() {
1323 if (m_activeTimeline) {
1324 m_activeTimeline->projectView()->slotEditClipMarker();
1328 void MainWindow::slotAddGuide() {
1329 if (m_activeTimeline)
1330 m_activeTimeline->projectView()->slotAddGuide();
1333 void MainWindow::slotEditGuide() {
1334 if (m_activeTimeline)
1335 m_activeTimeline->projectView()->slotEditGuide();
1338 void MainWindow::slotDeleteGuide() {
1339 if (m_activeTimeline)
1340 m_activeTimeline->projectView()->slotDeleteGuide();
1343 void MainWindow::slotDeleteAllGuides() {
1344 if (m_activeTimeline)
1345 m_activeTimeline->projectView()->slotDeleteAllGuides();
1348 void MainWindow::slotCutTimelineClip() {
1349 if (m_activeTimeline) {
1350 m_activeTimeline->projectView()->cutSelectedClips();
1354 void MainWindow::slotAddProjectClip(KUrl url) {
1355 if (m_activeDocument)
1356 m_activeDocument->slotAddClipFile(url, QString());
1359 void MainWindow::slotAddTransition(QAction *result) {
1360 if (!result) return;
1361 QDomElement effect = transitions.getEffectByName(result->data().toString());
1362 if (m_activeTimeline) {
1363 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1367 void MainWindow::slotAddVideoEffect(QAction *result) {
1368 if (!result) return;
1369 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1370 slotAddEffect(effect);
1373 void MainWindow::slotAddAudioEffect(QAction *result) {
1374 if (!result) return;
1375 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1376 slotAddEffect(effect);
1379 void MainWindow::slotAddCustomEffect(QAction *result) {
1380 if (!result) return;
1381 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1382 slotAddEffect(effect);
1385 void MainWindow::slotZoomIn() {
1386 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1389 void MainWindow::slotZoomOut() {
1390 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1393 void MainWindow::slotFitZoom() {
1394 if (m_activeTimeline) {
1395 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1399 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1400 statusProgressBar->setValue(progress);
1401 if (progress >= 0) {
1402 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1403 statusProgressBar->setVisible(true);
1405 m_messageLabel->setMessage(QString(), DefaultMessage);
1406 statusProgressBar->setVisible(false);
1410 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1411 if (clip->clipType() == TEXT) {
1412 QString path = clip->getProperty("xml");
1413 TitleWidget *dia_ui = new TitleWidget(KUrl()/*path + ".kdenlivetitle")*/, path, m_projectMonitor->render, this);
1415 doc.setContent(clip->getProperty("xmldata"));
1416 dia_ui->setXml(doc);
1417 if (dia_ui->exec() == QDialog::Accepted) {
1418 kDebug() << "// UPDATUING CLIP TITLE: " << path;
1419 QPixmap pix = dia_ui->renderedPixmap();
1420 pix.save(path + ".png");
1421 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1422 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1423 QMap <QString, QString> newprops;
1424 newprops.insert("xmldata", dia_ui->xml().toString());
1425 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1426 m_activeDocument->commandStack()->push(command);
1427 //setModified(true);
1431 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1434 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1435 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1436 if (dia.exec() == QDialog::Accepted) {
1437 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1438 m_activeDocument->commandStack()->push(command);
1440 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1441 if (dia.needsTimelineRefresh()) {
1442 // update clip occurences in timeline
1443 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1448 void MainWindow::customEvent(QEvent* e) {
1449 if (e->type() == QEvent::User) {
1450 // The timeline playing position changed...
1451 kDebug() << "RECIEVED JOG EVEMNT!!!";
1454 void MainWindow::slotActivateEffectStackView() {
1455 effectStack->raiseWindow(effectStackDock);
1458 void MainWindow::slotActivateTransitionView() {
1459 transitionConfig->raiseWindow(transitionConfigDock);
1462 void MainWindow::slotSnapRewind() {
1463 if (m_projectMonitor->isActive()) {
1464 if (m_activeTimeline)
1465 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1469 void MainWindow::slotSnapForward() {
1470 if (m_projectMonitor->isActive()) {
1471 if (m_activeTimeline)
1472 m_activeTimeline->projectView()->slotSeekToNextSnap();
1476 void MainWindow::slotClipStart() {
1477 if (m_projectMonitor->isActive()) {
1478 if (m_activeTimeline)
1479 m_activeTimeline->projectView()->clipStart();
1483 void MainWindow::slotClipEnd() {
1484 if (m_projectMonitor->isActive()) {
1485 if (m_activeTimeline)
1486 m_activeTimeline->projectView()->clipEnd();
1490 void MainWindow::slotChangeTool(QAction * action) {
1491 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1492 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1495 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1496 if (m_activeDocument && m_activeTimeline) {
1497 //m_activeDocument->setTool(tool);
1498 m_activeTimeline->projectView()->setTool(tool);
1502 void MainWindow::slotCopy() {
1503 if (!m_activeDocument || !m_activeTimeline) return;
1504 m_activeTimeline->projectView()->copyClip();
1507 void MainWindow::slotPaste() {
1508 if (!m_activeDocument || !m_activeTimeline) return;
1509 m_activeTimeline->projectView()->pasteClip();
1512 void MainWindow::slotPasteEffects() {
1513 if (!m_activeDocument || !m_activeTimeline) return;
1514 m_activeTimeline->projectView()->pasteClipEffects();
1517 void MainWindow::slotFind() {
1518 if (!m_activeDocument || !m_activeTimeline) return;
1519 m_projectSearch->setEnabled(false);
1520 m_findActivated = true;
1521 m_findString = QString();
1522 m_activeTimeline->projectView()->initSearchStrings();
1523 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1524 m_findTimer.start(5000);
1525 qApp->installEventFilter(this);
1528 void MainWindow::slotFindNext() {
1529 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1530 statusBar()->showMessage(i18n("Found : %1", m_findString));
1532 statusBar()->showMessage(i18n("Reached end of project"));
1534 m_findTimer.start(4000);
1537 void MainWindow::findAhead() {
1538 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1539 m_projectSearchNext->setEnabled(true);
1540 statusBar()->showMessage(i18n("Found : %1", m_findString));
1542 m_projectSearchNext->setEnabled(false);
1543 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1547 void MainWindow::findTimeout() {
1548 m_projectSearchNext->setEnabled(false);
1549 m_findActivated = false;
1550 m_findString = QString();
1551 statusBar()->showMessage(i18n("Find stopped"), 3000);
1552 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1553 m_projectSearch->setEnabled(true);
1554 removeEventFilter(this);
1557 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1558 if (m_findActivated) {
1559 if (ke->key() == Qt::Key_Backspace) {
1560 m_findString = m_findString.left(m_findString.length() - 1);
1562 if (!m_findString.isEmpty()) {
1568 m_findTimer.start(4000);
1571 } else if (ke->key() == Qt::Key_Escape) {
1575 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1576 m_findString += ke->text();
1580 m_findTimer.start(4000);
1584 } else KXmlGuiWindow::keyPressEvent(ke);
1587 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1588 if (m_findActivated) {
1589 if (event->type() == QEvent::ShortcutOverride) {
1590 QKeyEvent* ke = (QKeyEvent*) event;
1591 if (ke->text().trimmed().isEmpty()) return false;
1594 } else return false;
1596 // pass the event on to the parent class
1597 return QMainWindow::eventFilter(obj, event);
1601 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1602 KDialog *dialog = new KDialog(this);
1603 dialog->setCaption("Save clip zone");
1604 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1606 QWidget *widget = new QWidget(dialog);
1607 dialog->setMainWidget(widget);
1609 QVBoxLayout *vbox = new QVBoxLayout(widget);
1610 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1611 QString path = m_activeDocument->projectFolder().path();
1613 path.append("untitled.westley");
1614 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1615 url->setFilter("video/mlt-playlist");
1616 QLabel *label2 = new QLabel(i18n("Description:"), this);
1617 KLineEdit *edit = new KLineEdit(this);
1618 vbox->addWidget(label1);
1619 vbox->addWidget(url);
1620 vbox->addWidget(label2);
1621 vbox->addWidget(edit);
1622 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1626 void MainWindow::slotSetInPoint() {
1627 if (m_clipMonitor->isActive()) {
1628 m_clipMonitor->slotSetZoneStart();
1629 } else m_activeTimeline->projectView()->setInPoint();
1632 void MainWindow::slotSetOutPoint() {
1633 if (m_clipMonitor->isActive()) {
1634 m_clipMonitor->slotSetZoneEnd();
1635 } else m_activeTimeline->projectView()->setOutPoint();
1638 #include "mainwindow.moc"