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"
80 static const int ID_STATUS_MSG = 1;
81 static const int ID_EDITMODE_MSG = 2;
82 static const int ID_TIMELINE_MSG = 3;
83 static const int ID_TIMELINE_BUTTONS = 5;
84 static const int ID_TIMELINE_POS = 6;
85 static const int ID_TIMELINE_FORMAT = 7;
91 EffectsList MainWindow::videoEffects;
92 EffectsList MainWindow::audioEffects;
93 EffectsList MainWindow::customEffects;
94 EffectsList MainWindow::transitions;
96 MainWindow::MainWindow(QWidget *parent)
97 : KXmlGuiWindow(parent),
98 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), m_jogProcess(NULL), m_findActivated(false), m_initialized(false) {
99 setlocale(LC_NUMERIC, "POSIX");
100 setFont(KGlobalSettings::toolBarFont());
102 m_commandStack = new QUndoGroup;
103 m_timelineArea = new KTabWidget(this);
104 m_timelineArea->setTabReorderingEnabled(true);
105 m_timelineArea->setTabBarHidden(true);
107 QToolButton *closeTabButton = new QToolButton;
108 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
109 closeTabButton->setIcon(KIcon("tab-close"));
110 closeTabButton->adjustSize();
111 closeTabButton->setToolTip(i18n("Close the current tab"));
112 m_timelineArea->setCornerWidget(closeTabButton);
113 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
115 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
116 m_findTimer.setSingleShot(true);
118 initEffects::parseEffectFiles();
119 m_monitorManager = new MonitorManager();
121 projectListDock = new QDockWidget(i18n("Project Tree"), this);
122 projectListDock->setObjectName("project_tree");
123 m_projectList = new ProjectList(this);
124 projectListDock->setWidget(m_projectList);
125 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
127 effectListDock = new QDockWidget(i18n("Effect List"), this);
128 effectListDock->setObjectName("effect_list");
129 m_effectList = new EffectsListView();
131 //m_effectList = new KListWidget(this);
132 effectListDock->setWidget(m_effectList);
133 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
135 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
136 effectStackDock->setObjectName("effect_stack");
137 effectStack = new EffectStackView(this);
138 effectStackDock->setWidget(effectStack);
139 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
141 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
142 transitionConfigDock->setObjectName("transition");
143 transitionConfig = new TransitionSettings(this);
144 transitionConfigDock->setWidget(transitionConfig);
145 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
147 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
148 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
152 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
153 clipMonitorDock->setObjectName("clip_monitor");
154 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
155 clipMonitorDock->setWidget(m_clipMonitor);
156 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
157 //m_clipMonitor->stop();
159 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
160 projectMonitorDock->setObjectName("project_monitor");
161 m_projectMonitor = new Monitor("project", m_monitorManager, this);
162 projectMonitorDock->setWidget(m_projectMonitor);
163 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
165 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
166 recMonitorDock->setObjectName("record_monitor");
167 m_recMonitor = new RecMonitor("record", this);
168 recMonitorDock->setWidget(m_recMonitor);
169 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
171 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
172 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
174 undoViewDock = new QDockWidget(i18n("Undo History"), this);
175 undoViewDock->setObjectName("undo_history");
176 m_undoView = new QUndoView(this);
177 m_undoView->setCleanIcon(KIcon("edit-clear"));
178 m_undoView->setEmptyLabel(i18n("Clean"));
179 undoViewDock->setWidget(m_undoView);
180 m_undoView->setGroup(m_commandStack);
181 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
183 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
184 //overviewDock->setObjectName("project_overview");
185 //m_overView = new CustomTrackView(NULL, NULL, this);
186 //overviewDock->setWidget(m_overView);
187 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
190 //tabifyDockWidget(projectListDock, effectListDock);
191 tabifyDockWidget(projectListDock, effectStackDock);
192 tabifyDockWidget(projectListDock, transitionConfigDock);
193 //tabifyDockWidget(projectListDock, undoViewDock);
196 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
197 tabifyDockWidget(clipMonitorDock, recMonitorDock);
198 setCentralWidget(m_timelineArea);
200 setupGUI(Default, NULL /*"kdenliveui.rc"*/);
201 kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
203 // build effects menus
205 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
206 QStringList effects = videoEffects.effectNames();
207 foreach(const QString &name, effects) {
208 action = new QAction(name, this);
209 action->setData(name);
210 videoEffectsMenu->addAction(action);
212 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
213 effects = audioEffects.effectNames();
214 foreach(const QString &name, effects) {
215 action = new QAction(name, this);
216 action->setData(name);
217 audioEffectsMenu->addAction(action);
219 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
220 effects = customEffects.effectNames();
221 foreach(const QString &name, effects) {
222 action = new QAction(name, this);
223 action->setData(name);
224 m_customEffectsMenu->addAction(action);
227 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
228 const QList<QAction *> viewActions = createPopupMenu()->actions();
229 viewMenu->insertActions(NULL, viewActions);
231 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
232 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
233 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
235 m_timelineContextMenu = new QMenu(this);
236 m_timelineContextClipMenu = new QMenu(this);
237 m_timelineContextTransitionMenu = new QMenu(this);
240 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
241 effects = transitions.effectNames();
242 foreach(const QString &name, effects) {
243 action = new QAction(name, this);
244 action->setData(name);
245 transitionsMenu->addAction(action);
247 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
249 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
251 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
252 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
253 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
254 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
255 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
257 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
258 m_timelineContextClipMenu->addMenu(markersMenu);
259 m_timelineContextClipMenu->addMenu(transitionsMenu);
260 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
261 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
262 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
264 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
265 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
267 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
268 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
269 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
270 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
271 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
272 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
274 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
275 slotConnectMonitors();
277 setAutoSaveSettings();
279 if (KdenliveSettings::openlastproject()) {
282 /*QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::allStaleFiles();
283 if (!staleFiles.isEmpty()) {
284 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) {
285 recoverFiles(staleFiles);
293 activateShuttleDevice();
294 projectListDock->raise();
297 void MainWindow::queryQuit() {
298 kDebug() << "----- SAVING CONFUIG";
299 if (queryClose()) kapp->quit();
303 bool MainWindow::queryClose() {
305 if (m_activeDocument && m_activeDocument->isModified()) {
306 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
307 case KMessageBox::Yes :
308 // save document here. If saving fails, return false;
311 case KMessageBox::No :
320 void MainWindow::saveProperties(KConfig*) {
321 // save properties here,used by session management
326 void MainWindow::readProperties(KConfig *config) {
327 // read properties here,used by session management
328 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
329 openFile(KUrl(Lastproject));
332 void MainWindow::slotReloadEffects() {
333 initEffects::parseCustomEffectsFile();
334 m_customEffectsMenu->clear();
335 const QStringList effects = customEffects.effectNames();
337 foreach(const QString &name, effects) {
338 action = new QAction(name, this);
339 action->setData(name);
340 m_customEffectsMenu->addAction(action);
342 m_effectList->reloadEffectList();
345 void MainWindow::activateShuttleDevice() {
346 if (m_jogProcess) delete m_jogProcess;
348 if (KdenliveSettings::enableshuttle() == false) return;
349 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
350 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
351 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
352 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
353 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
354 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
355 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
358 void MainWindow::slotShuttleButton(int code) {
361 slotShuttleAction(KdenliveSettings::shuttle1());
364 slotShuttleAction(KdenliveSettings::shuttle2());
367 slotShuttleAction(KdenliveSettings::shuttle3());
370 slotShuttleAction(KdenliveSettings::shuttle4());
373 slotShuttleAction(KdenliveSettings::shuttle5());
378 void MainWindow::slotShuttleAction(int code) {
383 m_monitorManager->slotPlay();
386 m_monitorManager->slotPlay();
391 void MainWindow::slotFullScreen() {
392 //KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
395 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
396 if (!m_activeDocument) return;
397 if (effect.isNull()) {
398 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
401 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
402 currentTimeLine->projectView()->slotAddEffect(effect, pos, track);
405 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
406 if (clipMonitor) clipMonitorDock->raise();
407 else projectMonitorDock->raise();
410 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
411 if (!m_activeDocument) return;
412 m_activeDocument->setProducerDuration(id, duration);
415 void MainWindow::slotConnectMonitors() {
417 m_projectList->setRenderer(m_clipMonitor->render);
418 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
419 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
420 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
421 connect(m_clipMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
422 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 > &)));
424 connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
426 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
428 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
429 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
432 void MainWindow::slotAdjustClipMonitor() {
433 clipMonitorDock->updateGeometry();
434 clipMonitorDock->adjustSize();
435 m_clipMonitor->resetSize();
438 void MainWindow::slotAdjustProjectMonitor() {
439 projectMonitorDock->updateGeometry();
440 projectMonitorDock->adjustSize();
441 m_projectMonitor->resetSize();
444 void MainWindow::setupActions() {
446 m_timecodeFormat = new KComboBox(this);
447 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
448 m_timecodeFormat->addItem(i18n("Frames"));
450 statusProgressBar = new QProgressBar(this);
451 statusProgressBar->setMinimum(0);
452 statusProgressBar->setMaximum(100);
453 statusProgressBar->setMaximumWidth(150);
454 statusProgressBar->setVisible(false);
456 QWidget *w = new QWidget;
458 QHBoxLayout *layout = new QHBoxLayout;
459 w->setLayout(layout);
460 layout->setContentsMargins(5, 0, 5, 0);
461 QToolBar *toolbar = new QToolBar("statusToolBar", this);
464 m_toolGroup = new QActionGroup(this);
466 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;}";
468 m_buttonSelectTool = toolbar->addAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"));
469 m_buttonSelectTool->setCheckable(true);
470 m_buttonSelectTool->setChecked(true);
472 m_buttonRazorTool = toolbar->addAction(KIcon("edit-cut"), i18n("Razor tool"));
473 m_buttonRazorTool->setCheckable(true);
474 m_buttonRazorTool->setChecked(false);
476 m_toolGroup->addAction(m_buttonSelectTool);
477 m_toolGroup->addAction(m_buttonRazorTool);
478 m_toolGroup->setExclusive(true);
479 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
481 QWidget * actionWidget;
482 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
483 actionWidget->setMaximumWidth(24);
484 actionWidget->setMinimumHeight(17);
486 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
487 actionWidget->setMaximumWidth(24);
488 actionWidget->setMinimumHeight(17);
490 toolbar->setStyleSheet(style1);
491 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
493 toolbar->addSeparator();
494 m_buttonFitZoom = toolbar->addAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"));
495 m_buttonFitZoom->setCheckable(false);
496 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
498 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
499 actionWidget->setMaximumWidth(24);
500 actionWidget->setMinimumHeight(17);
502 m_zoomSlider = new QSlider(Qt::Horizontal, this);
503 m_zoomSlider->setMaximum(13);
504 m_zoomSlider->setPageStep(1);
506 m_zoomSlider->setMaximumWidth(150);
507 m_zoomSlider->setMinimumWidth(100);
509 const int contentHeight = QFontMetrics(w->font()).height() + 8;
510 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
511 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
512 m_zoomSlider->setStyleSheet(style);
514 //m_zoomSlider->setMaximumHeight(contentHeight);
515 //m_zoomSlider->height() + 5;
516 statusBar()->setMinimumHeight(contentHeight);
519 toolbar->addWidget(m_zoomSlider);
521 m_buttonVideoThumbs = toolbar->addAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"));
522 m_buttonVideoThumbs->setCheckable(true);
523 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
524 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
526 m_buttonAudioThumbs = toolbar->addAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"));
527 m_buttonAudioThumbs->setCheckable(true);
528 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
529 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
531 m_buttonShowMarkers = toolbar->addAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"));
532 m_buttonShowMarkers->setCheckable(true);
533 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
534 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
536 m_buttonSnap = toolbar->addAction(KIcon("kdenlive-snap"), i18n("Snap"));
537 m_buttonSnap->setCheckable(true);
538 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
539 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
540 layout->addWidget(toolbar);
543 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
544 actionWidget->setMaximumWidth(24);
545 actionWidget->setMinimumHeight(17);
547 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
548 actionWidget->setMaximumWidth(24);
549 actionWidget->setMinimumHeight(17);
551 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
552 actionWidget->setMaximumWidth(24);
553 actionWidget->setMinimumHeight(17);
555 actionWidget = toolbar->widgetForAction(m_buttonSnap);
556 actionWidget->setMaximumWidth(24);
557 actionWidget->setMinimumHeight(17);
559 m_messageLabel = new StatusBarMessageLabel(this);
560 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
562 statusBar()->addWidget(m_messageLabel, 10);
563 statusBar()->addWidget(statusProgressBar, 0);
564 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
565 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
566 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
567 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
568 m_messageLabel->hide();
570 actionCollection()->addAction("select_tool", m_buttonSelectTool);
571 actionCollection()->addAction("razor_tool", m_buttonRazorTool);
573 actionCollection()->addAction("show_video_thumbs", m_buttonVideoThumbs);
574 actionCollection()->addAction("show_audio_thumbs", m_buttonAudioThumbs);
575 actionCollection()->addAction("show_markers", m_buttonShowMarkers);
576 actionCollection()->addAction("snap", m_buttonSnap);
577 actionCollection()->addAction("zoom_fit", m_buttonFitZoom);
579 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
580 actionCollection()->addAction("project_find", m_projectSearch);
581 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
582 m_projectSearch->setShortcut(Qt::Key_Slash);
584 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
585 actionCollection()->addAction("project_find_next", m_projectSearchNext);
586 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
587 m_projectSearchNext->setShortcut(Qt::Key_F3);
588 m_projectSearchNext->setEnabled(false);
590 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
591 actionCollection()->addAction("manage_profiles", profilesAction);
592 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
594 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
595 actionCollection()->addAction("project_settings", projectAction);
596 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
598 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
599 actionCollection()->addAction("project_render", projectRender);
600 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
602 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
603 monitorPlay->setShortcut(Qt::Key_Space);
604 actionCollection()->addAction("monitor_play", monitorPlay);
605 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
607 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
608 monitorSeekBackward->setShortcut(Qt::Key_J);
609 actionCollection()->addAction("monitor_seek_backward", monitorSeekBackward);
610 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
612 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
613 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
614 actionCollection()->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
615 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
617 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
618 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
619 actionCollection()->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
620 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
622 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
623 monitorSeekForward->setShortcut(Qt::Key_L);
624 actionCollection()->addAction("monitor_seek_forward", monitorSeekForward);
625 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
627 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
628 clipStart->setShortcut(Qt::Key_Home);
629 actionCollection()->addAction("seek_clip_start", clipStart);
630 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
632 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
633 clipEnd->setShortcut(Qt::Key_End);
634 actionCollection()->addAction("seek_clip_end", clipEnd);
635 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
637 KAction* projectStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Project Start"), this);
638 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
639 actionCollection()->addAction("seek_start", projectStart);
640 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
642 KAction* projectEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Project End"), this);
643 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
644 actionCollection()->addAction("seek_end", projectEnd);
645 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
647 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
648 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
649 actionCollection()->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
650 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
652 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
653 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
654 actionCollection()->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
655 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
657 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
658 deleteTimelineClip->setShortcut(Qt::Key_Delete);
659 actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip);
660 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
662 KAction* editTimelineClipSpeed = new KAction(KIcon("edit-delete"), i18n("Change Clip Speed"), this);
663 actionCollection()->addAction("change_clip_speed", editTimelineClipSpeed);
664 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
666 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
667 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
668 actionCollection()->addAction("cut_timeline_clip", cutTimelineClip);
669 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
671 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker to Clip"), this);
672 actionCollection()->addAction("add_clip_marker", addClipMarker);
673 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
675 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker from Clip"), this);
676 actionCollection()->addAction("delete_clip_marker", deleteClipMarker);
677 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
679 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers from Clip"), this);
680 actionCollection()->addAction("delete_all_clip_markers", deleteAllClipMarkers);
681 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
683 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
684 actionCollection()->addAction("edit_clip_marker", editClipMarker);
685 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
687 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
688 actionCollection()->addAction("add_guide", addGuide);
689 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
691 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
692 actionCollection()->addAction("delete_guide", delGuide);
693 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
695 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
696 actionCollection()->addAction("edit_guide", editGuide);
697 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
699 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
700 actionCollection()->addAction("delete_all_guides", delAllGuides);
701 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
703 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
704 actionCollection()->addAction("paste_effects", pasteEffects);
705 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
707 KStandardAction::quit(this, SLOT(queryQuit()),
710 KStandardAction::open(this, SLOT(openFile()),
713 m_saveAction = KStandardAction::save(this, SLOT(saveFile()),
716 KStandardAction::saveAs(this, SLOT(saveFileAs()),
719 KStandardAction::openNew(this, SLOT(newFile()),
722 KStandardAction::preferences(this, SLOT(slotPreferences()),
725 KStandardAction::copy(this, SLOT(slotCopy()),
728 KStandardAction::paste(this, SLOT(slotPaste()),
731 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()),
733 undo->setEnabled(false);
734 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
736 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()),
738 redo->setEnabled(false);
739 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
741 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, actionCollection());
743 connect(actionCollection(), SIGNAL(actionHovered(QAction*)),
744 this, SLOT(slotDisplayActionMessage(QAction*)));
745 //connect(actionCollection(), SIGNAL( clearStatusText() ),
746 //statusBar(), SLOT( clear() ) );
749 void MainWindow::slotDisplayActionMessage(QAction *a) {
750 statusBar()->showMessage(a->data().toString(), 3000);
753 void MainWindow::saveOptions() {
754 KdenliveSettings::self()->writeConfig();
755 KSharedConfigPtr config = KGlobal::config();
756 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
760 void MainWindow::readOptions() {
761 KSharedConfigPtr config = KGlobal::config();
762 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
763 KConfigGroup initialGroup(config, "version");
764 if (!initialGroup.exists()) {
765 // this is our first run, show Wizard
766 Wizard *w = new Wizard(this);
767 if (w->exec() == QDialog::Accepted) {
769 initialGroup.writeEntry("version", "0.7");
775 void MainWindow::newFile() {
778 if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
780 ProjectSettings *w = new ProjectSettings;
781 if (w->exec() != QDialog::Accepted) return;
782 profileName = w->selectedProfile();
783 projectFolder = w->selectedFolder();
786 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, this);
787 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
788 TrackView *trackView = new TrackView(doc, this);
789 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
790 if (m_timelineArea->count() == 1) {
791 connectDocumentInfo(doc);
792 connectDocument(trackView, doc);
793 } else m_timelineArea->setTabBarHidden(false);
796 void MainWindow::activateDocument() {
797 if (m_timelineArea->currentWidget() == NULL) return;
798 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
799 KdenliveDoc *currentDoc = currentTab->document();
800 connectDocumentInfo(currentDoc);
801 connectDocument(currentTab, currentDoc);
804 void MainWindow::closeCurrentDocument() {
805 QWidget *w = m_timelineArea->currentWidget();
806 // closing current document
807 int ix = m_timelineArea->currentIndex() + 1;
808 if (ix == m_timelineArea->count()) ix = 0;
809 m_timelineArea->setCurrentIndex(ix);
810 TrackView *tabToClose = (TrackView *) w;
811 KdenliveDoc *docToClose = tabToClose->document();
812 if (docToClose && docToClose->isModified()) {
813 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
814 case KMessageBox::Yes :
815 // save document here. If saving fails, return false;
818 case KMessageBox::Cancel :
824 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
825 if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true);
828 if (m_timelineArea->count() == 0) m_activeDocument = NULL;
831 void MainWindow::saveFileAs(const QString &outputFileName) {
832 m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml());
833 m_activeDocument->setUrl(KUrl(outputFileName));
834 if (m_activeDocument->m_autosave == NULL) {
835 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
836 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
837 setCaption(m_activeDocument->description());
838 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
839 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
840 m_activeDocument->setModified(false);
841 m_fileOpenRecent->addUrl(KUrl(outputFileName));
844 void MainWindow::saveFileAs() {
845 QString outputFile = KFileDialog::getSaveFileName(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)");
846 if (QFile::exists(outputFile)) {
847 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return;
849 saveFileAs(outputFile);
852 void MainWindow::saveFile() {
853 if (!m_activeDocument) return;
854 if (m_activeDocument->url().isEmpty()) {
857 saveFileAs(m_activeDocument->url().path());
858 m_activeDocument->m_autosave->resize(0);
862 void MainWindow::openFile() {
863 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)");
864 if (url.isEmpty()) return;
865 m_fileOpenRecent->addUrl(url);
869 void MainWindow::openLastFile() {
870 KSharedConfigPtr config = KGlobal::config();
871 KUrl::List urls = m_fileOpenRecent->urls();
872 if (urls.isEmpty()) newFile();
873 else openFile(urls.last());
876 void MainWindow::openFile(const KUrl &url) {
877 // Check for backup file
878 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
879 if (!staleFiles.isEmpty()) {
880 if (KMessageBox::questionYesNo(this,
881 i18n("Auto-saved files exist. Do you want to recover them now?"),
882 i18n("File Recovery"),
883 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
884 recoverFiles(staleFiles);
887 // remove the stale files
888 foreach(KAutoSaveFile *stale, staleFiles) {
889 stale->open(QIODevice::ReadWrite);
894 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
895 doOpenFile(url, NULL);
898 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
900 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), this);
902 stale = new KAutoSaveFile(url, doc);
903 doc->m_autosave = stale;
905 doc->m_autosave = stale;
906 doc->setUrl(stale->managedFile());
907 doc->setModified(true);
908 stale->setParent(doc);
910 connectDocumentInfo(doc);
911 TrackView *trackView = new TrackView(doc, this);
912 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
913 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
914 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
915 slotGotProgressInfo(QString(), -1);
916 m_clipMonitor->refreshMonitor(true);
919 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
920 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
921 foreach(KAutoSaveFile *stale, staleFiles) {
922 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
923 // show an error message; we could not steal the lockfile
924 // maybe another application got to the file before us?
928 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
929 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
930 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
931 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
936 void MainWindow::parseProfiles() {
937 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
939 //KdenliveSettings::setDefaulttmpfolder();
940 if (KdenliveSettings::mltpath().isEmpty()) {
941 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
943 if (KdenliveSettings::rendererpath().isEmpty()) {
944 KdenliveSettings::setRendererpath(KStandardDirs::findExe("inigo"));
946 QStringList profilesFilter;
947 profilesFilter << "*";
948 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
950 if (profilesList.isEmpty()) {
951 // Cannot find MLT path, try finding inigo
952 QString profilePath = KdenliveSettings::rendererpath();
953 if (!profilePath.isEmpty()) {
954 profilePath = profilePath.section('/', 0, -3);
955 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
956 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
959 if (profilesList.isEmpty()) {
960 // Cannot find the MLT profiles, ask for location
961 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
962 getUrl->fileDialog()->setMode(KFile::Directory);
964 KUrl mltPath = getUrl->selectedUrl();
966 if (mltPath.isEmpty()) kapp->quit();
967 KdenliveSettings::setMltpath(mltPath.path());
968 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
972 if (KdenliveSettings::rendererpath().isEmpty()) {
973 // Cannot find the MLT inigo renderer, ask for location
974 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
976 KUrl rendererPath = getUrl->selectedUrl();
978 if (rendererPath.isEmpty()) kapp->quit();
979 KdenliveSettings::setRendererpath(rendererPath.path());
982 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
984 // Parse MLT profiles to build a list of available video formats
985 if (profilesList.isEmpty()) parseProfiles();
989 void MainWindow::slotEditProfiles() {
990 ProfilesDialog *w = new ProfilesDialog;
995 void MainWindow::slotEditProjectSettings() {
996 ProjectSettings *w = new ProjectSettings;
997 if (w->exec() == QDialog::Accepted) {
998 QString profile = w->selectedProfile();
999 m_activeDocument->setProfilePath(profile);
1000 KdenliveSettings::setCurrent_profile(profile);
1001 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1002 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1003 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1004 if (m_renderWidget) m_renderWidget->setDocumentStandard(m_activeDocument->getDocumentStandard());
1005 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1007 // We need to desactivate & reactivate monitors to get a refresh
1008 m_monitorManager->switchMonitors();
1013 void MainWindow::slotRenderProject() {
1014 if (!m_renderWidget) {
1015 m_renderWidget = new RenderWidget(this);
1016 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)));
1018 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1019 if (currentTab) m_renderWidget->setTimeline(currentTab);
1020 m_renderWidget->setDocument(m_activeDocument);*/
1021 m_renderWidget->show();
1024 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter) {
1025 if (dest.isEmpty()) return;
1028 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1029 if (currentTab && zoneOnly) {
1030 in = currentTab->inPoint();
1031 out = currentTab->outPoint();
1033 KTemporaryFile temp;
1034 temp.setAutoRemove(false);
1035 temp.setSuffix(".westley");
1037 m_projectMonitor->saveSceneList(temp.fileName());
1040 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1041 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1042 QString videoPlayer = "-";
1044 videoPlayer = KdenliveSettings::defaultplayerapp();
1045 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."));
1047 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1048 QProcess::startDetached("kdenlive_render", args);
1049 kDebug() << "/// STARTING RENDER PROCESS\n\nARGS:\n" << args;
1053 void MainWindow::slotUpdateMousePosition(int pos) {
1054 if (m_activeDocument)
1055 switch (m_timecodeFormat->currentIndex()) {
1057 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1060 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1064 void MainWindow::slotUpdateDocumentState(bool modified) {
1065 setCaption(m_activeDocument->description(), modified);
1066 m_saveAction->setEnabled(modified);
1068 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1069 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1071 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1072 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1076 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1077 if (m_activeDocument) {
1078 if (m_activeDocument == doc) return;
1079 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1081 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1084 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1085 //m_projectMonitor->stop();
1086 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1087 if (m_activeDocument) {
1088 if (m_activeDocument == doc) return;
1089 m_activeDocument->backupMltPlaylist();
1090 if (m_activeTimeline) {
1091 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1092 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1093 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1094 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1095 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1096 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1097 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1098 disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
1099 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1100 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1101 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
1102 disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
1103 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
1104 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
1105 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1106 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1107 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1109 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1110 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1111 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1112 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1113 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1114 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1115 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1116 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1117 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1118 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1119 effectStack->clear();
1121 m_activeDocument->setRenderer(NULL);
1122 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1123 m_clipMonitor->stop();
1125 KdenliveSettings::setCurrent_profile(doc->profilePath());
1126 KdenliveSettings::setProject_fps(doc->fps());
1127 m_monitorManager->resetProfiles(doc->timecode());
1128 m_projectList->setDocument(doc);
1129 transitionConfig->updateProjectFormat(doc->mltProfile());
1130 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1131 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1132 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1133 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1134 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1135 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1136 connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *)));
1137 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1138 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1139 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1140 connect(doc, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(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 m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1376 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1377 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1378 if (dia.exec() == QDialog::Accepted) {
1379 m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1380 if (dia.needsTimelineRefresh()) {
1381 // update clip occurences in timeline
1382 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1387 void MainWindow::customEvent(QEvent* e) {
1388 if (e->type() == QEvent::User) {
1389 // The timeline playing position changed...
1390 kDebug() << "RECIEVED JOG EVEMNT!!!";
1393 void MainWindow::slotActivateEffectStackView() {
1394 effectStack->raiseWindow(effectStackDock);
1397 void MainWindow::slotActivateTransitionView() {
1398 transitionConfig->raiseWindow(transitionConfigDock);
1401 void MainWindow::slotSnapRewind() {
1402 if (m_monitorManager->projectMonitorFocused()) {
1403 if (m_activeTimeline)
1404 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1408 void MainWindow::slotSnapForward() {
1409 if (m_monitorManager->projectMonitorFocused()) {
1410 if (m_activeTimeline)
1411 m_activeTimeline->projectView()->slotSeekToNextSnap();
1415 void MainWindow::slotClipStart() {
1416 if (m_monitorManager->projectMonitorFocused()) {
1417 if (m_activeTimeline)
1418 m_activeTimeline->projectView()->clipStart();
1422 void MainWindow::slotClipEnd() {
1423 if (m_monitorManager->projectMonitorFocused()) {
1424 if (m_activeTimeline)
1425 m_activeTimeline->projectView()->clipEnd();
1429 void MainWindow::slotChangeTool(QAction * action) {
1430 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1431 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1434 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1435 if (m_activeDocument && m_activeTimeline) {
1436 //m_activeDocument->setTool(tool);
1437 m_activeTimeline->projectView()->setTool(tool);
1441 void MainWindow::slotCopy() {
1442 if (!m_activeDocument || !m_activeTimeline) return;
1443 m_activeTimeline->projectView()->copyClip();
1446 void MainWindow::slotPaste() {
1447 if (!m_activeDocument || !m_activeTimeline) return;
1448 m_activeTimeline->projectView()->pasteClip();
1451 void MainWindow::slotPasteEffects() {
1452 if (!m_activeDocument || !m_activeTimeline) return;
1453 m_activeTimeline->projectView()->pasteClipEffects();
1456 void MainWindow::slotFind() {
1457 if (!m_activeDocument || !m_activeTimeline) return;
1458 m_projectSearch->setEnabled(false);
1459 m_findActivated = true;
1460 m_findString = QString();
1461 m_activeTimeline->projectView()->initSearchStrings();
1462 statusBar()->showMessage(i18n("Starting -- find text as you type"));
1463 m_findTimer.start(5000);
1464 qApp->installEventFilter(this);
1467 void MainWindow::slotFindNext() {
1468 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
1469 statusBar()->showMessage(i18n("Found : %1", m_findString));
1471 statusBar()->showMessage(i18n("Reached end of project"));
1473 m_findTimer.start(4000);
1476 void MainWindow::findAhead() {
1477 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
1478 m_projectSearchNext->setEnabled(true);
1479 statusBar()->showMessage(i18n("Found : %1", m_findString));
1481 m_projectSearchNext->setEnabled(false);
1482 statusBar()->showMessage(i18n("Not found : %1", m_findString));
1486 void MainWindow::findTimeout() {
1487 m_projectSearchNext->setEnabled(false);
1488 m_findActivated = false;
1489 m_findString = QString();
1490 statusBar()->showMessage(i18n("Find stopped"), 3000);
1491 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
1492 m_projectSearch->setEnabled(true);
1493 removeEventFilter(this);
1496 void MainWindow::keyPressEvent(QKeyEvent *ke) {
1497 if (m_findActivated) {
1498 if (ke->key() == Qt::Key_Backspace) {
1499 m_findString = m_findString.left(m_findString.length() - 1);
1501 if (!m_findString.isEmpty()) {
1507 m_findTimer.start(4000);
1510 } else if (ke->key() == Qt::Key_Escape) {
1514 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
1515 m_findString += ke->text();
1519 m_findTimer.start(4000);
1523 } else KXmlGuiWindow::keyPressEvent(ke);
1526 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
1527 if (m_findActivated) {
1528 if (event->type() == QEvent::ShortcutOverride) {
1529 QKeyEvent* ke = (QKeyEvent*) event;
1530 if (ke->text().trimmed().isEmpty()) return false;
1533 } else return false;
1535 // pass the event on to the parent class
1536 return QMainWindow::eventFilter(obj, event);
1540 #include "mainwindow.moc"