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"
42 #include "audiosignal.h"
44 #include "jogshuttle.h"
45 #endif /* NO_JOGSHUTTLE */
46 #include "clipproperties.h"
48 #include "editclipcommand.h"
49 #include "titlewidget.h"
50 #include "markerdialog.h"
52 #include "interfaces.h"
53 #include "kdenlive-config.h"
54 #include "cliptranscode.h"
55 #include "ui_templateclip_ui.h"
56 #include "vectorscope.h"
58 #include "rgbparade.h"
59 #include "histogram.h"
61 #include <KApplication>
65 #include <KActionCollection>
66 #include <KActionCategory>
67 #include <KStandardAction>
68 #include <KShortcutsDialog>
69 #include <KFileDialog>
70 #include <KMessageBox>
72 #include <KIO/NetAccess>
75 #include <KConfigDialog>
76 #include <KXMLGUIFactory>
78 #include <kstandarddirs.h>
79 #include <KUrlRequesterDialog>
80 #include <KTemporaryFile>
82 #include <KActionMenu>
85 #include <ktogglefullscreenaction.h>
87 #include <KNotification>
88 #include <KNotifyConfigWidget>
89 #if KDE_IS_VERSION(4,3,80)
90 #include <knewstuff3/downloaddialog.h>
91 #include <knewstuff3/knewstuffaction.h>
93 #include <knewstuff2/engine.h>
94 #include <knewstuff2/ui/knewstuffaction.h>
96 #endif /* KDE_IS_VERSION(4,3,80) */
98 #include <KColorScheme>
100 #include <QTextStream>
104 #include <QInputDialog>
105 #include <QDesktopWidget>
110 static const char version[] = VERSION;
112 static const int ID_TIMELINE_POS = 0;
119 EffectsList MainWindow::videoEffects;
120 EffectsList MainWindow::audioEffects;
121 EffectsList MainWindow::customEffects;
122 EffectsList MainWindow::transitions;
124 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
125 KXmlGuiWindow(parent),
126 m_activeDocument(NULL),
127 m_activeTimeline(NULL),
128 m_renderWidget(NULL),
129 #ifndef NO_JOGSHUTTLE
131 #endif /* NO_JOGSHUTTLE */
132 m_findActivated(false)
135 // Create DBus interface
136 new MainWindowAdaptor(this);
137 QDBusConnection dbus = QDBusConnection::sessionBus();
138 dbus.registerObject("/MainWindow", this);
140 setlocale(LC_NUMERIC, "POSIX");
141 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
142 setFont(KGlobalSettings::toolBarFont());
143 parseProfiles(MltPath);
144 m_commandStack = new QUndoGroup;
145 setDockNestingEnabled(true);
146 m_timelineArea = new KTabWidget(this);
147 m_timelineArea->setTabReorderingEnabled(true);
148 m_timelineArea->setTabBarHidden(true);
149 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
150 m_timelineArea->setMinimumHeight(200);
152 QToolButton *closeTabButton = new QToolButton;
153 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
154 closeTabButton->setIcon(KIcon("tab-close"));
155 closeTabButton->adjustSize();
156 closeTabButton->setToolTip(i18n("Close the current tab"));
157 m_timelineArea->setCornerWidget(closeTabButton);
158 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
160 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
161 m_findTimer.setSingleShot(true);
163 // FIXME: the next call returns a newly allocated object, which leaks
164 initEffects::parseEffectFiles();
165 //initEffects::parseCustomEffectsFile();
167 m_monitorManager = new MonitorManager();
169 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
170 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
175 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
176 m_projectListDock->setObjectName("project_tree");
177 m_projectList = new ProjectList();
178 m_projectListDock->setWidget(m_projectList);
179 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
181 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
182 m_clipMonitorDock->setObjectName("clip_monitor");
183 m_clipMonitor = new Monitor("clip", m_monitorManager, QString());
184 m_clipMonitorDock->setWidget(m_clipMonitor);
185 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
187 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
188 m_projectMonitorDock->setObjectName("project_monitor");
189 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
190 m_projectMonitorDock->setWidget(m_projectMonitor);
191 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
194 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
195 m_recMonitorDock->setObjectName("record_monitor");
196 m_recMonitor = new RecMonitor("record");
197 m_recMonitorDock->setWidget(m_recMonitor);
198 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
199 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
200 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
203 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
204 m_notesDock->setObjectName("notes_widget");
205 m_notesWidget = new KTextEdit();
206 m_notesWidget->setTabChangesFocus(true);
207 #if KDE_IS_VERSION(4,4,0)
208 m_notesWidget->setClickMessage(i18n("Enter your project notes here..."));
210 m_notesDock->setWidget(m_notesWidget);
211 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
213 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
214 m_effectStackDock->setObjectName("effect_stack");
215 m_effectStack = new EffectStackView(m_projectMonitor);
216 m_effectStackDock->setWidget(m_effectStack);
217 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
219 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
220 m_transitionConfigDock->setObjectName("transition");
221 m_transitionConfig = new TransitionSettings(m_projectMonitor);
222 m_transitionConfigDock->setWidget(m_transitionConfig);
223 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
225 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
226 m_effectListDock->setObjectName("effect_list");
227 m_effectList = new EffectsListView();
228 m_effectListDock->setWidget(m_effectList);
229 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
231 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
232 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
233 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
234 m_vectorscopeDock->setWidget(m_vectorscope);
235 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
236 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
237 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
238 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
239 m_scopesList.append(m_vectorscopeDock);
241 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
242 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
243 m_waveformDock->setObjectName(m_waveform->widgetName());
244 m_waveformDock->setWidget(m_waveform);
245 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
246 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
247 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
248 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
249 m_scopesList.append(m_waveformDock);
251 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
252 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
253 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
254 m_RGBParadeDock->setWidget(m_RGBParade);
255 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
256 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
257 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
258 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
259 m_scopesList.append(m_RGBParadeDock);
261 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
262 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
263 m_histogramDock->setObjectName(m_histogram->widgetName());
264 m_histogramDock->setWidget(m_histogram);
265 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
266 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
267 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
268 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
269 m_scopesList.append(m_histogramDock);
272 m_audiosignal = new AudioSignal;
273 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
274 m_audiosignalDock->setObjectName("audiosignal");
275 m_audiosignalDock->setWidget(m_audiosignal);
276 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
277 if (m_projectMonitor){
278 connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)) );
281 connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)) );
283 //connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
284 //connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
286 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
287 m_undoViewDock->setObjectName("undo_history");
288 m_undoView = new QUndoView();
289 m_undoView->setCleanIcon(KIcon("edit-clear"));
290 m_undoView->setEmptyLabel(i18n("Clean"));
291 m_undoViewDock->setWidget(m_undoView);
292 m_undoView->setGroup(m_commandStack);
293 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
295 //overviewDock = new QDockWidget(i18n("Project Overview"), this);
296 //overviewDock->setObjectName("project_overview");
297 //m_overView = new CustomTrackView(NULL, NULL, this);
298 //overviewDock->setWidget(m_overView);
299 //addDockWidget(Qt::TopDockWidgetArea, overviewDock);
304 /// Tabify Widgets ///
305 tabifyDockWidget(m_projectListDock, m_effectStackDock);
306 tabifyDockWidget(m_projectListDock, m_transitionConfigDock);
307 tabifyDockWidget(m_projectListDock, m_notesDock);
310 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
312 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
315 tabifyDockWidget(m_vectorscopeDock, m_waveformDock);
316 tabifyDockWidget(m_vectorscopeDock, m_RGBParadeDock);
317 tabifyDockWidget(m_vectorscopeDock, m_histogramDock);
318 tabifyDockWidget(m_vectorscopeDock, m_undoViewDock);
319 tabifyDockWidget(m_vectorscopeDock, m_effectListDock);
322 setCentralWidget(m_timelineArea);
325 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
326 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
328 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
329 m_fileRevert->setEnabled(false);
331 // Prepare layout actions
332 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
333 for (int i = 1; i < 5; i++) {
334 KAction *load = new KAction(KIcon(), i18n("Load Layout %1").arg(i), this);
335 load->setData("_" + QString::number(i));
336 layoutActions->addAction("load_layout" + QString::number(i), load);
337 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
338 save->setData("_" + QString::number(i));
339 layoutActions->addAction("save_layout" + QString::number(i), save);
345 // Find QDockWidget tab bars and show / hide widget title bars on right click
346 QList <QTabBar *> tabs = findChildren<QTabBar *>();
347 for (int i = 0; i < tabs.count(); i++) {
348 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
349 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
352 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
353 guiFactory()->addClient(sp);*/
356 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
358 connect(loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
359 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
361 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
364 // Load layout names from config file
369 //kDebug() << factory() << " " << factory()->container("video_effects_menu", this);
371 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
372 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
374 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
375 clipInTimeline->setIcon(KIcon("go-jump"));
376 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
377 static_cast<QMenu*>(factory()->container("transcoders", this)),
381 // build themes menus
382 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
383 QActionGroup *themegroup = new QActionGroup(this);
384 themegroup->setExclusive(true);
385 action = new KAction(i18n("Default"), this);
386 action->setCheckable(true);
387 themegroup->addAction(action);
388 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
390 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
392 for (int i = 0; i < schemeFiles.size(); ++i) {
394 const QString filename = schemeFiles.at(i);
395 const QFileInfo info(filename);
398 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
399 QIcon icon = createSchemePreviewIcon(config);
400 KConfigGroup group(config, "General");
401 const QString name = group.readEntry("Name", info.baseName());
402 action = new KAction(name, this);
403 action->setData(filename);
404 action->setIcon(icon);
405 action->setCheckable(true);
406 themegroup->addAction(action);
407 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
410 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
411 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
412 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
415 action = new QAction(fi.fileName(), this);
416 action->setData(*it);
417 action->setCheckable(true);
418 themegroup->addAction(action);
419 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
421 themesMenu->addActions(themegroup->actions());
422 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
424 // Setup and fill effects and transitions menus.
425 m_videoEffectsMenu = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
426 for (int i = 0; i < videoEffects.count(); ++i)
427 m_videoEffectsMenu->addAction(m_videoEffects[i]);
428 m_audioEffectsMenu = static_cast<QMenu*>(factory()->container("audio_effects_menu", this));
429 for (int i = 0; i < audioEffects.count(); ++i)
430 m_audioEffectsMenu->addAction(m_audioEffects[i]);
431 m_customEffectsMenu = static_cast<QMenu*>(factory()->container("custom_effects_menu", this));
432 if (customEffects.isEmpty())
433 m_customEffectsMenu->setEnabled(false);
435 m_customEffectsMenu->setEnabled(true);
436 for (int i = 0; i < customEffects.count(); ++i)
437 m_customEffectsMenu->addAction(m_customEffects[i]);
438 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
439 for (int i = 0; i < transitions.count(); ++i)
440 m_transitionsMenu->addAction(m_transitions[i]);
442 connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
443 connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *)));
444 connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *)));
445 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
447 QMenu *newEffect = new QMenu(this);
448 newEffect->addMenu(m_videoEffectsMenu);
449 newEffect->addMenu(m_audioEffectsMenu);
450 newEffect->addMenu(m_customEffectsMenu);
451 m_effectStack->setMenu(newEffect);
453 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
454 const QList<QAction *> viewActions = createPopupMenu()->actions();
455 viewMenu->insertActions(NULL, viewActions);
457 m_timelineContextMenu = new QMenu(this);
458 m_timelineContextClipMenu = new QMenu(this);
459 m_timelineContextTransitionMenu = new QMenu(this);
461 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
462 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
463 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
465 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
466 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
467 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
468 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
469 m_timelineContextClipMenu->addSeparator();
470 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
471 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
472 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
473 m_timelineContextClipMenu->addSeparator();
474 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
475 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
476 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
477 m_timelineContextClipMenu->addSeparator();
479 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
480 m_timelineContextClipMenu->addMenu(markersMenu);
481 m_timelineContextClipMenu->addSeparator();
482 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
483 m_timelineContextClipMenu->addMenu(m_videoEffectsMenu);
484 m_timelineContextClipMenu->addMenu(m_audioEffectsMenu);
485 m_timelineContextClipMenu->addMenu(m_customEffectsMenu);
487 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
488 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
489 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
491 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
493 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
494 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
495 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
496 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
497 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
498 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
499 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
501 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
502 slotConnectMonitors();
504 // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
505 KdenliveSettings::setDropbframes(false);
507 // Open or create a file. Command line argument passed in Url has
508 // precedence, then "openlastproject", then just a plain empty file.
509 // If opening Url fails, openlastproject will _not_ be used.
510 if (!Url.isEmpty()) {
511 // delay loading so that the window shows up
513 QTimer::singleShot(500, this, SLOT(openFile()));
514 } else if (KdenliveSettings::openlastproject()) {
515 QTimer::singleShot(500, this, SLOT(openLastFile()));
516 } else { //if (m_timelineArea->count() == 0) {
520 if (!clipsToLoad.isEmpty() && m_activeDocument) {
521 QStringList list = clipsToLoad.split(',');
523 foreach(QString path, list) {
524 kDebug() << QDir::current().absoluteFilePath(path);
525 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
527 m_projectList->slotAddClip(urls);
530 #ifndef NO_JOGSHUTTLE
531 activateShuttleDevice();
532 #endif /* NO_JOGSHUTTLE */
533 m_projectListDock->raise();
536 MainWindow::~MainWindow()
538 m_effectStack->slotClipItemSelected(NULL, 0);
539 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
541 if (m_projectMonitor) m_projectMonitor->stop();
542 if (m_clipMonitor) m_clipMonitor->stop();
544 delete m_activeTimeline;
545 delete m_effectStack;
546 delete m_transitionConfig;
547 delete m_activeDocument;
548 delete m_projectMonitor;
549 delete m_clipMonitor;
550 delete m_shortcutRemoveFocus;
551 Mlt::Factory::close();
554 void MainWindow::queryQuit()
562 bool MainWindow::queryClose()
564 if (m_renderWidget) {
565 int waitingJobs = m_renderWidget->waitingJobsCount();
566 if (waitingJobs > 0) {
567 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")))) {
568 case KMessageBox::Yes :
569 // create script with waiting jobs and start it
570 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
572 case KMessageBox::No :
573 // Don't do anything, jobs will be deleted
581 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
582 // warn the user to save if document is modified and we have clips in our project list
583 if (m_activeDocument && m_activeDocument->isModified() &&
584 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
585 !m_projectList->documentClipList().isEmpty())) {
589 if (m_activeDocument->url().fileName().isEmpty())
590 message = i18n("Save changes to document?");
592 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
593 switch (KMessageBox::warningYesNoCancel(this, message)) {
594 case KMessageBox::Yes :
595 // save document here. If saving fails, return false;
597 case KMessageBox::No :
598 // User does not want to save the changes, clear recovery files
599 m_activeDocument->m_autosave->resize(0);
608 void MainWindow::loadPlugins()
610 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
611 populateMenus(plugin);
614 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
616 filters << "libkdenlive*";
617 foreach(const QString & folder, directories) {
618 kDebug() << "Parsing plugin folder: " << folder;
619 QDir pluginsDir(folder);
620 foreach(const QString & fileName,
621 pluginsDir.entryList(filters, QDir::Files)) {
623 * Avoid loading the same plugin twice when there is more than one
626 if (!m_pluginFileNames.contains(fileName)) {
627 kDebug() << "Found plugin: " << fileName;
628 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
629 QObject *plugin = loader.instance();
631 populateMenus(plugin);
632 m_pluginFileNames += fileName;
634 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
640 void MainWindow::populateMenus(QObject *plugin)
642 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
643 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
645 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
649 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
650 QMenu *menu, const char *member,
651 QActionGroup *actionGroup)
653 kDebug() << "// ADD to MENU" << texts;
654 foreach(const QString & text, texts) {
655 QAction *action = new QAction(text, plugin);
656 action->setData(text);
657 connect(action, SIGNAL(triggered()), this, member);
658 menu->addAction(action);
661 action->setCheckable(true);
662 actionGroup->addAction(action);
667 void MainWindow::aboutPlugins()
669 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
674 void MainWindow::generateClip()
676 QAction *action = qobject_cast<QAction *>(sender());
677 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
679 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
680 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
681 if (!clipUrl.isEmpty()) {
682 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
686 void MainWindow::saveProperties(KConfigGroup &config)
688 // save properties here,used by session management
690 KMainWindow::saveProperties(config);
694 void MainWindow::readProperties(const KConfigGroup &config)
696 // read properties here,used by session management
697 KMainWindow::readProperties(config);
698 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
699 openFile(KUrl(Lastproject));
702 void MainWindow::slotReloadEffects()
704 m_customEffectsMenu->clear();
705 initEffects::parseCustomEffectsFile();
707 QStringList effectInfo;
708 QMap<QString, QStringList> effectsList;
709 for (int ix = 0; ix < customEffects.count(); ix++) {
710 effectInfo = customEffects.effectIdInfo(ix);
711 effectsList.insert(effectInfo.at(0).toLower(), effectInfo);
713 if (effectsList.isEmpty())
714 m_customEffectsMenu->setEnabled(false);
716 m_customEffectsMenu->setEnabled(true);
718 foreach(const QStringList & value, effectsList) {
719 action = new QAction(value.at(0), this);
720 action->setData(value);
721 m_customEffectsMenu->addAction(action);
723 m_effectList->reloadEffectList();
726 #ifndef NO_JOGSHUTTLE
727 void MainWindow::activateShuttleDevice()
731 if (KdenliveSettings::enableshuttle() == false) return;
732 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
733 connect(m_jogProcess, SIGNAL(rewind1()), m_monitorManager, SLOT(slotRewindOneFrame()));
734 connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
735 connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
736 connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
737 connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
738 connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
741 void MainWindow::slotShuttleButton(int code)
745 slotShuttleAction(KdenliveSettings::shuttle1());
748 slotShuttleAction(KdenliveSettings::shuttle2());
751 slotShuttleAction(KdenliveSettings::shuttle3());
754 slotShuttleAction(KdenliveSettings::shuttle4());
757 slotShuttleAction(KdenliveSettings::shuttle5());
762 void MainWindow::slotShuttleAction(int code)
768 m_monitorManager->slotPlay();
771 m_monitorManager->slotPlay();
775 #endif /* NO_JOGSHUTTLE */
777 void MainWindow::configureNotifications()
779 KNotifyConfigWidget::configure(this);
782 void MainWindow::slotFullScreen()
784 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
787 void MainWindow::slotAddEffect(const QDomElement effect)
789 if (!m_activeDocument) return;
790 if (effect.isNull()) {
791 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
794 QDomElement effectToAdd = effect.cloneNode().toElement();
796 int ix = m_effectStack->isTrackMode(&ok);
797 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
798 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
801 void MainWindow::slotRaiseMonitor(bool clipMonitor)
803 if (clipMonitor) m_clipMonitorDock->raise();
804 else m_projectMonitorDock->raise();
807 void MainWindow::slotUpdateClip(const QString &id)
809 if (!m_activeDocument) return;
810 m_activeTimeline->projectView()->slotUpdateClip(id);
813 void MainWindow::slotConnectMonitors()
815 m_projectList->setRenderer(m_projectMonitor->render);
816 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
817 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
818 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
819 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
820 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool)));
821 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
822 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)));
824 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
826 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &)));
828 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
829 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
831 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
833 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
834 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
837 void MainWindow::slotAdjustClipMonitor()
839 m_clipMonitorDock->updateGeometry();
840 m_clipMonitorDock->adjustSize();
841 m_clipMonitor->resetSize();
844 void MainWindow::slotAdjustProjectMonitor()
846 m_projectMonitorDock->updateGeometry();
847 m_projectMonitorDock->adjustSize();
848 m_projectMonitor->resetSize();
851 void MainWindow::setupActions()
854 KActionCollection* collection = actionCollection();
855 m_timecodeFormat = new KComboBox(this);
856 m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
857 m_timecodeFormat->addItem(i18n("Frames"));
858 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
859 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
861 m_statusProgressBar = new QProgressBar(this);
862 m_statusProgressBar->setMinimum(0);
863 m_statusProgressBar->setMaximum(100);
864 m_statusProgressBar->setMaximumWidth(150);
865 m_statusProgressBar->setVisible(false);
867 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
868 toolbar->setMovable(false);
869 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
870 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
871 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
872 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
873 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
874 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());
875 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
877 //create edit mode buttons
878 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
879 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
880 toolbar->addAction(m_normalEditTool);
881 m_normalEditTool->setCheckable(true);
882 m_normalEditTool->setChecked(true);
884 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
885 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
886 toolbar->addAction(m_overwriteEditTool);
887 m_overwriteEditTool->setCheckable(true);
888 m_overwriteEditTool->setChecked(false);
890 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
891 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
892 toolbar->addAction(m_insertEditTool);
893 m_insertEditTool->setCheckable(true);
894 m_insertEditTool->setChecked(false);
895 // not implemented yet
896 m_insertEditTool->setEnabled(false);
898 QActionGroup *editGroup = new QActionGroup(this);
899 editGroup->addAction(m_normalEditTool);
900 editGroup->addAction(m_overwriteEditTool);
901 editGroup->addAction(m_insertEditTool);
902 editGroup->setExclusive(true);
903 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
904 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
906 toolbar->addSeparator();
908 // create tools buttons
909 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
910 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
911 toolbar->addAction(m_buttonSelectTool);
912 m_buttonSelectTool->setCheckable(true);
913 m_buttonSelectTool->setChecked(true);
915 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
916 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
917 toolbar->addAction(m_buttonRazorTool);
918 m_buttonRazorTool->setCheckable(true);
919 m_buttonRazorTool->setChecked(false);
921 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
922 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
923 toolbar->addAction(m_buttonSpacerTool);
924 m_buttonSpacerTool->setCheckable(true);
925 m_buttonSpacerTool->setChecked(false);
927 QActionGroup *toolGroup = new QActionGroup(this);
928 toolGroup->addAction(m_buttonSelectTool);
929 toolGroup->addAction(m_buttonRazorTool);
930 toolGroup->addAction(m_buttonSpacerTool);
931 toolGroup->setExclusive(true);
932 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
934 QWidget * actionWidget;
935 int max = toolbar->iconSizeDefault() + 2;
936 actionWidget = toolbar->widgetForAction(m_normalEditTool);
937 actionWidget->setMaximumWidth(max);
938 actionWidget->setMaximumHeight(max - 4);
940 actionWidget = toolbar->widgetForAction(m_insertEditTool);
941 actionWidget->setMaximumWidth(max);
942 actionWidget->setMaximumHeight(max - 4);
944 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
945 actionWidget->setMaximumWidth(max);
946 actionWidget->setMaximumHeight(max - 4);
948 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
949 actionWidget->setMaximumWidth(max);
950 actionWidget->setMaximumHeight(max - 4);
952 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
953 actionWidget->setMaximumWidth(max);
954 actionWidget->setMaximumHeight(max - 4);
956 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
957 actionWidget->setMaximumWidth(max);
958 actionWidget->setMaximumHeight(max - 4);
960 toolbar->setStyleSheet(style1);
961 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
963 toolbar->addSeparator();
964 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
965 toolbar->addAction(m_buttonFitZoom);
966 m_buttonFitZoom->setCheckable(false);
968 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
969 toolbar->addAction(m_zoomOut);
970 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
972 m_zoomSlider = new QSlider(Qt::Horizontal, this);
973 m_zoomSlider->setMaximum(13);
974 m_zoomSlider->setPageStep(1);
975 m_zoomSlider->setInvertedAppearance(true);
977 m_zoomSlider->setMaximumWidth(150);
978 m_zoomSlider->setMinimumWidth(100);
979 toolbar->addWidget(m_zoomSlider);
981 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
982 toolbar->addAction(m_zoomIn);
983 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
985 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
986 actionWidget->setMaximumWidth(max);
987 actionWidget->setMaximumHeight(max - 4);
988 actionWidget->setStyleSheet(styleBorderless);
990 actionWidget = toolbar->widgetForAction(m_zoomIn);
991 actionWidget->setMaximumWidth(max);
992 actionWidget->setMaximumHeight(max - 4);
993 actionWidget->setStyleSheet(styleBorderless);
995 actionWidget = toolbar->widgetForAction(m_zoomOut);
996 actionWidget->setMaximumWidth(max);
997 actionWidget->setMaximumHeight(max - 4);
998 actionWidget->setStyleSheet(styleBorderless);
1000 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1001 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1002 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1003 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1004 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1006 toolbar->addSeparator();
1008 //create automatic audio split button
1009 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1010 toolbar->addAction(m_buttonAutomaticSplitAudio);
1011 m_buttonAutomaticSplitAudio->setCheckable(true);
1012 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1013 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1015 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1016 toolbar->addAction(m_buttonVideoThumbs);
1017 m_buttonVideoThumbs->setCheckable(true);
1018 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1019 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1021 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1022 toolbar->addAction(m_buttonAudioThumbs);
1023 m_buttonAudioThumbs->setCheckable(true);
1024 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1025 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1027 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1028 toolbar->addAction(m_buttonShowMarkers);
1029 m_buttonShowMarkers->setCheckable(true);
1030 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1031 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1033 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1034 toolbar->addAction(m_buttonSnap);
1035 m_buttonSnap->setCheckable(true);
1036 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1037 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1039 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1040 actionWidget->setMaximumWidth(max);
1041 actionWidget->setMaximumHeight(max - 4);
1043 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1044 actionWidget->setMaximumWidth(max);
1045 actionWidget->setMaximumHeight(max - 4);
1047 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1048 actionWidget->setMaximumWidth(max);
1049 actionWidget->setMaximumHeight(max - 4);
1051 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1052 actionWidget->setMaximumWidth(max);
1053 actionWidget->setMaximumHeight(max - 4);
1055 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1056 actionWidget->setMaximumWidth(max);
1057 actionWidget->setMaximumHeight(max - 4);
1059 m_messageLabel = new StatusBarMessageLabel(this);
1060 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1062 statusBar()->addWidget(m_messageLabel, 10);
1063 statusBar()->addWidget(m_statusProgressBar, 0);
1064 statusBar()->addPermanentWidget(toolbar);
1065 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1066 statusBar()->addPermanentWidget(m_timecodeFormat);
1067 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1069 collection->addAction("normal_mode", m_normalEditTool);
1070 collection->addAction("overwrite_mode", m_overwriteEditTool);
1071 collection->addAction("insert_mode", m_insertEditTool);
1072 collection->addAction("select_tool", m_buttonSelectTool);
1073 collection->addAction("razor_tool", m_buttonRazorTool);
1074 collection->addAction("spacer_tool", m_buttonSpacerTool);
1076 collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1077 collection->addAction("show_video_thumbs", m_buttonVideoThumbs);
1078 collection->addAction("show_audio_thumbs", m_buttonAudioThumbs);
1079 collection->addAction("show_markers", m_buttonShowMarkers);
1080 collection->addAction("snap", m_buttonSnap);
1081 collection->addAction("zoom_fit", m_buttonFitZoom);
1082 collection->addAction("zoom_in", m_zoomIn);
1083 collection->addAction("zoom_out", m_zoomOut);
1085 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1086 collection->addAction("project_find", m_projectSearch);
1087 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1088 m_projectSearch->setShortcut(Qt::Key_Slash);
1090 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1091 collection->addAction("project_find_next", m_projectSearchNext);
1092 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1093 m_projectSearchNext->setShortcut(Qt::Key_F3);
1094 m_projectSearchNext->setEnabled(false);
1096 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1097 collection->addAction("manage_profiles", profilesAction);
1098 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1100 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1101 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1102 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1103 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1105 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1106 collection->addAction("run_wizard", wizAction);
1107 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1109 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1110 collection->addAction("project_settings", projectAction);
1111 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1113 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1114 collection->addAction("project_render", projectRender);
1115 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1116 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1118 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1119 collection->addAction("project_clean", projectClean);
1120 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1122 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1123 collection->addAction("project_adjust_profile", projectAdjust);
1124 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1126 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1127 KShortcut playShortcut;
1128 playShortcut.setPrimary(Qt::Key_Space);
1129 playShortcut.setAlternate(Qt::Key_K);
1130 monitorPlay->setShortcut(playShortcut);
1131 collection->addAction("monitor_play", monitorPlay);
1132 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1134 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1135 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1136 collection->addAction("monitor_play_zone", m_playZone);
1137 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1139 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1140 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1141 collection->addAction("monitor_loop_zone", m_loopZone);
1142 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1144 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1145 m_loopClip->setEnabled(false);
1146 collection->addAction("monitor_loop_clip", m_loopClip);
1147 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1149 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1150 collection->addAction("dvd_wizard", dvdWizard);
1151 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1153 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1154 collection->addAction("transcode_clip", transcodeClip);
1155 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1157 KAction *markIn = collection->addAction("mark_in");
1158 markIn->setText(i18n("Set Zone In"));
1159 markIn->setShortcut(Qt::Key_I);
1160 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1162 KAction *markOut = collection->addAction("mark_out");
1163 markOut->setText(i18n("Set Zone Out"));
1164 markOut->setShortcut(Qt::Key_O);
1165 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1167 KAction *switchMon = collection->addAction("switch_monitor");
1168 switchMon->setText(i18n("Switch monitor"));
1169 switchMon->setShortcut(Qt::Key_T);
1170 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1172 KAction *insertTree = collection->addAction("insert_project_tree");
1173 insertTree->setText(i18n("Insert zone in project tree"));
1174 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1175 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1177 KAction *insertTimeline = collection->addAction("insert_timeline");
1178 insertTimeline->setText(i18n("Insert zone in timeline"));
1179 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1180 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1182 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1183 collection->addAction("resize_timeline_clip_start", resizeStart);
1184 resizeStart->setShortcut(Qt::Key_1);
1185 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1187 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1188 collection->addAction("resize_timeline_clip_end", resizeEnd);
1189 resizeEnd->setShortcut(Qt::Key_2);
1190 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1192 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1193 monitorSeekBackward->setShortcut(Qt::Key_J);
1194 collection->addAction("monitor_seek_backward", monitorSeekBackward);
1195 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1197 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1198 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1199 collection->addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1200 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1202 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1203 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1204 collection->addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1205 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1207 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1208 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1209 collection->addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1210 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1212 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1213 monitorSeekForward->setShortcut(Qt::Key_L);
1214 collection->addAction("monitor_seek_forward", monitorSeekForward);
1215 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1217 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1218 clipStart->setShortcut(Qt::Key_Home);
1219 collection->addAction("seek_clip_start", clipStart);
1220 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1222 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1223 clipEnd->setShortcut(Qt::Key_End);
1224 collection->addAction("seek_clip_end", clipEnd);
1225 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1227 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1228 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1229 collection->addAction("seek_zone_start", zoneStart);
1230 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1232 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1233 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1234 collection->addAction("seek_zone_end", zoneEnd);
1235 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1237 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1238 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1239 collection->addAction("seek_start", projectStart);
1240 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1242 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1243 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1244 collection->addAction("seek_end", projectEnd);
1245 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1247 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1248 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1249 collection->addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1250 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1252 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1253 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1254 collection->addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1255 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1257 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1258 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1259 collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1260 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1262 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1263 deleteItem->setShortcut(Qt::Key_Delete);
1264 collection->addAction("delete_timeline_clip", deleteItem);
1265 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1267 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1268 collection->addAction("change_clip_speed", editTimelineClipSpeed);
1269 editTimelineClipSpeed->setData("change_speed");
1270 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1272 KAction *stickTransition = collection->addAction("auto_transition");
1273 stickTransition->setData(QString("auto"));
1274 stickTransition->setCheckable(true);
1275 stickTransition->setEnabled(false);
1276 stickTransition->setText(i18n("Automatic Transition"));
1277 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1279 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1280 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1281 collection->addAction("group_clip", groupClip);
1282 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1284 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1285 collection->addAction("ungroup_clip", ungroupClip);
1286 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1287 ungroupClip->setData("ungroup_clip");
1288 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1290 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1291 collection->addAction("edit_item_duration", editItemDuration);
1292 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1294 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1295 collection->addAction("clip_in_project_tree", clipInProjectTree);
1296 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1298 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1299 collection->addAction("clip_to_project_tree", clipToProjectTree);
1300 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1302 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1303 insertOvertwrite->setShortcut(Qt::Key_V);
1304 collection->addAction("overwrite_to_in_point", insertOvertwrite);
1305 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1307 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1308 selectTimelineClip->setShortcut(Qt::Key_Plus);
1309 collection->addAction("select_timeline_clip", selectTimelineClip);
1310 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1312 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1313 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1314 collection->addAction("deselect_timeline_clip", deselectTimelineClip);
1315 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1317 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1318 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1319 collection->addAction("select_add_timeline_clip", selectAddTimelineClip);
1320 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1322 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1323 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1324 collection->addAction("select_timeline_transition", selectTimelineTransition);
1325 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1327 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1328 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1329 collection->addAction("deselect_timeline_transition", deselectTimelineTransition);
1330 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1332 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1333 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1334 collection->addAction("select_add_timeline_transition", selectAddTimelineTransition);
1335 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1337 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1338 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1339 collection->addAction("cut_timeline_clip", cutTimelineClip);
1340 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1342 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1343 collection->addAction("add_clip_marker", addClipMarker);
1344 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1346 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1347 collection->addAction("delete_clip_marker", deleteClipMarker);
1348 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1350 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1351 collection->addAction("delete_all_clip_markers", deleteAllClipMarkers);
1352 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1354 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1355 collection->addAction("edit_clip_marker", editClipMarker);
1356 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1358 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1359 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1360 collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1361 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1363 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1364 collection->addAction("split_audio", splitAudio);
1365 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1367 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1368 collection->addAction("clip_audio_only", audioOnly);
1369 audioOnly->setData("clip_audio_only");
1370 audioOnly->setCheckable(true);
1372 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1373 collection->addAction("clip_video_only", videoOnly);
1374 videoOnly->setData("clip_video_only");
1375 videoOnly->setCheckable(true);
1377 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1378 collection->addAction("clip_audio_and_video", audioAndVideo);
1379 audioAndVideo->setData("clip_audio_and_video");
1380 audioAndVideo->setCheckable(true);
1382 m_clipTypeGroup = new QActionGroup(this);
1383 m_clipTypeGroup->addAction(audioOnly);
1384 m_clipTypeGroup->addAction(videoOnly);
1385 m_clipTypeGroup->addAction(audioAndVideo);
1386 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1387 m_clipTypeGroup->setEnabled(false);
1389 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1390 collection->addAction("insert_space", insertSpace);
1391 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1393 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1394 collection->addAction("delete_space", removeSpace);
1395 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1397 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1398 collection->addAction("insert_track", insertTrack);
1399 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1401 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1402 collection->addAction("delete_track", deleteTrack);
1403 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1405 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1406 collection->addAction("config_tracks", configTracks);
1407 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1409 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1410 collection->addAction("add_guide", addGuide);
1411 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1413 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1414 collection->addAction("delete_guide", delGuide);
1415 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1417 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1418 collection->addAction("edit_guide", editGuide);
1419 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1421 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1422 collection->addAction("delete_all_guides", delAllGuides);
1423 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1425 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1426 collection->addAction("paste_effects", pasteEffects);
1427 pasteEffects->setData("paste_effects");
1428 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1430 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1431 collection->addAction("show_timeline", showTimeline);
1432 showTimeline->setCheckable(true);
1433 showTimeline->setChecked(true);
1434 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1436 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1437 collection->addAction("show_titlebars", showTitleBar);
1438 showTitleBar->setCheckable(true);
1439 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1440 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1441 slotShowTitleBars(KdenliveSettings::showtitlebars());
1444 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1446 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1447 collection->addAction("maximize_current", maxCurrent);
1448 maxCurrent->setCheckable(true);
1449 maxCurrent->setChecked(false);
1450 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1452 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1453 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1454 KStandardAction::open(this, SLOT(openFile()), collection);
1455 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1456 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1457 KStandardAction::openNew(this, SLOT(newFile()), collection);
1458 // TODO: make the following connection to slotEditKeys work
1459 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1460 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1461 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1462 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1463 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1464 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1466 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1467 undo->setEnabled(false);
1468 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1470 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1471 redo->setEnabled(false);
1472 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1475 //TODO: Add status tooltip to actions ?
1476 connect(collection, SIGNAL(actionHovered(QAction*)),
1477 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1480 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1481 collection->addAction("add_clip", addClip);
1482 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1484 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1485 collection->addAction("add_color_clip", addColorClip);
1486 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1488 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1489 collection->addAction("add_slide_clip", addSlideClip);
1490 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1492 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1493 collection->addAction("add_text_clip", addTitleClip);
1494 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1496 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1497 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1498 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1500 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1501 collection->addAction("add_folder", addFolderButton);
1502 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1504 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1505 collection->addAction("clip_properties", clipProperties);
1506 clipProperties->setData("clip_properties");
1507 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1508 clipProperties->setEnabled(false);
1510 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1511 collection->addAction("edit_clip", openClip);
1512 openClip->setData("edit_clip");
1513 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1514 openClip->setEnabled(false);
1516 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1517 collection->addAction("delete_clip", deleteClip);
1518 deleteClip->setData("delete_clip");
1519 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1520 deleteClip->setEnabled(false);
1522 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1523 collection->addAction("reload_clip", reloadClip);
1524 reloadClip->setData("reload_clip");
1525 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1526 reloadClip->setEnabled(false);
1528 QMenu *addClips = new QMenu();
1529 addClips->addAction(addClip);
1530 addClips->addAction(addColorClip);
1531 addClips->addAction(addSlideClip);
1532 addClips->addAction(addTitleClip);
1533 addClips->addAction(addTitleTemplateClip);
1534 addClips->addAction(addFolderButton);
1536 addClips->addAction(reloadClip);
1537 addClips->addAction(clipProperties);
1538 addClips->addAction(openClip);
1539 addClips->addAction(deleteClip);
1540 m_projectList->setupMenu(addClips, addClip);
1542 // Setup effects and transitions actions.
1543 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1544 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1545 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1546 m_videoEffects = new KAction*[videoEffects.count()];
1547 for (int i = 0; i < videoEffects.count(); ++i) {
1548 QStringList effectInfo = videoEffects.effectIdInfo(i);
1549 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1550 m_videoEffects[i]->setData(effectInfo);
1551 m_videoEffects[i]->setIconVisibleInMenu(false);
1552 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1554 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1555 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1556 m_audioEffects = new KAction*[audioEffects.count()];
1557 for (int i = 0; i < audioEffects.count(); ++i) {
1558 QStringList effectInfo = audioEffects.effectIdInfo(i);
1559 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1560 m_audioEffects[i]->setData(effectInfo);
1561 m_audioEffects[i]->setIconVisibleInMenu(false);
1562 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1564 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1565 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1566 m_customEffects = new KAction*[customEffects.count()];
1567 for (int i = 0; i < customEffects.count(); ++i) {
1568 QStringList effectInfo = customEffects.effectIdInfo(i);
1569 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1570 m_customEffects[i]->setData(effectInfo);
1571 m_customEffects[i]->setIconVisibleInMenu(false);
1572 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1574 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1575 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1576 m_transitions = new KAction*[transitions.count()];
1577 for (int i = 0; i < transitions.count(); i++) {
1578 QStringList effectInfo = transitions.effectIdInfo(i);
1579 m_transitions[i] = new KAction(effectInfo.at(0), this);
1580 m_transitions[i]->setData(effectInfo);
1581 m_transitions[i]->setIconVisibleInMenu(false);
1582 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1584 m_effectsActionCollection->readSettings();
1586 //connect(collection, SIGNAL( clearStatusText() ),
1587 //statusBar(), SLOT( clear() ) );
1590 void MainWindow::slotDisplayActionMessage(QAction *a)
1592 statusBar()->showMessage(a->data().toString(), 3000);
1595 void MainWindow::loadLayouts()
1597 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1598 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1599 if (loadLayout == NULL || saveLayout == NULL) return;
1600 KSharedConfigPtr config = KGlobal::config();
1601 KConfigGroup layoutGroup(config, "Layouts");
1602 QStringList entries = layoutGroup.keyList();
1603 QList<QAction *> loadActions = loadLayout->actions();
1604 QList<QAction *> saveActions = saveLayout->actions();
1605 for (int i = 1; i < 5; i++) {
1606 // Rename the layouts actions
1607 foreach(const QString & key, entries) {
1608 if (key.endsWith(QString("_%1").arg(i))) {
1609 // Found previously saved layout
1610 QString layoutName = key.section("_", 0, -2);
1611 for (int j = 0; j < loadActions.count(); j++) {
1612 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1613 loadActions[j]->setText(layoutName);
1614 loadActions[j]->setData(key);
1618 for (int j = 0; j < saveActions.count(); j++) {
1619 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1620 saveActions[j]->setText(layoutName);
1621 saveActions[j]->setData(key);
1630 void MainWindow::slotLoadLayout(QAction *action)
1632 if (!action) return;
1633 QString layoutId = action->data().toString();
1634 if (layoutId.isEmpty()) return;
1635 KSharedConfigPtr config = KGlobal::config();
1636 KConfigGroup layouts(config, "Layouts");
1637 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1638 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1639 //restoreGeometry(geom);
1640 restoreState(state);
1643 void MainWindow::slotSaveLayout(QAction *action)
1645 QString originallayoutName = action->data().toString();
1646 int layoutId = originallayoutName.section('_', -1).toInt();
1648 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1649 if (layoutName.isEmpty()) return;
1650 KSharedConfigPtr config = KGlobal::config();
1651 KConfigGroup layouts(config, "Layouts");
1652 layouts.deleteEntry(originallayoutName);
1654 QByteArray st = saveState();
1655 layoutName.append("_" + QString::number(layoutId));
1656 layouts.writeEntry(layoutName, st.toBase64());
1660 void MainWindow::saveOptions()
1662 KdenliveSettings::self()->writeConfig();
1663 KSharedConfigPtr config = KGlobal::config();
1664 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1665 KConfigGroup treecolumns(config, "Project Tree");
1666 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1670 void MainWindow::readOptions()
1672 KSharedConfigPtr config = KGlobal::config();
1673 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1674 KConfigGroup initialGroup(config, "version");
1675 bool upgrade = false;
1676 if (initialGroup.exists()) {
1677 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1681 if (initialGroup.readEntry("version") == "0.7") {
1682 //Add new settings from 0.7.1
1683 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1684 QString path = QDir::homePath() + "/kdenlive";
1685 if (KStandardDirs::makeDir(path) == false) {
1686 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1687 } else KdenliveSettings::setDefaultprojectfolder(path);
1693 if (!initialGroup.exists() || upgrade) {
1694 // this is our first run, show Wizard
1695 Wizard *w = new Wizard(upgrade, this);
1696 if (w->exec() == QDialog::Accepted && w->isOk()) {
1697 w->adjustSettings();
1698 initialGroup.writeEntry("version", version);
1704 KConfigGroup treecolumns(config, "Project Tree");
1705 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1706 if (!state.isEmpty())
1707 m_projectList->setHeaderInfo(state);
1710 void MainWindow::slotRunWizard()
1712 Wizard *w = new Wizard(false, this);
1713 if (w->exec() == QDialog::Accepted && w->isOk()) {
1714 w->adjustSettings();
1719 void MainWindow::newFile(bool showProjectSettings, bool force)
1721 if (!m_timelineArea->isEnabled() && !force)
1723 m_fileRevert->setEnabled(false);
1724 QString profileName = KdenliveSettings::default_profile();
1725 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1726 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1727 if (!showProjectSettings) {
1728 if (!KdenliveSettings::activatetabs())
1729 if (!closeCurrentDocument())
1732 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1733 if (w->exec() != QDialog::Accepted)
1735 if (!KdenliveSettings::activatetabs())
1736 if (!closeCurrentDocument())
1738 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1739 slotSwitchVideoThumbs();
1740 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1741 slotSwitchAudioThumbs();
1742 profileName = w->selectedProfile();
1743 projectFolder = w->selectedFolder();
1744 projectTracks = w->tracks();
1747 m_timelineArea->setEnabled(true);
1748 m_projectList->setEnabled(true);
1749 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1750 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1752 TrackView *trackView = new TrackView(doc, &ok, this);
1753 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1756 //m_timelineArea->setEnabled(false);
1757 //m_projectList->setEnabled(false);
1761 if (m_timelineArea->count() == 1) {
1762 connectDocumentInfo(doc);
1763 connectDocument(trackView, doc);
1765 m_timelineArea->setTabBarHidden(false);
1766 m_monitorManager->activateMonitor("clip");
1767 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1770 void MainWindow::activateDocument()
1772 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1773 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1774 KdenliveDoc *currentDoc = currentTab->document();
1775 connectDocumentInfo(currentDoc);
1776 connectDocument(currentTab, currentDoc);
1779 bool MainWindow::closeCurrentDocument(bool saveChanges)
1781 QWidget *w = m_timelineArea->currentWidget();
1782 if (!w) return true;
1783 // closing current document
1784 int ix = m_timelineArea->currentIndex() + 1;
1785 if (ix == m_timelineArea->count()) ix = 0;
1786 m_timelineArea->setCurrentIndex(ix);
1787 TrackView *tabToClose = (TrackView *) w;
1788 KdenliveDoc *docToClose = tabToClose->document();
1789 if (docToClose && docToClose->isModified() && saveChanges) {
1791 if (m_activeDocument->url().fileName().isEmpty())
1792 message = i18n("Save changes to document?");
1794 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1795 switch (KMessageBox::warningYesNoCancel(this, message)) {
1796 case KMessageBox::Yes :
1797 // save document here. If saving fails, return false;
1798 if (saveFile() == false) return false;
1800 case KMessageBox::Cancel :
1807 m_clipMonitor->slotSetXml(NULL);
1808 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1809 if (m_timelineArea->count() == 1) {
1810 m_timelineArea->setTabBarHidden(true);
1811 m_closeAction->setEnabled(false);
1813 if (docToClose == m_activeDocument) {
1814 delete m_activeDocument;
1815 m_activeDocument = NULL;
1816 m_effectStack->clear();
1817 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1821 if (w == m_activeTimeline) {
1822 delete m_activeTimeline;
1823 m_activeTimeline = NULL;
1830 bool MainWindow::saveFileAs(const QString &outputFileName)
1832 QString currentSceneList;
1833 m_monitorManager->stopActiveMonitor();
1834 if (KdenliveSettings::dropbframes()) {
1835 KdenliveSettings::setDropbframes(false);
1836 m_activeDocument->clipManager()->updatePreviewSettings();
1837 currentSceneList = m_projectMonitor->sceneList();
1838 KdenliveSettings::setDropbframes(true);
1839 m_activeDocument->clipManager()->updatePreviewSettings();
1840 } else currentSceneList = m_projectMonitor->sceneList();
1842 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1845 // Save timeline thumbnails
1846 m_activeTimeline->projectView()->saveThumbnails();
1847 m_activeDocument->setUrl(KUrl(outputFileName));
1848 if (m_activeDocument->m_autosave == NULL) {
1849 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1850 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1851 setCaption(m_activeDocument->description());
1852 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1853 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1854 m_activeDocument->setModified(false);
1855 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1856 m_fileRevert->setEnabled(true);
1860 bool MainWindow::saveFileAs()
1862 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1863 if (outputFile.isEmpty()) {
1866 if (QFile::exists(outputFile)) {
1867 // Show the file dialog again if the user does not want to overwrite the file
1868 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1869 return saveFileAs();
1871 return saveFileAs(outputFile);
1874 bool MainWindow::saveFile()
1876 if (!m_activeDocument) return true;
1877 if (m_activeDocument->url().isEmpty()) {
1878 return saveFileAs();
1880 bool result = saveFileAs(m_activeDocument->url().path());
1881 m_activeDocument->m_autosave->resize(0);
1886 void MainWindow::openFile()
1888 if (!m_startUrl.isEmpty()) {
1889 openFile(m_startUrl);
1890 m_startUrl = KUrl();
1893 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1894 if (url.isEmpty()) return;
1895 m_fileOpenRecent->addUrl(url);
1899 void MainWindow::openLastFile()
1901 KSharedConfigPtr config = KGlobal::config();
1902 KUrl::List urls = m_fileOpenRecent->urls();
1903 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1904 if (urls.isEmpty()) newFile(false);
1905 else openFile(urls.last());
1908 void MainWindow::openFile(const KUrl &url)
1910 // Check if the document is already opened
1911 const int ct = m_timelineArea->count();
1912 bool isOpened = false;
1914 for (i = 0; i < ct; i++) {
1915 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1916 KdenliveDoc *doc = tab->document();
1917 if (doc->url() == url) {
1923 m_timelineArea->setCurrentIndex(i);
1927 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1929 // Check for backup file
1930 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1931 if (!staleFiles.isEmpty()) {
1932 if (KMessageBox::questionYesNo(this,
1933 i18n("Auto-saved files exist. Do you want to recover them now?"),
1934 i18n("File Recovery"),
1935 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1936 recoverFiles(staleFiles);
1939 // remove the stale files
1940 foreach(KAutoSaveFile * stale, staleFiles) {
1941 stale->open(QIODevice::ReadWrite);
1946 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1947 m_messageLabel->repaint();
1948 doOpenFile(url, NULL);
1951 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1953 if (!m_timelineArea->isEnabled()) return;
1954 m_fileRevert->setEnabled(true);
1955 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this);
1956 if (stale == NULL) {
1957 stale = new KAutoSaveFile(url, doc);
1958 doc->m_autosave = stale;
1960 doc->m_autosave = stale;
1961 doc->setUrl(stale->managedFile());
1962 doc->setModified(true);
1963 stale->setParent(doc);
1965 connectDocumentInfo(doc);
1967 TrackView *trackView = new TrackView(doc, &ok, this);
1968 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1970 m_timelineArea->setEnabled(false);
1971 m_projectList->setEnabled(false);
1972 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1973 slotGotProgressInfo(QString(), -1);
1974 newFile(false, true);
1977 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1978 trackView->setDuration(trackView->duration());
1979 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1981 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1982 slotGotProgressInfo(QString(), -1);
1983 m_projectMonitor->adjustRulerSize(trackView->duration());
1984 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1985 m_clipMonitor->refreshMonitor(true);
1988 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1990 foreach(KAutoSaveFile * stale, staleFiles) {
1991 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1992 // show an error message; we could not steal the lockfile
1993 // maybe another application got to the file before us?
1997 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1998 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1999 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2000 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2004 void MainWindow::parseProfiles(const QString &mltPath)
2006 //KdenliveSettings::setDefaulttmpfolder();
2007 if (!mltPath.isEmpty()) {
2008 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2009 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2012 if (KdenliveSettings::mltpath().isEmpty())
2013 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2015 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2016 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2017 if (!QFile::exists(meltPath))
2018 meltPath = KStandardDirs::findExe("melt");
2019 KdenliveSettings::setRendererpath(meltPath);
2022 if (KdenliveSettings::rendererpath().isEmpty()) {
2023 // Cannot find the MLT melt renderer, ask for location
2024 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2025 if (getUrl->exec() == QDialog::Rejected) {
2028 KUrl rendererPath = getUrl->selectedUrl();
2030 if (rendererPath.isEmpty()) ::exit(0);
2031 KdenliveSettings::setRendererpath(rendererPath.path());
2034 QStringList profilesFilter;
2035 profilesFilter << "*";
2036 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2037 if (profilesList.isEmpty()) {
2038 // Cannot find MLT path, try finding melt
2039 QString profilePath = KdenliveSettings::rendererpath();
2040 if (!profilePath.isEmpty()) {
2041 profilePath = profilePath.section('/', 0, -3);
2042 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2043 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2045 if (profilesList.isEmpty()) {
2046 // Cannot find the MLT profiles, ask for location
2047 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2048 getUrl->fileDialog()->setMode(KFile::Directory);
2049 if (getUrl->exec() == QDialog::Rejected) {
2052 KUrl mltPath = getUrl->selectedUrl();
2054 if (mltPath.isEmpty()) ::exit(0);
2055 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2056 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2060 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2062 // Parse again MLT profiles to build a list of available video formats
2063 if (profilesList.isEmpty()) parseProfiles();
2067 void MainWindow::slotEditProfiles()
2069 ProfilesDialog *w = new ProfilesDialog;
2070 if (w->exec() == QDialog::Accepted) {
2071 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2072 if (d) d->checkProfile();
2077 void MainWindow::slotDetectAudioDriver()
2079 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2080 leading to no audio output, see bug #934 */
2082 //decide which audio driver is really best, in some cases SDL is wrong
2083 if (KdenliveSettings::audiodrivername().isEmpty()) {
2085 KProcess readProcess;
2086 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2087 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2088 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2089 readProcess.setProgram("pactl", QStringList() << "stat");
2090 readProcess.execute(2000); // Kill it after 2 seconds
2092 QString result = QString(readProcess.readAllStandardOutput());
2093 kDebug() << "// / / / / / READING PACTL: ";
2095 if (!result.isEmpty()) {
2097 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2101 KdenliveSettings::setAutoaudiodrivername(driver);
2105 void MainWindow::slotEditProjectSettings()
2107 QPoint p = m_activeDocument->getTracksCount();
2108 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2110 if (w->exec() == QDialog::Accepted) {
2111 QString profile = w->selectedProfile();
2112 m_activeDocument->setProjectFolder(w->selectedFolder());
2114 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2116 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2117 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2118 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2119 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2124 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2126 double dar = m_activeDocument->dar();
2128 // Deselect current effect / transition
2129 m_effectStack->slotClipItemSelected(NULL, 0);
2130 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2131 m_clipMonitor->slotSetXml(NULL);
2132 bool updateFps = m_activeDocument->setProfilePath(profile);
2133 KdenliveSettings::setCurrent_profile(profile);
2134 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2135 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2137 m_activeDocument->clipManager()->clearUnusedProducers();
2138 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2139 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2140 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2141 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2142 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2143 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2144 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2145 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2146 if (updateFps) m_activeTimeline->updateProjectFps();
2147 m_activeDocument->setModified(true);
2148 m_commandStack->activeStack()->clear();
2149 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2150 slotUpdateMousePosition(0);
2151 // We need to desactivate & reactivate monitors to get a refresh
2152 //m_monitorManager->switchMonitors();
2156 void MainWindow::slotRenderProject()
2158 if (!m_renderWidget) {
2159 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2160 m_renderWidget = new RenderWidget(projectfolder, this);
2161 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2162 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2163 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2164 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2165 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2166 if (m_activeDocument) {
2167 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2168 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2169 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2170 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2173 slotCheckRenderStatus();
2174 m_renderWidget->show();
2175 m_renderWidget->showNormal();
2177 // What are the following lines supposed to do?
2178 //m_activeTimeline->tracksNumber();
2179 //m_renderWidget->enableAudio(false);
2180 //m_renderWidget->export_audio;
2183 void MainWindow::slotCheckRenderStatus()
2185 // Make sure there are no missing clips
2187 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2190 void MainWindow::setRenderingProgress(const QString &url, int progress)
2193 m_renderWidget->setRenderJob(url, progress);
2196 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2199 m_renderWidget->setRenderStatus(url, status, error);
2202 void MainWindow::slotCleanProject()
2204 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2205 m_projectList->cleanup();
2208 void MainWindow::slotUpdateMousePosition(int pos)
2210 if (m_activeDocument)
2211 switch (m_timecodeFormat->currentIndex()) {
2213 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2216 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2220 void MainWindow::slotUpdateDocumentState(bool modified)
2222 if (!m_activeDocument) return;
2223 setCaption(m_activeDocument->description(), modified);
2224 m_saveAction->setEnabled(modified);
2226 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2227 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2229 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2230 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2234 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2236 if (m_activeDocument) {
2237 if (m_activeDocument == doc) return;
2238 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2240 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2243 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2245 //m_projectMonitor->stop();
2246 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2247 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2248 if (m_activeDocument) {
2249 if (m_activeDocument == doc) return;
2250 if (m_activeTimeline) {
2251 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2252 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2253 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2254 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2255 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2256 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2257 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2258 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2260 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2262 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2263 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2264 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2265 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2266 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2267 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2268 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2269 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2270 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2271 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2272 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2273 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2274 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2275 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2276 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2277 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2278 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2279 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2280 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2281 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2282 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2283 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2284 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2285 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2286 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2287 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2288 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2289 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2290 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2291 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2292 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2293 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2294 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2295 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2296 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2297 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2298 m_effectStack->clear();
2300 //m_activeDocument->setRenderer(NULL);
2301 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2302 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2303 m_clipMonitor->stop();
2305 KdenliveSettings::setCurrent_profile(doc->profilePath());
2306 KdenliveSettings::setProject_fps(doc->fps());
2307 m_monitorManager->resetProfiles(doc->timecode());
2308 m_projectList->setDocument(doc);
2309 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2310 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2311 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2312 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2313 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2315 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2316 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2317 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2319 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2322 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2323 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2324 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2325 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2326 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2327 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2328 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2329 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2330 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2331 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2332 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2333 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2334 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2335 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2337 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2338 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2339 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2340 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2341 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2343 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2344 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2345 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2346 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2348 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2349 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2350 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2351 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2353 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2354 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2355 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2356 m_zoomSlider->setValue(doc->zoom().x());
2357 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2358 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2359 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2360 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2362 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2363 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2365 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2366 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2368 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2369 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2370 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2371 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2372 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2373 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2374 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2375 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2376 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2377 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2378 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2380 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2381 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2382 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2383 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2384 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2387 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2388 m_activeTimeline = trackView;
2389 if (m_renderWidget) {
2390 slotCheckRenderStatus();
2391 m_renderWidget->setProfile(doc->mltProfile());
2392 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2393 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2394 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2396 //doc->setRenderer(m_projectMonitor->render);
2397 m_commandStack->setActiveStack(doc->commandStack());
2398 KdenliveSettings::setProject_display_ratio(doc->dar());
2399 //doc->clipManager()->checkAudioThumbs();
2401 //m_overView->setScene(trackView->projectScene());
2402 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2403 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2405 setCaption(doc->description(), doc->isModified());
2406 m_saveAction->setEnabled(doc->isModified());
2407 m_normalEditTool->setChecked(true);
2408 m_activeDocument = doc;
2409 m_activeTimeline->updateProjectFps();
2410 m_activeDocument->checkProjectClips();
2412 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2414 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2415 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2416 slotUpdateMousePosition(0);
2417 // set tool to select tool
2418 m_buttonSelectTool->setChecked(true);
2421 void MainWindow::slotZoneMoved(int start, int end)
2423 m_activeDocument->setZone(start, end);
2424 m_projectMonitor->slotZoneMoved(start, end);
2427 void MainWindow::slotGuidesUpdated()
2430 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2433 void MainWindow::slotEditKeys()
2435 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2436 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2437 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2441 void MainWindow::slotPreferences(int page, int option)
2444 * An instance of your dialog could be already created and could be
2445 * cached, in which case you want to display the cached dialog
2446 * instead of creating another one
2448 if (KConfigDialog::showDialog("settings")) {
2449 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2450 if (page != -1) d->showPage(page, option);
2454 // KConfigDialog didn't find an instance of this dialog, so lets
2456 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2457 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2458 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2459 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2460 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2462 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2464 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2466 if (page != -1) dialog->showPage(page, option);
2469 void MainWindow::slotUpdateCaptureFolder()
2473 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2474 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2478 void MainWindow::slotUpdatePreviewSettings()
2480 if (m_activeDocument) {
2481 m_clipMonitor->slotSetXml(NULL);
2482 m_activeDocument->updatePreviewSettings();
2486 void MainWindow::updateConfiguration()
2488 //TODO: we should apply settings to all projects, not only the current one
2489 if (m_activeTimeline) {
2490 m_activeTimeline->refresh();
2491 m_activeTimeline->projectView()->checkAutoScroll();
2492 m_activeTimeline->projectView()->checkTrackHeight();
2493 if (m_activeDocument)
2494 m_activeDocument->clipManager()->checkAudioThumbs();
2496 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2497 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2498 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2499 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2501 // Update list of transcoding profiles
2503 #ifndef NO_JOGSHUTTLE
2504 activateShuttleDevice();
2505 #endif /* NO_JOGSHUTTLE */
2509 void MainWindow::slotSwitchSplitAudio()
2511 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2512 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2515 void MainWindow::slotSwitchVideoThumbs()
2517 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2518 if (m_activeTimeline)
2519 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2520 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2523 void MainWindow::slotSwitchAudioThumbs()
2525 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2526 if (m_activeTimeline) {
2527 m_activeTimeline->refresh();
2528 m_activeTimeline->projectView()->checkAutoScroll();
2529 if (m_activeDocument)
2530 m_activeDocument->clipManager()->checkAudioThumbs();
2532 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2535 void MainWindow::slotSwitchMarkersComments()
2537 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2538 if (m_activeTimeline)
2539 m_activeTimeline->refresh();
2540 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2543 void MainWindow::slotSwitchSnap()
2545 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2546 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2550 void MainWindow::slotDeleteItem()
2552 if (QApplication::focusWidget() &&
2553 QApplication::focusWidget()->parentWidget() &&
2554 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2555 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2556 m_projectList->slotRemoveClip();
2559 QWidget *widget = QApplication::focusWidget();
2561 if (widget == m_effectStackDock) {
2562 m_effectStack->slotItemDel();
2565 widget = widget->parentWidget();
2568 // effect stack has no focus
2569 if (m_activeTimeline)
2570 m_activeTimeline->projectView()->deleteSelectedClips();
2574 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2576 if (m_clipMonitor->isActive())
2577 m_clipMonitor->checkOverlay();
2578 m_clipMonitor->updateMarkers(clip);
2581 void MainWindow::slotAddClipMarker()
2583 DocClipBase *clip = NULL;
2585 if (m_projectMonitor->isActive()) {
2586 if (m_activeTimeline) {
2587 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2589 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2590 clip = item->baseClip();
2594 clip = m_clipMonitor->activeClip();
2595 pos = m_clipMonitor->position();
2598 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2601 QString id = clip->getId();
2602 CommentedTime marker(pos, i18n("Marker"));
2603 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2604 if (d.exec() == QDialog::Accepted)
2605 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2608 void MainWindow::slotDeleteClipMarker()
2610 DocClipBase *clip = NULL;
2612 if (m_projectMonitor->isActive()) {
2613 if (m_activeTimeline) {
2614 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2616 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2617 clip = item->baseClip();
2621 clip = m_clipMonitor->activeClip();
2622 pos = m_clipMonitor->position();
2625 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2629 QString id = clip->getId();
2630 QString comment = clip->markerComment(pos);
2631 if (comment.isEmpty()) {
2632 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2635 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2638 void MainWindow::slotDeleteAllClipMarkers()
2640 DocClipBase *clip = NULL;
2641 if (m_projectMonitor->isActive()) {
2642 if (m_activeTimeline) {
2643 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2645 clip = item->baseClip();
2649 clip = m_clipMonitor->activeClip();
2652 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2655 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2658 void MainWindow::slotEditClipMarker()
2660 DocClipBase *clip = NULL;
2662 if (m_projectMonitor->isActive()) {
2663 if (m_activeTimeline) {
2664 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2666 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2667 clip = item->baseClip();
2671 clip = m_clipMonitor->activeClip();
2672 pos = m_clipMonitor->position();
2675 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2679 QString id = clip->getId();
2680 QString oldcomment = clip->markerComment(pos);
2681 if (oldcomment.isEmpty()) {
2682 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2686 CommentedTime marker(pos, oldcomment);
2687 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2688 if (d.exec() == QDialog::Accepted) {
2689 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2690 if (d.newMarker().time() != pos) {
2691 // remove old marker
2692 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2697 void MainWindow::slotAddMarkerGuideQuickly()
2699 if (!m_activeTimeline || !m_activeDocument)
2702 if (m_clipMonitor->isActive()) {
2703 DocClipBase *clip = m_clipMonitor->activeClip();
2704 GenTime pos = m_clipMonitor->position();
2707 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2711 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2713 m_activeTimeline->projectView()->slotAddGuide(false);
2717 void MainWindow::slotAddGuide()
2719 if (m_activeTimeline)
2720 m_activeTimeline->projectView()->slotAddGuide();
2723 void MainWindow::slotInsertSpace()
2725 if (m_activeTimeline)
2726 m_activeTimeline->projectView()->slotInsertSpace();
2729 void MainWindow::slotRemoveSpace()
2731 if (m_activeTimeline)
2732 m_activeTimeline->projectView()->slotRemoveSpace();
2735 void MainWindow::slotInsertTrack(int ix)
2737 m_projectMonitor->activateMonitor();
2738 if (m_activeTimeline)
2739 m_activeTimeline->projectView()->slotInsertTrack(ix);
2740 if (m_activeDocument)
2741 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2744 void MainWindow::slotDeleteTrack(int ix)
2746 m_projectMonitor->activateMonitor();
2747 if (m_activeTimeline)
2748 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2749 if (m_activeDocument)
2750 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2753 void MainWindow::slotConfigTrack(int ix)
2755 m_projectMonitor->activateMonitor();
2756 if (m_activeTimeline)
2757 m_activeTimeline->projectView()->slotConfigTracks(ix);
2758 if (m_activeDocument)
2759 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2762 void MainWindow::slotEditGuide()
2764 if (m_activeTimeline)
2765 m_activeTimeline->projectView()->slotEditGuide();
2768 void MainWindow::slotDeleteGuide()
2770 if (m_activeTimeline)
2771 m_activeTimeline->projectView()->slotDeleteGuide();
2774 void MainWindow::slotDeleteAllGuides()
2776 if (m_activeTimeline)
2777 m_activeTimeline->projectView()->slotDeleteAllGuides();
2780 void MainWindow::slotCutTimelineClip()
2782 if (m_activeTimeline)
2783 m_activeTimeline->projectView()->cutSelectedClips();
2786 void MainWindow::slotInsertClipOverwrite()
2788 if (m_activeTimeline) {
2789 QStringList data = m_clipMonitor->getZoneInfo();
2790 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2794 void MainWindow::slotSelectTimelineClip()
2796 if (m_activeTimeline)
2797 m_activeTimeline->projectView()->selectClip(true);
2800 void MainWindow::slotSelectTimelineTransition()
2802 if (m_activeTimeline)
2803 m_activeTimeline->projectView()->selectTransition(true);
2806 void MainWindow::slotDeselectTimelineClip()
2808 if (m_activeTimeline)
2809 m_activeTimeline->projectView()->selectClip(false, true);
2812 void MainWindow::slotDeselectTimelineTransition()
2814 if (m_activeTimeline)
2815 m_activeTimeline->projectView()->selectTransition(false, true);
2818 void MainWindow::slotSelectAddTimelineClip()
2820 if (m_activeTimeline)
2821 m_activeTimeline->projectView()->selectClip(true, true);
2824 void MainWindow::slotSelectAddTimelineTransition()
2826 if (m_activeTimeline)
2827 m_activeTimeline->projectView()->selectTransition(true, true);
2830 void MainWindow::slotGroupClips()
2832 if (m_activeTimeline)
2833 m_activeTimeline->projectView()->groupClips();
2836 void MainWindow::slotUnGroupClips()
2838 if (m_activeTimeline)
2839 m_activeTimeline->projectView()->groupClips(false);
2842 void MainWindow::slotEditItemDuration()
2844 if (m_activeTimeline)
2845 m_activeTimeline->projectView()->editItemDuration();
2848 void MainWindow::slotAddProjectClip(KUrl url)
2850 if (m_activeDocument)
2851 m_activeDocument->slotAddClipFile(url, QString());
2854 void MainWindow::slotAddTransition(QAction *result)
2856 if (!result) return;
2857 QStringList info = result->data().toStringList();
2858 if (info.isEmpty()) return;
2859 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2860 if (m_activeTimeline && !transition.isNull()) {
2861 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2865 void MainWindow::slotAddVideoEffect(QAction *result)
2867 if (!result) return;
2868 QStringList info = result->data().toStringList();
2869 if (info.isEmpty()) return;
2870 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2871 slotAddEffect(effect);
2874 void MainWindow::slotAddAudioEffect(QAction *result)
2876 if (!result) return;
2877 QStringList info = result->data().toStringList();
2878 if (info.isEmpty()) return;
2879 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2880 slotAddEffect(effect);
2883 void MainWindow::slotAddCustomEffect(QAction *result)
2885 if (!result) return;
2886 QStringList info = result->data().toStringList();
2887 if (info.isEmpty()) return;
2888 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2889 slotAddEffect(effect);
2892 void MainWindow::slotZoomIn()
2894 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2895 slotShowZoomSliderToolTip();
2898 void MainWindow::slotZoomOut()
2900 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2901 slotShowZoomSliderToolTip();
2904 void MainWindow::slotFitZoom()
2906 if (m_activeTimeline)
2907 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2910 void MainWindow::slotSetZoom(int value)
2912 value = qMax(m_zoomSlider->minimum(), value);
2913 value = qMin(m_zoomSlider->maximum(), value);
2915 if (m_activeTimeline)
2916 m_activeTimeline->slotChangeZoom(value);
2918 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2919 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2920 slotUpdateZoomSliderToolTip(value);
2922 m_zoomSlider->blockSignals(true);
2923 m_zoomSlider->setValue(value);
2924 m_zoomSlider->blockSignals(false);
2927 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2929 if (zoomlevel != -1)
2930 slotUpdateZoomSliderToolTip(zoomlevel);
2932 QPoint global = m_zoomSlider->rect().topLeft();
2933 global.ry() += m_zoomSlider->height() / 2;
2934 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2935 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2938 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2940 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2943 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2945 m_statusProgressBar->setValue(progress);
2946 if (progress >= 0) {
2947 if (!message.isEmpty())
2948 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2949 m_statusProgressBar->setVisible(true);
2950 } else if (progress == -2) {
2951 if (!message.isEmpty())
2952 m_messageLabel->setMessage(message, ErrorMessage);
2953 m_statusProgressBar->setVisible(false);
2955 m_messageLabel->setMessage(QString(), DefaultMessage);
2956 m_statusProgressBar->setVisible(false);
2960 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2962 if (clip->clipType() == TEXT) {
2963 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2964 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2965 // template text clip
2967 // Get the list of existing templates
2969 filter << "*.kdenlivetitle";
2970 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2972 QDialog *dia = new QDialog(this);
2973 Ui::TemplateClip_UI dia_ui;
2974 dia_ui.setupUi(dia);
2976 const QString templatePath = clip->getProperty("resource");
2977 for (int i = 0; i < templateFiles.size(); ++i) {
2978 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2979 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2981 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2982 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2983 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2984 //warning: setting base directory doesn't work??
2985 KUrl startDir(titlepath);
2986 dia_ui.template_list->fileDialog()->setUrl(startDir);
2987 dia_ui.description->setText(clip->getProperty("description"));
2988 if (dia->exec() == QDialog::Accepted) {
2989 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2990 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2992 QMap <QString, QString> newprops;
2994 if (KUrl(textTemplate).path() != templatePath) {
2995 // The template was changed
2996 newprops.insert("resource", textTemplate);
2999 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3000 newprops.insert("description", dia_ui.description->toPlainText());
3003 QString newtemplate = newprops.value("xmltemplate");
3004 if (newtemplate.isEmpty()) newtemplate = templatePath;
3006 // template modified we need to update xmldata
3007 QString description = newprops.value("description");
3008 if (description.isEmpty()) description = clip->getProperty("description");
3009 else newprops.insert("templatetext", description);
3010 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3011 if (!newprops.isEmpty()) {
3012 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3013 m_activeDocument->commandStack()->push(command);
3019 QString path = clip->getProperty("resource");
3020 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3022 doc.setContent(clip->getProperty("xmldata"));
3023 dia_ui->setXml(doc);
3024 if (dia_ui->exec() == QDialog::Accepted) {
3025 QMap <QString, QString> newprops;
3026 newprops.insert("xmldata", dia_ui->xml().toString());
3027 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3028 // duration changed, we need to update duration
3029 newprops.insert("out", QString::number(dia_ui->outPoint()));
3031 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3032 m_activeDocument->commandStack()->push(command);
3033 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3034 m_activeDocument->setModified(true);
3038 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3042 // any type of clip but a title
3043 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3044 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3045 if (dia.exec() == QDialog::Accepted) {
3046 QMap <QString, QString> newprops = dia.properties();
3047 if (newprops.isEmpty()) return;
3048 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3049 m_activeDocument->commandStack()->push(command);
3050 m_activeDocument->setModified();
3052 if (dia.needsTimelineRefresh()) {
3053 // update clip occurences in timeline
3054 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
3060 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3062 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3063 if (dia.exec() == QDialog::Accepted) {
3064 QUndoCommand *command = new QUndoCommand();
3065 command->setText(i18n("Edit clips"));
3066 for (int i = 0; i < cliplist.count(); i++) {
3067 DocClipBase *clip = cliplist.at(i);
3068 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3070 m_activeDocument->commandStack()->push(command);
3071 for (int i = 0; i < cliplist.count(); i++)
3072 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3076 void MainWindow::customEvent(QEvent* e)
3078 if (e->type() == QEvent::User)
3079 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3081 void MainWindow::slotActivateEffectStackView()
3083 m_effectStack->raiseWindow(m_effectStackDock);
3086 void MainWindow::slotActivateTransitionView(Transition *t)
3089 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3092 void MainWindow::slotSnapRewind()
3094 if (m_projectMonitor->isActive()) {
3095 if (m_activeTimeline)
3096 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3098 m_clipMonitor->slotSeekToPreviousSnap();
3102 void MainWindow::slotSnapForward()
3104 if (m_projectMonitor->isActive()) {
3105 if (m_activeTimeline)
3106 m_activeTimeline->projectView()->slotSeekToNextSnap();
3108 m_clipMonitor->slotSeekToNextSnap();
3112 void MainWindow::slotClipStart()
3114 if (m_projectMonitor->isActive()) {
3115 if (m_activeTimeline)
3116 m_activeTimeline->projectView()->clipStart();
3120 void MainWindow::slotClipEnd()
3122 if (m_projectMonitor->isActive()) {
3123 if (m_activeTimeline)
3124 m_activeTimeline->projectView()->clipEnd();
3128 void MainWindow::slotZoneStart()
3130 if (m_projectMonitor->isActive())
3131 m_projectMonitor->slotZoneStart();
3133 m_clipMonitor->slotZoneStart();
3136 void MainWindow::slotZoneEnd()
3138 if (m_projectMonitor->isActive())
3139 m_projectMonitor->slotZoneEnd();
3141 m_clipMonitor->slotZoneEnd();
3144 void MainWindow::slotChangeTool(QAction * action)
3146 if (action == m_buttonSelectTool)
3147 slotSetTool(SELECTTOOL);
3148 else if (action == m_buttonRazorTool)
3149 slotSetTool(RAZORTOOL);
3150 else if (action == m_buttonSpacerTool)
3151 slotSetTool(SPACERTOOL);
3154 void MainWindow::slotChangeEdit(QAction * action)
3156 if (!m_activeTimeline)
3159 if (action == m_overwriteEditTool)
3160 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3161 else if (action == m_insertEditTool)
3162 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3164 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3167 void MainWindow::slotSetTool(PROJECTTOOL tool)
3169 if (m_activeDocument && m_activeTimeline) {
3170 //m_activeDocument->setTool(tool);
3174 message = i18n("Ctrl + click to use spacer on current track only");
3177 message = i18n("Click on a clip to cut it");
3180 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3183 m_messageLabel->setMessage(message, InformationMessage);
3184 m_activeTimeline->projectView()->setTool(tool);
3188 void MainWindow::slotCopy()
3190 if (m_activeDocument && m_activeTimeline)
3191 m_activeTimeline->projectView()->copyClip();
3194 void MainWindow::slotPaste()
3196 if (m_activeDocument && m_activeTimeline)
3197 m_activeTimeline->projectView()->pasteClip();
3200 void MainWindow::slotPasteEffects()
3202 if (m_activeDocument && m_activeTimeline)
3203 m_activeTimeline->projectView()->pasteClipEffects();
3206 void MainWindow::slotFind()
3208 if (!m_activeDocument || !m_activeTimeline) return;
3209 m_projectSearch->setEnabled(false);
3210 m_findActivated = true;
3211 m_findString.clear();
3212 m_activeTimeline->projectView()->initSearchStrings();
3213 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3214 m_findTimer.start(5000);
3215 qApp->installEventFilter(this);
3218 void MainWindow::slotFindNext()
3220 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3221 statusBar()->showMessage(i18n("Found: %1", m_findString));
3223 statusBar()->showMessage(i18n("Reached end of project"));
3224 m_findTimer.start(4000);
3227 void MainWindow::findAhead()
3229 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3230 m_projectSearchNext->setEnabled(true);
3231 statusBar()->showMessage(i18n("Found: %1", m_findString));
3233 m_projectSearchNext->setEnabled(false);
3234 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3238 void MainWindow::findTimeout()
3240 m_projectSearchNext->setEnabled(false);
3241 m_findActivated = false;
3242 m_findString.clear();
3243 statusBar()->showMessage(i18n("Find stopped"), 3000);
3244 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3245 m_projectSearch->setEnabled(true);
3246 removeEventFilter(this);
3249 void MainWindow::slotClipInTimeline(const QString &clipId)
3251 if (m_activeTimeline && m_activeDocument) {
3252 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3254 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3255 inTimelineMenu->clear();
3257 QList <QAction *> actionList;
3259 for (int i = 0; i < matching.count(); ++i) {
3260 QString track = QString::number(matching.at(i).track);
3261 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3263 QAction *a = new QAction(track + ": " + start, this);
3264 a->setData(QStringList() << track << start);
3265 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3266 while (j < actionList.count()) {
3267 if (actionList.at(j)->text() > a->text()) break;
3270 actionList.insert(j, a);
3272 inTimelineMenu->addActions(actionList);
3274 if (matching.empty())
3275 inTimelineMenu->setEnabled(false);
3277 inTimelineMenu->setEnabled(true);
3281 void MainWindow::slotClipInProjectTree()
3283 if (m_activeTimeline) {
3284 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3285 if (clipIds.isEmpty())
3287 m_projectListDock->raise();
3288 for (int i = 0; i < clipIds.count(); i++)
3289 m_projectList->selectItemById(clipIds.at(i));
3290 if (m_projectMonitor->isActive())
3291 slotSwitchMonitors();
3295 /*void MainWindow::slotClipToProjectTree()
3297 if (m_activeTimeline) {
3298 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3299 if (clips.isEmpty()) return;
3300 for (int i = 0; i < clips.count(); i++) {
3301 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3303 //m_projectList->selectItemById(clipIds.at(i));
3307 void MainWindow::slotSelectClipInTimeline()
3309 if (m_activeTimeline) {
3310 QAction *action = qobject_cast<QAction *>(sender());
3311 QStringList data = action->data().toStringList();
3312 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3316 void MainWindow::keyPressEvent(QKeyEvent *ke)
3318 if (m_findActivated) {
3319 if (ke->key() == Qt::Key_Backspace) {
3320 m_findString = m_findString.left(m_findString.length() - 1);
3322 if (!m_findString.isEmpty())
3327 m_findTimer.start(4000);
3330 } else if (ke->key() == Qt::Key_Escape) {
3334 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3335 m_findString += ke->text();
3339 m_findTimer.start(4000);
3344 KXmlGuiWindow::keyPressEvent(ke);
3349 /** Gets called when the window gets hidden */
3350 void MainWindow::hideEvent(QHideEvent */*event*/)
3352 if (isMinimized() && m_monitorManager)
3353 m_monitorManager->stopActiveMonitor();
3356 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3358 if (m_findActivated) {
3359 if (event->type() == QEvent::ShortcutOverride) {
3360 QKeyEvent* ke = (QKeyEvent*) event;
3361 if (ke->text().trimmed().isEmpty()) return false;
3368 // pass the event on to the parent class
3369 return QMainWindow::eventFilter(obj, event);
3374 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3376 KDialog *dialog = new KDialog(this);
3377 dialog->setCaption("Save clip zone");
3378 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3380 QWidget *widget = new QWidget(dialog);
3381 dialog->setMainWidget(widget);
3383 QVBoxLayout *vbox = new QVBoxLayout(widget);
3384 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3385 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3386 path.append("untitled.mlt");
3387 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3388 url->setFilter("video/mlt-playlist");
3389 QLabel *label2 = new QLabel(i18n("Description:"), this);
3390 KLineEdit *edit = new KLineEdit(this);
3391 vbox->addWidget(label1);
3392 vbox->addWidget(url);
3393 vbox->addWidget(label2);
3394 vbox->addWidget(edit);
3395 if (dialog->exec() == QDialog::Accepted)
3396 render->saveZone(url->url(), edit->text(), zone);
3400 void MainWindow::slotSetInPoint()
3402 if (m_clipMonitor->isActive())
3403 m_clipMonitor->slotSetZoneStart();
3405 m_projectMonitor->slotSetZoneStart();
3406 //else m_activeTimeline->projectView()->setInPoint();
3409 void MainWindow::slotSetOutPoint()
3411 if (m_clipMonitor->isActive())
3412 m_clipMonitor->slotSetZoneEnd();
3414 m_projectMonitor->slotSetZoneEnd();
3415 // else m_activeTimeline->projectView()->setOutPoint();
3418 void MainWindow::slotResizeItemStart()
3420 if (m_activeTimeline)
3421 m_activeTimeline->projectView()->setInPoint();
3424 void MainWindow::slotResizeItemEnd()
3426 if (m_activeTimeline)
3427 m_activeTimeline->projectView()->setOutPoint();
3430 int MainWindow::getNewStuff(const QString &configFile)
3432 KNS3::Entry::List entries;
3433 #if KDE_IS_VERSION(4,3,80)
3434 KNS3::DownloadDialog dialog(configFile);
3436 entries = dialog.changedEntries();
3437 foreach(const KNS3::Entry & entry, entries) {
3438 if (entry.status() == KNS3::Entry::Installed)
3439 kDebug() << "// Installed files: " << entry.installedFiles();
3442 KNS::Engine engine(0);
3443 if (engine.init(configFile))
3444 entries = engine.downloadDialogModal(this);
3445 foreach(KNS::Entry * entry, entries) {
3446 if (entry->status() == KNS::Entry::Installed)
3447 kDebug() << "// Installed files: " << entry->installedFiles();
3449 #endif /* KDE_IS_VERSION(4,3,80) */
3450 return entries.size();
3453 void MainWindow::slotGetNewTitleStuff()
3455 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3456 TitleWidget::refreshTitleTemplates();
3459 void MainWindow::slotGetNewLumaStuff()
3461 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3462 initEffects::refreshLumas();
3463 m_activeTimeline->projectView()->reloadTransitionLumas();
3467 void MainWindow::slotGetNewRenderStuff()
3469 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3471 m_renderWidget->reloadProfiles();
3474 void MainWindow::slotGetNewMltProfileStuff()
3476 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3477 // update the list of profiles in settings dialog
3478 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3484 void MainWindow::slotAutoTransition()
3486 if (m_activeTimeline)
3487 m_activeTimeline->projectView()->autoTransition();
3490 void MainWindow::slotSplitAudio()
3492 if (m_activeTimeline)
3493 m_activeTimeline->projectView()->splitAudio();
3496 void MainWindow::slotUpdateClipType(QAction *action)
3498 if (m_activeTimeline) {
3499 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3500 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3501 else m_activeTimeline->projectView()->setAudioAndVideo();
3505 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3507 // We must stop the monitors since we create a new on in the dvd wizard
3508 m_clipMonitor->stop();
3509 m_projectMonitor->stop();
3510 DvdWizard w(url, profile, this);
3512 m_projectMonitor->start();
3515 void MainWindow::slotShowTimeline(bool show)
3517 if (show == false) {
3518 m_timelineState = saveState();
3519 centralWidget()->setHidden(true);
3521 centralWidget()->setHidden(false);
3522 restoreState(m_timelineState);
3526 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3528 //TODO: is there a way to maximize current widget?
3531 m_timelineState = saveState();
3532 QWidget *par = focusWidget()->parentWidget();
3533 while (par->parentWidget() && par->parentWidget() != this)
3534 par = par->parentWidget();
3535 kDebug() << "CURRENT WIDGET: " << par->objectName();
3538 //centralWidget()->setHidden(false);
3539 //restoreState(m_timelineState);
3543 void MainWindow::loadTranscoders()
3545 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3548 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3549 KConfigGroup transConfig(config, "Transcoding");
3551 QMap< QString, QString > profiles = transConfig.entryMap();
3552 QMapIterator<QString, QString> i(profiles);
3553 while (i.hasNext()) {
3555 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3556 QAction *a = transMenu->addAction(i.key());
3558 if (data.count() > 1)
3559 a->setToolTip(data.at(1));
3560 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3564 void MainWindow::slotTranscode(KUrl::List urls)
3569 if (urls.isEmpty()) {
3570 QAction *action = qobject_cast<QAction *>(sender());
3571 QStringList data = action->data().toStringList();
3572 params = data.at(0);
3573 if (data.count() > 1) desc = data.at(1);
3574 if (data.count() > 2) condition = data.at(2);
3575 urls << m_projectList->getConditionalUrls(condition);
3576 urls.removeAll(KUrl());
3578 if (urls.isEmpty()) {
3579 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3582 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3583 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3585 //QProcess::startDetached("ffmpeg", parameters);
3588 void MainWindow::slotTranscodeClip()
3590 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3591 if (urls.isEmpty()) return;
3592 slotTranscode(urls);
3595 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3597 if (m_activeDocument == NULL) return;
3598 QMapIterator<QString, QString> i(props);
3599 while (i.hasNext()) {
3601 m_activeDocument->setDocumentProperty(i.key(), i.value());
3603 m_activeDocument->setModified(true);
3607 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3609 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3611 QString playlistPath;
3614 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3615 QString path = m_renderWidget->getFreeScriptName();
3616 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3617 if (!ok || scriptPath.isEmpty()) return;
3618 scriptPath.prepend(scriptsFolder);
3619 QFile f(scriptPath);
3621 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3624 playlistPath = scriptPath + ".mlt";
3625 m_projectMonitor->saveSceneList(playlistPath);
3627 KTemporaryFile temp;
3628 temp.setAutoRemove(false);
3629 temp.setSuffix(".mlt");
3631 playlistPath = temp.fileName();
3632 m_projectMonitor->saveSceneList(playlistPath);
3635 if (!chapterFile.isEmpty()) {
3638 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3640 in = m_activeTimeline->inPoint();
3641 out = m_activeTimeline->outPoint();
3644 QDomElement chapters = doc.createElement("chapters");
3645 chapters.setAttribute("fps", m_activeDocument->fps());
3646 doc.appendChild(chapters);
3648 QDomElement guidesxml = m_activeDocument->guidesXml();
3649 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3650 for (int i = 0; i < nodes.count(); i++) {
3651 QDomElement e = nodes.item(i).toElement();
3653 QString comment = e.attribute("comment");
3654 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3655 if (time >= in && time < out) {
3656 if (zoneOnly) time = time - in;
3657 QDomElement chapter = doc.createElement("chapter");
3658 chapters.appendChild(chapter);
3659 chapter.setAttribute("title", comment);
3660 chapter.setAttribute("time", time);
3664 if (chapters.childNodes().count() > 0) {
3665 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3666 // Always insert a guide in pos 0
3667 QDomElement chapter = doc.createElement("chapter");
3668 chapters.insertBefore(chapter, QDomNode());
3669 chapter.setAttribute("title", i18n("Start"));
3670 chapter.setAttribute("time", "0");
3672 // save chapters file
3673 QFile file(chapterFile);
3674 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3675 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3677 file.write(doc.toString().toUtf8());
3678 if (file.error() != QFile::NoError) {
3679 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3686 if (m_renderWidget->automaticAudioExport()) {
3687 exportAudio = m_activeTimeline->checkProjectAudio();
3688 } else exportAudio = m_renderWidget->selectedAudioExport();
3689 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3692 void MainWindow::slotUpdateTimecodeFormat(int ix)
3694 KdenliveSettings::setFrametimecode(ix == 1);
3695 m_clipMonitor->updateTimecodeFormat();
3696 m_projectMonitor->updateTimecodeFormat();
3697 m_transitionConfig->updateTimecodeFormat();
3698 m_effectStack->updateTimecodeFormat();
3699 //m_activeTimeline->projectView()->clearSelection();
3700 m_activeTimeline->updateRuler();
3703 void MainWindow::slotRemoveFocus()
3705 statusBar()->setFocus();
3706 statusBar()->clearFocus();
3709 void MainWindow::slotRevert()
3711 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;
3712 KUrl url = m_activeDocument->url();
3713 if (closeCurrentDocument(false))
3714 doOpenFile(url, NULL);
3718 void MainWindow::slotShutdown()
3720 if (m_activeDocument) m_activeDocument->setModified(false);
3722 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3723 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3724 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3725 smserver.call("logout", 1, 2, 2);
3726 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3727 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3728 smserver.call("Shutdown");
3732 void MainWindow::slotUpdateTrackInfo()
3734 if (m_activeDocument)
3735 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3738 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3740 // Load the theme file
3742 if (action == NULL) theme = themename;
3743 else theme = action->data().toString();
3744 KdenliveSettings::setColortheme(theme);
3745 // Make palette for all widgets.
3747 if (theme.isEmpty())
3748 plt = QApplication::desktop()->palette();
3750 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3751 plt = KGlobalSettings::createApplicationPalette(config);
3754 kapp->setPalette(plt);
3755 const QObjectList children = statusBar()->children();
3757 foreach(QObject * child, children) {
3758 if (child->isWidgetType())
3759 ((QWidget*)child)->setPalette(plt);
3760 const QObjectList subchildren = child->children();
3761 foreach(QObject * subchild, subchildren) {
3762 if (subchild->isWidgetType())
3763 ((QWidget*)subchild)->setPalette(plt);
3766 if (m_activeTimeline) {
3767 m_activeTimeline->projectView()->updatePalette();
3772 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3774 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3775 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3776 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3777 const QSize bitsSize(24, 2);
3778 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3779 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3781 QPixmap pixmap(23, 16);
3782 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3784 KConfigGroup group(config, "WM");
3785 QPainter p(&pixmap);
3786 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3787 p.fillRect(1, 1, 7, 7, windowScheme.background());
3788 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3790 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3791 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3792 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3794 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3795 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3797 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3798 p.fillRect(1, 8, 7, 7, viewScheme.background());
3799 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3801 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3802 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3803 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3805 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3806 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3812 void MainWindow::slotSwitchMonitors()
3814 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3815 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3816 else m_projectList->focusTree();
3819 void MainWindow::slotInsertZoneToTree()
3821 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3822 QStringList info = m_clipMonitor->getZoneInfo();
3823 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3826 void MainWindow::slotInsertZoneToTimeline()
3828 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3829 QStringList info = m_clipMonitor->getZoneInfo();
3830 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3834 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3836 if (m_activeDocument && m_activeTimeline) {
3837 if (!ids.isEmpty()) {
3838 for (int i = 0; i < ids.size(); ++i) {
3839 m_activeTimeline->slotDeleteClip(ids.at(i));
3841 m_activeDocument->clipManager()->slotDeleteClips(ids);
3843 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3844 m_activeDocument->setModified(true);
3848 void MainWindow::slotShowTitleBars(bool show)
3850 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
3851 for (int i = 0; i < docks.count(); i++) {
3852 QDockWidget* dock=docks.at(i);
3854 dock->setTitleBarWidget(0);
3856 if (!dock->isFloating()){
3857 dock->setTitleBarWidget(new QWidget);
3861 KdenliveSettings::setShowtitlebars(show);
3864 void MainWindow::slotSwitchTitles()
3866 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3869 QString MainWindow::getMimeType()
3871 QString mimetype = "application/x-kdenlive";
3872 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3873 if (!mime) mimetype = "*.kdenlive";
3877 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3880 m_projectMonitor->render->sendFrameForAnalysis = true;
3883 for (int i = 0; i < m_scopesList.count(); i++) {
3884 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3891 m_projectMonitor->render->sendFrameForAnalysis = false;
3895 void MainWindow::slotUpdateScopeFrameRequest()
3897 // We need a delay to make sure widgets are hidden after a close event for example
3898 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3901 void MainWindow::slotDoUpdateScopeFrameRequest()
3904 bool request = false;
3905 for (int i = 0; i < m_scopesList.count(); i++) {
3906 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3907 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
3913 if (!m_projectMonitor->effectSceneDisplayed())
3914 m_projectMonitor->render->sendFrameForAnalysis = false;
3915 m_clipMonitor->render->sendFrameForAnalysis = false;
3917 m_projectMonitor->render->sendFrameForAnalysis = true;
3918 m_clipMonitor->render->sendFrameForAnalysis = true;
3922 void MainWindow::slotUpdateColorScopes()
3924 bool request = false;
3925 for (int i = 0; i < m_scopesList.count(); i++) {
3926 // Check if we need the renderer to send a new frame for update
3927 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
3928 static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
3931 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
3932 else m_projectMonitor->render->sendFrameUpdate();
3936 #include "mainwindow.moc"