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(m_projectMonitor);
273 m_audiosignalDock = new QDockWidget(i18n("AudioSignal"), 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* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1359 collection->addAction("split_audio", splitAudio);
1360 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1362 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1363 collection->addAction("clip_audio_only", audioOnly);
1364 audioOnly->setData("clip_audio_only");
1365 audioOnly->setCheckable(true);
1367 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1368 collection->addAction("clip_video_only", videoOnly);
1369 videoOnly->setData("clip_video_only");
1370 videoOnly->setCheckable(true);
1372 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1373 collection->addAction("clip_audio_and_video", audioAndVideo);
1374 audioAndVideo->setData("clip_audio_and_video");
1375 audioAndVideo->setCheckable(true);
1377 m_clipTypeGroup = new QActionGroup(this);
1378 m_clipTypeGroup->addAction(audioOnly);
1379 m_clipTypeGroup->addAction(videoOnly);
1380 m_clipTypeGroup->addAction(audioAndVideo);
1381 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1382 m_clipTypeGroup->setEnabled(false);
1384 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1385 collection->addAction("insert_space", insertSpace);
1386 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1388 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1389 collection->addAction("delete_space", removeSpace);
1390 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1392 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1393 collection->addAction("insert_track", insertTrack);
1394 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1396 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1397 collection->addAction("delete_track", deleteTrack);
1398 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1400 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1401 collection->addAction("config_tracks", configTracks);
1402 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1404 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1405 collection->addAction("add_guide", addGuide);
1406 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1408 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1409 collection->addAction("delete_guide", delGuide);
1410 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1412 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1413 collection->addAction("edit_guide", editGuide);
1414 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1416 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1417 collection->addAction("delete_all_guides", delAllGuides);
1418 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1420 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1421 collection->addAction("paste_effects", pasteEffects);
1422 pasteEffects->setData("paste_effects");
1423 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1425 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1426 collection->addAction("show_timeline", showTimeline);
1427 showTimeline->setCheckable(true);
1428 showTimeline->setChecked(true);
1429 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1431 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1432 collection->addAction("show_titlebars", showTitleBar);
1433 showTitleBar->setCheckable(true);
1434 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1435 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1436 slotShowTitleBars(KdenliveSettings::showtitlebars());
1439 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1441 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1442 collection->addAction("maximize_current", maxCurrent);
1443 maxCurrent->setCheckable(true);
1444 maxCurrent->setChecked(false);
1445 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1447 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1448 KStandardAction::quit(this, SLOT(queryQuit()), collection);
1449 KStandardAction::open(this, SLOT(openFile()), collection);
1450 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1451 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1452 KStandardAction::openNew(this, SLOT(newFile()), collection);
1453 // TODO: make the following connection to slotEditKeys work
1454 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1455 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1456 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1457 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1458 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1459 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1461 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1462 undo->setEnabled(false);
1463 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1465 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1466 redo->setEnabled(false);
1467 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1470 //TODO: Add status tooltip to actions ?
1471 connect(collection, SIGNAL(actionHovered(QAction*)),
1472 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1475 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1476 collection->addAction("add_clip", addClip);
1477 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1479 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1480 collection->addAction("add_color_clip", addColorClip);
1481 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1483 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1484 collection->addAction("add_slide_clip", addSlideClip);
1485 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1487 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1488 collection->addAction("add_text_clip", addTitleClip);
1489 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1491 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1492 collection->addAction("add_text_template_clip", addTitleTemplateClip);
1493 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1495 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1496 collection->addAction("add_folder", addFolderButton);
1497 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1499 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1500 collection->addAction("clip_properties", clipProperties);
1501 clipProperties->setData("clip_properties");
1502 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1503 clipProperties->setEnabled(false);
1505 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1506 collection->addAction("edit_clip", openClip);
1507 openClip->setData("edit_clip");
1508 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1509 openClip->setEnabled(false);
1511 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1512 collection->addAction("delete_clip", deleteClip);
1513 deleteClip->setData("delete_clip");
1514 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1515 deleteClip->setEnabled(false);
1517 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1518 collection->addAction("reload_clip", reloadClip);
1519 reloadClip->setData("reload_clip");
1520 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1521 reloadClip->setEnabled(false);
1523 QMenu *addClips = new QMenu();
1524 addClips->addAction(addClip);
1525 addClips->addAction(addColorClip);
1526 addClips->addAction(addSlideClip);
1527 addClips->addAction(addTitleClip);
1528 addClips->addAction(addTitleTemplateClip);
1529 addClips->addAction(addFolderButton);
1531 addClips->addAction(reloadClip);
1532 addClips->addAction(clipProperties);
1533 addClips->addAction(openClip);
1534 addClips->addAction(deleteClip);
1535 m_projectList->setupMenu(addClips, addClip);
1537 // Setup effects and transitions actions.
1538 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1539 //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection);
1540 KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection);
1541 m_videoEffects = new KAction*[videoEffects.count()];
1542 for (int i = 0; i < videoEffects.count(); ++i) {
1543 QStringList effectInfo = videoEffects.effectIdInfo(i);
1544 m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this);
1545 m_videoEffects[i]->setData(effectInfo);
1546 m_videoEffects[i]->setIconVisibleInMenu(false);
1547 videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]);
1549 //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection);
1550 KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection);
1551 m_audioEffects = new KAction*[audioEffects.count()];
1552 for (int i = 0; i < audioEffects.count(); ++i) {
1553 QStringList effectInfo = audioEffects.effectIdInfo(i);
1554 m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this);
1555 m_audioEffects[i]->setData(effectInfo);
1556 m_audioEffects[i]->setIconVisibleInMenu(false);
1557 audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]);
1559 //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection);
1560 KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection);
1561 m_customEffects = new KAction*[customEffects.count()];
1562 for (int i = 0; i < customEffects.count(); ++i) {
1563 QStringList effectInfo = customEffects.effectIdInfo(i);
1564 m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this);
1565 m_customEffects[i]->setData(effectInfo);
1566 m_customEffects[i]->setIconVisibleInMenu(false);
1567 customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]);
1569 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1570 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1571 m_transitions = new KAction*[transitions.count()];
1572 for (int i = 0; i < transitions.count(); i++) {
1573 QStringList effectInfo = transitions.effectIdInfo(i);
1574 m_transitions[i] = new KAction(effectInfo.at(0), this);
1575 m_transitions[i]->setData(effectInfo);
1576 m_transitions[i]->setIconVisibleInMenu(false);
1577 transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]);
1579 m_effectsActionCollection->readSettings();
1581 //connect(collection, SIGNAL( clearStatusText() ),
1582 //statusBar(), SLOT( clear() ) );
1585 void MainWindow::slotDisplayActionMessage(QAction *a)
1587 statusBar()->showMessage(a->data().toString(), 3000);
1590 void MainWindow::loadLayouts()
1592 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1593 QMenu *loadLayout = (QMenu*)(factory()->container("layout_load", this));
1594 if (loadLayout == NULL || saveLayout == NULL) return;
1595 KSharedConfigPtr config = KGlobal::config();
1596 KConfigGroup layoutGroup(config, "Layouts");
1597 QStringList entries = layoutGroup.keyList();
1598 QList<QAction *> loadActions = loadLayout->actions();
1599 QList<QAction *> saveActions = saveLayout->actions();
1600 for (int i = 1; i < 5; i++) {
1601 // Rename the layouts actions
1602 foreach(const QString & key, entries) {
1603 if (key.endsWith(QString("_%1").arg(i))) {
1604 // Found previously saved layout
1605 QString layoutName = key.section("_", 0, -2);
1606 for (int j = 0; j < loadActions.count(); j++) {
1607 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1608 loadActions[j]->setText(layoutName);
1609 loadActions[j]->setData(key);
1613 for (int j = 0; j < saveActions.count(); j++) {
1614 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1615 saveActions[j]->setText(layoutName);
1616 saveActions[j]->setData(key);
1625 void MainWindow::slotLoadLayout(QAction *action)
1627 if (!action) return;
1628 QString layoutId = action->data().toString();
1629 if (layoutId.isEmpty()) return;
1630 KSharedConfigPtr config = KGlobal::config();
1631 KConfigGroup layouts(config, "Layouts");
1632 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1633 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1634 //restoreGeometry(geom);
1635 restoreState(state);
1638 void MainWindow::slotSaveLayout(QAction *action)
1640 QString originallayoutName = action->data().toString();
1641 int layoutId = originallayoutName.section('_', -1).toInt();
1643 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1644 if (layoutName.isEmpty()) return;
1645 KSharedConfigPtr config = KGlobal::config();
1646 KConfigGroup layouts(config, "Layouts");
1647 layouts.deleteEntry(originallayoutName);
1649 QByteArray st = saveState();
1650 layoutName.append("_" + QString::number(layoutId));
1651 layouts.writeEntry(layoutName, st.toBase64());
1655 void MainWindow::saveOptions()
1657 KdenliveSettings::self()->writeConfig();
1658 KSharedConfigPtr config = KGlobal::config();
1659 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1660 KConfigGroup treecolumns(config, "Project Tree");
1661 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1665 void MainWindow::readOptions()
1667 KSharedConfigPtr config = KGlobal::config();
1668 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1669 KConfigGroup initialGroup(config, "version");
1670 bool upgrade = false;
1671 if (initialGroup.exists()) {
1672 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1676 if (initialGroup.readEntry("version") == "0.7") {
1677 //Add new settings from 0.7.1
1678 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1679 QString path = QDir::homePath() + "/kdenlive";
1680 if (KStandardDirs::makeDir(path) == false) {
1681 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1682 } else KdenliveSettings::setDefaultprojectfolder(path);
1688 if (!initialGroup.exists() || upgrade) {
1689 // this is our first run, show Wizard
1690 Wizard *w = new Wizard(upgrade, this);
1691 if (w->exec() == QDialog::Accepted && w->isOk()) {
1692 w->adjustSettings();
1693 initialGroup.writeEntry("version", version);
1699 KConfigGroup treecolumns(config, "Project Tree");
1700 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1701 if (!state.isEmpty())
1702 m_projectList->setHeaderInfo(state);
1705 void MainWindow::slotRunWizard()
1707 Wizard *w = new Wizard(false, this);
1708 if (w->exec() == QDialog::Accepted && w->isOk()) {
1709 w->adjustSettings();
1714 void MainWindow::newFile(bool showProjectSettings, bool force)
1716 if (!m_timelineArea->isEnabled() && !force)
1718 m_fileRevert->setEnabled(false);
1719 QString profileName = KdenliveSettings::default_profile();
1720 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1721 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1722 if (!showProjectSettings) {
1723 if (!KdenliveSettings::activatetabs())
1724 if (!closeCurrentDocument())
1727 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1728 if (w->exec() != QDialog::Accepted)
1730 if (!KdenliveSettings::activatetabs())
1731 if (!closeCurrentDocument())
1733 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1734 slotSwitchVideoThumbs();
1735 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1736 slotSwitchAudioThumbs();
1737 profileName = w->selectedProfile();
1738 projectFolder = w->selectedFolder();
1739 projectTracks = w->tracks();
1742 m_timelineArea->setEnabled(true);
1743 m_projectList->setEnabled(true);
1744 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1745 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1747 TrackView *trackView = new TrackView(doc, &ok, this);
1748 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1751 //m_timelineArea->setEnabled(false);
1752 //m_projectList->setEnabled(false);
1756 if (m_timelineArea->count() == 1) {
1757 connectDocumentInfo(doc);
1758 connectDocument(trackView, doc);
1760 m_timelineArea->setTabBarHidden(false);
1761 m_monitorManager->activateMonitor("clip");
1762 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1765 void MainWindow::activateDocument()
1767 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1768 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1769 KdenliveDoc *currentDoc = currentTab->document();
1770 connectDocumentInfo(currentDoc);
1771 connectDocument(currentTab, currentDoc);
1774 bool MainWindow::closeCurrentDocument(bool saveChanges)
1776 QWidget *w = m_timelineArea->currentWidget();
1777 if (!w) return true;
1778 // closing current document
1779 int ix = m_timelineArea->currentIndex() + 1;
1780 if (ix == m_timelineArea->count()) ix = 0;
1781 m_timelineArea->setCurrentIndex(ix);
1782 TrackView *tabToClose = (TrackView *) w;
1783 KdenliveDoc *docToClose = tabToClose->document();
1784 if (docToClose && docToClose->isModified() && saveChanges) {
1786 if (m_activeDocument->url().fileName().isEmpty())
1787 message = i18n("Save changes to document?");
1789 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1790 switch (KMessageBox::warningYesNoCancel(this, message)) {
1791 case KMessageBox::Yes :
1792 // save document here. If saving fails, return false;
1793 if (saveFile() == false) return false;
1795 case KMessageBox::Cancel :
1802 m_clipMonitor->slotSetXml(NULL);
1803 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1804 if (m_timelineArea->count() == 1) {
1805 m_timelineArea->setTabBarHidden(true);
1806 m_closeAction->setEnabled(false);
1808 if (docToClose == m_activeDocument) {
1809 delete m_activeDocument;
1810 m_activeDocument = NULL;
1811 m_effectStack->clear();
1812 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1816 if (w == m_activeTimeline) {
1817 delete m_activeTimeline;
1818 m_activeTimeline = NULL;
1825 bool MainWindow::saveFileAs(const QString &outputFileName)
1827 QString currentSceneList;
1828 m_monitorManager->stopActiveMonitor();
1829 if (KdenliveSettings::dropbframes()) {
1830 KdenliveSettings::setDropbframes(false);
1831 m_activeDocument->clipManager()->updatePreviewSettings();
1832 currentSceneList = m_projectMonitor->sceneList();
1833 KdenliveSettings::setDropbframes(true);
1834 m_activeDocument->clipManager()->updatePreviewSettings();
1835 } else currentSceneList = m_projectMonitor->sceneList();
1837 if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
1840 // Save timeline thumbnails
1841 m_activeTimeline->projectView()->saveThumbnails();
1842 m_activeDocument->setUrl(KUrl(outputFileName));
1843 if (m_activeDocument->m_autosave == NULL) {
1844 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1845 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1846 setCaption(m_activeDocument->description());
1847 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1848 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1849 m_activeDocument->setModified(false);
1850 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1851 m_fileRevert->setEnabled(true);
1855 bool MainWindow::saveFileAs()
1857 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1858 if (outputFile.isEmpty()) {
1861 if (QFile::exists(outputFile)) {
1862 // Show the file dialog again if the user does not want to overwrite the file
1863 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1864 return saveFileAs();
1866 return saveFileAs(outputFile);
1869 bool MainWindow::saveFile()
1871 if (!m_activeDocument) return true;
1872 if (m_activeDocument->url().isEmpty()) {
1873 return saveFileAs();
1875 bool result = saveFileAs(m_activeDocument->url().path());
1876 m_activeDocument->m_autosave->resize(0);
1881 void MainWindow::openFile()
1883 if (!m_startUrl.isEmpty()) {
1884 openFile(m_startUrl);
1885 m_startUrl = KUrl();
1888 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1889 if (url.isEmpty()) return;
1890 m_fileOpenRecent->addUrl(url);
1894 void MainWindow::openLastFile()
1896 KSharedConfigPtr config = KGlobal::config();
1897 KUrl::List urls = m_fileOpenRecent->urls();
1898 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1899 if (urls.isEmpty()) newFile(false);
1900 else openFile(urls.last());
1903 void MainWindow::openFile(const KUrl &url)
1905 // Check if the document is already opened
1906 const int ct = m_timelineArea->count();
1907 bool isOpened = false;
1909 for (i = 0; i < ct; i++) {
1910 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1911 KdenliveDoc *doc = tab->document();
1912 if (doc->url() == url) {
1918 m_timelineArea->setCurrentIndex(i);
1922 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1924 // Check for backup file
1925 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1926 if (!staleFiles.isEmpty()) {
1927 if (KMessageBox::questionYesNo(this,
1928 i18n("Auto-saved files exist. Do you want to recover them now?"),
1929 i18n("File Recovery"),
1930 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1931 recoverFiles(staleFiles);
1934 // remove the stale files
1935 foreach(KAutoSaveFile * stale, staleFiles) {
1936 stale->open(QIODevice::ReadWrite);
1941 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1942 m_messageLabel->repaint();
1943 doOpenFile(url, NULL);
1946 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1948 if (!m_timelineArea->isEnabled()) return;
1949 m_fileRevert->setEnabled(true);
1950 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this);
1951 if (stale == NULL) {
1952 stale = new KAutoSaveFile(url, doc);
1953 doc->m_autosave = stale;
1955 doc->m_autosave = stale;
1956 doc->setUrl(stale->managedFile());
1957 doc->setModified(true);
1958 stale->setParent(doc);
1960 connectDocumentInfo(doc);
1962 TrackView *trackView = new TrackView(doc, &ok, this);
1963 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
1965 m_timelineArea->setEnabled(false);
1966 m_projectList->setEnabled(false);
1967 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
1968 slotGotProgressInfo(QString(), -1);
1969 newFile(false, true);
1972 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
1973 trackView->setDuration(trackView->duration());
1974 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
1976 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
1977 slotGotProgressInfo(QString(), -1);
1978 m_projectMonitor->adjustRulerSize(trackView->duration());
1979 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
1980 m_clipMonitor->refreshMonitor(true);
1983 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
1985 foreach(KAutoSaveFile * stale, staleFiles) {
1986 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
1987 // show an error message; we could not steal the lockfile
1988 // maybe another application got to the file before us?
1992 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
1993 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
1994 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
1995 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
1999 void MainWindow::parseProfiles(const QString &mltPath)
2001 //KdenliveSettings::setDefaulttmpfolder();
2002 if (!mltPath.isEmpty()) {
2003 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2004 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2007 if (KdenliveSettings::mltpath().isEmpty())
2008 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2010 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2011 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2012 if (!QFile::exists(meltPath))
2013 meltPath = KStandardDirs::findExe("melt");
2014 KdenliveSettings::setRendererpath(meltPath);
2017 if (KdenliveSettings::rendererpath().isEmpty()) {
2018 // Cannot find the MLT melt renderer, ask for location
2019 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2020 if (getUrl->exec() == QDialog::Rejected) {
2023 KUrl rendererPath = getUrl->selectedUrl();
2025 if (rendererPath.isEmpty()) ::exit(0);
2026 KdenliveSettings::setRendererpath(rendererPath.path());
2029 QStringList profilesFilter;
2030 profilesFilter << "*";
2031 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2032 if (profilesList.isEmpty()) {
2033 // Cannot find MLT path, try finding melt
2034 QString profilePath = KdenliveSettings::rendererpath();
2035 if (!profilePath.isEmpty()) {
2036 profilePath = profilePath.section('/', 0, -3);
2037 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2038 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2040 if (profilesList.isEmpty()) {
2041 // Cannot find the MLT profiles, ask for location
2042 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2043 getUrl->fileDialog()->setMode(KFile::Directory);
2044 if (getUrl->exec() == QDialog::Rejected) {
2047 KUrl mltPath = getUrl->selectedUrl();
2049 if (mltPath.isEmpty()) ::exit(0);
2050 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2051 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2055 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2057 // Parse again MLT profiles to build a list of available video formats
2058 if (profilesList.isEmpty()) parseProfiles();
2062 void MainWindow::slotEditProfiles()
2064 ProfilesDialog *w = new ProfilesDialog;
2065 if (w->exec() == QDialog::Accepted) {
2066 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2067 if (d) d->checkProfile();
2072 void MainWindow::slotDetectAudioDriver()
2074 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2075 leading to no audio output, see bug #934 */
2077 //decide which audio driver is really best, in some cases SDL is wrong
2078 if (KdenliveSettings::audiodrivername().isEmpty()) {
2080 KProcess readProcess;
2081 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2082 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2083 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2084 readProcess.setProgram("pactl", QStringList() << "stat");
2085 readProcess.execute(2000); // Kill it after 2 seconds
2087 QString result = QString(readProcess.readAllStandardOutput());
2088 kDebug() << "// / / / / / READING PACTL: ";
2090 if (!result.isEmpty()) {
2092 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2096 KdenliveSettings::setAutoaudiodrivername(driver);
2100 void MainWindow::slotEditProjectSettings()
2102 QPoint p = m_activeDocument->getTracksCount();
2103 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2105 if (w->exec() == QDialog::Accepted) {
2106 QString profile = w->selectedProfile();
2107 m_activeDocument->setProjectFolder(w->selectedFolder());
2109 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2111 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2112 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2113 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2114 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2119 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2121 double dar = m_activeDocument->dar();
2123 // Deselect current effect / transition
2124 m_effectStack->slotClipItemSelected(NULL, 0);
2125 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2126 m_clipMonitor->slotSetXml(NULL);
2127 bool updateFps = m_activeDocument->setProfilePath(profile);
2128 KdenliveSettings::setCurrent_profile(profile);
2129 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2130 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2132 m_activeDocument->clipManager()->clearUnusedProducers();
2133 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2134 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2135 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2136 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2137 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2138 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2139 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2140 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2141 if (updateFps) m_activeTimeline->updateProjectFps();
2142 m_activeDocument->setModified(true);
2143 m_commandStack->activeStack()->clear();
2144 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2145 slotUpdateMousePosition(0);
2146 // We need to desactivate & reactivate monitors to get a refresh
2147 //m_monitorManager->switchMonitors();
2151 void MainWindow::slotRenderProject()
2153 if (!m_renderWidget) {
2154 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2155 m_renderWidget = new RenderWidget(projectfolder, this);
2156 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2157 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2158 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2159 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2160 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2161 if (m_activeDocument) {
2162 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2163 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2164 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2165 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2168 slotCheckRenderStatus();
2169 m_renderWidget->show();
2170 m_renderWidget->showNormal();
2172 // What are the following lines supposed to do?
2173 //m_activeTimeline->tracksNumber();
2174 //m_renderWidget->enableAudio(false);
2175 //m_renderWidget->export_audio;
2178 void MainWindow::slotCheckRenderStatus()
2180 // Make sure there are no missing clips
2182 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2185 void MainWindow::setRenderingProgress(const QString &url, int progress)
2188 m_renderWidget->setRenderJob(url, progress);
2191 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2194 m_renderWidget->setRenderStatus(url, status, error);
2197 void MainWindow::slotCleanProject()
2199 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2200 m_projectList->cleanup();
2203 void MainWindow::slotUpdateMousePosition(int pos)
2205 if (m_activeDocument)
2206 switch (m_timecodeFormat->currentIndex()) {
2208 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2211 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2215 void MainWindow::slotUpdateDocumentState(bool modified)
2217 if (!m_activeDocument) return;
2218 setCaption(m_activeDocument->description(), modified);
2219 m_saveAction->setEnabled(modified);
2221 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2222 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2224 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2225 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2229 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2231 if (m_activeDocument) {
2232 if (m_activeDocument == doc) return;
2233 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2235 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2238 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2240 //m_projectMonitor->stop();
2241 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2242 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2243 if (m_activeDocument) {
2244 if (m_activeDocument == doc) return;
2245 if (m_activeTimeline) {
2246 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2247 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2248 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2249 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2250 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2251 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2252 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2253 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2255 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2257 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2258 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2259 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2260 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2261 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2262 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2263 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2264 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2265 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2266 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2267 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2268 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2269 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2270 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2271 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2272 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2273 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2274 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2275 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2276 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2277 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2278 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2279 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2280 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2281 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2282 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2283 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2284 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2285 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2286 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2287 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2288 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2289 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2290 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2291 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2292 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2293 m_effectStack->clear();
2295 //m_activeDocument->setRenderer(NULL);
2296 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2297 disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2298 m_clipMonitor->stop();
2300 KdenliveSettings::setCurrent_profile(doc->profilePath());
2301 KdenliveSettings::setProject_fps(doc->fps());
2302 m_monitorManager->resetProfiles(doc->timecode());
2303 m_projectList->setDocument(doc);
2304 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2305 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2306 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2307 connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
2308 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2310 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2311 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2312 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2314 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2317 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2318 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2319 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2320 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2321 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2322 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2323 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2324 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2325 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2326 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2327 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2328 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2329 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2330 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2332 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2333 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2334 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
2335 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2336 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2338 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2339 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2340 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2341 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2343 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2344 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2345 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2346 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2348 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
2349 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2350 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2351 m_zoomSlider->setValue(doc->zoom().x());
2352 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2353 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2354 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2355 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2357 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2358 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2360 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2361 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2363 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2364 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2365 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2366 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2367 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2368 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2369 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2370 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2371 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2372 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2373 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2375 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2376 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2377 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2378 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2379 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2382 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2383 m_activeTimeline = trackView;
2384 if (m_renderWidget) {
2385 slotCheckRenderStatus();
2386 m_renderWidget->setProfile(doc->mltProfile());
2387 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2388 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2389 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2391 //doc->setRenderer(m_projectMonitor->render);
2392 m_commandStack->setActiveStack(doc->commandStack());
2393 KdenliveSettings::setProject_display_ratio(doc->dar());
2394 //doc->clipManager()->checkAudioThumbs();
2396 //m_overView->setScene(trackView->projectScene());
2397 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2398 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2400 setCaption(doc->description(), doc->isModified());
2401 m_saveAction->setEnabled(doc->isModified());
2402 m_normalEditTool->setChecked(true);
2403 m_activeDocument = doc;
2404 m_activeTimeline->updateProjectFps();
2405 m_activeDocument->checkProjectClips();
2407 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2409 if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
2410 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2411 slotUpdateMousePosition(0);
2412 // set tool to select tool
2413 m_buttonSelectTool->setChecked(true);
2416 void MainWindow::slotZoneMoved(int start, int end)
2418 m_activeDocument->setZone(start, end);
2419 m_projectMonitor->slotZoneMoved(start, end);
2422 void MainWindow::slotGuidesUpdated()
2425 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2428 void MainWindow::slotEditKeys()
2430 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2431 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2432 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2436 void MainWindow::slotPreferences(int page, int option)
2439 * An instance of your dialog could be already created and could be
2440 * cached, in which case you want to display the cached dialog
2441 * instead of creating another one
2443 if (KConfigDialog::showDialog("settings")) {
2444 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2445 if (page != -1) d->showPage(page, option);
2449 // KConfigDialog didn't find an instance of this dialog, so lets
2451 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
2452 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2453 //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
2454 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2455 connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2457 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2459 //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
2461 if (page != -1) dialog->showPage(page, option);
2464 void MainWindow::slotUpdateCaptureFolder()
2468 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2469 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2473 void MainWindow::slotUpdatePreviewSettings()
2475 if (m_activeDocument) {
2476 m_clipMonitor->slotSetXml(NULL);
2477 m_activeDocument->updatePreviewSettings();
2481 void MainWindow::updateConfiguration()
2483 //TODO: we should apply settings to all projects, not only the current one
2484 if (m_activeTimeline) {
2485 m_activeTimeline->refresh();
2486 m_activeTimeline->projectView()->checkAutoScroll();
2487 m_activeTimeline->projectView()->checkTrackHeight();
2488 if (m_activeDocument)
2489 m_activeDocument->clipManager()->checkAudioThumbs();
2491 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2492 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2493 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2494 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2496 // Update list of transcoding profiles
2498 #ifndef NO_JOGSHUTTLE
2499 activateShuttleDevice();
2500 #endif /* NO_JOGSHUTTLE */
2504 void MainWindow::slotSwitchSplitAudio()
2506 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2507 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2510 void MainWindow::slotSwitchVideoThumbs()
2512 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2513 if (m_activeTimeline)
2514 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2515 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2518 void MainWindow::slotSwitchAudioThumbs()
2520 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2521 if (m_activeTimeline) {
2522 m_activeTimeline->refresh();
2523 m_activeTimeline->projectView()->checkAutoScroll();
2524 if (m_activeDocument)
2525 m_activeDocument->clipManager()->checkAudioThumbs();
2527 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2530 void MainWindow::slotSwitchMarkersComments()
2532 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2533 if (m_activeTimeline)
2534 m_activeTimeline->refresh();
2535 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2538 void MainWindow::slotSwitchSnap()
2540 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2541 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2545 void MainWindow::slotDeleteItem()
2547 if (QApplication::focusWidget() &&
2548 QApplication::focusWidget()->parentWidget() &&
2549 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2550 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2551 m_projectList->slotRemoveClip();
2554 QWidget *widget = QApplication::focusWidget();
2556 if (widget == m_effectStackDock) {
2557 m_effectStack->slotItemDel();
2560 widget = widget->parentWidget();
2563 // effect stack has no focus
2564 if (m_activeTimeline)
2565 m_activeTimeline->projectView()->deleteSelectedClips();
2569 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2571 if (m_clipMonitor->isActive())
2572 m_clipMonitor->checkOverlay();
2573 m_clipMonitor->updateMarkers(clip);
2576 void MainWindow::slotAddClipMarker()
2578 DocClipBase *clip = NULL;
2580 if (m_projectMonitor->isActive()) {
2581 if (m_activeTimeline) {
2582 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2584 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2585 clip = item->baseClip();
2589 clip = m_clipMonitor->activeClip();
2590 pos = m_clipMonitor->position();
2593 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2596 QString id = clip->getId();
2597 CommentedTime marker(pos, i18n("Marker"));
2598 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2599 if (d.exec() == QDialog::Accepted)
2600 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2603 void MainWindow::slotDeleteClipMarker()
2605 DocClipBase *clip = NULL;
2607 if (m_projectMonitor->isActive()) {
2608 if (m_activeTimeline) {
2609 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2611 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2612 clip = item->baseClip();
2616 clip = m_clipMonitor->activeClip();
2617 pos = m_clipMonitor->position();
2620 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2624 QString id = clip->getId();
2625 QString comment = clip->markerComment(pos);
2626 if (comment.isEmpty()) {
2627 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2630 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2633 void MainWindow::slotDeleteAllClipMarkers()
2635 DocClipBase *clip = NULL;
2636 if (m_projectMonitor->isActive()) {
2637 if (m_activeTimeline) {
2638 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2640 clip = item->baseClip();
2644 clip = m_clipMonitor->activeClip();
2647 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2650 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2653 void MainWindow::slotEditClipMarker()
2655 DocClipBase *clip = NULL;
2657 if (m_projectMonitor->isActive()) {
2658 if (m_activeTimeline) {
2659 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2661 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2662 clip = item->baseClip();
2666 clip = m_clipMonitor->activeClip();
2667 pos = m_clipMonitor->position();
2670 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2674 QString id = clip->getId();
2675 QString oldcomment = clip->markerComment(pos);
2676 if (oldcomment.isEmpty()) {
2677 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2681 CommentedTime marker(pos, oldcomment);
2682 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2683 if (d.exec() == QDialog::Accepted) {
2684 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2685 if (d.newMarker().time() != pos) {
2686 // remove old marker
2687 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2692 void MainWindow::slotAddGuide()
2694 if (m_activeTimeline)
2695 m_activeTimeline->projectView()->slotAddGuide();
2698 void MainWindow::slotInsertSpace()
2700 if (m_activeTimeline)
2701 m_activeTimeline->projectView()->slotInsertSpace();
2704 void MainWindow::slotRemoveSpace()
2706 if (m_activeTimeline)
2707 m_activeTimeline->projectView()->slotRemoveSpace();
2710 void MainWindow::slotInsertTrack(int ix)
2712 m_projectMonitor->activateMonitor();
2713 if (m_activeTimeline)
2714 m_activeTimeline->projectView()->slotInsertTrack(ix);
2715 if (m_activeDocument)
2716 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2719 void MainWindow::slotDeleteTrack(int ix)
2721 m_projectMonitor->activateMonitor();
2722 if (m_activeTimeline)
2723 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2724 if (m_activeDocument)
2725 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2728 void MainWindow::slotConfigTrack(int ix)
2730 m_projectMonitor->activateMonitor();
2731 if (m_activeTimeline)
2732 m_activeTimeline->projectView()->slotConfigTracks(ix);
2733 if (m_activeDocument)
2734 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2737 void MainWindow::slotEditGuide()
2739 if (m_activeTimeline)
2740 m_activeTimeline->projectView()->slotEditGuide();
2743 void MainWindow::slotDeleteGuide()
2745 if (m_activeTimeline)
2746 m_activeTimeline->projectView()->slotDeleteGuide();
2749 void MainWindow::slotDeleteAllGuides()
2751 if (m_activeTimeline)
2752 m_activeTimeline->projectView()->slotDeleteAllGuides();
2755 void MainWindow::slotCutTimelineClip()
2757 if (m_activeTimeline)
2758 m_activeTimeline->projectView()->cutSelectedClips();
2761 void MainWindow::slotInsertClipOverwrite()
2763 if (m_activeTimeline) {
2764 QStringList data = m_clipMonitor->getZoneInfo();
2765 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2769 void MainWindow::slotSelectTimelineClip()
2771 if (m_activeTimeline)
2772 m_activeTimeline->projectView()->selectClip(true);
2775 void MainWindow::slotSelectTimelineTransition()
2777 if (m_activeTimeline)
2778 m_activeTimeline->projectView()->selectTransition(true);
2781 void MainWindow::slotDeselectTimelineClip()
2783 if (m_activeTimeline)
2784 m_activeTimeline->projectView()->selectClip(false, true);
2787 void MainWindow::slotDeselectTimelineTransition()
2789 if (m_activeTimeline)
2790 m_activeTimeline->projectView()->selectTransition(false, true);
2793 void MainWindow::slotSelectAddTimelineClip()
2795 if (m_activeTimeline)
2796 m_activeTimeline->projectView()->selectClip(true, true);
2799 void MainWindow::slotSelectAddTimelineTransition()
2801 if (m_activeTimeline)
2802 m_activeTimeline->projectView()->selectTransition(true, true);
2805 void MainWindow::slotGroupClips()
2807 if (m_activeTimeline)
2808 m_activeTimeline->projectView()->groupClips();
2811 void MainWindow::slotUnGroupClips()
2813 if (m_activeTimeline)
2814 m_activeTimeline->projectView()->groupClips(false);
2817 void MainWindow::slotEditItemDuration()
2819 if (m_activeTimeline)
2820 m_activeTimeline->projectView()->editItemDuration();
2823 void MainWindow::slotAddProjectClip(KUrl url)
2825 if (m_activeDocument)
2826 m_activeDocument->slotAddClipFile(url, QString());
2829 void MainWindow::slotAddTransition(QAction *result)
2831 if (!result) return;
2832 QStringList info = result->data().toStringList();
2833 if (info.isEmpty()) return;
2834 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2835 if (m_activeTimeline && !transition.isNull()) {
2836 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2840 void MainWindow::slotAddVideoEffect(QAction *result)
2842 if (!result) return;
2843 QStringList info = result->data().toStringList();
2844 if (info.isEmpty()) return;
2845 QDomElement effect = videoEffects.getEffectByTag(info.at(1), info.at(2));
2846 slotAddEffect(effect);
2849 void MainWindow::slotAddAudioEffect(QAction *result)
2851 if (!result) return;
2852 QStringList info = result->data().toStringList();
2853 if (info.isEmpty()) return;
2854 QDomElement effect = audioEffects.getEffectByTag(info.at(1), info.at(2));
2855 slotAddEffect(effect);
2858 void MainWindow::slotAddCustomEffect(QAction *result)
2860 if (!result) return;
2861 QStringList info = result->data().toStringList();
2862 if (info.isEmpty()) return;
2863 QDomElement effect = customEffects.getEffectByTag(info.at(1), info.at(2));
2864 slotAddEffect(effect);
2867 void MainWindow::slotZoomIn()
2869 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2870 slotShowZoomSliderToolTip();
2873 void MainWindow::slotZoomOut()
2875 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
2876 slotShowZoomSliderToolTip();
2879 void MainWindow::slotFitZoom()
2881 if (m_activeTimeline)
2882 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
2885 void MainWindow::slotSetZoom(int value)
2887 value = qMax(m_zoomSlider->minimum(), value);
2888 value = qMin(m_zoomSlider->maximum(), value);
2890 if (m_activeTimeline)
2891 m_activeTimeline->slotChangeZoom(value);
2893 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
2894 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
2895 slotUpdateZoomSliderToolTip(value);
2897 m_zoomSlider->blockSignals(true);
2898 m_zoomSlider->setValue(value);
2899 m_zoomSlider->blockSignals(false);
2902 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
2904 if (zoomlevel != -1)
2905 slotUpdateZoomSliderToolTip(zoomlevel);
2907 QPoint global = m_zoomSlider->rect().topLeft();
2908 global.ry() += m_zoomSlider->height() / 2;
2909 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
2910 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
2913 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
2915 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
2918 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
2920 m_statusProgressBar->setValue(progress);
2921 if (progress >= 0) {
2922 if (!message.isEmpty())
2923 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
2924 m_statusProgressBar->setVisible(true);
2925 } else if (progress == -2) {
2926 if (!message.isEmpty())
2927 m_messageLabel->setMessage(message, ErrorMessage);
2928 m_statusProgressBar->setVisible(false);
2930 m_messageLabel->setMessage(QString(), DefaultMessage);
2931 m_statusProgressBar->setVisible(false);
2935 void MainWindow::slotShowClipProperties(DocClipBase *clip)
2937 if (clip->clipType() == TEXT) {
2938 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
2939 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
2940 // template text clip
2942 // Get the list of existing templates
2944 filter << "*.kdenlivetitle";
2945 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
2947 QDialog *dia = new QDialog(this);
2948 Ui::TemplateClip_UI dia_ui;
2949 dia_ui.setupUi(dia);
2951 const QString templatePath = clip->getProperty("resource");
2952 for (int i = 0; i < templateFiles.size(); ++i) {
2953 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
2954 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
2956 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
2957 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
2958 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
2959 //warning: setting base directory doesn't work??
2960 KUrl startDir(titlepath);
2961 dia_ui.template_list->fileDialog()->setUrl(startDir);
2962 dia_ui.description->setText(clip->getProperty("description"));
2963 if (dia->exec() == QDialog::Accepted) {
2964 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
2965 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
2967 QMap <QString, QString> newprops;
2969 if (KUrl(textTemplate).path() != templatePath) {
2970 // The template was changed
2971 newprops.insert("resource", textTemplate);
2974 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
2975 newprops.insert("description", dia_ui.description->toPlainText());
2978 QString newtemplate = newprops.value("xmltemplate");
2979 if (newtemplate.isEmpty()) newtemplate = templatePath;
2981 // template modified we need to update xmldata
2982 QString description = newprops.value("description");
2983 if (description.isEmpty()) description = clip->getProperty("description");
2984 else newprops.insert("templatetext", description);
2985 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
2986 if (!newprops.isEmpty()) {
2987 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
2988 m_activeDocument->commandStack()->push(command);
2994 QString path = clip->getProperty("resource");
2995 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
2997 doc.setContent(clip->getProperty("xmldata"));
2998 dia_ui->setXml(doc);
2999 if (dia_ui->exec() == QDialog::Accepted) {
3000 QMap <QString, QString> newprops;
3001 newprops.insert("xmldata", dia_ui->xml().toString());
3002 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3003 // duration changed, we need to update duration
3004 newprops.insert("out", QString::number(dia_ui->outPoint()));
3006 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3007 m_activeDocument->commandStack()->push(command);
3008 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3009 m_activeDocument->setModified(true);
3013 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3017 // any type of clip but a title
3018 ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3019 connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3020 if (dia.exec() == QDialog::Accepted) {
3021 QMap <QString, QString> newprops = dia.properties();
3022 if (newprops.isEmpty()) return;
3023 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3024 m_activeDocument->commandStack()->push(command);
3025 m_activeDocument->setModified();
3027 if (dia.needsTimelineRefresh()) {
3028 // update clip occurences in timeline
3029 m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
3035 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3037 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3038 if (dia.exec() == QDialog::Accepted) {
3039 QUndoCommand *command = new QUndoCommand();
3040 command->setText(i18n("Edit clips"));
3041 for (int i = 0; i < cliplist.count(); i++) {
3042 DocClipBase *clip = cliplist.at(i);
3043 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), dia.properties(), true, command);
3045 m_activeDocument->commandStack()->push(command);
3046 for (int i = 0; i < cliplist.count(); i++)
3047 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3051 void MainWindow::customEvent(QEvent* e)
3053 if (e->type() == QEvent::User)
3054 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3056 void MainWindow::slotActivateEffectStackView()
3058 m_effectStack->raiseWindow(m_effectStackDock);
3061 void MainWindow::slotActivateTransitionView(Transition *t)
3064 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3067 void MainWindow::slotSnapRewind()
3069 if (m_projectMonitor->isActive()) {
3070 if (m_activeTimeline)
3071 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3073 m_clipMonitor->slotSeekToPreviousSnap();
3077 void MainWindow::slotSnapForward()
3079 if (m_projectMonitor->isActive()) {
3080 if (m_activeTimeline)
3081 m_activeTimeline->projectView()->slotSeekToNextSnap();
3083 m_clipMonitor->slotSeekToNextSnap();
3087 void MainWindow::slotClipStart()
3089 if (m_projectMonitor->isActive()) {
3090 if (m_activeTimeline)
3091 m_activeTimeline->projectView()->clipStart();
3095 void MainWindow::slotClipEnd()
3097 if (m_projectMonitor->isActive()) {
3098 if (m_activeTimeline)
3099 m_activeTimeline->projectView()->clipEnd();
3103 void MainWindow::slotZoneStart()
3105 if (m_projectMonitor->isActive())
3106 m_projectMonitor->slotZoneStart();
3108 m_clipMonitor->slotZoneStart();
3111 void MainWindow::slotZoneEnd()
3113 if (m_projectMonitor->isActive())
3114 m_projectMonitor->slotZoneEnd();
3116 m_clipMonitor->slotZoneEnd();
3119 void MainWindow::slotChangeTool(QAction * action)
3121 if (action == m_buttonSelectTool)
3122 slotSetTool(SELECTTOOL);
3123 else if (action == m_buttonRazorTool)
3124 slotSetTool(RAZORTOOL);
3125 else if (action == m_buttonSpacerTool)
3126 slotSetTool(SPACERTOOL);
3129 void MainWindow::slotChangeEdit(QAction * action)
3131 if (!m_activeTimeline)
3134 if (action == m_overwriteEditTool)
3135 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3136 else if (action == m_insertEditTool)
3137 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3139 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3142 void MainWindow::slotSetTool(PROJECTTOOL tool)
3144 if (m_activeDocument && m_activeTimeline) {
3145 //m_activeDocument->setTool(tool);
3149 message = i18n("Ctrl + click to use spacer on current track only");
3152 message = i18n("Click on a clip to cut it");
3155 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3158 m_messageLabel->setMessage(message, InformationMessage);
3159 m_activeTimeline->projectView()->setTool(tool);
3163 void MainWindow::slotCopy()
3165 if (m_activeDocument && m_activeTimeline)
3166 m_activeTimeline->projectView()->copyClip();
3169 void MainWindow::slotPaste()
3171 if (m_activeDocument && m_activeTimeline)
3172 m_activeTimeline->projectView()->pasteClip();
3175 void MainWindow::slotPasteEffects()
3177 if (m_activeDocument && m_activeTimeline)
3178 m_activeTimeline->projectView()->pasteClipEffects();
3181 void MainWindow::slotFind()
3183 if (!m_activeDocument || !m_activeTimeline) return;
3184 m_projectSearch->setEnabled(false);
3185 m_findActivated = true;
3186 m_findString.clear();
3187 m_activeTimeline->projectView()->initSearchStrings();
3188 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3189 m_findTimer.start(5000);
3190 qApp->installEventFilter(this);
3193 void MainWindow::slotFindNext()
3195 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3196 statusBar()->showMessage(i18n("Found: %1", m_findString));
3198 statusBar()->showMessage(i18n("Reached end of project"));
3199 m_findTimer.start(4000);
3202 void MainWindow::findAhead()
3204 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3205 m_projectSearchNext->setEnabled(true);
3206 statusBar()->showMessage(i18n("Found: %1", m_findString));
3208 m_projectSearchNext->setEnabled(false);
3209 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3213 void MainWindow::findTimeout()
3215 m_projectSearchNext->setEnabled(false);
3216 m_findActivated = false;
3217 m_findString.clear();
3218 statusBar()->showMessage(i18n("Find stopped"), 3000);
3219 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3220 m_projectSearch->setEnabled(true);
3221 removeEventFilter(this);
3224 void MainWindow::slotClipInTimeline(const QString &clipId)
3226 if (m_activeTimeline && m_activeDocument) {
3227 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3229 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3230 inTimelineMenu->clear();
3232 QList <QAction *> actionList;
3234 for (int i = 0; i < matching.count(); ++i) {
3235 QString track = QString::number(matching.at(i).track);
3236 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3238 QAction *a = new QAction(track + ": " + start, this);
3239 a->setData(QStringList() << track << start);
3240 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3241 while (j < actionList.count()) {
3242 if (actionList.at(j)->text() > a->text()) break;
3245 actionList.insert(j, a);
3247 inTimelineMenu->addActions(actionList);
3249 if (matching.empty())
3250 inTimelineMenu->setEnabled(false);
3252 inTimelineMenu->setEnabled(true);
3256 void MainWindow::slotClipInProjectTree()
3258 if (m_activeTimeline) {
3259 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3260 if (clipIds.isEmpty())
3262 m_projectListDock->raise();
3263 for (int i = 0; i < clipIds.count(); i++)
3264 m_projectList->selectItemById(clipIds.at(i));
3265 if (m_projectMonitor->isActive())
3266 slotSwitchMonitors();
3270 /*void MainWindow::slotClipToProjectTree()
3272 if (m_activeTimeline) {
3273 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3274 if (clips.isEmpty()) return;
3275 for (int i = 0; i < clips.count(); i++) {
3276 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3278 //m_projectList->selectItemById(clipIds.at(i));
3282 void MainWindow::slotSelectClipInTimeline()
3284 if (m_activeTimeline) {
3285 QAction *action = qobject_cast<QAction *>(sender());
3286 QStringList data = action->data().toStringList();
3287 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3291 void MainWindow::keyPressEvent(QKeyEvent *ke)
3293 if (m_findActivated) {
3294 if (ke->key() == Qt::Key_Backspace) {
3295 m_findString = m_findString.left(m_findString.length() - 1);
3297 if (!m_findString.isEmpty())
3302 m_findTimer.start(4000);
3305 } else if (ke->key() == Qt::Key_Escape) {
3309 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3310 m_findString += ke->text();
3314 m_findTimer.start(4000);
3319 KXmlGuiWindow::keyPressEvent(ke);
3324 /** Gets called when the window gets hidden */
3325 void MainWindow::hideEvent(QHideEvent */*event*/)
3327 if (isMinimized() && m_monitorManager)
3328 m_monitorManager->stopActiveMonitor();
3331 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3333 if (m_findActivated) {
3334 if (event->type() == QEvent::ShortcutOverride) {
3335 QKeyEvent* ke = (QKeyEvent*) event;
3336 if (ke->text().trimmed().isEmpty()) return false;
3343 // pass the event on to the parent class
3344 return QMainWindow::eventFilter(obj, event);
3349 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3351 KDialog *dialog = new KDialog(this);
3352 dialog->setCaption("Save clip zone");
3353 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3355 QWidget *widget = new QWidget(dialog);
3356 dialog->setMainWidget(widget);
3358 QVBoxLayout *vbox = new QVBoxLayout(widget);
3359 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3360 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3361 path.append("untitled.mlt");
3362 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3363 url->setFilter("video/mlt-playlist");
3364 QLabel *label2 = new QLabel(i18n("Description:"), this);
3365 KLineEdit *edit = new KLineEdit(this);
3366 vbox->addWidget(label1);
3367 vbox->addWidget(url);
3368 vbox->addWidget(label2);
3369 vbox->addWidget(edit);
3370 if (dialog->exec() == QDialog::Accepted)
3371 render->saveZone(url->url(), edit->text(), zone);
3375 void MainWindow::slotSetInPoint()
3377 if (m_clipMonitor->isActive())
3378 m_clipMonitor->slotSetZoneStart();
3380 m_projectMonitor->slotSetZoneStart();
3381 //else m_activeTimeline->projectView()->setInPoint();
3384 void MainWindow::slotSetOutPoint()
3386 if (m_clipMonitor->isActive())
3387 m_clipMonitor->slotSetZoneEnd();
3389 m_projectMonitor->slotSetZoneEnd();
3390 // else m_activeTimeline->projectView()->setOutPoint();
3393 void MainWindow::slotResizeItemStart()
3395 if (m_activeTimeline)
3396 m_activeTimeline->projectView()->setInPoint();
3399 void MainWindow::slotResizeItemEnd()
3401 if (m_activeTimeline)
3402 m_activeTimeline->projectView()->setOutPoint();
3405 int MainWindow::getNewStuff(const QString &configFile)
3407 KNS3::Entry::List entries;
3408 #if KDE_IS_VERSION(4,3,80)
3409 KNS3::DownloadDialog dialog(configFile);
3411 entries = dialog.changedEntries();
3412 foreach(const KNS3::Entry & entry, entries) {
3413 if (entry.status() == KNS3::Entry::Installed)
3414 kDebug() << "// Installed files: " << entry.installedFiles();
3417 KNS::Engine engine(0);
3418 if (engine.init(configFile))
3419 entries = engine.downloadDialogModal(this);
3420 foreach(KNS::Entry * entry, entries) {
3421 if (entry->status() == KNS::Entry::Installed)
3422 kDebug() << "// Installed files: " << entry->installedFiles();
3424 #endif /* KDE_IS_VERSION(4,3,80) */
3425 return entries.size();
3428 void MainWindow::slotGetNewTitleStuff()
3430 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3431 TitleWidget::refreshTitleTemplates();
3434 void MainWindow::slotGetNewLumaStuff()
3436 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3437 initEffects::refreshLumas();
3438 m_activeTimeline->projectView()->reloadTransitionLumas();
3442 void MainWindow::slotGetNewRenderStuff()
3444 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3446 m_renderWidget->reloadProfiles();
3449 void MainWindow::slotGetNewMltProfileStuff()
3451 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3452 // update the list of profiles in settings dialog
3453 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3459 void MainWindow::slotAutoTransition()
3461 if (m_activeTimeline)
3462 m_activeTimeline->projectView()->autoTransition();
3465 void MainWindow::slotSplitAudio()
3467 if (m_activeTimeline)
3468 m_activeTimeline->projectView()->splitAudio();
3471 void MainWindow::slotUpdateClipType(QAction *action)
3473 if (m_activeTimeline) {
3474 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3475 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3476 else m_activeTimeline->projectView()->setAudioAndVideo();
3480 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3482 // We must stop the monitors since we create a new on in the dvd wizard
3483 m_clipMonitor->stop();
3484 m_projectMonitor->stop();
3485 DvdWizard w(url, profile, this);
3487 m_projectMonitor->start();
3490 void MainWindow::slotShowTimeline(bool show)
3492 if (show == false) {
3493 m_timelineState = saveState();
3494 centralWidget()->setHidden(true);
3496 centralWidget()->setHidden(false);
3497 restoreState(m_timelineState);
3501 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3503 //TODO: is there a way to maximize current widget?
3506 m_timelineState = saveState();
3507 QWidget *par = focusWidget()->parentWidget();
3508 while (par->parentWidget() && par->parentWidget() != this)
3509 par = par->parentWidget();
3510 kDebug() << "CURRENT WIDGET: " << par->objectName();
3513 //centralWidget()->setHidden(false);
3514 //restoreState(m_timelineState);
3518 void MainWindow::loadTranscoders()
3520 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3523 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3524 KConfigGroup transConfig(config, "Transcoding");
3526 QMap< QString, QString > profiles = transConfig.entryMap();
3527 QMapIterator<QString, QString> i(profiles);
3528 while (i.hasNext()) {
3530 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3531 QAction *a = transMenu->addAction(i.key());
3533 if (data.count() > 1)
3534 a->setToolTip(data.at(1));
3535 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3539 void MainWindow::slotTranscode(KUrl::List urls)
3544 if (urls.isEmpty()) {
3545 QAction *action = qobject_cast<QAction *>(sender());
3546 QStringList data = action->data().toStringList();
3547 params = data.at(0);
3548 if (data.count() > 1) desc = data.at(1);
3549 if (data.count() > 2) condition = data.at(2);
3550 urls << m_projectList->getConditionalUrls(condition);
3551 urls.removeAll(KUrl());
3553 if (urls.isEmpty()) {
3554 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3557 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3558 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3560 //QProcess::startDetached("ffmpeg", parameters);
3563 void MainWindow::slotTranscodeClip()
3565 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3566 if (urls.isEmpty()) return;
3567 slotTranscode(urls);
3570 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3572 if (m_activeDocument == NULL) return;
3573 QMapIterator<QString, QString> i(props);
3574 while (i.hasNext()) {
3576 m_activeDocument->setDocumentProperty(i.key(), i.value());
3578 m_activeDocument->setModified(true);
3582 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3584 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3586 QString playlistPath;
3589 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3590 QString path = m_renderWidget->getFreeScriptName();
3591 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3592 if (!ok || scriptPath.isEmpty()) return;
3593 scriptPath.prepend(scriptsFolder);
3594 QFile f(scriptPath);
3596 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3599 playlistPath = scriptPath + ".mlt";
3600 m_projectMonitor->saveSceneList(playlistPath);
3602 KTemporaryFile temp;
3603 temp.setAutoRemove(false);
3604 temp.setSuffix(".mlt");
3606 playlistPath = temp.fileName();
3607 m_projectMonitor->saveSceneList(playlistPath);
3610 if (!chapterFile.isEmpty()) {
3613 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3615 in = m_activeTimeline->inPoint();
3616 out = m_activeTimeline->outPoint();
3619 QDomElement chapters = doc.createElement("chapters");
3620 chapters.setAttribute("fps", m_activeDocument->fps());
3621 doc.appendChild(chapters);
3623 QDomElement guidesxml = m_activeDocument->guidesXml();
3624 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3625 for (int i = 0; i < nodes.count(); i++) {
3626 QDomElement e = nodes.item(i).toElement();
3628 QString comment = e.attribute("comment");
3629 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3630 if (time >= in && time < out) {
3631 if (zoneOnly) time = time - in;
3632 QDomElement chapter = doc.createElement("chapter");
3633 chapters.appendChild(chapter);
3634 chapter.setAttribute("title", comment);
3635 chapter.setAttribute("time", time);
3639 if (chapters.childNodes().count() > 0) {
3640 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3641 // Always insert a guide in pos 0
3642 QDomElement chapter = doc.createElement("chapter");
3643 chapters.insertBefore(chapter, QDomNode());
3644 chapter.setAttribute("title", i18n("Start"));
3645 chapter.setAttribute("time", "0");
3647 // save chapters file
3648 QFile file(chapterFile);
3649 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3650 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3652 file.write(doc.toString().toUtf8());
3653 if (file.error() != QFile::NoError) {
3654 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3661 if (m_renderWidget->automaticAudioExport()) {
3662 exportAudio = m_activeTimeline->checkProjectAudio();
3663 } else exportAudio = m_renderWidget->selectedAudioExport();
3664 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3667 void MainWindow::slotUpdateTimecodeFormat(int ix)
3669 KdenliveSettings::setFrametimecode(ix == 1);
3670 m_clipMonitor->updateTimecodeFormat();
3671 m_projectMonitor->updateTimecodeFormat();
3672 m_transitionConfig->updateTimecodeFormat();
3673 m_effectStack->updateTimecodeFormat();
3674 //m_activeTimeline->projectView()->clearSelection();
3675 m_activeTimeline->updateRuler();
3678 void MainWindow::slotRemoveFocus()
3680 statusBar()->setFocus();
3681 statusBar()->clearFocus();
3684 void MainWindow::slotRevert()
3686 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;
3687 KUrl url = m_activeDocument->url();
3688 if (closeCurrentDocument(false))
3689 doOpenFile(url, NULL);
3693 void MainWindow::slotShutdown()
3695 if (m_activeDocument) m_activeDocument->setModified(false);
3697 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3698 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3699 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3700 smserver.call("logout", 1, 2, 2);
3701 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3702 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3703 smserver.call("Shutdown");
3707 void MainWindow::slotUpdateTrackInfo()
3709 if (m_activeDocument)
3710 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3713 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3715 // Load the theme file
3717 if (action == NULL) theme = themename;
3718 else theme = action->data().toString();
3719 KdenliveSettings::setColortheme(theme);
3720 // Make palette for all widgets.
3722 if (theme.isEmpty())
3723 plt = QApplication::desktop()->palette();
3725 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3726 plt = KGlobalSettings::createApplicationPalette(config);
3729 kapp->setPalette(plt);
3730 const QObjectList children = statusBar()->children();
3732 foreach(QObject * child, children) {
3733 if (child->isWidgetType())
3734 ((QWidget*)child)->setPalette(plt);
3735 const QObjectList subchildren = child->children();
3736 foreach(QObject * subchild, subchildren) {
3737 if (subchild->isWidgetType())
3738 ((QWidget*)subchild)->setPalette(plt);
3741 if (m_activeTimeline) {
3742 m_activeTimeline->projectView()->updatePalette();
3747 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
3749 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
3750 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
3751 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
3752 const QSize bitsSize(24, 2);
3753 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
3754 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
3756 QPixmap pixmap(23, 16);
3757 pixmap.fill(Qt::black); // ### use some color other than black for borders?
3759 KConfigGroup group(config, "WM");
3760 QPainter p(&pixmap);
3761 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
3762 p.fillRect(1, 1, 7, 7, windowScheme.background());
3763 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
3765 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
3766 p.fillRect(8, 1, 7, 7, buttonScheme.background());
3767 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
3769 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
3770 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
3772 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
3773 p.fillRect(1, 8, 7, 7, viewScheme.background());
3774 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
3776 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
3777 p.fillRect(8, 8, 7, 7, selectionScheme.background());
3778 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
3780 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
3781 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
3787 void MainWindow::slotSwitchMonitors()
3789 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
3790 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
3791 else m_projectList->focusTree();
3794 void MainWindow::slotInsertZoneToTree()
3796 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
3797 QStringList info = m_clipMonitor->getZoneInfo();
3798 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
3801 void MainWindow::slotInsertZoneToTimeline()
3803 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
3804 QStringList info = m_clipMonitor->getZoneInfo();
3805 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
3809 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
3811 if (m_activeDocument && m_activeTimeline) {
3812 if (!ids.isEmpty()) {
3813 for (int i = 0; i < ids.size(); ++i) {
3814 m_activeTimeline->slotDeleteClip(ids.at(i));
3816 m_activeDocument->clipManager()->slotDeleteClips(ids);
3818 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
3819 m_activeDocument->setModified(true);
3823 void MainWindow::slotShowTitleBars(bool show)
3826 m_effectStackDock->setTitleBarWidget(0);
3827 m_clipMonitorDock->setTitleBarWidget(0);
3828 m_projectMonitorDock->setTitleBarWidget(0);
3830 m_recMonitorDock->setTitleBarWidget(0);
3832 m_effectListDock->setTitleBarWidget(0);
3833 m_transitionConfigDock->setTitleBarWidget(0);
3834 m_projectListDock->setTitleBarWidget(0);
3835 m_undoViewDock->setTitleBarWidget(0);
3836 m_vectorscopeDock->setTitleBarWidget(0);
3837 m_waveformDock->setTitleBarWidget(0);
3838 m_RGBParadeDock->setTitleBarWidget(0);
3839 m_histogramDock->setTitleBarWidget(0);
3840 m_notesDock->setTitleBarWidget(0);
3842 if (!m_effectStackDock->isFloating()) {
3843 m_effectStackDock->setTitleBarWidget(new QWidget);
3845 if (!m_clipMonitorDock->isFloating()) {
3846 m_clipMonitorDock->setTitleBarWidget(new QWidget);
3848 if (!m_projectMonitorDock->isFloating()) {
3849 m_projectMonitorDock->setTitleBarWidget(new QWidget);
3852 if (!m_recMonitorDock->isFloating()) {
3853 m_recMonitorDock->setTitleBarWidget(new QWidget);
3856 if (!m_effectListDock->isFloating()) {
3857 m_effectListDock->setTitleBarWidget(new QWidget);
3859 if (!m_transitionConfigDock->isFloating()) {
3860 m_transitionConfigDock->setTitleBarWidget(new QWidget);
3862 if (!m_projectListDock->isFloating()) {
3863 m_projectListDock->setTitleBarWidget(new QWidget);
3865 if (!m_undoViewDock->isFloating()) {
3866 m_undoViewDock->setTitleBarWidget(new QWidget);
3868 if (!m_vectorscopeDock->isFloating()) {
3869 m_vectorscopeDock->setTitleBarWidget(new QWidget);
3871 if (!m_waveformDock->isFloating()) {
3872 m_waveformDock->setTitleBarWidget(new QWidget);
3874 if (!m_RGBParadeDock->isFloating()) {
3875 m_RGBParadeDock->setTitleBarWidget(new QWidget(this));
3877 if (!m_histogramDock->isFloating()) {
3878 m_histogramDock->setTitleBarWidget(new QWidget(this));
3880 if (!m_notesDock->isFloating()) {
3881 m_notesDock->setTitleBarWidget(new QWidget(this));
3884 KdenliveSettings::setShowtitlebars(show);
3887 void MainWindow::slotSwitchTitles()
3889 slotShowTitleBars(!KdenliveSettings::showtitlebars());
3892 QString MainWindow::getMimeType()
3894 QString mimetype = "application/x-kdenlive";
3895 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
3896 if (!mime) mimetype = "*.kdenlive";
3900 void MainWindow::slotMonitorRequestRenderFrame(bool request)
3903 m_projectMonitor->render->sendFrameForAnalysis = true;
3906 for (int i = 0; i < m_scopesList.count(); i++) {
3907 if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3914 m_projectMonitor->render->sendFrameForAnalysis = false;
3918 void MainWindow::slotUpdateScopeFrameRequest()
3920 // We need a delay to make sure widgets are hidden after a close event for example
3921 QTimer::singleShot(500, this, SLOT(slotDoUpdateScopeFrameRequest()));
3924 void MainWindow::slotDoUpdateScopeFrameRequest()
3927 bool request = false;
3928 for (int i = 0; i < m_scopesList.count(); i++) {
3929 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
3930 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
3936 if (!m_projectMonitor->effectSceneDisplayed())
3937 m_projectMonitor->render->sendFrameForAnalysis = false;
3938 m_clipMonitor->render->sendFrameForAnalysis = false;
3940 m_projectMonitor->render->sendFrameForAnalysis = true;
3941 m_clipMonitor->render->sendFrameForAnalysis = true;
3945 void MainWindow::slotUpdateColorScopes()
3947 bool request = false;
3948 for (int i = 0; i < m_scopesList.count(); i++) {
3949 // Check if we need the renderer to send a new frame for update
3950 if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
3951 static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
3954 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
3955 else m_projectMonitor->render->sendFrameUpdate();
3959 #include "mainwindow.moc"