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 ***************************************************************************/
21 #include "mainwindow.h"
22 #include "mainwindowadaptor.h"
23 #include "kdenlivesettings.h"
24 #include "kdenlivesettingsdialog.h"
25 #include "initeffects.h"
26 #include "profilesdialog.h"
27 #include "projectsettings.h"
29 #include "clipmanager.h"
30 #include "projectlist.h"
32 #include "recmonitor.h"
33 #include "monitormanager.h"
34 #include "kdenlivedoc.h"
35 #include "trackview.h"
36 #include "customtrackview.h"
37 #include "effectslistview.h"
38 #include "effectstackview.h"
39 #include "transitionsettings.h"
40 #include "renderwidget.h"
43 #include "jogshuttle.h"
44 #endif /* NO_JOGSHUTTLE */
45 #include "clipproperties.h"
47 #include "editclipcommand.h"
48 #include "titlewidget.h"
49 #include "markerdialog.h"
51 #include "interfaces.h"
52 #include "kdenlive-config.h"
53 #include "cliptranscode.h"
54 #include "ui_templateclip_ui.h"
56 #include <KApplication>
60 #include <KActionCollection>
61 #include <KStandardAction>
62 #include <KFileDialog>
63 #include <KMessageBox>
65 #include <KIO/NetAccess>
68 #include <KConfigDialog>
69 #include <KXMLGUIFactory>
71 #include <kstandarddirs.h>
72 #include <KUrlRequesterDialog>
73 #include <KTemporaryFile>
75 #include <KActionMenu>
78 #include <ktogglefullscreenaction.h>
80 #include <KNotification>
81 #include <KNotifyConfigWidget>
82 #include <knewstuff2/engine.h>
83 #include <knewstuff2/ui/knewstuffaction.h>
85 #include <KColorScheme>
87 #include <QTextStream>
91 #include <QInputDialog>
92 #include <QDesktopWidget>
97 static const char version[] = VERSION;
99 static const int ID_TIMELINE_POS = 0;
106 EffectsList MainWindow::videoEffects;
107 EffectsList MainWindow::audioEffects;
108 EffectsList MainWindow::customEffects;
109 EffectsList MainWindow::transitions;
111 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) :
112 KXmlGuiWindow(parent),
113 m_activeDocument(NULL),
114 m_activeTimeline(NULL),
115 m_renderWidget(NULL),
116 #ifndef NO_JOGSHUTTLE
118 #endif /* NO_JOGSHUTTLE */
119 m_findActivated(false)
122 // Create DBus interface
123 new MainWindowAdaptor(this);
124 QDBusConnection dbus = QDBusConnection::sessionBus();
125 dbus.registerObject("/MainWindow", this);
127 setlocale(LC_NUMERIC, "POSIX");
128 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
129 setFont(KGlobalSettings::toolBarFont());
130 parseProfiles(MltPath);
131 m_commandStack = new QUndoGroup;
132 m_timelineArea = new KTabWidget(this);
133 m_timelineArea->setTabReorderingEnabled(true);
134 m_timelineArea->setTabBarHidden(true);
136 QToolButton *closeTabButton = new QToolButton;
137 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
138 closeTabButton->setIcon(KIcon("tab-close"));
139 closeTabButton->adjustSize();
140 closeTabButton->setToolTip(i18n("Close the current tab"));
141 m_timelineArea->setCornerWidget(closeTabButton);
142 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
144 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
145 m_findTimer.setSingleShot(true);
147 // FIXME: the next call returns a newly allocated object, which leaks
148 initEffects::parseEffectFiles();
149 //initEffects::parseCustomEffectsFile();
151 m_monitorManager = new MonitorManager();
153 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
154 m_projectListDock->setObjectName("project_tree");
155 m_projectList = new ProjectList(this);
156 m_projectListDock->setWidget(m_projectList);
157 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
159 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
160 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
162 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
163 m_effectListDock->setObjectName("effect_list");
164 m_effectList = new EffectsListView();
166 //m_effectList = new KListWidget(this);
167 m_effectListDock->setWidget(m_effectList);
168 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
170 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
171 m_effectStackDock->setObjectName("effect_stack");
172 m_effectStack = new EffectStackView(this);
173 m_effectStackDock->setWidget(m_effectStack);
174 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
176 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
177 m_transitionConfigDock->setObjectName("transition");
178 m_transitionConfig = new TransitionSettings(this);
179 m_transitionConfigDock->setWidget(m_transitionConfig);
180 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
182 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
183 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
185 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
186 m_fileRevert->setEnabled(false);
188 //slotDetectAudioDriver();
190 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
191 m_clipMonitorDock->setObjectName("clip_monitor");
192 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this);
193 m_clipMonitorDock->setWidget(m_clipMonitor);
194 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
195 //m_clipMonitor->stop();
197 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
198 m_projectMonitorDock->setObjectName("project_monitor");
199 m_projectMonitor = new Monitor("project", m_monitorManager, QString(), this);
200 m_projectMonitorDock->setWidget(m_projectMonitor);
201 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
204 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
205 m_recMonitorDock->setObjectName("record_monitor");
206 m_recMonitor = new RecMonitor("record", this);
207 m_recMonitorDock->setWidget(m_recMonitor);
208 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
210 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
211 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
214 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
215 m_undoViewDock->setObjectName("undo_history");
216 m_undoView = new QUndoView(this);
217 m_undoView->setCleanIcon(KIcon("edit-clear"));
218 m_undoView->setEmptyLabel(i18n("Clean"));
219 m_undoViewDock->setWidget(m_undoView);
220 m_undoView->setGroup(m_commandStack);
221 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
223 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
224 //overviewDock->setObjectName("project_overview");
225 //m_overView = new CustomTrackView(NULL, NULL, this);
226 //overviewDock->setWidget(m_overView);
227 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
230 //tabifyDockWidget(projectListDock, effectListDock);
231 tabifyDockWidget(m_projectListDock, m_effectStackDock);
232 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
233 //tabifyDockWidget(projectListDock, undoViewDock);
236 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
238 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
240 setCentralWidget(m_timelineArea);
245 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
246 guiFactory()->addClient(sp);*/
250 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
252 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
253 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
254 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)), static_cast<QMenu*>(factory()->container("transcoders", this)));
257 // build themes menus
258 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
259 QActionGroup *themegroup = new QActionGroup(this);
260 themegroup->setExclusive(true);
261 action = new QAction(i18n("Default"), this);
262 action->setCheckable(true);
263 themegroup->addAction(action);
264 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
267 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
269 for (int i = 0; i < schemeFiles.size(); ++i) {
271 const QString filename = schemeFiles.at(i);
272 const QFileInfo info(filename);
275 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
276 QIcon icon = createSchemePreviewIcon(config);
277 KConfigGroup group(config, "General");
278 const QString name = group.readEntry("Name", info.baseName());
279 action = new QAction(name, this);
280 action->setData(filename);
281 action->setIcon(icon);
282 action->setCheckable(true);
283 themegroup->addAction(action);
284 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
292 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
293 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
294 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
297 action = new QAction(fi.fileName(), this);
298 action->setData(*it);
299 action->setCheckable(true);
300 themegroup->addAction(action);
301 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
303 themesMenu->addActions(themegroup->actions());
304 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
306 // build effects menus
307 QMenu *videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
309 QStringList effectInfo;
310 QMap<QString, QStringList> effectsList;
311 for (int ix = 0; ix < videoEffects.count(); ix++) {
312 effectInfo = videoEffects.effectIdInfo(ix);
313 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
316 foreach(const QStringList &value, effectsList) {
317 action = new QAction(value.at(0), this);
318 action->setData(value);
319 videoEffectsMenu->addAction(action);
322 QMenu *audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
326 for (int ix = 0; ix < audioEffects.count(); ix++) {
327 effectInfo = audioEffects.effectIdInfo(ix);
328 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
331 foreach(const QStringList &value, effectsList) {
332 action = new QAction(value.at(0), this);
333 action->setData(value);
334 audioEffectsMenu->addAction(action);
337 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
339 if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false);
340 else m_customEffectsMenu->setEnabled(true);
343 for (int ix = 0; ix < customEffects.count(); ix++) {
344 effectInfo = customEffects.effectIdInfo(ix);
345 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
348 foreach(const QStringList &value, effectsList) {
349 action = new QAction(value.at(0), this);
350 action->setData(value);
351 m_customEffectsMenu->addAction(action);
354 QMenu *newEffect = new QMenu(this);
355 newEffect->addMenu(videoEffectsMenu);
356 newEffect->addMenu(audioEffectsMenu);
357 newEffect->addMenu(m_customEffectsMenu);
358 m_effectStack->setMenu(newEffect);
361 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
362 const QList<QAction *> viewActions = createPopupMenu()->actions();
363 viewMenu->insertActions(NULL, viewActions);
365 connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
366 connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
367 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
369 m_timelineContextMenu = new QMenu(this);
370 m_timelineContextClipMenu = new QMenu(this);
371 m_timelineContextTransitionMenu = new QMenu(this);
374 QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this);
375 QStringList effects = transitions.effectNames();
378 for (int ix = 0; ix < transitions.count(); ix++) {
379 effectInfo = transitions.effectIdInfo(ix);
380 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
382 foreach(const QStringList &value, effectsList) {
383 action = new QAction(value.at(0), this);
384 action->setData(value);
385 transitionsMenu->addAction(action);
387 connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
389 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
390 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
391 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
393 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip"));
394 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
395 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
396 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
397 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
398 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
399 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
401 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
402 m_timelineContextClipMenu->addMenu(markersMenu);
403 m_timelineContextClipMenu->addMenu(transitionsMenu);
404 m_timelineContextClipMenu->addMenu(videoEffectsMenu);
405 m_timelineContextClipMenu->addMenu(audioEffectsMenu);
406 //TODO: re-enable custom effects menu when it is implemented
407 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
409 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip"));
410 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
412 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
414 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
415 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
416 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
417 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
418 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
419 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
421 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
422 slotConnectMonitors();
424 // Open or create a file. Command line argument passed in Url has
425 // precedence, then "openlastproject", then just a plain empty file.
426 // If opening Url fails, openlastproject will _not_ be used.
427 if (!Url.isEmpty()) {
428 // delay loading so that the window shows up
430 QTimer::singleShot(500, this, SLOT(openFile()));
431 } else if (KdenliveSettings::openlastproject()) {
432 QTimer::singleShot(500, this, SLOT(openLastFile()));
433 } else { //if (m_timelineArea->count() == 0) {
437 #ifndef NO_JOGSHUTTLE
438 activateShuttleDevice();
439 #endif /* NO_JOGSHUTTLE */
440 m_projectListDock->raise();
443 void MainWindow::queryQuit()
446 if (m_projectMonitor) m_projectMonitor->stop();
447 if (m_clipMonitor) m_clipMonitor->stop();
448 delete m_effectStack;
449 delete m_activeTimeline;
451 // This sometimes causes crash on exit on OS X for some reason.
452 delete m_projectMonitor;
453 delete m_clipMonitor;
455 delete m_activeDocument;
456 delete m_shortcutRemoveFocus;
457 Mlt::Factory::close();
463 bool MainWindow::queryClose()
465 if (m_renderWidget) {
466 int waitingJobs = m_renderWidget->waitingJobsCount();
467 if (waitingJobs > 0) {
468 switch (KMessageBox::warningYesNoCancel(this, i18np("You have 1 rendering job waiting in the queue.\nWhat do you want to do with this job?", "You have %1 rendering jobs waiting in the queue.\nWhat do you want to do with these jobs?", waitingJobs), QString(), KGuiItem(i18n("Start them now")), KGuiItem(i18n("Delete them")))) {
469 case KMessageBox::Yes :
470 // create script with waiting jobs and start it
471 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
473 case KMessageBox::No :
474 // Don't do anything, jobs will be deleted
482 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
483 if (m_activeDocument && m_activeDocument->isModified()) {
484 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
485 case KMessageBox::Yes :
486 // save document here. If saving fails, return false;
488 case KMessageBox::No :
489 // User does not want to save the changes, clear recovery files
490 m_activeDocument->m_autosave->resize(0);
500 void MainWindow::loadPlugins()
502 foreach(QObject *plugin, QPluginLoader::staticInstances())
503 populateMenus(plugin);
505 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
507 filters << "libkdenlive*";
508 foreach(const QString &folder, directories) {
509 kDebug() << "// PARSING FIOLER: " << folder;
510 QDir pluginsDir(folder);
511 foreach(const QString &fileName, pluginsDir.entryList(filters, QDir::Files)) {
512 kDebug() << "// FOUND PLUGIN: " << fileName << "= " << pluginsDir.absoluteFilePath(fileName);
513 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
514 QObject *plugin = loader.instance();
516 populateMenus(plugin);
517 m_pluginFileNames += fileName;
518 } else kDebug() << "// ERROR LOADING PLUGIN: " << fileName << ", " << loader.errorString();
524 void MainWindow::populateMenus(QObject *plugin)
526 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
527 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
529 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
533 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
534 QMenu *menu, const char *member,
535 QActionGroup *actionGroup)
537 kDebug() << "// ADD to MENU" << texts;
538 foreach(const QString &text, texts) {
539 QAction *action = new QAction(text, plugin);
540 action->setData(text);
541 connect(action, SIGNAL(triggered()), this, member);
542 menu->addAction(action);
545 action->setCheckable(true);
546 actionGroup->addAction(action);
551 void MainWindow::aboutPlugins()
553 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
558 void MainWindow::generateClip()
560 QAction *action = qobject_cast<QAction *>(sender());
561 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
563 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576);
564 if (!clipUrl.isEmpty()) {
565 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
569 void MainWindow::saveProperties(KConfigGroup &config)
571 // save properties here,used by session management
573 KMainWindow::saveProperties(config);
577 void MainWindow::readProperties(const KConfigGroup &config)
579 // read properties here,used by session management
580 KMainWindow::readProperties(config);
581 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
582 openFile(KUrl(Lastproject));
585 void MainWindow::slotReloadEffects()
587 kDebug() << "START RELOAD; COUNR: " << m_customEffectsMenu->actions().count();
588 m_customEffectsMenu->clear();
589 kDebug() << "START RELOAD; CLR: " << m_customEffectsMenu->actions().count();
590 initEffects::parseCustomEffectsFile();
591 const QStringList effects = customEffects.effectNames();
592 kDebug() << "NEW EFFS: " << effects;
594 if (effects.isEmpty()) m_customEffectsMenu->setEnabled(false);
595 else m_customEffectsMenu->setEnabled(true);
597 foreach(const QString &name, effects) {
598 action = new QAction(name, this);
599 action->setData(name);
600 m_customEffectsMenu->addAction(action);
602 m_effectList->reloadEffectList();
605 #ifndef NO_JOGSHUTTLE
606 void MainWindow::activateShuttleDevice()
610 if (KdenliveSettings::enableshuttle() == false) return;
611 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
612 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
613 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
614 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
615 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
616 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
617 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
620 void MainWindow::slotShuttleButton(int code)
624 slotShuttleAction(KdenliveSettings::shuttle1());
627 slotShuttleAction(KdenliveSettings::shuttle2());
630 slotShuttleAction(KdenliveSettings::shuttle3());
633 slotShuttleAction(KdenliveSettings::shuttle4());
636 slotShuttleAction(KdenliveSettings::shuttle5());
641 void MainWindow::slotShuttleAction(int code)
647 m_monitorManager->slotPlay();
650 m_monitorManager->slotPlay();
654 #endif /* NO_JOGSHUTTLE */
656 void MainWindow::configureNotifications()
658 KNotifyConfigWidget::configure(this);
661 void MainWindow::slotFullScreen()
663 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
666 void MainWindow::slotAddEffect(const QDomElement effect, GenTime pos, int track)
668 if (!m_activeDocument) return;
669 if (effect.isNull()) {
670 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
673 QDomElement effectToAdd = effect.cloneNode().toElement();
674 m_activeTimeline->projectView()->slotAddEffect(effectToAdd, pos, track);
677 void MainWindow::slotRaiseMonitor(bool clipMonitor)
679 if (clipMonitor) m_clipMonitorDock->raise();
680 else m_projectMonitorDock->raise();
683 void MainWindow::slotUpdateClip(const QString &id)
685 if (!m_activeDocument) return;
686 m_activeTimeline->projectView()->slotUpdateClip(id);
689 void MainWindow::slotConnectMonitors()
692 m_projectList->setRenderer(m_projectMonitor->render);
693 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
694 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
695 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, bool)));
696 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
697 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
699 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
701 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
703 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
704 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
706 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
707 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
710 void MainWindow::slotAdjustClipMonitor()
712 m_clipMonitorDock->updateGeometry();
713 m_clipMonitorDock->adjustSize();
714 m_clipMonitor->resetSize();
717 void MainWindow::slotAdjustProjectMonitor()
719 m_projectMonitorDock->updateGeometry();
720 m_projectMonitorDock->adjustSize();
721 m_projectMonitor->resetSize();
724 void MainWindow::setupActions()
727 KActionCollection* collection = actionCollection();
728 m_timecodeFormat = new KComboBox(this);
729 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
730 m_timecodeFormat->addItem(i18n("Frames"));
731 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
732 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
734 m_statusProgressBar = new QProgressBar(this);
735 m_statusProgressBar->setMinimum(0);
736 m_statusProgressBar->setMaximum(100);
737 m_statusProgressBar->setMaximumWidth(150);
738 m_statusProgressBar->setVisible(false);
740 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
741 toolbar->setMovable(false);
742 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
743 QString style1 = "QToolBar { border: 0px } QToolButton { 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;}";
745 //Â create edit mode buttons
746 KAction *normaledit = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
747 normaledit->setShortcut(i18nc("Normal editing", "n"));
748 toolbar->addAction(normaledit);
749 normaledit->setCheckable(true);
750 normaledit->setChecked(true);
752 m_overwriteModeTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
753 m_overwriteModeTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
754 toolbar->addAction(m_overwriteModeTool);
755 m_overwriteModeTool->setCheckable(true);
756 m_overwriteModeTool->setChecked(false);
758 m_insertModeTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
759 m_insertModeTool->setShortcut(i18nc("Insert mode shortcut", "i"));
760 toolbar->addAction(m_insertModeTool);
761 m_insertModeTool->setCheckable(true);
762 m_insertModeTool->setChecked(false);
763 // not implemented yet
764 m_insertModeTool->setEnabled(false);
766 QActionGroup *editGroup = new QActionGroup(this);
767 editGroup->addAction(normaledit);
768 editGroup->addAction(m_overwriteModeTool);
769 editGroup->addAction(m_insertModeTool);
770 editGroup->setExclusive(true);
771 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
772 //connect(m_overwriteModeTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
774 toolbar->addSeparator();
776 // create tools buttons
777 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
778 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
779 toolbar->addAction(m_buttonSelectTool);
780 m_buttonSelectTool->setCheckable(true);
781 m_buttonSelectTool->setChecked(true);
783 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
784 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
785 toolbar->addAction(m_buttonRazorTool);
786 m_buttonRazorTool->setCheckable(true);
787 m_buttonRazorTool->setChecked(false);
789 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
790 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
791 toolbar->addAction(m_buttonSpacerTool);
792 m_buttonSpacerTool->setCheckable(true);
793 m_buttonSpacerTool->setChecked(false);
795 QActionGroup *toolGroup = new QActionGroup(this);
796 toolGroup->addAction(m_buttonSelectTool);
797 toolGroup->addAction(m_buttonRazorTool);
798 toolGroup->addAction(m_buttonSpacerTool);
799 toolGroup->setExclusive(true);
800 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
802 QWidget * actionWidget;
803 int max = toolbar->iconSizeDefault() + 2;
804 actionWidget = toolbar->widgetForAction(normaledit);
805 actionWidget->setMaximumWidth(max);
806 actionWidget->setMaximumHeight(max - 4);
808 actionWidget = toolbar->widgetForAction(m_insertModeTool);
809 actionWidget->setMaximumWidth(max);
810 actionWidget->setMaximumHeight(max - 4);
812 actionWidget = toolbar->widgetForAction(m_overwriteModeTool);
813 actionWidget->setMaximumWidth(max);
814 actionWidget->setMaximumHeight(max - 4);
816 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
817 actionWidget->setMaximumWidth(max);
818 actionWidget->setMaximumHeight(max - 4);
820 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
821 actionWidget->setMaximumWidth(max);
822 actionWidget->setMaximumHeight(max - 4);
824 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
825 actionWidget->setMaximumWidth(max);
826 actionWidget->setMaximumHeight(max - 4);
828 toolbar->setStyleSheet(style1);
829 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
831 toolbar->addSeparator();
832 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
833 toolbar->addAction(m_buttonFitZoom);
834 m_buttonFitZoom->setCheckable(false);
835 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
837 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
838 actionWidget->setMaximumWidth(max);
839 actionWidget->setMaximumHeight(max - 4);
841 m_zoomSlider = new QSlider(Qt::Horizontal, this);
842 m_zoomSlider->setMaximum(13);
843 m_zoomSlider->setPageStep(1);
845 m_zoomSlider->setMaximumWidth(150);
846 m_zoomSlider->setMinimumWidth(100);
847 toolbar->addWidget(m_zoomSlider);
849 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
850 toolbar->addAction(m_buttonVideoThumbs);
851 m_buttonVideoThumbs->setCheckable(true);
852 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
853 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
855 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
856 toolbar->addAction(m_buttonAudioThumbs);
857 m_buttonAudioThumbs->setCheckable(true);
858 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
859 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
861 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
862 toolbar->addAction(m_buttonShowMarkers);
863 m_buttonShowMarkers->setCheckable(true);
864 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
865 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
867 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
868 toolbar->addAction(m_buttonSnap);
869 m_buttonSnap->setCheckable(true);
870 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
871 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
873 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
874 actionWidget->setMaximumWidth(max);
875 actionWidget->setMaximumHeight(max - 4);
877 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
878 actionWidget->setMaximumWidth(max);
879 actionWidget->setMaximumHeight(max - 4);
881 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
882 actionWidget->setMaximumWidth(max);
883 actionWidget->setMaximumHeight(max - 4);
885 actionWidget = toolbar->widgetForAction(m_buttonSnap);
886 actionWidget->setMaximumWidth(max);
887 actionWidget->setMaximumHeight(max - 4);
889 m_messageLabel = new StatusBarMessageLabel(this);
890 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
892 statusBar()->addWidget(m_messageLabel, 10);
893 statusBar()->addWidget(m_statusProgressBar, 0);
894 statusBar()->addPermanentWidget(toolbar);
895 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
896 statusBar()->addPermanentWidget(m_timecodeFormat);
897 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
899 collection->addAction("normal_mode", normaledit);
900 collection->addAction("overwrite_mode", m_overwriteModeTool);
901 collection->addAction("insert_mode", m_insertModeTool);
902 collection->addAction("select_tool", m_buttonSelectTool);
903 collection->addAction("razor_tool", m_buttonRazorTool);
904 collection->addAction("spacer_tool", m_buttonSpacerTool);
906 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
907 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
908 collection->addAction("show_markers", m_buttonShowMarkers);
909 collection->addAction("snap", m_buttonSnap);
910 collection->addAction("zoom_fit", m_buttonFitZoom);
912 KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
913 collection->addAction("zoom_in", zoomIn);
914 connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
915 zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
917 KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
918 collection->addAction("zoom_out", zoomOut);
919 connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
920 zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
922 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
923 collection->addAction("project_find", m_projectSearch);
924 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
925 m_projectSearch->setShortcut(Qt::Key_Slash);
927 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
928 collection->addAction("project_find_next", m_projectSearchNext);
929 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
930 m_projectSearchNext->setShortcut(Qt::Key_F3);
931 m_projectSearchNext->setEnabled(false);
933 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
934 collection->addAction("manage_profiles", profilesAction);
935 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
937 KNS::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
939 KNS::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
941 KNS::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
943 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
944 collection->addAction("run_wizard", wizAction);
945 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
947 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
948 collection->addAction("project_settings", projectAction);
949 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
951 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
952 collection->addAction("project_render", projectRender);
953 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
954 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
956 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
957 collection->addAction("project_clean", projectClean);
958 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
960 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
961 KShortcut playShortcut;
962 playShortcut.setPrimary(Qt::Key_Space);
963 playShortcut.setAlternate(Qt::Key_K);
964 monitorPlay->setShortcut(playShortcut);
965 collection->addAction("monitor_play", monitorPlay);
966 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
968 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
969 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
970 collection->addAction("monitor_play_zone", m_playZone);
971 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
973 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
974 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
975 collection->addAction("monitor_loop_zone", m_loopZone);
976 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
978 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
979 collection->addAction("dvd_wizard", dvdWizard);
980 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
982 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
983 collection->addAction("transcode_clip", transcodeClip);
984 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
986 KAction *markIn = collection->addAction("mark_in");
987 markIn->setText(i18n("Set Zone In"));
988 markIn->setShortcut(Qt::Key_I);
989 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
991 KAction *markOut = collection->addAction("mark_out");
992 markOut->setText(i18n("Set Zone Out"));
993 markOut->setShortcut(Qt::Key_O);
994 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
996 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
997 collection->addAction("resize_timeline_clip_start", resizeStart);
998 resizeStart->setShortcut(Qt::Key_1);
999 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1001 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1002 collection->addAction("resize_timeline_clip_end", resizeEnd);
1003 resizeEnd->setShortcut(Qt::Key_2);
1004 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1006 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1007 monitorSeekBackward->setShortcut(Qt::Key_J);
1008 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1009 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1011 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1012 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1013 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1014 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1016 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1017 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1018 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1019 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1021 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1022 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1023 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1024 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1026 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1027 monitorSeekForward->setShortcut(Qt::Key_L);
1028 collection->addAction("monitor_seek_forward", monitorSeekForward);
1029 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1031 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1032 clipStart->setShortcut(Qt::Key_Home);
1033 collection->addAction("seek_clip_start", clipStart);
1034 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1036 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1037 clipEnd->setShortcut(Qt::Key_End);
1038 collection->addAction("seek_clip_end", clipEnd);
1039 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1041 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1042 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1043 collection->addAction("seek_zone_start", zoneStart);
1044 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1046 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1047 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1048 collection->addAction("seek_zone_end", zoneEnd);
1049 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1051 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1052 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1053 collection->addAction("seek_start", projectStart);
1054 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1056 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1057 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1058 collection->addAction("seek_end", projectEnd);
1059 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1061 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1062 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1063 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1064 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1066 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1067 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1068 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1069 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1071 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1072 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1073 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1074 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1076 KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1077 deleteTimelineClip->setShortcut(Qt::Key_Delete);
1078 collection->addAction("delete_timeline_clip", deleteTimelineClip);
1079 connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip()));
1081 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1082 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1083 editTimelineClipSpeed->setData("change_speed");
1084 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1086 KAction *stickTransition = collection->addAction("auto_transition");
1087 stickTransition->setData(QString("auto"));
1088 stickTransition->setCheckable(true);
1089 stickTransition->setEnabled(false);
1090 stickTransition->setText(i18n("Automatic Transition"));
1091 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1093 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1094 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1095 collection->addAction("group_clip", groupClip);
1096 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1098 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1099 collection->addAction("ungroup_clip", ungroupClip);
1100 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1101 ungroupClip->setData("ungroup_clip");
1102 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1104 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1105 selectTimelineClip->setShortcut(Qt::Key_Plus);
1106 collection->addAction("select_timeline_clip", selectTimelineClip);
1107 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1109 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1110 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1111 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1112 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1114 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1115 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1116 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1117 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1119 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1120 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1121 collection->addAction("select_timeline_transition", selectTimelineTransition);
1122 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1124 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1125 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1126 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1127 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1129 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1130 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1131 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1132 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1134 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1135 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1136 collection->addAction("cut_timeline_clip", cutTimelineClip);
1137 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1139 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1140 collection->addAction("add_clip_marker", addClipMarker);
1141 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1143 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1144 collection->addAction("delete_clip_marker", deleteClipMarker);
1145 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1147 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1148 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1149 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1151 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1152 collection->addAction("edit_clip_marker", editClipMarker);
1153 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1155 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1156 collection->addAction("split_audio", splitAudio);
1157 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1159 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1160 collection->addAction("clip_audio_only", audioOnly);
1161 audioOnly->setData("clip_audio_only");
1162 audioOnly->setCheckable(true);
1164 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1165 collection->addAction("clip_video_only", videoOnly);
1166 videoOnly->setData("clip_video_only");
1167 videoOnly->setCheckable(true);
1169 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1170 collection->addAction("clip_audio_and_video", audioAndVideo);
1171 audioAndVideo->setData("clip_audio_and_video");
1172 audioAndVideo->setCheckable(true);
1174 m_clipTypeGroup = new QActionGroup(this);
1175 m_clipTypeGroup->addAction(audioOnly);
1176 m_clipTypeGroup->addAction(videoOnly);
1177 m_clipTypeGroup->addAction(audioAndVideo);
1178 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1179 m_clipTypeGroup->setEnabled(false);
1181 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1182 collection->addAction("insert_space", insertSpace);
1183 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1185 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1186 collection->addAction("delete_space", removeSpace);
1187 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1189 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1190 collection->addAction("insert_track", insertTrack);
1191 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1193 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1194 collection->addAction("delete_track", deleteTrack);
1195 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1197 KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this);
1198 collection->addAction("change_track", changeTrack);
1199 connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
1201 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1202 collection->addAction("add_guide", addGuide);
1203 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1205 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1206 collection->addAction("delete_guide", delGuide);
1207 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1209 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1210 collection->addAction("edit_guide", editGuide);
1211 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1213 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1214 collection->addAction("delete_all_guides", delAllGuides);
1215 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1217 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1218 collection->addAction("paste_effects", pasteEffects);
1219 pasteEffects->setData("paste_effects");
1220 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1222 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1223 collection->addAction("show_timeline", showTimeline);
1224 showTimeline->setCheckable(true);
1225 showTimeline->setChecked(true);
1226 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1228 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1229 collection->addAction("maximize_current", maxCurrent);
1230 maxCurrent->setCheckable(true);
1231 maxCurrent->setChecked(false);
1232 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1235 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1237 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1239 KStandardAction::open(this, SLOT(openFile()), collection);
1241 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1243 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1245 KStandardAction::openNew(this, SLOT(newFile()), collection);
1247 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1249 KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection);
1251 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1253 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1255 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1256 undo->setEnabled(false);
1257 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1259 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1260 redo->setEnabled(false);
1261 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1263 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1266 //TODO: Add status tooltip to actions ?
1267 connect(collection, SIGNAL(actionHovered(QAction*)),
1268 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1271 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1272 collection->addAction("add_clip", addClip);
1273 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1275 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1276 collection->addAction("add_color_clip", addColorClip);
1277 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1279 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1280 collection->addAction("add_slide_clip", addSlideClip);
1281 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1283 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1284 collection->addAction("add_text_clip", addTitleClip);
1285 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1287 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1288 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1289 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1291 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1292 collection->addAction("add_folder", addFolderButton);
1293 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1295 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1296 collection->addAction("clip_properties", clipProperties);
1297 clipProperties->setData("clip_properties");
1298 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1299 clipProperties->setEnabled(false);
1301 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1302 collection->addAction("edit_clip", openClip);
1303 openClip->setData("edit_clip");
1304 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1305 openClip->setEnabled(false);
1307 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1308 collection->addAction("delete_clip", deleteClip);
1309 deleteClip->setData("delete_clip");
1310 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1311 deleteClip->setEnabled(false);
1313 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1314 collection->addAction("reload_clip", reloadClip);
1315 reloadClip->setData("reload_clip");
1316 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1317 reloadClip->setEnabled(false);
1319 QMenu *addClips = new QMenu();
1320 addClips->addAction(addClip);
1321 addClips->addAction(addColorClip);
1322 addClips->addAction(addSlideClip);
1323 addClips->addAction(addTitleClip);
1324 addClips->addAction(addTitleTemplateClip);
1325 addClips->addAction(addFolderButton);
1327 addClips->addAction(reloadClip);
1328 addClips->addAction(clipProperties);
1329 addClips->addAction(openClip);
1330 addClips->addAction(deleteClip);
1331 m_projectList->setupMenu(addClips, addClip);
1333 //connect(collection, SIGNAL( clearStatusText() ),
1334 //statusBar(), SLOT( clear() ) );
1337 void MainWindow::slotDisplayActionMessage(QAction *a)
1339 statusBar()->showMessage(a->data().toString(), 3000);
1342 void MainWindow::saveOptions()
1344 KdenliveSettings::self()->writeConfig();
1345 KSharedConfigPtr config = KGlobal::config();
1346 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1347 KConfigGroup treecolumns(config, "Project Tree");
1348 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1352 void MainWindow::readOptions()
1354 KSharedConfigPtr config = KGlobal::config();
1355 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1356 KConfigGroup initialGroup(config, "version");
1357 bool upgrade = false;
1358 if (initialGroup.exists()) {
1359 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1363 if (initialGroup.readEntry("version") == "0.7") {
1364 //Add new settings from 0.7.1
1365 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1366 QString path = QDir::homePath() + "/kdenlive";
1367 if (KStandardDirs::makeDir(path) == false) {
1368 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1369 } else KdenliveSettings::setDefaultprojectfolder(path);
1375 if (!initialGroup.exists() || upgrade) {
1376 // this is our first run, show Wizard
1377 Wizard *w = new Wizard(upgrade, this);
1378 if (w->exec() == QDialog::Accepted && w->isOk()) {
1379 w->adjustSettings();
1380 initialGroup.writeEntry("version", version);
1386 KConfigGroup treecolumns(config, "Project Tree");
1387 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1388 if (!state.isEmpty())
1389 m_projectList->setHeaderInfo(state);
1392 void MainWindow::slotRunWizard()
1394 Wizard *w = new Wizard(false, this);
1395 if (w->exec() == QDialog::Accepted && w->isOk()) {
1396 w->adjustSettings();
1401 void MainWindow::newFile(bool showProjectSettings)
1403 if (!m_timelineArea->isEnabled()) return;
1404 m_fileRevert->setEnabled(false);
1405 QString profileName;
1407 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1408 if (!showProjectSettings && m_timelineArea->count() == 0) {
1409 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1410 profileName = KdenliveSettings::default_profile();
1411 projectFolder = KdenliveSettings::defaultprojectfolder();
1413 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1414 if (w->exec() != QDialog::Accepted) return;
1415 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1416 KdenliveSettings::setVideothumbnails(w->enableVideoThumbs());
1417 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1418 KdenliveSettings::setAudiothumbnails(w->enableAudioThumbs());
1419 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1420 profileName = w->selectedProfile();
1421 projectFolder = w->selectedFolder();
1422 projectTracks = w->tracks();
1425 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1426 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1428 TrackView *trackView = new TrackView(doc, &ok, this);
1429 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1432 m_timelineArea->setEnabled(false);
1433 m_projectList->setEnabled(false);
1434 m_monitorManager->slotBlockMonitors();
1438 if (m_timelineArea->count() == 1) {
1439 connectDocumentInfo(doc);
1440 connectDocument(trackView, doc);
1441 } else m_timelineArea->setTabBarHidden(false);
1442 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1445 void MainWindow::activateDocument()
1447 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1448 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1449 KdenliveDoc *currentDoc = currentTab->document();
1450 connectDocumentInfo(currentDoc);
1451 connectDocument(currentTab, currentDoc);
1454 void MainWindow::closeCurrentDocument(bool saveChanges)
1456 QWidget *w = m_timelineArea->currentWidget();
1458 // closing current document
1459 int ix = m_timelineArea->currentIndex() + 1;
1460 if (ix == m_timelineArea->count()) ix = 0;
1461 m_timelineArea->setCurrentIndex(ix);
1462 TrackView *tabToClose = (TrackView *) w;
1463 KdenliveDoc *docToClose = tabToClose->document();
1464 if (docToClose && docToClose->isModified() && saveChanges) {
1465 switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) {
1466 case KMessageBox::Yes :
1467 // save document here. If saving fails, return false;
1468 if (saveFile() == false) return;
1470 case KMessageBox::Cancel :
1477 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1478 if (m_timelineArea->count() == 1) {
1479 m_timelineArea->setTabBarHidden(true);
1480 m_closeAction->setEnabled(false);
1482 if (docToClose == m_activeDocument) {
1483 delete m_activeDocument;
1484 m_activeDocument = NULL;
1485 m_effectStack->clear();
1486 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1487 } else delete docToClose;
1488 if (w == m_activeTimeline) {
1489 delete m_activeTimeline;
1490 m_activeTimeline = NULL;
1494 bool MainWindow::saveFileAs(const QString &outputFileName)
1496 QString currentSceneList;
1497 if (KdenliveSettings::dropbframes()) {
1498 KdenliveSettings::setDropbframes(false);
1499 m_activeDocument->clipManager()->updatePreviewSettings();
1500 currentSceneList = m_projectMonitor->sceneList();
1501 KdenliveSettings::setDropbframes(true);
1502 m_activeDocument->clipManager()->updatePreviewSettings();
1503 } else currentSceneList = m_projectMonitor->sceneList();
1505 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1508 // Save timeline thumbnails
1509 m_activeTimeline->projectView()->saveThumbnails();
1510 m_activeDocument->setUrl(KUrl(outputFileName));
1511 if (m_activeDocument->m_autosave == NULL) {
1512 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1513 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1514 setCaption(m_activeDocument->description());
1515 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1516 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1517 m_activeDocument->setModified(false);
1518 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1519 m_fileRevert->setEnabled(true);
1523 bool MainWindow::saveFileAs()
1525 // Check that the Kdenlive mime type is correctly installed
1526 QString mimetype = "application/x-kdenlive";
1527 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1528 if (!mime) mimetype = "*.kdenlive";
1530 QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype);
1531 if (outputFile.isEmpty()) return false;
1532 if (QFile::exists(outputFile)) {
1533 if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false;
1535 return saveFileAs(outputFile);
1538 bool MainWindow::saveFile()
1540 if (!m_activeDocument) return true;
1541 if (m_activeDocument->url().isEmpty()) {
1542 return saveFileAs();
1544 bool result = saveFileAs(m_activeDocument->url().path());
1545 m_activeDocument->m_autosave->resize(0);
1550 void MainWindow::openFile()
1552 if (!m_startUrl.isEmpty()) {
1553 openFile(m_startUrl);
1554 m_startUrl = KUrl();
1557 // Check that the Kdenlive mime type is correctly installed
1558 QString mimetype = "application/x-kdenlive";
1559 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
1560 if (!mime) mimetype = "*.kdenlive";
1562 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype);
1563 if (url.isEmpty()) return;
1564 m_fileOpenRecent->addUrl(url);
1568 void MainWindow::openLastFile()
1570 KSharedConfigPtr config = KGlobal::config();
1571 KUrl::List urls = m_fileOpenRecent->urls();
1572 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1573 if (urls.isEmpty()) newFile(false);
1574 else openFile(urls.last());
1577 void MainWindow::openFile(const KUrl &url)
1579 // Check if the document is already opened
1580 const int ct = m_timelineArea->count();
1581 bool isOpened = false;
1583 for (i = 0; i < ct; i++) {
1584 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1585 KdenliveDoc *doc = tab->document();
1586 if (doc->url() == url) {
1592 m_timelineArea->setCurrentIndex(i);
1596 // Check for backup file
1597 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1598 if (!staleFiles.isEmpty()) {
1599 if (KMessageBox::questionYesNo(this,
1600 i18n("Auto-saved files exist. Do you want to recover them now?"),
1601 i18n("File Recovery"),
1602 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1603 recoverFiles(staleFiles);
1606 // remove the stale files
1607 foreach(KAutoSaveFile *stale, staleFiles) {
1608 stale->open(QIODevice::ReadWrite);
1613 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1614 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1615 qApp->processEvents();
1616 doOpenFile(url, NULL);
1619 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1621 if (!m_timelineArea->isEnabled()) return;
1622 m_fileRevert->setEnabled(true);
1623 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1624 if (stale == NULL) {
1625 stale = new KAutoSaveFile(url, doc);
1626 doc->m_autosave = stale;
1628 doc->m_autosave = stale;
1629 doc->setUrl(stale->managedFile());
1630 doc->setModified(true);
1631 stale->setParent(doc);
1633 connectDocumentInfo(doc);
1635 TrackView *trackView = new TrackView(doc, &ok, this);
1636 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1638 m_timelineArea->setEnabled(false);
1639 m_projectList->setEnabled(false);
1640 m_monitorManager->slotBlockMonitors();
1644 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1645 trackView->setDuration(trackView->duration());
1646 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1648 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1649 slotGotProgressInfo(QString(), -1);
1650 m_clipMonitor->refreshMonitor(true);
1651 m_projectMonitor->adjustRulerSize(trackView->duration());
1652 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1655 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1657 if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
1658 foreach(KAutoSaveFile *stale, staleFiles) {
1659 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1660 // show an error message; we could not steal the lockfile
1661 // maybe another application got to the file before us?
1665 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1666 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1667 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1668 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1673 void MainWindow::parseProfiles(const QString &mltPath)
1675 // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
1677 //KdenliveSettings::setDefaulttmpfolder();
1678 if (!mltPath.isEmpty()) {
1679 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1680 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1683 if (KdenliveSettings::mltpath().isEmpty()) {
1684 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1686 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1687 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1688 if (!QFile::exists(meltPath))
1689 meltPath = KStandardDirs::findExe("melt");
1690 KdenliveSettings::setRendererpath(meltPath);
1692 QStringList profilesFilter;
1693 profilesFilter << "*";
1694 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1696 if (profilesList.isEmpty()) {
1697 // Cannot find MLT path, try finding melt
1698 QString profilePath = KdenliveSettings::rendererpath();
1699 if (!profilePath.isEmpty()) {
1700 profilePath = profilePath.section('/', 0, -3);
1701 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1702 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1705 if (profilesList.isEmpty()) {
1706 // Cannot find the MLT profiles, ask for location
1707 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this);
1708 getUrl->fileDialog()->setMode(KFile::Directory);
1709 if (getUrl->exec() == QDialog::Rejected) {
1712 KUrl mltPath = getUrl->selectedUrl();
1714 if (mltPath.isEmpty()) ::exit(0);
1715 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1716 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1720 if (KdenliveSettings::rendererpath().isEmpty()) {
1721 // Cannot find the MLT melt renderer, ask for location
1722 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this);
1723 if (getUrl->exec() == QDialog::Rejected) {
1726 KUrl rendererPath = getUrl->selectedUrl();
1728 if (rendererPath.isEmpty()) ::exit(0);
1729 KdenliveSettings::setRendererpath(rendererPath.path());
1732 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1734 // Parse MLT profiles to build a list of available video formats
1735 if (profilesList.isEmpty()) parseProfiles();
1739 void MainWindow::slotEditProfiles()
1741 ProfilesDialog *w = new ProfilesDialog;
1742 if (w->exec() == QDialog::Accepted) {
1743 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1744 if (d) d->checkProfile();
1749 void MainWindow::slotDetectAudioDriver()
1751 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1752 leading to no audio output, see bug #934 */
1754 //decide which audio driver is really best, in some cases SDL is wrong
1755 if (KdenliveSettings::audiodrivername().isEmpty()) {
1757 KProcess readProcess;
1758 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1759 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1760 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1761 readProcess.setProgram("pactl", QStringList() << "stat");
1762 readProcess.execute(2000); // Kill it after 2 seconds
1764 QString result = QString(readProcess.readAllStandardOutput());
1765 kDebug() << "// / / / / / READING PACTL: ";
1767 if (!result.isEmpty()) {
1769 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1773 KdenliveSettings::setAutoaudiodrivername(driver);
1777 void MainWindow::slotEditProjectSettings()
1779 QPoint p = m_activeDocument->getTracksCount();
1780 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1782 if (w->exec() == QDialog::Accepted) {
1783 QString profile = w->selectedProfile();
1784 m_activeDocument->setProjectFolder(w->selectedFolder());
1785 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1786 if (m_activeDocument->profilePath() != profile) {
1787 // Profile was changed
1788 double dar = m_activeDocument->dar();
1790 // Deselect current effect / transition
1791 m_effectStack->slotClipItemSelected(NULL, 0);
1792 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1793 m_clipMonitor->slotSetXml(NULL);
1794 bool updateFps = m_activeDocument->setProfilePath(profile);
1795 KdenliveSettings::setCurrent_profile(profile);
1796 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1797 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1799 m_activeDocument->clipManager()->clearUnusedProducers();
1800 m_monitorManager->resetProfiles(m_activeDocument->timecode());
1802 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
1803 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
1804 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
1805 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1806 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
1807 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
1808 if (updateFps) m_activeTimeline->updateProjectFps();
1809 m_activeDocument->setModified(true);
1810 m_commandStack->activeStack()->clear();
1811 // We need to desactivate & reactivate monitors to get a refresh
1812 //m_monitorManager->switchMonitors();
1819 void MainWindow::slotRenderProject()
1821 if (!m_renderWidget) {
1822 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
1823 m_renderWidget = new RenderWidget(projectfolder, this);
1824 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
1825 connect(m_renderWidget, SIGNAL(selectedRenderProfile(const QString &, const QString &, const QString&)), this, SLOT(slotSetDocumentRenderProfile(const QString &, const QString &, const QString&)));
1826 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
1827 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
1828 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
1829 if (m_activeDocument) {
1830 m_renderWidget->setProfile(m_activeDocument->mltProfile());
1831 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
1832 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
1833 m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl"));
1836 /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1837 if (currentTab) m_renderWidget->setTimeline(currentTab);
1838 m_renderWidget->setDocument(m_activeDocument);*/
1839 m_renderWidget->show();
1840 m_renderWidget->showNormal();
1843 void MainWindow::setRenderingProgress(const QString &url, int progress)
1845 if (m_renderWidget) m_renderWidget->setRenderJob(url, progress);
1848 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
1850 if (m_renderWidget) m_renderWidget->setRenderStatus(url, status, error);
1853 void MainWindow::slotCleanProject()
1855 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
1856 m_projectList->cleanup();
1859 void MainWindow::slotUpdateMousePosition(int pos)
1861 if (m_activeDocument)
1862 switch (m_timecodeFormat->currentIndex()) {
1864 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
1867 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
1871 void MainWindow::slotUpdateDocumentState(bool modified)
1873 if (!m_activeDocument) return;
1874 setCaption(m_activeDocument->description(), modified);
1875 m_saveAction->setEnabled(modified);
1877 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
1878 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
1880 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
1881 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
1885 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
1887 if (m_activeDocument) {
1888 if (m_activeDocument == doc) return;
1889 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1891 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
1894 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
1896 //m_projectMonitor->stop();
1897 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1898 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
1899 if (m_activeDocument) {
1900 if (m_activeDocument == doc) return;
1901 if (m_activeTimeline) {
1902 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
1903 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
1904 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
1905 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
1906 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
1908 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1909 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1910 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1911 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1912 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1913 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1914 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
1915 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1916 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1917 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1918 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1919 disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
1920 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1921 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1922 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1923 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1924 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1925 disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1926 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1927 disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1928 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1929 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1930 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
1931 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
1932 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
1933 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
1934 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
1935 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
1936 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
1937 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
1938 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
1939 m_effectStack->clear();
1941 //m_activeDocument->setRenderer(NULL);
1942 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
1943 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1944 m_clipMonitor->stop();
1946 KdenliveSettings::setCurrent_profile(doc->profilePath());
1947 KdenliveSettings::setProject_fps(doc->fps());
1948 m_monitorManager->resetProfiles(doc->timecode());
1949 m_projectList->setDocument(doc);
1950 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
1951 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
1952 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
1953 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
1954 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
1955 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
1958 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
1959 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
1960 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
1961 connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int)));
1962 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
1963 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
1964 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
1965 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
1966 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
1967 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
1969 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
1970 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
1971 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
1972 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
1973 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
1975 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
1976 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
1977 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
1980 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
1981 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
1983 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
1984 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
1985 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
1986 m_zoomSlider->setValue(doc->zoom().x());
1987 connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
1988 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
1989 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
1990 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
1991 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
1993 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
1996 connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int)));
1997 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
1998 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool)));
1999 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int)));
2000 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2001 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2002 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2003 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2005 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2006 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2007 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2008 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2011 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
2012 m_activeTimeline = trackView;
2013 if (m_renderWidget) {
2014 m_renderWidget->setProfile(doc->mltProfile());
2015 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2016 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2017 m_renderWidget->setRenderProfile(doc->getDocumentProperty("renderdestination"), doc->getDocumentProperty("renderprofile"), doc->getDocumentProperty("renderurl"));
2019 //doc->setRenderer(m_projectMonitor->render);
2020 m_commandStack->setActiveStack(doc->commandStack());
2021 KdenliveSettings::setProject_display_ratio(doc->dar());
2022 //doc->clipManager()->checkAudioThumbs();
2024 //m_overView->setScene(trackView->projectScene());
2025 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2026 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2028 setCaption(doc->description(), doc->isModified());
2029 m_saveAction->setEnabled(doc->isModified());
2030 m_activeDocument = doc;
2031 m_activeTimeline->updateProjectFps();
2032 m_activeDocument->checkProjectClips();
2033 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2035 // set tool to select tool
2036 m_buttonSelectTool->setChecked(true);
2039 void MainWindow::slotZoneMoved(int start, int end)
2041 m_activeDocument->setZone(start, end);
2042 m_projectMonitor->slotZoneMoved(start, end);
2045 void MainWindow::slotGuidesUpdated()
2047 if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2050 void MainWindow::slotPreferences(int page, int option)
2052 //An instance of your dialog could be already created and could be
2053 // cached, in which case you want to display the cached dialog
2054 // instead of creating another one
2055 if (KConfigDialog::showDialog("settings")) {
2056 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2057 if (page != -1) d->showPage(page, option);
2061 // KConfigDialog didn't find an instance of this dialog, so lets
2063 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2064 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2065 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2066 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2067 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2069 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2071 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2073 if (page != -1) dialog->showPage(page, option);
2076 void MainWindow::slotUpdatePreviewSettings()
2078 if (m_activeDocument) {
2079 m_clipMonitor->slotSetXml(NULL);
2080 m_activeDocument->updatePreviewSettings();
2084 void MainWindow::updateConfiguration()
2086 //TODO: we should apply settings to all projects, not only the current one
2087 if (m_activeTimeline) {
2088 m_activeTimeline->refresh();
2089 m_activeTimeline->projectView()->checkAutoScroll();
2090 m_activeTimeline->projectView()->checkTrackHeight();
2091 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2093 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2094 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2096 // Update list of transcoding profiles
2098 #ifndef NO_JOGSHUTTLE
2099 activateShuttleDevice();
2100 #endif /* NO_JOGSHUTTLE */
2105 void MainWindow::slotSwitchVideoThumbs()
2107 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2108 if (m_activeTimeline) {
2109 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2111 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2114 void MainWindow::slotSwitchAudioThumbs()
2116 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2117 if (m_activeTimeline) {
2118 m_activeTimeline->refresh();
2119 m_activeTimeline->projectView()->checkAutoScroll();
2120 if (m_activeDocument) m_activeDocument->clipManager()->checkAudioThumbs();
2122 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2125 void MainWindow::slotSwitchMarkersComments()
2127 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2128 if (m_activeTimeline) {
2129 m_activeTimeline->refresh();
2131 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2134 void MainWindow::slotSwitchSnap()
2136 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2137 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2141 void MainWindow::slotDeleteTimelineClip()
2143 if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip();
2144 else if (m_activeTimeline) {
2145 m_activeTimeline->projectView()->deleteSelectedClips();
2149 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2151 if (m_clipMonitor->isActive()) m_clipMonitor->checkOverlay();
2152 m_clipMonitor->updateMarkers(clip);
2155 void MainWindow::slotAddClipMarker()
2157 DocClipBase *clip = NULL;
2159 if (m_projectMonitor->isActive()) {
2160 if (m_activeTimeline) {
2161 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2163 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2164 clip = item->baseClip();
2168 clip = m_clipMonitor->activeClip();
2169 pos = m_clipMonitor->position();
2172 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2175 QString id = clip->getId();
2176 CommentedTime marker(pos, i18n("Marker"));
2177 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2178 if (d.exec() == QDialog::Accepted) {
2179 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2183 void MainWindow::slotDeleteClipMarker()
2185 DocClipBase *clip = NULL;
2187 if (m_projectMonitor->isActive()) {
2188 if (m_activeTimeline) {
2189 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2191 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2192 clip = item->baseClip();
2196 clip = m_clipMonitor->activeClip();
2197 pos = m_clipMonitor->position();
2200 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2204 QString id = clip->getId();
2205 QString comment = clip->markerComment(pos);
2206 if (comment.isEmpty()) {
2207 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2210 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2213 void MainWindow::slotDeleteAllClipMarkers()
2215 DocClipBase *clip = NULL;
2216 if (m_projectMonitor->isActive()) {
2217 if (m_activeTimeline) {
2218 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2220 clip = item->baseClip();
2224 clip = m_clipMonitor->activeClip();
2227 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2230 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2233 void MainWindow::slotEditClipMarker()
2235 DocClipBase *clip = NULL;
2237 if (m_projectMonitor->isActive()) {
2238 if (m_activeTimeline) {
2239 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2241 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2242 clip = item->baseClip();
2246 clip = m_clipMonitor->activeClip();
2247 pos = m_clipMonitor->position();
2250 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2254 QString id = clip->getId();
2255 QString oldcomment = clip->markerComment(pos);
2256 if (oldcomment.isEmpty()) {
2257 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2261 CommentedTime marker(pos, oldcomment);
2262 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2263 if (d.exec() == QDialog::Accepted) {
2264 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2265 if (d.newMarker().time() != pos) {
2266 // remove old marker
2267 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2272 void MainWindow::slotAddGuide()
2274 if (m_activeTimeline)
2275 m_activeTimeline->projectView()->slotAddGuide();
2278 void MainWindow::slotInsertSpace()
2280 if (m_activeTimeline)
2281 m_activeTimeline->projectView()->slotInsertSpace();
2284 void MainWindow::slotRemoveSpace()
2286 if (m_activeTimeline)
2287 m_activeTimeline->projectView()->slotRemoveSpace();
2290 void MainWindow::slotInsertTrack(int ix)
2292 m_projectMonitor->activateMonitor();
2293 if (m_activeTimeline)
2294 m_activeTimeline->projectView()->slotInsertTrack(ix);
2297 void MainWindow::slotDeleteTrack(int ix)
2299 m_projectMonitor->activateMonitor();
2300 if (m_activeTimeline)
2301 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2304 void MainWindow::slotChangeTrack(int ix)
2306 m_projectMonitor->activateMonitor();
2307 if (m_activeTimeline)
2308 m_activeTimeline->projectView()->slotChangeTrack(ix);
2311 void MainWindow::slotEditGuide()
2313 if (m_activeTimeline)
2314 m_activeTimeline->projectView()->slotEditGuide();
2317 void MainWindow::slotDeleteGuide()
2319 if (m_activeTimeline)
2320 m_activeTimeline->projectView()->slotDeleteGuide();
2323 void MainWindow::slotDeleteAllGuides()
2325 if (m_activeTimeline)
2326 m_activeTimeline->projectView()->slotDeleteAllGuides();
2329 void MainWindow::slotCutTimelineClip()
2331 if (m_activeTimeline) {
2332 m_activeTimeline->projectView()->cutSelectedClips();
2336 void MainWindow::slotSelectTimelineClip()
2338 if (m_activeTimeline) {
2339 m_activeTimeline->projectView()->selectClip(true);
2343 void MainWindow::slotSelectTimelineTransition()
2345 if (m_activeTimeline) {
2346 m_activeTimeline->projectView()->selectTransition(true);
2350 void MainWindow::slotDeselectTimelineClip()
2352 if (m_activeTimeline) {
2353 m_activeTimeline->projectView()->selectClip(false, true);
2357 void MainWindow::slotDeselectTimelineTransition()
2359 if (m_activeTimeline) {
2360 m_activeTimeline->projectView()->selectTransition(false, true);
2364 void MainWindow::slotSelectAddTimelineClip()
2366 if (m_activeTimeline) {
2367 m_activeTimeline->projectView()->selectClip(true, true);
2371 void MainWindow::slotSelectAddTimelineTransition()
2373 if (m_activeTimeline) {
2374 m_activeTimeline->projectView()->selectTransition(true, true);
2378 void MainWindow::slotGroupClips()
2380 if (m_activeTimeline) {
2381 m_activeTimeline->projectView()->groupClips();
2385 void MainWindow::slotUnGroupClips()
2387 if (m_activeTimeline) {
2388 m_activeTimeline->projectView()->groupClips(false);
2392 void MainWindow::slotAddProjectClip(KUrl url)
2394 if (m_activeDocument)
2395 m_activeDocument->slotAddClipFile(url, QString());
2398 void MainWindow::slotAddTransition(QAction *result)
2400 if (!result) return;
2401 QStringList info = result->data().toStringList();
2402 if (info.isEmpty()) return;
2403 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2404 if (m_activeTimeline && !transition.isNull()) {
2405 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2409 void MainWindow::slotAddVideoEffect(QAction *result)
2411 if (!result) return;
2412 QStringList info = result->data().toStringList();
2413 if (info.isEmpty()) return;
2414 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2415 slotAddEffect(effect);
2418 void MainWindow::slotAddAudioEffect(QAction *result)
2420 if (!result) return;
2421 QStringList info = result->data().toStringList();
2422 if (info.isEmpty()) return;
2423 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2424 slotAddEffect(effect);
2427 void MainWindow::slotAddCustomEffect(QAction *result)
2429 if (!result) return;
2430 QStringList info = result->data().toStringList();
2431 if (info.isEmpty()) return;
2432 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2433 slotAddEffect(effect);
2436 void MainWindow::slotZoomIn()
2438 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2441 void MainWindow::slotZoomOut()
2443 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2446 void MainWindow::slotFitZoom()
2448 if (m_activeTimeline) {
2449 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2453 void MainWindow::slotSetZoom(int value)
2455 m_zoomSlider->setValue(value);
2458 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2460 m_statusProgressBar->setValue(progress);
2461 if (progress >= 0) {
2462 if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2463 m_statusProgressBar->setVisible(true);
2465 m_messageLabel->setMessage(QString(), DefaultMessage);
2466 m_statusProgressBar->setVisible(false);
2470 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2472 if (clip->clipType() == TEXT) {
2473 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2474 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2475 // template text clip
2477 // Get the list of existing templates
2479 filter << "*.kdenlivetitle";
2480 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2482 QDialog *dia = new QDialog(this);
2483 Ui::TemplateClip_UI dia_ui;
2484 dia_ui.setupUi(dia);
2486 const QString templatePath = clip->getProperty("resource");
2487 for (int i = 0; i < templateFiles.size(); ++i) {
2488 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2489 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2491 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2492 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2493 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2494 //warning: setting base directory doesn't work??
2495 KUrl startDir(titlepath);
2496 dia_ui.template_list->fileDialog()->setUrl(startDir);
2497 dia_ui.description->setText(clip->getProperty("description"));
2498 if (dia->exec() == QDialog::Accepted) {
2499 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2500 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2502 QMap <QString, QString> newprops;
2504 if (KUrl(textTemplate).path() != templatePath) {
2505 // The template was changed
2506 newprops.insert("resource", textTemplate);
2509 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2510 newprops.insert("description", dia_ui.description->toPlainText());
2513 QString newtemplate = newprops.value("xmltemplate");
2514 if (newtemplate.isEmpty()) newtemplate = templatePath;
2516 // template modified we need to update xmldata
2517 QString description = newprops.value("description");
2518 if (description.isEmpty()) description = clip->getProperty("description");
2519 else newprops.insert("templatetext", description);
2520 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2522 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2523 m_activeDocument->commandStack()->push(command);
2527 QString path = clip->getProperty("resource");
2528 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2530 doc.setContent(clip->getProperty("xmldata"));
2531 dia_ui->setXml(doc);
2532 if (dia_ui->exec() == QDialog::Accepted) {
2533 QMap <QString, QString> newprops;
2534 newprops.insert("xmldata", dia_ui->xml().toString());
2535 if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2536 // duration changed, we need to update duration
2537 newprops.insert("out", QString::number(dia_ui->duration()));
2539 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2540 m_activeDocument->commandStack()->push(command);
2541 m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2542 m_activeDocument->setModified(true);
2546 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2549 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2550 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2551 if (dia.exec() == QDialog::Accepted) {
2552 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true);
2553 m_activeDocument->commandStack()->push(command);
2555 if (dia.needsTimelineRefresh()) {
2556 // update clip occurences in timeline
2557 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2562 void MainWindow::customEvent(QEvent* e)
2564 if (e->type() == QEvent::User) {
2565 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2568 void MainWindow::slotActivateEffectStackView()
2570 m_effectStack->raiseWindow(m_effectStackDock);
2573 void MainWindow::slotActivateTransitionView(Transition *t)
2575 if (t) m_transitionConfig->raiseWindow(m_transitionConfigDock);
2578 void MainWindow::slotSnapRewind()
2580 if (m_projectMonitor->isActive()) {
2581 if (m_activeTimeline)
2582 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2583 } else m_clipMonitor->slotSeekToPreviousSnap();
2586 void MainWindow::slotSnapForward()
2588 if (m_projectMonitor->isActive()) {
2589 if (m_activeTimeline)
2590 m_activeTimeline->projectView()->slotSeekToNextSnap();
2591 } else m_clipMonitor->slotSeekToNextSnap();
2594 void MainWindow::slotClipStart()
2596 if (m_projectMonitor->isActive()) {
2597 if (m_activeTimeline)
2598 m_activeTimeline->projectView()->clipStart();
2602 void MainWindow::slotClipEnd()
2604 if (m_projectMonitor->isActive()) {
2605 if (m_activeTimeline)
2606 m_activeTimeline->projectView()->clipEnd();
2610 void MainWindow::slotZoneStart()
2612 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneStart();
2613 else m_clipMonitor->slotZoneStart();
2616 void MainWindow::slotZoneEnd()
2618 if (m_projectMonitor->isActive()) m_projectMonitor->slotZoneEnd();
2619 else m_clipMonitor->slotZoneEnd();
2622 void MainWindow::slotChangeTool(QAction * action)
2624 if (action == m_buttonSelectTool) slotSetTool(SELECTTOOL);
2625 else if (action == m_buttonRazorTool) slotSetTool(RAZORTOOL);
2626 else if (action == m_buttonSpacerTool) slotSetTool(SPACERTOOL);
2629 void MainWindow::slotChangeEdit(QAction * action)
2631 if (!m_activeTimeline) return;
2632 if (action == m_overwriteModeTool) m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2633 else if (action == m_insertModeTool) m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2634 else m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2637 void MainWindow::slotSetTool(PROJECTTOOL tool)
2639 if (m_activeDocument && m_activeTimeline) {
2640 //m_activeDocument->setTool(tool);
2644 message = i18n("Ctrl + click to use spacer on current track only");
2647 message = i18n("Click on a clip to cut it");
2650 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
2653 m_messageLabel->setMessage(message, InformationMessage);
2654 m_activeTimeline->projectView()->setTool(tool);
2658 void MainWindow::slotCopy()
2660 if (!m_activeDocument || !m_activeTimeline) return;
2661 m_activeTimeline->projectView()->copyClip();
2664 void MainWindow::slotPaste()
2666 if (!m_activeDocument || !m_activeTimeline) return;
2667 m_activeTimeline->projectView()->pasteClip();
2670 void MainWindow::slotPasteEffects()
2672 if (!m_activeDocument || !m_activeTimeline) return;
2673 m_activeTimeline->projectView()->pasteClipEffects();
2676 void MainWindow::slotFind()
2678 if (!m_activeDocument || !m_activeTimeline) return;
2679 m_projectSearch->setEnabled(false);
2680 m_findActivated = true;
2681 m_findString.clear();
2682 m_activeTimeline->projectView()->initSearchStrings();
2683 statusBar()->showMessage(i18n("Starting -- find text as you type"));
2684 m_findTimer.start(5000);
2685 qApp->installEventFilter(this);
2688 void MainWindow::slotFindNext()
2690 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString)) {
2691 statusBar()->showMessage(i18n("Found: %1", m_findString));
2693 statusBar()->showMessage(i18n("Reached end of project"));
2695 m_findTimer.start(4000);
2698 void MainWindow::findAhead()
2700 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
2701 m_projectSearchNext->setEnabled(true);
2702 statusBar()->showMessage(i18n("Found: %1", m_findString));
2704 m_projectSearchNext->setEnabled(false);
2705 statusBar()->showMessage(i18n("Not found: %1", m_findString));
2709 void MainWindow::findTimeout()
2711 m_projectSearchNext->setEnabled(false);
2712 m_findActivated = false;
2713 m_findString.clear();
2714 statusBar()->showMessage(i18n("Find stopped"), 3000);
2715 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
2716 m_projectSearch->setEnabled(true);
2717 removeEventFilter(this);
2720 void MainWindow::keyPressEvent(QKeyEvent *ke)
2722 if (m_findActivated) {
2723 if (ke->key() == Qt::Key_Backspace) {
2724 m_findString = m_findString.left(m_findString.length() - 1);
2726 if (!m_findString.isEmpty()) {
2732 m_findTimer.start(4000);
2735 } else if (ke->key() == Qt::Key_Escape) {
2739 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
2740 m_findString += ke->text();
2744 m_findTimer.start(4000);
2748 } else KXmlGuiWindow::keyPressEvent(ke);
2752 /** Gets called when the window gets hidden */
2753 void MainWindow::hideEvent(QHideEvent */*event*/)
2755 // kDebug() << "I was hidden";
2756 // issue http://www.kdenlive.org/mantis/view.php?id=231
2757 if (isMinimized()) {
2758 // kDebug() << "I am minimized";
2759 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
2763 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
2765 if (m_findActivated) {
2766 if (event->type() == QEvent::ShortcutOverride) {
2767 QKeyEvent* ke = (QKeyEvent*) event;
2768 if (ke->text().trimmed().isEmpty()) return false;
2771 } else return false;
2773 // pass the event on to the parent class
2774 return QMainWindow::eventFilter(obj, event);
2779 void MainWindow::slotSaveZone(Render *render, QPoint zone)
2781 KDialog *dialog = new KDialog(this);
2782 dialog->setCaption("Save clip zone");
2783 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
2785 QWidget *widget = new QWidget(dialog);
2786 dialog->setMainWidget(widget);
2788 QVBoxLayout *vbox = new QVBoxLayout(widget);
2789 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
2790 QString path = m_activeDocument->projectFolder().path();
2792 path.append("untitled.mlt");
2793 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
2794 url->setFilter("video/mlt-playlist");
2795 QLabel *label2 = new QLabel(i18n("Description:"), this);
2796 KLineEdit *edit = new KLineEdit(this);
2797 vbox->addWidget(label1);
2798 vbox->addWidget(url);
2799 vbox->addWidget(label2);
2800 vbox->addWidget(edit);
2801 if (dialog->exec() == QDialog::Accepted) render->saveZone(url->url(), edit->text(), zone);
2805 void MainWindow::slotSetInPoint()
2807 if (m_clipMonitor->isActive()) {
2808 m_clipMonitor->slotSetZoneStart();
2809 } else m_projectMonitor->slotSetZoneStart();
2810 //else m_activeTimeline->projectView()->setInPoint();
2813 void MainWindow::slotSetOutPoint()
2815 if (m_clipMonitor->isActive()) {
2816 m_clipMonitor->slotSetZoneEnd();
2817 } else m_projectMonitor->slotSetZoneEnd();
2818 // else m_activeTimeline->projectView()->setOutPoint();
2821 void MainWindow::slotResizeItemStart()
2823 if (m_activeTimeline) m_activeTimeline->projectView()->setInPoint();
2826 void MainWindow::slotResizeItemEnd()
2828 if (m_activeTimeline) m_activeTimeline->projectView()->setOutPoint();
2831 void MainWindow::slotGetNewLumaStuff()
2833 //KNS::Entry::List download();
2834 KNS::Entry::List entries = KNS::Engine::download();
2835 // list of changed entries
2836 kDebug() << "// PARSING KNS";
2837 foreach(KNS::Entry* entry, entries) {
2838 // care only about installed ones
2839 if (entry->status() == KNS::Entry::Installed) {
2840 foreach(const QString &file, entry->installedFiles()) {
2841 kDebug() << "// CURRENTLY INSTALLED: " << file;
2845 qDeleteAll(entries);
2846 initEffects::refreshLumas();
2847 m_activeTimeline->projectView()->reloadTransitionLumas();
2850 void MainWindow::slotGetNewRenderStuff()
2852 //KNS::Entry::List download();
2854 KNS::Engine engine(0);
2855 if (engine.init("kdenlive_render.knsrc")) {
2856 KNS::Entry::List entries = engine.downloadDialogModal(this);
2858 if (entries.size() > 0) {
2859 foreach(KNS::Entry* entry, entries) {
2860 // care only about installed ones
2861 if (entry->status() == KNS::Entry::Installed) {
2862 foreach(const QString &file, entry->installedFiles()) {
2863 kDebug() << "// CURRENTLY INSTALLED: " << file;
2868 if (m_renderWidget) m_renderWidget->reloadProfiles();
2872 void MainWindow::slotGetNewMltProfileStuff()
2874 //KNS::Entry::List download();
2876 KNS::Engine engine(0);
2877 if (engine.init("kdenlive_mltprofiles.knsrc")) {
2878 KNS::Entry::List entries = engine.downloadDialogModal(this);
2880 if (entries.size() > 0) {
2881 foreach(KNS::Entry* entry, entries) {
2882 // care only about installed ones
2883 if (entry->status() == KNS::Entry::Installed) {
2884 foreach(const QString &file, entry->installedFiles()) {
2885 kDebug() << "// CURRENTLY INSTALLED: " << file;
2890 // update the list of profiles in settings dialog
2891 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2892 if (d) d->checkProfile();
2897 void MainWindow::slotAutoTransition()
2899 if (m_activeTimeline) m_activeTimeline->projectView()->autoTransition();
2902 void MainWindow::slotSplitAudio()
2904 if (m_activeTimeline) m_activeTimeline->projectView()->splitAudio();
2907 void MainWindow::slotUpdateClipType(QAction *action)
2909 if (m_activeTimeline) {
2910 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
2911 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
2912 else m_activeTimeline->projectView()->setAudioAndVideo();
2916 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
2918 // We must stop the monitors since we create a new on in the dvd wizard
2919 m_clipMonitor->stop();
2920 m_projectMonitor->stop();
2921 DvdWizard w(url, profile, this);
2923 m_projectMonitor->start();
2926 void MainWindow::slotShowTimeline(bool show)
2928 if (show == false) {
2929 m_timelineState = saveState();
2930 centralWidget()->setHidden(true);
2932 centralWidget()->setHidden(false);
2933 restoreState(m_timelineState);
2937 void MainWindow::slotMaximizeCurrent(bool /*show*/)
2939 //TODO: is there a way to maximize current widget?
2942 m_timelineState = saveState();
2943 QWidget *par = focusWidget()->parentWidget();
2944 while (par->parentWidget() && par->parentWidget() != this) {
2945 par = par->parentWidget();
2947 kDebug() << "CURRENT WIDGET: " << par->objectName();
2950 //centralWidget()->setHidden(false);
2951 //restoreState(m_timelineState);
2955 void MainWindow::loadTranscoders()
2957 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
2960 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
2961 KConfigGroup transConfig(config, "Transcoding");
2963 QMap< QString, QString > profiles = transConfig.entryMap();
2964 QMapIterator<QString, QString> i(profiles);
2965 while (i.hasNext()) {
2967 QAction *a = transMenu->addAction(i.key());
2968 a->setData(i.value());
2969 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
2973 void MainWindow::slotTranscode(KUrl::List urls)
2976 if (urls.isEmpty()) {
2977 urls.append(m_projectList->currentClipUrl());
2978 QAction *action = qobject_cast<QAction *>(sender());
2979 params = action->data().toString();
2981 if (urls.isEmpty()) return;
2982 ClipTranscode *d = new ClipTranscode(urls, params);
2983 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
2985 //QProcess::startDetached("ffmpeg", parameters);
2988 void MainWindow::slotTranscodeClip()
2990 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
2991 if (urls.isEmpty()) return;
2992 slotTranscode(urls);
2995 void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
2997 if (m_activeDocument == NULL) return;
2998 m_activeDocument->setDocumentProperty("renderdestination", dest);
2999 m_activeDocument->setDocumentProperty("renderprofile", name);
3000 m_activeDocument->setDocumentProperty("renderurl", file);
3001 m_activeDocument->setModified(true);
3005 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3007 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3009 QString playlistPath;
3012 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3013 QString path = m_renderWidget->getFreeScriptName();
3014 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3015 if (!ok || scriptPath.isEmpty()) return;
3016 scriptPath.prepend(scriptsFolder);
3017 QFile f(scriptPath);
3019 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3022 playlistPath = scriptPath + ".mlt";
3023 m_projectMonitor->saveSceneList(playlistPath);
3025 KTemporaryFile temp;
3026 temp.setAutoRemove(false);
3027 temp.setSuffix(".mlt");
3029 playlistPath = temp.fileName();
3030 m_projectMonitor->saveSceneList(playlistPath);
3033 if (!chapterFile.isEmpty()) {
3036 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3038 in = m_activeTimeline->inPoint();
3039 out = m_activeTimeline->outPoint();
3042 QDomElement chapters = doc.createElement("chapters");
3043 chapters.setAttribute("fps", m_activeDocument->fps());
3044 doc.appendChild(chapters);
3046 QDomElement guidesxml = m_activeDocument->guidesXml();
3047 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3048 for (int i = 0; i < nodes.count(); i++) {
3049 QDomElement e = nodes.item(i).toElement();
3051 QString comment = e.attribute("comment");
3052 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3053 if (time >= in && time < out) {
3054 if (zoneOnly) time = time - in;
3055 QDomElement chapter = doc.createElement("chapter");
3056 chapters.appendChild(chapter);
3057 chapter.setAttribute("title", comment);
3058 chapter.setAttribute("time", time);
3062 if (chapters.childNodes().count() > 0) {
3063 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3064 // Always insert a guide in pos 0
3065 QDomElement chapter = doc.createElement("chapter");
3066 chapters.insertBefore(chapter, QDomNode());
3067 chapter.setAttribute("title", i18n("Start"));
3068 chapter.setAttribute("time", "0");
3070 // save chapters file
3071 QFile file(chapterFile);
3072 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3073 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3075 file.write(doc.toString().toUtf8());
3076 if (file.error() != QFile::NoError) {
3077 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3084 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
3087 void MainWindow::slotUpdateTimecodeFormat(int ix)
3089 KdenliveSettings::setFrametimecode(ix == 1);
3090 m_clipMonitor->updateTimecodeFormat();
3091 m_projectMonitor->updateTimecodeFormat();
3094 void MainWindow::slotRemoveFocus()
3096 statusBar()->setFocus();
3097 statusBar()->clearFocus();
3100 void MainWindow::slotRevert()
3102 if (KMessageBox::warningContinueCancel(this, i18n("This will delete all changes made since you last saved your project. Are you sure you want to continue?"), i18n("Revert to last saved version")) == KMessageBox::Cancel) return;
3103 KUrl url = m_activeDocument->url();
3104 closeCurrentDocument(false);
3105 doOpenFile(url, NULL);
3109 void MainWindow::slotShutdown()
3111 if (m_activeDocument) m_activeDocument->setModified(false);
3113 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3114 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3115 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3116 smserver.call("logout", 1, 2, 2);
3120 void MainWindow::slotUpdateTrackInfo()
3122 if (m_activeDocument)
3123 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3126 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3128 // Load the theme file
3130 if (action == NULL) theme = themename;
3131 else theme = action->data().toString();
3132 KdenliveSettings::setColortheme(theme);
3133 // Make palette for all widgets.
3135 if (theme.isEmpty())
3136 plt = QApplication::desktop()->palette();
3138 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3139 plt = KGlobalSettings::createApplicationPalette(config);
3142 kapp->setPalette(plt);
3143 const QObjectList children = statusBar()->children();
3145 foreach(QObject *child, children) {
3146 if (child->isWidgetType())
3147 ((QWidget*)child)->setPalette(plt);
3148 const QObjectList subchildren = child->children();
3149 foreach(QObject *subchild, subchildren) {
3150 if (subchild->isWidgetType())
3151 ((QWidget*)subchild)->setPalette(plt);
3157 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3159 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3160 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3161 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3162 const QSize bitsSize(24, 2);
3163 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3164 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3166 QPixmap pixmap(23, 16);
3167 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3169 KConfigGroup group(config, "WM");
3170 QPainter p(&pixmap);
3171 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3172 p.fillRect(1, 1, 7, 7, windowScheme.background());
3173 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3175 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3176 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3177 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3179 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3180 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3182 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3183 p.fillRect(1, 8, 7, 7, viewScheme.background());
3184 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3186 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3187 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3188 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3190 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3191 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3198 #include "mainwindow.moc"