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>
28 #include <KApplication>
32 #include <KActionCollection>
33 #include <KStandardAction>
34 #include <KFileDialog>
35 #include <KMessageBox>
37 #include <KIO/NetAccess>
40 #include <KConfigDialog>
41 #include <KXMLGUIFactory>
43 #include <kstandarddirs.h>
44 #include <KUrlRequesterDialog>
45 #include <KTemporaryFile>
46 #include <KActionMenu>
49 #include <ktogglefullscreenaction.h>
51 #include <mlt++/Mlt.h>
53 #include "mainwindow.h"
54 #include "kdenlivesettings.h"
55 #include "kdenlivesettingsdialog.h"
56 #include "initeffects.h"
57 #include "profilesdialog.h"
58 #include "projectsettings.h"
60 #include "renderjob.h"
61 #include "clipmanager.h"
62 #include "projectlist.h"
64 #include "recmonitor.h"
65 #include "monitormanager.h"
66 #include "kdenlivedoc.h"
67 #include "trackview.h"
68 #include "customtrackview.h"
69 #include "effectslistview.h"
70 #include "effectstackview.h"
71 #include "transitionsettings.h"
72 #include "renderwidget.h"
74 #include "jogshuttle.h"
75 #include "clipproperties.h"
77 #define ID_STATUS_MSG 1
78 #define ID_EDITMODE_MSG 2
79 #define ID_TIMELINE_MSG 3
80 #define ID_TIMELINE_BUTTONS 5
81 #define ID_TIMELINE_POS 6
82 #define ID_TIMELINE_FORMAT 7
84 EffectsList MainWindow::videoEffects;
85 EffectsList MainWindow::audioEffects;
86 EffectsList MainWindow::customEffects;
87 EffectsList MainWindow::transitions;
89 MainWindow::MainWindow(QWidget *parent)
90 : KXmlGuiWindow(parent),
91 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL) {
92 setlocale(LC_NUMERIC, "POSIX");
94 setFont(KGlobalSettings::toolBarFont());
95 m_commandStack = new QUndoGroup;
96 m_timelineArea = new KTabWidget(this);
97 m_timelineArea->setTabReorderingEnabled(true);
98 m_timelineArea->setTabBarHidden(true);
100 QToolButton *closeTabButton = new QToolButton;
101 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(slotRemoveTab()));
102 closeTabButton->setIcon(KIcon("tab-close"));
103 closeTabButton->adjustSize();
104 closeTabButton->setToolTip(i18n("Close the current tab"));
105 m_timelineArea->setCornerWidget(closeTabButton);
106 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
108 initEffects::parseEffectFiles();
109 m_monitorManager = new MonitorManager();
111 projectListDock = new QDockWidget(i18n("Project Tree"), this);
112 projectListDock->setObjectName("project_tree");
113 m_projectList = new ProjectList(this);
114 projectListDock->setWidget(m_projectList);
115 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
117 effectListDock = new QDockWidget(i18n("Effect List"), this);
118 effectListDock->setObjectName("effect_list");
119 m_effectList = new EffectsListView();
121 //m_effectList = new KListWidget(this);
122 effectListDock->setWidget(m_effectList);
123 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
125 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
126 effectStackDock->setObjectName("effect_stack");
127 effectStack = new EffectStackView(this);
128 effectStackDock->setWidget(effectStack);
129 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
131 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
132 transitionConfigDock->setObjectName("transition");
133 transitionConfig = new TransitionSettings(this);
134 transitionConfigDock->setWidget(transitionConfig);
135 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
138 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
139 clipMonitorDock->setObjectName("clip_monitor");
140 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
141 clipMonitorDock->setWidget(m_clipMonitor);
142 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
143 //m_clipMonitor->stop();
145 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
146 projectMonitorDock->setObjectName("project_monitor");
147 m_projectMonitor = new Monitor("project", m_monitorManager, this);
148 projectMonitorDock->setWidget(m_projectMonitor);
149 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
151 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
152 recMonitorDock->setObjectName("record_monitor");
153 m_recMonitor = new RecMonitor("record", this);
154 recMonitorDock->setWidget(m_recMonitor);
155 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
157 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
159 undoViewDock = new QDockWidget(i18n("Undo History"), this);
160 undoViewDock->setObjectName("undo_history");
161 m_undoView = new QUndoView(this);
162 m_undoView->setCleanIcon(KIcon("edit-clear"));
163 m_undoView->setEmptyLabel(i18n("Clean"));
164 undoViewDock->setWidget(m_undoView);
165 m_undoView->setGroup(m_commandStack);
166 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
168 overviewDock = new QDockWidget(i18n("Project Overview"), this);
169 overviewDock->setObjectName("project_overview");
170 //m_overView = new CustomTrackView(NULL, NULL, this);
171 //overviewDock->setWidget(m_overView);
172 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
175 //tabifyDockWidget(projectListDock, effectListDock);
176 tabifyDockWidget(projectListDock, effectStackDock);
177 tabifyDockWidget(projectListDock, transitionConfigDock);
178 //tabifyDockWidget(projectListDock, undoViewDock);
179 projectListDock->raise();
181 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
182 tabifyDockWidget(clipMonitorDock, recMonitorDock);
183 setCentralWidget(m_timelineArea);
185 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
186 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
188 // build effects menus
190 QMenu *videoEffectsMenu = (QMenu*)(factory()->container("video_effects_menu", this));
191 QStringList effects = videoEffects.effectNames();
192 foreach(const QString &name, effects) {
193 action = new QAction(name, this);
194 action->setData(name);
195 videoEffectsMenu->addAction(action);
197 QMenu *audioEffectsMenu = (QMenu*)(factory()->container("audio_effects_menu", this));
198 effects = audioEffects.effectNames();
199 foreach(const QString &name, effects) {
200 action = new QAction(name, this);
201 action->setData(name);
202 audioEffectsMenu->addAction(action);
204 QMenu *customEffectsMenu = (QMenu*)(factory()->container("custom_effects_menu", this));
205 effects = customEffects.effectNames();
206 foreach(const QString &name, effects) {
207 action = new QAction(name, this);
208 action->setData(name);
209 customEffectsMenu->addAction(action);
212 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
213 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
214 connect(customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
216 m_timelineContextMenu = new QMenu(this);
217 m_timelineContextClipMenu = new QMenu(this);
218 m_timelineContextTransitionMenu = new QMenu(this);
221 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
222 effects = transitions.effectNames();
223 foreach(const QString &name, effects) {
224 action = new QAction(name, this);
225 action->setData(name);
226 transitionsMenu->addAction(action);
228 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
230 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
231 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
233 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
234 m_timelineContextClipMenu->addMenu(markersMenu);
235 m_timelineContextClipMenu->addMenu(transitionsMenu);
236 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
237 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
238 m_timelineContextClipMenu->addMenu(customEffectsMenu);
240 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
242 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
243 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
244 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
245 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
246 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
247 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
248 slotConnectMonitors();
250 setAutoSaveSettings();
253 activateShuttleDevice();
256 void MainWindow::queryQuit() {
257 kDebug() << "----- SAVING CONFUIG";
258 if (queryClose()) kapp->quit();
262 bool MainWindow::queryClose() {
264 if (m_activeDocument && m_activeDocument->isModified()) {
265 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
266 case KMessageBox::Yes :
267 // save document here. If saving fails, return false;
269 case KMessageBox::No :
278 void MainWindow::activateShuttleDevice() {
279 if (m_jogProcess) delete m_jogProcess;
281 if (KdenliveSettings::enableshuttle() == false) return;
282 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
283 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
284 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
285 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
286 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
287 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
288 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
291 void MainWindow::slotShuttleButton(int code) {
294 slotShuttleAction(KdenliveSettings::shuttle1());
297 slotShuttleAction(KdenliveSettings::shuttle2());
300 slotShuttleAction(KdenliveSettings::shuttle3());
303 slotShuttleAction(KdenliveSettings::shuttle4());
306 slotShuttleAction(KdenliveSettings::shuttle5());
311 void MainWindow::slotShuttleAction(int code) {
316 m_monitorManager->slotPlay();
319 m_monitorManager->slotPlay();
324 void MainWindow::slotFullScreen() {
325 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
328 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
329 if (!m_activeDocument) return;
330 if (effect.isNull()) {
331 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
334 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
335 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
338 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
339 if (clipMonitor) clipMonitorDock->raise();
340 else projectMonitorDock->raise();
343 void MainWindow::slotSetClipDuration(int id, int duration) {
344 if (!m_activeDocument) return;
345 m_activeDocument->setProducerDuration(id, duration);
348 void MainWindow::slotConnectMonitors() {
350 m_projectList->setRenderer(m_clipMonitor->render);
351 connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
352 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
353 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
354 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
355 connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
358 void MainWindow::setupActions() {
360 m_timecodeFormat = new KComboBox(this);
361 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
362 m_timecodeFormat->addItem(i18n("Frames"));
364 statusProgressBar = new QProgressBar(this);
365 statusProgressBar->setMinimum(0);
366 statusProgressBar->setMaximum(100);
367 statusProgressBar->setMaximumWidth(150);
368 statusProgressBar->setVisible(false);
370 QWidget *w = new QWidget;
372 QHBoxLayout *layout = new QHBoxLayout;
373 w->setLayout(layout);
374 layout->setContentsMargins(5, 0, 5, 0);
375 QToolBar *toolbar = new QToolBar("statusToolBar", this);
378 m_toolGroup = new QActionGroup(this);
380 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;}";
382 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
383 m_buttonSelectTool->setCheckable(true);
384 m_buttonSelectTool->setChecked(true);
386 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
387 m_buttonRazorTool->setCheckable(true);
388 m_buttonRazorTool->setChecked(false);
390 m_toolGroup->addAction(m_buttonSelectTool);
391 m_toolGroup->addAction(m_buttonRazorTool);
392 m_toolGroup->setExclusive(true);
393 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
395 QWidget * actionWidget;
396 actionWidget = toolbar->widgetForAction( m_buttonSelectTool );
397 actionWidget->setMaximumWidth(24);
398 actionWidget->setMinimumHeight(17);
400 actionWidget = toolbar->widgetForAction( m_buttonRazorTool );
401 actionWidget->setMaximumWidth(24);
402 actionWidget->setMinimumHeight(17);
404 toolbar->setStyleSheet(style1);
405 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
407 toolbar->addSeparator();
408 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
409 m_buttonFitZoom->setCheckable(false);
410 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
412 actionWidget = toolbar->widgetForAction( m_buttonFitZoom );
413 actionWidget->setMaximumWidth(24);
414 actionWidget->setMinimumHeight(17);
416 m_zoomSlider = new QSlider(Qt::Horizontal, this);
417 m_zoomSlider->setMaximum(13);
419 m_zoomSlider->setMaximumWidth(150);
420 m_zoomSlider->setMinimumWidth(100);
422 const int contentHeight = QFontMetrics(w->font()).height() + 8;
423 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
424 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
425 m_zoomSlider->setStyleSheet(style);
427 //m_zoomSlider->setMaximumHeight(contentHeight);
428 //m_zoomSlider->height() + 5;
429 statusBar()->setMinimumHeight(contentHeight);
432 toolbar->addWidget(m_zoomSlider);
434 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
435 m_buttonVideoThumbs->setCheckable(true);
436 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
437 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
439 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
440 m_buttonAudioThumbs->setCheckable(true);
441 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
442 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
444 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
445 m_buttonShowMarkers->setCheckable(true);
446 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
447 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
449 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
450 m_buttonSnap->setCheckable(true);
451 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
452 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
453 layout->addWidget(toolbar);
456 actionWidget = toolbar->widgetForAction( m_buttonVideoThumbs );
457 actionWidget->setMaximumWidth(24);
458 actionWidget->setMinimumHeight(17);
460 actionWidget = toolbar->widgetForAction( m_buttonAudioThumbs );
461 actionWidget->setMaximumWidth(24);
462 actionWidget->setMinimumHeight(17);
464 actionWidget = toolbar->widgetForAction( m_buttonShowMarkers );
465 actionWidget->setMaximumWidth(24);
466 actionWidget->setMinimumHeight(17);
468 actionWidget = toolbar->widgetForAction( m_buttonSnap );
469 actionWidget->setMaximumWidth(24);
470 actionWidget->setMinimumHeight(17);
472 m_messageLabel = new StatusBarMessageLabel(this);
473 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
475 statusBar()->addWidget(m_messageLabel, 10);
476 statusBar()->addWidget(statusProgressBar, 0);
477 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
478 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
479 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
480 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
481 m_messageLabel->hide();
483 actionCollection()->addAction("select_tool", m_buttonSelectTool);
484 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
486 actionCollection()->addAction("show_video_thumbs", m_buttonVideoThumbs);
487 actionCollection()->addAction("show_audio_thumbs", m_buttonAudioThumbs);
488 actionCollection()->addAction("show_markers", m_buttonShowMarkers);
489 actionCollection()->addAction("snap", m_buttonSnap);
490 actionCollection()->addAction("zoom_fit", m_buttonFitZoom);
493 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
494 actionCollection()->addAction("manage_profiles", profilesAction);
495 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
497 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
498 actionCollection()->addAction("project_settings", projectAction);
499 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
501 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
502 actionCollection()->addAction("project_render", projectRender);
503 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
505 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
506 monitorPlay->setShortcut(Qt::Key_Space);
507 actionCollection()->addAction("monitor_play", monitorPlay);
508 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
510 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
511 monitorSeekBackward->setShortcut(Qt::Key_J);
512 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
513 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
515 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
516 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
517 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
518 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
520 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
521 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
522 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
523 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
525 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
526 monitorSeekForward->setShortcut(Qt::Key_L);
527 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
528 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
530 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
531 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
532 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
533 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
535 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
536 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
537 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
538 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
540 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
541 deleteTimelineClip->setShortcut(Qt::Key_Delete);
542 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
543 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
545 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
546 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
547 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
548 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
550 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
551 actionCollection()->addAction("add_clip_marker", addClipMarker);
552 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
554 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
555 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
556 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
558 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
559 actionCollection()->addAction("edit_clip_marker", editClipMarker);
560 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
562 KStandardAction::quit(this, SLOT(queryQuit()),
565 KStandardAction::open(this, SLOT(openFile()),
568 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
571 KStandardAction::save(this, SLOT(saveFile()),
574 KStandardAction::saveAs(this, SLOT(saveFileAs()),
577 KStandardAction::openNew(this, SLOT(newFile()),
580 KStandardAction::preferences(this, SLOT(slotPreferences()),
583 KStandardAction::undo(this, SLOT(undo()),
586 KStandardAction::redo(this, SLOT(redo()),
589 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
591 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
592 this, SLOT(slotDisplayActionMessage(QAction*)));
593 //connect(actionCollection(), SIGNAL( clearStatusText() ),
594 //statusBar(), SLOT( clear() ) );
599 void MainWindow::undo() {
600 m_commandStack->undo();
603 void MainWindow::redo() {
604 m_commandStack->redo();
607 void MainWindow::slotDisplayActionMessage(QAction *a) {
608 statusBar()->showMessage(a->data().toString(), 3000);
611 void MainWindow::saveOptions() {
612 KdenliveSettings::self()->writeConfig();
613 KSharedConfigPtr config = KGlobal::config();
614 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
618 void MainWindow::readOptions() {
619 KSharedConfigPtr config = KGlobal::config();
620 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
623 void MainWindow::newFile() {
626 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
628 ProjectSettings *w = new ProjectSettings;
629 if (w->exec() != QDialog::Accepted) return;
630 profileName = w->selectedProfile();
631 projectFolder = w->selectedFolder();
634 MltVideoProfile prof;
635 if (!profileName.isEmpty()) prof = ProfilesDialog::getVideoProfile(profileName);
636 else prof = ProfilesDialog::getVideoProfile("dv_pal");
637 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
638 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack, this);
639 TrackView *trackView = new TrackView(doc, this);
640 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
641 if (m_timelineArea->count() == 1) {
642 connectDocumentInfo(doc);
643 connectDocument(trackView, doc);
644 } else m_timelineArea->setTabBarHidden(false);
647 void MainWindow::activateDocument() {
648 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
649 KdenliveDoc *currentDoc = currentTab->document();
650 connectDocumentInfo(currentDoc);
651 connectDocument(currentTab, currentDoc);
654 void MainWindow::slotRemoveTab() {
655 QWidget *w = m_timelineArea->currentWidget();
656 // closing current document
657 int ix = m_timelineArea->currentIndex() + 1;
658 if (ix == m_timelineArea->count()) ix = 0;
659 m_timelineArea->setCurrentIndex(ix);
660 TrackView *tabToClose = (TrackView *) w;
661 KdenliveDoc *docToClose = tabToClose->document();
662 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
663 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
668 void MainWindow::saveFileAs(const QString &outputFileName) {
669 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml(m_activeTimeline->projectView()->xmlInfo()));
670 m_activeDocument->setUrl(KUrl(outputFileName));
671 setCaption(m_activeDocument->description());
672 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
673 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
674 m_activeDocument->setModified(false);
677 void MainWindow::saveFileAs() {
678 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
679 if (QFile::exists(outputFile)) {
680 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
682 saveFileAs(outputFile);
685 void MainWindow::saveFile() {
686 if (!m_activeDocument) return;
687 if (m_activeDocument->url().isEmpty()) {
690 saveFileAs(m_activeDocument->url().path());
694 void MainWindow::openFile() { //changed
695 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
696 if (url.isEmpty()) return;
697 m_fileOpenRecent->addUrl(url);
701 void MainWindow::openFile(const KUrl &url) { //new
702 //TODO: get video profile from url before opening it
703 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
704 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
705 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack, this);
706 connectDocumentInfo(doc);
707 TrackView *trackView = new TrackView(doc, this);
708 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
709 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
710 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
711 slotGotProgressInfo(QString(), -1);
712 //connectDocument(trackView, doc);
716 void MainWindow::parseProfiles() {
717 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
719 //KdenliveSettings::setDefaulttmpfolder();
720 if (KdenliveSettings::mltpath().isEmpty()) {
721 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
723 if (KdenliveSettings::rendererpath().isEmpty()) {
724 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
726 QStringList profilesFilter;
727 profilesFilter << "*";
728 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
730 if (profilesList.isEmpty()) {
731 // Cannot find MLT path, try finding inigo
732 QString profilePath = KdenliveSettings::rendererpath();
733 if (!profilePath.isEmpty()) {
734 profilePath = profilePath.section('/', 0, -3);
735 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
736 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
739 if (profilesList.isEmpty()) {
740 // Cannot find the MLT profiles, ask for location
741 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
742 getUrl->fileDialog()->setMode(KFile::Directory);
744 KUrl mltPath = getUrl->selectedUrl();
746 if (mltPath.isEmpty()) kapp->quit();
747 KdenliveSettings::setMltpath(mltPath.path());
748 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
752 if (KdenliveSettings::rendererpath().isEmpty()) {
753 // Cannot find the MLT inigo renderer, ask for location
754 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
756 KUrl rendererPath = getUrl->selectedUrl();
758 if (rendererPath.isEmpty()) kapp->quit();
759 KdenliveSettings::setRendererpath(rendererPath.path());
762 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
764 // Parse MLT profiles to build a list of available video formats
765 if (profilesList.isEmpty()) parseProfiles();
769 void MainWindow::slotEditProfiles() {
770 ProfilesDialog *w = new ProfilesDialog;
775 void MainWindow::slotEditProjectSettings() {
776 ProjectSettings *w = new ProjectSettings;
777 if (w->exec() == QDialog::Accepted) {
778 QString profile = w->selectedProfile();
779 m_activeDocument->setProfilePath(profile);
780 m_monitorManager->resetProfiles(profile);
781 setCaption(m_activeDocument->description());
782 KdenliveSettings::setCurrent_profile(m_activeDocument->profilePath());
783 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
784 m_monitorManager->setTimecode(m_activeDocument->timecode());
785 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
787 // We need to desactivate & reactivate monitors to get a refresh
788 m_monitorManager->switchMonitors();
793 void MainWindow::slotRenderProject() {
794 if (!m_renderWidget) {
795 m_renderWidget = new RenderWidget(this);
796 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, bool, bool)));
798 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
799 if (currentTab) m_renderWidget->setTimeline(currentTab);
800 m_renderWidget->setDocument(m_activeDocument);*/
801 m_renderWidget->show();
804 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
805 if (dest.isEmpty()) return;
808 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
809 if (currentTab && zoneOnly) {
810 in = currentTab->inPoint();
811 out = currentTab->outPoint();
814 temp.setAutoRemove(false);
815 temp.setSuffix(".westley");
817 m_projectMonitor->saveSceneList(temp.fileName());
820 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
821 QString videoPlayer = "-";
822 if (playAfter) videoPlayer = "kmplayer";
823 args << "inigo" << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
824 QProcess::startDetached("kdenlive_render", args);
828 void MainWindow::slotUpdateMousePosition(int pos) {
829 if (m_activeDocument)
830 switch (m_timecodeFormat->currentIndex()) {
832 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
835 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
839 void MainWindow::slotUpdateDocumentState(bool modified) {
840 setCaption(m_activeDocument->description(), modified);
842 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
843 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
845 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
846 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
850 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
851 if (m_activeDocument) {
852 if (m_activeDocument == doc) return;
853 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
855 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
858 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
859 //m_projectMonitor->stop();
860 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
861 if (m_activeDocument) {
862 if (m_activeDocument == doc) return;
863 m_activeDocument->backupMltPlaylist();
864 if (m_activeTimeline) {
865 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
866 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
867 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
868 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
869 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
870 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
871 disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
872 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
873 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
874 disconnect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
875 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
876 disconnect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
877 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
878 disconnect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
879 disconnect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
881 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
882 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
883 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
884 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
885 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
886 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
887 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
888 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
890 m_activeDocument->setRenderer(NULL);
891 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
892 m_clipMonitor->stop();
894 m_monitorManager->resetProfiles(doc->profilePath());
895 m_projectList->setDocument(doc);
896 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
897 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
898 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
899 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
900 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
901 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
902 connect(doc, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
903 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
904 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
905 connect(doc, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
907 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
908 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
912 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
913 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
914 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
915 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
916 m_zoomSlider->setValue(trackView->currentZoom());
917 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
918 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
919 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
920 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
922 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
925 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
926 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
927 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
928 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
929 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
930 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
931 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
932 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
933 m_activeTimeline = trackView;
934 KdenliveSettings::setCurrent_profile(doc->profilePath());
935 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
936 m_monitorManager->setTimecode(doc->timecode());
937 doc->setRenderer(m_projectMonitor->render);
938 m_commandStack->setActiveStack(doc->commandStack());
939 if (m_commandStack->isClean()) kDebug() << "//////////// UNDO STACK IS CLEAN";
940 else kDebug() << "//////////// UNDO STACK IS NOT CLEAN*******************";
942 //m_overView->setScene(trackView->projectScene());
943 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
944 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
946 setCaption(doc->description());
947 m_activeDocument = doc;
950 void MainWindow::slotPreferences() {
951 //An instance of your dialog could be already created and could be
952 // cached, in which case you want to display the cached dialog
953 // instead of creating another one
954 if (KConfigDialog::showDialog("settings"))
957 // KConfigDialog didn't find an instance of this dialog, so lets
959 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
960 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
964 void MainWindow::updateConfiguration() {
965 //TODO: we should apply settings to all projects, not only the current one
966 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
968 currentTab->refresh();
969 currentTab->projectView()->checkAutoScroll();
970 currentTab->projectView()->checkTrackHeight();
971 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
973 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
974 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
975 activateShuttleDevice();
979 void MainWindow::slotSwitchVideoThumbs() {
980 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
981 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
983 currentTab->refresh();
985 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
988 void MainWindow::slotSwitchAudioThumbs() {
989 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
990 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
992 currentTab->refresh();
993 currentTab->projectView()->checkAutoScroll();
994 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
996 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
999 void MainWindow::slotSwitchMarkersComments() {
1000 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1001 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1003 currentTab->refresh();
1005 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1008 void MainWindow::slotSwitchSnap() {
1009 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1010 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1014 void MainWindow::slotDeleteTimelineClip() {
1015 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1017 currentTab->projectView()->deleteSelectedClips();
1021 void MainWindow::slotAddClipMarker() {
1022 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1024 currentTab->projectView()->slotAddClipMarker();
1028 void MainWindow::slotDeleteClipMarker() {
1029 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1031 currentTab->projectView()->slotDeleteClipMarker();
1035 void MainWindow::slotEditClipMarker() {
1036 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1038 currentTab->projectView()->slotEditClipMarker();
1042 void MainWindow::slotCutTimelineClip() {
1043 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1045 currentTab->projectView()->cutSelectedClips();
1049 void MainWindow::slotAddProjectClip(KUrl url) {
1050 if (m_activeDocument)
1051 m_activeDocument->slotAddClipFile(url, QString());
1054 void MainWindow::slotAddTransition(QAction *result) {
1055 if (!result) return;
1056 QDomElement effect = transitions.getEffectByName(result->data().toString());
1057 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1059 currentTab->projectView()->slotAddTransitionToSelectedClips(effect);
1063 void MainWindow::slotAddVideoEffect(QAction *result) {
1064 if (!result) return;
1065 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1066 slotAddEffect(effect);
1069 void MainWindow::slotAddAudioEffect(QAction *result) {
1070 if (!result) return;
1071 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1072 slotAddEffect(effect);
1075 void MainWindow::slotAddCustomEffect(QAction *result) {
1076 if (!result) return;
1077 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1078 slotAddEffect(effect);
1081 void MainWindow::slotZoomIn() {
1082 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1085 void MainWindow::slotZoomOut() {
1086 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1089 void MainWindow::slotFitZoom() {
1090 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1092 m_zoomSlider->setValue(currentTab->fitZoom());
1096 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1097 statusProgressBar->setValue(progress);
1098 if (progress >= 0) {
1099 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1100 statusProgressBar->setVisible(true);
1102 m_messageLabel->setMessage(QString(), DefaultMessage);
1103 statusProgressBar->setVisible(false);
1107 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1108 if (clip->clipType() == TEXT) {
1109 m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1112 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1113 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1114 connect(&dia, SIGNAL(addMarker(int, GenTime, QString)), currentTab->projectView(), SLOT(slotAddClipMarker(int, GenTime, QString)));
1115 if (dia.exec() == QDialog::Accepted) {
1116 m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1117 if (dia.needsTimelineRefresh()) {
1118 // update clip occurences in timeline
1120 currentTab->projectView()->slotUpdateClip(dia.clipId());
1125 void MainWindow::customEvent(QEvent* e) {
1126 if (e->type() == QEvent::User) {
1127 // The timeline playing position changed...
1128 kDebug() << "RECIEVED JOG EVEMNT!!!";
1131 void MainWindow::slotActivateEffectStackView() {
1132 effectStack->raiseWindow(effectStackDock);
1135 void MainWindow::slotActivateTransitionView() {
1136 transitionConfig->raiseWindow(transitionConfigDock);
1139 void MainWindow::slotSnapRewind() {
1140 if (m_monitorManager->projectMonitorFocused()) {
1141 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1142 currentTab->projectView()->slotSeekToPreviousSnap();
1146 void MainWindow::slotSnapForward() {
1147 if (m_monitorManager->projectMonitorFocused()) {
1148 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1149 currentTab->projectView()->slotSeekToNextSnap();
1153 void MainWindow::slotChangeTool(QAction * action) {
1154 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1155 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1158 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1159 if (m_activeDocument) {
1160 //m_activeDocument->setTool(tool);
1161 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1162 currentTab->projectView()->setTool(tool);
1166 #include "mainwindow.moc"