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"
77 #include "jogshuttle.h"
78 #include "clipproperties.h"
80 #include "editclipcommand.h"
81 #include "titlewidget.h"
83 static const int ID_STATUS_MSG = 1;
84 static const int ID_EDITMODE_MSG = 2;
85 static const int ID_TIMELINE_MSG = 3;
86 static const int ID_TIMELINE_BUTTONS = 5;
87 static const int ID_TIMELINE_POS = 6;
88 static const int ID_TIMELINE_FORMAT = 7;
94 EffectsList MainWindow::videoEffects;
95 EffectsList MainWindow::audioEffects;
96 EffectsList MainWindow::customEffects;
97 EffectsList MainWindow::transitions;
99 MainWindow::MainWindow(const QString &MltPath, QWidget *parent)
100 : KXmlGuiWindow(parent),
101 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
102 setlocale(LC_NUMERIC, "POSIX");
103 setFont(KGlobalSettings::toolBarFont());
104 parseProfiles(MltPath);
105 m_commandStack = new QUndoGroup;
106 m_timelineArea = new KTabWidget(this);
107 m_timelineArea->setTabReorderingEnabled(true);
108 m_timelineArea->setTabBarHidden(true);
110 QToolButton *closeTabButton = new QToolButton;
111 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
112 closeTabButton->setIcon(KIcon("tab-close"));
113 closeTabButton->adjustSize();
114 closeTabButton->setToolTip(i18n("Close the current tab"));
115 m_timelineArea->setCornerWidget(closeTabButton);
116 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
118 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
119 m_findTimer.setSingleShot(true);
121 initEffects::parseEffectFiles();
122 //initEffects::parseCustomEffectsFile();
124 m_monitorManager = new MonitorManager();
126 projectListDock = new QDockWidget(i18n("Project Tree"), this);
127 projectListDock->setObjectName("project_tree");
128 m_projectList = new ProjectList(this);
129 projectListDock->setWidget(m_projectList);
130 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
132 effectListDock = new QDockWidget(i18n("Effect List"), this);
133 effectListDock->setObjectName("effect_list");
134 m_effectList = new EffectsListView();
136 //m_effectList = new KListWidget(this);
137 effectListDock->setWidget(m_effectList);
138 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
140 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
141 effectStackDock->setObjectName("effect_stack");
142 effectStack = new EffectStackView(this);
143 effectStackDock->setWidget(effectStack);
144 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
146 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
147 transitionConfigDock->setObjectName("transition");
148 transitionConfig = new TransitionSettings(this);
149 transitionConfigDock->setWidget(transitionConfig);
150 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
152 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
153 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
157 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
158 clipMonitorDock->setObjectName("clip_monitor");
159 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
160 clipMonitorDock->setWidget(m_clipMonitor);
161 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
162 //m_clipMonitor->stop();
164 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
165 projectMonitorDock->setObjectName("project_monitor");
166 m_projectMonitor = new Monitor("project", m_monitorManager, this);
167 projectMonitorDock->setWidget(m_projectMonitor);
168 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
170 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
171 recMonitorDock->setObjectName("record_monitor");
172 m_recMonitor = new RecMonitor("record", this);
173 recMonitorDock->setWidget(m_recMonitor);
174 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
176 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
177 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
179 undoViewDock = new QDockWidget(i18n("Undo History"), this);
180 undoViewDock->setObjectName("undo_history");
181 m_undoView = new QUndoView(this);
182 m_undoView->setCleanIcon(KIcon("edit-clear"));
183 m_undoView->setEmptyLabel(i18n("Clean"));
184 undoViewDock->setWidget(m_undoView);
185 m_undoView->setGroup(m_commandStack);
186 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
188 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
189 //overviewDock->setObjectName("project_overview");
190 //m_overView = new CustomTrackView(NULL, NULL, this);
191 //overviewDock->setWidget(m_overView);
192 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
195 //tabifyDockWidget(projectListDock, effectListDock);
196 tabifyDockWidget(projectListDock, effectStackDock);
197 tabifyDockWidget(projectListDock, transitionConfigDock);
198 //tabifyDockWidget(projectListDock, undoViewDock);
201 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
202 tabifyDockWidget(clipMonitorDock, recMonitorDock);
203 setCentralWidget(m_timelineArea);
205 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
206 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
208 // build effects menus
210 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
213 QStringList effects = videoEffects.effectNames();
214 QStringList effectInfo;
215 foreach(const QString &name, effects) {
216 action = new QAction(name, this);
217 effectInfo = videoEffects.effectIdInfo(ix);
218 action->setData(effectInfo);
219 videoEffectsMenu->addAction(action);
222 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
225 effects = audioEffects.effectNames();
226 foreach(const QString &name, effects) {
227 action = new QAction(name, this);
228 effectInfo = audioEffects.effectIdInfo(ix);
229 action->setData(effectInfo);
230 audioEffectsMenu->addAction(action);
233 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
234 effects = customEffects.effectNames();
235 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
236 else m_customEffectsMenu->setEnabled(true);
239 foreach(const QString &name, effects) {
240 action = new QAction(name, this);
241 effectInfo = videoEffects.effectIdInfo(ix);
242 action->setData(effectInfo);
243 m_customEffectsMenu->addAction(action);
247 QMenu *newEffect = new QMenu(this);
248 newEffect->addMenu(videoEffectsMenu);
249 newEffect->addMenu(audioEffectsMenu);
250 newEffect->addMenu(m_customEffectsMenu);
251 effectStack->setMenu(newEffect);
254 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
255 const QList<QAction *> viewActions = createPopupMenu()->actions();
256 viewMenu->insertActions(NULL, viewActions);
258 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
259 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
260 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
262 m_timelineContextMenu = new QMenu(this);
263 m_timelineContextClipMenu = new QMenu(this);
264 m_timelineContextTransitionMenu = new QMenu(this);
267 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
268 effects = transitions.effectNames();
269 foreach(const QString &name, effects) {
270 action = new QAction(name, this);
271 action->setData(name);
272 transitionsMenu->addAction(action);
274 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
276 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
278 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
279 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
280 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
281 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
282 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
284 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
285 m_timelineContextClipMenu->addMenu(markersMenu);
286 m_timelineContextClipMenu->addMenu(transitionsMenu);
287 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
288 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
289 //TODO: re-enable custom effects menu when it is implemented
290 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
292 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
293 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
295 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
296 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
297 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
298 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
299 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
300 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
302 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
303 slotConnectMonitors();
305 setAutoSaveSettings();
307 if (KdenliveSettings::openlastproject()) {
310 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
311 if (!staleFiles.isEmpty()) {
312 if (KMessageBox::questionYesNo(this, i18n("Auto-saved files exist. Do you want to recover them now?"), i18n("File Recovery"), KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
313 recoverFiles(staleFiles);
321 activateShuttleDevice();
322 projectListDock->raise();
325 void MainWindow::queryQuit() {
326 kDebug() << "----- SAVING CONFUIG";
327 if (queryClose()) kapp->quit();
331 bool MainWindow::queryClose() {
333 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
334 if (m_activeDocument && m_activeDocument->isModified()) {
335 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
336 case KMessageBox::Yes :
337 // save document here. If saving fails, return false;
340 case KMessageBox::No :
349 void MainWindow::saveProperties(KConfig*) {
350 // save properties here,used by session management
355 void MainWindow::readProperties(KConfig *config) {
356 // read properties here,used by session management
357 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
358 openFile(KUrl(Lastproject));
361 void MainWindow::slotReloadEffects() {
362 initEffects::parseCustomEffectsFile();
363 m_customEffectsMenu->clear();
364 const QStringList effects = customEffects.effectNames();
366 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
367 else m_customEffectsMenu->setEnabled(true);
369 foreach(const QString &name, effects) {
370 action = new QAction(name, this);
371 action->setData(name);
372 m_customEffectsMenu->addAction(action);
374 m_effectList->reloadEffectList();
377 void MainWindow::activateShuttleDevice() {
378 if (m_jogProcess) delete m_jogProcess;
380 if (KdenliveSettings::enableshuttle() == false) return;
381 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
382 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
383 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
384 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
385 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
386 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
387 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
390 void MainWindow::slotShuttleButton(int code) {
393 slotShuttleAction(KdenliveSettings::shuttle1());
396 slotShuttleAction(KdenliveSettings::shuttle2());
399 slotShuttleAction(KdenliveSettings::shuttle3());
402 slotShuttleAction(KdenliveSettings::shuttle4());
405 slotShuttleAction(KdenliveSettings::shuttle5());
410 void MainWindow::slotShuttleAction(int code) {
415 m_monitorManager->slotPlay();
418 m_monitorManager->slotPlay();
423 void MainWindow::configureNotifications() {
424 KNotifyConfigWidget::configure(this);
427 void MainWindow::slotFullScreen() {
428 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
431 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
432 if (!m_activeDocument) return;
433 if (effect.isNull()) {
434 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
437 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
438 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
441 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
442 if (clipMonitor) clipMonitorDock->raise();
443 else projectMonitorDock->raise();
446 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
447 if (!m_activeDocument) return;
448 m_activeDocument->setProducerDuration(id, duration);
451 void MainWindow::slotConnectMonitors() {
453 m_projectList->setRenderer(m_clipMonitor->render);
454 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
455 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
456 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
457 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
458 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 > &)));
460 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
462 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
464 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
465 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
467 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
468 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
471 void MainWindow::slotAdjustClipMonitor() {
472 clipMonitorDock->updateGeometry();
473 clipMonitorDock->adjustSize();
474 m_clipMonitor->resetSize();
477 void MainWindow::slotAdjustProjectMonitor() {
478 projectMonitorDock->updateGeometry();
479 projectMonitorDock->adjustSize();
480 m_projectMonitor->resetSize();
483 void MainWindow::setupActions() {
485 KActionCollection* collection = actionCollection();
486 m_timecodeFormat = new KComboBox(this);
487 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
488 m_timecodeFormat->addItem(i18n("Frames"));
490 statusProgressBar = new QProgressBar(this);
491 statusProgressBar->setMinimum(0);
492 statusProgressBar->setMaximum(100);
493 statusProgressBar->setMaximumWidth(150);
494 statusProgressBar->setVisible(false);
496 QWidget *w = new QWidget;
498 QHBoxLayout *layout = new QHBoxLayout;
499 w->setLayout(layout);
500 layout->setContentsMargins(5, 0, 5, 0);
501 QToolBar *toolbar = new QToolBar("statusToolBar", this);
504 m_toolGroup = new QActionGroup(this);
506 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;}";
508 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
509 m_buttonSelectTool->setCheckable(true);
510 m_buttonSelectTool->setChecked(true);
512 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
513 m_buttonRazorTool->setCheckable(true);
514 m_buttonRazorTool->setChecked(false);
516 m_toolGroup->addAction(m_buttonSelectTool);
517 m_toolGroup->addAction(m_buttonRazorTool);
518 m_toolGroup->setExclusive(true);
519 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
521 QWidget * actionWidget;
522 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
523 actionWidget->setMaximumWidth(24);
524 actionWidget->setMinimumHeight(17);
526 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
527 actionWidget->setMaximumWidth(24);
528 actionWidget->setMinimumHeight(17);
530 toolbar->setStyleSheet(style1);
531 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
533 toolbar->addSeparator();
534 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
535 m_buttonFitZoom->setCheckable(false);
536 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
538 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
539 actionWidget->setMaximumWidth(24);
540 actionWidget->setMinimumHeight(17);
542 m_zoomSlider = new QSlider(Qt::Horizontal, this);
543 m_zoomSlider->setMaximum(13);
544 m_zoomSlider->setPageStep(1);
546 m_zoomSlider->setMaximumWidth(150);
547 m_zoomSlider->setMinimumWidth(100);
549 const int contentHeight = QFontMetrics(w->font()).height() + 8;
551 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
552 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
554 m_zoomSlider->setStyleSheet(style);
556 //m_zoomSlider->height() + 5;
557 statusBar()->setMinimumHeight(contentHeight);
560 toolbar->addWidget(m_zoomSlider);
562 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
563 m_buttonVideoThumbs->setCheckable(true);
564 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
565 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
567 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
568 m_buttonAudioThumbs->setCheckable(true);
569 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
570 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
572 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
573 m_buttonShowMarkers->setCheckable(true);
574 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
575 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
577 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
578 m_buttonSnap->setCheckable(true);
579 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
580 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
581 layout->addWidget(toolbar);
584 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
585 actionWidget->setMaximumWidth(24);
586 actionWidget->setMinimumHeight(17);
588 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
589 actionWidget->setMaximumWidth(24);
590 actionWidget->setMinimumHeight(17);
592 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
593 actionWidget->setMaximumWidth(24);
594 actionWidget->setMinimumHeight(17);
596 actionWidget = toolbar->widgetForAction(m_buttonSnap);
597 actionWidget->setMaximumWidth(24);
598 actionWidget->setMinimumHeight(17);
600 m_messageLabel = new StatusBarMessageLabel(this);
601 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
603 statusBar()->addWidget(m_messageLabel, 10);
604 statusBar()->addWidget(statusProgressBar, 0);
605 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
606 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
607 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
608 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
609 m_messageLabel->hide();
611 collection->addAction("select_tool", m_buttonSelectTool);
612 collection->addAction("razor_tool", m_buttonRazorTool);
614 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
615 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
616 collection->addAction("show_markers", m_buttonShowMarkers);
617 collection->addAction("snap", m_buttonSnap);
618 collection->addAction("zoom_fit", m_buttonFitZoom);
620 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
621 collection->addAction("project_find", m_projectSearch);
622 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
623 m_projectSearch->setShortcut(Qt::Key_Slash);
625 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
626 collection->addAction("project_find_next", m_projectSearchNext);
627 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
628 m_projectSearchNext->setShortcut(Qt::Key_F3);
629 m_projectSearchNext->setEnabled(false);
631 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
632 collection->addAction("manage_profiles", profilesAction);
633 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
635 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
636 collection->addAction("project_settings", projectAction);
637 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
639 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
640 collection->addAction("project_render", projectRender);
641 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
643 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
644 KShortcut playShortcut;
645 playShortcut.setPrimary(Qt::Key_Space);
646 playShortcut.setAlternate(Qt::Key_K);
647 monitorPlay->setShortcut(playShortcut);
648 collection->addAction("monitor_play", monitorPlay);
649 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
651 KAction *markIn = collection->addAction("mark_in");
652 markIn->setText(i18n("Set In Point"));
653 markIn->setShortcut(Qt::Key_I);
654 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
656 KAction *markOut = collection->addAction("mark_out");
657 markOut->setText(i18n("Set Out Point"));
658 markOut->setShortcut(Qt::Key_O);
659 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
661 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
662 monitorSeekBackward->setShortcut(Qt::Key_J);
663 collection->addAction("monitor_seek_backward", monitorSeekBackward);
664 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
666 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
667 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
668 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
669 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
671 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
672 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
673 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
674 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
676 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
677 monitorSeekForward->setShortcut(Qt::Key_L);
678 collection->addAction("monitor_seek_forward", monitorSeekForward);
679 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
681 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
682 clipStart->setShortcut(Qt::Key_Home);
683 collection->addAction("seek_clip_start", clipStart);
684 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
686 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
687 clipEnd->setShortcut(Qt::Key_End);
688 collection->addAction("seek_clip_end", clipEnd);
689 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
691 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
692 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
693 collection->addAction("seek_start", projectStart);
694 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
696 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
697 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
698 collection->addAction("seek_end", projectEnd);
699 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
701 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
702 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
703 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
704 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
706 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
707 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
708 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
709 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
711 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
712 deleteTimelineClip->setShortcut(Qt::Key_Delete);
713 collection->addAction("delete_timeline_clip", deleteTimelineClip);
714 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
716 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
717 collection->addAction("change_clip_speed", editTimelineClipSpeed);
718 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
720 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
721 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
722 collection->addAction("cut_timeline_clip", cutTimelineClip);
723 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
725 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
726 collection->addAction("add_clip_marker", addClipMarker);
727 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
729 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
730 collection->addAction("delete_clip_marker", deleteClipMarker);
731 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
733 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
734 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
735 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
737 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
738 collection->addAction("edit_clip_marker", editClipMarker);
739 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
741 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
742 collection->addAction("add_guide", addGuide);
743 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
745 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
746 collection->addAction("delete_guide", delGuide);
747 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
749 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
750 collection->addAction("edit_guide", editGuide);
751 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
753 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
754 collection->addAction("delete_all_guides", delAllGuides);
755 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
757 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
758 collection->addAction("paste_effects", pasteEffects);
759 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
761 KStandardAction::quit(this, SLOT(queryQuit()),
764 KStandardAction::open(this, SLOT(openFile()),
767 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
770 KStandardAction::saveAs(this, SLOT(saveFileAs()),
773 KStandardAction::openNew(this, SLOT(newFile()),
776 KStandardAction::preferences(this, SLOT(slotPreferences()),
779 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
781 KStandardAction::copy(this, SLOT(slotCopy()),
784 KStandardAction::paste(this, SLOT(slotPaste()),
787 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
789 undo->setEnabled(false);
790 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
792 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
794 redo->setEnabled(false);
795 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
797 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
799 connect(collection, SIGNAL(actionHovered(QAction*)),
800 this, SLOT(slotDisplayActionMessage(QAction*)));
801 //connect(collection, SIGNAL( clearStatusText() ),
802 //statusBar(), SLOT( clear() ) );
805 void MainWindow::slotDisplayActionMessage(QAction *a) {
806 statusBar()->showMessage(a->data().toString(), 3000);
809 void MainWindow::saveOptions() {
810 KdenliveSettings::self()->writeConfig();
811 KSharedConfigPtr config = KGlobal::config();
812 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
816 void MainWindow::readOptions() {
817 KSharedConfigPtr config = KGlobal::config();
818 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
819 KConfigGroup initialGroup(config, "version");
820 if (!initialGroup.exists()) {
821 // this is our first run, show Wizard
822 Wizard *w = new Wizard(this);
823 if (w->exec() == QDialog::Accepted && w->isOk()) {
825 initialGroup.writeEntry("version", "0.7");
833 void MainWindow::newFile() {
836 QPoint projectTracks(3, 2);
837 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
839 ProjectSettings *w = new ProjectSettings;
840 if (w->exec() != QDialog::Accepted) return;
841 profileName = w->selectedProfile();
842 projectFolder = w->selectedFolder();
843 projectTracks = w->tracks();
846 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
847 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
848 TrackView *trackView = new TrackView(doc, this);
849 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
850 if (m_timelineArea->count() == 1) {
851 connectDocumentInfo(doc);
852 connectDocument(trackView, doc);
853 } else m_timelineArea->setTabBarHidden(false);
856 void MainWindow::activateDocument() {
857 if (m_timelineArea->currentWidget() == NULL) return;
858 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
859 KdenliveDoc *currentDoc = currentTab->document();
860 connectDocumentInfo(currentDoc);
861 connectDocument(currentTab, currentDoc);
864 void MainWindow::closeCurrentDocument() {
865 QWidget *w = m_timelineArea->currentWidget();
866 // closing current document
867 int ix = m_timelineArea->currentIndex() + 1;
868 if (ix == m_timelineArea->count()) ix = 0;
869 m_timelineArea->setCurrentIndex(ix);
870 TrackView *tabToClose = (TrackView *) w;
871 KdenliveDoc *docToClose = tabToClose->document();
872 if (docToClose && docToClose->isModified()) {
873 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
874 case KMessageBox::Yes :
875 // save document here. If saving fails, return false;
878 case KMessageBox::Cancel :
884 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
885 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
888 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
891 void MainWindow::saveFileAs(const QString &outputFileName) {
892 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
893 m_activeDocument->setUrl(KUrl(outputFileName));
894 if (m_activeDocument->m_autosave == NULL) {
895 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
896 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
897 setCaption(m_activeDocument->description());
898 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
899 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
900 m_activeDocument->setModified(false);
901 m_fileOpenRecent->addUrl(KUrl(outputFileName));
904 void MainWindow::saveFileAs() {
905 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
906 if (QFile::exists(outputFile)) {
907 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
909 saveFileAs(outputFile);
912 void MainWindow::saveFile() {
913 if (!m_activeDocument) return;
914 if (m_activeDocument->url().isEmpty()) {
917 saveFileAs(m_activeDocument->url().path());
918 m_activeDocument->m_autosave->resize(0);
922 void MainWindow::openFile() {
923 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
924 if (url.isEmpty()) return;
925 m_fileOpenRecent->addUrl(url);
929 void MainWindow::openLastFile() {
930 KSharedConfigPtr config = KGlobal::config();
931 KUrl::List urls = m_fileOpenRecent->urls();
932 if (urls.isEmpty()) newFile();
933 else openFile(urls.last());
936 void MainWindow::openFile(const KUrl &url) {
937 // Check for backup file
938 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
939 if (!staleFiles.isEmpty()) {
940 if (KMessageBox::questionYesNo(this,
941 i18n("Auto-saved files exist. Do you want to recover them now?"),
942 i18n("File Recovery"),
943 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
944 recoverFiles(staleFiles);
947 // remove the stale files
948 foreach(KAutoSaveFile *stale, staleFiles) {
949 stale->open(QIODevice::ReadWrite);
954 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
955 doOpenFile(url, NULL);
958 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
960 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
962 stale = new KAutoSaveFile(url, doc);
963 doc->m_autosave = stale;
965 doc->m_autosave = stale;
966 doc->setUrl(stale->managedFile());
967 doc->setModified(true);
968 stale->setParent(doc);
970 connectDocumentInfo(doc);
971 TrackView *trackView = new TrackView(doc, this);
972 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
973 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
974 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
975 slotGotProgressInfo(QString(), -1);
976 m_clipMonitor->refreshMonitor(true);
979 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
980 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
981 foreach(KAutoSaveFile *stale, staleFiles) {
982 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
983 // show an error message; we could not steal the lockfile
984 // maybe another application got to the file before us?
988 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
989 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
990 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
991 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
996 void MainWindow::parseProfiles(const QString &mltPath) {
997 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
999 //KdenliveSettings::setDefaulttmpfolder();
1000 if (!mltPath.isEmpty()) {
1001 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1002 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1005 if (KdenliveSettings::mltpath().isEmpty()) {
1006 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1008 if (KdenliveSettings::rendererpath().isEmpty()) {
1009 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1010 if (!QFile::exists(inigoPath))
1011 inigoPath = KStandardDirs::findExe("inigo");
1012 else KdenliveSettings::setRendererpath(inigoPath);
1014 QStringList profilesFilter;
1015 profilesFilter << "*";
1016 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1018 if (profilesList.isEmpty()) {
1019 // Cannot find MLT path, try finding inigo
1020 QString profilePath = KdenliveSettings::rendererpath();
1021 if (!profilePath.isEmpty()) {
1022 profilePath = profilePath.section('/', 0, -3);
1023 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1024 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1027 if (profilesList.isEmpty()) {
1028 // Cannot find the MLT profiles, ask for location
1029 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1030 getUrl->fileDialog()->setMode(KFile::Directory);
1031 if (getUrl->exec() == QDialog::Rejected) {
1034 KUrl mltPath = getUrl->selectedUrl();
1036 if (mltPath.isEmpty()) ::exit(0);
1037 KdenliveSettings::setMltpath(mltPath.path());
1038 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1042 if (KdenliveSettings::rendererpath().isEmpty()) {
1043 // Cannot find the MLT inigo renderer, ask for location
1044 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1045 if (getUrl->exec() == QDialog::Rejected) {
1048 KUrl rendererPath = getUrl->selectedUrl();
1050 if (rendererPath.isEmpty()) ::exit(0);
1051 KdenliveSettings::setRendererpath(rendererPath.path());
1054 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1056 // Parse MLT profiles to build a list of available video formats
1057 if (profilesList.isEmpty()) parseProfiles();
1061 void MainWindow::slotEditProfiles() {
1062 ProfilesDialog *w = new ProfilesDialog;
1067 void MainWindow::slotEditProjectSettings() {
1068 ProjectSettings *w = new ProjectSettings;
1069 if (w->exec() == QDialog::Accepted) {
1070 QString profile = w->selectedProfile();
1071 m_activeDocument->setProfilePath(profile);
1072 KdenliveSettings::setCurrent_profile(profile);
1073 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1074 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1075 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1076 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1077 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1079 // We need to desactivate & reactivate monitors to get a refresh
1080 m_monitorManager->switchMonitors();
1085 void MainWindow::slotRenderProject() {
1086 if (!m_renderWidget) {
1087 m_renderWidget = new RenderWidget(this);
1088 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)));
1089 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1091 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1092 if (currentTab) m_renderWidget->setTimeline(currentTab);
1093 m_renderWidget->setDocument(m_activeDocument);*/
1094 m_renderWidget->show();
1097 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) {
1098 if (dest.isEmpty()) return;
1101 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1102 if (currentTab && zoneOnly) {
1103 in = currentTab->inPoint();
1104 out = currentTab->outPoint();
1106 KTemporaryFile temp;
1107 temp.setAutoRemove(false);
1108 temp.setSuffix(".westley");
1110 m_projectMonitor->saveSceneList(temp.fileName());
1113 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1114 else if (guideStart != -1) {
1115 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1117 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1118 QString videoPlayer = "-";
1120 videoPlayer = KdenliveSettings::defaultplayerapp();
1121 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."));
1123 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1124 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1127 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1128 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1129 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1130 QProcess::startDetached(renderer, args);
1132 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1136 void MainWindow::slotUpdateMousePosition(int pos) {
1137 if (m_activeDocument)
1138 switch (m_timecodeFormat->currentIndex()) {
1140 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1143 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1147 void MainWindow::slotUpdateDocumentState(bool modified) {
1148 setCaption(m_activeDocument->description(), modified);
1149 m_saveAction->setEnabled(modified);
1151 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1152 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1154 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1155 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1159 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1160 if (m_activeDocument) {
1161 if (m_activeDocument == doc) return;
1162 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1164 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1167 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1168 //m_projectMonitor->stop();
1169 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1170 if (m_activeDocument) {
1171 if (m_activeDocument == doc) return;
1172 m_activeDocument->backupMltPlaylist();
1173 if (m_activeTimeline) {
1174 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1175 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1176 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1177 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1178 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1179 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1180 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1181 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1182 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1183 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1184 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1185 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1186 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1187 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1188 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1189 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1190 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1191 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1193 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1194 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1195 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1196 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1197 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1198 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1199 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1200 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1201 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1202 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1203 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1204 effectStack->clear();
1206 m_activeDocument->setRenderer(NULL);
1207 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1208 m_clipMonitor->stop();
1210 KdenliveSettings::setCurrent_profile(doc->profilePath());
1211 KdenliveSettings::setProject_fps(doc->fps());
1212 m_monitorManager->resetProfiles(doc->timecode());
1213 m_projectList->setDocument(doc);
1214 transitionConfig->updateProjectFormat(doc->mltProfile());
1215 effectStack->updateProjectFormat(doc->mltProfile());
1216 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1217 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1218 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1219 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1220 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1221 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1222 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1223 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1224 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1225 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1226 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1227 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1229 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1230 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1231 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1234 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1235 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1236 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1237 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1238 m_zoomSlider->setValue(doc->zoom());
1239 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1240 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1241 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1242 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1244 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1247 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1248 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1249 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1250 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1251 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1252 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1253 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1254 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1256 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1257 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1259 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1260 m_activeTimeline = trackView;
1261 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1262 doc->setRenderer(m_projectMonitor->render);
1263 m_commandStack->setActiveStack(doc->commandStack());
1264 KdenliveSettings::setProject_display_ratio(doc->dar());
1265 m_projectList->updateAllClips();
1266 trackView->projectView()->updateAllThumbs();
1267 doc->clipManager()->checkAudioThumbs();
1269 //m_overView->setScene(trackView->projectScene());
1270 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1271 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1273 setCaption(doc->description(), doc->isModified());
1274 m_saveAction->setEnabled(doc->isModified());
1275 m_activeDocument = doc;
1278 void MainWindow::slotGuidesUpdated() {
1279 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1282 void MainWindow::slotPreferences(int page, int option) {
1283 //An instance of your dialog could be already created and could be
1284 // cached, in which case you want to display the cached dialog
1285 // instead of creating another one
1286 if (KConfigDialog::showDialog("settings")) {
1287 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1291 // KConfigDialog didn't find an instance of this dialog, so lets
1293 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1294 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1295 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1297 if (page != -1) dialog->showPage(page, option);
1300 void MainWindow::updateConfiguration() {
1301 //TODO: we should apply settings to all projects, not only the current one
1302 if (m_activeTimeline) {
1303 m_activeTimeline->refresh();
1304 m_activeTimeline->projectView()->checkAutoScroll();
1305 m_activeTimeline->projectView()->checkTrackHeight();
1306 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1308 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1309 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1310 activateShuttleDevice();
1314 void MainWindow::slotSwitchVideoThumbs() {
1315 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1316 if (m_activeTimeline) {
1317 m_activeTimeline->refresh();
1319 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1322 void MainWindow::slotSwitchAudioThumbs() {
1323 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1324 if (m_activeTimeline) {
1325 m_activeTimeline->refresh();
1326 m_activeTimeline->projectView()->checkAutoScroll();
1327 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1329 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1332 void MainWindow::slotSwitchMarkersComments() {
1333 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1334 if (m_activeTimeline) {
1335 m_activeTimeline->refresh();
1337 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1340 void MainWindow::slotSwitchSnap() {
1341 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1342 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1346 void MainWindow::slotDeleteTimelineClip() {
1347 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1348 else if (m_activeTimeline) {
1349 m_activeTimeline->projectView()->deleteSelectedClips();
1353 void MainWindow::slotChangeClipSpeed() {
1354 if (m_activeTimeline) {
1355 m_activeTimeline->projectView()->changeClipSpeed();
1359 void MainWindow::slotAddClipMarker() {
1360 if (m_activeTimeline) {
1361 m_activeTimeline->projectView()->slotAddClipMarker();
1365 void MainWindow::slotDeleteClipMarker() {
1366 if (m_activeTimeline) {
1367 m_activeTimeline->projectView()->slotDeleteClipMarker();
1371 void MainWindow::slotDeleteAllClipMarkers() {
1372 if (m_activeTimeline) {
1373 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1377 void MainWindow::slotEditClipMarker() {
1378 if (m_activeTimeline) {
1379 m_activeTimeline->projectView()->slotEditClipMarker();
1383 void MainWindow::slotAddGuide() {
1384 if (m_activeTimeline)
1385 m_activeTimeline->projectView()->slotAddGuide();
1388 void MainWindow::slotEditGuide() {
1389 if (m_activeTimeline)
1390 m_activeTimeline->projectView()->slotEditGuide();
1393 void MainWindow::slotDeleteGuide() {
1394 if (m_activeTimeline)
1395 m_activeTimeline->projectView()->slotDeleteGuide();
1398 void MainWindow::slotDeleteAllGuides() {
1399 if (m_activeTimeline)
1400 m_activeTimeline->projectView()->slotDeleteAllGuides();
1403 void MainWindow::slotCutTimelineClip() {
1404 if (m_activeTimeline) {
1405 m_activeTimeline->projectView()->cutSelectedClips();
1409 void MainWindow::slotAddProjectClip(KUrl url) {
1410 if (m_activeDocument)
1411 m_activeDocument->slotAddClipFile(url, QString());
1414 void MainWindow::slotAddTransition(QAction *result) {
1415 if (!result) return;
1416 QDomElement effect = transitions.getEffectByName(result->data().toString());
1417 if (m_activeTimeline) {
1418 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1422 void MainWindow::slotAddVideoEffect(QAction *result) {
1423 if (!result) return;
1424 QStringList info = result->data().toStringList();
1425 if (info.isEmpty()) return;
1426 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1427 slotAddEffect(effect);
1430 void MainWindow::slotAddAudioEffect(QAction *result) {
1431 if (!result) return;
1432 QStringList info = result->data().toStringList();
1433 if (info.isEmpty()) return;
1434 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1435 slotAddEffect(effect);
1438 void MainWindow::slotAddCustomEffect(QAction *result) {
1439 if (!result) return;
1440 QStringList info = result->data().toStringList();
1441 if (info.isEmpty()) return;
1442 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1443 slotAddEffect(effect);
1446 void MainWindow::slotZoomIn() {
1447 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1450 void MainWindow::slotZoomOut() {
1451 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1454 void MainWindow::slotFitZoom() {
1455 if (m_activeTimeline) {
1456 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1460 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1461 statusProgressBar->setValue(progress);
1462 if (progress >= 0) {
1463 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1464 statusProgressBar->setVisible(true);
1466 m_messageLabel->setMessage(QString(), DefaultMessage);
1467 statusProgressBar->setVisible(false);
1471 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1472 if (clip->clipType() == TEXT) {
1473 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1474 QString path = clip->getProperty("resource");
1475 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1477 doc.setContent(clip->getProperty("xmldata"));
1478 dia_ui->setXml(doc);
1479 if (dia_ui->exec() == QDialog::Accepted) {
1480 QPixmap pix = dia_ui->renderedPixmap();
1482 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1483 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1484 QMap <QString, QString> newprops;
1485 newprops.insert("xmldata", dia_ui->xml().toString());
1486 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1487 m_activeDocument->commandStack()->push(command);
1488 m_clipMonitor->refreshMonitor(true);
1489 m_activeDocument->setModified(true);
1493 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1496 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1497 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1498 if (dia.exec() == QDialog::Accepted) {
1499 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1500 m_activeDocument->commandStack()->push(command);
1502 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1503 if (dia.needsTimelineRefresh()) {
1504 // update clip occurences in timeline
1505 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1510 void MainWindow::customEvent(QEvent* e) {
1511 if (e->type() == QEvent::User) {
1512 // The timeline playing position changed...
1513 kDebug() << "RECIEVED JOG EVEMNT!!!";
1516 void MainWindow::slotActivateEffectStackView() {
1517 effectStack->raiseWindow(effectStackDock);
1520 void MainWindow::slotActivateTransitionView() {
1521 transitionConfig->raiseWindow(transitionConfigDock);
1524 void MainWindow::slotSnapRewind() {
1525 if (m_projectMonitor->isActive()) {
1526 if (m_activeTimeline)
1527 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1531 void MainWindow::slotSnapForward() {
1532 if (m_projectMonitor->isActive()) {
1533 if (m_activeTimeline)
1534 m_activeTimeline->projectView()->slotSeekToNextSnap();
1538 void MainWindow::slotClipStart() {
1539 if (m_projectMonitor->isActive()) {
1540 if (m_activeTimeline)
1541 m_activeTimeline->projectView()->clipStart();
1545 void MainWindow::slotClipEnd() {
1546 if (m_projectMonitor->isActive()) {
1547 if (m_activeTimeline)
1548 m_activeTimeline->projectView()->clipEnd();
1552 void MainWindow::slotChangeTool(QAction * action) {
1553 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1554 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1557 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1558 if (m_activeDocument && m_activeTimeline) {
1559 //m_activeDocument->setTool(tool);
1560 m_activeTimeline->projectView()->setTool(tool);
1564 void MainWindow::slotCopy() {
1565 if (!m_activeDocument || !m_activeTimeline) return;
1566 m_activeTimeline->projectView()->copyClip();
1569 void MainWindow::slotPaste() {
1570 if (!m_activeDocument || !m_activeTimeline) return;
1571 m_activeTimeline->projectView()->pasteClip();
1574 void MainWindow::slotPasteEffects() {
1575 if (!m_activeDocument || !m_activeTimeline) return;
1576 m_activeTimeline->projectView()->pasteClipEffects();
1579 void MainWindow::slotFind() {
1580 if (!m_activeDocument || !m_activeTimeline) return;
1581 m_projectSearch->setEnabled(false);
1582 m_findActivated = true;
1583 m_findString = QString();
1584 m_activeTimeline->projectView()->initSearchStrings();
1585 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1586 m_findTimer.start(5000);
1587 qApp->installEventFilter(this);
1590 void MainWindow::slotFindNext() {
1591 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1592 statusBar()->showMessage(i18n("Found : %1", m_findString));
1594 statusBar()->showMessage(i18n("Reached end of project"));
1596 m_findTimer.start(4000);
1599 void MainWindow::findAhead() {
1600 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1601 m_projectSearchNext->setEnabled(true);
1602 statusBar()->showMessage(i18n("Found : %1", m_findString));
1604 m_projectSearchNext->setEnabled(false);
1605 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1609 void MainWindow::findTimeout() {
1610 m_projectSearchNext->setEnabled(false);
1611 m_findActivated = false;
1612 m_findString = QString();
1613 statusBar()->showMessage(i18n("Find stopped"), 3000);
1614 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1615 m_projectSearch->setEnabled(true);
1616 removeEventFilter(this);
1619 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1620 if (m_findActivated) {
1621 if (ke->key() == Qt::Key_Backspace) {
1622 m_findString = m_findString.left(m_findString.length() - 1);
1624 if (!m_findString.isEmpty()) {
1630 m_findTimer.start(4000);
1633 } else if (ke->key() == Qt::Key_Escape) {
1637 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1638 m_findString += ke->text();
1642 m_findTimer.start(4000);
1646 } else KXmlGuiWindow::keyPressEvent(ke);
1649 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1650 if (m_findActivated) {
1651 if (event->type() == QEvent::ShortcutOverride) {
1652 QKeyEvent* ke = (QKeyEvent*) event;
1653 if (ke->text().trimmed().isEmpty()) return false;
1656 } else return false;
1658 // pass the event on to the parent class
1659 return QMainWindow::eventFilter(obj, event);
1663 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1664 KDialog *dialog = new KDialog(this);
1665 dialog->setCaption("Save clip zone");
1666 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1668 QWidget *widget = new QWidget(dialog);
1669 dialog->setMainWidget(widget);
1671 QVBoxLayout *vbox = new QVBoxLayout(widget);
1672 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1673 QString path = m_activeDocument->projectFolder().path();
1675 path.append("untitled.westley");
1676 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1677 url->setFilter("video/mlt-playlist");
1678 QLabel *label2 = new QLabel(i18n("Description:"), this);
1679 KLineEdit *edit = new KLineEdit(this);
1680 vbox->addWidget(label1);
1681 vbox->addWidget(url);
1682 vbox->addWidget(label2);
1683 vbox->addWidget(edit);
1684 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1688 void MainWindow::slotSetInPoint() {
1689 if (m_clipMonitor->isActive()) {
1690 m_clipMonitor->slotSetZoneStart();
1691 } else m_activeTimeline->projectView()->setInPoint();
1694 void MainWindow::slotSetOutPoint() {
1695 if (m_clipMonitor->isActive()) {
1696 m_clipMonitor->slotSetZoneEnd();
1697 } else m_activeTimeline->projectView()->setOutPoint();
1700 #include "mainwindow.moc"