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 setCentralWidget(m_timelineArea);
184 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
185 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
187 // build effects menus
189 QMenu *videoEffectsMenu = (QMenu*)(factory()->container("video_effects_menu", this));
190 QStringList effects = videoEffects.effectNames();
191 foreach(const QString &name, effects) {
192 action = new QAction(name, this);
193 action->setData(name);
194 videoEffectsMenu->addAction(action);
196 QMenu *audioEffectsMenu = (QMenu*)(factory()->container("audio_effects_menu", this));
197 effects = audioEffects.effectNames();
198 foreach(const QString &name, effects) {
199 action = new QAction(name, this);
200 action->setData(name);
201 audioEffectsMenu->addAction(action);
203 QMenu *customEffectsMenu = (QMenu*)(factory()->container("custom_effects_menu", this));
204 effects = customEffects.effectNames();
205 foreach(const QString &name, effects) {
206 action = new QAction(name, this);
207 action->setData(name);
208 customEffectsMenu->addAction(action);
211 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
212 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
213 connect(customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
215 m_timelineContextMenu = new QMenu(this);
216 m_timelineContextClipMenu = new QMenu(this);
217 m_timelineContextTransitionMenu = new QMenu(this);
220 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
221 effects = transitions.effectNames();
222 foreach(const QString &name, effects) {
223 action = new QAction(name, this);
224 action->setData(name);
225 transitionsMenu->addAction(action);
227 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
229 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
230 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
232 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
233 m_timelineContextClipMenu->addMenu(markersMenu);
234 m_timelineContextClipMenu->addMenu(transitionsMenu);
235 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
236 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
237 m_timelineContextClipMenu->addMenu(customEffectsMenu);
239 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
241 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
242 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
243 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
244 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
245 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
246 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
247 slotConnectMonitors();
249 setAutoSaveSettings();
252 activateShuttleDevice();
255 void MainWindow::queryQuit() {
256 kDebug() << "----- SAVING CONFUIG";
257 if (queryClose()) kapp->quit();
261 bool MainWindow::queryClose() {
263 if (m_activeDocument && m_activeDocument->isModified()) {
264 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
265 case KMessageBox::Yes :
266 // save document here. If saving fails, return false;
268 case KMessageBox::No :
277 void MainWindow::activateShuttleDevice() {
278 if (m_jogProcess) delete m_jogProcess;
280 if (KdenliveSettings::enableshuttle() == false) return;
281 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
282 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
283 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
284 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
285 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
286 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
287 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
290 void MainWindow::slotShuttleButton(int code) {
293 slotShuttleAction(KdenliveSettings::shuttle1());
296 slotShuttleAction(KdenliveSettings::shuttle2());
299 slotShuttleAction(KdenliveSettings::shuttle3());
302 slotShuttleAction(KdenliveSettings::shuttle4());
305 slotShuttleAction(KdenliveSettings::shuttle5());
310 void MainWindow::slotShuttleAction(int code) {
315 m_monitorManager->slotPlay();
318 m_monitorManager->slotPlay();
323 void MainWindow::slotFullScreen() {
324 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
327 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
328 if (!m_activeDocument) return;
329 if (effect.isNull()) {
330 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
333 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
334 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
337 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
338 if (clipMonitor) clipMonitorDock->raise();
339 else projectMonitorDock->raise();
342 void MainWindow::slotSetClipDuration(int id, int duration) {
343 if (!m_activeDocument) return;
344 m_activeDocument->setProducerDuration(id, duration);
347 void MainWindow::slotConnectMonitors() {
349 m_projectList->setRenderer(m_clipMonitor->render);
350 connect(m_projectList, SIGNAL(receivedClipDuration(int, int)), this, SLOT(slotSetClipDuration(int, int)));
351 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
352 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
353 connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
354 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 > &)));
357 void MainWindow::setupActions() {
359 m_timecodeFormat = new KComboBox(this);
360 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
361 m_timecodeFormat->addItem(i18n("Frames"));
363 statusProgressBar = new QProgressBar(this);
364 statusProgressBar->setMinimum(0);
365 statusProgressBar->setMaximum(100);
366 statusProgressBar->setMaximumWidth(150);
367 statusProgressBar->setVisible(false);
369 QWidget *w = new QWidget;
371 QHBoxLayout *layout = new QHBoxLayout;
372 w->setLayout(layout);
373 layout->setContentsMargins(5, 0, 5, 0);
374 QToolBar *toolbar = new QToolBar("statusToolBar", this);
377 m_toolGroup = new QActionGroup(this);
379 QString style1 = "QToolButton { background-color: rgba(230, 230, 230, 20); border-style: inset; border:1px solid #666666;border-radius: 3px;margin: 0px 3px} QToolButton:checked { background-color: rgba(224, 0, 0, 100); border-style: inset; border:1px solid #666666;border-radius: 3px;}";
381 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
382 m_buttonSelectTool->setCheckable(true);
383 m_buttonSelectTool->setChecked(true);
385 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
386 m_buttonRazorTool->setCheckable(true);
387 m_buttonRazorTool->setChecked(false);
389 m_toolGroup->addAction(m_buttonSelectTool);
390 m_toolGroup->addAction(m_buttonRazorTool);
391 m_toolGroup->setExclusive(true);
392 toolbar->setStyleSheet(style1);
393 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
395 toolbar->addSeparator();
396 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
397 m_buttonFitZoom->setCheckable(false);
398 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
400 m_zoomSlider = new QSlider(Qt::Horizontal, this);
401 m_zoomSlider->setMaximum(13);
403 m_zoomSlider->setMaximumWidth(150);
404 m_zoomSlider->setMinimumWidth(100);
406 const int contentHeight = QFontMetrics(w->font()).height() + 8;
407 QString style = "QSlider::groove:horizontal { border: 1px solid #999999;height: 8px }";
408 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 8px;margin: -2px 0;border-radius: 3px; }");
409 m_zoomSlider->setStyleSheet(style);
411 //m_zoomSlider->setMaximumHeight(contentHeight);
412 //m_zoomSlider->height() + 5;
413 statusBar()->setMinimumHeight(contentHeight);
416 toolbar->addWidget(m_zoomSlider);
418 m_buttonVideoThumbs = toolbar->addAction(KIcon("video-mpeg"), i18n("Show video thumbnails"));
419 m_buttonVideoThumbs->setCheckable(true);
420 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
421 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
423 m_buttonAudioThumbs = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show audio thumbnails"));
424 m_buttonAudioThumbs->setCheckable(true);
425 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
426 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
428 m_buttonShowMarkers = toolbar->addAction(KIcon("audio-mpeg"), i18n("Show markers comments"));
429 m_buttonShowMarkers->setCheckable(true);
430 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
431 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
432 layout->addWidget(toolbar);
434 m_messageLabel = new StatusBarMessageLabel(this);
435 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
437 statusBar()->addWidget(m_messageLabel, 10);
438 statusBar()->addWidget(statusProgressBar, 0);
439 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
440 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
441 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
442 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
443 m_messageLabel->hide();
445 actionCollection()->addAction("select_tool", m_buttonSelectTool);
446 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
448 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
449 actionCollection()->addAction("manage_profiles", profilesAction);
450 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
452 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
453 actionCollection()->addAction("project_settings", projectAction);
454 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
456 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
457 actionCollection()->addAction("project_render", projectRender);
458 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
460 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
461 monitorPlay->setShortcut(Qt::Key_Space);
462 actionCollection()->addAction("monitor_play", monitorPlay);
463 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
465 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
466 monitorSeekBackward->setShortcut(Qt::Key_J);
467 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
468 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
470 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
471 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
472 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
473 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
475 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
476 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
477 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
478 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
480 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
481 monitorSeekForward->setShortcut(Qt::Key_L);
482 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
483 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
485 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
486 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
487 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
488 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
490 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
491 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
492 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
493 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
495 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
496 deleteTimelineClip->setShortcut(Qt::Key_Delete);
497 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
498 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
500 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
501 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
502 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
503 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
505 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
506 actionCollection()->addAction("add_clip_marker", addClipMarker);
507 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
509 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
510 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
511 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
513 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
514 actionCollection()->addAction("edit_clip_marker", editClipMarker);
515 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
517 KStandardAction::quit(this, SLOT(queryQuit()),
520 KStandardAction::open(this, SLOT(openFile()),
523 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
526 KStandardAction::save(this, SLOT(saveFile()),
529 KStandardAction::saveAs(this, SLOT(saveFileAs()),
532 KStandardAction::openNew(this, SLOT(newFile()),
535 KStandardAction::preferences(this, SLOT(slotPreferences()),
538 KStandardAction::undo(this, SLOT(undo()),
541 KStandardAction::redo(this, SLOT(redo()),
544 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
546 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
547 this, SLOT(slotDisplayActionMessage(QAction*)));
548 //connect(actionCollection(), SIGNAL( clearStatusText() ),
549 //statusBar(), SLOT( clear() ) );
554 void MainWindow::undo() {
555 m_commandStack->undo();
558 void MainWindow::redo() {
559 m_commandStack->redo();
562 void MainWindow::slotDisplayActionMessage(QAction *a) {
563 statusBar()->showMessage(a->data().toString(), 3000);
566 void MainWindow::saveOptions() {
567 KdenliveSettings::self()->writeConfig();
568 KSharedConfigPtr config = KGlobal::config();
569 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
573 void MainWindow::readOptions() {
574 KSharedConfigPtr config = KGlobal::config();
575 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
578 void MainWindow::newFile() {
581 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
583 ProjectSettings *w = new ProjectSettings;
584 if (w->exec() != QDialog::Accepted) return;
585 profileName = w->selectedProfile();
586 projectFolder = w->selectedFolder();
589 MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName);
590 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
591 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack, this);
592 TrackView *trackView = new TrackView(doc, this);
593 m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
594 if (m_timelineArea->count() == 1) {
595 connectDocumentInfo(doc);
596 connectDocument(trackView, doc);
597 } else m_timelineArea->setTabBarHidden(false);
600 void MainWindow::activateDocument() {
601 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
602 KdenliveDoc *currentDoc = currentTab->document();
603 connectDocumentInfo(currentDoc);
604 connectDocument(currentTab, currentDoc);
607 void MainWindow::slotRemoveTab() {
608 QWidget *w = m_timelineArea->currentWidget();
609 // closing current document
610 int ix = m_timelineArea->currentIndex() + 1;
611 if (ix == m_timelineArea->count()) ix = 0;
612 m_timelineArea->setCurrentIndex(ix);
613 TrackView *tabToClose = (TrackView *) w;
614 KdenliveDoc *docToClose = tabToClose->document();
615 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
616 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
621 void MainWindow::saveFileAs(const QString &outputFileName) {
622 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml(m_activeTimeline->projectView()->xmlInfo()));
623 m_activeDocument->setUrl(KUrl(outputFileName));
624 setCaption(m_activeDocument->description());
625 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
626 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
627 m_activeDocument->setModified(false);
630 void MainWindow::saveFileAs() {
631 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
632 if (QFile::exists(outputFile)) {
633 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
635 saveFileAs(outputFile);
638 void MainWindow::saveFile() {
639 if (!m_activeDocument) return;
640 if (m_activeDocument->url().isEmpty()) {
643 saveFileAs(m_activeDocument->url().path());
647 void MainWindow::openFile() { //changed
648 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
649 if (url.isEmpty()) return;
650 m_fileOpenRecent->addUrl(url);
654 void MainWindow::openFile(const KUrl &url) { //new
655 //TODO: get video profile from url before opening it
656 MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
657 if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
658 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack, this);
659 connectDocumentInfo(doc);
660 TrackView *trackView = new TrackView(doc, this);
661 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
662 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
663 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
664 slotGotProgressInfo(QString(), -1);
665 //connectDocument(trackView, doc);
669 void MainWindow::parseProfiles() {
670 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
672 //KdenliveSettings::setDefaulttmpfolder();
673 if (KdenliveSettings::mltpath().isEmpty()) {
674 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
676 if (KdenliveSettings::rendererpath().isEmpty()) {
677 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
679 QStringList profilesFilter;
680 profilesFilter << "*";
681 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
683 if (profilesList.isEmpty()) {
684 // Cannot find MLT path, try finding inigo
685 QString profilePath = KdenliveSettings::rendererpath();
686 if (!profilePath.isEmpty()) {
687 profilePath = profilePath.section('/', 0, -3);
688 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
689 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
692 if (profilesList.isEmpty()) {
693 // Cannot find the MLT profiles, ask for location
694 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
695 getUrl->fileDialog()->setMode(KFile::Directory);
697 KUrl mltPath = getUrl->selectedUrl();
699 if (mltPath.isEmpty()) kapp->quit();
700 KdenliveSettings::setMltpath(mltPath.path());
701 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
705 if (KdenliveSettings::rendererpath().isEmpty()) {
706 // Cannot find the MLT inigo renderer, ask for location
707 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
709 KUrl rendererPath = getUrl->selectedUrl();
711 if (rendererPath.isEmpty()) kapp->quit();
712 KdenliveSettings::setRendererpath(rendererPath.path());
715 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
717 // Parse MLT profiles to build a list of available video formats
718 if (profilesList.isEmpty()) parseProfiles();
722 void MainWindow::slotEditProfiles() {
723 ProfilesDialog *w = new ProfilesDialog;
728 void MainWindow::slotEditProjectSettings() {
729 ProjectSettings *w = new ProjectSettings;
730 if (w->exec() == QDialog::Accepted) {
731 QString profile = w->selectedProfile();
732 m_activeDocument->setProfilePath(profile);
733 m_monitorManager->resetProfiles(profile);
734 setCaption(m_activeDocument->description());
735 KdenliveSettings::setCurrent_profile(m_activeDocument->profilePath());
736 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
737 m_monitorManager->setTimecode(m_activeDocument->timecode());
738 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
740 // We need to desactivate & reactivate monitors to get a refresh
741 m_monitorManager->switchMonitors();
746 void MainWindow::slotRenderProject() {
747 if (!m_renderWidget) {
748 m_renderWidget = new RenderWidget(this);
749 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, bool, bool)));
751 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
752 if (currentTab) m_renderWidget->setTimeline(currentTab);
753 m_renderWidget->setDocument(m_activeDocument);*/
754 m_renderWidget->show();
757 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
758 if (dest.isEmpty()) return;
761 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
762 if (currentTab && zoneOnly) {
763 in = currentTab->inPoint();
764 out = currentTab->outPoint();
767 temp.setAutoRemove(false);
768 temp.setSuffix(".westley");
770 m_projectMonitor->saveSceneList(temp.fileName());
773 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
774 QString videoPlayer = "-";
775 if (playAfter) videoPlayer = "kmplayer";
776 args << "inigo" << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
777 QProcess::startDetached("kdenlive_render", args);
781 void MainWindow::slotUpdateMousePosition(int pos) {
782 if (m_activeDocument)
783 switch (m_timecodeFormat->currentIndex()) {
785 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
788 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
792 void MainWindow::slotUpdateDocumentState(bool modified) {
793 setCaption(m_activeDocument->description(), modified);
795 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
796 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
798 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
799 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
803 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
804 if (m_activeDocument) {
805 if (m_activeDocument == doc) return;
806 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
808 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
811 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
812 //m_projectMonitor->stop();
813 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
814 if (m_activeDocument) {
815 if (m_activeDocument == doc) return;
816 m_activeDocument->backupMltPlaylist();
817 if (m_activeTimeline) {
818 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
819 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
820 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
821 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
822 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
823 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
824 disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
825 disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
826 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
827 disconnect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
828 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
829 disconnect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
830 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
831 disconnect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
832 disconnect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
834 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
835 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
836 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
837 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
838 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
839 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
840 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
841 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
843 m_activeDocument->setRenderer(NULL);
844 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
845 m_clipMonitor->stop();
847 m_monitorManager->resetProfiles(doc->profilePath());
848 m_projectList->setDocument(doc);
849 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
850 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
851 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
852 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
853 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
854 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
855 connect(doc, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
856 connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
857 connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
858 connect(doc, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
860 connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
861 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
865 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
866 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
867 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
868 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
869 m_zoomSlider->setValue(trackView->currentZoom());
870 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
871 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
872 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
873 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
875 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
878 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
879 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
880 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, QDomElement, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, QDomElement, bool)));
881 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
882 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
883 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
884 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
885 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
886 m_activeTimeline = trackView;
887 KdenliveSettings::setCurrent_profile(doc->profilePath());
888 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
889 m_monitorManager->setTimecode(doc->timecode());
890 doc->setRenderer(m_projectMonitor->render);
891 m_commandStack->setActiveStack(doc->commandStack());
892 if (m_commandStack->isClean()) kDebug() << "//////////// UNDO STACK IS CLEAN";
893 else kDebug() << "//////////// UNDO STACK IS NOT CLEAN*******************";
895 //m_overView->setScene(trackView->projectScene());
896 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
897 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
899 setCaption(doc->description());
900 m_activeDocument = doc;
903 void MainWindow::slotPreferences() {
904 //An instance of your dialog could be already created and could be
905 // cached, in which case you want to display the cached dialog
906 // instead of creating another one
907 if (KConfigDialog::showDialog("settings"))
910 // KConfigDialog didn't find an instance of this dialog, so lets
912 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
913 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
917 void MainWindow::updateConfiguration() {
918 //TODO: we should apply settings to all projects, not only the current one
919 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
921 currentTab->refresh();
922 currentTab->projectView()->checkAutoScroll();
923 currentTab->projectView()->checkTrackHeight();
924 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
926 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
927 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
928 activateShuttleDevice();
932 void MainWindow::slotSwitchVideoThumbs() {
933 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
934 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
936 currentTab->refresh();
938 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
941 void MainWindow::slotSwitchAudioThumbs() {
942 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
943 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
945 currentTab->refresh();
946 currentTab->projectView()->checkAutoScroll();
947 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
949 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
952 void MainWindow::slotSwitchMarkersComments() {
953 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
954 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
956 currentTab->refresh();
958 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
964 void MainWindow::slotDeleteTimelineClip() {
965 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
967 currentTab->projectView()->deleteSelectedClips();
971 void MainWindow::slotAddClipMarker() {
972 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
974 currentTab->projectView()->slotAddClipMarker();
978 void MainWindow::slotDeleteClipMarker() {
979 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
981 currentTab->projectView()->slotDeleteClipMarker();
985 void MainWindow::slotEditClipMarker() {
986 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
988 currentTab->projectView()->slotEditClipMarker();
992 void MainWindow::slotCutTimelineClip() {
993 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
995 currentTab->projectView()->cutSelectedClips();
999 void MainWindow::slotAddProjectClip(KUrl url) {
1000 if (m_activeDocument)
1001 m_activeDocument->slotAddClipFile(url, QString());
1004 void MainWindow::slotAddTransition(QAction *result) {
1005 if (!result) return;
1006 QDomElement effect = transitions.getEffectByName(result->data().toString());
1007 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1009 currentTab->projectView()->slotAddTransitionToSelectedClips(effect);
1013 void MainWindow::slotAddVideoEffect(QAction *result) {
1014 if (!result) return;
1015 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1016 slotAddEffect(effect);
1019 void MainWindow::slotAddAudioEffect(QAction *result) {
1020 if (!result) return;
1021 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1022 slotAddEffect(effect);
1025 void MainWindow::slotAddCustomEffect(QAction *result) {
1026 if (!result) return;
1027 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1028 slotAddEffect(effect);
1031 void MainWindow::slotZoomIn() {
1032 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1035 void MainWindow::slotZoomOut() {
1036 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1039 void MainWindow::slotFitZoom() {
1040 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1042 m_zoomSlider->setValue(currentTab->fitZoom());
1046 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1047 statusProgressBar->setValue(progress);
1048 if (progress >= 0) {
1049 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1050 statusProgressBar->setVisible(true);
1052 m_messageLabel->setMessage(QString(), DefaultMessage);
1053 statusProgressBar->setVisible(false);
1057 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1058 if (clip->clipType() == TEXT) {
1059 m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1062 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1063 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1064 connect(&dia, SIGNAL(addMarker(int, GenTime, QString)), currentTab->projectView(), SLOT(slotAddClipMarker(int, GenTime, QString)));
1065 if (dia.exec() == QDialog::Accepted) {
1066 m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1067 if (dia.needsTimelineRefresh()) {
1068 // update clip occurences in timeline
1070 currentTab->projectView()->slotUpdateClip(dia.clipId());
1075 void MainWindow::customEvent(QEvent* e) {
1076 if (e->type() == QEvent::User) {
1077 // The timeline playing position changed...
1078 kDebug() << "RECIEVED JOG EVEMNT!!!";
1081 void MainWindow::slotActivateEffectStackView() {
1082 effectStack->raiseWindow(effectStackDock);
1085 void MainWindow::slotActivateTransitionView() {
1086 transitionConfig->raiseWindow(transitionConfigDock);
1089 void MainWindow::slotSnapRewind() {
1090 if (m_monitorManager->projectMonitorFocused()) {
1091 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1092 currentTab->projectView()->slotSeekToPreviousSnap();
1096 void MainWindow::slotSnapForward() {
1097 if (m_monitorManager->projectMonitorFocused()) {
1098 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1099 currentTab->projectView()->slotSeekToNextSnap();
1103 void MainWindow::slotChangeTool(QAction * action) {
1104 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1105 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1108 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1109 if (m_activeDocument) {
1110 //m_activeDocument->setTool(tool);
1111 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1112 currentTab->projectView()->setTool(tool);
1116 #include "mainwindow.moc"