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>
59 #include "mainwindow.h"
60 #include "mainwindowadaptor.h"
61 #include "kdenlivesettings.h"
62 #include "kdenlivesettingsdialog.h"
63 #include "initeffects.h"
64 #include "profilesdialog.h"
65 #include "projectsettings.h"
67 #include "clipmanager.h"
68 #include "projectlist.h"
70 #include "recmonitor.h"
71 #include "monitormanager.h"
72 #include "kdenlivedoc.h"
73 #include "trackview.h"
74 #include "customtrackview.h"
75 #include "effectslistview.h"
76 #include "effectstackview.h"
77 #include "transitionsettings.h"
78 #include "renderwidget.h"
81 #include "jogshuttle.h"
82 #endif /* NO_JOGSHUTTLE */
83 #include "clipproperties.h"
85 #include "editclipcommand.h"
86 #include "titlewidget.h"
87 #include "markerdialog.h"
90 #include "interfaces.h"
92 // #include "scriptingpart.h"
94 static const int ID_STATUS_MSG = 1;
95 static const int ID_EDITMODE_MSG = 2;
96 static const int ID_TIMELINE_MSG = 3;
97 static const int ID_TIMELINE_BUTTONS = 5;
98 static const int ID_TIMELINE_POS = 6;
99 static const int ID_TIMELINE_FORMAT = 7;
105 EffectsList MainWindow::videoEffects;
106 EffectsList MainWindow::audioEffects;
107 EffectsList MainWindow::customEffects;
108 EffectsList MainWindow::transitions;
110 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent)
111 : KXmlGuiWindow(parent),
112 m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL),
113 #ifndef NO_JOGSHUTTLE
115 #endif /* NO_JOGSHUTTLE */
116 m_findActivated(false), m_initialized(false) {
118 // Create DBus interface
119 new MainWindowAdaptor(this);
120 QDBusConnection dbus = QDBusConnection::sessionBus();
121 dbus.registerObject("/MainWindow", this);
123 setlocale(LC_NUMERIC, "POSIX");
124 setFont(KGlobalSettings::toolBarFont());
125 parseProfiles(MltPath);
126 m_commandStack = new QUndoGroup;
127 m_timelineArea = new KTabWidget(this);
128 m_timelineArea->setTabReorderingEnabled(true);
129 m_timelineArea->setTabBarHidden(true);
131 QToolButton *closeTabButton = new QToolButton;
132 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
133 closeTabButton->setIcon(KIcon("tab-close"));
134 closeTabButton->adjustSize();
135 closeTabButton->setToolTip(i18n("Close the current tab"));
136 m_timelineArea->setCornerWidget(closeTabButton);
137 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
139 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
140 m_findTimer.setSingleShot(true);
142 initEffects::parseEffectFiles();
143 //initEffects::parseCustomEffectsFile();
145 m_monitorManager = new MonitorManager();
147 projectListDock = new QDockWidget(i18n("Project Tree"), this);
148 projectListDock->setObjectName("project_tree");
149 m_projectList = new ProjectList(this);
150 projectListDock->setWidget(m_projectList);
151 addDockWidget(Qt::TopDockWidgetArea, projectListDock);
153 effectListDock = new QDockWidget(i18n("Effect List"), this);
154 effectListDock->setObjectName("effect_list");
155 m_effectList = new EffectsListView();
157 //m_effectList = new KListWidget(this);
158 effectListDock->setWidget(m_effectList);
159 addDockWidget(Qt::TopDockWidgetArea, effectListDock);
161 effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
162 effectStackDock->setObjectName("effect_stack");
163 effectStack = new EffectStackView(this);
164 effectStackDock->setWidget(effectStack);
165 addDockWidget(Qt::TopDockWidgetArea, effectStackDock);
167 transitionConfigDock = new QDockWidget(i18n("Transition"), this);
168 transitionConfigDock->setObjectName("transition");
169 transitionConfig = new TransitionSettings(this);
170 transitionConfigDock->setWidget(transitionConfig);
171 addDockWidget(Qt::TopDockWidgetArea, transitionConfigDock);
173 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
174 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)),
178 clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
179 clipMonitorDock->setObjectName("clip_monitor");
180 m_clipMonitor = new Monitor("clip", m_monitorManager, this);
181 clipMonitorDock->setWidget(m_clipMonitor);
182 addDockWidget(Qt::TopDockWidgetArea, clipMonitorDock);
183 //m_clipMonitor->stop();
185 projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
186 projectMonitorDock->setObjectName("project_monitor");
187 m_projectMonitor = new Monitor("project", m_monitorManager, this);
188 projectMonitorDock->setWidget(m_projectMonitor);
189 addDockWidget(Qt::TopDockWidgetArea, projectMonitorDock);
191 recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
192 recMonitorDock->setObjectName("record_monitor");
193 m_recMonitor = new RecMonitor("record", this);
194 recMonitorDock->setWidget(m_recMonitor);
195 addDockWidget(Qt::TopDockWidgetArea, recMonitorDock);
197 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
198 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
200 undoViewDock = new QDockWidget(i18n("Undo History"), this);
201 undoViewDock->setObjectName("undo_history");
202 m_undoView = new QUndoView(this);
203 m_undoView->setCleanIcon(KIcon("edit-clear"));
204 m_undoView->setEmptyLabel(i18n("Clean"));
205 undoViewDock->setWidget(m_undoView);
206 m_undoView->setGroup(m_commandStack);
207 addDockWidget(Qt::TopDockWidgetArea, undoViewDock);
209 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
210 //overviewDock->setObjectName("project_overview");
211 //m_overView = new CustomTrackView(NULL, NULL, this);
212 //overviewDock->setWidget(m_overView);
213 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
216 //tabifyDockWidget(projectListDock, effectListDock);
217 tabifyDockWidget(projectListDock, effectStackDock);
218 tabifyDockWidget(projectListDock, transitionConfigDock);
219 //tabifyDockWidget(projectListDock, undoViewDock);
222 tabifyDockWidget(clipMonitorDock, projectMonitorDock);
223 tabifyDockWidget(clipMonitorDock, recMonitorDock);
224 setCentralWidget(m_timelineArea);
228 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
229 guiFactory()->addClient(sp);*/
232 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
234 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
235 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
236 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)));
238 // build effects menus
240 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
242 QStringList effectInfo;
243 QMap<QString, QStringList> effectsList;
244 for (int ix = 0; ix < videoEffects.count(); ix++) {
245 effectInfo = videoEffects.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 videoEffectsMenu->addAction(action);
255 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
259 for (int ix = 0; ix < audioEffects.count(); ix++) {
260 effectInfo = audioEffects.effectIdInfo(ix);
261 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
264 foreach(QStringList value, effectsList) {
265 action = new QAction(value.at(0), this);
266 action->setData(value);
267 audioEffectsMenu->addAction(action);
270 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
272 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
273 else m_customEffectsMenu->setEnabled(true);
276 for (int ix = 0; ix < customEffects.count(); ix++) {
277 effectInfo = customEffects.effectIdInfo(ix);
278 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
281 foreach(QStringList value, effectsList) {
282 action = new QAction(value.at(0), this);
283 action->setData(value);
284 m_customEffectsMenu->addAction(action);
287 QMenu *newEffect = new QMenu(this);
288 newEffect->addMenu(videoEffectsMenu);
289 newEffect->addMenu(audioEffectsMenu);
290 newEffect->addMenu(m_customEffectsMenu);
291 effectStack->setMenu(newEffect);
294 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
295 const QList<QAction *> viewActions = createPopupMenu()->actions();
296 viewMenu->insertActions(NULL, viewActions);
298 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
299 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
300 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
302 m_timelineContextMenu = new QMenu(this);
303 m_timelineContextClipMenu = new QMenu(this);
304 m_timelineContextTransitionMenu = new QMenu(this);
307 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
308 QStringList effects = transitions.effectNames();
311 for (int ix = 0; ix < transitions.count(); ix++) {
312 effectInfo = transitions.effectIdInfo(ix);
313 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
315 foreach(QStringList value, effectsList) {
316 action = new QAction(value.at(0), this);
317 action->setData(value);
318 transitionsMenu->addAction(action);
320 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
322 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
323 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
324 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
326 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
327 m_timelineContextClipMenu->addAction(actionCollection()->action("change_clip_speed"));
328 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
329 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
330 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
332 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
333 m_timelineContextClipMenu->addMenu(markersMenu);
334 m_timelineContextClipMenu->addMenu(transitionsMenu);
335 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
336 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
337 //TODO: re-enable custom effects menu when it is implemented
338 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
340 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
341 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
343 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
345 connect(projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
346 connect(clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
347 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
348 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
349 connect(m_effectList, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
350 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
352 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
353 slotConnectMonitors();
355 // Open or create a file. Command line argument passed in Url has
356 // precedence, then "openlastproject", then just a plain empty file.
357 // If opening Url fails, openlastproject will _not_ be used.
358 if (!Url.isEmpty()) {
361 if (KdenliveSettings::openlastproject()) {
365 if (m_timelineArea->count() == 0) {
369 #ifndef NO_JOGSHUTTLE
370 activateShuttleDevice();
371 #endif /* NO_JOGSHUTTLE */
372 projectListDock->raise();
375 void MainWindow::queryQuit() {
376 kDebug() << "----- SAVING CONFUIG";
377 if (queryClose()) kapp->quit();
381 bool MainWindow::queryClose() {
383 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
384 if (m_activeDocument && m_activeDocument->isModified()) {
385 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
386 case KMessageBox::Yes :
387 // save document here. If saving fails, return false;
389 case KMessageBox::No :
399 void MainWindow::loadPlugins() {
400 foreach(QObject *plugin, QPluginLoader::staticInstances())
401 populateMenus(plugin);
403 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
405 filters << "libkdenlive*";
406 foreach(const QString &folder, directories) {
407 kDebug() << "// PARSING FIOLER: " << folder;
408 QDir pluginsDir(folder);
409 foreach(QString fileName, pluginsDir.entryList(filters, QDir::Files)) {
410 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
411 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
412 QObject *plugin = loader.instance();
414 populateMenus(plugin);
415 m_pluginFileNames += fileName;
416 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
422 void MainWindow::populateMenus(QObject *plugin) {
423 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
424 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
426 addToMenu(plugin, iGenerator->generators(), addMenu, SLOT(generateClip()),
430 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
431 QMenu *menu, const char *member,
432 QActionGroup *actionGroup) {
433 kDebug() << "// ADD to MENU" << texts;
434 foreach(QString text, texts) {
435 QAction *action = new QAction(text, plugin);
436 action->setData(text);
437 connect(action, SIGNAL(triggered()), this, member);
438 menu->addAction(action);
441 action->setCheckable(true);
442 actionGroup->addAction(action);
447 void MainWindow::aboutPlugins() {
448 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
453 void MainWindow::generateClip() {
454 QAction *action = qobject_cast<QAction *>(sender());
455 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
457 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
458 if (!clipUrl.isEmpty()) {
459 m_projectList->slotAddClip(clipUrl);
463 void MainWindow::saveProperties(KConfig*) {
464 // save properties here,used by session management
469 void MainWindow::readProperties(KConfig *config) {
470 // read properties here,used by session management
471 QString Lastproject = config->group("Recent Files").readPathEntry("File1", QString());
472 openFile(KUrl(Lastproject));
475 void MainWindow::slotReloadEffects() {
476 initEffects::parseCustomEffectsFile();
477 m_customEffectsMenu->clear();
478 const QStringList effects = customEffects.effectNames();
480 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
481 else m_customEffectsMenu->setEnabled(true);
483 foreach(const QString &name, effects) {
484 action = new QAction(name, this);
485 action->setData(name);
486 m_customEffectsMenu->addAction(action);
488 m_effectList->reloadEffectList();
491 #ifndef NO_JOGSHUTTLE
492 void MainWindow::activateShuttleDevice() {
493 if (m_jogProcess) delete m_jogProcess;
495 if (KdenliveSettings::enableshuttle() == false) return;
496 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
497 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
498 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
499 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
500 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
501 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
502 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
505 void MainWindow::slotShuttleButton(int code) {
508 slotShuttleAction(KdenliveSettings::shuttle1());
511 slotShuttleAction(KdenliveSettings::shuttle2());
514 slotShuttleAction(KdenliveSettings::shuttle3());
517 slotShuttleAction(KdenliveSettings::shuttle4());
520 slotShuttleAction(KdenliveSettings::shuttle5());
525 void MainWindow::slotShuttleAction(int code) {
530 m_monitorManager->slotPlay();
533 m_monitorManager->slotPlay();
537 #endif /* NO_JOGSHUTTLE */
539 void MainWindow::configureNotifications() {
540 KNotifyConfigWidget::configure(this);
543 void MainWindow::slotFullScreen() {
544 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
547 void MainWindow::slotAddEffect(QDomElement effect, GenTime pos, int track) {
548 if (!m_activeDocument) return;
549 if (effect.isNull()) {
550 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
553 TrackView *currentTimeLine = (TrackView *) m_timelineArea->currentWidget();
554 currentTimeLine->projectView()->slotAddEffect(effect.cloneNode().toElement(), pos, track);
557 void MainWindow::slotRaiseMonitor(bool clipMonitor) {
558 if (clipMonitor) clipMonitorDock->raise();
559 else projectMonitorDock->raise();
562 void MainWindow::slotSetClipDuration(const QString &id, int duration) {
563 if (!m_activeDocument) return;
564 m_activeDocument->setProducerDuration(id, duration);
567 void MainWindow::slotConnectMonitors() {
569 m_projectList->setRenderer(m_projectMonitor->render);
570 connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
571 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
572 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
573 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const QString &, int, const QPixmap &, int, int)));
574 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 > &)));
576 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
578 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
580 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
581 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
583 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
584 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
587 void MainWindow::slotAdjustClipMonitor() {
588 clipMonitorDock->updateGeometry();
589 clipMonitorDock->adjustSize();
590 m_clipMonitor->resetSize();
593 void MainWindow::slotAdjustProjectMonitor() {
594 projectMonitorDock->updateGeometry();
595 projectMonitorDock->adjustSize();
596 m_projectMonitor->resetSize();
599 void MainWindow::setupActions() {
601 KActionCollection* collection = actionCollection();
602 m_timecodeFormat = new KComboBox(this);
603 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
604 m_timecodeFormat->addItem(i18n("Frames"));
606 statusProgressBar = new QProgressBar(this);
607 statusProgressBar->setMinimum(0);
608 statusProgressBar->setMaximum(100);
609 statusProgressBar->setMaximumWidth(150);
610 statusProgressBar->setVisible(false);
612 QWidget *w = new QWidget;
614 QHBoxLayout *layout = new QHBoxLayout;
615 w->setLayout(layout);
616 layout->setContentsMargins(5, 0, 5, 0);
617 QToolBar *toolbar = new QToolBar("statusToolBar", this);
620 m_toolGroup = new QActionGroup(this);
622 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;}";
624 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
625 toolbar->addAction(m_buttonSelectTool);
626 m_buttonSelectTool->setCheckable(true);
627 m_buttonSelectTool->setChecked(true);
629 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
630 toolbar->addAction(m_buttonRazorTool);
631 m_buttonRazorTool->setCheckable(true);
632 m_buttonRazorTool->setChecked(false);
634 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
635 toolbar->addAction(m_buttonSpacerTool);
636 m_buttonSpacerTool->setCheckable(true);
637 m_buttonSpacerTool->setChecked(false);
639 m_toolGroup->addAction(m_buttonSelectTool);
640 m_toolGroup->addAction(m_buttonRazorTool);
641 m_toolGroup->addAction(m_buttonSpacerTool);
642 m_toolGroup->setExclusive(true);
643 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
645 QWidget * actionWidget;
646 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
647 actionWidget->setMaximumWidth(24);
648 actionWidget->setMinimumHeight(17);
650 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
651 actionWidget->setMaximumWidth(24);
652 actionWidget->setMinimumHeight(17);
654 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
655 actionWidget->setMaximumWidth(24);
656 actionWidget->setMinimumHeight(17);
658 toolbar->setStyleSheet(style1);
659 connect(m_toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
661 toolbar->addSeparator();
662 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
663 toolbar->addAction(m_buttonFitZoom);
664 m_buttonFitZoom->setCheckable(false);
665 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
667 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
668 actionWidget->setMaximumWidth(24);
669 actionWidget->setMinimumHeight(17);
671 m_zoomSlider = new QSlider(Qt::Horizontal, this);
672 m_zoomSlider->setMaximum(13);
673 m_zoomSlider->setPageStep(1);
675 m_zoomSlider->setMaximumWidth(150);
676 m_zoomSlider->setMinimumWidth(100);
678 const int contentHeight = QFontMetrics(w->font()).height() + 8;
680 QString style = "QSlider::groove:horizontal { background-color: rgba(230, 230, 230, 220);border: 1px solid #999999;height: 8px;border-radius: 3px;margin-top:3px }";
681 style.append("QSlider::handle:horizontal { background-color: white; border: 1px solid #999999;width: 9px;margin: -2px 0;border-radius: 3px; }");
683 m_zoomSlider->setStyleSheet(style);
685 //m_zoomSlider->height() + 5;
686 statusBar()->setMinimumHeight(contentHeight);
689 toolbar->addWidget(m_zoomSlider);
691 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
692 toolbar->addAction(m_buttonVideoThumbs);
693 m_buttonVideoThumbs->setCheckable(true);
694 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
695 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
697 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
698 toolbar->addAction(m_buttonAudioThumbs);
699 m_buttonAudioThumbs->setCheckable(true);
700 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
701 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
703 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
704 toolbar->addAction(m_buttonShowMarkers);
705 m_buttonShowMarkers->setCheckable(true);
706 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
707 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
709 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
710 toolbar->addAction(m_buttonSnap);
711 m_buttonSnap->setCheckable(true);
712 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
713 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
714 layout->addWidget(toolbar);
717 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
718 actionWidget->setMaximumWidth(24);
719 actionWidget->setMinimumHeight(17);
721 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
722 actionWidget->setMaximumWidth(24);
723 actionWidget->setMinimumHeight(17);
725 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
726 actionWidget->setMaximumWidth(24);
727 actionWidget->setMinimumHeight(17);
729 actionWidget = toolbar->widgetForAction(m_buttonSnap);
730 actionWidget->setMaximumWidth(24);
731 actionWidget->setMinimumHeight(17);
733 m_messageLabel = new StatusBarMessageLabel(this);
734 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
736 statusBar()->addWidget(m_messageLabel, 10);
737 statusBar()->addWidget(statusProgressBar, 0);
738 statusBar()->insertPermanentWidget(ID_TIMELINE_BUTTONS, w);
739 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
740 statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
741 statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4);
742 m_messageLabel->hide();
744 collection->addAction("select_tool", m_buttonSelectTool);
745 collection->addAction("razor_tool", m_buttonRazorTool);
746 collection->addAction("spacer_tool", m_buttonSpacerTool);
748 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
749 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
750 collection->addAction("show_markers", m_buttonShowMarkers);
751 collection->addAction("snap", m_buttonSnap);
752 collection->addAction("zoom_fit", m_buttonFitZoom);
754 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
755 collection->addAction("zoom_in", zoomIn);
756 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
757 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
759 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
760 collection->addAction("zoom_out", zoomOut);
761 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
762 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
764 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
765 collection->addAction("project_find", m_projectSearch);
766 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
767 m_projectSearch->setShortcut(Qt::Key_Slash);
769 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
770 collection->addAction("project_find_next", m_projectSearchNext);
771 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
772 m_projectSearchNext->setShortcut(Qt::Key_F3);
773 m_projectSearchNext->setEnabled(false);
775 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Profiles"), this);
776 collection->addAction("manage_profiles", profilesAction);
777 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
779 KAction* fileGHNS = KNS::standardAction(i18n("Download New Lumas..."), this, SLOT(slotGetNewStuff()), actionCollection(), "get_new_stuff");
781 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
782 collection->addAction("run_wizard", wizAction);
783 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
785 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
786 collection->addAction("project_settings", projectAction);
787 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
789 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
790 collection->addAction("project_render", projectRender);
791 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
792 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
794 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
795 KShortcut playShortcut;
796 playShortcut.setPrimary(Qt::Key_Space);
797 playShortcut.setAlternate(Qt::Key_K);
798 monitorPlay->setShortcut(playShortcut);
799 collection->addAction("monitor_play", monitorPlay);
800 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
802 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
803 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
804 collection->addAction("monitor_play_zone", m_playZone);
805 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
807 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
808 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
809 collection->addAction("monitor_loop_zone", m_loopZone);
810 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
812 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("Dvd Wizard"), this);
813 collection->addAction("dvd_wizard", dvdWizard);
814 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
816 KAction *markIn = collection->addAction("mark_in");
817 markIn->setText(i18n("Set In Point"));
818 markIn->setShortcut(Qt::Key_I);
819 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
821 KAction *markOut = collection->addAction("mark_out");
822 markOut->setText(i18n("Set Out Point"));
823 markOut->setShortcut(Qt::Key_O);
824 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
826 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
827 monitorSeekBackward->setShortcut(Qt::Key_J);
828 collection->addAction("monitor_seek_backward", monitorSeekBackward);
829 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
831 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
832 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
833 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
834 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
836 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
837 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
838 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
839 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
841 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
842 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
843 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
844 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
846 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
847 monitorSeekForward->setShortcut(Qt::Key_L);
848 collection->addAction("monitor_seek_forward", monitorSeekForward);
849 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
851 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
852 clipStart->setShortcut(Qt::Key_Home);
853 collection->addAction("seek_clip_start", clipStart);
854 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
856 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
857 clipEnd->setShortcut(Qt::Key_End);
858 collection->addAction("seek_clip_end", clipEnd);
859 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
861 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
862 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
863 collection->addAction("seek_start", projectStart);
864 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
866 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
867 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
868 collection->addAction("seek_end", projectEnd);
869 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
871 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
872 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
873 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
874 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
876 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
877 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
878 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
879 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
881 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
882 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
883 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
884 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
886 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
887 deleteTimelineClip->setShortcut(Qt::Key_Delete);
888 collection->addAction("delete_timeline_clip", deleteTimelineClip);
889 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
891 KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
892 collection->addAction("change_clip_speed", editTimelineClipSpeed);
893 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));
895 KAction *stickTransition = collection->addAction("auto_transition");
896 stickTransition->setData(QString("auto"));
897 stickTransition->setCheckable(true);
898 stickTransition->setEnabled(false);
899 stickTransition->setText(i18n("Automatic Transition"));
900 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
902 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
903 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
904 collection->addAction("cut_timeline_clip", cutTimelineClip);
905 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
907 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
908 collection->addAction("add_clip_marker", addClipMarker);
909 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
911 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
912 collection->addAction("delete_clip_marker", deleteClipMarker);
913 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
915 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
916 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
917 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
919 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
920 collection->addAction("edit_clip_marker", editClipMarker);
921 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
923 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
924 collection->addAction("insert_space", insertSpace);
925 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
927 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
928 collection->addAction("delete_space", removeSpace);
929 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
931 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
932 collection->addAction("insert_track", insertTrack);
933 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
935 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
936 collection->addAction("delete_track", deleteTrack);
937 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
939 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
940 collection->addAction("change_track", changeTrack);
941 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
943 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
944 collection->addAction("add_guide", addGuide);
945 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
947 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
948 collection->addAction("delete_guide", delGuide);
949 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
951 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
952 collection->addAction("edit_guide", editGuide);
953 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
955 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
956 collection->addAction("delete_all_guides", delAllGuides);
957 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
959 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
960 collection->addAction("paste_effects", pasteEffects);
961 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
963 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
965 KStandardAction::quit(this, SLOT(queryQuit()), collection);
967 KStandardAction::open(this, SLOT(openFile()), collection);
969 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
971 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
973 KStandardAction::openNew(this, SLOT(newFile()), collection);
975 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
977 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
979 KStandardAction::copy(this, SLOT(slotCopy()), collection);
981 KStandardAction::paste(this, SLOT(slotPaste()), collection);
983 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
984 undo->setEnabled(false);
985 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
987 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
988 redo->setEnabled(false);
989 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
991 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
993 connect(collection, SIGNAL(actionHovered(QAction*)),
994 this, SLOT(slotDisplayActionMessage(QAction*)));
997 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
998 collection->addAction("add_clip", addClip);
999 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1001 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1002 collection->addAction("add_color_clip", addColorClip);
1003 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1005 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1006 collection->addAction("add_slide_clip", addSlideClip);
1007 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1009 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1010 collection->addAction("add_text_clip", addTitleClip);
1011 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1013 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1014 collection->addAction("add_folder", addFolderButton);
1015 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1017 QMenu *addClips = new QMenu();
1018 addClips->addAction(addClip);
1019 addClips->addAction(addColorClip);
1020 addClips->addAction(addSlideClip);
1021 addClips->addAction(addTitleClip);
1022 addClips->addAction(addFolderButton);
1023 m_projectList->setupMenu(addClips, addClip);
1025 //connect(collection, SIGNAL( clearStatusText() ),
1026 //statusBar(), SLOT( clear() ) );
1029 void MainWindow::slotDisplayActionMessage(QAction *a) {
1030 statusBar()->showMessage(a->data().toString(), 3000);
1033 void MainWindow::saveOptions() {
1034 KdenliveSettings::self()->writeConfig();
1035 KSharedConfigPtr config = KGlobal::config();
1036 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1037 KConfigGroup treecolumns(config, "Project Tree");
1038 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1042 void MainWindow::readOptions() {
1043 KSharedConfigPtr config = KGlobal::config();
1044 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1045 KConfigGroup initialGroup(config, "version");
1046 if (!initialGroup.exists()) {
1047 // this is our first run, show Wizard
1048 Wizard *w = new Wizard(this);
1049 if (w->exec() == QDialog::Accepted && w->isOk()) {
1050 w->adjustSettings();
1051 initialGroup.writeEntry("version", "0.7");
1056 } else if (initialGroup.readEntry("version") == "0.7") {
1057 //Add new settings from 0.7.1
1058 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1059 QString path = QDir::homePath() + "/kdenlive";
1060 if (KStandardDirs::makeDir(path) == false) kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1061 KdenliveSettings::setDefaultprojectfolder(path);
1064 KConfigGroup treecolumns(config, "Project Tree");
1065 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1066 if (!state.isEmpty())
1067 m_projectList->setHeaderInfo(state);
1070 void MainWindow::slotRunWizard() {
1071 Wizard *w = new Wizard(this);
1072 if (w->exec() == QDialog::Accepted && w->isOk()) {
1073 w->adjustSettings();
1078 void MainWindow::newFile(bool showProjectSettings) {
1079 QString profileName;
1081 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1082 if (!showProjectSettings && m_timelineArea->count() == 0) {
1083 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1084 profileName = KdenliveSettings::default_profile();
1086 ProjectSettings *w = new ProjectSettings(projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, this);
1087 if (w->exec() != QDialog::Accepted) return;
1088 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1089 profileName = w->selectedProfile();
1090 projectFolder = w->selectedFolder();
1091 projectTracks = w->tracks();
1094 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1095 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1096 TrackView *trackView = new TrackView(doc, this);
1097 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1098 if (m_timelineArea->count() == 1) {
1099 connectDocumentInfo(doc);
1100 connectDocument(trackView, doc);
1101 } else m_timelineArea->setTabBarHidden(false);
1102 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1105 void MainWindow::activateDocument() {
1106 if (m_timelineArea->currentWidget() == NULL) return;
1107 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1108 KdenliveDoc *currentDoc = currentTab->document();
1109 connectDocumentInfo(currentDoc);
1110 connectDocument(currentTab, currentDoc);
1113 void MainWindow::closeCurrentDocument() {
1114 QWidget *w = m_timelineArea->currentWidget();
1116 // closing current document
1117 int ix = m_timelineArea->currentIndex() + 1;
1118 if (ix == m_timelineArea->count()) ix = 0;
1119 m_timelineArea->setCurrentIndex(ix);
1120 TrackView *tabToClose = (TrackView *) w;
1121 KdenliveDoc *docToClose = tabToClose->document();
1122 if (docToClose && docToClose->isModified()) {
1123 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document ?"))) {
1124 case KMessageBox::Yes :
1125 // save document here. If saving fails, return false;
1128 case KMessageBox::Cancel :
1134 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1135 if (m_timelineArea->count() == 1) {
1136 m_timelineArea->setTabBarHidden(true);
1137 m_closeAction->setEnabled(false);
1141 if (m_timelineArea->count() == 0) {
1142 m_activeDocument = NULL;
1143 effectStack->clear();
1144 transitionConfig->slotTransitionItemSelected(NULL, false);
1148 bool MainWindow::saveFileAs(const QString &outputFileName) {
1149 QDomDocument currentSceneList;
1150 if (KdenliveSettings::dropbframes()) {
1151 KdenliveSettings::setDropbframes(false);
1152 m_activeDocument->clipManager()->updatePreviewSettings();
1153 currentSceneList = m_projectMonitor->sceneList();
1154 KdenliveSettings::setDropbframes(true);
1155 m_activeDocument->clipManager()->updatePreviewSettings();
1156 } else currentSceneList = m_projectMonitor->sceneList();
1158 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1161 // Save timeline thumbnails
1162 m_activeTimeline->projectView()->saveThumbnails();
1163 m_activeDocument->setUrl(KUrl(outputFileName));
1164 if (m_activeDocument->m_autosave == NULL) {
1165 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1166 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1167 setCaption(m_activeDocument->description());
1168 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1169 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1170 m_activeDocument->setModified(false);
1171 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1175 bool MainWindow::saveFileAs() {
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 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1182 if (outputFile.isEmpty()) return false;
1183 if (QFile::exists(outputFile)) {
1184 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) == KMessageBox::No) return false;
1186 return saveFileAs(outputFile);
1189 bool MainWindow::saveFile() {
1190 if (!m_activeDocument) return true;
1191 if (m_activeDocument->url().isEmpty()) {
1192 return saveFileAs();
1194 bool result = saveFileAs(m_activeDocument->url().path());
1195 m_activeDocument->m_autosave->resize(0);
1200 void MainWindow::openFile() {
1201 // Check that the Kdenlive mime type is correctly installed
1202 QString mimetype = "application/x-kdenlive";
1203 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1204 if (!mime) mimetype = "*.kdenlive";
1206 KUrl url = KFileDialog::getOpenUrl(KUrl(), mimetype);
1207 if (url.isEmpty()) return;
1208 m_fileOpenRecent->addUrl(url);
1212 void MainWindow::openLastFile() {
1213 KSharedConfigPtr config = KGlobal::config();
1214 KUrl::List urls = m_fileOpenRecent->urls();
1215 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction ?
1216 if (urls.isEmpty()) newFile(false);
1217 else openFile(urls.last());
1220 void MainWindow::openFile(const KUrl &url) {
1221 // Check if the document is already opened
1222 const int ct = m_timelineArea->count();
1223 bool isOpened = false;
1225 for (i = 0; i < ct; i++) {
1226 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1227 KdenliveDoc *doc = tab->document();
1228 if (doc->url() == url) {
1234 m_timelineArea->setCurrentIndex(i);
1238 // Check for backup file
1239 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1240 if (!staleFiles.isEmpty()) {
1241 if (KMessageBox::questionYesNo(this,
1242 i18n("Auto-saved files exist. Do you want to recover them now?"),
1243 i18n("File Recovery"),
1244 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1245 recoverFiles(staleFiles);
1248 // remove the stale files
1249 foreach(KAutoSaveFile *stale, staleFiles) {
1250 stale->open(QIODevice::ReadWrite);
1255 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1256 doOpenFile(url, NULL);
1259 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale) {
1260 KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), m_commandStack, QString(), QPoint(3, 2), m_projectMonitor->render, this);
1261 if (stale == NULL) {
1262 stale = new KAutoSaveFile(url, doc);
1263 doc->m_autosave = stale;
1265 doc->m_autosave = stale;
1266 doc->setUrl(stale->managedFile());
1267 doc->setModified(true);
1268 stale->setParent(doc);
1270 connectDocumentInfo(doc);
1271 TrackView *trackView = new TrackView(doc, this);
1272 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1273 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1274 trackView->setDuration(trackView->duration());
1275 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1277 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1278 slotGotProgressInfo(QString(), -1);
1279 m_clipMonitor->refreshMonitor(true);
1280 m_projectMonitor->adjustRulerSize(trackView->duration());
1281 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1284 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles) {
1285 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1286 foreach(KAutoSaveFile *stale, staleFiles) {
1287 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1288 // show an error message; we could not steal the lockfile
1289 // maybe another application got to the file before us?
1293 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1294 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile ?
1295 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1296 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1301 void MainWindow::parseProfiles(const QString &mltPath) {
1302 //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1304 //KdenliveSettings::setDefaulttmpfolder();
1305 if (!mltPath.isEmpty()) {
1306 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1307 KdenliveSettings::setRendererpath(mltPath + "/bin/inigo");
1310 if (KdenliveSettings::mltpath().isEmpty()) {
1311 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1313 if (KdenliveSettings::rendererpath().isEmpty()) {
1314 QString inigoPath = QString(MLT_PREFIX) + QString("/bin/inigo");
1315 if (!QFile::exists(inigoPath))
1316 inigoPath = KStandardDirs::findExe("inigo");
1317 else KdenliveSettings::setRendererpath(inigoPath);
1319 QStringList profilesFilter;
1320 profilesFilter << "*";
1321 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1323 if (profilesList.isEmpty()) {
1324 // Cannot find MLT path, try finding inigo
1325 QString profilePath = KdenliveSettings::rendererpath();
1326 if (!profilePath.isEmpty()) {
1327 profilePath = profilePath.section('/', 0, -3);
1328 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1329 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1332 if (profilesList.isEmpty()) {
1333 // Cannot find the MLT profiles, ask for location
1334 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1335 getUrl->fileDialog()->setMode(KFile::Directory);
1336 if (getUrl->exec() == QDialog::Rejected) {
1339 KUrl mltPath = getUrl->selectedUrl();
1341 if (mltPath.isEmpty()) ::exit(0);
1342 KdenliveSettings::setMltpath(mltPath.path());
1343 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1347 if (KdenliveSettings::rendererpath().isEmpty()) {
1348 // Cannot find the MLT inigo renderer, ask for location
1349 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the inigo program required for rendering (part of Mlt)"), this);
1350 if (getUrl->exec() == QDialog::Rejected) {
1353 KUrl rendererPath = getUrl->selectedUrl();
1355 if (rendererPath.isEmpty()) ::exit(0);
1356 KdenliveSettings::setRendererpath(rendererPath.path());
1359 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1361 // Parse MLT profiles to build a list of available video formats
1362 if (profilesList.isEmpty()) parseProfiles();
1366 void MainWindow::slotEditProfiles() {
1367 ProfilesDialog *w = new ProfilesDialog;
1372 void MainWindow::slotEditProjectSettings() {
1373 QPoint p = m_activeDocument->getTracksCount();
1374 ProjectSettings *w = new ProjectSettings(p.x(), p.y(), m_activeDocument->projectFolder().path(), true, this);
1376 if (w->exec() == QDialog::Accepted) {
1377 QString profile = w->selectedProfile();
1378 m_activeDocument->setProjectFolder(w->selectedFolder());
1379 if (m_activeDocument->profilePath() != profile) {
1380 // Profile was changed
1381 m_activeDocument->setProfilePath(profile);
1382 KdenliveSettings::setCurrent_profile(profile);
1383 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1384 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1385 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1386 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1387 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1388 m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1390 // We need to desactivate & reactivate monitors to get a refresh
1391 m_monitorManager->switchMonitors();
1397 void MainWindow::slotRenderProject() {
1398 if (!m_renderWidget) {
1399 m_renderWidget = new RenderWidget(this);
1400 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)));
1401 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1402 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1403 if (m_activeDocument) {
1404 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1405 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1408 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1409 if (currentTab) m_renderWidget->setTimeline(currentTab);
1410 m_renderWidget->setDocument(m_activeDocument);*/
1411 m_renderWidget->show();
1414 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) {
1415 if (dest.isEmpty()) return;
1418 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1419 if (currentTab && zoneOnly) {
1420 in = currentTab->inPoint();
1421 out = currentTab->outPoint();
1423 KTemporaryFile temp;
1424 temp.setAutoRemove(false);
1425 temp.setSuffix(".westley");
1428 if (KdenliveSettings::dropbframes()) {
1429 KdenliveSettings::setDropbframes(false);
1430 m_activeDocument->clipManager()->updatePreviewSettings();
1431 m_projectMonitor->saveSceneList(temp.fileName());
1432 KdenliveSettings::setDropbframes(true);
1433 m_activeDocument->clipManager()->updatePreviewSettings();
1434 } else m_projectMonitor->saveSceneList(temp.fileName());
1438 if (zoneOnly) args << "in=" + QString::number(in) << "out=" + QString::number(out);
1439 else if (guideStart != -1) {
1440 args << "in=" + QString::number(GenTime(guideStart).frames(m_activeDocument->fps())) << "out=" + QString::number(GenTime(guideEnd).frames(m_activeDocument->fps()));
1442 if (!overlay_args.isEmpty()) args << "preargs=" + overlay_args.join(" ");
1443 QString videoPlayer = "-";
1445 videoPlayer = KdenliveSettings::defaultplayerapp();
1446 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."));
1448 if (!QFile::exists(KdenliveSettings::rendererpath())) {
1449 KMessageBox::sorry(this, i18n("Cannot find the inigo program required for rendering (part of Mlt)"));
1450 setRenderingProgress(dest, -3);
1453 args << KdenliveSettings::rendererpath() << m_activeDocument->profilePath() << render << videoPlayer;
1455 for (int i = 0; i < avformat_args.count(); i++) {
1456 if (avformat_args.at(i).startsWith("profile=")) {
1457 if (avformat_args.at(i).section('=', 1) != m_activeDocument->profilePath()) resizeProfile = true;
1462 if (resizeProfile) {
1463 // The rendering profile is different from project profile, so use MLT's special producer_consumer
1464 args << "consumer:" + temp.fileName();
1465 } else args << temp.fileName();
1466 args << dest << avformat_args;
1467 QString renderer = QCoreApplication::applicationDirPath() + QString("/kdenlive_render");
1468 if (!QFile::exists(renderer)) renderer = "kdenlive_render";
1469 QProcess::startDetached(renderer, args);
1471 KNotification::event("RenderStarted", i18n("Rendering <i>%1</i> started", dest), QPixmap(), this);
1475 void MainWindow::setRenderingProgress(const QString &url, int progress) {
1476 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1479 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error) {
1480 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1483 void MainWindow::slotUpdateMousePosition(int pos) {
1484 if (m_activeDocument)
1485 switch (m_timecodeFormat->currentIndex()) {
1487 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1490 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1494 void MainWindow::slotUpdateDocumentState(bool modified) {
1495 if (!m_activeDocument) return;
1496 setCaption(m_activeDocument->description(), modified);
1497 m_saveAction->setEnabled(modified);
1499 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1500 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1502 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1503 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1507 void MainWindow::connectDocumentInfo(KdenliveDoc *doc) {
1508 if (m_activeDocument) {
1509 if (m_activeDocument == doc) return;
1510 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1512 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1515 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed
1516 //m_projectMonitor->stop();
1517 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1518 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1519 if (m_activeDocument) {
1520 if (m_activeDocument == doc) return;
1521 m_activeDocument->backupMltPlaylist();
1522 if (m_activeTimeline) {
1523 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1524 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1525 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1526 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1529 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1530 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1531 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1532 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1533 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1534 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1535 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1536 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1537 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1538 disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1539 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1540 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1541 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1542 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1543 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1544 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1545 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1546 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1547 disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1548 disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1549 disconnect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1550 disconnect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1551 disconnect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1552 disconnect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1553 disconnect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1554 disconnect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), m_activeTimeline->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1555 disconnect(transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1556 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1557 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1558 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1559 effectStack->clear();
1561 //m_activeDocument->setRenderer(NULL);
1562 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1563 m_clipMonitor->stop();
1565 KdenliveSettings::setCurrent_profile(doc->profilePath());
1566 KdenliveSettings::setProject_fps(doc->fps());
1567 m_monitorManager->resetProfiles(doc->timecode());
1568 m_projectList->setDocument(doc);
1569 transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), trackView->tracksNumber());
1570 effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1571 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1572 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1573 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1576 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1577 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1578 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1579 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1580 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1581 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1582 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1583 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1584 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1585 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1586 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1587 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1589 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1590 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1591 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1594 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1595 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1596 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*, bool)));
1597 connect(trackView, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1598 m_zoomSlider->setValue(doc->zoom());
1599 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1600 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1601 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1602 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1604 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1607 connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1608 connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1609 connect(effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1610 connect(effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1611 connect(effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1612 connect(transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1613 connect(transitionConfig, SIGNAL(transitionTrackUpdated(Transition *, int)), trackView->projectView() , SLOT(slotTransitionTrackUpdated(Transition *, int)));
1614 connect(transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
1615 connect(effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1617 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1618 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1619 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
1621 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu);
1622 m_activeTimeline = trackView;
1623 if (m_renderWidget) m_renderWidget->setProfile(doc->mltProfile());
1624 //doc->setRenderer(m_projectMonitor->render);
1625 m_commandStack->setActiveStack(doc->commandStack());
1626 KdenliveSettings::setProject_display_ratio(doc->dar());
1627 m_projectList->updateAllClips();
1628 //doc->clipManager()->checkAudioThumbs();
1630 //m_overView->setScene(trackView->projectScene());
1631 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
1632 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
1634 setCaption(doc->description(), doc->isModified());
1635 m_saveAction->setEnabled(doc->isModified());
1636 m_activeDocument = doc;
1637 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
1639 // set tool to select tool
1640 m_buttonSelectTool->setChecked(true);
1643 void MainWindow::slotZoneMoved(int start, int end) {
1644 m_activeDocument->setZone(start, end);
1645 m_projectMonitor->slotZoneMoved(start, end);
1648 void MainWindow::slotGuidesUpdated() {
1649 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1652 void MainWindow::slotPreferences(int page, int option) {
1653 //An instance of your dialog could be already created and could be
1654 // cached, in which case you want to display the cached dialog
1655 // instead of creating another one
1656 if (KConfigDialog::showDialog("settings")) {
1657 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1658 if (page != -1) d->showPage(page, option);
1663 // KConfigDialog didn't find an instance of this dialog, so lets
1665 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
1666 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
1667 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
1668 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1669 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
1671 if (page != -1) dialog->showPage(page, option);
1674 void MainWindow::slotUpdatePreviewSettings() {
1675 if (m_activeDocument) {
1676 m_clipMonitor->slotSetXml(NULL, 0);
1677 m_activeDocument->updatePreviewSettings();
1681 void MainWindow::updateConfiguration() {
1682 //TODO: we should apply settings to all projects, not only the current one
1683 if (m_activeTimeline) {
1684 m_activeTimeline->refresh();
1685 m_activeTimeline->projectView()->checkAutoScroll();
1686 m_activeTimeline->projectView()->checkTrackHeight();
1687 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1689 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1690 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1691 #ifndef NO_JOGSHUTTLE
1692 activateShuttleDevice();
1693 #endif /* NO_JOGSHUTTLE */
1698 void MainWindow::slotSwitchVideoThumbs() {
1699 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
1700 if (m_activeTimeline) {
1701 m_activeTimeline->refresh();
1703 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1706 void MainWindow::slotSwitchAudioThumbs() {
1707 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
1708 if (m_activeTimeline) {
1709 m_activeTimeline->refresh();
1710 m_activeTimeline->projectView()->checkAutoScroll();
1711 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
1713 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1716 void MainWindow::slotSwitchMarkersComments() {
1717 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
1718 if (m_activeTimeline) {
1719 m_activeTimeline->refresh();
1721 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1724 void MainWindow::slotSwitchSnap() {
1725 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
1726 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1730 void MainWindow::slotDeleteTimelineClip() {
1731 if (QApplication::focusWidget()->parentWidget()->parentWidget() == projectListDock) m_projectList->slotRemoveClip();
1732 else if (m_activeTimeline) {
1733 m_activeTimeline->projectView()->deleteSelectedClips();
1737 void MainWindow::slotChangeClipSpeed() {
1738 if (m_activeTimeline) {
1739 m_activeTimeline->projectView()->changeClipSpeed();
1743 void MainWindow::slotAddClipMarker() {
1744 DocClipBase *clip = NULL;
1746 if (m_projectMonitor->isActive()) {
1747 if (m_activeTimeline) {
1748 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1750 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1751 clip = item->baseClip();
1755 clip = m_clipMonitor->activeClip();
1756 pos = m_clipMonitor->position();
1759 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
1762 QString id = clip->getId();
1763 CommentedTime marker(pos, i18n("Marker"));
1764 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
1765 if (d.exec() == QDialog::Accepted) {
1766 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1768 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1771 void MainWindow::slotDeleteClipMarker() {
1772 DocClipBase *clip = NULL;
1774 if (m_projectMonitor->isActive()) {
1775 if (m_activeTimeline) {
1776 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1778 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1779 clip = item->baseClip();
1783 clip = m_clipMonitor->activeClip();
1784 pos = m_clipMonitor->position();
1787 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1791 QString id = clip->getId();
1792 QString comment = clip->markerComment(pos);
1793 if (comment.isEmpty()) {
1794 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1797 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
1798 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1802 void MainWindow::slotDeleteAllClipMarkers() {
1803 DocClipBase *clip = NULL;
1804 if (m_projectMonitor->isActive()) {
1805 if (m_activeTimeline) {
1806 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1808 clip = item->baseClip();
1812 clip = m_clipMonitor->activeClip();
1815 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1818 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
1819 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1822 void MainWindow::slotEditClipMarker() {
1823 DocClipBase *clip = NULL;
1825 if (m_projectMonitor->isActive()) {
1826 if (m_activeTimeline) {
1827 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
1829 pos = m_projectMonitor->position() - item->startPos() + item->cropStart();
1830 clip = item->baseClip();
1834 clip = m_clipMonitor->activeClip();
1835 pos = m_clipMonitor->position();
1838 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
1842 QString id = clip->getId();
1843 QString oldcomment = clip->markerComment(pos);
1844 if (oldcomment.isEmpty()) {
1845 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
1849 CommentedTime marker(pos, oldcomment);
1850 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
1851 if (d.exec() == QDialog::Accepted) {
1852 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
1853 if (d.newMarker().time() != pos) {
1854 // remove old marker
1855 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
1857 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
1861 void MainWindow::slotAddGuide() {
1862 if (m_activeTimeline)
1863 m_activeTimeline->projectView()->slotAddGuide();
1866 void MainWindow::slotInsertSpace() {
1867 if (m_activeTimeline)
1868 m_activeTimeline->projectView()->slotInsertSpace();
1871 void MainWindow::slotRemoveSpace() {
1872 if (m_activeTimeline)
1873 m_activeTimeline->projectView()->slotRemoveSpace();
1876 void MainWindow::slotInsertTrack(int ix) {
1877 m_projectMonitor->activateMonitor();
1878 if (m_activeTimeline)
1879 m_activeTimeline->projectView()->slotInsertTrack(ix);
1882 void MainWindow::slotDeleteTrack(int ix) {
1883 m_projectMonitor->activateMonitor();
1884 if (m_activeTimeline)
1885 m_activeTimeline->projectView()->slotDeleteTrack(ix);
1888 void MainWindow::slotChangeTrack(int ix) {
1889 m_projectMonitor->activateMonitor();
1890 if (m_activeTimeline)
1891 m_activeTimeline->projectView()->slotChangeTrack(ix);
1894 void MainWindow::slotEditGuide() {
1895 if (m_activeTimeline)
1896 m_activeTimeline->projectView()->slotEditGuide();
1899 void MainWindow::slotDeleteGuide() {
1900 if (m_activeTimeline)
1901 m_activeTimeline->projectView()->slotDeleteGuide();
1904 void MainWindow::slotDeleteAllGuides() {
1905 if (m_activeTimeline)
1906 m_activeTimeline->projectView()->slotDeleteAllGuides();
1909 void MainWindow::slotCutTimelineClip() {
1910 if (m_activeTimeline) {
1911 m_activeTimeline->projectView()->cutSelectedClips();
1915 void MainWindow::slotAddProjectClip(KUrl url) {
1916 if (m_activeDocument)
1917 m_activeDocument->slotAddClipFile(url, QString());
1920 void MainWindow::slotAddTransition(QAction *result) {
1921 if (!result) return;
1922 QStringList info = result->data().toStringList();
1923 if (info.isEmpty()) return;
1924 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
1925 if (m_activeTimeline && !transition.isNull()) {
1926 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
1930 void MainWindow::slotAddVideoEffect(QAction *result) {
1931 if (!result) return;
1932 QStringList info = result->data().toStringList();
1933 if (info.isEmpty()) return;
1934 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
1935 slotAddEffect(effect);
1938 void MainWindow::slotAddAudioEffect(QAction *result) {
1939 if (!result) return;
1940 QStringList info = result->data().toStringList();
1941 if (info.isEmpty()) return;
1942 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
1943 slotAddEffect(effect);
1946 void MainWindow::slotAddCustomEffect(QAction *result) {
1947 if (!result) return;
1948 QStringList info = result->data().toStringList();
1949 if (info.isEmpty()) return;
1950 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
1951 slotAddEffect(effect);
1954 void MainWindow::slotZoomIn() {
1955 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
1958 void MainWindow::slotZoomOut() {
1959 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
1962 void MainWindow::slotFitZoom() {
1963 if (m_activeTimeline) {
1964 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
1968 void MainWindow::slotGotProgressInfo(const QString &message, int progress) {
1969 statusProgressBar->setValue(progress);
1970 if (progress >= 0) {
1971 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
1972 statusProgressBar->setVisible(true);
1974 m_messageLabel->setMessage(QString(), DefaultMessage);
1975 statusProgressBar->setVisible(false);
1979 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
1980 if (clip->clipType() == TEXT) {
1981 QString titlepath = m_activeDocument->projectFolder().path() + "/titles/";
1982 QString path = clip->getProperty("resource");
1983 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlepath, m_projectMonitor->render, this);
1985 doc.setContent(clip->getProperty("xmldata"));
1986 dia_ui->setXml(doc);
1987 if (dia_ui->exec() == QDialog::Accepted) {
1988 QImage pix = dia_ui->renderedPixmap();
1990 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
1991 //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
1992 QMap <QString, QString> newprops;
1993 newprops.insert("xmldata", dia_ui->xml().toString());
1994 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
1995 m_activeDocument->commandStack()->push(command);
1996 m_clipMonitor->refreshMonitor(true);
1997 m_activeDocument->setModified(true);
2001 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2004 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2005 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2006 if (dia.exec() == QDialog::Accepted) {
2007 EditClipCommand *command = new EditClipCommand(m_projectList, dia.clipId(), clip->properties(), dia.properties(), true);
2008 m_activeDocument->commandStack()->push(command);
2010 //m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
2011 if (dia.needsTimelineRefresh()) {
2012 // update clip occurences in timeline
2013 m_activeTimeline->projectView()->slotUpdateClip(dia.clipId());
2018 void MainWindow::customEvent(QEvent* e) {
2019 if (e->type() == QEvent::User) {
2020 // The timeline playing position changed...
2021 kDebug() << "RECIEVED JOG EVEMNT!!!";
2024 void MainWindow::slotActivateEffectStackView() {
2025 effectStack->raiseWindow(effectStackDock);
2028 void MainWindow::slotActivateTransitionView(Transition *t) {
2029 if (t) transitionConfig->raiseWindow(transitionConfigDock);
2032 void MainWindow::slotSnapRewind() {
2033 if (m_projectMonitor->isActive()) {
2034 if (m_activeTimeline)
2035 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2036 } else m_clipMonitor->slotSeekToPreviousSnap();
2039 void MainWindow::slotSnapForward() {
2040 if (m_projectMonitor->isActive()) {
2041 if (m_activeTimeline)
2042 m_activeTimeline->projectView()->slotSeekToNextSnap();
2043 } else m_clipMonitor->slotSeekToNextSnap();
2046 void MainWindow::slotClipStart() {
2047 if (m_projectMonitor->isActive()) {
2048 if (m_activeTimeline)
2049 m_activeTimeline->projectView()->clipStart();
2053 void MainWindow::slotClipEnd() {
2054 if (m_projectMonitor->isActive()) {
2055 if (m_activeTimeline)
2056 m_activeTimeline->projectView()->clipEnd();
2060 void MainWindow::slotChangeTool(QAction * action) {
2061 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2062 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2063 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2066 void MainWindow::slotSetTool(PROJECTTOOL tool) {
2067 if (m_activeDocument && m_activeTimeline) {
2068 //m_activeDocument->setTool(tool);
2069 m_activeTimeline->projectView()->setTool(tool);
2073 void MainWindow::slotCopy() {
2074 if (!m_activeDocument || !m_activeTimeline) return;
2075 m_activeTimeline->projectView()->copyClip();
2078 void MainWindow::slotPaste() {
2079 if (!m_activeDocument || !m_activeTimeline) return;
2080 m_activeTimeline->projectView()->pasteClip();
2083 void MainWindow::slotPasteEffects() {
2084 if (!m_activeDocument || !m_activeTimeline) return;
2085 m_activeTimeline->projectView()->pasteClipEffects();
2088 void MainWindow::slotFind() {
2089 if (!m_activeDocument || !m_activeTimeline) return;
2090 m_projectSearch->setEnabled(false);
2091 m_findActivated = true;
2092 m_findString = QString();
2093 m_activeTimeline->projectView()->initSearchStrings();
2094 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2095 m_findTimer.start(5000);
2096 qApp->installEventFilter(this);
2099 void MainWindow::slotFindNext() {
2100 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2101 statusBar()->showMessage(i18n("Found : %1", m_findString));
2103 statusBar()->showMessage(i18n("Reached end of project"));
2105 m_findTimer.start(4000);
2108 void MainWindow::findAhead() {
2109 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2110 m_projectSearchNext->setEnabled(true);
2111 statusBar()->showMessage(i18n("Found : %1", m_findString));
2113 m_projectSearchNext->setEnabled(false);
2114 statusBar()->showMessage(i18n("Not found : %1", m_findString));
2118 void MainWindow::findTimeout() {
2119 m_projectSearchNext->setEnabled(false);
2120 m_findActivated = false;
2121 m_findString = QString();
2122 statusBar()->showMessage(i18n("Find stopped"), 3000);
2123 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2124 m_projectSearch->setEnabled(true);
2125 removeEventFilter(this);
2128 void MainWindow::keyPressEvent(QKeyEvent *ke) {
2129 if (m_findActivated) {
2130 if (ke->key() == Qt::Key_Backspace) {
2131 m_findString = m_findString.left(m_findString.length() - 1);
2133 if (!m_findString.isEmpty()) {
2139 m_findTimer.start(4000);
2142 } else if (ke->key() == Qt::Key_Escape) {
2146 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2147 m_findString += ke->text();
2151 m_findTimer.start(4000);
2155 } else KXmlGuiWindow::keyPressEvent(ke);
2159 /** Gets called when the window gets hidden */
2160 void MainWindow::hideEvent(QHideEvent *event) {
2161 // kDebug() << "I was hidden";
2162 // issue http://www.kdenlive.org/mantis/view.php?id=231
2163 if (this->isMinimized()) {
2164 // kDebug() << "I am minimized";
2165 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2169 bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
2170 if (m_findActivated) {
2171 if (event->type() == QEvent::ShortcutOverride) {
2172 QKeyEvent* ke = (QKeyEvent*) event;
2173 if (ke->text().trimmed().isEmpty()) return false;
2176 } else return false;
2178 // pass the event on to the parent class
2179 return QMainWindow::eventFilter(obj, event);
2183 void MainWindow::slotSaveZone(Render *render, QPoint zone) {
2184 KDialog *dialog = new KDialog(this);
2185 dialog->setCaption("Save clip zone");
2186 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2188 QWidget *widget = new QWidget(dialog);
2189 dialog->setMainWidget(widget);
2191 QVBoxLayout *vbox = new QVBoxLayout(widget);
2192 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2193 QString path = m_activeDocument->projectFolder().path();
2195 path.append("untitled.westley");
2196 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2197 url->setFilter("video/mlt-playlist");
2198 QLabel *label2 = new QLabel(i18n("Description:"), this);
2199 KLineEdit *edit = new KLineEdit(this);
2200 vbox->addWidget(label1);
2201 vbox->addWidget(url);
2202 vbox->addWidget(label2);
2203 vbox->addWidget(edit);
2204 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2208 void MainWindow::slotSetInPoint() {
2209 if (m_clipMonitor->isActive()) {
2210 m_clipMonitor->slotSetZoneStart();
2211 } else m_activeTimeline->projectView()->setInPoint();
2214 void MainWindow::slotSetOutPoint() {
2215 if (m_clipMonitor->isActive()) {
2216 m_clipMonitor->slotSetZoneEnd();
2217 } else m_activeTimeline->projectView()->setOutPoint();
2220 void MainWindow::slotGetNewStuff() {
2221 //KNS::Entry::List download();
2222 KNS::Entry::List entries = KNS::Engine::download();
2223 int numberInstalled = 0;
2224 // list of changed entries
2225 kDebug() << "// PARSING KNS";
2226 foreach(KNS::Entry* entry, entries) {
2227 // care only about installed ones
2228 if (entry->status() == KNS::Entry::Installed) {
2229 foreach(const QString &file, entry->installedFiles()) {
2230 kDebug() << "// CURRENTLY INSTALLED: " << file;
2234 qDeleteAll(entries);
2235 initEffects::refreshLumas();
2238 void MainWindow::slotAutoTransition() {
2239 m_activeTimeline->projectView()->autoTransition();
2242 void MainWindow::slotDvdWizard(const QString &url, const QString &profile) {
2243 DvdWizard *w = new DvdWizard(url, profile, this);
2248 #include "mainwindow.moc"