1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include <QTextStream>
29 #include <KApplication>
33 #include <KActionCollection>
34 #include <KStandardAction>
35 #include <KFileDialog>
36 #include <KMessageBox>
38 #include <KIO/NetAccess>
41 #include <KConfigDialog>
42 #include <KXMLGUIFactory>
44 #include <kstandarddirs.h>
45 #include <KUrlRequesterDialog>
46 #include <KTemporaryFile>
47 #include <KActionMenu>
50 #include <ktogglefullscreenaction.h>
52 #include <KNotification>
53 #include <KNotifyConfigWidget>
55 #include <mlt++/Mlt.h>
57 #include "mainwindow.h"
58 #include "kdenlivesettings.h"
59 #include "kdenlivesettingsdialog.h"
60 #include "initeffects.h"
61 #include "profilesdialog.h"
62 #include "projectsettings.h"
64 #include "clipmanager.h"
65 #include "projectlist.h"
67 #include "recmonitor.h"
68 #include "monitormanager.h"
69 #include "kdenlivedoc.h"
70 #include "trackview.h"
71 #include "customtrackview.h"
72 #include "effectslistview.h"
73 #include "effectstackview.h"
74 #include "transitionsettings.h"
75 #include "renderwidget.h"
78 #include "jogshuttle.h"
79 #endif /* NO_JOGSHUTTLE */
80 #include "clipproperties.h"
82 #include "editclipcommand.h"
83 #include "titlewidget.h"
85 static const int ID_STATUS_MSG = 1;
86 static const int ID_EDITMODE_MSG = 2;
87 static const int ID_TIMELINE_MSG = 3;
88 static const int ID_TIMELINE_BUTTONS = 5;
89 static const int ID_TIMELINE_POS = 6;
90 static const int ID_TIMELINE_FORMAT = 7;
96 EffectsList MainWindow::videoEffects;
97 EffectsList MainWindow::audioEffects;
98 EffectsList MainWindow::customEffects;
99 EffectsList MainWindow::transitions;
101 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent)
102 : KXmlGuiWindow(parent),
103 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL),
104 #ifndef NO_JOGSHUTTLE
106 #endif /* NO_JOGSHUTTLE */
107 m_findActivated(false), m_initialized(false) {
108 setlocale(LC_NUMERIC, "POSIX");
109 setFont(KGlobalSettings::toolBarFont());
110 parseProfiles(MltPath);
111 m_commandStack = new QUndoGroup;
112 m_timelineArea = new KTabWidget(this);
113 m_timelineArea->setTabReorderingEnabled(true);
114 m_timelineArea->setTabBarHidden(true);
116 QToolButton *closeTabButton = new QToolButton;
117 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
118 closeTabButton->setIcon(KIcon("tab-close"));
119 closeTabButton->adjustSize();
120 closeTabButton->setToolTip(i18n("Close the current tab"));
121 m_timelineArea->setCornerWidget(closeTabButton);
122 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
124 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
125 m_findTimer.setSingleShot(true);
127 initEffects::parseEffectFiles();
128 //initEffects::parseCustomEffectsFile();
130 m_monitorManager = new MonitorManager();
132 projectListDock = new QDockWidget(i18n("Project Tree"), this);
133 projectListDock->setObjectName("project_tree");
134 m_projectList = new ProjectList(this);
135 projectListDock->setWidget(m_projectList);
136 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
138 effectListDock = new QDockWidget(i18n("Effect List"), this);
139 effectListDock->setObjectName("effect_list");
140 m_effectList = new EffectsListView();
142 //m_effectList = new KListWidget(this);
143 effectListDock->setWidget(m_effectList);
144 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
146 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
147 effectStackDock->setObjectName("effect_stack");
148 effectStack = new EffectStackView(this);
149 effectStackDock->setWidget(effectStack);
150 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
152 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
153 transitionConfigDock->setObjectName("transition");
154 transitionConfig = new TransitionSettings(this);
155 transitionConfigDock->setWidget(transitionConfig);
156 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
158 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
159 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
163 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
164 clipMonitorDock->setObjectName("clip_monitor");
165 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
166 clipMonitorDock->setWidget(m_clipMonitor);
167 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
168 //m_clipMonitor->stop();
170 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
171 projectMonitorDock->setObjectName("project_monitor");
172 m_projectMonitor = new Monitor("project", m_monitorManager, this);
173 projectMonitorDock->setWidget(m_projectMonitor);
174 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
176 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
177 recMonitorDock->setObjectName("record_monitor");
178 m_recMonitor = new RecMonitor("record", this);
179 recMonitorDock->setWidget(m_recMonitor);
180 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
182 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
183 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
185 undoViewDock = new QDockWidget(i18n("Undo History"), this);
186 undoViewDock->setObjectName("undo_history");
187 m_undoView = new QUndoView(this);
188 m_undoView->setCleanIcon(KIcon("edit-clear"));
189 m_undoView->setEmptyLabel(i18n("Clean"));
190 undoViewDock->setWidget(m_undoView);
191 m_undoView->setGroup(m_commandStack);
192 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
194 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
195 //overviewDock->setObjectName("project_overview");
196 //m_overView = new CustomTrackView(NULL, NULL, this);
197 //overviewDock->setWidget(m_overView);
198 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
201 //tabifyDockWidget(projectListDock, effectListDock);
202 tabifyDockWidget(projectListDock, effectStackDock);
203 tabifyDockWidget(projectListDock, transitionConfigDock);
204 //tabifyDockWidget(projectListDock, undoViewDock);
207 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
208 tabifyDockWidget(clipMonitorDock, recMonitorDock);
209 setCentralWidget(m_timelineArea);
212 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
214 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)));
215 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)));
217 // build effects menus
219 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
221 QStringList effectInfo;
222 QMap<QString, QStringList> effectsList;
223 for (int ix = 0; ix < videoEffects.count(); ix++) {
224 effectInfo = videoEffects.effectIdInfo(ix);
225 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
228 foreach(QStringList value, effectsList) {
229 action = new QAction(value.at(0), this);
230 action->setData(value);
231 videoEffectsMenu->addAction(action);
234 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
238 for (int ix = 0; ix < audioEffects.count(); ix++) {
239 effectInfo = audioEffects.effectIdInfo(ix);
240 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
243 foreach(QStringList value, effectsList) {
244 action = new QAction(value.at(0), this);
245 action->setData(value);
246 audioEffectsMenu->addAction(action);
249 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
251 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
252 else m_customEffectsMenu->setEnabled(true);
255 for (int ix = 0; ix < customEffects.count(); ix++) {
256 effectInfo = customEffects.effectIdInfo(ix);
257 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
260 foreach(QStringList value, effectsList) {
261 action = new QAction(value.at(0), this);
262 action->setData(value);
263 m_customEffectsMenu->addAction(action);
266 QMenu *newEffect = new QMenu(this);
267 newEffect->addMenu(videoEffectsMenu);
268 newEffect->addMenu(audioEffectsMenu);
269 newEffect->addMenu(m_customEffectsMenu);
270 effectStack->setMenu(newEffect);
273 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
274 const QList<QAction *> viewActions = createPopupMenu()->actions();
275 viewMenu->insertActions(NULL, viewActions);
277 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
278 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
279 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
281 m_timelineContextMenu = new QMenu(this);
282 m_timelineContextClipMenu = new QMenu(this);
283 m_timelineContextTransitionMenu = new QMenu(this);
286 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
287 QStringList effects = transitions.effectNames();
290 for (int ix = 0; ix < transitions.count(); ix++) {
291 effectInfo = transitions.effectIdInfo(ix);
292 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
294 foreach(QStringList value, effectsList) {
295 action = new QAction(value.at(0), this);
296 action->setData(value);
297 transitionsMenu->addAction(action);
299 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
301 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
303 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
304 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
305 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
306 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
307 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
309 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
310 m_timelineContextClipMenu->addMenu(markersMenu);
311 m_timelineContextClipMenu->addMenu(transitionsMenu);
312 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
313 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
314 //TODO: re-enable custom effects menu when it is implemented
315 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
317 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
318 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
320 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
321 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
322 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
323 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
324 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
325 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
327 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
328 slotConnectMonitors();
330 // Open or create a file. Command line argument passed in Url has
331 // precedence, then "openlastproject", then just a plain empty file.
332 // If opening Url fails, openlastproject will _not_ be used.
333 if (!Url.isEmpty()) {
336 if (KdenliveSettings::openlastproject()) {
340 if (m_timelineArea->count() == 0) {
344 #ifndef NO_JOGSHUTTLE
345 activateShuttleDevice();
346 #endif /* NO_JOGSHUTTLE */
347 projectListDock->raise();
350 void MainWindow::queryQuit() {
351 kDebug() << "----- SAVING CONFUIG";
352 if (queryClose()) kapp->quit();
356 bool MainWindow::queryClose() {
358 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
359 if (m_activeDocument && m_activeDocument->isModified()) {
360 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
361 case KMessageBox::Yes :
362 // save document here. If saving fails, return false;
364 case KMessageBox::No :
373 void MainWindow::saveProperties(KConfig*) {
374 // save properties here,used by session management
379 void MainWindow::readProperties(KConfig *config) {
380 // read properties here,used by session management
381 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
382 openFile(KUrl(Lastproject));
385 void MainWindow::slotReloadEffects() {
386 initEffects::parseCustomEffectsFile();
387 m_customEffectsMenu->clear();
388 const QStringList effects = customEffects.effectNames();
390 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
391 else m_customEffectsMenu->setEnabled(true);
393 foreach(const QString &name, effects) {
394 action = new QAction(name, this);
395 action->setData(name);
396 m_customEffectsMenu->addAction(action);
398 m_effectList->reloadEffectList();
401 #ifndef NO_JOGSHUTTLE
402 void MainWindow::activateShuttleDevice() {
403 if (m_jogProcess) delete m_jogProcess;
405 if (KdenliveSettings::enableshuttle() == false) return;
406 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
407 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
408 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
409 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
410 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
411 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
412 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
415 void MainWindow::slotShuttleButton(int code) {
418 slotShuttleAction(KdenliveSettings::shuttle1());
421 slotShuttleAction(KdenliveSettings::shuttle2());
424 slotShuttleAction(KdenliveSettings::shuttle3());
427 slotShuttleAction(KdenliveSettings::shuttle4());
430 slotShuttleAction(KdenliveSettings::shuttle5());
435 void MainWindow::slotShuttleAction(int code) {
440 m_monitorManager->slotPlay();
443 m_monitorManager->slotPlay();
447 #endif /* NO_JOGSHUTTLE */
449 void MainWindow::configureNotifications() {
450 KNotifyConfigWidget::configure(this);
453 void MainWindow::slotFullScreen() {
454 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
457 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
458 if (!m_activeDocument) return;
459 if (effect.isNull()) {
460 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
463 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
464 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
467 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
468 if (clipMonitor) clipMonitorDock->raise();
469 else projectMonitorDock->raise();
472 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
473 if (!m_activeDocument) return;
474 m_activeDocument->setProducerDuration(id, duration);
477 void MainWindow::slotConnectMonitors() {
479 m_projectList->setRenderer(m_clipMonitor->render);
480 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
481 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
482 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
483 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
484 connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
486 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
488 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
490 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
491 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
493 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
494 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
497 void MainWindow::slotAdjustClipMonitor() {
498 clipMonitorDock->updateGeometry();
499 clipMonitorDock->adjustSize();
500 m_clipMonitor->resetSize();
503 void MainWindow::slotAdjustProjectMonitor() {
504 projectMonitorDock->updateGeometry();
505 projectMonitorDock->adjustSize();
506 m_projectMonitor->resetSize();
509 void MainWindow::setupActions() {
511 KActionCollection* collection = actionCollection();
512 m_timecodeFormat = new KComboBox(this);
513 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
514 m_timecodeFormat->addItem(i18n("Frames"));
516 statusProgressBar = new QProgressBar(this);
517 statusProgressBar->setMinimum(0);
518 statusProgressBar->setMaximum(100);
519 statusProgressBar->setMaximumWidth(150);
520 statusProgressBar->setVisible(false);
522 QWidget *w = new QWidget;
524 QHBoxLayout *layout = new QHBoxLayout;
525 w->setLayout(layout);
526 layout->setContentsMargins(5, 0, 5, 0);
527 QToolBar *toolbar = new QToolBar("statusToolBar", this);
530 m_toolGroup = new QActionGroup(this);
532 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;}";
534 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
535 toolbar->addAction(m_buttonSelectTool);
536 m_buttonSelectTool->setCheckable(true);
537 m_buttonSelectTool->setChecked(true);
539 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
540 toolbar->addAction(m_buttonRazorTool);
541 m_buttonRazorTool->setCheckable(true);
542 m_buttonRazorTool->setChecked(false);
544 m_toolGroup->addAction(m_buttonSelectTool);
545 m_toolGroup->addAction(m_buttonRazorTool);
546 m_toolGroup->setExclusive(true);
547 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
549 QWidget * actionWidget;
550 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
551 actionWidget->setMaximumWidth(24);
552 actionWidget->setMinimumHeight(17);
554 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
555 actionWidget->setMaximumWidth(24);
556 actionWidget->setMinimumHeight(17);
558 toolbar->setStyleSheet(style1);
559 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
561 toolbar->addSeparator();
562 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
563 toolbar->addAction(m_buttonFitZoom);
564 m_buttonFitZoom->setCheckable(false);
565 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
567 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
568 actionWidget->setMaximumWidth(24);
569 actionWidget->setMinimumHeight(17);
571 m_zoomSlider = new QSlider(Qt::Horizontal, this);
572 m_zoomSlider->setMaximum(13);
573 m_zoomSlider->setPageStep(1);
575 m_zoomSlider->setMaximumWidth(150);
576 m_zoomSlider->setMinimumWidth(100);
578 const int contentHeight = QFontMetrics(w->font()).height() + 8;
580 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
581 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
583 m_zoomSlider->setStyleSheet(style);
585 //m_zoomSlider->height() + 5;
586 statusBar()->setMinimumHeight(contentHeight);
589 toolbar->addWidget(m_zoomSlider);
591 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
592 toolbar->addAction(m_buttonVideoThumbs);
593 m_buttonVideoThumbs->setCheckable(true);
594 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
595 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
597 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
598 toolbar->addAction(m_buttonAudioThumbs);
599 m_buttonAudioThumbs->setCheckable(true);
600 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
601 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
603 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
604 toolbar->addAction(m_buttonShowMarkers);
605 m_buttonShowMarkers->setCheckable(true);
606 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
607 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
609 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
610 toolbar->addAction(m_buttonSnap);
611 m_buttonSnap->setCheckable(true);
612 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
613 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
614 layout->addWidget(toolbar);
617 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
618 actionWidget->setMaximumWidth(24);
619 actionWidget->setMinimumHeight(17);
621 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
622 actionWidget->setMaximumWidth(24);
623 actionWidget->setMinimumHeight(17);
625 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
626 actionWidget->setMaximumWidth(24);
627 actionWidget->setMinimumHeight(17);
629 actionWidget = toolbar->widgetForAction(m_buttonSnap);
630 actionWidget->setMaximumWidth(24);
631 actionWidget->setMinimumHeight(17);
633 m_messageLabel = new StatusBarMessageLabel(this);
634 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
636 statusBar()->addWidget(m_messageLabel, 10);
637 statusBar()->addWidget(statusProgressBar, 0);
638 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
639 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
640 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
641 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
642 m_messageLabel->hide();
644 collection->addAction("select_tool", m_buttonSelectTool);
645 collection->addAction("razor_tool", m_buttonRazorTool);
647 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
648 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
649 collection->addAction("show_markers", m_buttonShowMarkers);
650 collection->addAction("snap", m_buttonSnap);
651 collection->addAction("zoom_fit", m_buttonFitZoom);
653 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
654 collection->addAction("zoom_in", zoomIn);
655 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
656 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
658 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
659 collection->addAction("zoom_out", zoomOut);
660 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
661 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
663 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
664 collection->addAction("project_find", m_projectSearch);
665 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
666 m_projectSearch->setShortcut(Qt::Key_Slash);
668 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
669 collection->addAction("project_find_next", m_projectSearchNext);
670 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
671 m_projectSearchNext->setShortcut(Qt::Key_F3);
672 m_projectSearchNext->setEnabled(false);
674 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
675 collection->addAction("manage_profiles", profilesAction);
676 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
678 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
679 collection->addAction("project_settings", projectAction);
680 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
682 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
683 collection->addAction("project_render", projectRender);
684 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
685 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
687 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
688 KShortcut playShortcut;
689 playShortcut.setPrimary(Qt::Key_Space);
690 playShortcut.setAlternate(Qt::Key_K);
691 monitorPlay->setShortcut(playShortcut);
692 collection->addAction("monitor_play", monitorPlay);
693 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
695 KAction *markIn = collection->addAction("mark_in");
696 markIn->setText(i18n("Set In Point"));
697 markIn->setShortcut(Qt::Key_I);
698 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
700 KAction *markOut = collection->addAction("mark_out");
701 markOut->setText(i18n("Set Out Point"));
702 markOut->setShortcut(Qt::Key_O);
703 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
705 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
706 monitorSeekBackward->setShortcut(Qt::Key_J);
707 collection->addAction("monitor_seek_backward", monitorSeekBackward);
708 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
710 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
711 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
712 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
713 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
715 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
716 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
717 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
718 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
720 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
721 monitorSeekForward->setShortcut(Qt::Key_L);
722 collection->addAction("monitor_seek_forward", monitorSeekForward);
723 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
725 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
726 clipStart->setShortcut(Qt::Key_Home);
727 collection->addAction("seek_clip_start", clipStart);
728 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
730 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
731 clipEnd->setShortcut(Qt::Key_End);
732 collection->addAction("seek_clip_end", clipEnd);
733 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
735 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
736 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
737 collection->addAction("seek_start", projectStart);
738 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
740 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
741 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
742 collection->addAction("seek_end", projectEnd);
743 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
745 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
746 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
747 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
748 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
750 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
751 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
752 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
753 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
755 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
756 deleteTimelineClip->setShortcut(Qt::Key_Delete);
757 collection->addAction("delete_timeline_clip", deleteTimelineClip);
758 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
760 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
761 collection->addAction("change_clip_speed", editTimelineClipSpeed);
762 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
764 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
765 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
766 collection->addAction("cut_timeline_clip", cutTimelineClip);
767 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
769 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
770 collection->addAction("add_clip_marker", addClipMarker);
771 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
773 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
774 collection->addAction("delete_clip_marker", deleteClipMarker);
775 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
777 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
778 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
779 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
781 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
782 collection->addAction("edit_clip_marker", editClipMarker);
783 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
785 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
786 collection->addAction("add_guide", addGuide);
787 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
789 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
790 collection->addAction("delete_guide", delGuide);
791 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
793 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
794 collection->addAction("edit_guide", editGuide);
795 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
797 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
798 collection->addAction("delete_all_guides", delAllGuides);
799 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
801 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
802 collection->addAction("paste_effects", pasteEffects);
803 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
805 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
807 KStandardAction::quit(this, SLOT(queryQuit()), collection);
809 KStandardAction::open(this, SLOT(openFile()), collection);
811 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
813 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
815 KStandardAction::openNew(this, SLOT(newFile()), collection);
817 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
819 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
821 KStandardAction::copy(this, SLOT(slotCopy()), collection);
823 KStandardAction::paste(this, SLOT(slotPaste()), collection);
825 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
826 undo->setEnabled(false);
827 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
829 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
830 redo->setEnabled(false);
831 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
833 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
835 connect(collection, SIGNAL(actionHovered(QAction*)),
836 this, SLOT(slotDisplayActionMessage(QAction*)));
837 //connect(collection, SIGNAL( clearStatusText() ),
838 //statusBar(), SLOT( clear() ) );
841 void MainWindow::slotDisplayActionMessage(QAction *a) {
842 statusBar()->showMessage(a->data().toString(), 3000);
845 void MainWindow::saveOptions() {
846 KdenliveSettings::self()->writeConfig();
847 KSharedConfigPtr config = KGlobal::config();
848 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
849 KConfigGroup treecolumns(config, "Project Tree");
850 treecolumns.writeEntry("columns", m_projectList->headerInfo());
854 void MainWindow::readOptions() {
855 KSharedConfigPtr config = KGlobal::config();
856 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
857 KConfigGroup initialGroup(config, "version");
858 if (!initialGroup.exists()) {
859 // this is our first run, show Wizard
860 Wizard *w = new Wizard(this);
861 if (w->exec() == QDialog::Accepted && w->isOk()) {
863 initialGroup.writeEntry("version", "0.7");
869 KConfigGroup treecolumns(config, "Project Tree");
870 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
871 if (!state.isEmpty())
872 m_projectList->setHeaderInfo(state);
875 void MainWindow::newFile(bool showProjectSettings) {
878 QPoint projectTracks(3, 2);
879 if (!showProjectSettings && m_timelineArea->count() == 0) {
880 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
881 profileName = KdenliveSettings::default_profile();
883 ProjectSettings *w = new ProjectSettings;
884 if (w->exec() != QDialog::Accepted) return;
885 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
886 profileName = w->selectedProfile();
887 projectFolder = w->selectedFolder();
888 projectTracks = w->tracks();
891 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
892 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
893 TrackView *trackView = new TrackView(doc, this);
894 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
895 if (m_timelineArea->count() == 1) {
896 connectDocumentInfo(doc);
897 connectDocument(trackView, doc);
898 } else m_timelineArea->setTabBarHidden(false);
899 m_closeAction->setEnabled(m_timelineArea->count() > 1);
902 void MainWindow::activateDocument() {
903 if (m_timelineArea->currentWidget() == NULL) return;
904 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
905 KdenliveDoc *currentDoc = currentTab->document();
906 connectDocumentInfo(currentDoc);
907 connectDocument(currentTab, currentDoc);
910 void MainWindow::closeCurrentDocument() {
911 QWidget *w = m_timelineArea->currentWidget();
913 // closing current document
914 int ix = m_timelineArea->currentIndex() + 1;
915 if (ix == m_timelineArea->count()) ix = 0;
916 m_timelineArea->setCurrentIndex(ix);
917 TrackView *tabToClose = (TrackView *) w;
918 KdenliveDoc *docToClose = tabToClose->document();
919 if (docToClose && docToClose->isModified()) {
920 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
921 case KMessageBox::Yes :
922 // save document here. If saving fails, return false;
925 case KMessageBox::Cancel :
931 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
932 if (m_timelineArea->count() == 1) {
933 m_timelineArea->setTabBarHidden(true);
934 m_closeAction->setEnabled(false);
938 if (m_timelineArea->count() == 0) {
939 m_activeDocument = NULL;
940 effectStack->clear();
941 transitionConfig->slotTransitionItemSelected(NULL, false);
945 bool MainWindow::saveFileAs(const QString &outputFileName) {
946 QDomDocument currentSceneList = m_projectMonitor->sceneList();
947 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
949 m_activeDocument->setUrl(KUrl(outputFileName));
950 if (m_activeDocument->m_autosave == NULL) {
951 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
952 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
953 setCaption(m_activeDocument->description());
954 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
955 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
956 m_activeDocument->setModified(false);
957 m_fileOpenRecent->addUrl(KUrl(outputFileName));
961 bool MainWindow::saveFileAs() {
962 // Check that the Kdenlive mime type is correctly installed
963 QString mimetype = "application/x-kdenlive";
964 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
965 if (!mime) mimetype = "*.kdenlive";
967 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
968 if (outputFile.isEmpty()) return false;
969 if (QFile::exists(outputFile)) {
970 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
972 return saveFileAs(outputFile);
975 bool MainWindow::saveFile() {
976 if (!m_activeDocument) return true;
977 if (m_activeDocument->url().isEmpty()) {
980 bool result = saveFileAs(m_activeDocument->url().path());
981 m_activeDocument->m_autosave->resize(0);
986 void MainWindow::openFile() {
987 // Check that the Kdenlive mime type is correctly installed
988 QString mimetype = "application/x-kdenlive";
989 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
990 if (!mime) mimetype = "*.kdenlive";
992 KUrl url = KFileDialog::getOpenUrl(KUrl(), mimetype);
993 if (url.isEmpty()) return;
994 m_fileOpenRecent->addUrl(url);
998 void MainWindow::openLastFile() {
999 KSharedConfigPtr config = KGlobal::config();
1000 KUrl::List urls = m_fileOpenRecent->urls();
1001 if (urls.isEmpty()) newFile(false);
1002 else openFile(urls.last());
1005 void MainWindow::openFile(const KUrl &url) {
1006 // Check if the document is already opened
1007 const int ct = m_timelineArea->count();
1008 bool isOpened = false;
1010 for (i = 0; i < ct; i++) {
1011 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1012 KdenliveDoc *doc = tab->document();
1013 if (doc->url() == url) {
1019 m_timelineArea->setCurrentIndex(i);
1023 // Check for backup file
1024 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1025 if (!staleFiles.isEmpty()) {
1026 if (KMessageBox::questionYesNo(this,
1027 i18n("Auto-saved files exist. Do you want to recover them now?"),
1028 i18n("File Recovery"),
1029 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1030 recoverFiles(staleFiles);
1033 // remove the stale files
1034 foreach(KAutoSaveFile *stale, staleFiles) {
1035 stale->open(QIODevice::ReadWrite);
1040 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1041 doOpenFile(url, NULL);
1044 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1046 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
1047 if (stale == NULL) {
1048 stale = new KAutoSaveFile(url, doc);
1049 doc->m_autosave = stale;
1051 doc->m_autosave = stale;
1052 doc->setUrl(stale->managedFile());
1053 doc->setModified(true);
1054 stale->setParent(doc);
1056 connectDocumentInfo(doc);
1057 TrackView *trackView = new TrackView(doc, this);
1058 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1059 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1060 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1061 slotGotProgressInfo(QString(), -1);
1062 m_clipMonitor->refreshMonitor(true);
1065 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1066 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1067 foreach(KAutoSaveFile *stale, staleFiles) {
1068 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1069 // show an error message; we could not steal the lockfile
1070 // maybe another application got to the file before us?
1074 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1075 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1076 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1077 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1082 void MainWindow::parseProfiles(const QString &mltPath) {
1083 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1085 //KdenliveSettings::setDefaulttmpfolder();
1086 if (!mltPath.isEmpty()) {
1087 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1088 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1091 if (KdenliveSettings::mltpath().isEmpty()) {
1092 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1094 if (KdenliveSettings::rendererpath().isEmpty()) {
1095 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1096 if (!QFile::exists(inigoPath))
1097 inigoPath = KStandardDirs::findExe("inigo");
1098 else KdenliveSettings::setRendererpath(inigoPath);
1100 QStringList profilesFilter;
1101 profilesFilter << "*";
1102 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1104 if (profilesList.isEmpty()) {
1105 // Cannot find MLT path, try finding inigo
1106 QString profilePath = KdenliveSettings::rendererpath();
1107 if (!profilePath.isEmpty()) {
1108 profilePath = profilePath.section('/', 0, -3);
1109 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1110 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1113 if (profilesList.isEmpty()) {
1114 // Cannot find the MLT profiles, ask for location
1115 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1116 getUrl->fileDialog()->setMode(KFile::Directory);
1117 if (getUrl->exec() == QDialog::Rejected) {
1120 KUrl mltPath = getUrl->selectedUrl();
1122 if (mltPath.isEmpty()) ::exit(0);
1123 KdenliveSettings::setMltpath(mltPath.path());
1124 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1128 if (KdenliveSettings::rendererpath().isEmpty()) {
1129 // Cannot find the MLT inigo renderer, ask for location
1130 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1131 if (getUrl->exec() == QDialog::Rejected) {
1134 KUrl rendererPath = getUrl->selectedUrl();
1136 if (rendererPath.isEmpty()) ::exit(0);
1137 KdenliveSettings::setRendererpath(rendererPath.path());
1140 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1142 // Parse MLT profiles to build a list of available video formats
1143 if (profilesList.isEmpty()) parseProfiles();
1147 void MainWindow::slotEditProfiles() {
1148 ProfilesDialog *w = new ProfilesDialog;
1153 void MainWindow::slotEditProjectSettings() {
1154 ProjectSettings *w = new ProjectSettings;
1155 if (w->exec() == QDialog::Accepted) {
1156 QString profile = w->selectedProfile();
1157 m_activeDocument->setProfilePath(profile);
1158 KdenliveSettings::setCurrent_profile(profile);
1159 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1160 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1161 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1162 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1163 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1165 // We need to desactivate & reactivate monitors to get a refresh
1166 m_monitorManager->switchMonitors();
1171 void MainWindow::slotRenderProject() {
1172 if (!m_renderWidget) {
1173 m_renderWidget = new RenderWidget(this);
1174 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)));
1175 if (m_activeDocument) {
1176 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1177 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1180 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1181 if (currentTab) m_renderWidget->setTimeline(currentTab);
1182 m_renderWidget->setDocument(m_activeDocument);*/
1183 m_renderWidget->show();
1186 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd) {
1187 if (dest.isEmpty()) return;
1190 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1191 if (currentTab && zoneOnly) {
1192 in = currentTab->inPoint();
1193 out = currentTab->outPoint();
1195 KTemporaryFile temp;
1196 temp.setAutoRemove(false);
1197 temp.setSuffix(".westley");
1199 m_projectMonitor->saveSceneList(temp.fileName());
1202 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1203 else if (guideStart != -1) {
1204 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1206 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1207 QString videoPlayer = "-";
1209 videoPlayer = KdenliveSettings::defaultplayerapp();
1210 if (videoPlayer.isEmpty()) KMessageBox::sorry(this, i18n("Cannot play video after rendering because the default video player application is not set.\nPlease define it in Kdenlive settings dialog."));
1212 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1213 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1216 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1217 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1218 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1219 QProcess::startDetached(renderer, args);
1221 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1225 void MainWindow::slotUpdateMousePosition(int pos) {
1226 if (m_activeDocument)
1227 switch (m_timecodeFormat->currentIndex()) {
1229 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1232 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1236 void MainWindow::slotUpdateDocumentState(bool modified) {
1237 setCaption(m_activeDocument->description(), modified);
1238 m_saveAction->setEnabled(modified);
1240 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1241 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1243 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1244 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1248 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1249 if (m_activeDocument) {
1250 if (m_activeDocument == doc) return;
1251 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1253 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1256 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1257 //m_projectMonitor->stop();
1258 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1259 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1260 if (m_activeDocument) {
1261 if (m_activeDocument == doc) return;
1262 m_activeDocument->backupMltPlaylist();
1263 if (m_activeTimeline) {
1264 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1265 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1266 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1267 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1268 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1269 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1270 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1271 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1272 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1273 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1274 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1275 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1276 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1277 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1278 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1279 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1280 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1281 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1283 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1284 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1285 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1286 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1287 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1288 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1289 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1290 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1291 disconnect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), m_activeTimeline->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1292 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1293 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1294 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1295 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1296 effectStack->clear();
1298 m_activeDocument->setRenderer(NULL);
1299 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1300 m_clipMonitor->stop();
1302 KdenliveSettings::setCurrent_profile(doc->profilePath());
1303 KdenliveSettings::setProject_fps(doc->fps());
1304 m_monitorManager->resetProfiles(doc->timecode());
1305 m_projectList->setDocument(doc);
1306 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1307 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1308 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1309 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1310 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1311 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1312 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1313 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1314 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1315 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1316 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1317 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1318 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1319 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1321 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1322 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1323 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1326 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1327 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1328 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1329 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1330 m_zoomSlider->setValue(doc->zoom());
1331 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1332 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1333 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1334 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1336 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1339 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1340 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1341 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1342 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1343 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1344 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1345 connect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), trackView->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1346 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1347 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1349 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1350 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1351 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1353 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1354 m_activeTimeline = trackView;
1355 if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
1356 doc->setRenderer(m_projectMonitor->render);
1357 m_commandStack->setActiveStack(doc->commandStack());
1358 KdenliveSettings::setProject_display_ratio(doc->dar());
1359 m_projectList->updateAllClips();
1360 //doc->clipManager()->checkAudioThumbs();
1362 //m_overView->setScene(trackView->projectScene());
1363 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1364 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1366 setCaption(doc->description(), doc->isModified());
1367 m_saveAction->setEnabled(doc->isModified());
1368 m_activeDocument = doc;
1371 void MainWindow::slotGuidesUpdated() {
1372 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1375 void MainWindow::slotPreferences(int page, int option) {
1376 //An instance of your dialog could be already created and could be
1377 // cached, in which case you want to display the cached dialog
1378 // instead of creating another one
1379 if (KConfigDialog::showDialog("settings")) {
1380 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1381 if (page != -1) d->showPage(page, option);
1386 // KConfigDialog didn't find an instance of this dialog, so lets
1388 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1389 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1390 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1392 if (page != -1) dialog->showPage(page, option);
1395 void MainWindow::updateConfiguration() {
1396 //TODO: we should apply settings to all projects, not only the current one
1397 if (m_activeTimeline) {
1398 m_activeTimeline->refresh();
1399 m_activeTimeline->projectView()->checkAutoScroll();
1400 m_activeTimeline->projectView()->checkTrackHeight();
1401 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1403 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1404 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1405 #ifndef NO_JOGSHUTTLE
1406 activateShuttleDevice();
1407 #endif /* NO_JOGSHUTTLE */
1411 void MainWindow::slotSwitchVideoThumbs() {
1412 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1413 if (m_activeTimeline) {
1414 m_activeTimeline->refresh();
1416 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1419 void MainWindow::slotSwitchAudioThumbs() {
1420 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1421 if (m_activeTimeline) {
1422 m_activeTimeline->refresh();
1423 m_activeTimeline->projectView()->checkAutoScroll();
1424 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1426 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1429 void MainWindow::slotSwitchMarkersComments() {
1430 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1431 if (m_activeTimeline) {
1432 m_activeTimeline->refresh();
1434 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1437 void MainWindow::slotSwitchSnap() {
1438 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1439 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1443 void MainWindow::slotDeleteTimelineClip() {
1444 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1445 else if (m_activeTimeline) {
1446 m_activeTimeline->projectView()->deleteSelectedClips();
1450 void MainWindow::slotChangeClipSpeed() {
1451 if (m_activeTimeline) {
1452 m_activeTimeline->projectView()->changeClipSpeed();
1456 void MainWindow::slotAddClipMarker() {
1457 if (m_activeTimeline) {
1458 m_activeTimeline->projectView()->slotAddClipMarker();
1462 void MainWindow::slotDeleteClipMarker() {
1463 if (m_activeTimeline) {
1464 m_activeTimeline->projectView()->slotDeleteClipMarker();
1468 void MainWindow::slotDeleteAllClipMarkers() {
1469 if (m_activeTimeline) {
1470 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1474 void MainWindow::slotEditClipMarker() {
1475 if (m_activeTimeline) {
1476 m_activeTimeline->projectView()->slotEditClipMarker();
1480 void MainWindow::slotAddGuide() {
1481 if (m_activeTimeline)
1482 m_activeTimeline->projectView()->slotAddGuide();
1485 void MainWindow::slotEditGuide() {
1486 if (m_activeTimeline)
1487 m_activeTimeline->projectView()->slotEditGuide();
1490 void MainWindow::slotDeleteGuide() {
1491 if (m_activeTimeline)
1492 m_activeTimeline->projectView()->slotDeleteGuide();
1495 void MainWindow::slotDeleteAllGuides() {
1496 if (m_activeTimeline)
1497 m_activeTimeline->projectView()->slotDeleteAllGuides();
1500 void MainWindow::slotCutTimelineClip() {
1501 if (m_activeTimeline) {
1502 m_activeTimeline->projectView()->cutSelectedClips();
1506 void MainWindow::slotAddProjectClip(KUrl url) {
1507 if (m_activeDocument)
1508 m_activeDocument->slotAddClipFile(url, QString());
1511 void MainWindow::slotAddTransition(QAction *result) {
1512 if (!result) return;
1513 QStringList info = result->data().toStringList();
1514 if (info.isEmpty()) return;
1515 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
1516 if (m_activeTimeline && !transition.isNull()) {
1517 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
1521 void MainWindow::slotAddVideoEffect(QAction *result) {
1522 if (!result) return;
1523 QStringList info = result->data().toStringList();
1524 if (info.isEmpty()) return;
1525 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1526 slotAddEffect(effect);
1529 void MainWindow::slotAddAudioEffect(QAction *result) {
1530 if (!result) return;
1531 QStringList info = result->data().toStringList();
1532 if (info.isEmpty()) return;
1533 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1534 slotAddEffect(effect);
1537 void MainWindow::slotAddCustomEffect(QAction *result) {
1538 if (!result) return;
1539 QStringList info = result->data().toStringList();
1540 if (info.isEmpty()) return;
1541 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1542 slotAddEffect(effect);
1545 void MainWindow::slotZoomIn() {
1546 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1549 void MainWindow::slotZoomOut() {
1550 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1553 void MainWindow::slotFitZoom() {
1554 if (m_activeTimeline) {
1555 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1559 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1560 statusProgressBar->setValue(progress);
1561 if (progress >= 0) {
1562 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1563 statusProgressBar->setVisible(true);
1565 m_messageLabel->setMessage(QString(), DefaultMessage);
1566 statusProgressBar->setVisible(false);
1570 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1571 if (clip->clipType() == TEXT) {
1572 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1573 QString path = clip->getProperty("resource");
1574 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1576 doc.setContent(clip->getProperty("xmldata"));
1577 dia_ui->setXml(doc);
1578 if (dia_ui->exec() == QDialog::Accepted) {
1579 QPixmap pix = dia_ui->renderedPixmap();
1581 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1582 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1583 QMap <QString, QString> newprops;
1584 newprops.insert("xmldata", dia_ui->xml().toString());
1585 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1586 m_activeDocument->commandStack()->push(command);
1587 m_clipMonitor->refreshMonitor(true);
1588 m_activeDocument->setModified(true);
1592 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1595 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1596 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1597 if (dia.exec() == QDialog::Accepted) {
1598 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1599 m_activeDocument->commandStack()->push(command);
1601 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1602 if (dia.needsTimelineRefresh()) {
1603 // update clip occurences in timeline
1604 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1609 void MainWindow::customEvent(QEvent* e) {
1610 if (e->type() == QEvent::User) {
1611 // The timeline playing position changed...
1612 kDebug() << "RECIEVED JOG EVEMNT!!!";
1615 void MainWindow::slotActivateEffectStackView() {
1616 effectStack->raiseWindow(effectStackDock);
1619 void MainWindow::slotActivateTransitionView() {
1620 transitionConfig->raiseWindow(transitionConfigDock);
1623 void MainWindow::slotSnapRewind() {
1624 if (m_projectMonitor->isActive()) {
1625 if (m_activeTimeline)
1626 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1630 void MainWindow::slotSnapForward() {
1631 if (m_projectMonitor->isActive()) {
1632 if (m_activeTimeline)
1633 m_activeTimeline->projectView()->slotSeekToNextSnap();
1637 void MainWindow::slotClipStart() {
1638 if (m_projectMonitor->isActive()) {
1639 if (m_activeTimeline)
1640 m_activeTimeline->projectView()->clipStart();
1644 void MainWindow::slotClipEnd() {
1645 if (m_projectMonitor->isActive()) {
1646 if (m_activeTimeline)
1647 m_activeTimeline->projectView()->clipEnd();
1651 void MainWindow::slotChangeTool(QAction * action) {
1652 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1653 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1656 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1657 if (m_activeDocument && m_activeTimeline) {
1658 //m_activeDocument->setTool(tool);
1659 m_activeTimeline->projectView()->setTool(tool);
1663 void MainWindow::slotCopy() {
1664 if (!m_activeDocument || !m_activeTimeline) return;
1665 m_activeTimeline->projectView()->copyClip();
1668 void MainWindow::slotPaste() {
1669 if (!m_activeDocument || !m_activeTimeline) return;
1670 m_activeTimeline->projectView()->pasteClip();
1673 void MainWindow::slotPasteEffects() {
1674 if (!m_activeDocument || !m_activeTimeline) return;
1675 m_activeTimeline->projectView()->pasteClipEffects();
1678 void MainWindow::slotFind() {
1679 if (!m_activeDocument || !m_activeTimeline) return;
1680 m_projectSearch->setEnabled(false);
1681 m_findActivated = true;
1682 m_findString = QString();
1683 m_activeTimeline->projectView()->initSearchStrings();
1684 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1685 m_findTimer.start(5000);
1686 qApp->installEventFilter(this);
1689 void MainWindow::slotFindNext() {
1690 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1691 statusBar()->showMessage(i18n("Found : %1", m_findString));
1693 statusBar()->showMessage(i18n("Reached end of project"));
1695 m_findTimer.start(4000);
1698 void MainWindow::findAhead() {
1699 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1700 m_projectSearchNext->setEnabled(true);
1701 statusBar()->showMessage(i18n("Found : %1", m_findString));
1703 m_projectSearchNext->setEnabled(false);
1704 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1708 void MainWindow::findTimeout() {
1709 m_projectSearchNext->setEnabled(false);
1710 m_findActivated = false;
1711 m_findString = QString();
1712 statusBar()->showMessage(i18n("Find stopped"), 3000);
1713 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1714 m_projectSearch->setEnabled(true);
1715 removeEventFilter(this);
1718 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1719 if (m_findActivated) {
1720 if (ke->key() == Qt::Key_Backspace) {
1721 m_findString = m_findString.left(m_findString.length() - 1);
1723 if (!m_findString.isEmpty()) {
1729 m_findTimer.start(4000);
1732 } else if (ke->key() == Qt::Key_Escape) {
1736 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1737 m_findString += ke->text();
1741 m_findTimer.start(4000);
1745 } else KXmlGuiWindow::keyPressEvent(ke);
1749 /** Gets called when the window gets hidden */
1750 void MainWindow::hideEvent(QHideEvent *event) {
1751 // kDebug() << "I was hidden";
1752 // issue http://www.kdenlive.org/mantis/view.php?id=231
1753 if (this->isMinimized()) {
1754 // kDebug() << "I am minimized";
1755 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
1759 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1760 if (m_findActivated) {
1761 if (event->type() == QEvent::ShortcutOverride) {
1762 QKeyEvent* ke = (QKeyEvent*) event;
1763 if (ke->text().trimmed().isEmpty()) return false;
1766 } else return false;
1768 // pass the event on to the parent class
1769 return QMainWindow::eventFilter(obj, event);
1773 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1774 KDialog *dialog = new KDialog(this);
1775 dialog->setCaption("Save clip zone");
1776 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1778 QWidget *widget = new QWidget(dialog);
1779 dialog->setMainWidget(widget);
1781 QVBoxLayout *vbox = new QVBoxLayout(widget);
1782 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1783 QString path = m_activeDocument->projectFolder().path();
1785 path.append("untitled.westley");
1786 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1787 url->setFilter("video/mlt-playlist");
1788 QLabel *label2 = new QLabel(i18n("Description:"), this);
1789 KLineEdit *edit = new KLineEdit(this);
1790 vbox->addWidget(label1);
1791 vbox->addWidget(url);
1792 vbox->addWidget(label2);
1793 vbox->addWidget(edit);
1794 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1798 void MainWindow::slotSetInPoint() {
1799 if (m_clipMonitor->isActive()) {
1800 m_clipMonitor->slotSetZoneStart();
1801 } else m_activeTimeline->projectView()->setInPoint();
1804 void MainWindow::slotSetOutPoint() {
1805 if (m_clipMonitor->isActive()) {
1806 m_clipMonitor->slotSetZoneEnd();
1807 } else m_activeTimeline->projectView()->setOutPoint();
1811 #include "mainwindow.moc"