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));
211 QStringList effects = videoEffects.effectNames();
212 foreach(const QString &name, effects) {
213 action = new QAction(name, this);
214 action->setData(name);
215 videoEffectsMenu->addAction(action);
217 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
218 effects = audioEffects.effectNames();
219 foreach(const QString &name, effects) {
220 action = new QAction(name, this);
221 action->setData(name);
222 audioEffectsMenu->addAction(action);
224 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
225 effects = customEffects.effectNames();
226 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
227 else m_customEffectsMenu->setEnabled(true);
229 foreach(const QString &name, effects) {
230 action = new QAction(name, this);
231 action->setData(name);
232 m_customEffectsMenu->addAction(action);
235 QMenu *newEffect = new QMenu(this);
236 newEffect->addMenu(videoEffectsMenu);
237 newEffect->addMenu(audioEffectsMenu);
238 newEffect->addMenu(m_customEffectsMenu);
239 effectStack->setMenu(newEffect);
242 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
243 const QList<QAction *> viewActions = createPopupMenu()->actions();
244 viewMenu->insertActions(NULL, viewActions);
246 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
247 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
248 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
250 m_timelineContextMenu = new QMenu(this);
251 m_timelineContextClipMenu = new QMenu(this);
252 m_timelineContextTransitionMenu = new QMenu(this);
255 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
256 effects = transitions.effectNames();
257 foreach(const QString &name, effects) {
258 action = new QAction(name, this);
259 action->setData(name);
260 transitionsMenu->addAction(action);
262 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
264 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
266 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
267 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
268 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
269 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
270 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
272 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
273 m_timelineContextClipMenu->addMenu(markersMenu);
274 m_timelineContextClipMenu->addMenu(transitionsMenu);
275 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
276 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
277 //TODO: re-enable custom effects menu when it is implemented
278 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
280 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
281 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
283 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
284 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
285 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
286 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
287 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
288 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
290 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
291 slotConnectMonitors();
293 setAutoSaveSettings();
295 if (KdenliveSettings::openlastproject()) {
298 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
299 if (!staleFiles.isEmpty()) {
300 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) {
301 recoverFiles(staleFiles);
309 activateShuttleDevice();
310 projectListDock->raise();
313 void MainWindow::queryQuit() {
314 kDebug() << "----- SAVING CONFUIG";
315 if (queryClose()) kapp->quit();
319 bool MainWindow::queryClose() {
321 if (m_activeDocument && m_activeDocument->isModified()) {
322 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
323 case KMessageBox::Yes :
324 // save document here. If saving fails, return false;
327 case KMessageBox::No :
336 void MainWindow::saveProperties(KConfig*) {
337 // save properties here,used by session management
342 void MainWindow::readProperties(KConfig *config) {
343 // read properties here,used by session management
344 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
345 openFile(KUrl(Lastproject));
348 void MainWindow::slotReloadEffects() {
349 initEffects::parseCustomEffectsFile();
350 m_customEffectsMenu->clear();
351 const QStringList effects = customEffects.effectNames();
353 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
354 else m_customEffectsMenu->setEnabled(true);
356 foreach(const QString &name, effects) {
357 action = new QAction(name, this);
358 action->setData(name);
359 m_customEffectsMenu->addAction(action);
361 m_effectList->reloadEffectList();
364 void MainWindow::activateShuttleDevice() {
365 if (m_jogProcess) delete m_jogProcess;
367 if (KdenliveSettings::enableshuttle() == false) return;
368 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
369 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
370 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
371 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
372 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
373 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
374 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
377 void MainWindow::slotShuttleButton(int code) {
380 slotShuttleAction(KdenliveSettings::shuttle1());
383 slotShuttleAction(KdenliveSettings::shuttle2());
386 slotShuttleAction(KdenliveSettings::shuttle3());
389 slotShuttleAction(KdenliveSettings::shuttle4());
392 slotShuttleAction(KdenliveSettings::shuttle5());
397 void MainWindow::slotShuttleAction(int code) {
402 m_monitorManager->slotPlay();
405 m_monitorManager->slotPlay();
410 void MainWindow::configureNotifications() {
411 KNotifyConfigWidget::configure(this);
414 void MainWindow::slotFullScreen() {
415 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
418 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
419 if (!m_activeDocument) return;
420 if (effect.isNull()) {
421 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
424 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
425 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
428 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
429 if (clipMonitor) clipMonitorDock->raise();
430 else projectMonitorDock->raise();
433 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
434 if (!m_activeDocument) return;
435 m_activeDocument->setProducerDuration(id, duration);
438 void MainWindow::slotConnectMonitors() {
440 m_projectList->setRenderer(m_clipMonitor->render);
441 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
442 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
443 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
444 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
445 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 > &)));
447 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
449 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
451 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
452 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
454 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
455 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
458 void MainWindow::slotAdjustClipMonitor() {
459 clipMonitorDock->updateGeometry();
460 clipMonitorDock->adjustSize();
461 m_clipMonitor->resetSize();
464 void MainWindow::slotAdjustProjectMonitor() {
465 projectMonitorDock->updateGeometry();
466 projectMonitorDock->adjustSize();
467 m_projectMonitor->resetSize();
470 void MainWindow::setupActions() {
472 KActionCollection* collection = actionCollection();
473 m_timecodeFormat = new KComboBox(this);
474 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
475 m_timecodeFormat->addItem(i18n("Frames"));
477 statusProgressBar = new QProgressBar(this);
478 statusProgressBar->setMinimum(0);
479 statusProgressBar->setMaximum(100);
480 statusProgressBar->setMaximumWidth(150);
481 statusProgressBar->setVisible(false);
483 QWidget *w = new QWidget;
485 QHBoxLayout *layout = new QHBoxLayout;
486 w->setLayout(layout);
487 layout->setContentsMargins(5, 0, 5, 0);
488 QToolBar *toolbar = new QToolBar("statusToolBar", this);
491 m_toolGroup = new QActionGroup(this);
493 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;}";
495 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
496 m_buttonSelectTool->setCheckable(true);
497 m_buttonSelectTool->setChecked(true);
499 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
500 m_buttonRazorTool->setCheckable(true);
501 m_buttonRazorTool->setChecked(false);
503 m_toolGroup->addAction(m_buttonSelectTool);
504 m_toolGroup->addAction(m_buttonRazorTool);
505 m_toolGroup->setExclusive(true);
506 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
508 QWidget * actionWidget;
509 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
510 actionWidget->setMaximumWidth(24);
511 actionWidget->setMinimumHeight(17);
513 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
514 actionWidget->setMaximumWidth(24);
515 actionWidget->setMinimumHeight(17);
517 toolbar->setStyleSheet(style1);
518 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
520 toolbar->addSeparator();
521 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
522 m_buttonFitZoom->setCheckable(false);
523 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
525 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
526 actionWidget->setMaximumWidth(24);
527 actionWidget->setMinimumHeight(17);
529 m_zoomSlider = new QSlider(Qt::Horizontal, this);
530 m_zoomSlider->setMaximum(13);
531 m_zoomSlider->setPageStep(1);
533 m_zoomSlider->setMaximumWidth(150);
534 m_zoomSlider->setMinimumWidth(100);
536 const int contentHeight = QFontMetrics(w->font()).height() + 8;
538 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
539 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
541 m_zoomSlider->setStyleSheet(style);
543 //m_zoomSlider->height() + 5;
544 statusBar()->setMinimumHeight(contentHeight);
547 toolbar->addWidget(m_zoomSlider);
549 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
550 m_buttonVideoThumbs->setCheckable(true);
551 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
552 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
554 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
555 m_buttonAudioThumbs->setCheckable(true);
556 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
557 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
559 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
560 m_buttonShowMarkers->setCheckable(true);
561 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
562 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
564 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
565 m_buttonSnap->setCheckable(true);
566 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
567 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
568 layout->addWidget(toolbar);
571 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
572 actionWidget->setMaximumWidth(24);
573 actionWidget->setMinimumHeight(17);
575 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
576 actionWidget->setMaximumWidth(24);
577 actionWidget->setMinimumHeight(17);
579 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
580 actionWidget->setMaximumWidth(24);
581 actionWidget->setMinimumHeight(17);
583 actionWidget = toolbar->widgetForAction(m_buttonSnap);
584 actionWidget->setMaximumWidth(24);
585 actionWidget->setMinimumHeight(17);
587 m_messageLabel = new StatusBarMessageLabel(this);
588 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
590 statusBar()->addWidget(m_messageLabel, 10);
591 statusBar()->addWidget(statusProgressBar, 0);
592 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
593 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
594 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
595 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
596 m_messageLabel->hide();
598 collection->addAction("select_tool", m_buttonSelectTool);
599 collection->addAction("razor_tool", m_buttonRazorTool);
601 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
602 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
603 collection->addAction("show_markers", m_buttonShowMarkers);
604 collection->addAction("snap", m_buttonSnap);
605 collection->addAction("zoom_fit", m_buttonFitZoom);
607 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
608 collection->addAction("project_find", m_projectSearch);
609 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
610 m_projectSearch->setShortcut(Qt::Key_Slash);
612 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
613 collection->addAction("project_find_next", m_projectSearchNext);
614 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
615 m_projectSearchNext->setShortcut(Qt::Key_F3);
616 m_projectSearchNext->setEnabled(false);
618 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
619 collection->addAction("manage_profiles", profilesAction);
620 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
622 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
623 collection->addAction("project_settings", projectAction);
624 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
626 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
627 collection->addAction("project_render", projectRender);
628 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
630 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
631 KShortcut playShortcut;
632 playShortcut.setPrimary(Qt::Key_Space);
633 playShortcut.setAlternate(Qt::Key_K);
634 monitorPlay->setShortcut(playShortcut);
635 collection->addAction("monitor_play", monitorPlay);
636 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
638 KAction *markIn = collection->addAction("mark_in");
639 markIn->setText(i18n("Set In Point"));
640 markIn->setShortcut(Qt::Key_I);
641 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
643 KAction *markOut = collection->addAction("mark_out");
644 markOut->setText(i18n("Set Out Point"));
645 markOut->setShortcut(Qt::Key_O);
646 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
648 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
649 monitorSeekBackward->setShortcut(Qt::Key_J);
650 collection->addAction("monitor_seek_backward", monitorSeekBackward);
651 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
653 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
654 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
655 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
656 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
658 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
659 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
660 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
661 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
663 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
664 monitorSeekForward->setShortcut(Qt::Key_L);
665 collection->addAction("monitor_seek_forward", monitorSeekForward);
666 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
668 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
669 clipStart->setShortcut(Qt::Key_Home);
670 collection->addAction("seek_clip_start", clipStart);
671 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
673 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
674 clipEnd->setShortcut(Qt::Key_End);
675 collection->addAction("seek_clip_end", clipEnd);
676 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
678 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
679 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
680 collection->addAction("seek_start", projectStart);
681 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
683 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
684 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
685 collection->addAction("seek_end", projectEnd);
686 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
688 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
689 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
690 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
691 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
693 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
694 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
695 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
696 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
698 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
699 deleteTimelineClip->setShortcut(Qt::Key_Delete);
700 collection->addAction("delete_timeline_clip", deleteTimelineClip);
701 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
703 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
704 collection->addAction("change_clip_speed", editTimelineClipSpeed);
705 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
707 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
708 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
709 collection->addAction("cut_timeline_clip", cutTimelineClip);
710 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
712 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
713 collection->addAction("add_clip_marker", addClipMarker);
714 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
716 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
717 collection->addAction("delete_clip_marker", deleteClipMarker);
718 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
720 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
721 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
722 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
724 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
725 collection->addAction("edit_clip_marker", editClipMarker);
726 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
728 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
729 collection->addAction("add_guide", addGuide);
730 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
732 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
733 collection->addAction("delete_guide", delGuide);
734 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
736 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
737 collection->addAction("edit_guide", editGuide);
738 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
740 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
741 collection->addAction("delete_all_guides", delAllGuides);
742 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
744 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
745 collection->addAction("paste_effects", pasteEffects);
746 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
748 KStandardAction::quit(this, SLOT(queryQuit()),
751 KStandardAction::open(this, SLOT(openFile()),
754 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
757 KStandardAction::saveAs(this, SLOT(saveFileAs()),
760 KStandardAction::openNew(this, SLOT(newFile()),
763 KStandardAction::preferences(this, SLOT(slotPreferences()),
766 KStandardAction::configureNotifications(this , SLOT(configureNotifications()) , collection);
768 KStandardAction::copy(this, SLOT(slotCopy()),
771 KStandardAction::paste(this, SLOT(slotPaste()),
774 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
776 undo->setEnabled(false);
777 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
779 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
781 redo->setEnabled(false);
782 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
784 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
786 connect(collection, SIGNAL(actionHovered(QAction*)),
787 this, SLOT(slotDisplayActionMessage(QAction*)));
788 //connect(collection, SIGNAL( clearStatusText() ),
789 //statusBar(), SLOT( clear() ) );
792 void MainWindow::slotDisplayActionMessage(QAction *a) {
793 statusBar()->showMessage(a->data().toString(), 3000);
796 void MainWindow::saveOptions() {
797 KdenliveSettings::self()->writeConfig();
798 KSharedConfigPtr config = KGlobal::config();
799 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
803 void MainWindow::readOptions() {
804 KSharedConfigPtr config = KGlobal::config();
805 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
806 KConfigGroup initialGroup(config, "version");
807 if (!initialGroup.exists()) {
808 // this is our first run, show Wizard
809 Wizard *w = new Wizard(this);
810 if (w->exec() == QDialog::Accepted && w->isOk()) {
812 initialGroup.writeEntry("version", "0.7");
820 void MainWindow::newFile() {
823 QPoint projectTracks(3, 2);
824 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
826 ProjectSettings *w = new ProjectSettings;
827 if (w->exec() != QDialog::Accepted) return;
828 profileName = w->selectedProfile();
829 projectFolder = w->selectedFolder();
830 projectTracks = w->tracks();
833 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, this);
834 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
835 TrackView *trackView = new TrackView(doc, this);
836 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
837 if (m_timelineArea->count() == 1) {
838 connectDocumentInfo(doc);
839 connectDocument(trackView, doc);
840 } else m_timelineArea->setTabBarHidden(false);
843 void MainWindow::activateDocument() {
844 if (m_timelineArea->currentWidget() == NULL) return;
845 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
846 KdenliveDoc *currentDoc = currentTab->document();
847 connectDocumentInfo(currentDoc);
848 connectDocument(currentTab, currentDoc);
851 void MainWindow::closeCurrentDocument() {
852 QWidget *w = m_timelineArea->currentWidget();
853 // closing current document
854 int ix = m_timelineArea->currentIndex() + 1;
855 if (ix == m_timelineArea->count()) ix = 0;
856 m_timelineArea->setCurrentIndex(ix);
857 TrackView *tabToClose = (TrackView *) w;
858 KdenliveDoc *docToClose = tabToClose->document();
859 if (docToClose && docToClose->isModified()) {
860 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
861 case KMessageBox::Yes :
862 // save document here. If saving fails, return false;
865 case KMessageBox::Cancel :
871 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
872 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
875 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
878 void MainWindow::saveFileAs(const QString &outputFileName) {
879 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
880 m_activeDocument->setUrl(KUrl(outputFileName));
881 if (m_activeDocument->m_autosave == NULL) {
882 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
883 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
884 setCaption(m_activeDocument->description());
885 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
886 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
887 m_activeDocument->setModified(false);
888 m_fileOpenRecent->addUrl(KUrl(outputFileName));
891 void MainWindow::saveFileAs() {
892 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
893 if (QFile::exists(outputFile)) {
894 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
896 saveFileAs(outputFile);
899 void MainWindow::saveFile() {
900 if (!m_activeDocument) return;
901 if (m_activeDocument->url().isEmpty()) {
904 saveFileAs(m_activeDocument->url().path());
905 m_activeDocument->m_autosave->resize(0);
909 void MainWindow::openFile() {
910 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
911 if (url.isEmpty()) return;
912 m_fileOpenRecent->addUrl(url);
916 void MainWindow::openLastFile() {
917 KSharedConfigPtr config = KGlobal::config();
918 KUrl::List urls = m_fileOpenRecent->urls();
919 if (urls.isEmpty()) newFile();
920 else openFile(urls.last());
923 void MainWindow::openFile(const KUrl &url) {
924 // Check for backup file
925 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
926 if (!staleFiles.isEmpty()) {
927 if (KMessageBox::questionYesNo(this,
928 i18n("Auto-saved files exist. Do you want to recover them now?"),
929 i18n("File Recovery"),
930 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
931 recoverFiles(staleFiles);
934 // remove the stale files
935 foreach(KAutoSaveFile *stale, staleFiles) {
936 stale->open(QIODevice::ReadWrite);
941 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
942 doOpenFile(url, NULL);
945 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
947 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), this);
949 stale = new KAutoSaveFile(url, doc);
950 doc->m_autosave = stale;
952 doc->m_autosave = stale;
953 doc->setUrl(stale->managedFile());
954 doc->setModified(true);
955 stale->setParent(doc);
957 connectDocumentInfo(doc);
958 TrackView *trackView = new TrackView(doc, this);
959 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
960 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
961 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
962 slotGotProgressInfo(QString(), -1);
963 m_clipMonitor->refreshMonitor(true);
966 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
967 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
968 foreach(KAutoSaveFile *stale, staleFiles) {
969 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
970 // show an error message; we could not steal the lockfile
971 // maybe another application got to the file before us?
975 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
976 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
977 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
978 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
983 void MainWindow::parseProfiles(const QString &mltPath) {
984 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
986 //KdenliveSettings::setDefaulttmpfolder();
987 if (!mltPath.isEmpty()) {
988 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
989 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
992 if (KdenliveSettings::mltpath().isEmpty()) {
993 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
995 if (KdenliveSettings::rendererpath().isEmpty()) {
996 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
997 if (!QFile::exists(inigoPath))
998 inigoPath = KStandardDirs::findExe("inigo");
999 else KdenliveSettings::setRendererpath(inigoPath);
1001 QStringList profilesFilter;
1002 profilesFilter << "*";
1003 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1005 if (profilesList.isEmpty()) {
1006 // Cannot find MLT path, try finding inigo
1007 QString profilePath = KdenliveSettings::rendererpath();
1008 if (!profilePath.isEmpty()) {
1009 profilePath = profilePath.section('/', 0, -3);
1010 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1011 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1014 if (profilesList.isEmpty()) {
1015 // Cannot find the MLT profiles, ask for location
1016 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1017 getUrl->fileDialog()->setMode(KFile::Directory);
1018 if (getUrl->exec() == QDialog::Rejected) {
1021 KUrl mltPath = getUrl->selectedUrl();
1023 if (mltPath.isEmpty()) ::exit(0);
1024 KdenliveSettings::setMltpath(mltPath.path());
1025 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1029 if (KdenliveSettings::rendererpath().isEmpty()) {
1030 // Cannot find the MLT inigo renderer, ask for location
1031 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1032 if (getUrl->exec() == QDialog::Rejected) {
1035 KUrl rendererPath = getUrl->selectedUrl();
1037 if (rendererPath.isEmpty()) ::exit(0);
1038 KdenliveSettings::setRendererpath(rendererPath.path());
1041 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1043 // Parse MLT profiles to build a list of available video formats
1044 if (profilesList.isEmpty()) parseProfiles();
1048 void MainWindow::slotEditProfiles() {
1049 ProfilesDialog *w = new ProfilesDialog;
1054 void MainWindow::slotEditProjectSettings() {
1055 ProjectSettings *w = new ProjectSettings;
1056 if (w->exec() == QDialog::Accepted) {
1057 QString profile = w->selectedProfile();
1058 m_activeDocument->setProfilePath(profile);
1059 KdenliveSettings::setCurrent_profile(profile);
1060 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1061 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1062 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1063 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1064 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1066 // We need to desactivate & reactivate monitors to get a refresh
1067 m_monitorManager->switchMonitors();
1072 void MainWindow::slotRenderProject() {
1073 if (!m_renderWidget) {
1074 m_renderWidget = new RenderWidget(this);
1075 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)));
1076 if (m_activeDocument) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1078 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1079 if (currentTab) m_renderWidget->setTimeline(currentTab);
1080 m_renderWidget->setDocument(m_activeDocument);*/
1081 m_renderWidget->show();
1084 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) {
1085 if (dest.isEmpty()) return;
1088 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1089 if (currentTab && zoneOnly) {
1090 in = currentTab->inPoint();
1091 out = currentTab->outPoint();
1093 KTemporaryFile temp;
1094 temp.setAutoRemove(false);
1095 temp.setSuffix(".westley");
1097 m_projectMonitor->saveSceneList(temp.fileName());
1100 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1101 else if (guideStart != -1) {
1102 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1104 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1105 QString videoPlayer = "-";
1107 videoPlayer = KdenliveSettings::defaultplayerapp();
1108 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."));
1110 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1111 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1114 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1115 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1116 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1117 QProcess::startDetached(renderer, args);
1119 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1123 void MainWindow::slotUpdateMousePosition(int pos) {
1124 if (m_activeDocument)
1125 switch (m_timecodeFormat->currentIndex()) {
1127 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1130 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1134 void MainWindow::slotUpdateDocumentState(bool modified) {
1135 setCaption(m_activeDocument->description(), modified);
1136 m_saveAction->setEnabled(modified);
1138 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1139 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1141 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1142 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1146 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1147 if (m_activeDocument) {
1148 if (m_activeDocument == doc) return;
1149 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1151 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1154 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1155 //m_projectMonitor->stop();
1156 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1157 if (m_activeDocument) {
1158 if (m_activeDocument == doc) return;
1159 m_activeDocument->backupMltPlaylist();
1160 if (m_activeTimeline) {
1161 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1162 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1163 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1164 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1165 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1166 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1167 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1168 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1169 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1170 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1171 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1172 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1173 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1174 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1175 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1176 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1177 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1178 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1180 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1181 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1182 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1183 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1184 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1185 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1186 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1187 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1188 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1189 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1190 disconnect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1191 effectStack->clear();
1193 m_activeDocument->setRenderer(NULL);
1194 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1195 m_clipMonitor->stop();
1197 KdenliveSettings::setCurrent_profile(doc->profilePath());
1198 KdenliveSettings::setProject_fps(doc->fps());
1199 m_monitorManager->resetProfiles(doc->timecode());
1200 m_projectList->setDocument(doc);
1201 transitionConfig->updateProjectFormat(doc->mltProfile());
1202 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1203 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1204 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1205 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1206 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1207 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1208 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1209 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1210 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1211 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1212 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1213 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1215 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1216 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1217 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1220 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1221 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1222 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1223 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1224 m_zoomSlider->setValue(doc->zoom());
1225 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1226 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1227 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1228 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1230 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1233 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1234 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1235 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1236 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1237 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1238 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1239 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1240 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1242 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1243 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1245 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1246 m_activeTimeline = trackView;
1247 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1248 doc->setRenderer(m_projectMonitor->render);
1249 m_commandStack->setActiveStack(doc->commandStack());
1250 KdenliveSettings::setProject_display_ratio(doc->dar());
1251 m_projectList->updateAllClips();
1252 trackView->projectView()->updateAllThumbs();
1255 //m_overView->setScene(trackView->projectScene());
1256 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1257 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1259 setCaption(doc->description(), doc->isModified());
1260 m_saveAction->setEnabled(doc->isModified());
1261 m_activeDocument = doc;
1264 void MainWindow::slotGuidesUpdated() {
1265 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1268 void MainWindow::slotPreferences(int page, int option) {
1269 //An instance of your dialog could be already created and could be
1270 // cached, in which case you want to display the cached dialog
1271 // instead of creating another one
1272 if (KConfigDialog::showDialog("settings")) {
1273 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1277 // KConfigDialog didn't find an instance of this dialog, so lets
1279 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1280 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1281 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1283 if (page != -1) dialog->showPage(page, option);
1286 void MainWindow::updateConfiguration() {
1287 //TODO: we should apply settings to all projects, not only the current one
1288 if (m_activeTimeline) {
1289 m_activeTimeline->refresh();
1290 m_activeTimeline->projectView()->checkAutoScroll();
1291 m_activeTimeline->projectView()->checkTrackHeight();
1292 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1294 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1295 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1296 activateShuttleDevice();
1300 void MainWindow::slotSwitchVideoThumbs() {
1301 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1302 if (m_activeTimeline) {
1303 m_activeTimeline->refresh();
1305 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1308 void MainWindow::slotSwitchAudioThumbs() {
1309 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1310 if (m_activeTimeline) {
1311 m_activeTimeline->refresh();
1312 m_activeTimeline->projectView()->checkAutoScroll();
1313 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1315 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1318 void MainWindow::slotSwitchMarkersComments() {
1319 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1320 if (m_activeTimeline) {
1321 m_activeTimeline->refresh();
1323 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1326 void MainWindow::slotSwitchSnap() {
1327 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1328 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1332 void MainWindow::slotDeleteTimelineClip() {
1333 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1334 else if (m_activeTimeline) {
1335 m_activeTimeline->projectView()->deleteSelectedClips();
1339 void MainWindow::slotChangeClipSpeed() {
1340 if (m_activeTimeline) {
1341 m_activeTimeline->projectView()->changeClipSpeed();
1345 void MainWindow::slotAddClipMarker() {
1346 if (m_activeTimeline) {
1347 m_activeTimeline->projectView()->slotAddClipMarker();
1351 void MainWindow::slotDeleteClipMarker() {
1352 if (m_activeTimeline) {
1353 m_activeTimeline->projectView()->slotDeleteClipMarker();
1357 void MainWindow::slotDeleteAllClipMarkers() {
1358 if (m_activeTimeline) {
1359 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1363 void MainWindow::slotEditClipMarker() {
1364 if (m_activeTimeline) {
1365 m_activeTimeline->projectView()->slotEditClipMarker();
1369 void MainWindow::slotAddGuide() {
1370 if (m_activeTimeline)
1371 m_activeTimeline->projectView()->slotAddGuide();
1374 void MainWindow::slotEditGuide() {
1375 if (m_activeTimeline)
1376 m_activeTimeline->projectView()->slotEditGuide();
1379 void MainWindow::slotDeleteGuide() {
1380 if (m_activeTimeline)
1381 m_activeTimeline->projectView()->slotDeleteGuide();
1384 void MainWindow::slotDeleteAllGuides() {
1385 if (m_activeTimeline)
1386 m_activeTimeline->projectView()->slotDeleteAllGuides();
1389 void MainWindow::slotCutTimelineClip() {
1390 if (m_activeTimeline) {
1391 m_activeTimeline->projectView()->cutSelectedClips();
1395 void MainWindow::slotAddProjectClip(KUrl url) {
1396 if (m_activeDocument)
1397 m_activeDocument->slotAddClipFile(url, QString());
1400 void MainWindow::slotAddTransition(QAction *result) {
1401 if (!result) return;
1402 QDomElement effect = transitions.getEffectByName(result->data().toString());
1403 if (m_activeTimeline) {
1404 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1408 void MainWindow::slotAddVideoEffect(QAction *result) {
1409 if (!result) return;
1410 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1411 slotAddEffect(effect);
1414 void MainWindow::slotAddAudioEffect(QAction *result) {
1415 if (!result) return;
1416 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1417 slotAddEffect(effect);
1420 void MainWindow::slotAddCustomEffect(QAction *result) {
1421 if (!result) return;
1422 if (result->data().toString().isEmpty()) return;
1423 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1424 slotAddEffect(effect);
1427 void MainWindow::slotZoomIn() {
1428 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1431 void MainWindow::slotZoomOut() {
1432 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1435 void MainWindow::slotFitZoom() {
1436 if (m_activeTimeline) {
1437 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1441 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1442 statusProgressBar->setValue(progress);
1443 if (progress >= 0) {
1444 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1445 statusProgressBar->setVisible(true);
1447 m_messageLabel->setMessage(QString(), DefaultMessage);
1448 statusProgressBar->setVisible(false);
1452 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1453 if (clip->clipType() == TEXT) {
1454 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1455 QString path = clip->getProperty("resource");
1456 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1458 doc.setContent(clip->getProperty("xmldata"));
1459 dia_ui->setXml(doc);
1460 if (dia_ui->exec() == QDialog::Accepted) {
1461 QPixmap pix = dia_ui->renderedPixmap();
1463 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1464 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1465 QMap <QString, QString> newprops;
1466 newprops.insert("xmldata", dia_ui->xml().toString());
1467 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1468 m_activeDocument->commandStack()->push(command);
1469 m_clipMonitor->refreshMonitor(true);
1470 m_activeDocument->setModified(true);
1474 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1477 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1478 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1479 if (dia.exec() == QDialog::Accepted) {
1480 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1481 m_activeDocument->commandStack()->push(command);
1483 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1484 if (dia.needsTimelineRefresh()) {
1485 // update clip occurences in timeline
1486 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1491 void MainWindow::customEvent(QEvent* e) {
1492 if (e->type() == QEvent::User) {
1493 // The timeline playing position changed...
1494 kDebug() << "RECIEVED JOG EVEMNT!!!";
1497 void MainWindow::slotActivateEffectStackView() {
1498 effectStack->raiseWindow(effectStackDock);
1501 void MainWindow::slotActivateTransitionView() {
1502 transitionConfig->raiseWindow(transitionConfigDock);
1505 void MainWindow::slotSnapRewind() {
1506 if (m_projectMonitor->isActive()) {
1507 if (m_activeTimeline)
1508 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1512 void MainWindow::slotSnapForward() {
1513 if (m_projectMonitor->isActive()) {
1514 if (m_activeTimeline)
1515 m_activeTimeline->projectView()->slotSeekToNextSnap();
1519 void MainWindow::slotClipStart() {
1520 if (m_projectMonitor->isActive()) {
1521 if (m_activeTimeline)
1522 m_activeTimeline->projectView()->clipStart();
1526 void MainWindow::slotClipEnd() {
1527 if (m_projectMonitor->isActive()) {
1528 if (m_activeTimeline)
1529 m_activeTimeline->projectView()->clipEnd();
1533 void MainWindow::slotChangeTool(QAction * action) {
1534 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1535 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1538 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1539 if (m_activeDocument && m_activeTimeline) {
1540 //m_activeDocument->setTool(tool);
1541 m_activeTimeline->projectView()->setTool(tool);
1545 void MainWindow::slotCopy() {
1546 if (!m_activeDocument || !m_activeTimeline) return;
1547 m_activeTimeline->projectView()->copyClip();
1550 void MainWindow::slotPaste() {
1551 if (!m_activeDocument || !m_activeTimeline) return;
1552 m_activeTimeline->projectView()->pasteClip();
1555 void MainWindow::slotPasteEffects() {
1556 if (!m_activeDocument || !m_activeTimeline) return;
1557 m_activeTimeline->projectView()->pasteClipEffects();
1560 void MainWindow::slotFind() {
1561 if (!m_activeDocument || !m_activeTimeline) return;
1562 m_projectSearch->setEnabled(false);
1563 m_findActivated = true;
1564 m_findString = QString();
1565 m_activeTimeline->projectView()->initSearchStrings();
1566 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1567 m_findTimer.start(5000);
1568 qApp->installEventFilter(this);
1571 void MainWindow::slotFindNext() {
1572 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1573 statusBar()->showMessage(i18n("Found : %1", m_findString));
1575 statusBar()->showMessage(i18n("Reached end of project"));
1577 m_findTimer.start(4000);
1580 void MainWindow::findAhead() {
1581 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1582 m_projectSearchNext->setEnabled(true);
1583 statusBar()->showMessage(i18n("Found : %1", m_findString));
1585 m_projectSearchNext->setEnabled(false);
1586 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1590 void MainWindow::findTimeout() {
1591 m_projectSearchNext->setEnabled(false);
1592 m_findActivated = false;
1593 m_findString = QString();
1594 statusBar()->showMessage(i18n("Find stopped"), 3000);
1595 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1596 m_projectSearch->setEnabled(true);
1597 removeEventFilter(this);
1600 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1601 if (m_findActivated) {
1602 if (ke->key() == Qt::Key_Backspace) {
1603 m_findString = m_findString.left(m_findString.length() - 1);
1605 if (!m_findString.isEmpty()) {
1611 m_findTimer.start(4000);
1614 } else if (ke->key() == Qt::Key_Escape) {
1618 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1619 m_findString += ke->text();
1623 m_findTimer.start(4000);
1627 } else KXmlGuiWindow::keyPressEvent(ke);
1630 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1631 if (m_findActivated) {
1632 if (event->type() == QEvent::ShortcutOverride) {
1633 QKeyEvent* ke = (QKeyEvent*) event;
1634 if (ke->text().trimmed().isEmpty()) return false;
1637 } else return false;
1639 // pass the event on to the parent class
1640 return QMainWindow::eventFilter(obj, event);
1644 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
1645 KDialog *dialog = new KDialog(this);
1646 dialog->setCaption("Save clip zone");
1647 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
1649 QWidget *widget = new QWidget(dialog);
1650 dialog->setMainWidget(widget);
1652 QVBoxLayout *vbox = new QVBoxLayout(widget);
1653 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
1654 QString path = m_activeDocument->projectFolder().path();
1656 path.append("untitled.westley");
1657 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
1658 url->setFilter("video/mlt-playlist");
1659 QLabel *label2 = new QLabel(i18n("Description:"), this);
1660 KLineEdit *edit = new KLineEdit(this);
1661 vbox->addWidget(label1);
1662 vbox->addWidget(url);
1663 vbox->addWidget(label2);
1664 vbox->addWidget(edit);
1665 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
1669 void MainWindow::slotSetInPoint() {
1670 if (m_clipMonitor->isActive()) {
1671 m_clipMonitor->slotSetZoneStart();
1672 } else m_activeTimeline->projectView()->setInPoint();
1675 void MainWindow::slotSetOutPoint() {
1676 if (m_clipMonitor->isActive()) {
1677 m_clipMonitor->slotSetZoneEnd();
1678 } else m_activeTimeline->projectView()->setOutPoint();
1681 #include "mainwindow.moc"