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>
53 #include <mlt++/Mlt.h>
55 #include "mainwindow.h"
56 #include "kdenlivesettings.h"
57 #include "kdenlivesettingsdialog.h"
58 #include "initeffects.h"
59 #include "profilesdialog.h"
60 #include "projectsettings.h"
62 #include "renderjob.h"
63 #include "clipmanager.h"
64 #include "projectlist.h"
66 #include "recmonitor.h"
67 #include "monitormanager.h"
68 #include "kdenlivedoc.h"
69 #include "trackview.h"
70 #include "customtrackview.h"
71 #include "effectslistview.h"
72 #include "effectstackview.h"
73 #include "transitionsettings.h"
74 #include "renderwidget.h"
76 #include "jogshuttle.h"
77 #include "clipproperties.h"
79 #include "editclipcommand.h"
80 #include "titlewidget.h"
82 static const int ID_STATUS_MSG = 1;
83 static const int ID_EDITMODE_MSG = 2;
84 static const int ID_TIMELINE_MSG = 3;
85 static const int ID_TIMELINE_BUTTONS = 5;
86 static const int ID_TIMELINE_POS = 6;
87 static const int ID_TIMELINE_FORMAT = 7;
93 EffectsList MainWindow::videoEffects;
94 EffectsList MainWindow::audioEffects;
95 EffectsList MainWindow::customEffects;
96 EffectsList MainWindow::transitions;
98 MainWindow::MainWindow(QWidget *parent)
99 : KXmlGuiWindow(parent),
100 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
101 setlocale(LC_NUMERIC, "POSIX");
102 setFont(KGlobalSettings::toolBarFont());
104 m_commandStack = new QUndoGroup;
105 m_timelineArea = new KTabWidget(this);
106 m_timelineArea->setTabReorderingEnabled(true);
107 m_timelineArea->setTabBarHidden(true);
109 QToolButton *closeTabButton = new QToolButton;
110 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
111 closeTabButton->setIcon(KIcon("tab-close"));
112 closeTabButton->adjustSize();
113 closeTabButton->setToolTip(i18n("Close the current tab"));
114 m_timelineArea->setCornerWidget(closeTabButton);
115 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
117 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
118 m_findTimer.setSingleShot(true);
120 initEffects::parseEffectFiles();
121 m_monitorManager = new MonitorManager();
123 projectListDock = new QDockWidget(i18n("Project Tree"), this);
124 projectListDock->setObjectName("project_tree");
125 m_projectList = new ProjectList(this);
126 projectListDock->setWidget(m_projectList);
127 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
129 effectListDock = new QDockWidget(i18n("Effect List"), this);
130 effectListDock->setObjectName("effect_list");
131 m_effectList = new EffectsListView();
133 //m_effectList = new KListWidget(this);
134 effectListDock->setWidget(m_effectList);
135 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
137 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
138 effectStackDock->setObjectName("effect_stack");
139 effectStack = new EffectStackView(this);
140 effectStackDock->setWidget(effectStack);
141 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
143 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
144 transitionConfigDock->setObjectName("transition");
145 transitionConfig = new TransitionSettings(this);
146 transitionConfigDock->setWidget(transitionConfig);
147 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
149 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
150 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
154 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
155 clipMonitorDock->setObjectName("clip_monitor");
156 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
157 clipMonitorDock->setWidget(m_clipMonitor);
158 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
159 //m_clipMonitor->stop();
161 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
162 projectMonitorDock->setObjectName("project_monitor");
163 m_projectMonitor = new Monitor("project", m_monitorManager, this);
164 projectMonitorDock->setWidget(m_projectMonitor);
165 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
167 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
168 recMonitorDock->setObjectName("record_monitor");
169 m_recMonitor = new RecMonitor("record", this);
170 recMonitorDock->setWidget(m_recMonitor);
171 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
173 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
174 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
176 undoViewDock = new QDockWidget(i18n("Undo History"), this);
177 undoViewDock->setObjectName("undo_history");
178 m_undoView = new QUndoView(this);
179 m_undoView->setCleanIcon(KIcon("edit-clear"));
180 m_undoView->setEmptyLabel(i18n("Clean"));
181 undoViewDock->setWidget(m_undoView);
182 m_undoView->setGroup(m_commandStack);
183 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
185 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
186 //overviewDock->setObjectName("project_overview");
187 //m_overView = new CustomTrackView(NULL, NULL, this);
188 //overviewDock->setWidget(m_overView);
189 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
192 //tabifyDockWidget(projectListDock, effectListDock);
193 tabifyDockWidget(projectListDock, effectStackDock);
194 tabifyDockWidget(projectListDock, transitionConfigDock);
195 //tabifyDockWidget(projectListDock, undoViewDock);
198 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
199 tabifyDockWidget(clipMonitorDock, recMonitorDock);
200 setCentralWidget(m_timelineArea);
202 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
203 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
205 // build effects menus
207 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
208 QStringList effects = videoEffects.effectNames();
209 foreach(const QString &name, effects) {
210 action = new QAction(name, this);
211 action->setData(name);
212 videoEffectsMenu->addAction(action);
214 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
215 effects = audioEffects.effectNames();
216 foreach(const QString &name, effects) {
217 action = new QAction(name, this);
218 action->setData(name);
219 audioEffectsMenu->addAction(action);
221 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
222 effects = customEffects.effectNames();
223 foreach(const QString &name, effects) {
224 action = new QAction(name, this);
225 action->setData(name);
226 m_customEffectsMenu->addAction(action);
229 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
230 const QList<QAction *> viewActions = createPopupMenu()->actions();
231 viewMenu->insertActions(NULL, viewActions);
233 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
234 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
235 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
237 m_timelineContextMenu = new QMenu(this);
238 m_timelineContextClipMenu = new QMenu(this);
239 m_timelineContextTransitionMenu = new QMenu(this);
242 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
243 effects = transitions.effectNames();
244 foreach(const QString &name, effects) {
245 action = new QAction(name, this);
246 action->setData(name);
247 transitionsMenu->addAction(action);
249 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
251 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
253 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
254 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
255 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
256 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
257 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
259 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
260 m_timelineContextClipMenu->addMenu(markersMenu);
261 m_timelineContextClipMenu->addMenu(transitionsMenu);
262 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
263 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
264 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
266 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
267 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
269 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
270 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
271 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
272 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
273 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
274 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
276 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
277 slotConnectMonitors();
279 setAutoSaveSettings();
281 if (KdenliveSettings::openlastproject()) {
284 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
285 if (!staleFiles.isEmpty()) {
286 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) {
287 recoverFiles(staleFiles);
295 activateShuttleDevice();
296 projectListDock->raise();
299 void MainWindow::queryQuit() {
300 kDebug() << "----- SAVING CONFUIG";
301 if (queryClose()) kapp->quit();
305 bool MainWindow::queryClose() {
307 if (m_activeDocument && m_activeDocument->isModified()) {
308 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
309 case KMessageBox::Yes :
310 // save document here. If saving fails, return false;
313 case KMessageBox::No :
322 void MainWindow::saveProperties(KConfig*) {
323 // save properties here,used by session management
328 void MainWindow::readProperties(KConfig *config) {
329 // read properties here,used by session management
330 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
331 openFile(KUrl(Lastproject));
334 void MainWindow::slotReloadEffects() {
335 initEffects::parseCustomEffectsFile();
336 m_customEffectsMenu->clear();
337 const QStringList effects = customEffects.effectNames();
339 foreach(const QString &name, effects) {
340 action = new QAction(name, this);
341 action->setData(name);
342 m_customEffectsMenu->addAction(action);
344 m_effectList->reloadEffectList();
347 void MainWindow::activateShuttleDevice() {
348 if (m_jogProcess) delete m_jogProcess;
350 if (KdenliveSettings::enableshuttle() == false) return;
351 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
352 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
353 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
354 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
355 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
356 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
357 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
360 void MainWindow::slotShuttleButton(int code) {
363 slotShuttleAction(KdenliveSettings::shuttle1());
366 slotShuttleAction(KdenliveSettings::shuttle2());
369 slotShuttleAction(KdenliveSettings::shuttle3());
372 slotShuttleAction(KdenliveSettings::shuttle4());
375 slotShuttleAction(KdenliveSettings::shuttle5());
380 void MainWindow::slotShuttleAction(int code) {
385 m_monitorManager->slotPlay();
388 m_monitorManager->slotPlay();
393 void MainWindow::slotFullScreen() {
394 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
397 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
398 if (!m_activeDocument) return;
399 if (effect.isNull()) {
400 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
403 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
404 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
407 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
408 if (clipMonitor) clipMonitorDock->raise();
409 else projectMonitorDock->raise();
412 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
413 if (!m_activeDocument) return;
414 m_activeDocument->setProducerDuration(id, duration);
417 void MainWindow::slotConnectMonitors() {
419 m_projectList->setRenderer(m_clipMonitor->render);
420 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
421 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
422 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
423 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
424 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 > &)));
426 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
428 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
430 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
431 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
434 void MainWindow::slotAdjustClipMonitor() {
435 clipMonitorDock->updateGeometry();
436 clipMonitorDock->adjustSize();
437 m_clipMonitor->resetSize();
440 void MainWindow::slotAdjustProjectMonitor() {
441 projectMonitorDock->updateGeometry();
442 projectMonitorDock->adjustSize();
443 m_projectMonitor->resetSize();
446 void MainWindow::setupActions() {
448 m_timecodeFormat = new KComboBox(this);
449 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
450 m_timecodeFormat->addItem(i18n("Frames"));
452 statusProgressBar = new QProgressBar(this);
453 statusProgressBar->setMinimum(0);
454 statusProgressBar->setMaximum(100);
455 statusProgressBar->setMaximumWidth(150);
456 statusProgressBar->setVisible(false);
458 QWidget *w = new QWidget;
460 QHBoxLayout *layout = new QHBoxLayout;
461 w->setLayout(layout);
462 layout->setContentsMargins(5, 0, 5, 0);
463 QToolBar *toolbar = new QToolBar("statusToolBar", this);
466 m_toolGroup = new QActionGroup(this);
468 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;}";
470 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
471 m_buttonSelectTool->setCheckable(true);
472 m_buttonSelectTool->setChecked(true);
474 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
475 m_buttonRazorTool->setCheckable(true);
476 m_buttonRazorTool->setChecked(false);
478 m_toolGroup->addAction(m_buttonSelectTool);
479 m_toolGroup->addAction(m_buttonRazorTool);
480 m_toolGroup->setExclusive(true);
481 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
483 QWidget * actionWidget;
484 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
485 actionWidget->setMaximumWidth(24);
486 actionWidget->setMinimumHeight(17);
488 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
489 actionWidget->setMaximumWidth(24);
490 actionWidget->setMinimumHeight(17);
492 toolbar->setStyleSheet(style1);
493 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
495 toolbar->addSeparator();
496 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
497 m_buttonFitZoom->setCheckable(false);
498 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
500 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
501 actionWidget->setMaximumWidth(24);
502 actionWidget->setMinimumHeight(17);
504 m_zoomSlider = new QSlider(Qt::Horizontal, this);
505 m_zoomSlider->setMaximum(13);
506 m_zoomSlider->setPageStep(1);
508 m_zoomSlider->setMaximumWidth(150);
509 m_zoomSlider->setMinimumWidth(100);
511 const int contentHeight = QFontMetrics(w->font()).height() + 8;
512 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
513 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
514 m_zoomSlider->setStyleSheet(style);
516 //m_zoomSlider->setMaximumHeight(contentHeight);
517 //m_zoomSlider->height() + 5;
518 statusBar()->setMinimumHeight(contentHeight);
521 toolbar->addWidget(m_zoomSlider);
523 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
524 m_buttonVideoThumbs->setCheckable(true);
525 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
526 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
528 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
529 m_buttonAudioThumbs->setCheckable(true);
530 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
531 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
533 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
534 m_buttonShowMarkers->setCheckable(true);
535 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
536 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
538 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
539 m_buttonSnap->setCheckable(true);
540 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
541 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
542 layout->addWidget(toolbar);
545 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
546 actionWidget->setMaximumWidth(24);
547 actionWidget->setMinimumHeight(17);
549 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
550 actionWidget->setMaximumWidth(24);
551 actionWidget->setMinimumHeight(17);
553 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
554 actionWidget->setMaximumWidth(24);
555 actionWidget->setMinimumHeight(17);
557 actionWidget = toolbar->widgetForAction(m_buttonSnap);
558 actionWidget->setMaximumWidth(24);
559 actionWidget->setMinimumHeight(17);
561 m_messageLabel = new StatusBarMessageLabel(this);
562 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
564 statusBar()->addWidget(m_messageLabel, 10);
565 statusBar()->addWidget(statusProgressBar, 0);
566 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
567 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
568 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
569 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
570 m_messageLabel->hide();
572 actionCollection()->addAction("select_tool", m_buttonSelectTool);
573 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
575 actionCollection()->addAction("show_video_thumbs", m_buttonVideoThumbs);
576 actionCollection()->addAction("show_audio_thumbs", m_buttonAudioThumbs);
577 actionCollection()->addAction("show_markers", m_buttonShowMarkers);
578 actionCollection()->addAction("snap", m_buttonSnap);
579 actionCollection()->addAction("zoom_fit", m_buttonFitZoom);
581 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
582 actionCollection()->addAction("project_find", m_projectSearch);
583 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
584 m_projectSearch->setShortcut(Qt::Key_Slash);
586 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
587 actionCollection()->addAction("project_find_next", m_projectSearchNext);
588 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
589 m_projectSearchNext->setShortcut(Qt::Key_F3);
590 m_projectSearchNext->setEnabled(false);
592 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
593 actionCollection()->addAction("manage_profiles", profilesAction);
594 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
596 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
597 actionCollection()->addAction("project_settings", projectAction);
598 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
600 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
601 actionCollection()->addAction("project_render", projectRender);
602 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
604 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
605 monitorPlay->setShortcut(Qt::Key_Space);
606 actionCollection()->addAction("monitor_play", monitorPlay);
607 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
609 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
610 monitorSeekBackward->setShortcut(Qt::Key_J);
611 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
612 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
614 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
615 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
616 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
617 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
619 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
620 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
621 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
622 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
624 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
625 monitorSeekForward->setShortcut(Qt::Key_L);
626 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
627 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
629 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
630 clipStart->setShortcut(Qt::Key_Home);
631 actionCollection()->addAction("seek_clip_start", clipStart);
632 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
634 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
635 clipEnd->setShortcut(Qt::Key_End);
636 actionCollection()->addAction("seek_clip_end", clipEnd);
637 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
639 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
640 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
641 actionCollection()->addAction("seek_start", projectStart);
642 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
644 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
645 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
646 actionCollection()->addAction("seek_end", projectEnd);
647 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
649 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
650 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
651 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
652 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
654 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
655 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
656 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
657 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
659 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
660 deleteTimelineClip->setShortcut(Qt::Key_Delete);
661 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
662 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
664 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
665 actionCollection()->addAction("change_clip_speed", editTimelineClipSpeed);
666 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
668 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
669 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
670 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
671 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
673 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
674 actionCollection()->addAction("add_clip_marker", addClipMarker);
675 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
677 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
678 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
679 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
681 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
682 actionCollection()->addAction("delete_all_clip_markers", deleteAllClipMarkers);
683 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
685 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
686 actionCollection()->addAction("edit_clip_marker", editClipMarker);
687 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
689 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
690 actionCollection()->addAction("add_guide", addGuide);
691 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
693 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
694 actionCollection()->addAction("delete_guide", delGuide);
695 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
697 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
698 actionCollection()->addAction("edit_guide", editGuide);
699 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
701 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
702 actionCollection()->addAction("delete_all_guides", delAllGuides);
703 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
705 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
706 actionCollection()->addAction("paste_effects", pasteEffects);
707 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
709 KStandardAction::quit(this, SLOT(queryQuit()),
712 KStandardAction::open(this, SLOT(openFile()),
715 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
718 KStandardAction::saveAs(this, SLOT(saveFileAs()),
721 KStandardAction::openNew(this, SLOT(newFile()),
724 KStandardAction::preferences(this, SLOT(slotPreferences()),
727 KStandardAction::copy(this, SLOT(slotCopy()),
730 KStandardAction::paste(this, SLOT(slotPaste()),
733 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
735 undo->setEnabled(false);
736 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
738 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
740 redo->setEnabled(false);
741 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
743 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
745 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
746 this, SLOT(slotDisplayActionMessage(QAction*)));
747 //connect(actionCollection(), SIGNAL( clearStatusText() ),
748 //statusBar(), SLOT( clear() ) );
751 void MainWindow::slotDisplayActionMessage(QAction *a) {
752 statusBar()->showMessage(a->data().toString(), 3000);
755 void MainWindow::saveOptions() {
756 KdenliveSettings::self()->writeConfig();
757 KSharedConfigPtr config = KGlobal::config();
758 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
762 void MainWindow::readOptions() {
763 KSharedConfigPtr config = KGlobal::config();
764 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
765 KConfigGroup initialGroup(config, "version");
766 if (!initialGroup.exists()) {
767 // this is our first run, show Wizard
768 Wizard *w = new Wizard(this);
769 if (w->exec() == QDialog::Accepted) {
771 initialGroup.writeEntry("version", "0.7");
777 void MainWindow::newFile() {
780 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
782 ProjectSettings *w = new ProjectSettings;
783 if (w->exec() != QDialog::Accepted) return;
784 profileName = w->selectedProfile();
785 projectFolder = w->selectedFolder();
788 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, this);
789 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
790 TrackView *trackView = new TrackView(doc, this);
791 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
792 if (m_timelineArea->count() == 1) {
793 connectDocumentInfo(doc);
794 connectDocument(trackView, doc);
795 } else m_timelineArea->setTabBarHidden(false);
798 void MainWindow::activateDocument() {
799 if (m_timelineArea->currentWidget() == NULL) return;
800 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
801 KdenliveDoc *currentDoc = currentTab->document();
802 connectDocumentInfo(currentDoc);
803 connectDocument(currentTab, currentDoc);
806 void MainWindow::closeCurrentDocument() {
807 QWidget *w = m_timelineArea->currentWidget();
808 // closing current document
809 int ix = m_timelineArea->currentIndex() + 1;
810 if (ix == m_timelineArea->count()) ix = 0;
811 m_timelineArea->setCurrentIndex(ix);
812 TrackView *tabToClose = (TrackView *) w;
813 KdenliveDoc *docToClose = tabToClose->document();
814 if (docToClose && docToClose->isModified()) {
815 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
816 case KMessageBox::Yes :
817 // save document here. If saving fails, return false;
820 case KMessageBox::Cancel :
826 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
827 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
830 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
833 void MainWindow::saveFileAs(const QString &outputFileName) {
834 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
835 m_activeDocument->setUrl(KUrl(outputFileName));
836 if (m_activeDocument->m_autosave == NULL) {
837 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
838 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
839 setCaption(m_activeDocument->description());
840 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
841 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
842 m_activeDocument->setModified(false);
843 m_fileOpenRecent->addUrl(KUrl(outputFileName));
846 void MainWindow::saveFileAs() {
847 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
848 if (QFile::exists(outputFile)) {
849 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
851 saveFileAs(outputFile);
854 void MainWindow::saveFile() {
855 if (!m_activeDocument) return;
856 if (m_activeDocument->url().isEmpty()) {
859 saveFileAs(m_activeDocument->url().path());
860 m_activeDocument->m_autosave->resize(0);
864 void MainWindow::openFile() {
865 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
866 if (url.isEmpty()) return;
867 m_fileOpenRecent->addUrl(url);
871 void MainWindow::openLastFile() {
872 KSharedConfigPtr config = KGlobal::config();
873 KUrl::List urls = m_fileOpenRecent->urls();
874 if (urls.isEmpty()) newFile();
875 else openFile(urls.last());
878 void MainWindow::openFile(const KUrl &url) {
879 // Check for backup file
880 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
881 if (!staleFiles.isEmpty()) {
882 if (KMessageBox::questionYesNo(this,
883 i18n("Auto-saved files exist. Do you want to recover them now?"),
884 i18n("File Recovery"),
885 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
886 recoverFiles(staleFiles);
889 // remove the stale files
890 foreach(KAutoSaveFile *stale, staleFiles) {
891 stale->open(QIODevice::ReadWrite);
896 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
897 doOpenFile(url, NULL);
900 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
902 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), this);
904 stale = new KAutoSaveFile(url, doc);
905 doc->m_autosave = stale;
907 doc->m_autosave = stale;
908 doc->setUrl(stale->managedFile());
909 doc->setModified(true);
910 stale->setParent(doc);
912 connectDocumentInfo(doc);
913 TrackView *trackView = new TrackView(doc, this);
914 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
915 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
916 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
917 slotGotProgressInfo(QString(), -1);
918 m_clipMonitor->refreshMonitor(true);
921 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
922 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
923 foreach(KAutoSaveFile *stale, staleFiles) {
924 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
925 // show an error message; we could not steal the lockfile
926 // maybe another application got to the file before us?
930 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
931 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
932 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
933 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
938 void MainWindow::parseProfiles() {
939 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
941 //KdenliveSettings::setDefaulttmpfolder();
942 if (KdenliveSettings::mltpath().isEmpty()) {
943 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
945 if (KdenliveSettings::rendererpath().isEmpty()) {
946 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
948 QStringList profilesFilter;
949 profilesFilter << "*";
950 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
952 if (profilesList.isEmpty()) {
953 // Cannot find MLT path, try finding inigo
954 QString profilePath = KdenliveSettings::rendererpath();
955 if (!profilePath.isEmpty()) {
956 profilePath = profilePath.section('/', 0, -3);
957 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
958 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
961 if (profilesList.isEmpty()) {
962 // Cannot find the MLT profiles, ask for location
963 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
964 getUrl->fileDialog()->setMode(KFile::Directory);
966 KUrl mltPath = getUrl->selectedUrl();
968 if (mltPath.isEmpty()) kapp->quit();
969 KdenliveSettings::setMltpath(mltPath.path());
970 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
974 if (KdenliveSettings::rendererpath().isEmpty()) {
975 // Cannot find the MLT inigo renderer, ask for location
976 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
978 KUrl rendererPath = getUrl->selectedUrl();
980 if (rendererPath.isEmpty()) kapp->quit();
981 KdenliveSettings::setRendererpath(rendererPath.path());
984 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
986 // Parse MLT profiles to build a list of available video formats
987 if (profilesList.isEmpty()) parseProfiles();
991 void MainWindow::slotEditProfiles() {
992 ProfilesDialog *w = new ProfilesDialog;
997 void MainWindow::slotEditProjectSettings() {
998 ProjectSettings *w = new ProjectSettings;
999 if (w->exec() == QDialog::Accepted) {
1000 QString profile = w->selectedProfile();
1001 m_activeDocument->setProfilePath(profile);
1002 KdenliveSettings::setCurrent_profile(profile);
1003 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1004 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1005 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1006 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1007 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1009 // We need to desactivate & reactivate monitors to get a refresh
1010 m_monitorManager->switchMonitors();
1015 void MainWindow::slotRenderProject() {
1016 if (!m_renderWidget) {
1017 m_renderWidget = new RenderWidget(this);
1018 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool)));
1020 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1021 if (currentTab) m_renderWidget->setTimeline(currentTab);
1022 m_renderWidget->setDocument(m_activeDocument);*/
1023 m_renderWidget->show();
1026 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
1027 if (dest.isEmpty()) return;
1030 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1031 if (currentTab && zoneOnly) {
1032 in = currentTab->inPoint();
1033 out = currentTab->outPoint();
1035 KTemporaryFile temp;
1036 temp.setAutoRemove(false);
1037 temp.setSuffix(".westley");
1039 m_projectMonitor->saveSceneList(temp.fileName());
1042 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1043 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1044 QString videoPlayer = "-";
1046 videoPlayer = KdenliveSettings::defaultplayerapp();
1047 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."));
1049 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1050 QProcess::startDetached("kdenlive_render", args);
1051 kDebug() << "/// STARTING RENDER PROCESS\n\nARGS:\n" << args;
1055 void MainWindow::slotUpdateMousePosition(int pos) {
1056 if (m_activeDocument)
1057 switch (m_timecodeFormat->currentIndex()) {
1059 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1062 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1066 void MainWindow::slotUpdateDocumentState(bool modified) {
1067 setCaption(m_activeDocument->description(), modified);
1068 m_saveAction->setEnabled(modified);
1070 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1071 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1073 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1074 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1078 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1079 if (m_activeDocument) {
1080 if (m_activeDocument == doc) return;
1081 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1083 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1086 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1087 //m_projectMonitor->stop();
1088 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1089 if (m_activeDocument) {
1090 if (m_activeDocument == doc) return;
1091 m_activeDocument->backupMltPlaylist();
1092 if (m_activeTimeline) {
1093 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1094 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1095 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1096 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1097 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1098 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1099 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1100 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1101 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1102 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1103 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1104 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1105 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1106 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1107 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1108 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1110 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1111 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1112 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1113 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1114 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1115 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1116 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1117 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1118 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1119 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1120 effectStack->clear();
1122 m_activeDocument->setRenderer(NULL);
1123 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1124 m_clipMonitor->stop();
1126 KdenliveSettings::setCurrent_profile(doc->profilePath());
1127 KdenliveSettings::setProject_fps(doc->fps());
1128 m_monitorManager->resetProfiles(doc->timecode());
1129 m_projectList->setDocument(doc);
1130 transitionConfig->updateProjectFormat(doc->mltProfile());
1131 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1132 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1133 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1134 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1135 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1136 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1137 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1138 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1139 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1140 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1141 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1143 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1144 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1148 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1149 connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1150 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1151 connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1152 m_zoomSlider->setValue(doc->zoom());
1153 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1154 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1155 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1156 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1158 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1161 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1162 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1163 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1164 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1165 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1166 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1167 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1168 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1170 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1171 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1172 m_activeTimeline = trackView;
1173 if (m_renderWidget) m_renderWidget->setDocumentStandard(doc->getDocumentStandard());
1174 doc->setRenderer(m_projectMonitor->render);
1175 m_commandStack->setActiveStack(doc->commandStack());
1176 KdenliveSettings::setProject_display_ratio(doc->dar());
1177 doc->updateAllProjectClips();
1180 //m_overView->setScene(trackView->projectScene());
1181 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1182 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1184 setCaption(doc->description(), doc->isModified());
1185 m_saveAction->setEnabled(doc->isModified());
1186 m_activeDocument = doc;
1189 void MainWindow::slotPreferences(int page, int option) {
1190 //An instance of your dialog could be already created and could be
1191 // cached, in which case you want to display the cached dialog
1192 // instead of creating another one
1193 if (KConfigDialog::showDialog("settings")) {
1194 if (page != -1) static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"))->showPage(page, option);
1198 // KConfigDialog didn't find an instance of this dialog, so lets
1200 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1201 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1202 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1204 if (page != -1) dialog->showPage(page, option);
1207 void MainWindow::updateConfiguration() {
1208 //TODO: we should apply settings to all projects, not only the current one
1209 if (m_activeTimeline) {
1210 m_activeTimeline->refresh();
1211 m_activeTimeline->projectView()->checkAutoScroll();
1212 m_activeTimeline->projectView()->checkTrackHeight();
1213 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1215 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1216 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1217 activateShuttleDevice();
1221 void MainWindow::slotSwitchVideoThumbs() {
1222 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1223 if (m_activeTimeline) {
1224 m_activeTimeline->refresh();
1226 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1229 void MainWindow::slotSwitchAudioThumbs() {
1230 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1231 if (m_activeTimeline) {
1232 m_activeTimeline->refresh();
1233 m_activeTimeline->projectView()->checkAutoScroll();
1234 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1236 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1239 void MainWindow::slotSwitchMarkersComments() {
1240 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1241 if (m_activeTimeline) {
1242 m_activeTimeline->refresh();
1244 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1247 void MainWindow::slotSwitchSnap() {
1248 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1249 m_buttonShowMarkers->setChecked(KdenliveSettings::snaptopoints());
1253 void MainWindow::slotDeleteTimelineClip() {
1254 if (m_activeTimeline) {
1255 m_activeTimeline->projectView()->deleteSelectedClips();
1259 void MainWindow::slotChangeClipSpeed() {
1260 if (m_activeTimeline) {
1261 m_activeTimeline->projectView()->changeClipSpeed();
1265 void MainWindow::slotAddClipMarker() {
1266 if (m_activeTimeline) {
1267 m_activeTimeline->projectView()->slotAddClipMarker();
1271 void MainWindow::slotDeleteClipMarker() {
1272 if (m_activeTimeline) {
1273 m_activeTimeline->projectView()->slotDeleteClipMarker();
1277 void MainWindow::slotDeleteAllClipMarkers() {
1278 if (m_activeTimeline) {
1279 m_activeTimeline->projectView()->slotDeleteAllClipMarkers();
1283 void MainWindow::slotEditClipMarker() {
1284 if (m_activeTimeline) {
1285 m_activeTimeline->projectView()->slotEditClipMarker();
1289 void MainWindow::slotAddGuide() {
1290 if (m_activeTimeline)
1291 m_activeTimeline->projectView()->slotAddGuide();
1294 void MainWindow::slotEditGuide() {
1295 if (m_activeTimeline)
1296 m_activeTimeline->projectView()->slotEditGuide();
1299 void MainWindow::slotDeleteGuide() {
1300 if (m_activeTimeline)
1301 m_activeTimeline->projectView()->slotDeleteGuide();
1304 void MainWindow::slotDeleteAllGuides() {
1305 if (m_activeTimeline)
1306 m_activeTimeline->projectView()->slotDeleteAllGuides();
1309 void MainWindow::slotCutTimelineClip() {
1310 if (m_activeTimeline) {
1311 m_activeTimeline->projectView()->cutSelectedClips();
1315 void MainWindow::slotAddProjectClip(KUrl url) {
1316 if (m_activeDocument)
1317 m_activeDocument->slotAddClipFile(url, QString());
1320 void MainWindow::slotAddTransition(QAction *result) {
1321 if (!result) return;
1322 QDomElement effect = transitions.getEffectByName(result->data().toString());
1323 if (m_activeTimeline) {
1324 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(effect);
1328 void MainWindow::slotAddVideoEffect(QAction *result) {
1329 if (!result) return;
1330 QDomElement effect = videoEffects.getEffectByName(result->data().toString());
1331 slotAddEffect(effect);
1334 void MainWindow::slotAddAudioEffect(QAction *result) {
1335 if (!result) return;
1336 QDomElement effect = audioEffects.getEffectByName(result->data().toString());
1337 slotAddEffect(effect);
1340 void MainWindow::slotAddCustomEffect(QAction *result) {
1341 if (!result) return;
1342 QDomElement effect = customEffects.getEffectByName(result->data().toString());
1343 slotAddEffect(effect);
1346 void MainWindow::slotZoomIn() {
1347 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1350 void MainWindow::slotZoomOut() {
1351 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1354 void MainWindow::slotFitZoom() {
1355 if (m_activeTimeline) {
1356 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1360 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1361 statusProgressBar->setValue(progress);
1362 if (progress >= 0) {
1363 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1364 statusProgressBar->setVisible(true);
1366 m_messageLabel->setMessage(QString(), DefaultMessage);
1367 statusProgressBar->setVisible(false);
1371 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1372 if (clip->clipType() == TEXT) {
1373 QString path = clip->getProperty("xml");
1374 TitleWidget *dia_ui = new TitleWidget(KUrl()/*path + ".kdenlivetitle")*/, path, m_projectMonitor->render, this);
1376 doc.setContent(clip->getProperty("xmldata"));
1377 dia_ui->setXml(doc);
1378 if (dia_ui->exec() == QDialog::Accepted) {
1379 kDebug() << "// UPDATUING CLIP TITLE: " << path;
1380 QPixmap pix = dia_ui->renderedPixmap();
1381 pix.save(path + ".png");
1382 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1383 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1384 QMap <QString, QString> newprops;
1385 newprops.insert("xmldata", dia_ui->xml().toString());
1386 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1387 m_activeDocument->commandStack()->push(command);
1388 //setModified(true);
1392 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1395 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1396 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1397 if (dia.exec() == QDialog::Accepted) {
1398 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1399 m_activeDocument->commandStack()->push(command);
1401 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1402 if (dia.needsTimelineRefresh()) {
1403 // update clip occurences in timeline
1404 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1409 void MainWindow::customEvent(QEvent* e) {
1410 if (e->type() == QEvent::User) {
1411 // The timeline playing position changed...
1412 kDebug() << "RECIEVED JOG EVEMNT!!!";
1415 void MainWindow::slotActivateEffectStackView() {
1416 effectStack->raiseWindow(effectStackDock);
1419 void MainWindow::slotActivateTransitionView() {
1420 transitionConfig->raiseWindow(transitionConfigDock);
1423 void MainWindow::slotSnapRewind() {
1424 if (m_monitorManager->projectMonitorFocused()) {
1425 if (m_activeTimeline)
1426 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1430 void MainWindow::slotSnapForward() {
1431 if (m_monitorManager->projectMonitorFocused()) {
1432 if (m_activeTimeline)
1433 m_activeTimeline->projectView()->slotSeekToNextSnap();
1437 void MainWindow::slotClipStart() {
1438 if (m_monitorManager->projectMonitorFocused()) {
1439 if (m_activeTimeline)
1440 m_activeTimeline->projectView()->clipStart();
1444 void MainWindow::slotClipEnd() {
1445 if (m_monitorManager->projectMonitorFocused()) {
1446 if (m_activeTimeline)
1447 m_activeTimeline->projectView()->clipEnd();
1451 void MainWindow::slotChangeTool(QAction * action) {
1452 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1453 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1456 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1457 if (m_activeDocument && m_activeTimeline) {
1458 //m_activeDocument->setTool(tool);
1459 m_activeTimeline->projectView()->setTool(tool);
1463 void MainWindow::slotCopy() {
1464 if (!m_activeDocument || !m_activeTimeline) return;
1465 m_activeTimeline->projectView()->copyClip();
1468 void MainWindow::slotPaste() {
1469 if (!m_activeDocument || !m_activeTimeline) return;
1470 m_activeTimeline->projectView()->pasteClip();
1473 void MainWindow::slotPasteEffects() {
1474 if (!m_activeDocument || !m_activeTimeline) return;
1475 m_activeTimeline->projectView()->pasteClipEffects();
1478 void MainWindow::slotFind() {
1479 if (!m_activeDocument || !m_activeTimeline) return;
1480 m_projectSearch->setEnabled(false);
1481 m_findActivated = true;
1482 m_findString = QString();
1483 m_activeTimeline->projectView()->initSearchStrings();
1484 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1485 m_findTimer.start(5000);
1486 qApp->installEventFilter(this);
1489 void MainWindow::slotFindNext() {
1490 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1491 statusBar()->showMessage(i18n("Found : %1", m_findString));
1493 statusBar()->showMessage(i18n("Reached end of project"));
1495 m_findTimer.start(4000);
1498 void MainWindow::findAhead() {
1499 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1500 m_projectSearchNext->setEnabled(true);
1501 statusBar()->showMessage(i18n("Found : %1", m_findString));
1503 m_projectSearchNext->setEnabled(false);
1504 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1508 void MainWindow::findTimeout() {
1509 m_projectSearchNext->setEnabled(false);
1510 m_findActivated = false;
1511 m_findString = QString();
1512 statusBar()->showMessage(i18n("Find stopped"), 3000);
1513 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1514 m_projectSearch->setEnabled(true);
1515 removeEventFilter(this);
1518 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1519 if (m_findActivated) {
1520 if (ke->key() == Qt::Key_Backspace) {
1521 m_findString = m_findString.left(m_findString.length() - 1);
1523 if (!m_findString.isEmpty()) {
1529 m_findTimer.start(4000);
1532 } else if (ke->key() == Qt::Key_Escape) {
1536 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1537 m_findString += ke->text();
1541 m_findTimer.start(4000);
1545 } else KXmlGuiWindow::keyPressEvent(ke);
1548 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1549 if (m_findActivated) {
1550 if (event->type() == QEvent::ShortcutOverride) {
1551 QKeyEvent* ke = (QKeyEvent*) event;
1552 if (ke->text().trimmed().isEmpty()) return false;
1555 } else return false;
1557 // pass the event on to the parent class
1558 return QMainWindow::eventFilter(obj, event);
1562 #include "mainwindow.moc"