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"
55 #include "vectorscope.h"
57 #include "rgbparade.h"
58 #include "histogram.h"
60 #include <KApplication>
64 #include <KActionCollection>
65 #include <KActionCategory>
66 #include <KStandardAction>
67 #include <KShortcutsDialog>
68 #include <KFileDialog>
69 #include <KMessageBox>
71 #include <KIO/NetAccess>
74 #include <KConfigDialog>
75 #include <KXMLGUIFactory>
77 #include <kstandarddirs.h>
78 #include <KUrlRequesterDialog>
79 #include <KTemporaryFile>
81 #include <KActionMenu>
84 #include <ktogglefullscreenaction.h>
86 #include <KNotification>
87 #include <KNotifyConfigWidget>
88 #if KDE_IS_VERSION(4,3,80)
89 #include <knewstuff3/downloaddialog.h>
90 #include <knewstuff3/knewstuffaction.h>
92 #include <knewstuff2/engine.h>
93 #include <knewstuff2/ui/knewstuffaction.h>
95 #endif /* KDE_IS_VERSION(4,3,80) */
97 #include <KColorScheme>
99 #include <QTextStream>
103 #include <QInputDialog>
104 #include <QDesktopWidget>
109 static const char version[] = VERSION;
111 static const int ID_TIMELINE_POS = 0;
118 EffectsList MainWindow::videoEffects;
119 EffectsList MainWindow::audioEffects;
120 EffectsList MainWindow::customEffects;
121 EffectsList MainWindow::transitions;
123 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
124 KXmlGuiWindow(parent),
125 m_activeDocument(NULL),
126 m_activeTimeline(NULL),
127 m_renderWidget(NULL),
128 #ifndef NO_JOGSHUTTLE
130 #endif /* NO_JOGSHUTTLE */
131 m_findActivated(false)
134 // Create DBus interface
135 new MainWindowAdaptor(this);
136 QDBusConnection dbus = QDBusConnection::sessionBus();
137 dbus.registerObject("/MainWindow", this);
139 setlocale(LC_NUMERIC, "POSIX");
140 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
141 setFont(KGlobalSettings::toolBarFont());
142 parseProfiles(MltPath);
143 m_commandStack = new QUndoGroup;
144 m_timelineArea = new KTabWidget(this);
145 m_timelineArea->setTabReorderingEnabled(true);
146 m_timelineArea->setTabBarHidden(true);
147 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
148 m_timelineArea->setMinimumHeight(200);
150 QToolButton *closeTabButton = new QToolButton;
151 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
152 closeTabButton->setIcon(KIcon("tab-close"));
153 closeTabButton->adjustSize();
154 closeTabButton->setToolTip(i18n("Close the current tab"));
155 m_timelineArea->setCornerWidget(closeTabButton);
156 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
158 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
159 m_findTimer.setSingleShot(true);
161 // FIXME: the next call returns a newly allocated object, which leaks
162 initEffects::parseEffectFiles();
163 //initEffects::parseCustomEffectsFile();
165 m_monitorManager = new MonitorManager();
167 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
168 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
173 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
174 m_projectListDock->setObjectName("project_tree");
175 m_projectList = new ProjectList();
176 m_projectListDock->setWidget(m_projectList);
177 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
179 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
180 m_clipMonitorDock->setObjectName("clip_monitor");
181 m_clipMonitor = new Monitor("clip", m_monitorManager, QString());
182 m_clipMonitorDock->setWidget(m_clipMonitor);
183 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
185 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
186 m_projectMonitorDock->setObjectName("project_monitor");
187 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
188 m_projectMonitorDock->setWidget(m_projectMonitor);
189 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
192 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
193 m_recMonitorDock->setObjectName("record_monitor");
194 m_recMonitor = new RecMonitor("record");
195 m_recMonitorDock->setWidget(m_recMonitor);
196 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
197 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
198 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
201 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
202 m_effectStackDock->setObjectName("effect_stack");
203 m_effectStack = new EffectStackView(m_projectMonitor);
204 m_effectStackDock->setWidget(m_effectStack);
205 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
207 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
208 m_transitionConfigDock->setObjectName("transition");
209 m_transitionConfig = new TransitionSettings(m_projectMonitor);
210 m_transitionConfigDock->setWidget(m_transitionConfig);
211 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
213 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
214 m_effectListDock->setObjectName("effect_list");
215 m_effectList = new EffectsListView();
216 m_effectListDock->setWidget(m_effectList);
217 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
219 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
220 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
221 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
222 m_vectorscopeDock->setWidget(m_vectorscope);
223 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
224 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
225 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
226 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
227 m_scopesList.append(m_vectorscopeDock);
229 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
230 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
231 m_waveformDock->setObjectName(m_waveform->widgetName());
232 m_waveformDock->setWidget(m_waveform);
233 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
234 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
235 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
236 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
237 m_scopesList.append(m_waveformDock);
239 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
240 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
241 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
242 m_RGBParadeDock->setWidget(m_RGBParade);
243 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
244 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
245 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
246 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
247 m_scopesList.append(m_RGBParadeDock);
249 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
250 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
251 m_histogramDock->setObjectName(m_histogram->widgetName());
252 m_histogramDock->setWidget(m_histogram);
253 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
254 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
255 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
256 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
257 m_scopesList.append(m_histogramDock);
260 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
261 m_undoViewDock->setObjectName("undo_history");
262 m_undoView = new QUndoView();
263 m_undoView->setCleanIcon(KIcon("edit-clear"));
264 m_undoView->setEmptyLabel(i18n("Clean"));
265 m_undoViewDock->setWidget(m_undoView);
266 m_undoView->setGroup(m_commandStack);
267 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
269 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
270 //overviewDock->setObjectName("project_overview");
271 //m_overView = new CustomTrackView(NULL, NULL, this);
272 //overviewDock->setWidget(m_overView);
273 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
278 /// Tabify Widgets ///
279 tabifyDockWidget(m_projectListDock, m_effectStackDock);
280 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
283 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
285 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
288 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
289 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
290 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
291 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
292 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
295 setCentralWidget(m_timelineArea);
298 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
299 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
301 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
302 m_fileRevert->setEnabled(false);
308 // Find QDockWidget tab bars and show / hide widget title bars on right click
309 QList <QTabBar *> tabs = findChildren<QTabBar *>();
310 for (int i = 0; i < tabs.count(); i++) {
311 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
312 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
315 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
316 guiFactory()->addClient(sp);*/
320 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
322 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone);
323 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
325 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
326 clipInTimeline->setIcon(KIcon("go-jump"));
327 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
328 static_cast<QMenu*>(factory()->container("transcoders", this)),
332 // build themes menus
333 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
334 QActionGroup *themegroup = new QActionGroup(this);
335 themegroup->setExclusive(true);
336 action = new KAction(i18n("Default"), this);
337 action->setCheckable(true);
338 themegroup->addAction(action);
339 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
341 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
343 for (int i = 0; i < schemeFiles.size(); ++i) {
345 const QString filename = schemeFiles.at(i);
346 const QFileInfo info(filename);
349 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
350 QIcon icon = createSchemePreviewIcon(config);
351 KConfigGroup group(config, "General");
352 const QString name = group.readEntry("Name", info.baseName());
353 action = new KAction(name, this);
354 action->setData(filename);
355 action->setIcon(icon);
356 action->setCheckable(true);
357 themegroup->addAction(action);
358 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
361 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
362 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
363 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
366 action = new QAction(fi.fileName(), this);
367 action->setData(*it);
368 action->setCheckable(true);
369 themegroup->addAction(action);
370 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
372 themesMenu->addActions(themegroup->actions());
373 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
375 // Setup and fill effects and transitions menus.
376 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
377 for (int i = 0; i < videoEffects.count(); ++i)
378 m_videoEffectsMenu->addAction(m_videoEffects[i]);
379 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
380 for (int i = 0; i < audioEffects.count(); ++i)
381 m_audioEffectsMenu->addAction(m_audioEffects[i]);
382 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
383 if (customEffects.isEmpty())
384 m_customEffectsMenu->setEnabled(false);
386 m_customEffectsMenu->setEnabled(true);
387 for (int i = 0; i < customEffects.count(); ++i)
388 m_customEffectsMenu->addAction(m_customEffects[i]);
389 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
390 for (int i = 0; i < transitions.count(); ++i)
391 m_transitionsMenu->addAction(m_transitions[i]);
393 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
394 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
395 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
396 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
398 QMenu *newEffect = new QMenu(this);
399 newEffect->addMenu(m_videoEffectsMenu);
400 newEffect->addMenu(m_audioEffectsMenu);
401 newEffect->addMenu(m_customEffectsMenu);
402 m_effectStack->setMenu(newEffect);
404 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
405 const QList<QAction *> viewActions = createPopupMenu()->actions();
406 viewMenu->insertActions(NULL, viewActions);
408 m_timelineContextMenu = new QMenu(this);
409 m_timelineContextClipMenu = new QMenu(this);
410 m_timelineContextTransitionMenu = new QMenu(this);
412 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
413 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
414 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
416 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
417 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
418 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
419 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
420 m_timelineContextClipMenu->addSeparator();
421 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
422 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
423 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
424 m_timelineContextClipMenu->addSeparator();
425 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
426 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
427 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
428 m_timelineContextClipMenu->addSeparator();
430 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
431 m_timelineContextClipMenu->addMenu(markersMenu);
432 m_timelineContextClipMenu->addSeparator();
433 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
434 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
435 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
436 //TODO: re-enable custom effects menu when it is implemented
437 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
439 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
440 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
441 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
443 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
445 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
446 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
447 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
448 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
449 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
450 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
451 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
453 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
454 slotConnectMonitors();
456 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
457 KdenliveSettings::setDropbframes(false);
459 // Open or create a file. Command line argument passed in Url has
460 // precedence, then "openlastproject", then just a plain empty file.
461 // If opening Url fails, openlastproject will _not_ be used.
462 if (!Url.isEmpty()) {
463 // delay loading so that the window shows up
465 QTimer::singleShot(500, this, SLOT(openFile()));
466 } else if (KdenliveSettings::openlastproject()) {
467 QTimer::singleShot(500, this, SLOT(openLastFile()));
468 } else { //if (m_timelineArea->count() == 0) {
472 if (!clipsToLoad.isEmpty() && m_activeDocument) {
473 QStringList list = clipsToLoad.split(',');
475 foreach(QString path, list) {
476 kDebug() << QDir::current().absoluteFilePath(path);
477 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
479 m_projectList->slotAddClip(urls);
482 #ifndef NO_JOGSHUTTLE
483 activateShuttleDevice();
484 #endif /* NO_JOGSHUTTLE */
485 m_projectListDock->raise();
488 MainWindow::~MainWindow()
490 m_effectStack->slotClipItemSelected(NULL, 0);
491 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
493 if (m_projectMonitor) m_projectMonitor->stop();
494 if (m_clipMonitor) m_clipMonitor->stop();
496 delete m_activeTimeline;
497 delete m_effectStack;
498 delete m_transitionConfig;
499 delete m_activeDocument;
500 delete m_projectMonitor;
501 delete m_clipMonitor;
502 delete m_shortcutRemoveFocus;
503 Mlt::Factory::close();
506 void MainWindow::queryQuit()
514 bool MainWindow::queryClose()
516 if (m_renderWidget) {
517 int waitingJobs = m_renderWidget->waitingJobsCount();
518 if (waitingJobs > 0) {
519 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")))) {
520 case KMessageBox::Yes :
521 // create script with waiting jobs and start it
522 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
524 case KMessageBox::No :
525 // Don't do anything, jobs will be deleted
533 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
534 // warn the user to save if document is modified and we have clips in our project list
535 if (m_activeDocument && m_activeDocument->isModified() &&
536 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
537 !m_projectList->documentClipList().isEmpty())) {
541 if (m_activeDocument->url().fileName().isEmpty())
542 message = i18n("Save changes to document?");
544 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
545 switch (KMessageBox::warningYesNoCancel(this, message)) {
546 case KMessageBox::Yes :
547 // save document here. If saving fails, return false;
549 case KMessageBox::No :
550 // User does not want to save the changes, clear recovery files
551 m_activeDocument->m_autosave->resize(0);
560 void MainWindow::loadPlugins()
562 foreach(QObject *plugin, QPluginLoader::staticInstances()) {
563 populateMenus(plugin);
566 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
568 filters << "libkdenlive*";
569 foreach(const QString &folder, directories) {
570 kDebug() << "Parsing plugin folder: " << folder;
571 QDir pluginsDir(folder);
572 foreach(const QString &fileName,
573 pluginsDir.entryList(filters, QDir::Files)) {
575 * Avoid loading the same plugin twice when there is more than one
578 if (!m_pluginFileNames.contains(fileName)) {
579 kDebug() << "Found plugin: " << fileName;
580 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
581 QObject *plugin = loader.instance();
583 populateMenus(plugin);
584 m_pluginFileNames += fileName;
586 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
592 void MainWindow::populateMenus(QObject *plugin)
594 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
595 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
597 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
601 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
602 QMenu *menu, const char *member,
603 QActionGroup *actionGroup)
605 kDebug() << "// ADD to MENU" << texts;
606 foreach(const QString &text, texts) {
607 QAction *action = new QAction(text, plugin);
608 action->setData(text);
609 connect(action, SIGNAL(triggered()), this, member);
610 menu->addAction(action);
613 action->setCheckable(true);
614 actionGroup->addAction(action);
619 void MainWindow::aboutPlugins()
621 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
626 void MainWindow::generateClip()
628 QAction *action = qobject_cast<QAction *>(sender());
629 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
631 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
632 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
633 if (!clipUrl.isEmpty()) {
634 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
638 void MainWindow::saveProperties(KConfigGroup &config)
640 // save properties here,used by session management
642 KMainWindow::saveProperties(config);
646 void MainWindow::readProperties(const KConfigGroup &config)
648 // read properties here,used by session management
649 KMainWindow::readProperties(config);
650 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
651 openFile(KUrl(Lastproject));
654 void MainWindow::slotReloadEffects()
656 m_customEffectsMenu->clear();
657 initEffects::parseCustomEffectsFile();
659 QStringList effectInfo;
660 QMap<QString, QStringList> effectsList;
661 for (int ix = 0; ix < customEffects.count(); ix++) {
662 effectInfo = customEffects.effectIdInfo(ix);
663 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
665 if (effectsList.isEmpty())
666 m_customEffectsMenu->setEnabled(false);
668 m_customEffectsMenu->setEnabled(true);
670 foreach(const QStringList &value, effectsList) {
671 action = new QAction(value.at(0), this);
672 action->setData(value);
673 m_customEffectsMenu->addAction(action);
675 m_effectList->reloadEffectList();
678 #ifndef NO_JOGSHUTTLE
679 void MainWindow::activateShuttleDevice()
683 if (KdenliveSettings::enableshuttle() == false) return;
684 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
685 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
686 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
687 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
688 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
689 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
690 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
693 void MainWindow::slotShuttleButton(int code)
697 slotShuttleAction(KdenliveSettings::shuttle1());
700 slotShuttleAction(KdenliveSettings::shuttle2());
703 slotShuttleAction(KdenliveSettings::shuttle3());
706 slotShuttleAction(KdenliveSettings::shuttle4());
709 slotShuttleAction(KdenliveSettings::shuttle5());
714 void MainWindow::slotShuttleAction(int code)
720 m_monitorManager->slotPlay();
723 m_monitorManager->slotPlay();
727 #endif /* NO_JOGSHUTTLE */
729 void MainWindow::configureNotifications()
731 KNotifyConfigWidget::configure(this);
734 void MainWindow::slotFullScreen()
736 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
739 void MainWindow::slotAddEffect(const QDomElement effect)
741 if (!m_activeDocument) return;
742 if (effect.isNull()) {
743 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
746 QDomElement effectToAdd = effect.cloneNode().toElement();
748 int ix = m_effectStack->isTrackMode(&ok);
749 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
750 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
753 void MainWindow::slotRaiseMonitor(bool clipMonitor)
755 if (clipMonitor) m_clipMonitorDock->raise();
756 else m_projectMonitorDock->raise();
759 void MainWindow::slotUpdateClip(const QString &id)
761 if (!m_activeDocument) return;
762 m_activeTimeline->projectView()->slotUpdateClip(id);
765 void MainWindow::slotConnectMonitors()
767 m_projectList->setRenderer(m_projectMonitor->render);
768 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
769 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
770 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
771 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
772 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
773 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
774 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)));
776 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
778 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
780 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
781 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
783 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
785 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
786 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
789 void MainWindow::slotAdjustClipMonitor()
791 m_clipMonitorDock->updateGeometry();
792 m_clipMonitorDock->adjustSize();
793 m_clipMonitor->resetSize();
796 void MainWindow::slotAdjustProjectMonitor()
798 m_projectMonitorDock->updateGeometry();
799 m_projectMonitorDock->adjustSize();
800 m_projectMonitor->resetSize();
803 void MainWindow::setupActions()
806 KActionCollection* collection = actionCollection();
807 m_timecodeFormat = new KComboBox(this);
808 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
809 m_timecodeFormat->addItem(i18n("Frames"));
810 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
811 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
813 m_statusProgressBar = new QProgressBar(this);
814 m_statusProgressBar->setMinimum(0);
815 m_statusProgressBar->setMaximum(100);
816 m_statusProgressBar->setMaximumWidth(150);
817 m_statusProgressBar->setVisible(false);
819 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
820 toolbar->setMovable(false);
821 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
822 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
823 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
824 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
825 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
826 QString style1 = QString("QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid transparent;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:hover { background: rgb(%7, %8, %9);border-style: inset; border:1px solid rgb(%7, %8, %9);border-radius: 3px;} QToolButton:checked { background-color: rgb(%1, %2, %3); border-style: inset; border:1px solid rgb(%4, %5, %6);border-radius: 3px;}").arg(buttonBg.red()).arg(buttonBg.green()).arg(buttonBg.blue()).arg(buttonBord.red()).arg(buttonBord.green()).arg(buttonBord.blue()).arg(buttonBord2.red()).arg(buttonBord2.green()).arg(buttonBord2.blue());
827 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
829 //create edit mode buttons
830 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
831 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
832 toolbar->addAction(m_normalEditTool);
833 m_normalEditTool->setCheckable(true);
834 m_normalEditTool->setChecked(true);
836 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
837 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
838 toolbar->addAction(m_overwriteEditTool);
839 m_overwriteEditTool->setCheckable(true);
840 m_overwriteEditTool->setChecked(false);
842 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
843 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
844 toolbar->addAction(m_insertEditTool);
845 m_insertEditTool->setCheckable(true);
846 m_insertEditTool->setChecked(false);
847 // not implemented yet
848 m_insertEditTool->setEnabled(false);
850 QActionGroup *editGroup = new QActionGroup(this);
851 editGroup->addAction(m_normalEditTool);
852 editGroup->addAction(m_overwriteEditTool);
853 editGroup->addAction(m_insertEditTool);
854 editGroup->setExclusive(true);
855 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
856 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
858 toolbar->addSeparator();
860 // create tools buttons
861 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
862 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
863 toolbar->addAction(m_buttonSelectTool);
864 m_buttonSelectTool->setCheckable(true);
865 m_buttonSelectTool->setChecked(true);
867 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
868 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
869 toolbar->addAction(m_buttonRazorTool);
870 m_buttonRazorTool->setCheckable(true);
871 m_buttonRazorTool->setChecked(false);
873 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
874 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
875 toolbar->addAction(m_buttonSpacerTool);
876 m_buttonSpacerTool->setCheckable(true);
877 m_buttonSpacerTool->setChecked(false);
879 QActionGroup *toolGroup = new QActionGroup(this);
880 toolGroup->addAction(m_buttonSelectTool);
881 toolGroup->addAction(m_buttonRazorTool);
882 toolGroup->addAction(m_buttonSpacerTool);
883 toolGroup->setExclusive(true);
884 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
886 QWidget * actionWidget;
887 int max = toolbar->iconSizeDefault() + 2;
888 actionWidget = toolbar->widgetForAction(m_normalEditTool);
889 actionWidget->setMaximumWidth(max);
890 actionWidget->setMaximumHeight(max - 4);
892 actionWidget = toolbar->widgetForAction(m_insertEditTool);
893 actionWidget->setMaximumWidth(max);
894 actionWidget->setMaximumHeight(max - 4);
896 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
897 actionWidget->setMaximumWidth(max);
898 actionWidget->setMaximumHeight(max - 4);
900 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
901 actionWidget->setMaximumWidth(max);
902 actionWidget->setMaximumHeight(max - 4);
904 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
905 actionWidget->setMaximumWidth(max);
906 actionWidget->setMaximumHeight(max - 4);
908 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
909 actionWidget->setMaximumWidth(max);
910 actionWidget->setMaximumHeight(max - 4);
912 toolbar->setStyleSheet(style1);
913 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
915 toolbar->addSeparator();
916 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
917 toolbar->addAction(m_buttonFitZoom);
918 m_buttonFitZoom->setCheckable(false);
920 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
921 toolbar->addAction(m_zoomOut);
922 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
924 m_zoomSlider = new QSlider(Qt::Horizontal, this);
925 m_zoomSlider->setMaximum(13);
926 m_zoomSlider->setPageStep(1);
927 m_zoomSlider->setInvertedAppearance(true);
929 m_zoomSlider->setMaximumWidth(150);
930 m_zoomSlider->setMinimumWidth(100);
931 toolbar->addWidget(m_zoomSlider);
933 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
934 toolbar->addAction(m_zoomIn);
935 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
937 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
938 actionWidget->setMaximumWidth(max);
939 actionWidget->setMaximumHeight(max - 4);
940 actionWidget->setStyleSheet(styleBorderless);
942 actionWidget = toolbar->widgetForAction(m_zoomIn);
943 actionWidget->setMaximumWidth(max);
944 actionWidget->setMaximumHeight(max - 4);
945 actionWidget->setStyleSheet(styleBorderless);
947 actionWidget = toolbar->widgetForAction(m_zoomOut);
948 actionWidget->setMaximumWidth(max);
949 actionWidget->setMaximumHeight(max - 4);
950 actionWidget->setStyleSheet(styleBorderless);
952 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
953 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
954 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
955 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
956 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
958 toolbar->addSeparator();
960 //create automatic audio split button
961 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
962 toolbar->addAction(m_buttonAutomaticSplitAudio);
963 m_buttonAutomaticSplitAudio->setCheckable(true);
964 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
965 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
967 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
968 toolbar->addAction(m_buttonVideoThumbs);
969 m_buttonVideoThumbs->setCheckable(true);
970 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
971 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
973 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
974 toolbar->addAction(m_buttonAudioThumbs);
975 m_buttonAudioThumbs->setCheckable(true);
976 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
977 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
979 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
980 toolbar->addAction(m_buttonShowMarkers);
981 m_buttonShowMarkers->setCheckable(true);
982 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
983 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
985 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
986 toolbar->addAction(m_buttonSnap);
987 m_buttonSnap->setCheckable(true);
988 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
989 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
991 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
992 actionWidget->setMaximumWidth(max);
993 actionWidget->setMaximumHeight(max - 4);
995 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
999 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1000 actionWidget->setMaximumWidth(max);
1001 actionWidget->setMaximumHeight(max - 4);
1003 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1004 actionWidget->setMaximumWidth(max);
1005 actionWidget->setMaximumHeight(max - 4);
1007 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1008 actionWidget->setMaximumWidth(max);
1009 actionWidget->setMaximumHeight(max - 4);
1011 m_messageLabel = new StatusBarMessageLabel(this);
1012 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1014 statusBar()->addWidget(m_messageLabel, 10);
1015 statusBar()->addWidget(m_statusProgressBar, 0);
1016 statusBar()->addPermanentWidget(toolbar);
1017 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1018 statusBar()->addPermanentWidget(m_timecodeFormat);
1019 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1021 collection->addAction("normal_mode", m_normalEditTool);
1022 collection->addAction("overwrite_mode", m_overwriteEditTool);
1023 collection->addAction("insert_mode", m_insertEditTool);
1024 collection->addAction("select_tool", m_buttonSelectTool);
1025 collection->addAction("razor_tool", m_buttonRazorTool);
1026 collection->addAction("spacer_tool", m_buttonSpacerTool);
1028 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1029 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1030 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1031 collection->addAction("show_markers", m_buttonShowMarkers);
1032 collection->addAction("snap", m_buttonSnap);
1033 collection->addAction("zoom_fit", m_buttonFitZoom);
1034 collection->addAction("zoom_in", m_zoomIn);
1035 collection->addAction("zoom_out", m_zoomOut);
1037 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1038 collection->addAction("project_find", m_projectSearch);
1039 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1040 m_projectSearch->setShortcut(Qt::Key_Slash);
1042 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1043 collection->addAction("project_find_next", m_projectSearchNext);
1044 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1045 m_projectSearchNext->setShortcut(Qt::Key_F3);
1046 m_projectSearchNext->setEnabled(false);
1048 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1049 collection->addAction("manage_profiles", profilesAction);
1050 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1052 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1053 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1054 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1055 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1057 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1058 collection->addAction("run_wizard", wizAction);
1059 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1061 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1062 collection->addAction("project_settings", projectAction);
1063 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1065 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1066 collection->addAction("project_render", projectRender);
1067 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1068 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1070 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1071 collection->addAction("project_clean", projectClean);
1072 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1074 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1075 KShortcut playShortcut;
1076 playShortcut.setPrimary(Qt::Key_Space);
1077 playShortcut.setAlternate(Qt::Key_K);
1078 monitorPlay->setShortcut(playShortcut);
1079 collection->addAction("monitor_play", monitorPlay);
1080 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1082 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1083 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1084 collection->addAction("monitor_play_zone", m_playZone);
1085 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1087 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1088 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1089 collection->addAction("monitor_loop_zone", m_loopZone);
1090 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1092 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1093 collection->addAction("dvd_wizard", dvdWizard);
1094 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1096 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1097 collection->addAction("transcode_clip", transcodeClip);
1098 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1100 KAction *markIn = collection->addAction("mark_in");
1101 markIn->setText(i18n("Set Zone In"));
1102 markIn->setShortcut(Qt::Key_I);
1103 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1105 KAction *markOut = collection->addAction("mark_out");
1106 markOut->setText(i18n("Set Zone Out"));
1107 markOut->setShortcut(Qt::Key_O);
1108 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1110 KAction *switchMon = collection->addAction("switch_monitor");
1111 switchMon->setText(i18n("Switch monitor"));
1112 switchMon->setShortcut(Qt::Key_T);
1113 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1115 KAction *insertTree = collection->addAction("insert_project_tree");
1116 insertTree->setText(i18n("Insert zone in project tree"));
1117 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1118 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1120 KAction *insertTimeline = collection->addAction("insert_timeline");
1121 insertTimeline->setText(i18n("Insert zone in timeline"));
1122 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1123 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1125 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1126 collection->addAction("resize_timeline_clip_start", resizeStart);
1127 resizeStart->setShortcut(Qt::Key_1);
1128 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1130 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1131 collection->addAction("resize_timeline_clip_end", resizeEnd);
1132 resizeEnd->setShortcut(Qt::Key_2);
1133 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1135 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1136 monitorSeekBackward->setShortcut(Qt::Key_J);
1137 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1138 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1140 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1141 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1142 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1143 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1145 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1146 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1147 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1148 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1150 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1151 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1152 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1153 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1155 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1156 monitorSeekForward->setShortcut(Qt::Key_L);
1157 collection->addAction("monitor_seek_forward", monitorSeekForward);
1158 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1160 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1161 clipStart->setShortcut(Qt::Key_Home);
1162 collection->addAction("seek_clip_start", clipStart);
1163 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1165 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1166 clipEnd->setShortcut(Qt::Key_End);
1167 collection->addAction("seek_clip_end", clipEnd);
1168 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1170 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1171 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1172 collection->addAction("seek_zone_start", zoneStart);
1173 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1175 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1176 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1177 collection->addAction("seek_zone_end", zoneEnd);
1178 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1180 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1181 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1182 collection->addAction("seek_start", projectStart);
1183 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1185 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1186 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1187 collection->addAction("seek_end", projectEnd);
1188 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1190 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1191 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1192 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1193 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1195 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1196 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1197 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1198 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1200 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1201 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1202 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1203 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1205 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1206 deleteItem->setShortcut(Qt::Key_Delete);
1207 collection->addAction("delete_timeline_clip", deleteItem);
1208 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1210 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1211 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1212 editTimelineClipSpeed->setData("change_speed");
1213 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1215 KAction *stickTransition = collection->addAction("auto_transition");
1216 stickTransition->setData(QString("auto"));
1217 stickTransition->setCheckable(true);
1218 stickTransition->setEnabled(false);
1219 stickTransition->setText(i18n("Automatic Transition"));
1220 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1222 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1223 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1224 collection->addAction("group_clip", groupClip);
1225 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1227 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1228 collection->addAction("ungroup_clip", ungroupClip);
1229 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1230 ungroupClip->setData("ungroup_clip");
1231 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1233 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1234 collection->addAction("edit_item_duration", editItemDuration);
1235 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1237 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1238 collection->addAction("clip_in_project_tree", clipInProjectTree);
1239 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1241 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1242 collection->addAction("clip_to_project_tree", clipToProjectTree);
1243 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1245 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1246 insertOvertwrite->setShortcut(Qt::Key_V);
1247 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1248 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1250 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1251 selectTimelineClip->setShortcut(Qt::Key_Plus);
1252 collection->addAction("select_timeline_clip", selectTimelineClip);
1253 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1255 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1256 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1257 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1258 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1260 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1261 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1262 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1263 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1265 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1266 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1267 collection->addAction("select_timeline_transition", selectTimelineTransition);
1268 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1270 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1271 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1272 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1273 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1275 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1276 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1277 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1278 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1280 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1281 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1282 collection->addAction("cut_timeline_clip", cutTimelineClip);
1283 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1285 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1286 collection->addAction("add_clip_marker", addClipMarker);
1287 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1289 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1290 collection->addAction("delete_clip_marker", deleteClipMarker);
1291 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1293 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1294 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1295 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1297 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1298 collection->addAction("edit_clip_marker", editClipMarker);
1299 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1301 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1302 collection->addAction("split_audio", splitAudio);
1303 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1305 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1306 collection->addAction("clip_audio_only", audioOnly);
1307 audioOnly->setData("clip_audio_only");
1308 audioOnly->setCheckable(true);
1310 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1311 collection->addAction("clip_video_only", videoOnly);
1312 videoOnly->setData("clip_video_only");
1313 videoOnly->setCheckable(true);
1315 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1316 collection->addAction("clip_audio_and_video", audioAndVideo);
1317 audioAndVideo->setData("clip_audio_and_video");
1318 audioAndVideo->setCheckable(true);
1320 m_clipTypeGroup = new QActionGroup(this);
1321 m_clipTypeGroup->addAction(audioOnly);
1322 m_clipTypeGroup->addAction(videoOnly);
1323 m_clipTypeGroup->addAction(audioAndVideo);
1324 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1325 m_clipTypeGroup->setEnabled(false);
1327 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1328 collection->addAction("insert_space", insertSpace);
1329 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1331 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1332 collection->addAction("delete_space", removeSpace);
1333 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1335 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1336 collection->addAction("insert_track", insertTrack);
1337 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1339 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1340 collection->addAction("delete_track", deleteTrack);
1341 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1343 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1344 collection->addAction("config_tracks", configTracks);
1345 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1347 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1348 collection->addAction("add_guide", addGuide);
1349 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1351 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1352 collection->addAction("delete_guide", delGuide);
1353 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1355 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1356 collection->addAction("edit_guide", editGuide);
1357 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1359 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1360 collection->addAction("delete_all_guides", delAllGuides);
1361 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1363 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1364 collection->addAction("paste_effects", pasteEffects);
1365 pasteEffects->setData("paste_effects");
1366 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1368 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1369 collection->addAction("show_timeline", showTimeline);
1370 showTimeline->setCheckable(true);
1371 showTimeline->setChecked(true);
1372 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1374 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1375 collection->addAction("show_titlebars", showTitleBar);
1376 showTitleBar->setCheckable(true);
1377 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1378 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1379 slotShowTitleBars(KdenliveSettings::showtitlebars());
1381 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1382 collection->addAction("maximize_current", maxCurrent);
1383 maxCurrent->setCheckable(true);
1384 maxCurrent->setChecked(false);
1385 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1387 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1388 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1389 KStandardAction::open(this, SLOT(openFile()), collection);
1390 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1391 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1392 KStandardAction::openNew(this, SLOT(newFile()), collection);
1393 // TODO: make the following connection to slotEditKeys work
1394 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1395 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1396 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1397 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1398 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1399 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1401 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1402 undo->setEnabled(false);
1403 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1405 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1406 redo->setEnabled(false);
1407 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1410 //TODO: Add status tooltip to actions ?
1411 connect(collection, SIGNAL(actionHovered(QAction*)),
1412 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1415 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1416 collection->addAction("add_clip", addClip);
1417 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1419 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1420 collection->addAction("add_color_clip", addColorClip);
1421 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1423 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1424 collection->addAction("add_slide_clip", addSlideClip);
1425 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1427 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1428 collection->addAction("add_text_clip", addTitleClip);
1429 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1431 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1432 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1433 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1435 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1436 collection->addAction("add_folder", addFolderButton);
1437 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1439 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1440 collection->addAction("clip_properties", clipProperties);
1441 clipProperties->setData("clip_properties");
1442 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1443 clipProperties->setEnabled(false);
1445 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1446 collection->addAction("edit_clip", openClip);
1447 openClip->setData("edit_clip");
1448 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1449 openClip->setEnabled(false);
1451 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1452 collection->addAction("delete_clip", deleteClip);
1453 deleteClip->setData("delete_clip");
1454 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1455 deleteClip->setEnabled(false);
1457 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1458 collection->addAction("reload_clip", reloadClip);
1459 reloadClip->setData("reload_clip");
1460 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1461 reloadClip->setEnabled(false);
1463 QMenu *addClips = new QMenu();
1464 addClips->addAction(addClip);
1465 addClips->addAction(addColorClip);
1466 addClips->addAction(addSlideClip);
1467 addClips->addAction(addTitleClip);
1468 addClips->addAction(addTitleTemplateClip);
1469 addClips->addAction(addFolderButton);
1471 addClips->addAction(reloadClip);
1472 addClips->addAction(clipProperties);
1473 addClips->addAction(openClip);
1474 addClips->addAction(deleteClip);
1475 m_projectList->setupMenu(addClips, addClip);
1477 // Setup effects and transitions actions.
1478 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1479 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1480 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1481 m_videoEffects = new KAction*[videoEffects.count()];
1482 for (int i = 0; i < videoEffects.count(); ++i) {
1483 QStringList effectInfo = videoEffects.effectIdInfo(i);
1484 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1485 m_videoEffects[i]->setData(effectInfo);
1486 m_videoEffects[i]->setIconVisibleInMenu(false);
1487 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1489 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1490 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1491 m_audioEffects = new KAction*[audioEffects.count()];
1492 for (int i = 0; i < audioEffects.count(); ++i) {
1493 QStringList effectInfo = audioEffects.effectIdInfo(i);
1494 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1495 m_audioEffects[i]->setData(effectInfo);
1496 m_audioEffects[i]->setIconVisibleInMenu(false);
1497 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1499 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1500 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1501 m_customEffects = new KAction*[customEffects.count()];
1502 for (int i = 0; i < customEffects.count(); ++i) {
1503 QStringList effectInfo = customEffects.effectIdInfo(i);
1504 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1505 m_customEffects[i]->setData(effectInfo);
1506 m_customEffects[i]->setIconVisibleInMenu(false);
1507 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1509 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1510 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1511 m_transitions = new KAction*[transitions.count()];
1512 for (int i = 0; i < transitions.count(); i++) {
1513 QStringList effectInfo = transitions.effectIdInfo(i);
1514 m_transitions[i] = new KAction(effectInfo.at(0), this);
1515 m_transitions[i]->setData(effectInfo);
1516 m_transitions[i]->setIconVisibleInMenu(false);
1517 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1519 m_effectsActionCollection->readSettings();
1521 //connect(collection, SIGNAL( clearStatusText() ),
1522 //statusBar(), SLOT( clear() ) );
1525 void MainWindow::slotDisplayActionMessage(QAction *a)
1527 statusBar()->showMessage(a->data().toString(), 3000);
1530 void MainWindow::saveOptions()
1532 KdenliveSettings::self()->writeConfig();
1533 KSharedConfigPtr config = KGlobal::config();
1534 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1535 KConfigGroup treecolumns(config, "Project Tree");
1536 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1540 void MainWindow::readOptions()
1542 KSharedConfigPtr config = KGlobal::config();
1543 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1544 KConfigGroup initialGroup(config, "version");
1545 bool upgrade = false;
1546 if (initialGroup.exists()) {
1547 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1551 if (initialGroup.readEntry("version") == "0.7") {
1552 //Add new settings from 0.7.1
1553 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1554 QString path = QDir::homePath() + "/kdenlive";
1555 if (KStandardDirs::makeDir(path) == false) {
1556 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1557 } else KdenliveSettings::setDefaultprojectfolder(path);
1563 if (!initialGroup.exists() || upgrade) {
1564 // this is our first run, show Wizard
1565 Wizard *w = new Wizard(upgrade, this);
1566 if (w->exec() == QDialog::Accepted && w->isOk()) {
1567 w->adjustSettings();
1568 initialGroup.writeEntry("version", version);
1574 KConfigGroup treecolumns(config, "Project Tree");
1575 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1576 if (!state.isEmpty())
1577 m_projectList->setHeaderInfo(state);
1580 void MainWindow::slotRunWizard()
1582 Wizard *w = new Wizard(false, this);
1583 if (w->exec() == QDialog::Accepted && w->isOk()) {
1584 w->adjustSettings();
1589 void MainWindow::newFile(bool showProjectSettings, bool force)
1591 if (!m_timelineArea->isEnabled() && !force)
1593 m_fileRevert->setEnabled(false);
1594 QString profileName = KdenliveSettings::default_profile();
1595 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1596 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1597 if (!showProjectSettings) {
1598 if (!KdenliveSettings::activatetabs())
1599 if (!closeCurrentDocument())
1602 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1603 if (w->exec() != QDialog::Accepted)
1605 if (!KdenliveSettings::activatetabs())
1606 if (!closeCurrentDocument())
1608 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1609 slotSwitchVideoThumbs();
1610 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1611 slotSwitchAudioThumbs();
1612 profileName = w->selectedProfile();
1613 projectFolder = w->selectedFolder();
1614 projectTracks = w->tracks();
1617 m_timelineArea->setEnabled(true);
1618 m_projectList->setEnabled(true);
1619 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, this);
1620 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1622 TrackView *trackView = new TrackView(doc, &ok, this);
1623 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1626 //m_timelineArea->setEnabled(false);
1627 //m_projectList->setEnabled(false);
1631 if (m_timelineArea->count() == 1) {
1632 connectDocumentInfo(doc);
1633 connectDocument(trackView, doc);
1635 m_timelineArea->setTabBarHidden(false);
1636 m_monitorManager->activateMonitor("clip");
1637 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1640 void MainWindow::activateDocument()
1642 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1643 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1644 KdenliveDoc *currentDoc = currentTab->document();
1645 connectDocumentInfo(currentDoc);
1646 connectDocument(currentTab, currentDoc);
1649 bool MainWindow::closeCurrentDocument(bool saveChanges)
1651 QWidget *w = m_timelineArea->currentWidget();
1652 if (!w) return true;
1653 // closing current document
1654 int ix = m_timelineArea->currentIndex() + 1;
1655 if (ix == m_timelineArea->count()) ix = 0;
1656 m_timelineArea->setCurrentIndex(ix);
1657 TrackView *tabToClose = (TrackView *) w;
1658 KdenliveDoc *docToClose = tabToClose->document();
1659 if (docToClose && docToClose->isModified() && saveChanges) {
1661 if (m_activeDocument->url().fileName().isEmpty())
1662 message = i18n("Save changes to document?");
1664 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1665 switch (KMessageBox::warningYesNoCancel(this, message)) {
1666 case KMessageBox::Yes :
1667 // save document here. If saving fails, return false;
1668 if (saveFile() == false) return false;
1670 case KMessageBox::Cancel :
1677 m_clipMonitor->slotSetXml(NULL);
1678 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1679 if (m_timelineArea->count() == 1) {
1680 m_timelineArea->setTabBarHidden(true);
1681 m_closeAction->setEnabled(false);
1683 if (docToClose == m_activeDocument) {
1684 delete m_activeDocument;
1685 m_activeDocument = NULL;
1686 m_effectStack->clear();
1687 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1691 if (w == m_activeTimeline) {
1692 delete m_activeTimeline;
1693 m_activeTimeline = NULL;
1700 bool MainWindow::saveFileAs(const QString &outputFileName)
1702 QString currentSceneList;
1703 m_monitorManager->stopActiveMonitor();
1704 if (KdenliveSettings::dropbframes()) {
1705 KdenliveSettings::setDropbframes(false);
1706 m_activeDocument->clipManager()->updatePreviewSettings();
1707 currentSceneList = m_projectMonitor->sceneList();
1708 KdenliveSettings::setDropbframes(true);
1709 m_activeDocument->clipManager()->updatePreviewSettings();
1710 } else currentSceneList = m_projectMonitor->sceneList();
1712 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1715 // Save timeline thumbnails
1716 m_activeTimeline->projectView()->saveThumbnails();
1717 m_activeDocument->setUrl(KUrl(outputFileName));
1718 if (m_activeDocument->m_autosave == NULL) {
1719 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1720 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1721 setCaption(m_activeDocument->description());
1722 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1723 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1724 m_activeDocument->setModified(false);
1725 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1726 m_fileRevert->setEnabled(true);
1730 bool MainWindow::saveFileAs()
1732 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1733 if (outputFile.isEmpty()) {
1736 if (QFile::exists(outputFile)) {
1737 // Show the file dialog again if the user does not want to overwrite the file
1738 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1739 return saveFileAs();
1741 return saveFileAs(outputFile);
1744 bool MainWindow::saveFile()
1746 if (!m_activeDocument) return true;
1747 if (m_activeDocument->url().isEmpty()) {
1748 return saveFileAs();
1750 bool result = saveFileAs(m_activeDocument->url().path());
1751 m_activeDocument->m_autosave->resize(0);
1756 void MainWindow::openFile()
1758 if (!m_startUrl.isEmpty()) {
1759 openFile(m_startUrl);
1760 m_startUrl = KUrl();
1763 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1764 if (url.isEmpty()) return;
1765 m_fileOpenRecent->addUrl(url);
1769 void MainWindow::openLastFile()
1771 KSharedConfigPtr config = KGlobal::config();
1772 KUrl::List urls = m_fileOpenRecent->urls();
1773 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1774 if (urls.isEmpty()) newFile(false);
1775 else openFile(urls.last());
1778 void MainWindow::openFile(const KUrl &url)
1780 // Check if the document is already opened
1781 const int ct = m_timelineArea->count();
1782 bool isOpened = false;
1784 for (i = 0; i < ct; i++) {
1785 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1786 KdenliveDoc *doc = tab->document();
1787 if (doc->url() == url) {
1793 m_timelineArea->setCurrentIndex(i);
1797 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1799 // Check for backup file
1800 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1801 if (!staleFiles.isEmpty()) {
1802 if (KMessageBox::questionYesNo(this,
1803 i18n("Auto-saved files exist. Do you want to recover them now?"),
1804 i18n("File Recovery"),
1805 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1806 recoverFiles(staleFiles);
1809 // remove the stale files
1810 foreach(KAutoSaveFile *stale, staleFiles) {
1811 stale->open(QIODevice::ReadWrite);
1816 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1817 m_messageLabel->repaint();
1818 doOpenFile(url, NULL);
1821 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1823 if (!m_timelineArea->isEnabled()) return;
1824 m_fileRevert->setEnabled(true);
1825 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, this);
1826 if (stale == NULL) {
1827 stale = new KAutoSaveFile(url, doc);
1828 doc->m_autosave = stale;
1830 doc->m_autosave = stale;
1831 doc->setUrl(stale->managedFile());
1832 doc->setModified(true);
1833 stale->setParent(doc);
1835 connectDocumentInfo(doc);
1837 TrackView *trackView = new TrackView(doc, &ok, this);
1838 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1840 m_timelineArea->setEnabled(false);
1841 m_projectList->setEnabled(false);
1842 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1843 slotGotProgressInfo(QString(), -1);
1844 newFile(false, true);
1847 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1848 trackView->setDuration(trackView->duration());
1849 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1851 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1852 slotGotProgressInfo(QString(), -1);
1853 m_projectMonitor->adjustRulerSize(trackView->duration());
1854 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1855 m_clipMonitor->refreshMonitor(true);
1858 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1860 foreach(KAutoSaveFile *stale, staleFiles) {
1861 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1862 // show an error message; we could not steal the lockfile
1863 // maybe another application got to the file before us?
1867 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1868 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1869 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1870 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1874 void MainWindow::parseProfiles(const QString &mltPath)
1876 //KdenliveSettings::setDefaulttmpfolder();
1877 if (!mltPath.isEmpty()) {
1878 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
1879 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
1882 if (KdenliveSettings::mltpath().isEmpty())
1883 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
1885 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
1886 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
1887 if (!QFile::exists(meltPath))
1888 meltPath = KStandardDirs::findExe("melt");
1889 KdenliveSettings::setRendererpath(meltPath);
1892 if (KdenliveSettings::rendererpath().isEmpty()) {
1893 // Cannot find the MLT melt renderer, ask for location
1894 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
1895 if (getUrl->exec() == QDialog::Rejected) {
1898 KUrl rendererPath = getUrl->selectedUrl();
1900 if (rendererPath.isEmpty()) ::exit(0);
1901 KdenliveSettings::setRendererpath(rendererPath.path());
1904 QStringList profilesFilter;
1905 profilesFilter << "*";
1906 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1907 if (profilesList.isEmpty()) {
1908 // Cannot find MLT path, try finding melt
1909 QString profilePath = KdenliveSettings::rendererpath();
1910 if (!profilePath.isEmpty()) {
1911 profilePath = profilePath.section('/', 0, -3);
1912 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
1913 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1915 if (profilesList.isEmpty()) {
1916 // Cannot find the MLT profiles, ask for location
1917 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
1918 getUrl->fileDialog()->setMode(KFile::Directory);
1919 if (getUrl->exec() == QDialog::Rejected) {
1922 KUrl mltPath = getUrl->selectedUrl();
1924 if (mltPath.isEmpty()) ::exit(0);
1925 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
1926 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
1930 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
1932 // Parse again MLT profiles to build a list of available video formats
1933 if (profilesList.isEmpty()) parseProfiles();
1937 void MainWindow::slotEditProfiles()
1939 ProfilesDialog *w = new ProfilesDialog;
1940 if (w->exec() == QDialog::Accepted) {
1941 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
1942 if (d) d->checkProfile();
1947 void MainWindow::slotDetectAudioDriver()
1949 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
1950 leading to no audio output, see bug #934 */
1952 //decide which audio driver is really best, in some cases SDL is wrong
1953 if (KdenliveSettings::audiodrivername().isEmpty()) {
1955 KProcess readProcess;
1956 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
1957 if (!KStandardDirs::findExe("pactl").isEmpty()) {
1958 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
1959 readProcess.setProgram("pactl", QStringList() << "stat");
1960 readProcess.execute(2000); // Kill it after 2 seconds
1962 QString result = QString(readProcess.readAllStandardOutput());
1963 kDebug() << "// / / / / / READING PACTL: ";
1965 if (!result.isEmpty()) {
1967 kDebug() << "// / / / / PULSEAUDIO DETECTED";
1971 KdenliveSettings::setAutoaudiodrivername(driver);
1975 void MainWindow::slotEditProjectSettings()
1977 QPoint p = m_activeDocument->getTracksCount();
1978 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
1980 if (w->exec() == QDialog::Accepted) {
1981 QString profile = w->selectedProfile();
1982 m_activeDocument->setProjectFolder(w->selectedFolder());
1983 if (m_renderWidget) m_renderWidget->setDocumentPath(w->selectedFolder().path(KUrl::AddTrailingSlash));
1984 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
1985 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
1986 if (m_activeDocument->profilePath() != profile) {
1987 // Profile was changed
1988 double dar = m_activeDocument->dar();
1990 // Deselect current effect / transition
1991 m_effectStack->slotClipItemSelected(NULL, 0);
1992 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1993 m_clipMonitor->slotSetXml(NULL);
1994 bool updateFps = m_activeDocument->setProfilePath(profile);
1995 KdenliveSettings::setCurrent_profile(profile);
1996 KdenliveSettings::setProject_fps(m_activeDocument->fps());
1997 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
1999 m_activeDocument->clipManager()->clearUnusedProducers();
2000 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2002 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2003 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2004 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2005 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2006 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2007 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2008 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2009 if (updateFps) m_activeTimeline->updateProjectFps();
2010 m_activeDocument->setModified(true);
2011 m_commandStack->activeStack()->clear();
2012 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2013 slotUpdateMousePosition(0);
2014 // We need to desactivate & reactivate monitors to get a refresh
2015 //m_monitorManager->switchMonitors();
2022 void MainWindow::slotRenderProject()
2024 if (!m_renderWidget) {
2025 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2026 m_renderWidget = new RenderWidget(projectfolder, this);
2027 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2028 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2029 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2030 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2031 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2032 if (m_activeDocument) {
2033 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2034 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2035 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2036 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2039 slotCheckRenderStatus();
2040 m_renderWidget->show();
2041 m_renderWidget->showNormal();
2043 // What are the following lines supposed to do?
2044 //m_activeTimeline->tracksNumber();
2045 //m_renderWidget->enableAudio(false);
2046 //m_renderWidget->export_audio;
2049 void MainWindow::slotCheckRenderStatus()
2051 // Make sure there are no missing clips
2053 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2056 void MainWindow::setRenderingProgress(const QString &url, int progress)
2059 m_renderWidget->setRenderJob(url, progress);
2062 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2065 m_renderWidget->setRenderStatus(url, status, error);
2068 void MainWindow::slotCleanProject()
2070 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2071 m_projectList->cleanup();
2074 void MainWindow::slotUpdateMousePosition(int pos)
2076 if (m_activeDocument)
2077 switch (m_timecodeFormat->currentIndex()) {
2079 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2082 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2086 void MainWindow::slotUpdateDocumentState(bool modified)
2088 if (!m_activeDocument) return;
2089 setCaption(m_activeDocument->description(), modified);
2090 m_saveAction->setEnabled(modified);
2092 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2093 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2095 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2096 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2100 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2102 if (m_activeDocument) {
2103 if (m_activeDocument == doc) return;
2104 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2106 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2109 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2111 //m_projectMonitor->stop();
2112 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2113 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2114 if (m_activeDocument) {
2115 if (m_activeDocument == doc) return;
2116 if (m_activeTimeline) {
2117 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2118 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2119 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2120 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2121 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2122 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2123 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2125 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2126 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2127 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2128 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2129 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2130 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2131 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2132 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2133 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2134 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2135 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2136 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2137 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2138 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2139 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2140 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2141 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2142 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2143 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2144 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2145 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2146 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2147 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2148 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2149 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2150 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2151 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2152 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2153 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2154 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2155 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2156 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2157 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2158 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2159 m_effectStack->clear();
2161 //m_activeDocument->setRenderer(NULL);
2162 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2163 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2164 m_clipMonitor->stop();
2166 KdenliveSettings::setCurrent_profile(doc->profilePath());
2167 KdenliveSettings::setProject_fps(doc->fps());
2168 m_monitorManager->resetProfiles(doc->timecode());
2169 m_projectList->setDocument(doc);
2170 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2171 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2172 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2173 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2174 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2176 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2177 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2179 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2182 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2183 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2184 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2185 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2186 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2187 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2188 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2189 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2190 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2191 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2192 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2193 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2194 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2195 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2197 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2198 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2199 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2200 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2201 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2203 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2204 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2205 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2208 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2209 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2210 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2211 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2213 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2214 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2215 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2216 m_zoomSlider->setValue(doc->zoom().x());
2217 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2218 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2219 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2220 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2222 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2223 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2226 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2227 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2228 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2229 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2230 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2231 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2232 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2233 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2234 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2235 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2236 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2238 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2239 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2240 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2241 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2242 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2245 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2246 m_activeTimeline = trackView;
2247 if (m_renderWidget) {
2248 slotCheckRenderStatus();
2249 m_renderWidget->setProfile(doc->mltProfile());
2250 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2251 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2252 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2254 //doc->setRenderer(m_projectMonitor->render);
2255 m_commandStack->setActiveStack(doc->commandStack());
2256 KdenliveSettings::setProject_display_ratio(doc->dar());
2257 //doc->clipManager()->checkAudioThumbs();
2259 //m_overView->setScene(trackView->projectScene());
2260 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2261 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2263 setCaption(doc->description(), doc->isModified());
2264 m_saveAction->setEnabled(doc->isModified());
2265 m_normalEditTool->setChecked(true);
2266 m_activeDocument = doc;
2267 m_activeTimeline->updateProjectFps();
2268 m_activeDocument->checkProjectClips();
2269 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2270 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2271 slotUpdateMousePosition(0);
2272 // set tool to select tool
2273 m_buttonSelectTool->setChecked(true);
2276 void MainWindow::slotZoneMoved(int start, int end)
2278 m_activeDocument->setZone(start, end);
2279 m_projectMonitor->slotZoneMoved(start, end);
2282 void MainWindow::slotGuidesUpdated()
2285 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2288 void MainWindow::slotEditKeys()
2290 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2291 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2292 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2296 void MainWindow::slotPreferences(int page, int option)
2298 //An instance of your dialog could be already created and could be
2299 // cached, in which case you want to display the cached dialog
2300 // instead of creating another one
2301 if (KConfigDialog::showDialog("settings")) {
2302 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2303 if (page != -1) d->showPage(page, option);
2307 // KConfigDialog didn't find an instance of this dialog, so lets
2309 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2310 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2311 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2312 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2313 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2315 connect(dialog, SIGNAL(updateCaptureFolder()), m_recMonitor, SLOT(slotUpdateCaptureFolder()));
2317 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2319 if (page != -1) dialog->showPage(page, option);
2322 void MainWindow::slotUpdatePreviewSettings()
2324 if (m_activeDocument) {
2325 m_clipMonitor->slotSetXml(NULL);
2326 m_activeDocument->updatePreviewSettings();
2330 void MainWindow::updateConfiguration()
2332 //TODO: we should apply settings to all projects, not only the current one
2333 if (m_activeTimeline) {
2334 m_activeTimeline->refresh();
2335 m_activeTimeline->projectView()->checkAutoScroll();
2336 m_activeTimeline->projectView()->checkTrackHeight();
2337 if (m_activeDocument)
2338 m_activeDocument->clipManager()->checkAudioThumbs();
2340 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2341 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2342 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2343 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2345 // Update list of transcoding profiles
2347 #ifndef NO_JOGSHUTTLE
2348 activateShuttleDevice();
2349 #endif /* NO_JOGSHUTTLE */
2353 void MainWindow::slotSwitchSplitAudio()
2355 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2356 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2359 void MainWindow::slotSwitchVideoThumbs()
2361 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2362 if (m_activeTimeline)
2363 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2364 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2367 void MainWindow::slotSwitchAudioThumbs()
2369 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2370 if (m_activeTimeline) {
2371 m_activeTimeline->refresh();
2372 m_activeTimeline->projectView()->checkAutoScroll();
2373 if (m_activeDocument)
2374 m_activeDocument->clipManager()->checkAudioThumbs();
2376 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2379 void MainWindow::slotSwitchMarkersComments()
2381 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2382 if (m_activeTimeline)
2383 m_activeTimeline->refresh();
2384 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2387 void MainWindow::slotSwitchSnap()
2389 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2390 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2394 void MainWindow::slotDeleteItem()
2396 if (QApplication::focusWidget() &&
2397 QApplication::focusWidget()->parentWidget() &&
2398 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2399 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2400 m_projectList->slotRemoveClip();
2403 QWidget *widget = QApplication::focusWidget();
2405 if (widget == m_effectStackDock) {
2406 m_effectStack->slotItemDel();
2409 widget = widget->parentWidget();
2412 // effect stack has no focus
2413 if (m_activeTimeline)
2414 m_activeTimeline->projectView()->deleteSelectedClips();
2418 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2420 if (m_clipMonitor->isActive())
2421 m_clipMonitor->checkOverlay();
2422 m_clipMonitor->updateMarkers(clip);
2425 void MainWindow::slotAddClipMarker()
2427 DocClipBase *clip = NULL;
2429 if (m_projectMonitor->isActive()) {
2430 if (m_activeTimeline) {
2431 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2433 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2434 clip = item->baseClip();
2438 clip = m_clipMonitor->activeClip();
2439 pos = m_clipMonitor->position();
2442 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2445 QString id = clip->getId();
2446 CommentedTime marker(pos, i18n("Marker"));
2447 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2448 if (d.exec() == QDialog::Accepted)
2449 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2452 void MainWindow::slotDeleteClipMarker()
2454 DocClipBase *clip = NULL;
2456 if (m_projectMonitor->isActive()) {
2457 if (m_activeTimeline) {
2458 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2460 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2461 clip = item->baseClip();
2465 clip = m_clipMonitor->activeClip();
2466 pos = m_clipMonitor->position();
2469 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2473 QString id = clip->getId();
2474 QString comment = clip->markerComment(pos);
2475 if (comment.isEmpty()) {
2476 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2479 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2482 void MainWindow::slotDeleteAllClipMarkers()
2484 DocClipBase *clip = NULL;
2485 if (m_projectMonitor->isActive()) {
2486 if (m_activeTimeline) {
2487 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2489 clip = item->baseClip();
2493 clip = m_clipMonitor->activeClip();
2496 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2499 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2502 void MainWindow::slotEditClipMarker()
2504 DocClipBase *clip = NULL;
2506 if (m_projectMonitor->isActive()) {
2507 if (m_activeTimeline) {
2508 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2510 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2511 clip = item->baseClip();
2515 clip = m_clipMonitor->activeClip();
2516 pos = m_clipMonitor->position();
2519 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2523 QString id = clip->getId();
2524 QString oldcomment = clip->markerComment(pos);
2525 if (oldcomment.isEmpty()) {
2526 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2530 CommentedTime marker(pos, oldcomment);
2531 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2532 if (d.exec() == QDialog::Accepted) {
2533 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2534 if (d.newMarker().time() != pos) {
2535 // remove old marker
2536 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2541 void MainWindow::slotAddGuide()
2543 if (m_activeTimeline)
2544 m_activeTimeline->projectView()->slotAddGuide();
2547 void MainWindow::slotInsertSpace()
2549 if (m_activeTimeline)
2550 m_activeTimeline->projectView()->slotInsertSpace();
2553 void MainWindow::slotRemoveSpace()
2555 if (m_activeTimeline)
2556 m_activeTimeline->projectView()->slotRemoveSpace();
2559 void MainWindow::slotInsertTrack(int ix)
2561 m_projectMonitor->activateMonitor();
2562 if (m_activeTimeline)
2563 m_activeTimeline->projectView()->slotInsertTrack(ix);
2564 if (m_activeDocument)
2565 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2568 void MainWindow::slotDeleteTrack(int ix)
2570 m_projectMonitor->activateMonitor();
2571 if (m_activeTimeline)
2572 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2573 if (m_activeDocument)
2574 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2577 void MainWindow::slotConfigTrack(int ix)
2579 m_projectMonitor->activateMonitor();
2580 if (m_activeTimeline)
2581 m_activeTimeline->projectView()->slotConfigTracks(ix);
2582 if (m_activeDocument)
2583 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2586 void MainWindow::slotEditGuide()
2588 if (m_activeTimeline)
2589 m_activeTimeline->projectView()->slotEditGuide();
2592 void MainWindow::slotDeleteGuide()
2594 if (m_activeTimeline)
2595 m_activeTimeline->projectView()->slotDeleteGuide();
2598 void MainWindow::slotDeleteAllGuides()
2600 if (m_activeTimeline)
2601 m_activeTimeline->projectView()->slotDeleteAllGuides();
2604 void MainWindow::slotCutTimelineClip()
2606 if (m_activeTimeline)
2607 m_activeTimeline->projectView()->cutSelectedClips();
2610 void MainWindow::slotInsertClipOverwrite()
2612 if (m_activeTimeline) {
2613 QStringList data = m_clipMonitor->getZoneInfo();
2614 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2618 void MainWindow::slotSelectTimelineClip()
2620 if (m_activeTimeline)
2621 m_activeTimeline->projectView()->selectClip(true);
2624 void MainWindow::slotSelectTimelineTransition()
2626 if (m_activeTimeline)
2627 m_activeTimeline->projectView()->selectTransition(true);
2630 void MainWindow::slotDeselectTimelineClip()
2632 if (m_activeTimeline)
2633 m_activeTimeline->projectView()->selectClip(false, true);
2636 void MainWindow::slotDeselectTimelineTransition()
2638 if (m_activeTimeline)
2639 m_activeTimeline->projectView()->selectTransition(false, true);
2642 void MainWindow::slotSelectAddTimelineClip()
2644 if (m_activeTimeline)
2645 m_activeTimeline->projectView()->selectClip(true, true);
2648 void MainWindow::slotSelectAddTimelineTransition()
2650 if (m_activeTimeline)
2651 m_activeTimeline->projectView()->selectTransition(true, true);
2654 void MainWindow::slotGroupClips()
2656 if (m_activeTimeline)
2657 m_activeTimeline->projectView()->groupClips();
2660 void MainWindow::slotUnGroupClips()
2662 if (m_activeTimeline)
2663 m_activeTimeline->projectView()->groupClips(false);
2666 void MainWindow::slotEditItemDuration()
2668 if (m_activeTimeline)
2669 m_activeTimeline->projectView()->editItemDuration();
2672 void MainWindow::slotAddProjectClip(KUrl url)
2674 if (m_activeDocument)
2675 m_activeDocument->slotAddClipFile(url, QString());
2678 void MainWindow::slotAddTransition(QAction *result)
2680 if (!result) return;
2681 QStringList info = result->data().toStringList();
2682 if (info.isEmpty()) return;
2683 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2684 if (m_activeTimeline && !transition.isNull()) {
2685 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2689 void MainWindow::slotAddVideoEffect(QAction *result)
2691 if (!result) return;
2692 QStringList info = result->data().toStringList();
2693 if (info.isEmpty()) return;
2694 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2695 slotAddEffect(effect);
2698 void MainWindow::slotAddAudioEffect(QAction *result)
2700 if (!result) return;
2701 QStringList info = result->data().toStringList();
2702 if (info.isEmpty()) return;
2703 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2704 slotAddEffect(effect);
2707 void MainWindow::slotAddCustomEffect(QAction *result)
2709 if (!result) return;
2710 QStringList info = result->data().toStringList();
2711 if (info.isEmpty()) return;
2712 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2713 slotAddEffect(effect);
2716 void MainWindow::slotZoomIn()
2718 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2719 slotShowZoomSliderToolTip();
2722 void MainWindow::slotZoomOut()
2724 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2725 slotShowZoomSliderToolTip();
2728 void MainWindow::slotFitZoom()
2730 if (m_activeTimeline)
2731 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2734 void MainWindow::slotSetZoom(int value)
2736 value = qMax(m_zoomSlider->minimum(), value);
2737 value = qMin(m_zoomSlider->maximum(), value);
2739 if (m_activeTimeline)
2740 m_activeTimeline->slotChangeZoom(value);
2742 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2743 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2744 slotUpdateZoomSliderToolTip(value);
2746 m_zoomSlider->blockSignals(true);
2747 m_zoomSlider->setValue(value);
2748 m_zoomSlider->blockSignals(false);
2751 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2753 if (zoomlevel != -1)
2754 slotUpdateZoomSliderToolTip(zoomlevel);
2756 QPoint global = m_zoomSlider->rect().topLeft();
2757 global.ry() += m_zoomSlider->height() / 2;
2758 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2759 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2762 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2764 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2767 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2769 m_statusProgressBar->setValue(progress);
2770 if (progress >= 0) {
2771 if (!message.isEmpty())
2772 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2773 m_statusProgressBar->setVisible(true);
2774 } else if (progress == -2) {
2775 if (!message.isEmpty())
2776 m_messageLabel->setMessage(message, ErrorMessage);
2777 m_statusProgressBar->setVisible(false);
2779 m_messageLabel->setMessage(QString(), DefaultMessage);
2780 m_statusProgressBar->setVisible(false);
2784 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2786 if (clip->clipType() == TEXT) {
2787 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2788 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2789 // template text clip
2791 // Get the list of existing templates
2793 filter << "*.kdenlivetitle";
2794 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2796 QDialog *dia = new QDialog(this);
2797 Ui::TemplateClip_UI dia_ui;
2798 dia_ui.setupUi(dia);
2800 const QString templatePath = clip->getProperty("resource");
2801 for (int i = 0; i < templateFiles.size(); ++i) {
2802 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2803 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2805 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2806 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2807 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2808 //warning: setting base directory doesn't work??
2809 KUrl startDir(titlepath);
2810 dia_ui.template_list->fileDialog()->setUrl(startDir);
2811 dia_ui.description->setText(clip->getProperty("description"));
2812 if (dia->exec() == QDialog::Accepted) {
2813 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2814 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2816 QMap <QString, QString> newprops;
2818 if (KUrl(textTemplate).path() != templatePath) {
2819 // The template was changed
2820 newprops.insert("resource", textTemplate);
2823 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2824 newprops.insert("description", dia_ui.description->toPlainText());
2827 QString newtemplate = newprops.value("xmltemplate");
2828 if (newtemplate.isEmpty()) newtemplate = templatePath;
2830 // template modified we need to update xmldata
2831 QString description = newprops.value("description");
2832 if (description.isEmpty()) description = clip->getProperty("description");
2833 else newprops.insert("templatetext", description);
2834 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2835 if (!newprops.isEmpty()) {
2836 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2837 m_activeDocument->commandStack()->push(command);
2843 QString path = clip->getProperty("resource");
2844 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2846 doc.setContent(clip->getProperty("xmldata"));
2847 dia_ui->setXml(doc);
2848 if (dia_ui->exec() == QDialog::Accepted) {
2849 QMap <QString, QString> newprops;
2850 newprops.insert("xmldata", dia_ui->xml().toString());
2851 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
2852 // duration changed, we need to update duration
2853 newprops.insert("out", QString::number(dia_ui->outPoint()));
2855 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2856 m_activeDocument->commandStack()->push(command);
2857 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
2858 m_activeDocument->setModified(true);
2862 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
2866 // any type of clip but a title
2867 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
2868 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
2869 if (dia.exec() == QDialog::Accepted) {
2870 QMap <QString, QString> newprops = dia.properties();
2871 if (newprops.isEmpty()) return;
2872 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2873 m_activeDocument->commandStack()->push(command);
2874 m_activeDocument->setModified();
2876 if (dia.needsTimelineRefresh()) {
2877 // update clip occurences in timeline
2878 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
2884 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
2886 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
2887 if (dia.exec() == QDialog::Accepted) {
2888 QUndoCommand *command = new QUndoCommand();
2889 command->setText(i18n("Edit clips"));
2890 for (int i = 0; i < cliplist.count(); i++) {
2891 DocClipBase *clip = cliplist.at(i);
2892 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
2894 m_activeDocument->commandStack()->push(command);
2895 for (int i = 0; i < cliplist.count(); i++)
2896 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
2900 void MainWindow::customEvent(QEvent* e)
2902 if (e->type() == QEvent::User)
2903 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
2905 void MainWindow::slotActivateEffectStackView()
2907 m_effectStack->raiseWindow(m_effectStackDock);
2910 void MainWindow::slotActivateTransitionView(Transition *t)
2913 m_transitionConfig->raiseWindow(m_transitionConfigDock);
2916 void MainWindow::slotSnapRewind()
2918 if (m_projectMonitor->isActive()) {
2919 if (m_activeTimeline)
2920 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
2922 m_clipMonitor->slotSeekToPreviousSnap();
2926 void MainWindow::slotSnapForward()
2928 if (m_projectMonitor->isActive()) {
2929 if (m_activeTimeline)
2930 m_activeTimeline->projectView()->slotSeekToNextSnap();
2932 m_clipMonitor->slotSeekToNextSnap();
2936 void MainWindow::slotClipStart()
2938 if (m_projectMonitor->isActive()) {
2939 if (m_activeTimeline)
2940 m_activeTimeline->projectView()->clipStart();
2944 void MainWindow::slotClipEnd()
2946 if (m_projectMonitor->isActive()) {
2947 if (m_activeTimeline)
2948 m_activeTimeline->projectView()->clipEnd();
2952 void MainWindow::slotZoneStart()
2954 if (m_projectMonitor->isActive())
2955 m_projectMonitor->slotZoneStart();
2957 m_clipMonitor->slotZoneStart();
2960 void MainWindow::slotZoneEnd()
2962 if (m_projectMonitor->isActive())
2963 m_projectMonitor->slotZoneEnd();
2965 m_clipMonitor->slotZoneEnd();
2968 void MainWindow::slotChangeTool(QAction * action)
2970 if (action == m_buttonSelectTool)
2971 slotSetTool(SELECTTOOL);
2972 else if (action == m_buttonRazorTool)
2973 slotSetTool(RAZORTOOL);
2974 else if (action == m_buttonSpacerTool)
2975 slotSetTool(SPACERTOOL);
2978 void MainWindow::slotChangeEdit(QAction * action)
2980 if (!m_activeTimeline)
2983 if (action == m_overwriteEditTool)
2984 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
2985 else if (action == m_insertEditTool)
2986 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
2988 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
2991 void MainWindow::slotSetTool(PROJECTTOOL tool)
2993 if (m_activeDocument && m_activeTimeline) {
2994 //m_activeDocument->setTool(tool);
2998 message = i18n("Ctrl + click to use spacer on current track only");
3001 message = i18n("Click on a clip to cut it");
3004 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3007 m_messageLabel->setMessage(message, InformationMessage);
3008 m_activeTimeline->projectView()->setTool(tool);
3012 void MainWindow::slotCopy()
3014 if (m_activeDocument && m_activeTimeline)
3015 m_activeTimeline->projectView()->copyClip();
3018 void MainWindow::slotPaste()
3020 if (m_activeDocument && m_activeTimeline)
3021 m_activeTimeline->projectView()->pasteClip();
3024 void MainWindow::slotPasteEffects()
3026 if (m_activeDocument && m_activeTimeline)
3027 m_activeTimeline->projectView()->pasteClipEffects();
3030 void MainWindow::slotFind()
3032 if (!m_activeDocument || !m_activeTimeline) return;
3033 m_projectSearch->setEnabled(false);
3034 m_findActivated = true;
3035 m_findString.clear();
3036 m_activeTimeline->projectView()->initSearchStrings();
3037 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3038 m_findTimer.start(5000);
3039 qApp->installEventFilter(this);
3042 void MainWindow::slotFindNext()
3044 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3045 statusBar()->showMessage(i18n("Found: %1", m_findString));
3047 statusBar()->showMessage(i18n("Reached end of project"));
3048 m_findTimer.start(4000);
3051 void MainWindow::findAhead()
3053 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3054 m_projectSearchNext->setEnabled(true);
3055 statusBar()->showMessage(i18n("Found: %1", m_findString));
3057 m_projectSearchNext->setEnabled(false);
3058 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3062 void MainWindow::findTimeout()
3064 m_projectSearchNext->setEnabled(false);
3065 m_findActivated = false;
3066 m_findString.clear();
3067 statusBar()->showMessage(i18n("Find stopped"), 3000);
3068 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3069 m_projectSearch->setEnabled(true);
3070 removeEventFilter(this);
3073 void MainWindow::slotClipInTimeline(const QString &clipId)
3075 if (m_activeTimeline && m_activeDocument) {
3076 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3078 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3079 inTimelineMenu->clear();
3081 QList <QAction *> actionList;
3083 for (int i = 0; i < matching.count(); ++i) {
3084 QString track = QString::number(matching.at(i).track);
3085 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3087 QAction *a = new QAction(track + ": " + start, this);
3088 a->setData(QStringList() << track << start);
3089 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3090 while (j < actionList.count()) {
3091 if (actionList.at(j)->text() > a->text()) break;
3094 actionList.insert(j, a);
3096 inTimelineMenu->addActions(actionList);
3098 if (matching.empty())
3099 inTimelineMenu->setEnabled(false);
3101 inTimelineMenu->setEnabled(true);
3105 void MainWindow::slotClipInProjectTree()
3107 if (m_activeTimeline) {
3108 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3109 if (clipIds.isEmpty())
3111 m_projectListDock->raise();
3112 for (int i = 0; i < clipIds.count(); i++)
3113 m_projectList->selectItemById(clipIds.at(i));
3114 if (m_projectMonitor->isActive())
3115 slotSwitchMonitors();
3119 /*void MainWindow::slotClipToProjectTree()
3121 if (m_activeTimeline) {
3122 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3123 if (clips.isEmpty()) return;
3124 for (int i = 0; i < clips.count(); i++) {
3125 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3127 //m_projectList->selectItemById(clipIds.at(i));
3131 void MainWindow::slotSelectClipInTimeline()
3133 if (m_activeTimeline) {
3134 QAction *action = qobject_cast<QAction *>(sender());
3135 QStringList data = action->data().toStringList();
3136 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3140 void MainWindow::keyPressEvent(QKeyEvent *ke)
3142 if (m_findActivated) {
3143 if (ke->key() == Qt::Key_Backspace) {
3144 m_findString = m_findString.left(m_findString.length() - 1);
3146 if (!m_findString.isEmpty())
3151 m_findTimer.start(4000);
3154 } else if (ke->key() == Qt::Key_Escape) {
3158 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3159 m_findString += ke->text();
3163 m_findTimer.start(4000);
3168 KXmlGuiWindow::keyPressEvent(ke);
3173 /** Gets called when the window gets hidden */
3174 void MainWindow::hideEvent(QHideEvent */*event*/)
3176 if (isMinimized() && m_monitorManager)
3177 m_monitorManager->stopActiveMonitor();
3180 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3182 if (m_findActivated) {
3183 if (event->type() == QEvent::ShortcutOverride) {
3184 QKeyEvent* ke = (QKeyEvent*) event;
3185 if (ke->text().trimmed().isEmpty()) return false;
3192 // pass the event on to the parent class
3193 return QMainWindow::eventFilter(obj, event);
3198 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3200 KDialog *dialog = new KDialog(this);
3201 dialog->setCaption("Save clip zone");
3202 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3204 QWidget *widget = new QWidget(dialog);
3205 dialog->setMainWidget(widget);
3207 QVBoxLayout *vbox = new QVBoxLayout(widget);
3208 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3209 QString path = m_activeDocument->projectFolder().path();
3211 path.append("untitled.mlt");
3212 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3213 url->setFilter("video/mlt-playlist");
3214 QLabel *label2 = new QLabel(i18n("Description:"), this);
3215 KLineEdit *edit = new KLineEdit(this);
3216 vbox->addWidget(label1);
3217 vbox->addWidget(url);
3218 vbox->addWidget(label2);
3219 vbox->addWidget(edit);
3220 if (dialog->exec() == QDialog::Accepted)
3221 render->saveZone(url->url(), edit->text(), zone);
3225 void MainWindow::slotSetInPoint()
3227 if (m_clipMonitor->isActive())
3228 m_clipMonitor->slotSetZoneStart();
3230 m_projectMonitor->slotSetZoneStart();
3231 //else m_activeTimeline->projectView()->setInPoint();
3234 void MainWindow::slotSetOutPoint()
3236 if (m_clipMonitor->isActive())
3237 m_clipMonitor->slotSetZoneEnd();
3239 m_projectMonitor->slotSetZoneEnd();
3240 // else m_activeTimeline->projectView()->setOutPoint();
3243 void MainWindow::slotResizeItemStart()
3245 if (m_activeTimeline)
3246 m_activeTimeline->projectView()->setInPoint();
3249 void MainWindow::slotResizeItemEnd()
3251 if (m_activeTimeline)
3252 m_activeTimeline->projectView()->setOutPoint();
3255 int MainWindow::getNewStuff(const QString &configFile)
3257 KNS3::Entry::List entries;
3258 #if KDE_IS_VERSION(4,3,80)
3259 KNS3::DownloadDialog dialog(configFile);
3261 entries = dialog.changedEntries();
3262 foreach(const KNS3::Entry &entry, entries) {
3263 if (entry.status() == KNS3::Entry::Installed)
3264 kDebug() << "// Installed files: " << entry.installedFiles();
3267 KNS::Engine engine(0);
3268 if (engine.init(configFile))
3269 entries = engine.downloadDialogModal(this);
3270 foreach(KNS::Entry *entry, entries) {
3271 if (entry->status() == KNS::Entry::Installed)
3272 kDebug() << "// Installed files: " << entry->installedFiles();
3274 #endif /* KDE_IS_VERSION(4,3,80) */
3275 return entries.size();
3278 void MainWindow::slotGetNewTitleStuff()
3280 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3281 TitleWidget::refreshTitleTemplates();
3284 void MainWindow::slotGetNewLumaStuff()
3286 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3287 initEffects::refreshLumas();
3288 m_activeTimeline->projectView()->reloadTransitionLumas();
3292 void MainWindow::slotGetNewRenderStuff()
3294 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3296 m_renderWidget->reloadProfiles();
3299 void MainWindow::slotGetNewMltProfileStuff()
3301 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3302 // update the list of profiles in settings dialog
3303 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3309 void MainWindow::slotAutoTransition()
3311 if (m_activeTimeline)
3312 m_activeTimeline->projectView()->autoTransition();
3315 void MainWindow::slotSplitAudio()
3317 if (m_activeTimeline)
3318 m_activeTimeline->projectView()->splitAudio();
3321 void MainWindow::slotUpdateClipType(QAction *action)
3323 if (m_activeTimeline) {
3324 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3325 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3326 else m_activeTimeline->projectView()->setAudioAndVideo();
3330 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3332 // We must stop the monitors since we create a new on in the dvd wizard
3333 m_clipMonitor->stop();
3334 m_projectMonitor->stop();
3335 DvdWizard w(url, profile, this);
3337 m_projectMonitor->start();
3340 void MainWindow::slotShowTimeline(bool show)
3342 if (show == false) {
3343 m_timelineState = saveState();
3344 centralWidget()->setHidden(true);
3346 centralWidget()->setHidden(false);
3347 restoreState(m_timelineState);
3351 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3353 //TODO: is there a way to maximize current widget?
3356 m_timelineState = saveState();
3357 QWidget *par = focusWidget()->parentWidget();
3358 while (par->parentWidget() && par->parentWidget() != this)
3359 par = par->parentWidget();
3360 kDebug() << "CURRENT WIDGET: " << par->objectName();
3363 //centralWidget()->setHidden(false);
3364 //restoreState(m_timelineState);
3368 void MainWindow::loadTranscoders()
3370 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3373 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3374 KConfigGroup transConfig(config, "Transcoding");
3376 QMap< QString, QString > profiles = transConfig.entryMap();
3377 QMapIterator<QString, QString> i(profiles);
3378 while (i.hasNext()) {
3380 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3381 QAction *a = transMenu->addAction(i.key());
3383 if (data.count() > 1)
3384 a->setToolTip(data.at(1));
3385 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3389 void MainWindow::slotTranscode(KUrl::List urls)
3394 if (urls.isEmpty()) {
3395 QAction *action = qobject_cast<QAction *>(sender());
3396 QStringList data = action->data().toStringList();
3397 params = data.at(0);
3398 if (data.count() > 1) desc = data.at(1);
3399 if (data.count() > 2) condition = data.at(2);
3400 urls << m_projectList->getConditionalUrls(condition);
3401 urls.removeAll(KUrl());
3403 if (urls.isEmpty()) {
3404 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3407 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3408 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3410 //QProcess::startDetached("ffmpeg", parameters);
3413 void MainWindow::slotTranscodeClip()
3415 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3416 if (urls.isEmpty()) return;
3417 slotTranscode(urls);
3420 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3422 if (m_activeDocument == NULL) return;
3423 QMapIterator<QString, QString> i(props);
3424 while (i.hasNext()) {
3426 m_activeDocument->setDocumentProperty(i.key(), i.value());
3428 m_activeDocument->setModified(true);
3432 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3434 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3436 QString playlistPath;
3439 QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
3440 QString path = m_renderWidget->getFreeScriptName();
3441 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3442 if (!ok || scriptPath.isEmpty()) return;
3443 scriptPath.prepend(scriptsFolder);
3444 QFile f(scriptPath);
3446 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3449 playlistPath = scriptPath + ".mlt";
3450 m_projectMonitor->saveSceneList(playlistPath);
3452 KTemporaryFile temp;
3453 temp.setAutoRemove(false);
3454 temp.setSuffix(".mlt");
3456 playlistPath = temp.fileName();
3457 m_projectMonitor->saveSceneList(playlistPath);
3460 if (!chapterFile.isEmpty()) {
3463 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3465 in = m_activeTimeline->inPoint();
3466 out = m_activeTimeline->outPoint();
3469 QDomElement chapters = doc.createElement("chapters");
3470 chapters.setAttribute("fps", m_activeDocument->fps());
3471 doc.appendChild(chapters);
3473 QDomElement guidesxml = m_activeDocument->guidesXml();
3474 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3475 for (int i = 0; i < nodes.count(); i++) {
3476 QDomElement e = nodes.item(i).toElement();
3478 QString comment = e.attribute("comment");
3479 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3480 if (time >= in && time < out) {
3481 if (zoneOnly) time = time - in;
3482 QDomElement chapter = doc.createElement("chapter");
3483 chapters.appendChild(chapter);
3484 chapter.setAttribute("title", comment);
3485 chapter.setAttribute("time", time);
3489 if (chapters.childNodes().count() > 0) {
3490 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3491 // Always insert a guide in pos 0
3492 QDomElement chapter = doc.createElement("chapter");
3493 chapters.insertBefore(chapter, QDomNode());
3494 chapter.setAttribute("title", i18n("Start"));
3495 chapter.setAttribute("time", "0");
3497 // save chapters file
3498 QFile file(chapterFile);
3499 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3500 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3502 file.write(doc.toString().toUtf8());
3503 if (file.error() != QFile::NoError) {
3504 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3511 if (m_renderWidget->automaticAudioExport()) {
3512 exportAudio = m_activeTimeline->checkProjectAudio();
3513 } else exportAudio = m_renderWidget->selectedAudioExport();
3514 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3517 void MainWindow::slotUpdateTimecodeFormat(int ix)
3519 KdenliveSettings::setFrametimecode(ix == 1);
3520 m_clipMonitor->updateTimecodeFormat();
3521 m_projectMonitor->updateTimecodeFormat();
3522 m_transitionConfig->updateTimecodeFormat();
3523 m_effectStack->updateTimecodeFormat();
3524 //m_activeTimeline->projectView()->clearSelection();
3525 m_activeTimeline->updateRuler();
3528 void MainWindow::slotRemoveFocus()
3530 statusBar()->setFocus();
3531 statusBar()->clearFocus();
3534 void MainWindow::slotRevert()
3536 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;
3537 KUrl url = m_activeDocument->url();
3538 if (closeCurrentDocument(false))
3539 doOpenFile(url, NULL);
3543 void MainWindow::slotShutdown()
3545 if (m_activeDocument) m_activeDocument->setModified(false);
3547 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3548 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3549 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3550 smserver.call("logout", 1, 2, 2);
3551 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3552 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3553 smserver.call("Shutdown");
3557 void MainWindow::slotUpdateTrackInfo()
3559 if (m_activeDocument)
3560 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3563 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3565 // Load the theme file
3567 if (action == NULL) theme = themename;
3568 else theme = action->data().toString();
3569 KdenliveSettings::setColortheme(theme);
3570 // Make palette for all widgets.
3572 if (theme.isEmpty())
3573 plt = QApplication::desktop()->palette();
3575 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3576 plt = KGlobalSettings::createApplicationPalette(config);
3579 kapp->setPalette(plt);
3580 const QObjectList children = statusBar()->children();
3582 foreach(QObject *child, children) {
3583 if (child->isWidgetType())
3584 ((QWidget*)child)->setPalette(plt);
3585 const QObjectList subchildren = child->children();
3586 foreach(QObject *subchild, subchildren) {
3587 if (subchild->isWidgetType())
3588 ((QWidget*)subchild)->setPalette(plt);
3591 if (m_activeTimeline) {
3592 m_activeTimeline->projectView()->updatePalette();
3597 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3599 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3600 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3601 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3602 const QSize bitsSize(24, 2);
3603 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3604 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3606 QPixmap pixmap(23, 16);
3607 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3609 KConfigGroup group(config, "WM");
3610 QPainter p(&pixmap);
3611 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3612 p.fillRect(1, 1, 7, 7, windowScheme.background());
3613 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3615 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3616 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3617 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3619 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3620 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3622 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3623 p.fillRect(1, 8, 7, 7, viewScheme.background());
3624 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3626 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3627 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3628 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3630 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3631 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3637 void MainWindow::slotSwitchMonitors()
3639 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3640 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3641 else m_projectList->focusTree();
3644 void MainWindow::slotInsertZoneToTree()
3646 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3647 QStringList info = m_clipMonitor->getZoneInfo();
3648 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3651 void MainWindow::slotInsertZoneToTimeline()
3653 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3654 QStringList info = m_clipMonitor->getZoneInfo();
3655 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3659 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3661 if (m_activeDocument && m_activeTimeline) {
3662 if (!ids.isEmpty()) {
3663 for (int i = 0; i < ids.size(); ++i) {
3664 m_activeTimeline->slotDeleteClip(ids.at(i));
3666 m_activeDocument->clipManager()->slotDeleteClips(ids);
3668 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3669 m_activeDocument->setModified(true);
3673 void MainWindow::slotShowTitleBars(bool show)
3676 m_effectStackDock->setTitleBarWidget(0);
3677 m_clipMonitorDock->setTitleBarWidget(0);
3678 m_projectMonitorDock->setTitleBarWidget(0);
3680 m_recMonitorDock->setTitleBarWidget(0);
3682 m_effectListDock->setTitleBarWidget(0);
3683 m_transitionConfigDock->setTitleBarWidget(0);
3684 m_projectListDock->setTitleBarWidget(0);
3685 m_undoViewDock->setTitleBarWidget(0);
3686 m_vectorscopeDock->setTitleBarWidget(0);
3687 m_waveformDock->setTitleBarWidget(0);
3688 m_RGBParadeDock->setTitleBarWidget(0);
3689 m_histogramDock->setTitleBarWidget(0);
3691 if (!m_effectStackDock->isFloating()) {
3692 m_effectStackDock->setTitleBarWidget(new QWidget);
3694 if (!m_clipMonitorDock->isFloating()) {
3695 m_clipMonitorDock->setTitleBarWidget(new QWidget);
3697 if (!m_projectMonitorDock->isFloating()) {
3698 m_projectMonitorDock->setTitleBarWidget(new QWidget);
3701 if (!m_recMonitorDock->isFloating()) {
3702 m_recMonitorDock->setTitleBarWidget(new QWidget);
3705 if (!m_effectListDock->isFloating()) {
3706 m_effectListDock->setTitleBarWidget(new QWidget);
3708 if (!m_transitionConfigDock->isFloating()) {
3709 m_transitionConfigDock->setTitleBarWidget(new QWidget);
3711 if (!m_projectListDock->isFloating()) {
3712 m_projectListDock->setTitleBarWidget(new QWidget);
3714 if (!m_undoViewDock->isFloating()) {
3715 m_undoViewDock->setTitleBarWidget(new QWidget);
3717 if (!m_vectorscopeDock->isFloating()) {
3718 m_vectorscopeDock->setTitleBarWidget(new QWidget);
3720 if (!m_waveformDock->isFloating()) {
3721 m_waveformDock->setTitleBarWidget(new QWidget);
3723 if (!m_RGBParadeDock->isFloating()) {
3724 m_RGBParadeDock->setTitleBarWidget(new QWidget(this));
3726 if (!m_histogramDock->isFloating()) {
3727 m_histogramDock->setTitleBarWidget(new QWidget(this));
3730 KdenliveSettings::setShowtitlebars(show);
3733 void MainWindow::slotSwitchTitles()
3735 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3738 QString MainWindow::getMimeType()
3740 QString mimetype = "application/x-kdenlive";
3741 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3742 if (!mime) mimetype = "*.kdenlive";
3746 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3749 m_projectMonitor->render->sendFrameForAnalysis = true;
3752 for (int i = 0; i < m_scopesList.count(); i++) {
3753 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3760 m_projectMonitor->render->sendFrameForAnalysis = false;
3764 void MainWindow::slotUpdateScopeFrameRequest()
3766 // We need a delay to make sure widgets are hidden after a close event for example
3767 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3770 void MainWindow::slotDoUpdateScopeFrameRequest()
3773 bool request = false;
3774 for (int i = 0; i < m_scopesList.count(); i++) {
3775 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3776 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
3782 if (!m_projectMonitor->effectSceneDisplayed())
3783 m_projectMonitor->render->sendFrameForAnalysis = false;
3784 m_clipMonitor->render->sendFrameForAnalysis = false;
3786 m_projectMonitor->render->sendFrameForAnalysis = true;
3787 m_clipMonitor->render->sendFrameForAnalysis = true;
3791 void MainWindow::slotUpdateColorScopes()
3793 bool request = false;
3794 for (int i = 0; i < m_scopesList.count(); i++) {
3795 // Check if we need the renderer to send a new frame for update
3796 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
3797 static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
3800 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
3801 else m_projectMonitor->render->sendFrameUpdate();
3805 #include "mainwindow.moc"