1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
22 #include <QTextStream>
29 #include <KApplication>
33 #include <KActionCollection>
34 #include <KStandardAction>
35 #include <KFileDialog>
36 #include <KMessageBox>
38 #include <KIO/NetAccess>
41 #include <KConfigDialog>
42 #include <KXMLGUIFactory>
44 #include <kstandarddirs.h>
45 #include <KUrlRequesterDialog>
46 #include <KTemporaryFile>
47 #include <KActionMenu>
50 #include <ktogglefullscreenaction.h>
52 #include <KNotification>
53 #include <KNotifyConfigWidget>
54 #include <knewstuff2/engine.h>
55 #include <knewstuff2/ui/knewstuffaction.h>
57 #include "mainwindow.h"
58 #include "kdenlivesettings.h"
59 #include "kdenlivesettingsdialog.h"
60 #include "initeffects.h"
61 #include "profilesdialog.h"
62 #include "projectsettings.h"
64 #include "clipmanager.h"
65 #include "projectlist.h"
67 #include "recmonitor.h"
68 #include "monitormanager.h"
69 #include "kdenlivedoc.h"
70 #include "trackview.h"
71 #include "customtrackview.h"
72 #include "effectslistview.h"
73 #include "effectstackview.h"
74 #include "transitionsettings.h"
75 #include "renderwidget.h"
78 #include "jogshuttle.h"
79 #endif /* NO_JOGSHUTTLE */
80 #include "clipproperties.h"
82 #include "editclipcommand.h"
83 #include "titlewidget.h"
84 #include "markerdialog.h"
87 #include "interfaces.h"
89 static const int ID_STATUS_MSG = 1;
90 static const int ID_EDITMODE_MSG = 2;
91 static const int ID_TIMELINE_MSG = 3;
92 static const int ID_TIMELINE_BUTTONS = 5;
93 static const int ID_TIMELINE_POS = 6;
94 static const int ID_TIMELINE_FORMAT = 7;
100 EffectsList MainWindow::videoEffects;
101 EffectsList MainWindow::audioEffects;
102 EffectsList MainWindow::customEffects;
103 EffectsList MainWindow::transitions;
105 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent)
106 : KXmlGuiWindow(parent),
107 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL),
108 #ifndef NO_JOGSHUTTLE
110 #endif /* NO_JOGSHUTTLE */
111 m_findActivated(false), m_initialized(false) {
112 setlocale(LC_NUMERIC, "POSIX");
113 setFont(KGlobalSettings::toolBarFont());
114 parseProfiles(MltPath);
115 m_commandStack = new QUndoGroup;
116 m_timelineArea = new KTabWidget(this);
117 m_timelineArea->setTabReorderingEnabled(true);
118 m_timelineArea->setTabBarHidden(true);
120 QToolButton *closeTabButton = new QToolButton;
121 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
122 closeTabButton->setIcon(KIcon("tab-close"));
123 closeTabButton->adjustSize();
124 closeTabButton->setToolTip(i18n("Close the current tab"));
125 m_timelineArea->setCornerWidget(closeTabButton);
126 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
128 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
129 m_findTimer.setSingleShot(true);
131 initEffects::parseEffectFiles();
132 //initEffects::parseCustomEffectsFile();
134 m_monitorManager = new MonitorManager();
136 projectListDock = new QDockWidget(i18n("Project Tree"), this);
137 projectListDock->setObjectName("project_tree");
138 m_projectList = new ProjectList(this);
139 projectListDock->setWidget(m_projectList);
140 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
142 effectListDock = new QDockWidget(i18n("Effect List"), this);
143 effectListDock->setObjectName("effect_list");
144 m_effectList = new EffectsListView();
146 //m_effectList = new KListWidget(this);
147 effectListDock->setWidget(m_effectList);
148 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
150 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
151 effectStackDock->setObjectName("effect_stack");
152 effectStack = new EffectStackView(this);
153 effectStackDock->setWidget(effectStack);
154 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
156 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
157 transitionConfigDock->setObjectName("transition");
158 transitionConfig = new TransitionSettings(this);
159 transitionConfigDock->setWidget(transitionConfig);
160 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
162 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
163 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
167 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
168 clipMonitorDock->setObjectName("clip_monitor");
169 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
170 clipMonitorDock->setWidget(m_clipMonitor);
171 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
172 //m_clipMonitor->stop();
174 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
175 projectMonitorDock->setObjectName("project_monitor");
176 m_projectMonitor = new Monitor("project", m_monitorManager, this);
177 projectMonitorDock->setWidget(m_projectMonitor);
178 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
180 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
181 recMonitorDock->setObjectName("record_monitor");
182 m_recMonitor = new RecMonitor("record", this);
183 recMonitorDock->setWidget(m_recMonitor);
184 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
186 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
187 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
189 undoViewDock = new QDockWidget(i18n("Undo History"), this);
190 undoViewDock->setObjectName("undo_history");
191 m_undoView = new QUndoView(this);
192 m_undoView->setCleanIcon(KIcon("edit-clear"));
193 m_undoView->setEmptyLabel(i18n("Clean"));
194 undoViewDock->setWidget(m_undoView);
195 m_undoView->setGroup(m_commandStack);
196 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
198 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
199 //overviewDock->setObjectName("project_overview");
200 //m_overView = new CustomTrackView(NULL, NULL, this);
201 //overviewDock->setWidget(m_overView);
202 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
205 //tabifyDockWidget(projectListDock, effectListDock);
206 tabifyDockWidget(projectListDock, effectStackDock);
207 tabifyDockWidget(projectListDock, transitionConfigDock);
208 //tabifyDockWidget(projectListDock, undoViewDock);
211 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
212 tabifyDockWidget(clipMonitorDock, recMonitorDock);
213 setCentralWidget(m_timelineArea);
217 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
219 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
220 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
221 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)));
223 // build effects menus
225 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
227 QStringList effectInfo;
228 QMap<QString, QStringList> effectsList;
229 for (int ix = 0; ix < videoEffects.count(); ix++) {
230 effectInfo = videoEffects.effectIdInfo(ix);
231 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
234 foreach(QStringList value, effectsList) {
235 action = new QAction(value.at(0), this);
236 action->setData(value);
237 videoEffectsMenu->addAction(action);
240 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
244 for (int ix = 0; ix < audioEffects.count(); ix++) {
245 effectInfo = audioEffects.effectIdInfo(ix);
246 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
249 foreach(QStringList value, effectsList) {
250 action = new QAction(value.at(0), this);
251 action->setData(value);
252 audioEffectsMenu->addAction(action);
255 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
257 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
258 else m_customEffectsMenu->setEnabled(true);
261 for (int ix = 0; ix < customEffects.count(); ix++) {
262 effectInfo = customEffects.effectIdInfo(ix);
263 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
266 foreach(QStringList value, effectsList) {
267 action = new QAction(value.at(0), this);
268 action->setData(value);
269 m_customEffectsMenu->addAction(action);
272 QMenu *newEffect = new QMenu(this);
273 newEffect->addMenu(videoEffectsMenu);
274 newEffect->addMenu(audioEffectsMenu);
275 newEffect->addMenu(m_customEffectsMenu);
276 effectStack->setMenu(newEffect);
279 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
280 const QList<QAction *> viewActions = createPopupMenu()->actions();
281 viewMenu->insertActions(NULL, viewActions);
283 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
284 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
285 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
287 m_timelineContextMenu = new QMenu(this);
288 m_timelineContextClipMenu = new QMenu(this);
289 m_timelineContextTransitionMenu = new QMenu(this);
292 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
293 QStringList effects = transitions.effectNames();
296 for (int ix = 0; ix < transitions.count(); ix++) {
297 effectInfo = transitions.effectIdInfo(ix);
298 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
300 foreach(QStringList value, effectsList) {
301 action = new QAction(value.at(0), this);
302 action->setData(value);
303 transitionsMenu->addAction(action);
305 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
307 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
308 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
309 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
311 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
312 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
313 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
314 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
315 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
317 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
318 m_timelineContextClipMenu->addMenu(markersMenu);
319 m_timelineContextClipMenu->addMenu(transitionsMenu);
320 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
321 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
322 //TODO: re-enable custom effects menu when it is implemented
323 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
325 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
326 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
328 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
330 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
331 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
332 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
333 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
334 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
335 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
337 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
338 slotConnectMonitors();
340 // Open or create a file. Command line argument passed in Url has
341 // precedence, then "openlastproject", then just a plain empty file.
342 // If opening Url fails, openlastproject will _not_ be used.
343 if (!Url.isEmpty()) {
346 if (KdenliveSettings::openlastproject()) {
350 if (m_timelineArea->count() == 0) {
354 #ifndef NO_JOGSHUTTLE
355 activateShuttleDevice();
356 #endif /* NO_JOGSHUTTLE */
357 projectListDock->raise();
360 void MainWindow::queryQuit() {
361 kDebug() << "----- SAVING CONFUIG";
362 if (queryClose()) kapp->quit();
366 bool MainWindow::queryClose() {
368 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
369 if (m_activeDocument && m_activeDocument->isModified()) {
370 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
371 case KMessageBox::Yes :
372 // save document here. If saving fails, return false;
374 case KMessageBox::No :
384 void MainWindow::loadPlugins() {
385 foreach(QObject *plugin, QPluginLoader::staticInstances())
386 populateMenus(plugin);
388 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
390 filters << "libkdenlive*";
391 foreach(const QString &folder, directories) {
392 kDebug() << "// PARSING FIOLER: " << folder;
393 QDir pluginsDir(folder);
394 foreach(QString fileName, pluginsDir.entryList(filters, QDir::Files)) {
395 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
396 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
397 QObject *plugin = loader.instance();
399 populateMenus(plugin);
400 m_pluginFileNames += fileName;
401 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
407 void MainWindow::populateMenus(QObject *plugin) {
408 kDebug() << "// POP MENU";
409 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
410 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
411 kDebug() << "// POP MENU 2";
412 if (addMenu) kDebug() << "// POP MENU 3";
414 addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
418 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
419 QMenu *menu, const char *member,
420 QActionGroup *actionGroup) {
421 kDebug() << "// ADD to MENU" << texts;
422 foreach(QString text, texts) {
423 QAction *action = new QAction(text, plugin);
424 connect(action, SIGNAL(triggered()), this, member);
425 menu->addAction(action);
428 action->setCheckable(true);
429 actionGroup->addAction(action);
434 void MainWindow::aboutPlugins() {
435 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
440 void MainWindow::generateClip() {
441 QAction *action = qobject_cast<QAction *>(sender());
442 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
444 KUrl clipUrl = iGenerator->generatedClip(action->text(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
445 if (!clipUrl.isEmpty()) {
446 m_projectList->slotAddClip(clipUrl);
450 void MainWindow::saveProperties(KConfig*) {
451 // save properties here,used by session management
456 void MainWindow::readProperties(KConfig *config) {
457 // read properties here,used by session management
458 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
459 openFile(KUrl(Lastproject));
462 void MainWindow::slotReloadEffects() {
463 initEffects::parseCustomEffectsFile();
464 m_customEffectsMenu->clear();
465 const QStringList effects = customEffects.effectNames();
467 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
468 else m_customEffectsMenu->setEnabled(true);
470 foreach(const QString &name, effects) {
471 action = new QAction(name, this);
472 action->setData(name);
473 m_customEffectsMenu->addAction(action);
475 m_effectList->reloadEffectList();
478 #ifndef NO_JOGSHUTTLE
479 void MainWindow::activateShuttleDevice() {
480 if (m_jogProcess) delete m_jogProcess;
482 if (KdenliveSettings::enableshuttle() == false) return;
483 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
484 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
485 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
486 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
487 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
488 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
489 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
492 void MainWindow::slotShuttleButton(int code) {
495 slotShuttleAction(KdenliveSettings::shuttle1());
498 slotShuttleAction(KdenliveSettings::shuttle2());
501 slotShuttleAction(KdenliveSettings::shuttle3());
504 slotShuttleAction(KdenliveSettings::shuttle4());
507 slotShuttleAction(KdenliveSettings::shuttle5());
512 void MainWindow::slotShuttleAction(int code) {
517 m_monitorManager->slotPlay();
520 m_monitorManager->slotPlay();
524 #endif /* NO_JOGSHUTTLE */
526 void MainWindow::configureNotifications() {
527 KNotifyConfigWidget::configure(this);
530 void MainWindow::slotFullScreen() {
531 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
534 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
535 if (!m_activeDocument) return;
536 if (effect.isNull()) {
537 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
540 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
541 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
544 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
545 if (clipMonitor) clipMonitorDock->raise();
546 else projectMonitorDock->raise();
549 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
550 if (!m_activeDocument) return;
551 m_activeDocument->setProducerDuration(id, duration);
554 void MainWindow::slotConnectMonitors() {
556 m_projectList->setRenderer(m_projectMonitor->render);
557 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
558 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
559 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
560 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
561 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
563 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
565 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
567 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
568 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
570 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
571 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
574 void MainWindow::slotAdjustClipMonitor() {
575 clipMonitorDock->updateGeometry();
576 clipMonitorDock->adjustSize();
577 m_clipMonitor->resetSize();
580 void MainWindow::slotAdjustProjectMonitor() {
581 projectMonitorDock->updateGeometry();
582 projectMonitorDock->adjustSize();
583 m_projectMonitor->resetSize();
586 void MainWindow::setupActions() {
588 KActionCollection* collection = actionCollection();
589 m_timecodeFormat = new KComboBox(this);
590 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
591 m_timecodeFormat->addItem(i18n("Frames"));
593 statusProgressBar = new QProgressBar(this);
594 statusProgressBar->setMinimum(0);
595 statusProgressBar->setMaximum(100);
596 statusProgressBar->setMaximumWidth(150);
597 statusProgressBar->setVisible(false);
599 QWidget *w = new QWidget;
601 QHBoxLayout *layout = new QHBoxLayout;
602 w->setLayout(layout);
603 layout->setContentsMargins(5, 0, 5, 0);
604 QToolBar *toolbar = new QToolBar("statusToolBar", this);
607 m_toolGroup = new QActionGroup(this);
609 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;}";
611 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
612 toolbar->addAction(m_buttonSelectTool);
613 m_buttonSelectTool->setCheckable(true);
614 m_buttonSelectTool->setChecked(true);
616 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
617 toolbar->addAction(m_buttonRazorTool);
618 m_buttonRazorTool->setCheckable(true);
619 m_buttonRazorTool->setChecked(false);
621 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
622 toolbar->addAction(m_buttonSpacerTool);
623 m_buttonSpacerTool->setCheckable(true);
624 m_buttonSpacerTool->setChecked(false);
626 m_toolGroup->addAction(m_buttonSelectTool);
627 m_toolGroup->addAction(m_buttonRazorTool);
628 m_toolGroup->addAction(m_buttonSpacerTool);
629 m_toolGroup->setExclusive(true);
630 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
632 QWidget * actionWidget;
633 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
634 actionWidget->setMaximumWidth(24);
635 actionWidget->setMinimumHeight(17);
637 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
638 actionWidget->setMaximumWidth(24);
639 actionWidget->setMinimumHeight(17);
641 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
642 actionWidget->setMaximumWidth(24);
643 actionWidget->setMinimumHeight(17);
645 toolbar->setStyleSheet(style1);
646 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
648 toolbar->addSeparator();
649 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
650 toolbar->addAction(m_buttonFitZoom);
651 m_buttonFitZoom->setCheckable(false);
652 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
654 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
655 actionWidget->setMaximumWidth(24);
656 actionWidget->setMinimumHeight(17);
658 m_zoomSlider = new QSlider(Qt::Horizontal, this);
659 m_zoomSlider->setMaximum(13);
660 m_zoomSlider->setPageStep(1);
662 m_zoomSlider->setMaximumWidth(150);
663 m_zoomSlider->setMinimumWidth(100);
665 const int contentHeight = QFontMetrics(w->font()).height() + 8;
667 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
668 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
670 m_zoomSlider->setStyleSheet(style);
672 //m_zoomSlider->height() + 5;
673 statusBar()->setMinimumHeight(contentHeight);
676 toolbar->addWidget(m_zoomSlider);
678 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
679 toolbar->addAction(m_buttonVideoThumbs);
680 m_buttonVideoThumbs->setCheckable(true);
681 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
682 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
684 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
685 toolbar->addAction(m_buttonAudioThumbs);
686 m_buttonAudioThumbs->setCheckable(true);
687 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
688 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
690 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
691 toolbar->addAction(m_buttonShowMarkers);
692 m_buttonShowMarkers->setCheckable(true);
693 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
694 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
696 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
697 toolbar->addAction(m_buttonSnap);
698 m_buttonSnap->setCheckable(true);
699 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
700 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
701 layout->addWidget(toolbar);
704 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
705 actionWidget->setMaximumWidth(24);
706 actionWidget->setMinimumHeight(17);
708 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
709 actionWidget->setMaximumWidth(24);
710 actionWidget->setMinimumHeight(17);
712 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
713 actionWidget->setMaximumWidth(24);
714 actionWidget->setMinimumHeight(17);
716 actionWidget = toolbar->widgetForAction(m_buttonSnap);
717 actionWidget->setMaximumWidth(24);
718 actionWidget->setMinimumHeight(17);
720 m_messageLabel = new StatusBarMessageLabel(this);
721 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
723 statusBar()->addWidget(m_messageLabel, 10);
724 statusBar()->addWidget(statusProgressBar, 0);
725 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
726 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
727 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
728 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
729 m_messageLabel->hide();
731 collection->addAction("select_tool", m_buttonSelectTool);
732 collection->addAction("razor_tool", m_buttonRazorTool);
733 collection->addAction("spacer_tool", m_buttonSpacerTool);
735 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
736 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
737 collection->addAction("show_markers", m_buttonShowMarkers);
738 collection->addAction("snap", m_buttonSnap);
739 collection->addAction("zoom_fit", m_buttonFitZoom);
741 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
742 collection->addAction("zoom_in", zoomIn);
743 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
744 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
746 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
747 collection->addAction("zoom_out", zoomOut);
748 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
749 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
751 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
752 collection->addAction("project_find", m_projectSearch);
753 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
754 m_projectSearch->setShortcut(Qt::Key_Slash);
756 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
757 collection->addAction("project_find_next", m_projectSearchNext);
758 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
759 m_projectSearchNext->setShortcut(Qt::Key_F3);
760 m_projectSearchNext->setEnabled(false);
762 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
763 collection->addAction("manage_profiles", profilesAction);
764 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
766 KAction* fileGHNS = KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewStuff()), actionCollection(), "get_new_stuff");
768 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
769 collection->addAction("run_wizard", wizAction);
770 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
772 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
773 collection->addAction("project_settings", projectAction);
774 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
776 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
777 collection->addAction("project_render", projectRender);
778 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
779 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
781 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
782 KShortcut playShortcut;
783 playShortcut.setPrimary(Qt::Key_Space);
784 playShortcut.setAlternate(Qt::Key_K);
785 monitorPlay->setShortcut(playShortcut);
786 collection->addAction("monitor_play", monitorPlay);
787 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
789 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
790 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
791 collection->addAction("monitor_play_zone", m_playZone);
792 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
794 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
795 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
796 collection->addAction("monitor_loop_zone", m_loopZone);
797 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
799 KAction *markIn = collection->addAction("mark_in");
800 markIn->setText(i18n("Set In Point"));
801 markIn->setShortcut(Qt::Key_I);
802 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
804 KAction *markOut = collection->addAction("mark_out");
805 markOut->setText(i18n("Set Out Point"));
806 markOut->setShortcut(Qt::Key_O);
807 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
809 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
810 monitorSeekBackward->setShortcut(Qt::Key_J);
811 collection->addAction("monitor_seek_backward", monitorSeekBackward);
812 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
814 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
815 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
816 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
817 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
819 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
820 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
821 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
822 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
824 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
825 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
826 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
827 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
829 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
830 monitorSeekForward->setShortcut(Qt::Key_L);
831 collection->addAction("monitor_seek_forward", monitorSeekForward);
832 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
834 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
835 clipStart->setShortcut(Qt::Key_Home);
836 collection->addAction("seek_clip_start", clipStart);
837 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
839 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
840 clipEnd->setShortcut(Qt::Key_End);
841 collection->addAction("seek_clip_end", clipEnd);
842 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
844 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
845 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
846 collection->addAction("seek_start", projectStart);
847 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
849 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
850 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
851 collection->addAction("seek_end", projectEnd);
852 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
854 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
855 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
856 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
857 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
859 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
860 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
861 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
862 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
864 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
865 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
866 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
867 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
869 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
870 deleteTimelineClip->setShortcut(Qt::Key_Delete);
871 collection->addAction("delete_timeline_clip", deleteTimelineClip);
872 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
874 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
875 collection->addAction("change_clip_speed", editTimelineClipSpeed);
876 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
878 KAction *stickTransition = collection->addAction("auto_transition");
879 stickTransition->setData(QString("auto"));
880 stickTransition->setCheckable(true);
881 stickTransition->setEnabled(false);
882 stickTransition->setText(i18n("Automatic Transition"));
883 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
885 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
886 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
887 collection->addAction("cut_timeline_clip", cutTimelineClip);
888 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
890 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
891 collection->addAction("add_clip_marker", addClipMarker);
892 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
894 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
895 collection->addAction("delete_clip_marker", deleteClipMarker);
896 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
898 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
899 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
900 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
902 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
903 collection->addAction("edit_clip_marker", editClipMarker);
904 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
906 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
907 collection->addAction("insert_space", insertSpace);
908 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
910 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
911 collection->addAction("delete_space", removeSpace);
912 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
914 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
915 collection->addAction("insert_track", insertTrack);
916 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
918 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
919 collection->addAction("delete_track", deleteTrack);
920 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
922 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
923 collection->addAction("change_track", changeTrack);
924 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
926 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
927 collection->addAction("add_guide", addGuide);
928 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
930 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
931 collection->addAction("delete_guide", delGuide);
932 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
934 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
935 collection->addAction("edit_guide", editGuide);
936 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
938 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
939 collection->addAction("delete_all_guides", delAllGuides);
940 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
942 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
943 collection->addAction("paste_effects", pasteEffects);
944 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
946 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
948 KStandardAction::quit(this, SLOT(queryQuit()), collection);
950 KStandardAction::open(this, SLOT(openFile()), collection);
952 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
954 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
956 KStandardAction::openNew(this, SLOT(newFile()), collection);
958 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
960 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
962 KStandardAction::copy(this, SLOT(slotCopy()), collection);
964 KStandardAction::paste(this, SLOT(slotPaste()), collection);
966 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
967 undo->setEnabled(false);
968 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
970 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
971 redo->setEnabled(false);
972 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
974 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
976 connect(collection, SIGNAL(actionHovered(QAction*)),
977 this, SLOT(slotDisplayActionMessage(QAction*)));
980 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
981 collection->addAction("add_clip", addClip);
982 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
984 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
985 collection->addAction("add_color_clip", addColorClip);
986 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
988 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
989 collection->addAction("add_slide_clip", addSlideClip);
990 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
992 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
993 collection->addAction("add_text_clip", addTitleClip);
994 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
996 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
997 collection->addAction("add_folder", addFolderButton);
998 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1000 QMenu *addClips = new QMenu();
1001 addClips->addAction(addClip);
1002 addClips->addAction(addColorClip);
1003 addClips->addAction(addSlideClip);
1004 addClips->addAction(addTitleClip);
1005 addClips->addAction(addFolderButton);
1006 m_projectList->setupMenu(addClips, addClip);
1008 //connect(collection, SIGNAL( clearStatusText() ),
1009 //statusBar(), SLOT( clear() ) );
1012 void MainWindow::slotDisplayActionMessage(QAction *a) {
1013 statusBar()->showMessage(a->data().toString(), 3000);
1016 void MainWindow::saveOptions() {
1017 KdenliveSettings::self()->writeConfig();
1018 KSharedConfigPtr config = KGlobal::config();
1019 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1020 KConfigGroup treecolumns(config, "Project Tree");
1021 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1025 void MainWindow::readOptions() {
1026 KSharedConfigPtr config = KGlobal::config();
1027 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1028 KConfigGroup initialGroup(config, "version");
1029 if (!initialGroup.exists()) {
1030 // this is our first run, show Wizard
1031 Wizard *w = new Wizard(this);
1032 if (w->exec() == QDialog::Accepted && w->isOk()) {
1033 w->adjustSettings();
1034 initialGroup.writeEntry("version", "0.7");
1039 } else if (initialGroup.readEntry("version") == "0.7") {
1040 //Add new settings from 0.7.1
1041 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1042 QString path = QDir::homePath() + "/kdenlive";
1043 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1044 KdenliveSettings::setDefaultprojectfolder(path);
1047 KConfigGroup treecolumns(config, "Project Tree");
1048 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1049 if (!state.isEmpty())
1050 m_projectList->setHeaderInfo(state);
1053 void MainWindow::slotRunWizard() {
1054 Wizard *w = new Wizard(this);
1055 if (w->exec() == QDialog::Accepted && w->isOk()) {
1056 w->adjustSettings();
1061 void MainWindow::newFile(bool showProjectSettings) {
1062 QString profileName;
1064 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1065 if (!showProjectSettings && m_timelineArea->count() == 0) {
1066 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1067 profileName = KdenliveSettings::default_profile();
1069 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1070 if (w->exec() != QDialog::Accepted) return;
1071 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1072 profileName = w->selectedProfile();
1073 projectFolder = w->selectedFolder();
1074 projectTracks = w->tracks();
1077 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1078 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1079 TrackView *trackView = new TrackView(doc, this);
1080 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1081 if (m_timelineArea->count() == 1) {
1082 connectDocumentInfo(doc);
1083 connectDocument(trackView, doc);
1084 } else m_timelineArea->setTabBarHidden(false);
1085 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1088 void MainWindow::activateDocument() {
1089 if (m_timelineArea->currentWidget() == NULL) return;
1090 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1091 KdenliveDoc *currentDoc = currentTab->document();
1092 connectDocumentInfo(currentDoc);
1093 connectDocument(currentTab, currentDoc);
1096 void MainWindow::closeCurrentDocument() {
1097 QWidget *w = m_timelineArea->currentWidget();
1099 // closing current document
1100 int ix = m_timelineArea->currentIndex() + 1;
1101 if (ix == m_timelineArea->count()) ix = 0;
1102 m_timelineArea->setCurrentIndex(ix);
1103 TrackView *tabToClose = (TrackView *) w;
1104 KdenliveDoc *docToClose = tabToClose->document();
1105 if (docToClose && docToClose->isModified()) {
1106 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1107 case KMessageBox::Yes :
1108 // save document here. If saving fails, return false;
1111 case KMessageBox::Cancel :
1117 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1118 if (m_timelineArea->count() == 1) {
1119 m_timelineArea->setTabBarHidden(true);
1120 m_closeAction->setEnabled(false);
1124 if (m_timelineArea->count() == 0) {
1125 m_activeDocument = NULL;
1126 effectStack->clear();
1127 transitionConfig->slotTransitionItemSelected(NULL, false);
1131 bool MainWindow::saveFileAs(const QString &outputFileName) {
1132 QDomDocument currentSceneList = m_projectMonitor->sceneList();
1133 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1136 // Save timeline thumbnails
1137 m_activeTimeline->projectView()->saveThumbnails();
1138 m_activeDocument->setUrl(KUrl(outputFileName));
1139 if (m_activeDocument->m_autosave == NULL) {
1140 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1141 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1142 setCaption(m_activeDocument->description());
1143 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1144 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1145 m_activeDocument->setModified(false);
1146 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1150 bool MainWindow::saveFileAs() {
1151 // Check that the Kdenlive mime type is correctly installed
1152 QString mimetype = "application/x-kdenlive";
1153 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1154 if (!mime) mimetype = "*.kdenlive";
1156 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1157 if (outputFile.isEmpty()) return false;
1158 if (QFile::exists(outputFile)) {
1159 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1161 return saveFileAs(outputFile);
1164 bool MainWindow::saveFile() {
1165 if (!m_activeDocument) return true;
1166 if (m_activeDocument->url().isEmpty()) {
1167 return saveFileAs();
1169 bool result = saveFileAs(m_activeDocument->url().path());
1170 m_activeDocument->m_autosave->resize(0);
1175 void MainWindow::openFile() {
1176 // Check that the Kdenlive mime type is correctly installed
1177 QString mimetype = "application/x-kdenlive";
1178 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1179 if (!mime) mimetype = "*.kdenlive";
1181 KUrl url = KFileDialog::getOpenUrl(KUrl(), mimetype);
1182 if (url.isEmpty()) return;
1183 m_fileOpenRecent->addUrl(url);
1187 void MainWindow::openLastFile() {
1188 KSharedConfigPtr config = KGlobal::config();
1189 KUrl::List urls = m_fileOpenRecent->urls();
1190 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1191 if (urls.isEmpty()) newFile(false);
1192 else openFile(urls.last());
1195 void MainWindow::openFile(const KUrl &url) {
1196 // Check if the document is already opened
1197 const int ct = m_timelineArea->count();
1198 bool isOpened = false;
1200 for (i = 0; i < ct; i++) {
1201 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1202 KdenliveDoc *doc = tab->document();
1203 if (doc->url() == url) {
1209 m_timelineArea->setCurrentIndex(i);
1213 // Check for backup file
1214 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1215 if (!staleFiles.isEmpty()) {
1216 if (KMessageBox::questionYesNo(this,
1217 i18n("Auto-saved files exist. Do you want to recover them now?"),
1218 i18n("File Recovery"),
1219 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1220 recoverFiles(staleFiles);
1223 // remove the stale files
1224 foreach(KAutoSaveFile *stale, staleFiles) {
1225 stale->open(QIODevice::ReadWrite);
1230 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1231 doOpenFile(url, NULL);
1234 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1236 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1237 if (stale == NULL) {
1238 stale = new KAutoSaveFile(url, doc);
1239 doc->m_autosave = stale;
1241 doc->m_autosave = stale;
1242 doc->setUrl(stale->managedFile());
1243 doc->setModified(true);
1244 stale->setParent(doc);
1246 connectDocumentInfo(doc);
1247 TrackView *trackView = new TrackView(doc, this);
1248 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1249 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1250 trackView->setDuration(trackView->duration());
1251 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1253 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1254 slotGotProgressInfo(QString(), -1);
1255 m_clipMonitor->refreshMonitor(true);
1256 m_projectMonitor->adjustRulerSize(trackView->duration());
1257 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1260 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1261 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1262 foreach(KAutoSaveFile *stale, staleFiles) {
1263 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1264 // show an error message; we could not steal the lockfile
1265 // maybe another application got to the file before us?
1269 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1270 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1271 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1272 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1277 void MainWindow::parseProfiles(const QString &mltPath) {
1278 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1280 //KdenliveSettings::setDefaulttmpfolder();
1281 if (!mltPath.isEmpty()) {
1282 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1283 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1286 if (KdenliveSettings::mltpath().isEmpty()) {
1287 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1289 if (KdenliveSettings::rendererpath().isEmpty()) {
1290 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1291 if (!QFile::exists(inigoPath))
1292 inigoPath = KStandardDirs::findExe("inigo");
1293 else KdenliveSettings::setRendererpath(inigoPath);
1295 QStringList profilesFilter;
1296 profilesFilter << "*";
1297 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1299 if (profilesList.isEmpty()) {
1300 // Cannot find MLT path, try finding inigo
1301 QString profilePath = KdenliveSettings::rendererpath();
1302 if (!profilePath.isEmpty()) {
1303 profilePath = profilePath.section('/', 0, -3);
1304 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1305 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1308 if (profilesList.isEmpty()) {
1309 // Cannot find the MLT profiles, ask for location
1310 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1311 getUrl->fileDialog()->setMode(KFile::Directory);
1312 if (getUrl->exec() == QDialog::Rejected) {
1315 KUrl mltPath = getUrl->selectedUrl();
1317 if (mltPath.isEmpty()) ::exit(0);
1318 KdenliveSettings::setMltpath(mltPath.path());
1319 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1323 if (KdenliveSettings::rendererpath().isEmpty()) {
1324 // Cannot find the MLT inigo renderer, ask for location
1325 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1326 if (getUrl->exec() == QDialog::Rejected) {
1329 KUrl rendererPath = getUrl->selectedUrl();
1331 if (rendererPath.isEmpty()) ::exit(0);
1332 KdenliveSettings::setRendererpath(rendererPath.path());
1335 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1337 // Parse MLT profiles to build a list of available video formats
1338 if (profilesList.isEmpty()) parseProfiles();
1342 void MainWindow::slotEditProfiles() {
1343 ProfilesDialog *w = new ProfilesDialog;
1348 void MainWindow::slotEditProjectSettings() {
1349 QPoint p = m_activeDocument->getTracksCount();
1350 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1352 if (w->exec() == QDialog::Accepted) {
1353 QString profile = w->selectedProfile();
1354 m_activeDocument->setProjectFolder(w->selectedFolder());
1355 if (m_activeDocument->profilePath() != profile) {
1356 // Profile was changed
1357 m_activeDocument->setProfilePath(profile);
1358 KdenliveSettings::setCurrent_profile(profile);
1359 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1360 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1361 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1362 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1363 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1365 // We need to desactivate & reactivate monitors to get a refresh
1366 m_monitorManager->switchMonitors();
1372 void MainWindow::slotRenderProject() {
1373 if (!m_renderWidget) {
1374 m_renderWidget = new RenderWidget(this);
1375 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double, bool)));
1376 if (m_activeDocument) {
1377 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1378 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1381 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1382 if (currentTab) m_renderWidget->setTimeline(currentTab);
1383 m_renderWidget->setDocument(m_activeDocument);*/
1384 m_renderWidget->show();
1387 void MainWindow::slotDoRender(const QString &dest, const QString &render, const QStringList &overlay_args, const QStringList &avformat_args, bool zoneOnly, bool playAfter, double guideStart, double guideEnd, bool resizeProfile) {
1388 if (dest.isEmpty()) return;
1391 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1392 if (currentTab && zoneOnly) {
1393 in = currentTab->inPoint();
1394 out = currentTab->outPoint();
1396 KTemporaryFile temp;
1397 temp.setAutoRemove(false);
1398 temp.setSuffix(".westley");
1400 m_projectMonitor->saveSceneList(temp.fileName());
1403 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1404 else if (guideStart != -1) {
1405 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1407 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1408 QString videoPlayer = "-";
1410 videoPlayer = KdenliveSettings::defaultplayerapp();
1411 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."));
1413 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1414 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1417 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1419 for (int i = 0; i < avformat_args.count(); i++) {
1420 if (avformat_args.at(i).startsWith("profile=")) {
1421 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1426 if (resizeProfile) {
1427 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1428 args << "consumer:" + temp.fileName();
1429 } else args << temp.fileName();
1430 args << dest << avformat_args;
1431 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1432 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1433 QProcess::startDetached(renderer, args);
1435 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1439 void MainWindow::slotUpdateMousePosition(int pos) {
1440 if (m_activeDocument)
1441 switch (m_timecodeFormat->currentIndex()) {
1443 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1446 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1450 void MainWindow::slotUpdateDocumentState(bool modified) {
1451 setCaption(m_activeDocument->description(), modified);
1452 m_saveAction->setEnabled(modified);
1454 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1455 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1457 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1458 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1462 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1463 if (m_activeDocument) {
1464 if (m_activeDocument == doc) return;
1465 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1467 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1470 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1471 //m_projectMonitor->stop();
1472 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1473 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1474 if (m_activeDocument) {
1475 if (m_activeDocument == doc) return;
1476 m_activeDocument->backupMltPlaylist();
1477 if (m_activeTimeline) {
1478 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1479 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1480 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1481 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1484 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1485 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1486 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1487 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1488 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1489 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1490 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1491 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1492 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1493 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1494 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1495 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1496 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1497 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1498 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1499 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1500 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1501 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1502 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1503 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1504 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1505 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1506 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1507 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1508 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1509 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1510 disconnect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), m_activeTimeline->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1511 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1512 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1513 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1514 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1515 effectStack->clear();
1517 //m_activeDocument->setRenderer(NULL);
1518 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1519 m_clipMonitor->stop();
1521 KdenliveSettings::setCurrent_profile(doc->profilePath());
1522 KdenliveSettings::setProject_fps(doc->fps());
1523 m_monitorManager->resetProfiles(doc->timecode());
1524 m_projectList->setDocument(doc);
1525 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1526 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1527 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1528 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1529 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1530 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1531 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1532 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1533 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1534 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1535 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1536 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1537 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1538 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1539 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1540 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1541 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1543 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1544 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1545 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1548 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1549 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1550 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1551 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1552 m_zoomSlider->setValue(doc->zoom());
1553 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1554 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1555 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1556 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1558 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1561 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1562 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1563 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1564 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1565 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1566 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1567 connect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), trackView->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1568 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1569 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1571 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1572 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1573 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1575 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1576 m_activeTimeline = trackView;
1577 if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
1578 //doc->setRenderer(m_projectMonitor->render);
1579 m_commandStack->setActiveStack(doc->commandStack());
1580 KdenliveSettings::setProject_display_ratio(doc->dar());
1581 m_projectList->updateAllClips();
1582 //doc->clipManager()->checkAudioThumbs();
1584 //m_overView->setScene(trackView->projectScene());
1585 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1586 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1588 setCaption(doc->description(), doc->isModified());
1589 m_saveAction->setEnabled(doc->isModified());
1590 m_activeDocument = doc;
1592 // set tool to select tool
1593 m_buttonSelectTool->setChecked(true);
1596 void MainWindow::slotZoneMoved(int start, int end) {
1597 m_activeDocument->setZone(start, end);
1598 m_projectMonitor->slotZoneMoved(start, end);
1601 void MainWindow::slotGuidesUpdated() {
1602 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1605 void MainWindow::slotPreferences(int page, int option) {
1606 //An instance of your dialog could be already created and could be
1607 // cached, in which case you want to display the cached dialog
1608 // instead of creating another one
1609 if (KConfigDialog::showDialog("settings")) {
1610 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1611 if (page != -1) d->showPage(page, option);
1616 // KConfigDialog didn't find an instance of this dialog, so lets
1618 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1619 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1620 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1622 if (page != -1) dialog->showPage(page, option);
1625 void MainWindow::updateConfiguration() {
1626 //TODO: we should apply settings to all projects, not only the current one
1627 if (m_activeTimeline) {
1628 m_activeTimeline->refresh();
1629 m_activeTimeline->projectView()->checkAutoScroll();
1630 m_activeTimeline->projectView()->checkTrackHeight();
1631 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1633 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1634 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1635 #ifndef NO_JOGSHUTTLE
1636 activateShuttleDevice();
1637 #endif /* NO_JOGSHUTTLE */
1641 void MainWindow::slotSwitchVideoThumbs() {
1642 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1643 if (m_activeTimeline) {
1644 m_activeTimeline->refresh();
1646 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1649 void MainWindow::slotSwitchAudioThumbs() {
1650 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1651 if (m_activeTimeline) {
1652 m_activeTimeline->refresh();
1653 m_activeTimeline->projectView()->checkAutoScroll();
1654 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1656 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1659 void MainWindow::slotSwitchMarkersComments() {
1660 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1661 if (m_activeTimeline) {
1662 m_activeTimeline->refresh();
1664 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1667 void MainWindow::slotSwitchSnap() {
1668 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1669 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1673 void MainWindow::slotDeleteTimelineClip() {
1674 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1675 else if (m_activeTimeline) {
1676 m_activeTimeline->projectView()->deleteSelectedClips();
1680 void MainWindow::slotChangeClipSpeed() {
1681 if (m_activeTimeline) {
1682 m_activeTimeline->projectView()->changeClipSpeed();
1686 void MainWindow::slotAddClipMarker() {
1687 DocClipBase *clip = NULL;
1689 if (m_projectMonitor->isActive()) {
1690 if (m_activeTimeline) {
1691 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1693 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1694 clip = item->baseClip();
1698 clip = m_clipMonitor->activeClip();
1699 pos = m_clipMonitor->position();
1702 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1705 QString id = clip->getId();
1706 CommentedTime marker(pos, i18n("Marker"));
1707 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1708 if (d.exec() == QDialog::Accepted) {
1709 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1711 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1714 void MainWindow::slotDeleteClipMarker() {
1715 DocClipBase *clip = NULL;
1717 if (m_projectMonitor->isActive()) {
1718 if (m_activeTimeline) {
1719 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1721 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1722 clip = item->baseClip();
1726 clip = m_clipMonitor->activeClip();
1727 pos = m_clipMonitor->position();
1730 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1734 QString id = clip->getId();
1735 QString comment = clip->markerComment(pos);
1736 if (comment.isEmpty()) {
1737 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1740 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1741 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1745 void MainWindow::slotDeleteAllClipMarkers() {
1746 DocClipBase *clip = NULL;
1747 if (m_projectMonitor->isActive()) {
1748 if (m_activeTimeline) {
1749 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1751 clip = item->baseClip();
1755 clip = m_clipMonitor->activeClip();
1758 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1761 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
1762 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1765 void MainWindow::slotEditClipMarker() {
1766 DocClipBase *clip = NULL;
1768 if (m_projectMonitor->isActive()) {
1769 if (m_activeTimeline) {
1770 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1772 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1773 clip = item->baseClip();
1777 clip = m_clipMonitor->activeClip();
1778 pos = m_clipMonitor->position();
1781 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1785 QString id = clip->getId();
1786 QString oldcomment = clip->markerComment(pos);
1787 if (oldcomment.isEmpty()) {
1788 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1792 CommentedTime marker(pos, oldcomment);
1793 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
1794 if (d.exec() == QDialog::Accepted) {
1795 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1796 if (d.newMarker().time() != pos) {
1797 // remove old marker
1798 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
1800 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1804 void MainWindow::slotAddGuide() {
1805 if (m_activeTimeline)
1806 m_activeTimeline->projectView()->slotAddGuide();
1809 void MainWindow::slotInsertSpace() {
1810 if (m_activeTimeline)
1811 m_activeTimeline->projectView()->slotInsertSpace();
1814 void MainWindow::slotRemoveSpace() {
1815 if (m_activeTimeline)
1816 m_activeTimeline->projectView()->slotRemoveSpace();
1819 void MainWindow::slotInsertTrack(int ix) {
1820 m_projectMonitor->activateMonitor();
1821 if (m_activeTimeline)
1822 m_activeTimeline->projectView()->slotInsertTrack(ix);
1825 void MainWindow::slotDeleteTrack(int ix) {
1826 m_projectMonitor->activateMonitor();
1827 if (m_activeTimeline)
1828 m_activeTimeline->projectView()->slotDeleteTrack(ix);
1831 void MainWindow::slotChangeTrack(int ix) {
1832 m_projectMonitor->activateMonitor();
1833 if (m_activeTimeline)
1834 m_activeTimeline->projectView()->slotChangeTrack(ix);
1837 void MainWindow::slotEditGuide() {
1838 if (m_activeTimeline)
1839 m_activeTimeline->projectView()->slotEditGuide();
1842 void MainWindow::slotDeleteGuide() {
1843 if (m_activeTimeline)
1844 m_activeTimeline->projectView()->slotDeleteGuide();
1847 void MainWindow::slotDeleteAllGuides() {
1848 if (m_activeTimeline)
1849 m_activeTimeline->projectView()->slotDeleteAllGuides();
1852 void MainWindow::slotCutTimelineClip() {
1853 if (m_activeTimeline) {
1854 m_activeTimeline->projectView()->cutSelectedClips();
1858 void MainWindow::slotAddProjectClip(KUrl url) {
1859 if (m_activeDocument)
1860 m_activeDocument->slotAddClipFile(url, QString());
1863 void MainWindow::slotAddTransition(QAction *result) {
1864 if (!result) return;
1865 QStringList info = result->data().toStringList();
1866 if (info.isEmpty()) return;
1867 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
1868 if (m_activeTimeline && !transition.isNull()) {
1869 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
1873 void MainWindow::slotAddVideoEffect(QAction *result) {
1874 if (!result) return;
1875 QStringList info = result->data().toStringList();
1876 if (info.isEmpty()) return;
1877 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1878 slotAddEffect(effect);
1881 void MainWindow::slotAddAudioEffect(QAction *result) {
1882 if (!result) return;
1883 QStringList info = result->data().toStringList();
1884 if (info.isEmpty()) return;
1885 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1886 slotAddEffect(effect);
1889 void MainWindow::slotAddCustomEffect(QAction *result) {
1890 if (!result) return;
1891 QStringList info = result->data().toStringList();
1892 if (info.isEmpty()) return;
1893 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1894 slotAddEffect(effect);
1897 void MainWindow::slotZoomIn() {
1898 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1901 void MainWindow::slotZoomOut() {
1902 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1905 void MainWindow::slotFitZoom() {
1906 if (m_activeTimeline) {
1907 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1911 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1912 statusProgressBar->setValue(progress);
1913 if (progress >= 0) {
1914 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1915 statusProgressBar->setVisible(true);
1917 m_messageLabel->setMessage(QString(), DefaultMessage);
1918 statusProgressBar->setVisible(false);
1922 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1923 if (clip->clipType() == TEXT) {
1924 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1925 QString path = clip->getProperty("resource");
1926 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1928 doc.setContent(clip->getProperty("xmldata"));
1929 dia_ui->setXml(doc);
1930 if (dia_ui->exec() == QDialog::Accepted) {
1931 QPixmap pix = dia_ui->renderedPixmap();
1933 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1934 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1935 QMap <QString, QString> newprops;
1936 newprops.insert("xmldata", dia_ui->xml().toString());
1937 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1938 m_activeDocument->commandStack()->push(command);
1939 m_clipMonitor->refreshMonitor(true);
1940 m_activeDocument->setModified(true);
1944 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1947 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1948 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1949 if (dia.exec() == QDialog::Accepted) {
1950 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1951 m_activeDocument->commandStack()->push(command);
1953 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1954 if (dia.needsTimelineRefresh()) {
1955 // update clip occurences in timeline
1956 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1961 void MainWindow::customEvent(QEvent* e) {
1962 if (e->type() == QEvent::User) {
1963 // The timeline playing position changed...
1964 kDebug() << "RECIEVED JOG EVEMNT!!!";
1967 void MainWindow::slotActivateEffectStackView() {
1968 effectStack->raiseWindow(effectStackDock);
1971 void MainWindow::slotActivateTransitionView() {
1972 transitionConfig->raiseWindow(transitionConfigDock);
1975 void MainWindow::slotSnapRewind() {
1976 if (m_projectMonitor->isActive()) {
1977 if (m_activeTimeline)
1978 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1979 } else m_clipMonitor->slotSeekToPreviousSnap();
1982 void MainWindow::slotSnapForward() {
1983 if (m_projectMonitor->isActive()) {
1984 if (m_activeTimeline)
1985 m_activeTimeline->projectView()->slotSeekToNextSnap();
1986 } else m_clipMonitor->slotSeekToNextSnap();
1989 void MainWindow::slotClipStart() {
1990 if (m_projectMonitor->isActive()) {
1991 if (m_activeTimeline)
1992 m_activeTimeline->projectView()->clipStart();
1996 void MainWindow::slotClipEnd() {
1997 if (m_projectMonitor->isActive()) {
1998 if (m_activeTimeline)
1999 m_activeTimeline->projectView()->clipEnd();
2003 void MainWindow::slotChangeTool(QAction * action) {
2004 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2005 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2006 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2009 void MainWindow::slotSetTool(PROJECTTOOL tool) {
2010 if (m_activeDocument && m_activeTimeline) {
2011 //m_activeDocument->setTool(tool);
2012 m_activeTimeline->projectView()->setTool(tool);
2016 void MainWindow::slotCopy() {
2017 if (!m_activeDocument || !m_activeTimeline) return;
2018 m_activeTimeline->projectView()->copyClip();
2021 void MainWindow::slotPaste() {
2022 if (!m_activeDocument || !m_activeTimeline) return;
2023 m_activeTimeline->projectView()->pasteClip();
2026 void MainWindow::slotPasteEffects() {
2027 if (!m_activeDocument || !m_activeTimeline) return;
2028 m_activeTimeline->projectView()->pasteClipEffects();
2031 void MainWindow::slotFind() {
2032 if (!m_activeDocument || !m_activeTimeline) return;
2033 m_projectSearch->setEnabled(false);
2034 m_findActivated = true;
2035 m_findString = QString();
2036 m_activeTimeline->projectView()->initSearchStrings();
2037 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2038 m_findTimer.start(5000);
2039 qApp->installEventFilter(this);
2042 void MainWindow::slotFindNext() {
2043 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2044 statusBar()->showMessage(i18n("Found : %1", m_findString));
2046 statusBar()->showMessage(i18n("Reached end of project"));
2048 m_findTimer.start(4000);
2051 void MainWindow::findAhead() {
2052 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2053 m_projectSearchNext->setEnabled(true);
2054 statusBar()->showMessage(i18n("Found : %1", m_findString));
2056 m_projectSearchNext->setEnabled(false);
2057 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2061 void MainWindow::findTimeout() {
2062 m_projectSearchNext->setEnabled(false);
2063 m_findActivated = false;
2064 m_findString = QString();
2065 statusBar()->showMessage(i18n("Find stopped"), 3000);
2066 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2067 m_projectSearch->setEnabled(true);
2068 removeEventFilter(this);
2071 void MainWindow::keyPressEvent(QKeyEvent *ke) {
2072 if (m_findActivated) {
2073 if (ke->key() == Qt::Key_Backspace) {
2074 m_findString = m_findString.left(m_findString.length() - 1);
2076 if (!m_findString.isEmpty()) {
2082 m_findTimer.start(4000);
2085 } else if (ke->key() == Qt::Key_Escape) {
2089 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2090 m_findString += ke->text();
2094 m_findTimer.start(4000);
2098 } else KXmlGuiWindow::keyPressEvent(ke);
2102 /** Gets called when the window gets hidden */
2103 void MainWindow::hideEvent(QHideEvent *event) {
2104 // kDebug() << "I was hidden";
2105 // issue http://www.kdenlive.org/mantis/view.php?id=231
2106 if (this->isMinimized()) {
2107 // kDebug() << "I am minimized";
2108 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2112 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
2113 if (m_findActivated) {
2114 if (event->type() == QEvent::ShortcutOverride) {
2115 QKeyEvent* ke = (QKeyEvent*) event;
2116 if (ke->text().trimmed().isEmpty()) return false;
2119 } else return false;
2121 // pass the event on to the parent class
2122 return QMainWindow::eventFilter(obj, event);
2126 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
2127 KDialog *dialog = new KDialog(this);
2128 dialog->setCaption("Save clip zone");
2129 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2131 QWidget *widget = new QWidget(dialog);
2132 dialog->setMainWidget(widget);
2134 QVBoxLayout *vbox = new QVBoxLayout(widget);
2135 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2136 QString path = m_activeDocument->projectFolder().path();
2138 path.append("untitled.westley");
2139 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2140 url->setFilter("video/mlt-playlist");
2141 QLabel *label2 = new QLabel(i18n("Description:"), this);
2142 KLineEdit *edit = new KLineEdit(this);
2143 vbox->addWidget(label1);
2144 vbox->addWidget(url);
2145 vbox->addWidget(label2);
2146 vbox->addWidget(edit);
2147 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2151 void MainWindow::slotSetInPoint() {
2152 if (m_clipMonitor->isActive()) {
2153 m_clipMonitor->slotSetZoneStart();
2154 } else m_activeTimeline->projectView()->setInPoint();
2157 void MainWindow::slotSetOutPoint() {
2158 if (m_clipMonitor->isActive()) {
2159 m_clipMonitor->slotSetZoneEnd();
2160 } else m_activeTimeline->projectView()->setOutPoint();
2163 void MainWindow::slotGetNewStuff() {
2164 //KNS::Entry::List download();
2165 KNS::Entry::List entries = KNS::Engine::download();
2166 int numberInstalled = 0;
2167 // list of changed entries
2168 kDebug() << "// PARSING KNS";
2169 foreach(KNS::Entry* entry, entries) {
2170 // care only about installed ones
2171 if (entry->status() == KNS::Entry::Installed) {
2172 foreach(const QString &file, entry->installedFiles()) {
2173 kDebug() << "// CURRENTLY INSTALLED: " << file;
2177 qDeleteAll(entries);
2178 initEffects::refreshLumas();
2181 void MainWindow::slotAutoTransition() {
2182 m_activeTimeline->projectView()->autoTransition();
2185 #include "mainwindow.moc"