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>
54 #include <knewstuff2/engine.h>
55 #include <knewstuff2/ui/knewstuffaction.h>
57 #include "mainwindow.h"
58 #include "kdenlivesettings.h"
59 #include "kdenlivesettingsdialog.h"
60 #include "initeffects.h"
61 #include "profilesdialog.h"
62 #include "projectsettings.h"
64 #include "clipmanager.h"
65 #include "projectlist.h"
67 #include "recmonitor.h"
68 #include "monitormanager.h"
69 #include "kdenlivedoc.h"
70 #include "trackview.h"
71 #include "customtrackview.h"
72 #include "effectslistview.h"
73 #include "effectstackview.h"
74 #include "transitionsettings.h"
75 #include "renderwidget.h"
78 #include "jogshuttle.h"
79 #endif /* NO_JOGSHUTTLE */
80 #include "clipproperties.h"
82 #include "editclipcommand.h"
83 #include "titlewidget.h"
84 #include "markerdialog.h"
87 static const int ID_STATUS_MSG = 1;
88 static const int ID_EDITMODE_MSG = 2;
89 static const int ID_TIMELINE_MSG = 3;
90 static const int ID_TIMELINE_BUTTONS = 5;
91 static const int ID_TIMELINE_POS = 6;
92 static const int ID_TIMELINE_FORMAT = 7;
98 EffectsList MainWindow::videoEffects;
99 EffectsList MainWindow::audioEffects;
100 EffectsList MainWindow::customEffects;
101 EffectsList MainWindow::transitions;
103 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent)
104 : KXmlGuiWindow(parent),
105 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL),
106 #ifndef NO_JOGSHUTTLE
108 #endif /* NO_JOGSHUTTLE */
109 m_findActivated(false), m_initialized(false) {
110 setlocale(LC_NUMERIC, "POSIX");
111 setFont(KGlobalSettings::toolBarFont());
112 parseProfiles(MltPath);
113 m_commandStack = new QUndoGroup;
114 m_timelineArea = new KTabWidget(this);
115 m_timelineArea->setTabReorderingEnabled(true);
116 m_timelineArea->setTabBarHidden(true);
118 QToolButton *closeTabButton = new QToolButton;
119 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
120 closeTabButton->setIcon(KIcon("tab-close"));
121 closeTabButton->adjustSize();
122 closeTabButton->setToolTip(i18n("Close the current tab"));
123 m_timelineArea->setCornerWidget(closeTabButton);
124 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
126 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
127 m_findTimer.setSingleShot(true);
129 initEffects::parseEffectFiles();
130 //initEffects::parseCustomEffectsFile();
132 m_monitorManager = new MonitorManager();
134 projectListDock = new QDockWidget(i18n("Project Tree"), this);
135 projectListDock->setObjectName("project_tree");
136 m_projectList = new ProjectList(this);
137 projectListDock->setWidget(m_projectList);
138 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
140 effectListDock = new QDockWidget(i18n("Effect List"), this);
141 effectListDock->setObjectName("effect_list");
142 m_effectList = new EffectsListView();
144 //m_effectList = new KListWidget(this);
145 effectListDock->setWidget(m_effectList);
146 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
148 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
149 effectStackDock->setObjectName("effect_stack");
150 effectStack = new EffectStackView(this);
151 effectStackDock->setWidget(effectStack);
152 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
154 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
155 transitionConfigDock->setObjectName("transition");
156 transitionConfig = new TransitionSettings(this);
157 transitionConfigDock->setWidget(transitionConfig);
158 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
160 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
161 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
165 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
166 clipMonitorDock->setObjectName("clip_monitor");
167 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
168 clipMonitorDock->setWidget(m_clipMonitor);
169 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
170 //m_clipMonitor->stop();
172 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
173 projectMonitorDock->setObjectName("project_monitor");
174 m_projectMonitor = new Monitor("project", m_monitorManager, this);
175 projectMonitorDock->setWidget(m_projectMonitor);
176 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
178 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
179 recMonitorDock->setObjectName("record_monitor");
180 m_recMonitor = new RecMonitor("record", this);
181 recMonitorDock->setWidget(m_recMonitor);
182 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
184 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
185 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
187 undoViewDock = new QDockWidget(i18n("Undo History"), this);
188 undoViewDock->setObjectName("undo_history");
189 m_undoView = new QUndoView(this);
190 m_undoView->setCleanIcon(KIcon("edit-clear"));
191 m_undoView->setEmptyLabel(i18n("Clean"));
192 undoViewDock->setWidget(m_undoView);
193 m_undoView->setGroup(m_commandStack);
194 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
196 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
197 //overviewDock->setObjectName("project_overview");
198 //m_overView = new CustomTrackView(NULL, NULL, this);
199 //overviewDock->setWidget(m_overView);
200 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
203 //tabifyDockWidget(projectListDock, effectListDock);
204 tabifyDockWidget(projectListDock, effectStackDock);
205 tabifyDockWidget(projectListDock, transitionConfigDock);
206 //tabifyDockWidget(projectListDock, undoViewDock);
209 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
210 tabifyDockWidget(clipMonitorDock, recMonitorDock);
211 setCentralWidget(m_timelineArea);
214 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
216 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
217 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
219 // build effects menus
221 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
223 QStringList effectInfo;
224 QMap<QString, QStringList> effectsList;
225 for (int ix = 0; ix < videoEffects.count(); ix++) {
226 effectInfo = videoEffects.effectIdInfo(ix);
227 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
230 foreach(QStringList value, effectsList) {
231 action = new QAction(value.at(0), this);
232 action->setData(value);
233 videoEffectsMenu->addAction(action);
236 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
240 for (int ix = 0; ix < audioEffects.count(); ix++) {
241 effectInfo = audioEffects.effectIdInfo(ix);
242 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
245 foreach(QStringList value, effectsList) {
246 action = new QAction(value.at(0), this);
247 action->setData(value);
248 audioEffectsMenu->addAction(action);
251 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
253 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
254 else m_customEffectsMenu->setEnabled(true);
257 for (int ix = 0; ix < customEffects.count(); ix++) {
258 effectInfo = customEffects.effectIdInfo(ix);
259 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
262 foreach(QStringList value, effectsList) {
263 action = new QAction(value.at(0), this);
264 action->setData(value);
265 m_customEffectsMenu->addAction(action);
268 QMenu *newEffect = new QMenu(this);
269 newEffect->addMenu(videoEffectsMenu);
270 newEffect->addMenu(audioEffectsMenu);
271 newEffect->addMenu(m_customEffectsMenu);
272 effectStack->setMenu(newEffect);
275 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
276 const QList<QAction *> viewActions = createPopupMenu()->actions();
277 viewMenu->insertActions(NULL, viewActions);
279 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
280 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
281 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
283 m_timelineContextMenu = new QMenu(this);
284 m_timelineContextClipMenu = new QMenu(this);
285 m_timelineContextTransitionMenu = new QMenu(this);
288 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
289 QStringList effects = transitions.effectNames();
292 for (int ix = 0; ix < transitions.count(); ix++) {
293 effectInfo = transitions.effectIdInfo(ix);
294 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
296 foreach(QStringList value, effectsList) {
297 action = new QAction(value.at(0), this);
298 action->setData(value);
299 transitionsMenu->addAction(action);
301 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
303 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
304 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
305 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
307 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
308 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
309 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
310 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
311 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
313 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
314 m_timelineContextClipMenu->addMenu(markersMenu);
315 m_timelineContextClipMenu->addMenu(transitionsMenu);
316 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
317 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
318 //TODO: re-enable custom effects menu when it is implemented
319 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
321 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
322 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
324 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
326 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
327 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
328 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
329 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
330 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
331 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
333 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
334 slotConnectMonitors();
336 // Open or create a file. Command line argument passed in Url has
337 // precedence, then "openlastproject", then just a plain empty file.
338 // If opening Url fails, openlastproject will _not_ be used.
339 if (!Url.isEmpty()) {
342 if (KdenliveSettings::openlastproject()) {
346 if (m_timelineArea->count() == 0) {
350 #ifndef NO_JOGSHUTTLE
351 activateShuttleDevice();
352 #endif /* NO_JOGSHUTTLE */
353 projectListDock->raise();
356 void MainWindow::queryQuit() {
357 kDebug() << "----- SAVING CONFUIG";
358 if (queryClose()) kapp->quit();
362 bool MainWindow::queryClose() {
364 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
365 if (m_activeDocument && m_activeDocument->isModified()) {
366 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
367 case KMessageBox::Yes :
368 // save document here. If saving fails, return false;
370 case KMessageBox::No :
379 void MainWindow::saveProperties(KConfig*) {
380 // save properties here,used by session management
385 void MainWindow::readProperties(KConfig *config) {
386 // read properties here,used by session management
387 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
388 openFile(KUrl(Lastproject));
391 void MainWindow::slotReloadEffects() {
392 initEffects::parseCustomEffectsFile();
393 m_customEffectsMenu->clear();
394 const QStringList effects = customEffects.effectNames();
396 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
397 else m_customEffectsMenu->setEnabled(true);
399 foreach(const QString &name, effects) {
400 action = new QAction(name, this);
401 action->setData(name);
402 m_customEffectsMenu->addAction(action);
404 m_effectList->reloadEffectList();
407 #ifndef NO_JOGSHUTTLE
408 void MainWindow::activateShuttleDevice() {
409 if (m_jogProcess) delete m_jogProcess;
411 if (KdenliveSettings::enableshuttle() == false) return;
412 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
413 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
414 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
415 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
416 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
417 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
418 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
421 void MainWindow::slotShuttleButton(int code) {
424 slotShuttleAction(KdenliveSettings::shuttle1());
427 slotShuttleAction(KdenliveSettings::shuttle2());
430 slotShuttleAction(KdenliveSettings::shuttle3());
433 slotShuttleAction(KdenliveSettings::shuttle4());
436 slotShuttleAction(KdenliveSettings::shuttle5());
441 void MainWindow::slotShuttleAction(int code) {
446 m_monitorManager->slotPlay();
449 m_monitorManager->slotPlay();
453 #endif /* NO_JOGSHUTTLE */
455 void MainWindow::configureNotifications() {
456 KNotifyConfigWidget::configure(this);
459 void MainWindow::slotFullScreen() {
460 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
463 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
464 if (!m_activeDocument) return;
465 if (effect.isNull()) {
466 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
469 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
470 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
473 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
474 if (clipMonitor) clipMonitorDock->raise();
475 else projectMonitorDock->raise();
478 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
479 if (!m_activeDocument) return;
480 m_activeDocument->setProducerDuration(id, duration);
483 void MainWindow::slotConnectMonitors() {
485 m_projectList->setRenderer(m_projectMonitor->render);
486 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
487 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
488 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
489 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
490 connect(m_projectMonitor->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 > &)));
492 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
494 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
496 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
497 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
499 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
500 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
503 void MainWindow::slotAdjustClipMonitor() {
504 clipMonitorDock->updateGeometry();
505 clipMonitorDock->adjustSize();
506 m_clipMonitor->resetSize();
509 void MainWindow::slotAdjustProjectMonitor() {
510 projectMonitorDock->updateGeometry();
511 projectMonitorDock->adjustSize();
512 m_projectMonitor->resetSize();
515 void MainWindow::setupActions() {
517 KActionCollection* collection = actionCollection();
518 m_timecodeFormat = new KComboBox(this);
519 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
520 m_timecodeFormat->addItem(i18n("Frames"));
522 statusProgressBar = new QProgressBar(this);
523 statusProgressBar->setMinimum(0);
524 statusProgressBar->setMaximum(100);
525 statusProgressBar->setMaximumWidth(150);
526 statusProgressBar->setVisible(false);
528 QWidget *w = new QWidget;
530 QHBoxLayout *layout = new QHBoxLayout;
531 w->setLayout(layout);
532 layout->setContentsMargins(5, 0, 5, 0);
533 QToolBar *toolbar = new QToolBar("statusToolBar", this);
536 m_toolGroup = new QActionGroup(this);
538 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;}";
540 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
541 toolbar->addAction(m_buttonSelectTool);
542 m_buttonSelectTool->setCheckable(true);
543 m_buttonSelectTool->setChecked(true);
545 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
546 toolbar->addAction(m_buttonRazorTool);
547 m_buttonRazorTool->setCheckable(true);
548 m_buttonRazorTool->setChecked(false);
550 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
551 toolbar->addAction(m_buttonSpacerTool);
552 m_buttonSpacerTool->setCheckable(true);
553 m_buttonSpacerTool->setChecked(false);
555 m_toolGroup->addAction(m_buttonSelectTool);
556 m_toolGroup->addAction(m_buttonRazorTool);
557 m_toolGroup->addAction(m_buttonSpacerTool);
558 m_toolGroup->setExclusive(true);
559 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
561 QWidget * actionWidget;
562 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
563 actionWidget->setMaximumWidth(24);
564 actionWidget->setMinimumHeight(17);
566 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
567 actionWidget->setMaximumWidth(24);
568 actionWidget->setMinimumHeight(17);
570 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
571 actionWidget->setMaximumWidth(24);
572 actionWidget->setMinimumHeight(17);
574 toolbar->setStyleSheet(style1);
575 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
577 toolbar->addSeparator();
578 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
579 toolbar->addAction(m_buttonFitZoom);
580 m_buttonFitZoom->setCheckable(false);
581 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
583 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
584 actionWidget->setMaximumWidth(24);
585 actionWidget->setMinimumHeight(17);
587 m_zoomSlider = new QSlider(Qt::Horizontal, this);
588 m_zoomSlider->setMaximum(13);
589 m_zoomSlider->setPageStep(1);
591 m_zoomSlider->setMaximumWidth(150);
592 m_zoomSlider->setMinimumWidth(100);
594 const int contentHeight = QFontMetrics(w->font()).height() + 8;
596 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
597 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
599 m_zoomSlider->setStyleSheet(style);
601 //m_zoomSlider->height() + 5;
602 statusBar()->setMinimumHeight(contentHeight);
605 toolbar->addWidget(m_zoomSlider);
607 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
608 toolbar->addAction(m_buttonVideoThumbs);
609 m_buttonVideoThumbs->setCheckable(true);
610 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
611 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
613 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
614 toolbar->addAction(m_buttonAudioThumbs);
615 m_buttonAudioThumbs->setCheckable(true);
616 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
617 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
619 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
620 toolbar->addAction(m_buttonShowMarkers);
621 m_buttonShowMarkers->setCheckable(true);
622 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
623 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
625 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
626 toolbar->addAction(m_buttonSnap);
627 m_buttonSnap->setCheckable(true);
628 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
629 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
630 layout->addWidget(toolbar);
633 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
634 actionWidget->setMaximumWidth(24);
635 actionWidget->setMinimumHeight(17);
637 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
638 actionWidget->setMaximumWidth(24);
639 actionWidget->setMinimumHeight(17);
641 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
642 actionWidget->setMaximumWidth(24);
643 actionWidget->setMinimumHeight(17);
645 actionWidget = toolbar->widgetForAction(m_buttonSnap);
646 actionWidget->setMaximumWidth(24);
647 actionWidget->setMinimumHeight(17);
649 m_messageLabel = new StatusBarMessageLabel(this);
650 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
652 statusBar()->addWidget(m_messageLabel, 10);
653 statusBar()->addWidget(statusProgressBar, 0);
654 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
655 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
656 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
657 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
658 m_messageLabel->hide();
660 collection->addAction("select_tool", m_buttonSelectTool);
661 collection->addAction("razor_tool", m_buttonRazorTool);
662 collection->addAction("spacer_tool", m_buttonSpacerTool);
664 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
665 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
666 collection->addAction("show_markers", m_buttonShowMarkers);
667 collection->addAction("snap", m_buttonSnap);
668 collection->addAction("zoom_fit", m_buttonFitZoom);
670 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
671 collection->addAction("zoom_in", zoomIn);
672 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
673 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
675 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
676 collection->addAction("zoom_out", zoomOut);
677 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
678 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
680 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
681 collection->addAction("project_find", m_projectSearch);
682 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
683 m_projectSearch->setShortcut(Qt::Key_Slash);
685 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
686 collection->addAction("project_find_next", m_projectSearchNext);
687 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
688 m_projectSearchNext->setShortcut(Qt::Key_F3);
689 m_projectSearchNext->setEnabled(false);
691 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
692 collection->addAction("manage_profiles", profilesAction);
693 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
695 KAction* fileGHNS = KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewStuff()), actionCollection(), "get_new_stuff");
697 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
698 collection->addAction("run_wizard", wizAction);
699 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
701 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
702 collection->addAction("project_settings", projectAction);
703 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
705 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
706 collection->addAction("project_render", projectRender);
707 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
708 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
710 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
711 KShortcut playShortcut;
712 playShortcut.setPrimary(Qt::Key_Space);
713 playShortcut.setAlternate(Qt::Key_K);
714 monitorPlay->setShortcut(playShortcut);
715 collection->addAction("monitor_play", monitorPlay);
716 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
718 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
719 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
720 collection->addAction("monitor_play_zone", m_playZone);
721 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
723 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
724 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
725 collection->addAction("monitor_loop_zone", m_loopZone);
726 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
728 KAction *markIn = collection->addAction("mark_in");
729 markIn->setText(i18n("Set In Point"));
730 markIn->setShortcut(Qt::Key_I);
731 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
733 KAction *markOut = collection->addAction("mark_out");
734 markOut->setText(i18n("Set Out Point"));
735 markOut->setShortcut(Qt::Key_O);
736 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
738 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
739 monitorSeekBackward->setShortcut(Qt::Key_J);
740 collection->addAction("monitor_seek_backward", monitorSeekBackward);
741 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
743 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
744 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
745 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
746 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
748 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
749 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
750 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
751 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
753 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
754 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
755 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
756 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
758 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
759 monitorSeekForward->setShortcut(Qt::Key_L);
760 collection->addAction("monitor_seek_forward", monitorSeekForward);
761 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
763 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
764 clipStart->setShortcut(Qt::Key_Home);
765 collection->addAction("seek_clip_start", clipStart);
766 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
768 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
769 clipEnd->setShortcut(Qt::Key_End);
770 collection->addAction("seek_clip_end", clipEnd);
771 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
773 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
774 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
775 collection->addAction("seek_start", projectStart);
776 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
778 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
779 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
780 collection->addAction("seek_end", projectEnd);
781 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
783 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
784 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
785 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
786 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
788 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
789 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
790 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
791 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
793 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
794 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
795 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
796 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
798 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
799 deleteTimelineClip->setShortcut(Qt::Key_Delete);
800 collection->addAction("delete_timeline_clip", deleteTimelineClip);
801 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
803 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
804 collection->addAction("change_clip_speed", editTimelineClipSpeed);
805 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
807 KAction *stickTransition = collection->addAction("auto_transition");
808 stickTransition->setData(QString("auto"));
809 stickTransition->setCheckable(true);
810 stickTransition->setEnabled(false);
811 stickTransition->setText(i18n("Automatic Transition"));
812 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
814 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
815 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
816 collection->addAction("cut_timeline_clip", cutTimelineClip);
817 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
819 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
820 collection->addAction("add_clip_marker", addClipMarker);
821 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
823 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
824 collection->addAction("delete_clip_marker", deleteClipMarker);
825 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
827 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
828 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
829 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
831 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
832 collection->addAction("edit_clip_marker", editClipMarker);
833 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
835 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
836 collection->addAction("insert_space", insertSpace);
837 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
839 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
840 collection->addAction("delete_space", removeSpace);
841 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
843 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
844 collection->addAction("insert_track", insertTrack);
845 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
847 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
848 collection->addAction("delete_track", deleteTrack);
849 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
851 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
852 collection->addAction("change_track", changeTrack);
853 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
855 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
856 collection->addAction("add_guide", addGuide);
857 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
859 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
860 collection->addAction("delete_guide", delGuide);
861 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
863 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
864 collection->addAction("edit_guide", editGuide);
865 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
867 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
868 collection->addAction("delete_all_guides", delAllGuides);
869 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
871 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
872 collection->addAction("paste_effects", pasteEffects);
873 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
875 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
877 KStandardAction::quit(this, SLOT(queryQuit()), collection);
879 KStandardAction::open(this, SLOT(openFile()), collection);
881 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
883 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
885 KStandardAction::openNew(this, SLOT(newFile()), collection);
887 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
889 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
891 KStandardAction::copy(this, SLOT(slotCopy()), collection);
893 KStandardAction::paste(this, SLOT(slotPaste()), collection);
895 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
896 undo->setEnabled(false);
897 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
899 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
900 redo->setEnabled(false);
901 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
903 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
905 connect(collection, SIGNAL(actionHovered(QAction*)),
906 this, SLOT(slotDisplayActionMessage(QAction*)));
907 //connect(collection, SIGNAL( clearStatusText() ),
908 //statusBar(), SLOT( clear() ) );
911 void MainWindow::slotDisplayActionMessage(QAction *a) {
912 statusBar()->showMessage(a->data().toString(), 3000);
915 void MainWindow::saveOptions() {
916 KdenliveSettings::self()->writeConfig();
917 KSharedConfigPtr config = KGlobal::config();
918 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
919 KConfigGroup treecolumns(config, "Project Tree");
920 treecolumns.writeEntry("columns", m_projectList->headerInfo());
924 void MainWindow::readOptions() {
925 KSharedConfigPtr config = KGlobal::config();
926 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
927 KConfigGroup initialGroup(config, "version");
928 if (!initialGroup.exists()) {
929 // this is our first run, show Wizard
930 Wizard *w = new Wizard(this);
931 if (w->exec() == QDialog::Accepted && w->isOk()) {
933 initialGroup.writeEntry("version", "0.7");
938 } else if (initialGroup.readEntry("version") == "0.7") {
939 //Add new settings from 0.7.1
940 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
941 QString path = QDir::homePath() + "/kdenlive";
942 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
943 KdenliveSettings::setDefaultprojectfolder(path);
946 KConfigGroup treecolumns(config, "Project Tree");
947 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
948 if (!state.isEmpty())
949 m_projectList->setHeaderInfo(state);
952 void MainWindow::slotRunWizard() {
953 Wizard *w = new Wizard(this);
954 if (w->exec() == QDialog::Accepted && w->isOk()) {
960 void MainWindow::newFile(bool showProjectSettings) {
963 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
964 if (!showProjectSettings && m_timelineArea->count() == 0) {
965 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
966 profileName = KdenliveSettings::default_profile();
968 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
969 if (w->exec() != QDialog::Accepted) return;
970 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
971 profileName = w->selectedProfile();
972 projectFolder = w->selectedFolder();
973 projectTracks = w->tracks();
976 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
977 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
978 TrackView *trackView = new TrackView(doc, this);
979 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
980 if (m_timelineArea->count() == 1) {
981 connectDocumentInfo(doc);
982 connectDocument(trackView, doc);
983 } else m_timelineArea->setTabBarHidden(false);
984 m_closeAction->setEnabled(m_timelineArea->count() > 1);
987 void MainWindow::activateDocument() {
988 if (m_timelineArea->currentWidget() == NULL) return;
989 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
990 KdenliveDoc *currentDoc = currentTab->document();
991 connectDocumentInfo(currentDoc);
992 connectDocument(currentTab, currentDoc);
995 void MainWindow::closeCurrentDocument() {
996 QWidget *w = m_timelineArea->currentWidget();
998 // closing current document
999 int ix = m_timelineArea->currentIndex() + 1;
1000 if (ix == m_timelineArea->count()) ix = 0;
1001 m_timelineArea->setCurrentIndex(ix);
1002 TrackView *tabToClose = (TrackView *) w;
1003 KdenliveDoc *docToClose = tabToClose->document();
1004 if (docToClose && docToClose->isModified()) {
1005 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1006 case KMessageBox::Yes :
1007 // save document here. If saving fails, return false;
1010 case KMessageBox::Cancel :
1016 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1017 if (m_timelineArea->count() == 1) {
1018 m_timelineArea->setTabBarHidden(true);
1019 m_closeAction->setEnabled(false);
1023 if (m_timelineArea->count() == 0) {
1024 m_activeDocument = NULL;
1025 effectStack->clear();
1026 transitionConfig->slotTransitionItemSelected(NULL, false);
1030 bool MainWindow::saveFileAs(const QString &outputFileName) {
1031 QDomDocument currentSceneList = m_projectMonitor->sceneList();
1032 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1035 // Save timeline thumbnails
1036 m_activeTimeline->projectView()->saveThumbnails();
1037 m_activeDocument->setUrl(KUrl(outputFileName));
1038 if (m_activeDocument->m_autosave == NULL) {
1039 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1040 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1041 setCaption(m_activeDocument->description());
1042 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1043 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1044 m_activeDocument->setModified(false);
1045 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1049 bool MainWindow::saveFileAs() {
1050 // Check that the Kdenlive mime type is correctly installed
1051 QString mimetype = "application/x-kdenlive";
1052 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1053 if (!mime) mimetype = "*.kdenlive";
1055 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1056 if (outputFile.isEmpty()) return false;
1057 if (QFile::exists(outputFile)) {
1058 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1060 return saveFileAs(outputFile);
1063 bool MainWindow::saveFile() {
1064 if (!m_activeDocument) return true;
1065 if (m_activeDocument->url().isEmpty()) {
1066 return saveFileAs();
1068 bool result = saveFileAs(m_activeDocument->url().path());
1069 m_activeDocument->m_autosave->resize(0);
1074 void MainWindow::openFile() {
1075 // Check that the Kdenlive mime type is correctly installed
1076 QString mimetype = "application/x-kdenlive";
1077 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1078 if (!mime) mimetype = "*.kdenlive";
1080 KUrl url = KFileDialog::getOpenUrl(KUrl(), mimetype);
1081 if (url.isEmpty()) return;
1082 m_fileOpenRecent->addUrl(url);
1086 void MainWindow::openLastFile() {
1087 KSharedConfigPtr config = KGlobal::config();
1088 KUrl::List urls = m_fileOpenRecent->urls();
1089 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1090 if (urls.isEmpty()) newFile(false);
1091 else openFile(urls.last());
1094 void MainWindow::openFile(const KUrl &url) {
1095 // Check if the document is already opened
1096 const int ct = m_timelineArea->count();
1097 bool isOpened = false;
1099 for (i = 0; i < ct; i++) {
1100 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1101 KdenliveDoc *doc = tab->document();
1102 if (doc->url() == url) {
1108 m_timelineArea->setCurrentIndex(i);
1112 // Check for backup file
1113 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1114 if (!staleFiles.isEmpty()) {
1115 if (KMessageBox::questionYesNo(this,
1116 i18n("Auto-saved files exist. Do you want to recover them now?"),
1117 i18n("File Recovery"),
1118 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1119 recoverFiles(staleFiles);
1122 // remove the stale files
1123 foreach(KAutoSaveFile *stale, staleFiles) {
1124 stale->open(QIODevice::ReadWrite);
1129 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1130 doOpenFile(url, NULL);
1133 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1135 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1136 if (stale == NULL) {
1137 stale = new KAutoSaveFile(url, doc);
1138 doc->m_autosave = stale;
1140 doc->m_autosave = stale;
1141 doc->setUrl(stale->managedFile());
1142 doc->setModified(true);
1143 stale->setParent(doc);
1145 connectDocumentInfo(doc);
1146 TrackView *trackView = new TrackView(doc, this);
1147 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1148 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1149 trackView->setDuration(trackView->duration());
1150 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1152 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1153 slotGotProgressInfo(QString(), -1);
1154 m_clipMonitor->refreshMonitor(true);
1157 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1158 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1159 foreach(KAutoSaveFile *stale, staleFiles) {
1160 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1161 // show an error message; we could not steal the lockfile
1162 // maybe another application got to the file before us?
1166 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1167 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1168 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1169 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1174 void MainWindow::parseProfiles(const QString &mltPath) {
1175 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1177 //KdenliveSettings::setDefaulttmpfolder();
1178 if (!mltPath.isEmpty()) {
1179 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1180 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1183 if (KdenliveSettings::mltpath().isEmpty()) {
1184 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1186 if (KdenliveSettings::rendererpath().isEmpty()) {
1187 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1188 if (!QFile::exists(inigoPath))
1189 inigoPath = KStandardDirs::findExe("inigo");
1190 else KdenliveSettings::setRendererpath(inigoPath);
1192 QStringList profilesFilter;
1193 profilesFilter << "*";
1194 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1196 if (profilesList.isEmpty()) {
1197 // Cannot find MLT path, try finding inigo
1198 QString profilePath = KdenliveSettings::rendererpath();
1199 if (!profilePath.isEmpty()) {
1200 profilePath = profilePath.section('/', 0, -3);
1201 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1202 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1205 if (profilesList.isEmpty()) {
1206 // Cannot find the MLT profiles, ask for location
1207 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1208 getUrl->fileDialog()->setMode(KFile::Directory);
1209 if (getUrl->exec() == QDialog::Rejected) {
1212 KUrl mltPath = getUrl->selectedUrl();
1214 if (mltPath.isEmpty()) ::exit(0);
1215 KdenliveSettings::setMltpath(mltPath.path());
1216 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1220 if (KdenliveSettings::rendererpath().isEmpty()) {
1221 // Cannot find the MLT inigo renderer, ask for location
1222 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1223 if (getUrl->exec() == QDialog::Rejected) {
1226 KUrl rendererPath = getUrl->selectedUrl();
1228 if (rendererPath.isEmpty()) ::exit(0);
1229 KdenliveSettings::setRendererpath(rendererPath.path());
1232 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1234 // Parse MLT profiles to build a list of available video formats
1235 if (profilesList.isEmpty()) parseProfiles();
1239 void MainWindow::slotEditProfiles() {
1240 ProfilesDialog *w = new ProfilesDialog;
1245 void MainWindow::slotEditProjectSettings() {
1246 QPoint p = m_activeDocument->getTracksCount();
1247 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1249 if (w->exec() == QDialog::Accepted) {
1250 QString profile = w->selectedProfile();
1251 m_activeDocument->setProjectFolder(w->selectedFolder());
1252 if (m_activeDocument->profilePath() != profile) {
1253 // Profile was changed
1254 m_activeDocument->setProfilePath(profile);
1255 KdenliveSettings::setCurrent_profile(profile);
1256 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1257 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1258 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1259 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1260 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1262 // We need to desactivate & reactivate monitors to get a refresh
1263 m_monitorManager->switchMonitors();
1269 void MainWindow::slotRenderProject() {
1270 if (!m_renderWidget) {
1271 m_renderWidget = new RenderWidget(this);
1272 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)));
1273 if (m_activeDocument) {
1274 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1275 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1278 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1279 if (currentTab) m_renderWidget->setTimeline(currentTab);
1280 m_renderWidget->setDocument(m_activeDocument);*/
1281 m_renderWidget->show();
1284 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) {
1285 if (dest.isEmpty()) return;
1288 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1289 if (currentTab && zoneOnly) {
1290 in = currentTab->inPoint();
1291 out = currentTab->outPoint();
1293 KTemporaryFile temp;
1294 temp.setAutoRemove(false);
1295 temp.setSuffix(".westley");
1297 m_projectMonitor->saveSceneList(temp.fileName());
1300 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1301 else if (guideStart != -1) {
1302 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1304 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1305 QString videoPlayer = "-";
1307 videoPlayer = KdenliveSettings::defaultplayerapp();
1308 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."));
1310 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1311 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1314 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1315 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1316 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1317 QProcess::startDetached(renderer, args);
1319 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1323 void MainWindow::slotUpdateMousePosition(int pos) {
1324 if (m_activeDocument)
1325 switch (m_timecodeFormat->currentIndex()) {
1327 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1330 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1334 void MainWindow::slotUpdateDocumentState(bool modified) {
1335 setCaption(m_activeDocument->description(), modified);
1336 m_saveAction->setEnabled(modified);
1338 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1339 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1341 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1342 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1346 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1347 if (m_activeDocument) {
1348 if (m_activeDocument == doc) return;
1349 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1351 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1354 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1355 //m_projectMonitor->stop();
1356 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1357 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1358 if (m_activeDocument) {
1359 if (m_activeDocument == doc) return;
1360 m_activeDocument->backupMltPlaylist();
1361 if (m_activeTimeline) {
1362 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1363 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1364 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1365 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1368 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1369 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1370 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1371 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1372 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1373 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1374 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1375 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1376 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1377 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1378 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1379 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1380 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1381 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1382 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1383 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1384 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1385 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1386 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1387 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1388 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1389 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1390 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1391 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1392 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1393 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1394 disconnect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), m_activeTimeline->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1395 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1396 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1397 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1398 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1399 effectStack->clear();
1401 //m_activeDocument->setRenderer(NULL);
1402 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1403 m_clipMonitor->stop();
1405 KdenliveSettings::setCurrent_profile(doc->profilePath());
1406 KdenliveSettings::setProject_fps(doc->fps());
1407 m_monitorManager->resetProfiles(doc->timecode());
1408 m_projectList->setDocument(doc);
1409 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1410 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1411 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1412 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1413 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1414 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1415 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1416 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1417 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1418 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1419 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1420 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1421 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1422 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1423 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1424 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1425 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1427 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1428 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1429 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1432 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1433 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1434 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1435 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1436 m_zoomSlider->setValue(doc->zoom());
1437 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1438 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1439 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1440 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1442 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1445 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1446 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1447 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1448 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1449 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1450 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1451 connect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), trackView->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1452 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1453 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1455 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1456 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1457 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1459 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1460 m_activeTimeline = trackView;
1461 if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
1462 //doc->setRenderer(m_projectMonitor->render);
1463 m_commandStack->setActiveStack(doc->commandStack());
1464 KdenliveSettings::setProject_display_ratio(doc->dar());
1465 m_projectList->updateAllClips();
1466 //doc->clipManager()->checkAudioThumbs();
1468 //m_overView->setScene(trackView->projectScene());
1469 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1470 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1472 setCaption(doc->description(), doc->isModified());
1473 m_saveAction->setEnabled(doc->isModified());
1474 m_activeDocument = doc;
1476 // set tool to select tool
1477 m_buttonSelectTool->setChecked(true);
1480 void MainWindow::slotGuidesUpdated() {
1481 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1484 void MainWindow::slotPreferences(int page, int option) {
1485 //An instance of your dialog could be already created and could be
1486 // cached, in which case you want to display the cached dialog
1487 // instead of creating another one
1488 if (KConfigDialog::showDialog("settings")) {
1489 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1490 if (page != -1) d->showPage(page, option);
1495 // KConfigDialog didn't find an instance of this dialog, so lets
1497 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1498 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1499 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1501 if (page != -1) dialog->showPage(page, option);
1504 void MainWindow::updateConfiguration() {
1505 //TODO: we should apply settings to all projects, not only the current one
1506 if (m_activeTimeline) {
1507 m_activeTimeline->refresh();
1508 m_activeTimeline->projectView()->checkAutoScroll();
1509 m_activeTimeline->projectView()->checkTrackHeight();
1510 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1512 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1513 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1514 #ifndef NO_JOGSHUTTLE
1515 activateShuttleDevice();
1516 #endif /* NO_JOGSHUTTLE */
1520 void MainWindow::slotSwitchVideoThumbs() {
1521 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1522 if (m_activeTimeline) {
1523 m_activeTimeline->refresh();
1525 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1528 void MainWindow::slotSwitchAudioThumbs() {
1529 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1530 if (m_activeTimeline) {
1531 m_activeTimeline->refresh();
1532 m_activeTimeline->projectView()->checkAutoScroll();
1533 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1535 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1538 void MainWindow::slotSwitchMarkersComments() {
1539 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1540 if (m_activeTimeline) {
1541 m_activeTimeline->refresh();
1543 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1546 void MainWindow::slotSwitchSnap() {
1547 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1548 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1552 void MainWindow::slotDeleteTimelineClip() {
1553 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1554 else if (m_activeTimeline) {
1555 m_activeTimeline->projectView()->deleteSelectedClips();
1559 void MainWindow::slotChangeClipSpeed() {
1560 if (m_activeTimeline) {
1561 m_activeTimeline->projectView()->changeClipSpeed();
1565 void MainWindow::slotAddClipMarker() {
1566 DocClipBase *clip = NULL;
1568 if (m_projectMonitor->isActive()) {
1569 if (m_activeTimeline) {
1570 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1572 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1573 clip = item->baseClip();
1577 clip = m_clipMonitor->activeClip();
1578 pos = m_clipMonitor->position();
1581 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1584 QString id = clip->getId();
1585 CommentedTime marker(pos, i18n("Marker"));
1586 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1587 if (d.exec() == QDialog::Accepted) {
1588 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1590 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1593 void MainWindow::slotDeleteClipMarker() {
1594 DocClipBase *clip = NULL;
1596 if (m_projectMonitor->isActive()) {
1597 if (m_activeTimeline) {
1598 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1600 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1601 clip = item->baseClip();
1605 clip = m_clipMonitor->activeClip();
1606 pos = m_clipMonitor->position();
1609 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1613 QString id = clip->getId();
1614 QString comment = clip->markerComment(pos);
1615 if (comment.isEmpty()) {
1616 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1619 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1620 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1624 void MainWindow::slotDeleteAllClipMarkers() {
1625 DocClipBase *clip = NULL;
1626 if (m_projectMonitor->isActive()) {
1627 if (m_activeTimeline) {
1628 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1630 clip = item->baseClip();
1634 clip = m_clipMonitor->activeClip();
1637 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1640 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
1641 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1644 void MainWindow::slotEditClipMarker() {
1645 DocClipBase *clip = NULL;
1647 if (m_projectMonitor->isActive()) {
1648 if (m_activeTimeline) {
1649 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1651 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1652 clip = item->baseClip();
1656 clip = m_clipMonitor->activeClip();
1657 pos = m_clipMonitor->position();
1660 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1664 QString id = clip->getId();
1665 QString oldcomment = clip->markerComment(pos);
1666 if (oldcomment.isEmpty()) {
1667 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1671 CommentedTime marker(pos, oldcomment);
1672 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
1673 if (d.exec() == QDialog::Accepted) {
1674 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1675 if (d.newMarker().time() != pos) {
1676 // remove old marker
1677 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
1679 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1683 void MainWindow::slotAddGuide() {
1684 if (m_activeTimeline)
1685 m_activeTimeline->projectView()->slotAddGuide();
1688 void MainWindow::slotInsertSpace() {
1689 if (m_activeTimeline)
1690 m_activeTimeline->projectView()->slotInsertSpace();
1693 void MainWindow::slotRemoveSpace() {
1694 if (m_activeTimeline)
1695 m_activeTimeline->projectView()->slotRemoveSpace();
1698 void MainWindow::slotInsertTrack(int ix) {
1699 m_projectMonitor->activateMonitor();
1700 if (m_activeTimeline)
1701 m_activeTimeline->projectView()->slotInsertTrack(ix);
1704 void MainWindow::slotDeleteTrack(int ix) {
1705 m_projectMonitor->activateMonitor();
1706 if (m_activeTimeline)
1707 m_activeTimeline->projectView()->slotDeleteTrack(ix);
1710 void MainWindow::slotChangeTrack(int ix) {
1711 m_projectMonitor->activateMonitor();
1712 if (m_activeTimeline)
1713 m_activeTimeline->projectView()->slotChangeTrack(ix);
1716 void MainWindow::slotEditGuide() {
1717 if (m_activeTimeline)
1718 m_activeTimeline->projectView()->slotEditGuide();
1721 void MainWindow::slotDeleteGuide() {
1722 if (m_activeTimeline)
1723 m_activeTimeline->projectView()->slotDeleteGuide();
1726 void MainWindow::slotDeleteAllGuides() {
1727 if (m_activeTimeline)
1728 m_activeTimeline->projectView()->slotDeleteAllGuides();
1731 void MainWindow::slotCutTimelineClip() {
1732 if (m_activeTimeline) {
1733 m_activeTimeline->projectView()->cutSelectedClips();
1737 void MainWindow::slotAddProjectClip(KUrl url) {
1738 if (m_activeDocument)
1739 m_activeDocument->slotAddClipFile(url, QString());
1742 void MainWindow::slotAddTransition(QAction *result) {
1743 if (!result) return;
1744 QStringList info = result->data().toStringList();
1745 if (info.isEmpty()) return;
1746 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
1747 if (m_activeTimeline && !transition.isNull()) {
1748 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
1752 void MainWindow::slotAddVideoEffect(QAction *result) {
1753 if (!result) return;
1754 QStringList info = result->data().toStringList();
1755 if (info.isEmpty()) return;
1756 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1757 slotAddEffect(effect);
1760 void MainWindow::slotAddAudioEffect(QAction *result) {
1761 if (!result) return;
1762 QStringList info = result->data().toStringList();
1763 if (info.isEmpty()) return;
1764 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1765 slotAddEffect(effect);
1768 void MainWindow::slotAddCustomEffect(QAction *result) {
1769 if (!result) return;
1770 QStringList info = result->data().toStringList();
1771 if (info.isEmpty()) return;
1772 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1773 slotAddEffect(effect);
1776 void MainWindow::slotZoomIn() {
1777 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1780 void MainWindow::slotZoomOut() {
1781 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1784 void MainWindow::slotFitZoom() {
1785 if (m_activeTimeline) {
1786 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1790 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1791 statusProgressBar->setValue(progress);
1792 if (progress >= 0) {
1793 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1794 statusProgressBar->setVisible(true);
1796 m_messageLabel->setMessage(QString(), DefaultMessage);
1797 statusProgressBar->setVisible(false);
1801 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1802 if (clip->clipType() == TEXT) {
1803 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1804 QString path = clip->getProperty("resource");
1805 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1807 doc.setContent(clip->getProperty("xmldata"));
1808 dia_ui->setXml(doc);
1809 if (dia_ui->exec() == QDialog::Accepted) {
1810 QPixmap pix = dia_ui->renderedPixmap();
1812 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1813 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1814 QMap <QString, QString> newprops;
1815 newprops.insert("xmldata", dia_ui->xml().toString());
1816 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1817 m_activeDocument->commandStack()->push(command);
1818 m_clipMonitor->refreshMonitor(true);
1819 m_activeDocument->setModified(true);
1823 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1826 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1827 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1828 if (dia.exec() == QDialog::Accepted) {
1829 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1830 m_activeDocument->commandStack()->push(command);
1832 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1833 if (dia.needsTimelineRefresh()) {
1834 // update clip occurences in timeline
1835 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1840 void MainWindow::customEvent(QEvent* e) {
1841 if (e->type() == QEvent::User) {
1842 // The timeline playing position changed...
1843 kDebug() << "RECIEVED JOG EVEMNT!!!";
1846 void MainWindow::slotActivateEffectStackView() {
1847 effectStack->raiseWindow(effectStackDock);
1850 void MainWindow::slotActivateTransitionView() {
1851 transitionConfig->raiseWindow(transitionConfigDock);
1854 void MainWindow::slotSnapRewind() {
1855 if (m_projectMonitor->isActive()) {
1856 if (m_activeTimeline)
1857 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1858 } else m_clipMonitor->slotSeekToPreviousSnap();
1861 void MainWindow::slotSnapForward() {
1862 if (m_projectMonitor->isActive()) {
1863 if (m_activeTimeline)
1864 m_activeTimeline->projectView()->slotSeekToNextSnap();
1865 } else m_clipMonitor->slotSeekToNextSnap();
1868 void MainWindow::slotClipStart() {
1869 if (m_projectMonitor->isActive()) {
1870 if (m_activeTimeline)
1871 m_activeTimeline->projectView()->clipStart();
1875 void MainWindow::slotClipEnd() {
1876 if (m_projectMonitor->isActive()) {
1877 if (m_activeTimeline)
1878 m_activeTimeline->projectView()->clipEnd();
1882 void MainWindow::slotChangeTool(QAction * action) {
1883 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1884 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1885 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
1888 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1889 if (m_activeDocument && m_activeTimeline) {
1890 //m_activeDocument->setTool(tool);
1891 m_activeTimeline->projectView()->setTool(tool);
1895 void MainWindow::slotCopy() {
1896 if (!m_activeDocument || !m_activeTimeline) return;
1897 m_activeTimeline->projectView()->copyClip();
1900 void MainWindow::slotPaste() {
1901 if (!m_activeDocument || !m_activeTimeline) return;
1902 m_activeTimeline->projectView()->pasteClip();
1905 void MainWindow::slotPasteEffects() {
1906 if (!m_activeDocument || !m_activeTimeline) return;
1907 m_activeTimeline->projectView()->pasteClipEffects();
1910 void MainWindow::slotFind() {
1911 if (!m_activeDocument || !m_activeTimeline) return;
1912 m_projectSearch->setEnabled(false);
1913 m_findActivated = true;
1914 m_findString = QString();
1915 m_activeTimeline->projectView()->initSearchStrings();
1916 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1917 m_findTimer.start(5000);
1918 qApp->installEventFilter(this);
1921 void MainWindow::slotFindNext() {
1922 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1923 statusBar()->showMessage(i18n("Found : %1", m_findString));
1925 statusBar()->showMessage(i18n("Reached end of project"));
1927 m_findTimer.start(4000);
1930 void MainWindow::findAhead() {
1931 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1932 m_projectSearchNext->setEnabled(true);
1933 statusBar()->showMessage(i18n("Found : %1", m_findString));
1935 m_projectSearchNext->setEnabled(false);
1936 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1940 void MainWindow::findTimeout() {
1941 m_projectSearchNext->setEnabled(false);
1942 m_findActivated = false;
1943 m_findString = QString();
1944 statusBar()->showMessage(i18n("Find stopped"), 3000);
1945 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1946 m_projectSearch->setEnabled(true);
1947 removeEventFilter(this);
1950 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1951 if (m_findActivated) {
1952 if (ke->key() == Qt::Key_Backspace) {
1953 m_findString = m_findString.left(m_findString.length() - 1);
1955 if (!m_findString.isEmpty()) {
1961 m_findTimer.start(4000);
1964 } else if (ke->key() == Qt::Key_Escape) {
1968 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1969 m_findString += ke->text();
1973 m_findTimer.start(4000);
1977 } else KXmlGuiWindow::keyPressEvent(ke);
1981 /** Gets called when the window gets hidden */
1982 void MainWindow::hideEvent(QHideEvent *event) {
1983 // kDebug() << "I was hidden";
1984 // issue http://www.kdenlive.org/mantis/view.php?id=231
1985 if (this->isMinimized()) {
1986 // kDebug() << "I am minimized";
1987 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
1991 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1992 if (m_findActivated) {
1993 if (event->type() == QEvent::ShortcutOverride) {
1994 QKeyEvent* ke = (QKeyEvent*) event;
1995 if (ke->text().trimmed().isEmpty()) return false;
1998 } else return false;
2000 // pass the event on to the parent class
2001 return QMainWindow::eventFilter(obj, event);
2005 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
2006 KDialog *dialog = new KDialog(this);
2007 dialog->setCaption("Save clip zone");
2008 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2010 QWidget *widget = new QWidget(dialog);
2011 dialog->setMainWidget(widget);
2013 QVBoxLayout *vbox = new QVBoxLayout(widget);
2014 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2015 QString path = m_activeDocument->projectFolder().path();
2017 path.append("untitled.westley");
2018 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2019 url->setFilter("video/mlt-playlist");
2020 QLabel *label2 = new QLabel(i18n("Description:"), this);
2021 KLineEdit *edit = new KLineEdit(this);
2022 vbox->addWidget(label1);
2023 vbox->addWidget(url);
2024 vbox->addWidget(label2);
2025 vbox->addWidget(edit);
2026 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2030 void MainWindow::slotSetInPoint() {
2031 if (m_clipMonitor->isActive()) {
2032 m_clipMonitor->slotSetZoneStart();
2033 } else m_activeTimeline->projectView()->setInPoint();
2036 void MainWindow::slotSetOutPoint() {
2037 if (m_clipMonitor->isActive()) {
2038 m_clipMonitor->slotSetZoneEnd();
2039 } else m_activeTimeline->projectView()->setOutPoint();
2042 void MainWindow::slotGetNewStuff() {
2043 //KNS::Entry::List download();
2044 KNS::Entry::List entries = KNS::Engine::download();
2045 int numberInstalled = 0;
2046 // list of changed entries
2047 kDebug() << "// PARSING KNS";
2048 foreach(KNS::Entry* entry, entries) {
2049 // care only about installed ones
2050 if (entry->status() == KNS::Entry::Installed) {
2051 foreach(const QString &file, entry->installedFiles()) {
2052 kDebug() << "// CURRENTLY INSTALLED: " << file;
2056 qDeleteAll(entries);
2057 initEffects::refreshLumas();
2060 void MainWindow::slotAutoTransition() {
2061 m_activeTimeline->projectView()->autoTransition();
2064 #include "mainwindow.moc"