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;
402 else kDebug()<<"// ERROR LOADING PLUGIN: "<<fileName<<", "<<loader.errorString ();
408 void MainWindow::populateMenus(QObject *plugin)
410 kDebug()<<"// POP MENU";
411 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
412 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
413 kDebug()<<"// POP MENU 2";
414 if (addMenu) kDebug()<<"// POP MENU 3";
416 addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
420 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
421 QMenu *menu, const char *member,
422 QActionGroup *actionGroup)
424 kDebug()<<"// ADD to MENU"<<texts;
425 foreach (QString text, texts) {
426 QAction *action = new QAction(text, plugin);
427 connect(action, SIGNAL(triggered()), this, member);
428 menu->addAction(action);
431 action->setCheckable(true);
432 actionGroup->addAction(action);
437 void MainWindow::aboutPlugins()
439 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
444 void MainWindow::generateClip()
446 QAction *action = qobject_cast<QAction *>(sender());
447 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
449 KUrl clipUrl = iGenerator->generatedClip(action->text(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
450 if (!clipUrl.isEmpty()) {
451 m_projectList->slotAddClip(clipUrl);
455 void MainWindow::saveProperties(KConfig*) {
456 // save properties here,used by session management
461 void MainWindow::readProperties(KConfig *config) {
462 // read properties here,used by session management
463 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
464 openFile(KUrl(Lastproject));
467 void MainWindow::slotReloadEffects() {
468 initEffects::parseCustomEffectsFile();
469 m_customEffectsMenu->clear();
470 const QStringList effects = customEffects.effectNames();
472 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
473 else m_customEffectsMenu->setEnabled(true);
475 foreach(const QString &name, effects) {
476 action = new QAction(name, this);
477 action->setData(name);
478 m_customEffectsMenu->addAction(action);
480 m_effectList->reloadEffectList();
483 #ifndef NO_JOGSHUTTLE
484 void MainWindow::activateShuttleDevice() {
485 if (m_jogProcess) delete m_jogProcess;
487 if (KdenliveSettings::enableshuttle() == false) return;
488 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
489 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
490 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
491 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
492 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
493 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
494 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
497 void MainWindow::slotShuttleButton(int code) {
500 slotShuttleAction(KdenliveSettings::shuttle1());
503 slotShuttleAction(KdenliveSettings::shuttle2());
506 slotShuttleAction(KdenliveSettings::shuttle3());
509 slotShuttleAction(KdenliveSettings::shuttle4());
512 slotShuttleAction(KdenliveSettings::shuttle5());
517 void MainWindow::slotShuttleAction(int code) {
522 m_monitorManager->slotPlay();
525 m_monitorManager->slotPlay();
529 #endif /* NO_JOGSHUTTLE */
531 void MainWindow::configureNotifications() {
532 KNotifyConfigWidget::configure(this);
535 void MainWindow::slotFullScreen() {
536 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
539 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
540 if (!m_activeDocument) return;
541 if (effect.isNull()) {
542 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
545 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
546 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
549 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
550 if (clipMonitor) clipMonitorDock->raise();
551 else projectMonitorDock->raise();
554 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
555 if (!m_activeDocument) return;
556 m_activeDocument->setProducerDuration(id, duration);
559 void MainWindow::slotConnectMonitors() {
561 m_projectList->setRenderer(m_projectMonitor->render);
562 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
563 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
564 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
565 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
566 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 > &)));
568 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
570 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
572 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
573 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
575 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
576 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
579 void MainWindow::slotAdjustClipMonitor() {
580 clipMonitorDock->updateGeometry();
581 clipMonitorDock->adjustSize();
582 m_clipMonitor->resetSize();
585 void MainWindow::slotAdjustProjectMonitor() {
586 projectMonitorDock->updateGeometry();
587 projectMonitorDock->adjustSize();
588 m_projectMonitor->resetSize();
591 void MainWindow::setupActions() {
593 KActionCollection* collection = actionCollection();
594 m_timecodeFormat = new KComboBox(this);
595 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
596 m_timecodeFormat->addItem(i18n("Frames"));
598 statusProgressBar = new QProgressBar(this);
599 statusProgressBar->setMinimum(0);
600 statusProgressBar->setMaximum(100);
601 statusProgressBar->setMaximumWidth(150);
602 statusProgressBar->setVisible(false);
604 QWidget *w = new QWidget;
606 QHBoxLayout *layout = new QHBoxLayout;
607 w->setLayout(layout);
608 layout->setContentsMargins(5, 0, 5, 0);
609 QToolBar *toolbar = new QToolBar("statusToolBar", this);
612 m_toolGroup = new QActionGroup(this);
614 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;}";
616 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
617 toolbar->addAction(m_buttonSelectTool);
618 m_buttonSelectTool->setCheckable(true);
619 m_buttonSelectTool->setChecked(true);
621 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
622 toolbar->addAction(m_buttonRazorTool);
623 m_buttonRazorTool->setCheckable(true);
624 m_buttonRazorTool->setChecked(false);
626 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
627 toolbar->addAction(m_buttonSpacerTool);
628 m_buttonSpacerTool->setCheckable(true);
629 m_buttonSpacerTool->setChecked(false);
631 m_toolGroup->addAction(m_buttonSelectTool);
632 m_toolGroup->addAction(m_buttonRazorTool);
633 m_toolGroup->addAction(m_buttonSpacerTool);
634 m_toolGroup->setExclusive(true);
635 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
637 QWidget * actionWidget;
638 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
639 actionWidget->setMaximumWidth(24);
640 actionWidget->setMinimumHeight(17);
642 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
643 actionWidget->setMaximumWidth(24);
644 actionWidget->setMinimumHeight(17);
646 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
647 actionWidget->setMaximumWidth(24);
648 actionWidget->setMinimumHeight(17);
650 toolbar->setStyleSheet(style1);
651 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
653 toolbar->addSeparator();
654 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
655 toolbar->addAction(m_buttonFitZoom);
656 m_buttonFitZoom->setCheckable(false);
657 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
659 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
660 actionWidget->setMaximumWidth(24);
661 actionWidget->setMinimumHeight(17);
663 m_zoomSlider = new QSlider(Qt::Horizontal, this);
664 m_zoomSlider->setMaximum(13);
665 m_zoomSlider->setPageStep(1);
667 m_zoomSlider->setMaximumWidth(150);
668 m_zoomSlider->setMinimumWidth(100);
670 const int contentHeight = QFontMetrics(w->font()).height() + 8;
672 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
673 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
675 m_zoomSlider->setStyleSheet(style);
677 //m_zoomSlider->height() + 5;
678 statusBar()->setMinimumHeight(contentHeight);
681 toolbar->addWidget(m_zoomSlider);
683 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
684 toolbar->addAction(m_buttonVideoThumbs);
685 m_buttonVideoThumbs->setCheckable(true);
686 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
687 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
689 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
690 toolbar->addAction(m_buttonAudioThumbs);
691 m_buttonAudioThumbs->setCheckable(true);
692 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
693 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
695 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
696 toolbar->addAction(m_buttonShowMarkers);
697 m_buttonShowMarkers->setCheckable(true);
698 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
699 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
701 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
702 toolbar->addAction(m_buttonSnap);
703 m_buttonSnap->setCheckable(true);
704 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
705 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
706 layout->addWidget(toolbar);
709 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
710 actionWidget->setMaximumWidth(24);
711 actionWidget->setMinimumHeight(17);
713 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
714 actionWidget->setMaximumWidth(24);
715 actionWidget->setMinimumHeight(17);
717 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
718 actionWidget->setMaximumWidth(24);
719 actionWidget->setMinimumHeight(17);
721 actionWidget = toolbar->widgetForAction(m_buttonSnap);
722 actionWidget->setMaximumWidth(24);
723 actionWidget->setMinimumHeight(17);
725 m_messageLabel = new StatusBarMessageLabel(this);
726 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
728 statusBar()->addWidget(m_messageLabel, 10);
729 statusBar()->addWidget(statusProgressBar, 0);
730 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
731 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
732 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
733 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
734 m_messageLabel->hide();
736 collection->addAction("select_tool", m_buttonSelectTool);
737 collection->addAction("razor_tool", m_buttonRazorTool);
738 collection->addAction("spacer_tool", m_buttonSpacerTool);
740 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
741 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
742 collection->addAction("show_markers", m_buttonShowMarkers);
743 collection->addAction("snap", m_buttonSnap);
744 collection->addAction("zoom_fit", m_buttonFitZoom);
746 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
747 collection->addAction("zoom_in", zoomIn);
748 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
749 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
751 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
752 collection->addAction("zoom_out", zoomOut);
753 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
754 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
756 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
757 collection->addAction("project_find", m_projectSearch);
758 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
759 m_projectSearch->setShortcut(Qt::Key_Slash);
761 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
762 collection->addAction("project_find_next", m_projectSearchNext);
763 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
764 m_projectSearchNext->setShortcut(Qt::Key_F3);
765 m_projectSearchNext->setEnabled(false);
767 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
768 collection->addAction("manage_profiles", profilesAction);
769 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
771 KAction* fileGHNS = KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewStuff()), actionCollection(), "get_new_stuff");
773 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
774 collection->addAction("run_wizard", wizAction);
775 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
777 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
778 collection->addAction("project_settings", projectAction);
779 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
781 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
782 collection->addAction("project_render", projectRender);
783 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
784 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
786 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
787 KShortcut playShortcut;
788 playShortcut.setPrimary(Qt::Key_Space);
789 playShortcut.setAlternate(Qt::Key_K);
790 monitorPlay->setShortcut(playShortcut);
791 collection->addAction("monitor_play", monitorPlay);
792 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
794 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
795 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
796 collection->addAction("monitor_play_zone", m_playZone);
797 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
799 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
800 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
801 collection->addAction("monitor_loop_zone", m_loopZone);
802 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
804 KAction *markIn = collection->addAction("mark_in");
805 markIn->setText(i18n("Set In Point"));
806 markIn->setShortcut(Qt::Key_I);
807 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
809 KAction *markOut = collection->addAction("mark_out");
810 markOut->setText(i18n("Set Out Point"));
811 markOut->setShortcut(Qt::Key_O);
812 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
814 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
815 monitorSeekBackward->setShortcut(Qt::Key_J);
816 collection->addAction("monitor_seek_backward", monitorSeekBackward);
817 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
819 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
820 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
821 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
822 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
824 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
825 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
826 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
827 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
829 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
830 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
831 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
832 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
834 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
835 monitorSeekForward->setShortcut(Qt::Key_L);
836 collection->addAction("monitor_seek_forward", monitorSeekForward);
837 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
839 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
840 clipStart->setShortcut(Qt::Key_Home);
841 collection->addAction("seek_clip_start", clipStart);
842 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
844 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
845 clipEnd->setShortcut(Qt::Key_End);
846 collection->addAction("seek_clip_end", clipEnd);
847 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
849 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
850 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
851 collection->addAction("seek_start", projectStart);
852 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
854 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
855 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
856 collection->addAction("seek_end", projectEnd);
857 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
859 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
860 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
861 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
862 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
864 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
865 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
866 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
867 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
869 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
870 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
871 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
872 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
874 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
875 deleteTimelineClip->setShortcut(Qt::Key_Delete);
876 collection->addAction("delete_timeline_clip", deleteTimelineClip);
877 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
879 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
880 collection->addAction("change_clip_speed", editTimelineClipSpeed);
881 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
883 KAction *stickTransition = collection->addAction("auto_transition");
884 stickTransition->setData(QString("auto"));
885 stickTransition->setCheckable(true);
886 stickTransition->setEnabled(false);
887 stickTransition->setText(i18n("Automatic Transition"));
888 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
890 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
891 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
892 collection->addAction("cut_timeline_clip", cutTimelineClip);
893 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
895 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
896 collection->addAction("add_clip_marker", addClipMarker);
897 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
899 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
900 collection->addAction("delete_clip_marker", deleteClipMarker);
901 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
903 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
904 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
905 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
907 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
908 collection->addAction("edit_clip_marker", editClipMarker);
909 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
911 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
912 collection->addAction("insert_space", insertSpace);
913 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
915 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
916 collection->addAction("delete_space", removeSpace);
917 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
919 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
920 collection->addAction("insert_track", insertTrack);
921 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
923 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
924 collection->addAction("delete_track", deleteTrack);
925 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
927 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
928 collection->addAction("change_track", changeTrack);
929 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
931 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
932 collection->addAction("add_guide", addGuide);
933 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
935 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
936 collection->addAction("delete_guide", delGuide);
937 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
939 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
940 collection->addAction("edit_guide", editGuide);
941 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
943 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
944 collection->addAction("delete_all_guides", delAllGuides);
945 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
947 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
948 collection->addAction("paste_effects", pasteEffects);
949 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
951 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
953 KStandardAction::quit(this, SLOT(queryQuit()), collection);
955 KStandardAction::open(this, SLOT(openFile()), collection);
957 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
959 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
961 KStandardAction::openNew(this, SLOT(newFile()), collection);
963 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
965 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
967 KStandardAction::copy(this, SLOT(slotCopy()), collection);
969 KStandardAction::paste(this, SLOT(slotPaste()), collection);
971 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
972 undo->setEnabled(false);
973 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
975 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
976 redo->setEnabled(false);
977 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
979 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
981 connect(collection, SIGNAL(actionHovered(QAction*)),
982 this, SLOT(slotDisplayActionMessage(QAction*)));
985 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
986 collection->addAction("add_clip", addClip);
987 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
989 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
990 collection->addAction("add_color_clip", addColorClip);
991 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
993 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
994 collection->addAction("add_slide_clip", addSlideClip);
995 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
997 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
998 collection->addAction("add_text_clip", addTitleClip);
999 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1001 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1002 collection->addAction("add_folder", addFolderButton);
1003 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1005 QMenu *addClips = new QMenu();
1006 addClips->addAction(addClip);
1007 addClips->addAction(addColorClip);
1008 addClips->addAction(addSlideClip);
1009 addClips->addAction(addTitleClip);
1010 addClips->addAction(addFolderButton);
1011 m_projectList->setupMenu(addClips, addClip);
1013 //connect(collection, SIGNAL( clearStatusText() ),
1014 //statusBar(), SLOT( clear() ) );
1017 void MainWindow::slotDisplayActionMessage(QAction *a) {
1018 statusBar()->showMessage(a->data().toString(), 3000);
1021 void MainWindow::saveOptions() {
1022 KdenliveSettings::self()->writeConfig();
1023 KSharedConfigPtr config = KGlobal::config();
1024 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1025 KConfigGroup treecolumns(config, "Project Tree");
1026 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1030 void MainWindow::readOptions() {
1031 KSharedConfigPtr config = KGlobal::config();
1032 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1033 KConfigGroup initialGroup(config, "version");
1034 if (!initialGroup.exists()) {
1035 // this is our first run, show Wizard
1036 Wizard *w = new Wizard(this);
1037 if (w->exec() == QDialog::Accepted && w->isOk()) {
1038 w->adjustSettings();
1039 initialGroup.writeEntry("version", "0.7");
1044 } else if (initialGroup.readEntry("version") == "0.7") {
1045 //Add new settings from 0.7.1
1046 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1047 QString path = QDir::homePath() + "/kdenlive";
1048 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1049 KdenliveSettings::setDefaultprojectfolder(path);
1052 KConfigGroup treecolumns(config, "Project Tree");
1053 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1054 if (!state.isEmpty())
1055 m_projectList->setHeaderInfo(state);
1058 void MainWindow::slotRunWizard() {
1059 Wizard *w = new Wizard(this);
1060 if (w->exec() == QDialog::Accepted && w->isOk()) {
1061 w->adjustSettings();
1066 void MainWindow::newFile(bool showProjectSettings) {
1067 QString profileName;
1069 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1070 if (!showProjectSettings && m_timelineArea->count() == 0) {
1071 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1072 profileName = KdenliveSettings::default_profile();
1074 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1075 if (w->exec() != QDialog::Accepted) return;
1076 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1077 profileName = w->selectedProfile();
1078 projectFolder = w->selectedFolder();
1079 projectTracks = w->tracks();
1082 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1083 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1084 TrackView *trackView = new TrackView(doc, this);
1085 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1086 if (m_timelineArea->count() == 1) {
1087 connectDocumentInfo(doc);
1088 connectDocument(trackView, doc);
1089 } else m_timelineArea->setTabBarHidden(false);
1090 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1093 void MainWindow::activateDocument() {
1094 if (m_timelineArea->currentWidget() == NULL) return;
1095 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1096 KdenliveDoc *currentDoc = currentTab->document();
1097 connectDocumentInfo(currentDoc);
1098 connectDocument(currentTab, currentDoc);
1101 void MainWindow::closeCurrentDocument() {
1102 QWidget *w = m_timelineArea->currentWidget();
1104 // closing current document
1105 int ix = m_timelineArea->currentIndex() + 1;
1106 if (ix == m_timelineArea->count()) ix = 0;
1107 m_timelineArea->setCurrentIndex(ix);
1108 TrackView *tabToClose = (TrackView *) w;
1109 KdenliveDoc *docToClose = tabToClose->document();
1110 if (docToClose && docToClose->isModified()) {
1111 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1112 case KMessageBox::Yes :
1113 // save document here. If saving fails, return false;
1116 case KMessageBox::Cancel :
1122 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1123 if (m_timelineArea->count() == 1) {
1124 m_timelineArea->setTabBarHidden(true);
1125 m_closeAction->setEnabled(false);
1129 if (m_timelineArea->count() == 0) {
1130 m_activeDocument = NULL;
1131 effectStack->clear();
1132 transitionConfig->slotTransitionItemSelected(NULL, false);
1136 bool MainWindow::saveFileAs(const QString &outputFileName) {
1137 QDomDocument currentSceneList = m_projectMonitor->sceneList();
1138 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1141 // Save timeline thumbnails
1142 m_activeTimeline->projectView()->saveThumbnails();
1143 m_activeDocument->setUrl(KUrl(outputFileName));
1144 if (m_activeDocument->m_autosave == NULL) {
1145 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1146 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1147 setCaption(m_activeDocument->description());
1148 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1149 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1150 m_activeDocument->setModified(false);
1151 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1155 bool MainWindow::saveFileAs() {
1156 // Check that the Kdenlive mime type is correctly installed
1157 QString mimetype = "application/x-kdenlive";
1158 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1159 if (!mime) mimetype = "*.kdenlive";
1161 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1162 if (outputFile.isEmpty()) return false;
1163 if (QFile::exists(outputFile)) {
1164 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1166 return saveFileAs(outputFile);
1169 bool MainWindow::saveFile() {
1170 if (!m_activeDocument) return true;
1171 if (m_activeDocument->url().isEmpty()) {
1172 return saveFileAs();
1174 bool result = saveFileAs(m_activeDocument->url().path());
1175 m_activeDocument->m_autosave->resize(0);
1180 void MainWindow::openFile() {
1181 // Check that the Kdenlive mime type is correctly installed
1182 QString mimetype = "application/x-kdenlive";
1183 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1184 if (!mime) mimetype = "*.kdenlive";
1186 KUrl url = KFileDialog::getOpenUrl(KUrl(), mimetype);
1187 if (url.isEmpty()) return;
1188 m_fileOpenRecent->addUrl(url);
1192 void MainWindow::openLastFile() {
1193 KSharedConfigPtr config = KGlobal::config();
1194 KUrl::List urls = m_fileOpenRecent->urls();
1195 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1196 if (urls.isEmpty()) newFile(false);
1197 else openFile(urls.last());
1200 void MainWindow::openFile(const KUrl &url) {
1201 // Check if the document is already opened
1202 const int ct = m_timelineArea->count();
1203 bool isOpened = false;
1205 for (i = 0; i < ct; i++) {
1206 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1207 KdenliveDoc *doc = tab->document();
1208 if (doc->url() == url) {
1214 m_timelineArea->setCurrentIndex(i);
1218 // Check for backup file
1219 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1220 if (!staleFiles.isEmpty()) {
1221 if (KMessageBox::questionYesNo(this,
1222 i18n("Auto-saved files exist. Do you want to recover them now?"),
1223 i18n("File Recovery"),
1224 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1225 recoverFiles(staleFiles);
1228 // remove the stale files
1229 foreach(KAutoSaveFile *stale, staleFiles) {
1230 stale->open(QIODevice::ReadWrite);
1235 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1236 doOpenFile(url, NULL);
1239 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1241 doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1242 if (stale == NULL) {
1243 stale = new KAutoSaveFile(url, doc);
1244 doc->m_autosave = stale;
1246 doc->m_autosave = stale;
1247 doc->setUrl(stale->managedFile());
1248 doc->setModified(true);
1249 stale->setParent(doc);
1251 connectDocumentInfo(doc);
1252 TrackView *trackView = new TrackView(doc, this);
1253 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1254 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1255 trackView->setDuration(trackView->duration());
1256 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1258 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1259 slotGotProgressInfo(QString(), -1);
1260 m_clipMonitor->refreshMonitor(true);
1263 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1264 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1265 foreach(KAutoSaveFile *stale, staleFiles) {
1266 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1267 // show an error message; we could not steal the lockfile
1268 // maybe another application got to the file before us?
1272 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1273 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1274 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1275 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1280 void MainWindow::parseProfiles(const QString &mltPath) {
1281 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1283 //KdenliveSettings::setDefaulttmpfolder();
1284 if (!mltPath.isEmpty()) {
1285 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1286 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1289 if (KdenliveSettings::mltpath().isEmpty()) {
1290 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1292 if (KdenliveSettings::rendererpath().isEmpty()) {
1293 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1294 if (!QFile::exists(inigoPath))
1295 inigoPath = KStandardDirs::findExe("inigo");
1296 else KdenliveSettings::setRendererpath(inigoPath);
1298 QStringList profilesFilter;
1299 profilesFilter << "*";
1300 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1302 if (profilesList.isEmpty()) {
1303 // Cannot find MLT path, try finding inigo
1304 QString profilePath = KdenliveSettings::rendererpath();
1305 if (!profilePath.isEmpty()) {
1306 profilePath = profilePath.section('/', 0, -3);
1307 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1308 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1311 if (profilesList.isEmpty()) {
1312 // Cannot find the MLT profiles, ask for location
1313 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1314 getUrl->fileDialog()->setMode(KFile::Directory);
1315 if (getUrl->exec() == QDialog::Rejected) {
1318 KUrl mltPath = getUrl->selectedUrl();
1320 if (mltPath.isEmpty()) ::exit(0);
1321 KdenliveSettings::setMltpath(mltPath.path());
1322 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1326 if (KdenliveSettings::rendererpath().isEmpty()) {
1327 // Cannot find the MLT inigo renderer, ask for location
1328 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1329 if (getUrl->exec() == QDialog::Rejected) {
1332 KUrl rendererPath = getUrl->selectedUrl();
1334 if (rendererPath.isEmpty()) ::exit(0);
1335 KdenliveSettings::setRendererpath(rendererPath.path());
1338 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1340 // Parse MLT profiles to build a list of available video formats
1341 if (profilesList.isEmpty()) parseProfiles();
1345 void MainWindow::slotEditProfiles() {
1346 ProfilesDialog *w = new ProfilesDialog;
1351 void MainWindow::slotEditProjectSettings() {
1352 QPoint p = m_activeDocument->getTracksCount();
1353 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1355 if (w->exec() == QDialog::Accepted) {
1356 QString profile = w->selectedProfile();
1357 m_activeDocument->setProjectFolder(w->selectedFolder());
1358 if (m_activeDocument->profilePath() != profile) {
1359 // Profile was changed
1360 m_activeDocument->setProfilePath(profile);
1361 KdenliveSettings::setCurrent_profile(profile);
1362 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1363 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1364 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1365 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1366 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1368 // We need to desactivate & reactivate monitors to get a refresh
1369 m_monitorManager->switchMonitors();
1375 void MainWindow::slotRenderProject() {
1376 if (!m_renderWidget) {
1377 m_renderWidget = new RenderWidget(this);
1378 connect(m_renderWidget, SIGNAL(doRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)), this, SLOT(slotDoRender(const QString&, const QString&, const QStringList &, const QStringList &, bool, bool, double, double)));
1379 if (m_activeDocument) {
1380 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1381 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1384 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1385 if (currentTab) m_renderWidget->setTimeline(currentTab);
1386 m_renderWidget->setDocument(m_activeDocument);*/
1387 m_renderWidget->show();
1390 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) {
1391 if (dest.isEmpty()) return;
1394 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1395 if (currentTab && zoneOnly) {
1396 in = currentTab->inPoint();
1397 out = currentTab->outPoint();
1399 KTemporaryFile temp;
1400 temp.setAutoRemove(false);
1401 temp.setSuffix(".westley");
1403 m_projectMonitor->saveSceneList(temp.fileName());
1406 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1407 else if (guideStart != -1) {
1408 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1410 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1411 QString videoPlayer = "-";
1413 videoPlayer = KdenliveSettings::defaultplayerapp();
1414 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."));
1416 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1417 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1420 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer << temp.fileName() << dest << avformat_args;
1421 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1422 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1423 QProcess::startDetached(renderer, args);
1425 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1429 void MainWindow::slotUpdateMousePosition(int pos) {
1430 if (m_activeDocument)
1431 switch (m_timecodeFormat->currentIndex()) {
1433 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1436 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1440 void MainWindow::slotUpdateDocumentState(bool modified) {
1441 setCaption(m_activeDocument->description(), modified);
1442 m_saveAction->setEnabled(modified);
1444 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1445 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1447 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1448 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1452 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1453 if (m_activeDocument) {
1454 if (m_activeDocument == doc) return;
1455 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1457 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1460 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1461 //m_projectMonitor->stop();
1462 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1463 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1464 if (m_activeDocument) {
1465 if (m_activeDocument == doc) return;
1466 m_activeDocument->backupMltPlaylist();
1467 if (m_activeTimeline) {
1468 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1469 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1470 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1471 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1474 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1475 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1476 disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1477 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1478 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1479 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1480 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1481 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1482 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1483 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1484 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1485 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1486 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1487 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1488 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1489 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1490 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1491 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1492 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1493 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1494 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1495 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1496 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1497 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1498 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1499 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1500 disconnect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), m_activeTimeline->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1501 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1502 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1503 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1504 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1505 effectStack->clear();
1507 //m_activeDocument->setRenderer(NULL);
1508 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1509 m_clipMonitor->stop();
1511 KdenliveSettings::setCurrent_profile(doc->profilePath());
1512 KdenliveSettings::setProject_fps(doc->fps());
1513 m_monitorManager->resetProfiles(doc->timecode());
1514 m_projectList->setDocument(doc);
1515 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1516 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1517 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1518 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1519 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1520 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1521 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1522 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1523 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1524 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1525 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1526 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1527 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1528 connect(doc, SIGNAL(addProjectFolder(const QString, const QString &, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, const QString &, bool, bool)));
1529 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1530 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1531 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1533 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1534 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1535 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1538 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1539 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1540 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1541 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView()));
1542 m_zoomSlider->setValue(doc->zoom());
1543 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1544 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1545 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1546 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1548 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1551 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1552 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1553 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1554 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1555 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1556 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1557 connect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), trackView->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1558 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1559 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1561 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1562 connect(trackView, SIGNAL(zoneMoved(int, int)), m_projectMonitor, SLOT(slotZoneMoved(int, int)));
1563 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1565 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1566 m_activeTimeline = trackView;
1567 if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
1568 //doc->setRenderer(m_projectMonitor->render);
1569 m_commandStack->setActiveStack(doc->commandStack());
1570 KdenliveSettings::setProject_display_ratio(doc->dar());
1571 m_projectList->updateAllClips();
1572 //doc->clipManager()->checkAudioThumbs();
1574 //m_overView->setScene(trackView->projectScene());
1575 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1576 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1578 setCaption(doc->description(), doc->isModified());
1579 m_saveAction->setEnabled(doc->isModified());
1580 m_activeDocument = doc;
1582 // set tool to select tool
1583 m_buttonSelectTool->setChecked(true);
1586 void MainWindow::slotGuidesUpdated() {
1587 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1590 void MainWindow::slotPreferences(int page, int option) {
1591 //An instance of your dialog could be already created and could be
1592 // cached, in which case you want to display the cached dialog
1593 // instead of creating another one
1594 if (KConfigDialog::showDialog("settings")) {
1595 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1596 if (page != -1) d->showPage(page, option);
1601 // KConfigDialog didn't find an instance of this dialog, so lets
1603 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1604 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1605 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1607 if (page != -1) dialog->showPage(page, option);
1610 void MainWindow::updateConfiguration() {
1611 //TODO: we should apply settings to all projects, not only the current one
1612 if (m_activeTimeline) {
1613 m_activeTimeline->refresh();
1614 m_activeTimeline->projectView()->checkAutoScroll();
1615 m_activeTimeline->projectView()->checkTrackHeight();
1616 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1618 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1619 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1620 #ifndef NO_JOGSHUTTLE
1621 activateShuttleDevice();
1622 #endif /* NO_JOGSHUTTLE */
1626 void MainWindow::slotSwitchVideoThumbs() {
1627 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1628 if (m_activeTimeline) {
1629 m_activeTimeline->refresh();
1631 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1634 void MainWindow::slotSwitchAudioThumbs() {
1635 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1636 if (m_activeTimeline) {
1637 m_activeTimeline->refresh();
1638 m_activeTimeline->projectView()->checkAutoScroll();
1639 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1641 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1644 void MainWindow::slotSwitchMarkersComments() {
1645 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1646 if (m_activeTimeline) {
1647 m_activeTimeline->refresh();
1649 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1652 void MainWindow::slotSwitchSnap() {
1653 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1654 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1658 void MainWindow::slotDeleteTimelineClip() {
1659 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1660 else if (m_activeTimeline) {
1661 m_activeTimeline->projectView()->deleteSelectedClips();
1665 void MainWindow::slotChangeClipSpeed() {
1666 if (m_activeTimeline) {
1667 m_activeTimeline->projectView()->changeClipSpeed();
1671 void MainWindow::slotAddClipMarker() {
1672 DocClipBase *clip = NULL;
1674 if (m_projectMonitor->isActive()) {
1675 if (m_activeTimeline) {
1676 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1678 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1679 clip = item->baseClip();
1683 clip = m_clipMonitor->activeClip();
1684 pos = m_clipMonitor->position();
1687 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1690 QString id = clip->getId();
1691 CommentedTime marker(pos, i18n("Marker"));
1692 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1693 if (d.exec() == QDialog::Accepted) {
1694 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1696 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1699 void MainWindow::slotDeleteClipMarker() {
1700 DocClipBase *clip = NULL;
1702 if (m_projectMonitor->isActive()) {
1703 if (m_activeTimeline) {
1704 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1706 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1707 clip = item->baseClip();
1711 clip = m_clipMonitor->activeClip();
1712 pos = m_clipMonitor->position();
1715 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1719 QString id = clip->getId();
1720 QString comment = clip->markerComment(pos);
1721 if (comment.isEmpty()) {
1722 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1725 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1726 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1730 void MainWindow::slotDeleteAllClipMarkers() {
1731 DocClipBase *clip = NULL;
1732 if (m_projectMonitor->isActive()) {
1733 if (m_activeTimeline) {
1734 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1736 clip = item->baseClip();
1740 clip = m_clipMonitor->activeClip();
1743 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1746 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
1747 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1750 void MainWindow::slotEditClipMarker() {
1751 DocClipBase *clip = NULL;
1753 if (m_projectMonitor->isActive()) {
1754 if (m_activeTimeline) {
1755 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1757 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1758 clip = item->baseClip();
1762 clip = m_clipMonitor->activeClip();
1763 pos = m_clipMonitor->position();
1766 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1770 QString id = clip->getId();
1771 QString oldcomment = clip->markerComment(pos);
1772 if (oldcomment.isEmpty()) {
1773 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1777 CommentedTime marker(pos, oldcomment);
1778 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
1779 if (d.exec() == QDialog::Accepted) {
1780 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1781 if (d.newMarker().time() != pos) {
1782 // remove old marker
1783 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
1785 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1789 void MainWindow::slotAddGuide() {
1790 if (m_activeTimeline)
1791 m_activeTimeline->projectView()->slotAddGuide();
1794 void MainWindow::slotInsertSpace() {
1795 if (m_activeTimeline)
1796 m_activeTimeline->projectView()->slotInsertSpace();
1799 void MainWindow::slotRemoveSpace() {
1800 if (m_activeTimeline)
1801 m_activeTimeline->projectView()->slotRemoveSpace();
1804 void MainWindow::slotInsertTrack(int ix) {
1805 m_projectMonitor->activateMonitor();
1806 if (m_activeTimeline)
1807 m_activeTimeline->projectView()->slotInsertTrack(ix);
1810 void MainWindow::slotDeleteTrack(int ix) {
1811 m_projectMonitor->activateMonitor();
1812 if (m_activeTimeline)
1813 m_activeTimeline->projectView()->slotDeleteTrack(ix);
1816 void MainWindow::slotChangeTrack(int ix) {
1817 m_projectMonitor->activateMonitor();
1818 if (m_activeTimeline)
1819 m_activeTimeline->projectView()->slotChangeTrack(ix);
1822 void MainWindow::slotEditGuide() {
1823 if (m_activeTimeline)
1824 m_activeTimeline->projectView()->slotEditGuide();
1827 void MainWindow::slotDeleteGuide() {
1828 if (m_activeTimeline)
1829 m_activeTimeline->projectView()->slotDeleteGuide();
1832 void MainWindow::slotDeleteAllGuides() {
1833 if (m_activeTimeline)
1834 m_activeTimeline->projectView()->slotDeleteAllGuides();
1837 void MainWindow::slotCutTimelineClip() {
1838 if (m_activeTimeline) {
1839 m_activeTimeline->projectView()->cutSelectedClips();
1843 void MainWindow::slotAddProjectClip(KUrl url) {
1844 if (m_activeDocument)
1845 m_activeDocument->slotAddClipFile(url, QString());
1848 void MainWindow::slotAddTransition(QAction *result) {
1849 if (!result) return;
1850 QStringList info = result->data().toStringList();
1851 if (info.isEmpty()) return;
1852 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
1853 if (m_activeTimeline && !transition.isNull()) {
1854 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
1858 void MainWindow::slotAddVideoEffect(QAction *result) {
1859 if (!result) return;
1860 QStringList info = result->data().toStringList();
1861 if (info.isEmpty()) return;
1862 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1863 slotAddEffect(effect);
1866 void MainWindow::slotAddAudioEffect(QAction *result) {
1867 if (!result) return;
1868 QStringList info = result->data().toStringList();
1869 if (info.isEmpty()) return;
1870 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1871 slotAddEffect(effect);
1874 void MainWindow::slotAddCustomEffect(QAction *result) {
1875 if (!result) return;
1876 QStringList info = result->data().toStringList();
1877 if (info.isEmpty()) return;
1878 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1879 slotAddEffect(effect);
1882 void MainWindow::slotZoomIn() {
1883 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1886 void MainWindow::slotZoomOut() {
1887 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1890 void MainWindow::slotFitZoom() {
1891 if (m_activeTimeline) {
1892 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1896 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1897 statusProgressBar->setValue(progress);
1898 if (progress >= 0) {
1899 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1900 statusProgressBar->setVisible(true);
1902 m_messageLabel->setMessage(QString(), DefaultMessage);
1903 statusProgressBar->setVisible(false);
1907 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1908 if (clip->clipType() == TEXT) {
1909 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1910 QString path = clip->getProperty("resource");
1911 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1913 doc.setContent(clip->getProperty("xmldata"));
1914 dia_ui->setXml(doc);
1915 if (dia_ui->exec() == QDialog::Accepted) {
1916 QPixmap pix = dia_ui->renderedPixmap();
1918 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1919 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1920 QMap <QString, QString> newprops;
1921 newprops.insert("xmldata", dia_ui->xml().toString());
1922 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1923 m_activeDocument->commandStack()->push(command);
1924 m_clipMonitor->refreshMonitor(true);
1925 m_activeDocument->setModified(true);
1929 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
1932 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
1933 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
1934 if (dia.exec() == QDialog::Accepted) {
1935 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
1936 m_activeDocument->commandStack()->push(command);
1938 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
1939 if (dia.needsTimelineRefresh()) {
1940 // update clip occurences in timeline
1941 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
1946 void MainWindow::customEvent(QEvent* e) {
1947 if (e->type() == QEvent::User) {
1948 // The timeline playing position changed...
1949 kDebug() << "RECIEVED JOG EVEMNT!!!";
1952 void MainWindow::slotActivateEffectStackView() {
1953 effectStack->raiseWindow(effectStackDock);
1956 void MainWindow::slotActivateTransitionView() {
1957 transitionConfig->raiseWindow(transitionConfigDock);
1960 void MainWindow::slotSnapRewind() {
1961 if (m_projectMonitor->isActive()) {
1962 if (m_activeTimeline)
1963 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
1964 } else m_clipMonitor->slotSeekToPreviousSnap();
1967 void MainWindow::slotSnapForward() {
1968 if (m_projectMonitor->isActive()) {
1969 if (m_activeTimeline)
1970 m_activeTimeline->projectView()->slotSeekToNextSnap();
1971 } else m_clipMonitor->slotSeekToNextSnap();
1974 void MainWindow::slotClipStart() {
1975 if (m_projectMonitor->isActive()) {
1976 if (m_activeTimeline)
1977 m_activeTimeline->projectView()->clipStart();
1981 void MainWindow::slotClipEnd() {
1982 if (m_projectMonitor->isActive()) {
1983 if (m_activeTimeline)
1984 m_activeTimeline->projectView()->clipEnd();
1988 void MainWindow::slotChangeTool(QAction * action) {
1989 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
1990 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
1991 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
1994 void MainWindow::slotSetTool(PROJECTTOOL tool) {
1995 if (m_activeDocument && m_activeTimeline) {
1996 //m_activeDocument->setTool(tool);
1997 m_activeTimeline->projectView()->setTool(tool);
2001 void MainWindow::slotCopy() {
2002 if (!m_activeDocument || !m_activeTimeline) return;
2003 m_activeTimeline->projectView()->copyClip();
2006 void MainWindow::slotPaste() {
2007 if (!m_activeDocument || !m_activeTimeline) return;
2008 m_activeTimeline->projectView()->pasteClip();
2011 void MainWindow::slotPasteEffects() {
2012 if (!m_activeDocument || !m_activeTimeline) return;
2013 m_activeTimeline->projectView()->pasteClipEffects();
2016 void MainWindow::slotFind() {
2017 if (!m_activeDocument || !m_activeTimeline) return;
2018 m_projectSearch->setEnabled(false);
2019 m_findActivated = true;
2020 m_findString = QString();
2021 m_activeTimeline->projectView()->initSearchStrings();
2022 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2023 m_findTimer.start(5000);
2024 qApp->installEventFilter(this);
2027 void MainWindow::slotFindNext() {
2028 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2029 statusBar()->showMessage(i18n("Found : %1", m_findString));
2031 statusBar()->showMessage(i18n("Reached end of project"));
2033 m_findTimer.start(4000);
2036 void MainWindow::findAhead() {
2037 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2038 m_projectSearchNext->setEnabled(true);
2039 statusBar()->showMessage(i18n("Found : %1", m_findString));
2041 m_projectSearchNext->setEnabled(false);
2042 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2046 void MainWindow::findTimeout() {
2047 m_projectSearchNext->setEnabled(false);
2048 m_findActivated = false;
2049 m_findString = QString();
2050 statusBar()->showMessage(i18n("Find stopped"), 3000);
2051 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2052 m_projectSearch->setEnabled(true);
2053 removeEventFilter(this);
2056 void MainWindow::keyPressEvent(QKeyEvent *ke) {
2057 if (m_findActivated) {
2058 if (ke->key() == Qt::Key_Backspace) {
2059 m_findString = m_findString.left(m_findString.length() - 1);
2061 if (!m_findString.isEmpty()) {
2067 m_findTimer.start(4000);
2070 } else if (ke->key() == Qt::Key_Escape) {
2074 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2075 m_findString += ke->text();
2079 m_findTimer.start(4000);
2083 } else KXmlGuiWindow::keyPressEvent(ke);
2087 /** Gets called when the window gets hidden */
2088 void MainWindow::hideEvent(QHideEvent *event) {
2089 // kDebug() << "I was hidden";
2090 // issue http://www.kdenlive.org/mantis/view.php?id=231
2091 if (this->isMinimized()) {
2092 // kDebug() << "I am minimized";
2093 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2097 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
2098 if (m_findActivated) {
2099 if (event->type() == QEvent::ShortcutOverride) {
2100 QKeyEvent* ke = (QKeyEvent*) event;
2101 if (ke->text().trimmed().isEmpty()) return false;
2104 } else return false;
2106 // pass the event on to the parent class
2107 return QMainWindow::eventFilter(obj, event);
2111 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
2112 KDialog *dialog = new KDialog(this);
2113 dialog->setCaption("Save clip zone");
2114 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2116 QWidget *widget = new QWidget(dialog);
2117 dialog->setMainWidget(widget);
2119 QVBoxLayout *vbox = new QVBoxLayout(widget);
2120 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2121 QString path = m_activeDocument->projectFolder().path();
2123 path.append("untitled.westley");
2124 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2125 url->setFilter("video/mlt-playlist");
2126 QLabel *label2 = new QLabel(i18n("Description:"), this);
2127 KLineEdit *edit = new KLineEdit(this);
2128 vbox->addWidget(label1);
2129 vbox->addWidget(url);
2130 vbox->addWidget(label2);
2131 vbox->addWidget(edit);
2132 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2136 void MainWindow::slotSetInPoint() {
2137 if (m_clipMonitor->isActive()) {
2138 m_clipMonitor->slotSetZoneStart();
2139 } else m_activeTimeline->projectView()->setInPoint();
2142 void MainWindow::slotSetOutPoint() {
2143 if (m_clipMonitor->isActive()) {
2144 m_clipMonitor->slotSetZoneEnd();
2145 } else m_activeTimeline->projectView()->setOutPoint();
2148 void MainWindow::slotGetNewStuff() {
2149 //KNS::Entry::List download();
2150 KNS::Entry::List entries = KNS::Engine::download();
2151 int numberInstalled = 0;
2152 // list of changed entries
2153 kDebug() << "// PARSING KNS";
2154 foreach(KNS::Entry* entry, entries) {
2155 // care only about installed ones
2156 if (entry->status() == KNS::Entry::Installed) {
2157 foreach(const QString &file, entry->installedFiles()) {
2158 kDebug() << "// CURRENTLY INSTALLED: " << file;
2162 qDeleteAll(entries);
2163 initEffects::refreshLumas();
2166 void MainWindow::slotAutoTransition() {
2167 m_activeTimeline->projectView()->autoTransition();
2170 #include "mainwindow.moc"