1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include <QTextStream>
29 #include <KApplication>
33 #include <KActionCollection>
34 #include <KStandardAction>
35 #include <KFileDialog>
36 #include <KMessageBox>
38 #include <KIO/NetAccess>
41 #include <KConfigDialog>
42 #include <KXMLGUIFactory>
44 #include <kstandarddirs.h>
45 #include <KUrlRequesterDialog>
46 #include <KTemporaryFile>
47 #include <KActionMenu>
50 #include <ktogglefullscreenaction.h>
52 #include <mlt++/Mlt.h>
54 #include "mainwindow.h"
55 #include "kdenlivesettings.h"
56 #include "kdenlivesettingsdialog.h"
57 #include "initeffects.h"
58 #include "profilesdialog.h"
59 #include "projectsettings.h"
61 #include "renderjob.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 #define ID_STATUS_MSG 1
79 #define ID_EDITMODE_MSG 2
80 #define ID_TIMELINE_MSG 3
81 #define ID_TIMELINE_BUTTONS 5
82 #define ID_TIMELINE_POS 6
83 #define ID_TIMELINE_FORMAT 7
85 EffectsList MainWindow::videoEffects;
86 EffectsList MainWindow::audioEffects;
87 EffectsList MainWindow::customEffects;
88 EffectsList MainWindow::transitions;
90 MainWindow::MainWindow(QWidget *parent)
91 : KXmlGuiWindow(parent),
92 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false) {
93 setlocale(LC_NUMERIC, "POSIX");
95 setFont(KGlobalSettings::toolBarFont());
96 m_commandStack = new QUndoGroup;
97 m_timelineArea = new KTabWidget(this);
98 m_timelineArea->setTabReorderingEnabled(true);
99 m_timelineArea->setTabBarHidden(true);
101 QToolButton *closeTabButton = new QToolButton;
102 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(slotRemoveTab()));
103 closeTabButton->setIcon(KIcon("tab-close"));
104 closeTabButton->adjustSize();
105 closeTabButton->setToolTip(i18n("Close the current tab"));
106 m_timelineArea->setCornerWidget(closeTabButton);
107 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
109 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
110 m_findTimer.setSingleShot(true);
112 initEffects::parseEffectFiles();
113 m_monitorManager = new MonitorManager();
115 projectListDock = new QDockWidget(i18n("Project Tree"), this);
116 projectListDock->setObjectName("project_tree");
117 m_projectList = new ProjectList(this);
118 projectListDock->setWidget(m_projectList);
119 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
121 effectListDock = new QDockWidget(i18n("Effect List"), this);
122 effectListDock->setObjectName("effect_list");
123 m_effectList = new EffectsListView();
125 //m_effectList = new KListWidget(this);
126 effectListDock->setWidget(m_effectList);
127 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
129 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
130 effectStackDock->setObjectName("effect_stack");
131 effectStack = new EffectStackView(this);
132 effectStackDock->setWidget(effectStack);
133 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
135 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
136 transitionConfigDock->setObjectName("transition");
137 transitionConfig = new TransitionSettings(this);
138 transitionConfigDock->setWidget(transitionConfig);
139 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
142 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
143 clipMonitorDock->setObjectName("clip_monitor");
144 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
145 clipMonitorDock->setWidget(m_clipMonitor);
146 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
147 //m_clipMonitor->stop();
149 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
150 projectMonitorDock->setObjectName("project_monitor");
151 m_projectMonitor = new Monitor("project", m_monitorManager, this);
152 projectMonitorDock->setWidget(m_projectMonitor);
153 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
155 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
156 recMonitorDock->setObjectName("record_monitor");
157 m_recMonitor = new RecMonitor("record", this);
158 recMonitorDock->setWidget(m_recMonitor);
159 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
161 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
163 undoViewDock = new QDockWidget(i18n("Undo History"), this);
164 undoViewDock->setObjectName("undo_history");
165 m_undoView = new QUndoView(this);
166 m_undoView->setCleanIcon(KIcon("edit-clear"));
167 m_undoView->setEmptyLabel(i18n("Clean"));
168 undoViewDock->setWidget(m_undoView);
169 m_undoView->setGroup(m_commandStack);
170 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
172 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
173 //overviewDock->setObjectName("project_overview");
174 //m_overView = new CustomTrackView(NULL, NULL, this);
175 //overviewDock->setWidget(m_overView);
176 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
179 //tabifyDockWidget(projectListDock, effectListDock);
180 tabifyDockWidget(projectListDock, effectStackDock);
181 tabifyDockWidget(projectListDock, transitionConfigDock);
182 //tabifyDockWidget(projectListDock, undoViewDock);
183 projectListDock->raise();
185 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
186 tabifyDockWidget(clipMonitorDock, recMonitorDock);
187 setCentralWidget(m_timelineArea);
189 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
190 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
192 // build effects menus
194 QMenu *videoEffectsMenu = (QMenu*)(factory()->container("video_effects_menu", this));
195 QStringList effects = videoEffects.effectNames();
196 foreach(const QString &name, effects) {
197 action = new QAction(name, this);
198 action->setData(name);
199 videoEffectsMenu->addAction(action);
201 QMenu *audioEffectsMenu = (QMenu*)(factory()->container("audio_effects_menu", this));
202 effects = audioEffects.effectNames();
203 foreach(const QString &name, effects) {
204 action = new QAction(name, this);
205 action->setData(name);
206 audioEffectsMenu->addAction(action);
208 QMenu *customEffectsMenu = (QMenu*)(factory()->container("custom_effects_menu", this));
209 effects = customEffects.effectNames();
210 foreach(const QString &name, effects) {
211 action = new QAction(name, this);
212 action->setData(name);
213 customEffectsMenu->addAction(action);
216 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
217 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
218 connect(customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
220 m_timelineContextMenu = new QMenu(this);
221 m_timelineContextClipMenu = new QMenu(this);
222 m_timelineContextTransitionMenu = new QMenu(this);
225 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
226 effects = transitions.effectNames();
227 foreach(const QString &name, effects) {
228 action = new QAction(name, this);
229 action->setData(name);
230 transitionsMenu->addAction(action);
232 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
234 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
235 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
237 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
238 m_timelineContextClipMenu->addMenu(markersMenu);
239 m_timelineContextClipMenu->addMenu(transitionsMenu);
240 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
241 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
242 m_timelineContextClipMenu->addMenu(customEffectsMenu);
244 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
246 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
247 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
248 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
249 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
250 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
251 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
252 slotConnectMonitors();
254 setAutoSaveSettings();
256 if (KdenliveSettings::openlastproject()) {
257 KSharedConfigPtr config = KGlobal::config();
258 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
259 openFile(KUrl(Lastproject));
263 activateShuttleDevice();
266 void MainWindow::queryQuit() {
267 kDebug() << "----- SAVING CONFUIG";
268 if (queryClose()) kapp->quit();
272 bool MainWindow::queryClose() {
274 if (m_activeDocument && m_activeDocument->isModified()) {
275 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
276 case KMessageBox::Yes :
277 // save document here. If saving fails, return false;
279 case KMessageBox::No :
288 void MainWindow::activateShuttleDevice() {
289 if (m_jogProcess) delete m_jogProcess;
291 if (KdenliveSettings::enableshuttle() == false) return;
292 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
293 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
294 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
295 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
296 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
297 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
298 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
301 void MainWindow::slotShuttleButton(int code) {
304 slotShuttleAction(KdenliveSettings::shuttle1());
307 slotShuttleAction(KdenliveSettings::shuttle2());
310 slotShuttleAction(KdenliveSettings::shuttle3());
313 slotShuttleAction(KdenliveSettings::shuttle4());
316 slotShuttleAction(KdenliveSettings::shuttle5());
321 void MainWindow::slotShuttleAction(int code) {
326 m_monitorManager->slotPlay();
329 m_monitorManager->slotPlay();
334 void MainWindow::slotFullScreen() {
335 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
338 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
339 if (!m_activeDocument) return;
340 if (effect.isNull()) {
341 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
344 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
345 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
348 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
349 if (clipMonitor) clipMonitorDock->raise();
350 else projectMonitorDock->raise();
353 void MainWindow::slotSetClipDuration(int id, int duration) {
354 if (!m_activeDocument) return;
355 m_activeDocument->setProducerDuration(id, duration);
358 void MainWindow::slotConnectMonitors() {
360 m_projectList->setRenderer(m_clipMonitor->render);
361 connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
362 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
363 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
364 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
365 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 > &)));
366 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
369 void MainWindow::setupActions() {
371 m_timecodeFormat = new KComboBox(this);
372 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
373 m_timecodeFormat->addItem(i18n("Frames"));
375 statusProgressBar = new QProgressBar(this);
376 statusProgressBar->setMinimum(0);
377 statusProgressBar->setMaximum(100);
378 statusProgressBar->setMaximumWidth(150);
379 statusProgressBar->setVisible(false);
381 QWidget *w = new QWidget;
383 QHBoxLayout *layout = new QHBoxLayout;
384 w->setLayout(layout);
385 layout->setContentsMargins(5, 0, 5, 0);
386 QToolBar *toolbar = new QToolBar("statusToolBar", this);
389 m_toolGroup = new QActionGroup(this);
391 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;}";
393 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
394 m_buttonSelectTool->setCheckable(true);
395 m_buttonSelectTool->setChecked(true);
397 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
398 m_buttonRazorTool->setCheckable(true);
399 m_buttonRazorTool->setChecked(false);
401 m_toolGroup->addAction(m_buttonSelectTool);
402 m_toolGroup->addAction(m_buttonRazorTool);
403 m_toolGroup->setExclusive(true);
404 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
406 QWidget * actionWidget;
407 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
408 actionWidget->setMaximumWidth(24);
409 actionWidget->setMinimumHeight(17);
411 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
412 actionWidget->setMaximumWidth(24);
413 actionWidget->setMinimumHeight(17);
415 toolbar->setStyleSheet(style1);
416 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
418 toolbar->addSeparator();
419 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
420 m_buttonFitZoom->setCheckable(false);
421 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
423 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
424 actionWidget->setMaximumWidth(24);
425 actionWidget->setMinimumHeight(17);
427 m_zoomSlider = new QSlider(Qt::Horizontal, this);
428 m_zoomSlider->setMaximum(13);
430 m_zoomSlider->setMaximumWidth(150);
431 m_zoomSlider->setMinimumWidth(100);
433 const int contentHeight = QFontMetrics(w->font()).height() + 8;
434 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
435 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
436 m_zoomSlider->setStyleSheet(style);
438 //m_zoomSlider->setMaximumHeight(contentHeight);
439 //m_zoomSlider->height() + 5;
440 statusBar()->setMinimumHeight(contentHeight);
443 toolbar->addWidget(m_zoomSlider);
445 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
446 m_buttonVideoThumbs->setCheckable(true);
447 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
448 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
450 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
451 m_buttonAudioThumbs->setCheckable(true);
452 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
453 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
455 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
456 m_buttonShowMarkers->setCheckable(true);
457 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
458 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
460 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
461 m_buttonSnap->setCheckable(true);
462 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
463 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
464 layout->addWidget(toolbar);
467 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
468 actionWidget->setMaximumWidth(24);
469 actionWidget->setMinimumHeight(17);
471 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
472 actionWidget->setMaximumWidth(24);
473 actionWidget->setMinimumHeight(17);
475 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
476 actionWidget->setMaximumWidth(24);
477 actionWidget->setMinimumHeight(17);
479 actionWidget = toolbar->widgetForAction(m_buttonSnap);
480 actionWidget->setMaximumWidth(24);
481 actionWidget->setMinimumHeight(17);
483 m_messageLabel = new StatusBarMessageLabel(this);
484 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
486 statusBar()->addWidget(m_messageLabel, 10);
487 statusBar()->addWidget(statusProgressBar, 0);
488 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
489 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
490 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
491 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
492 m_messageLabel->hide();
494 actionCollection()->addAction("select_tool", m_buttonSelectTool);
495 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
497 actionCollection()->addAction("show_video_thumbs", m_buttonVideoThumbs);
498 actionCollection()->addAction("show_audio_thumbs", m_buttonAudioThumbs);
499 actionCollection()->addAction("show_markers", m_buttonShowMarkers);
500 actionCollection()->addAction("snap", m_buttonSnap);
501 actionCollection()->addAction("zoom_fit", m_buttonFitZoom);
503 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
504 actionCollection()->addAction("project_find", m_projectSearch);
505 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
506 m_projectSearch->setShortcut(Qt::Key_Slash);
508 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
509 actionCollection()->addAction("project_find_next", m_projectSearchNext);
510 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
511 m_projectSearchNext->setShortcut(Qt::Key_F3);
512 m_projectSearchNext->setEnabled(false);
514 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
515 actionCollection()->addAction("manage_profiles", profilesAction);
516 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
518 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
519 actionCollection()->addAction("project_settings", projectAction);
520 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
522 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
523 actionCollection()->addAction("project_render", projectRender);
524 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
526 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
527 monitorPlay->setShortcut(Qt::Key_Space);
528 actionCollection()->addAction("monitor_play", monitorPlay);
529 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
531 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
532 monitorSeekBackward->setShortcut(Qt::Key_J);
533 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
534 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
536 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
537 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
538 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
539 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
541 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
542 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
543 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
544 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
546 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
547 monitorSeekForward->setShortcut(Qt::Key_L);
548 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
549 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
551 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
552 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
553 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
554 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
556 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
557 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
558 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
559 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
561 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
562 deleteTimelineClip->setShortcut(Qt::Key_Delete);
563 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
564 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
566 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
567 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
568 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
569 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
571 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
572 actionCollection()->addAction("add_clip_marker", addClipMarker);
573 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
575 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
576 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
577 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
579 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
580 actionCollection()->addAction("edit_clip_marker", editClipMarker);
581 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
583 KStandardAction::quit(this, SLOT(queryQuit()),
586 KStandardAction::open(this, SLOT(openFile()),
589 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
592 KStandardAction::save(this, SLOT(saveFile()),
595 KStandardAction::saveAs(this, SLOT(saveFileAs()),
598 KStandardAction::openNew(this, SLOT(newFile()),
601 KStandardAction::preferences(this, SLOT(slotPreferences()),
604 KStandardAction::undo(this, SLOT(undo()),
607 KStandardAction::redo(this, SLOT(redo()),
610 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
612 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
613 this, SLOT(slotDisplayActionMessage(QAction*)));
614 //connect(actionCollection(), SIGNAL( clearStatusText() ),
615 //statusBar(), SLOT( clear() ) );
620 void MainWindow::undo() {
621 m_commandStack->undo();
624 void MainWindow::redo() {
625 m_commandStack->redo();
628 void MainWindow::slotDisplayActionMessage(QAction *a) {
629 statusBar()->showMessage(a->data().toString(), 3000);
632 void MainWindow::saveOptions() {
633 KdenliveSettings::self()->writeConfig();
634 KSharedConfigPtr config = KGlobal::config();
635 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
639 void MainWindow::readOptions() {
640 KSharedConfigPtr config = KGlobal::config();
641 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
644 void MainWindow::newFile() {
647 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
649 ProjectSettings *w = new ProjectSettings;
650 if (w->exec() != QDialog::Accepted) return;
651 profileName = w->selectedProfile();
652 projectFolder = w->selectedFolder();
655 MltVideoProfile prof;
656 if (!profileName.isEmpty()) prof = ProfilesDialog::getVideoProfile(profileName);
657 else prof = ProfilesDialog::getVideoProfile("dv_pal");
658 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
659 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack, this);
660 TrackView *trackView = new TrackView(doc, this);
661 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
662 if (m_timelineArea->count() == 1) {
663 connectDocumentInfo(doc);
664 connectDocument(trackView, doc);
665 } else m_timelineArea->setTabBarHidden(false);
668 void MainWindow::activateDocument() {
669 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
670 KdenliveDoc *currentDoc = currentTab->document();
671 connectDocumentInfo(currentDoc);
672 connectDocument(currentTab, currentDoc);
675 void MainWindow::slotRemoveTab() {
676 QWidget *w = m_timelineArea->currentWidget();
677 // closing current document
678 int ix = m_timelineArea->currentIndex() + 1;
679 if (ix == m_timelineArea->count()) ix = 0;
680 m_timelineArea->setCurrentIndex(ix);
681 TrackView *tabToClose = (TrackView *) w;
682 KdenliveDoc *docToClose = tabToClose->document();
683 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
684 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
689 void MainWindow::saveFileAs(const QString &outputFileName) {
690 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml(m_activeTimeline->projectView()->xmlInfo()));
691 m_activeDocument->setUrl(KUrl(outputFileName));
692 setCaption(m_activeDocument->description());
693 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
694 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
695 m_activeDocument->setModified(false);
698 void MainWindow::saveFileAs() {
699 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
700 if (QFile::exists(outputFile)) {
701 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
703 saveFileAs(outputFile);
706 void MainWindow::saveFile() {
707 if (!m_activeDocument) return;
708 if (m_activeDocument->url().isEmpty()) {
711 saveFileAs(m_activeDocument->url().path());
715 void MainWindow::openFile() { //changed
716 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
717 if (url.isEmpty()) return;
718 m_fileOpenRecent->addUrl(url);
722 void MainWindow::openFile(const KUrl &url) { //new
723 //TODO: get video profile from url before opening it
724 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
725 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
726 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack, this);
727 connectDocumentInfo(doc);
728 TrackView *trackView = new TrackView(doc, this);
729 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
730 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
731 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
732 slotGotProgressInfo(QString(), -1);
733 //connectDocument(trackView, doc);
737 void MainWindow::parseProfiles() {
738 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
740 //KdenliveSettings::setDefaulttmpfolder();
741 if (KdenliveSettings::mltpath().isEmpty()) {
742 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
744 if (KdenliveSettings::rendererpath().isEmpty()) {
745 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
747 QStringList profilesFilter;
748 profilesFilter << "*";
749 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
751 if (profilesList.isEmpty()) {
752 // Cannot find MLT path, try finding inigo
753 QString profilePath = KdenliveSettings::rendererpath();
754 if (!profilePath.isEmpty()) {
755 profilePath = profilePath.section('/', 0, -3);
756 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
757 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
760 if (profilesList.isEmpty()) {
761 // Cannot find the MLT profiles, ask for location
762 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
763 getUrl->fileDialog()->setMode(KFile::Directory);
765 KUrl mltPath = getUrl->selectedUrl();
767 if (mltPath.isEmpty()) kapp->quit();
768 KdenliveSettings::setMltpath(mltPath.path());
769 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
773 if (KdenliveSettings::rendererpath().isEmpty()) {
774 // Cannot find the MLT inigo renderer, ask for location
775 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
777 KUrl rendererPath = getUrl->selectedUrl();
779 if (rendererPath.isEmpty()) kapp->quit();
780 KdenliveSettings::setRendererpath(rendererPath.path());
783 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
785 // Parse MLT profiles to build a list of available video formats
786 if (profilesList.isEmpty()) parseProfiles();
790 void MainWindow::slotEditProfiles() {
791 ProfilesDialog *w = new ProfilesDialog;
796 void MainWindow::slotEditProjectSettings() {
797 ProjectSettings *w = new ProjectSettings;
798 if (w->exec() == QDialog::Accepted) {
799 QString profile = w->selectedProfile();
800 m_activeDocument->setProfilePath(profile);
801 m_monitorManager->resetProfiles(profile);
802 setCaption(m_activeDocument->description());
803 KdenliveSettings::setCurrent_profile(m_activeDocument->profilePath());
804 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
805 m_monitorManager->setTimecode(m_activeDocument->timecode());
806 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
808 // We need to desactivate & reactivate monitors to get a refresh
809 m_monitorManager->switchMonitors();
814 void MainWindow::slotRenderProject() {
815 if (!m_renderWidget) {
816 m_renderWidget = new RenderWidget(this);
817 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, bool, bool)));
819 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
820 if (currentTab) m_renderWidget->setTimeline(currentTab);
821 m_renderWidget->setDocument(m_activeDocument);*/
822 m_renderWidget->show();
825 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
826 if (dest.isEmpty()) return;
829 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
830 if (currentTab && zoneOnly) {
831 in = currentTab->inPoint();
832 out = currentTab->outPoint();
835 temp.setAutoRemove(false);
836 temp.setSuffix(".westley");
838 m_projectMonitor->saveSceneList(temp.fileName());
841 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
842 QString videoPlayer = "-";
843 if (playAfter) videoPlayer = "kmplayer";
844 args << "inigo" << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
845 QProcess::startDetached("kdenlive_render", args);
849 void MainWindow::slotUpdateMousePosition(int pos) {
850 if (m_activeDocument)
851 switch (m_timecodeFormat->currentIndex()) {
853 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
856 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
860 void MainWindow::slotUpdateDocumentState(bool modified) {
861 setCaption(m_activeDocument->description(), modified);
863 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
864 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
866 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
867 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
871 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
872 if (m_activeDocument) {
873 if (m_activeDocument == doc) return;
874 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
876 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
879 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
880 //m_projectMonitor->stop();
881 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
882 if (m_activeDocument) {
883 if (m_activeDocument == doc) return;
884 m_activeDocument->backupMltPlaylist();
885 if (m_activeTimeline) {
886 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
887 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
888 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
889 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
890 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
891 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
892 disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
893 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
894 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
895 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
896 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
897 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
898 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
899 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
900 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
902 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
903 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
904 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
905 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
906 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
907 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
908 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
909 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
911 m_activeDocument->setRenderer(NULL);
912 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
913 m_clipMonitor->stop();
915 m_monitorManager->resetProfiles(doc->profilePath());
916 m_projectList->setDocument(doc);
917 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
918 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
919 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
920 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
921 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
922 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
923 connect(doc, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
924 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
925 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
926 connect(doc, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
928 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
929 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
933 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
934 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
935 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
936 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
937 m_zoomSlider->setValue(trackView->currentZoom());
938 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
939 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
940 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
941 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
943 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
946 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
947 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
948 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
949 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
950 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
951 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
952 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
953 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
954 m_activeTimeline = trackView;
955 KdenliveSettings::setCurrent_profile(doc->profilePath());
956 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
957 m_monitorManager->setTimecode(doc->timecode());
958 doc->setRenderer(m_projectMonitor->render);
959 m_commandStack->setActiveStack(doc->commandStack());
961 doc->updateAllProjectClips();
963 if (m_commandStack->isClean()) kDebug() << "//////////// UNDO STACK IS CLEAN";
964 else kDebug() << "//////////// UNDO STACK IS NOT CLEAN*******************";
966 //m_overView->setScene(trackView->projectScene());
967 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
968 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
970 setCaption(doc->description());
971 m_activeDocument = doc;
974 void MainWindow::slotPreferences() {
975 //An instance of your dialog could be already created and could be
976 // cached, in which case you want to display the cached dialog
977 // instead of creating another one
978 if (KConfigDialog::showDialog("settings"))
981 // KConfigDialog didn't find an instance of this dialog, so lets
983 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
984 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
988 void MainWindow::updateConfiguration() {
989 //TODO: we should apply settings to all projects, not only the current one
990 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
992 currentTab->refresh();
993 currentTab->projectView()->checkAutoScroll();
994 currentTab->projectView()->checkTrackHeight();
995 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
997 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
998 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
999 activateShuttleDevice();
1003 void MainWindow::slotSwitchVideoThumbs() {
1004 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1005 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1007 currentTab->refresh();
1009 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1012 void MainWindow::slotSwitchAudioThumbs() {
1013 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1014 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1016 currentTab->refresh();
1017 currentTab->projectView()->checkAutoScroll();
1018 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1020 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1023 void MainWindow::slotSwitchMarkersComments() {
1024 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1025 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1027 currentTab->refresh();
1029 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1032 void MainWindow::slotSwitchSnap() {
1033 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1034 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1038 void MainWindow::slotDeleteTimelineClip() {
1039 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1041 currentTab->projectView()->deleteSelectedClips();
1045 void MainWindow::slotAddClipMarker() {
1046 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1048 currentTab->projectView()->slotAddClipMarker();
1052 void MainWindow::slotDeleteClipMarker() {
1053 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1055 currentTab->projectView()->slotDeleteClipMarker();
1059 void MainWindow::slotEditClipMarker() {
1060 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1062 currentTab->projectView()->slotEditClipMarker();
1066 void MainWindow::slotCutTimelineClip() {
1067 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1069 currentTab->projectView()->cutSelectedClips();
1073 void MainWindow::slotAddProjectClip(KUrl url) {
1074 if (m_activeDocument)
1075 m_activeDocument->slotAddClipFile(url, QString());
1078 void MainWindow::slotAddTransition(QAction *result) {
1079 if (!result) return;
1080 QDomElement effect = transitions.getEffectByName(result->data().toString());
1081 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1083 currentTab->projectView()->slotAddTransitionToSelectedClips(effect);
1087 void MainWindow::slotAddVideoEffect(QAction *result) {
1088 if (!result) return;
1089 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1090 slotAddEffect(effect);
1093 void MainWindow::slotAddAudioEffect(QAction *result) {
1094 if (!result) return;
1095 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1096 slotAddEffect(effect);
1099 void MainWindow::slotAddCustomEffect(QAction *result) {
1100 if (!result) return;
1101 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1102 slotAddEffect(effect);
1105 void MainWindow::slotZoomIn() {
1106 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1109 void MainWindow::slotZoomOut() {
1110 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1113 void MainWindow::slotFitZoom() {
1114 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1116 m_zoomSlider->setValue(currentTab->fitZoom());
1120 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1121 statusProgressBar->setValue(progress);
1122 if (progress >= 0) {
1123 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1124 statusProgressBar->setVisible(true);
1126 m_messageLabel->setMessage(QString(), DefaultMessage);
1127 statusProgressBar->setVisible(false);
1131 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1132 if (clip->clipType() == TEXT) {
1133 m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1136 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1137 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1138 connect(&dia, SIGNAL(addMarker(int, GenTime, QString)), currentTab->projectView(), SLOT(slotAddClipMarker(int, GenTime, QString)));
1139 if (dia.exec() == QDialog::Accepted) {
1140 m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1141 if (dia.needsTimelineRefresh()) {
1142 // update clip occurences in timeline
1144 currentTab->projectView()->slotUpdateClip(dia.clipId());
1149 void MainWindow::customEvent(QEvent* e) {
1150 if (e->type() == QEvent::User) {
1151 // The timeline playing position changed...
1152 kDebug() << "RECIEVED JOG EVEMNT!!!";
1155 void MainWindow::slotActivateEffectStackView() {
1156 effectStack->raiseWindow(effectStackDock);
1159 void MainWindow::slotActivateTransitionView() {
1160 transitionConfig->raiseWindow(transitionConfigDock);
1163 void MainWindow::slotSnapRewind() {
1164 if (m_monitorManager->projectMonitorFocused()) {
1165 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1166 currentTab->projectView()->slotSeekToPreviousSnap();
1170 void MainWindow::slotSnapForward() {
1171 if (m_monitorManager->projectMonitorFocused()) {
1172 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1173 currentTab->projectView()->slotSeekToNextSnap();
1177 void MainWindow::slotChangeTool(QAction * action) {
1178 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1179 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1182 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1183 if (m_activeDocument) {
1184 //m_activeDocument->setTool(tool);
1185 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1186 currentTab->projectView()->setTool(tool);
1190 void MainWindow::slotFind() {
1191 m_projectSearch->setEnabled(false);
1192 m_findActivated = true;
1193 m_findString = QString();
1194 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1195 currentTab->projectView()->initSearchStrings();
1196 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1197 m_findTimer.start(5000);
1198 qApp->installEventFilter(this);
1201 void MainWindow::slotFindNext() {
1202 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1203 if (currentTab->projectView()->findNextString(m_findString)) {
1204 statusBar()->showMessage(i18n("Found : %1", m_findString));
1206 statusBar()->showMessage(i18n("Reached end of project"));
1208 m_findTimer.start(4000);
1211 void MainWindow::findAhead() {
1212 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1213 if (currentTab->projectView()->findString(m_findString)) {
1214 m_projectSearchNext->setEnabled(true);
1215 statusBar()->showMessage(i18n("Found : %1", m_findString));
1217 m_projectSearchNext->setEnabled(false);
1218 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1222 void MainWindow::findTimeout() {
1223 m_projectSearchNext->setEnabled(false);
1224 m_findActivated = false;
1225 m_findString = QString();
1226 statusBar()->showMessage(i18n("Find stopped"), 3000);
1227 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1228 currentTab->projectView()->clearSearchStrings();
1229 m_projectSearch->setEnabled(true);
1230 removeEventFilter(this);
1233 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1234 if (m_findActivated) {
1235 if (ke->key() == Qt::Key_Backspace) {
1236 m_findString = m_findString.left(m_findString.length() - 1);
1238 if (!m_findString.isEmpty()) {
1244 m_findTimer.start(4000);
1247 } else if (ke->key() == Qt::Key_Escape) {
1251 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1252 m_findString += ke->text();
1256 m_findTimer.start(4000);
1260 } else KXmlGuiWindow::keyPressEvent(ke);
1263 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1264 if (m_findActivated) {
1265 if (event->type() == QEvent::ShortcutOverride) {
1266 QKeyEvent* ke = (QKeyEvent*) event;
1267 if (ke->text().trimmed().isEmpty()) return false;
1270 } else return false;
1272 // pass the event on to the parent class
1273 return QMainWindow::eventFilter(obj, event);
1277 #include "mainwindow.moc"