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 #include "jogaction.h"
46 #include "jogshuttleconfig.h"
47 #endif /* NO_JOGSHUTTLE */
48 #include "clipproperties.h"
50 #include "editclipcommand.h"
51 #include "titlewidget.h"
52 #include "markerdialog.h"
54 #include "interfaces.h"
55 #include "kdenlive-config.h"
56 #include "cliptranscode.h"
57 #include "ui_templateclip_ui.h"
58 #include "colorscopes/vectorscope.h"
59 #include "colorscopes/waveform.h"
60 #include "colorscopes/rgbparade.h"
61 #include "colorscopes/histogram.h"
62 #include "audiospectrum.h"
63 #include "spectrogram.h"
65 #include <KApplication>
69 #include <KActionCollection>
70 #include <KActionCategory>
71 #include <KStandardAction>
72 #include <KShortcutsDialog>
73 #include <KFileDialog>
74 #include <KMessageBox>
76 #include <KIO/NetAccess>
79 #include <KConfigDialog>
80 #include <KXMLGUIFactory>
82 #include <kstandarddirs.h>
83 #include <KUrlRequesterDialog>
84 #include <KTemporaryFile>
86 #include <KActionMenu>
89 #include <ktogglefullscreenaction.h>
91 #include <KNotification>
92 #include <KNotifyConfigWidget>
93 #if KDE_IS_VERSION(4,3,80)
94 #include <knewstuff3/downloaddialog.h>
95 #include <knewstuff3/knewstuffaction.h>
97 #include <knewstuff2/engine.h>
98 #include <knewstuff2/ui/knewstuffaction.h>
100 #endif /* KDE_IS_VERSION(4,3,80) */
102 #include <KColorScheme>
103 #include <KProgressDialog>
105 #include <QTextStream>
109 #include <QInputDialog>
110 #include <QDesktopWidget>
115 // Uncomment for deeper debugging
116 //#define DEBUG_MAINW
122 static const char version[] = VERSION;
124 static const int ID_TIMELINE_POS = 0;
130 Q_DECLARE_METATYPE(QVector<int16_t>)
132 EffectsList MainWindow::videoEffects;
133 EffectsList MainWindow::audioEffects;
134 EffectsList MainWindow::customEffects;
135 EffectsList MainWindow::transitions;
137 MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString & clipsToLoad, QWidget *parent) :
138 KXmlGuiWindow(parent),
139 m_activeDocument(NULL),
140 m_activeTimeline(NULL),
141 m_renderWidget(NULL),
142 #ifndef NO_JOGSHUTTLE
145 #endif /* NO_JOGSHUTTLE */
146 m_findActivated(false),
149 qRegisterMetaType<QVector<int16_t> > ();
150 // Create DBus interface
151 new MainWindowAdaptor(this);
152 QDBusConnection dbus = QDBusConnection::sessionBus();
153 dbus.registerObject("/MainWindow", this);
155 setlocale(LC_NUMERIC, "POSIX");
156 if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
157 setFont(KGlobalSettings::toolBarFont());
158 parseProfiles(MltPath);
159 KdenliveSettings::setCurrent_profile(KdenliveSettings::default_profile());
160 m_commandStack = new QUndoGroup;
161 setDockNestingEnabled(true);
162 m_timelineArea = new KTabWidget(this);
163 m_timelineArea->setTabReorderingEnabled(true);
164 m_timelineArea->setTabBarHidden(true);
165 m_timelineArea->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
166 m_timelineArea->setMinimumHeight(200);
168 QToolButton *closeTabButton = new QToolButton;
169 connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeCurrentDocument()));
170 closeTabButton->setIcon(KIcon("tab-close"));
171 closeTabButton->adjustSize();
172 closeTabButton->setToolTip(i18n("Close the current tab"));
173 m_timelineArea->setCornerWidget(closeTabButton);
174 connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument()));
176 connect(&m_findTimer, SIGNAL(timeout()), this, SLOT(findTimeout()));
177 m_findTimer.setSingleShot(true);
179 // FIXME: the next call returns a newly allocated object, which leaks
180 initEffects::parseEffectFiles();
181 //initEffects::parseCustomEffectsFile();
183 m_monitorManager = new MonitorManager();
185 m_shortcutRemoveFocus = new QShortcut(QKeySequence("Esc"), this);
186 connect(m_shortcutRemoveFocus, SIGNAL(activated()), this, SLOT(slotRemoveFocus()));
191 m_projectListDock = new QDockWidget(i18n("Project Tree"), this);
192 m_projectListDock->setObjectName("project_tree");
193 m_projectList = new ProjectList();
194 m_projectListDock->setWidget(m_projectList);
195 addDockWidget(Qt::TopDockWidgetArea, m_projectListDock);
197 m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
198 m_clipMonitorDock->setObjectName("clip_monitor");
199 m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
200 m_clipMonitorDock->setWidget(m_clipMonitor);
202 m_projectMonitorDock = new QDockWidget(i18n("Project Monitor"), this);
203 m_projectMonitorDock->setObjectName("project_monitor");
204 m_projectMonitor = new Monitor("project", m_monitorManager, QString());
205 m_projectMonitorDock->setWidget(m_projectMonitor);
208 m_recMonitorDock = new QDockWidget(i18n("Record Monitor"), this);
209 m_recMonitorDock->setObjectName("record_monitor");
210 m_recMonitor = new RecMonitor("record");
211 m_recMonitorDock->setWidget(m_recMonitor);
212 connect(m_recMonitor, SIGNAL(addProjectClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
213 connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int)));
216 m_notesDock = new QDockWidget(i18n("Project Notes"), this);
217 m_notesDock->setObjectName("notes_widget");
218 m_notesWidget = new NotesWidget();
219 connect(m_notesWidget, SIGNAL(insertNotesTimecode()), this, SLOT(slotInsertNotesTimecode()));
220 connect(m_notesWidget, SIGNAL(seekProject(int)), m_projectMonitor->render, SLOT(seekToFrame(int)));
222 m_notesWidget->setTabChangesFocus(true);
223 #if KDE_IS_VERSION(4,4,0)
224 m_notesWidget->setClickMessage(i18n("Enter your project notes here ..."));
226 m_notesDock->setWidget(m_notesWidget);
227 addDockWidget(Qt::TopDockWidgetArea, m_notesDock);
229 m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this);
230 m_effectStackDock->setObjectName("effect_stack");
231 m_effectStack = new EffectStackView(m_projectMonitor);
232 m_effectStackDock->setWidget(m_effectStack);
233 addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock);
235 m_transitionConfigDock = new QDockWidget(i18n("Transition"), this);
236 m_transitionConfigDock->setObjectName("transition");
237 m_transitionConfig = new TransitionSettings(m_projectMonitor);
238 m_transitionConfigDock->setWidget(m_transitionConfig);
239 addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock);
241 m_effectListDock = new QDockWidget(i18n("Effect List"), this);
242 m_effectListDock->setObjectName("effect_list");
243 m_effectList = new EffectsListView();
244 m_effectListDock->setWidget(m_effectList);
245 addDockWidget(Qt::TopDockWidgetArea, m_effectListDock);
247 m_vectorscope = new Vectorscope(m_projectMonitor, m_clipMonitor);
248 m_vectorscopeDock = new QDockWidget(i18n("Vectorscope"), this);
249 m_vectorscopeDock->setObjectName(m_vectorscope->widgetName());
250 m_vectorscopeDock->setWidget(m_vectorscope);
251 addDockWidget(Qt::TopDockWidgetArea, m_vectorscopeDock);
252 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), m_vectorscope, SLOT(forceUpdate(bool)));
253 connect(m_vectorscopeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
254 connect(m_vectorscope, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
255 m_gfxScopesList.append(m_vectorscopeDock);
257 m_waveform = new Waveform(m_projectMonitor, m_clipMonitor);
258 m_waveformDock = new QDockWidget(i18n("Waveform"), this);
259 m_waveformDock->setObjectName(m_waveform->widgetName());
260 m_waveformDock->setWidget(m_waveform);
261 addDockWidget(Qt::TopDockWidgetArea, m_waveformDock);
262 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), m_waveform, SLOT(forceUpdate(bool)));
263 connect(m_waveformDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
264 connect(m_waveform, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
265 m_gfxScopesList.append(m_waveformDock);
267 m_RGBParade = new RGBParade(m_projectMonitor, m_clipMonitor);
268 m_RGBParadeDock = new QDockWidget(i18n("RGB Parade"), this);
269 m_RGBParadeDock->setObjectName(m_RGBParade->widgetName());
270 m_RGBParadeDock->setWidget(m_RGBParade);
271 addDockWidget(Qt::TopDockWidgetArea, m_RGBParadeDock);
272 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), m_RGBParade, SLOT(forceUpdate(bool)));
273 connect(m_RGBParadeDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
274 connect(m_RGBParade, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
275 m_gfxScopesList.append(m_RGBParadeDock);
277 m_histogram = new Histogram(m_projectMonitor, m_clipMonitor);
278 m_histogramDock = new QDockWidget(i18n("Histogram"), this);
279 m_histogramDock->setObjectName(m_histogram->widgetName());
280 m_histogramDock->setWidget(m_histogram);
281 addDockWidget(Qt::TopDockWidgetArea, m_histogramDock);
282 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), m_histogram, SLOT(forceUpdate(bool)));
283 connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
284 connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateGfxScopeFrameRequest()));
285 m_gfxScopesList.append(m_histogramDock);
288 m_audiosignal = new AudioSignal;
289 m_audiosignalDock = new QDockWidget(i18n("Audio Signal"), this);
290 m_audiosignalDock->setObjectName("audiosignal");
291 m_audiosignalDock->setWidget(m_audiosignal);
292 addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
293 connect(m_audiosignalDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
294 connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), this, SLOT(slotUpdateAudioScopeFrameRequest()));
296 m_audioSpectrum = new AudioSpectrum();
297 m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
298 m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
299 m_audioSpectrumDock->setWidget(m_audioSpectrum);
300 addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
301 m_audioScopesList.append(m_audioSpectrum);
302 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
303 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
305 m_spectrogram = new Spectrogram();
306 m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
307 m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
308 m_spectrogramDock->setWidget(m_spectrogram);
309 addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
310 m_audioScopesList.append(m_spectrogram);
311 connect(m_audioSpectrumDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
312 connect(m_audioSpectrum, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateAudioScopeFrameRequest()));
314 // Connect the audio signal to the audio scope slots
316 if (m_projectMonitor) {
317 qDebug() << "project monitor connected";
318 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
319 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
320 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
321 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
322 b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
323 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
326 qDebug() << "clip monitor connected";
327 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
328 m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
329 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
330 m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
331 b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
332 m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
334 // Ensure connections were set up correctly
339 // Add monitors here to keep them at the right of the window
340 addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
341 addDockWidget(Qt::TopDockWidgetArea, m_projectMonitorDock);
343 addDockWidget(Qt::TopDockWidgetArea, m_recMonitorDock);
346 m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
347 m_undoViewDock->setObjectName("undo_history");
348 m_undoView = new QUndoView();
349 m_undoView->setCleanIcon(KIcon("edit-clear"));
350 m_undoView->setEmptyLabel(i18n("Clean"));
351 m_undoViewDock->setWidget(m_undoView);
352 m_undoView->setGroup(m_commandStack);
353 addDockWidget(Qt::TopDockWidgetArea, m_undoViewDock);
359 // Close non-general docks for the initial layout
360 // only show important ones
361 m_histogramDock->close();
362 m_RGBParadeDock->close();
363 m_waveformDock->close();
364 m_vectorscopeDock->close();
366 m_audioSpectrumDock->close();
367 m_spectrogramDock->close();
368 m_audiosignalDock->close();
370 m_undoViewDock->close();
374 /// Tabify Widgets ///
375 tabifyDockWidget(m_effectListDock, m_effectStackDock);
376 tabifyDockWidget(m_effectListDock, m_transitionConfigDock);
377 tabifyDockWidget(m_projectListDock, m_notesDock);
379 tabifyDockWidget(m_clipMonitorDock, m_projectMonitorDock);
381 tabifyDockWidget(m_clipMonitorDock, m_recMonitorDock);
387 setCentralWidget(m_timelineArea);
390 m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), actionCollection());
392 m_fileRevert = KStandardAction::revert(this, SLOT(slotRevert()), actionCollection());
393 m_fileRevert->setEnabled(false);
395 // Prepare layout actions
396 KActionCategory *layoutActions = new KActionCategory(i18n("Layouts"), actionCollection());
397 m_loadLayout = new KSelectAction(i18n("Load Layout"), actionCollection());
398 for (int i = 1; i < 5; i++) {
399 KAction *load = new KAction(KIcon(), i18n("Layout %1").arg(i), this);
400 load->setData("_" + QString::number(i));
401 layoutActions->addAction("load_layout" + QString::number(i), load);
402 m_loadLayout->addAction(load);
403 KAction *save = new KAction(KIcon(), i18n("Save As Layout %1").arg(i), this);
404 save->setData("_" + QString::number(i));
405 layoutActions->addAction("save_layout" + QString::number(i), save);
407 layoutActions->addAction("load_layouts", m_loadLayout);
408 connect(m_loadLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotLoadLayout(QAction*)));
411 // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
412 m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
413 action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
414 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
415 m_stopmotion_actions->addAction("stopmotion_capture", action);
416 action = new KAction(i18n("Switch live / captured frame"), this);
417 //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
418 m_stopmotion_actions->addAction("stopmotion_switch", action);
419 action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
420 action->setCheckable(true);
421 action->setChecked(false);
422 m_stopmotion_actions->addAction("stopmotion_overlay", action);
424 // Build effects menu
425 m_effectsMenu = new QMenu(i18n("Add Effect"));
426 m_effectActions = new KActionCategory(i18n("Effects"), actionCollection());
427 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
428 m_effectsActionCollection->readSettings();
432 // Find QDockWidget tab bars and show / hide widget title bars on right click
433 QList <QTabBar *> tabs = findChildren<QTabBar *>();
434 for (int i = 0; i < tabs.count(); i++) {
435 tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
436 connect(tabs.at(i), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(slotSwitchTitles()));
439 /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
440 guiFactory()->addClient(sp);*/
442 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
444 connect(saveLayout, SIGNAL(triggered(QAction*)), this, SLOT(slotSaveLayout(QAction*)));
447 // Load layout names from config file
453 m_projectMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, NULL, m_loopClip);
454 m_clipMonitor->setupMenu(static_cast<QMenu*>(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast<QMenu*>(factory()->container("marker_menu", this)));
456 QMenu *clipInTimeline = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
457 clipInTimeline->setIcon(KIcon("go-jump"));
458 m_projectList->setupGeneratorMenu(static_cast<QMenu*>(factory()->container("generators", this)),
459 static_cast<QMenu*>(factory()->container("transcoders", this)),
462 // build themes menus
463 QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
464 QActionGroup *themegroup = new QActionGroup(this);
465 themegroup->setExclusive(true);
466 action = new KAction(i18n("Default"), this);
467 action->setCheckable(true);
468 themegroup->addAction(action);
469 if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true);
471 const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);
473 for (int i = 0; i < schemeFiles.size(); ++i) {
475 const QString filename = schemeFiles.at(i);
476 const QFileInfo info(filename);
479 KSharedConfigPtr config = KSharedConfig::openConfig(filename);
480 QIcon icon = createSchemePreviewIcon(config);
481 KConfigGroup group(config, "General");
482 const QString name = group.readEntry("Name", info.baseName());
483 action = new KAction(name, this);
484 action->setData(filename);
485 action->setIcon(icon);
486 action->setCheckable(true);
487 themegroup->addAction(action);
488 if (KdenliveSettings::colortheme() == filename) action->setChecked(true);
491 /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes"));
492 QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates);
493 for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it)
496 action = new QAction(fi.fileName(), this);
497 action->setData(*it);
498 action->setCheckable(true);
499 themegroup->addAction(action);
500 if (KdenliveSettings::colortheme() == *it) action->setChecked(true);
502 themesMenu->addActions(themegroup->actions());
503 connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*)));
505 // Setup and fill effects and transitions menus.
508 QMenu *m = static_cast<QMenu*>(factory()->container("video_effects_menu", this));
509 m->addActions(m_effectsMenu->actions());
512 m_transitionsMenu = new QMenu(i18n("Add Transition"), this);
513 for (int i = 0; i < transitions.count(); ++i)
514 m_transitionsMenu->addAction(m_transitions[i]);
516 connect(m, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
517 connect(m_effectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *)));
518 connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *)));
520 m_effectStack->setMenu(m_effectsMenu);
522 QMenu *viewMenu = static_cast<QMenu*>(factory()->container("dockwindows", this));
523 const QList<QAction *> viewActions = createPopupMenu()->actions();
524 viewMenu->insertActions(NULL, viewActions);
526 m_timelineContextMenu = new QMenu(this);
527 m_timelineContextClipMenu = new QMenu(this);
528 m_timelineContextTransitionMenu = new QMenu(this);
530 m_timelineContextMenu->addAction(actionCollection()->action("insert_space"));
531 m_timelineContextMenu->addAction(actionCollection()->action("delete_space"));
532 m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste)));
534 m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree"));
535 //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree"));
536 m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration"));
537 m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item"));
538 m_timelineContextClipMenu->addSeparator();
539 m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip"));
540 m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip"));
541 m_timelineContextClipMenu->addAction(actionCollection()->action("split_audio"));
542 m_timelineContextClipMenu->addSeparator();
543 m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip"));
544 m_timelineContextClipMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
545 m_timelineContextClipMenu->addAction(actionCollection()->action("paste_effects"));
546 m_timelineContextClipMenu->addSeparator();
548 QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this));
549 m_timelineContextClipMenu->addMenu(markersMenu);
550 m_timelineContextClipMenu->addSeparator();
551 m_timelineContextClipMenu->addMenu(m_transitionsMenu);
552 m_timelineContextClipMenu->addMenu(m_effectsMenu);
554 m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration"));
555 m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item"));
556 m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy)));
558 m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition"));
560 connect(m_projectMonitorDock, SIGNAL(visibilityChanged(bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
561 connect(m_clipMonitorDock, SIGNAL(visibilityChanged(bool)), m_clipMonitor, SLOT(refreshMonitor(bool)));
562 //connect(m_monitorManager, SIGNAL(connectMonitors()), this, SLOT(slotConnectMonitors()));
563 connect(m_monitorManager, SIGNAL(raiseClipMonitor(bool)), this, SLOT(slotRaiseMonitor(bool)));
564 connect(m_monitorManager, SIGNAL(checkColorScopes()), this, SLOT(slotUpdateColorScopes()));
565 connect(m_effectList, SIGNAL(addEffect(const QDomElement)), this, SLOT(slotAddEffect(const QDomElement)));
566 connect(m_effectList, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
568 m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
569 slotConnectMonitors();
571 // Open or create a file. Command line argument passed in Url has
572 // precedence, then "openlastproject", then just a plain empty file.
573 // If opening Url fails, openlastproject will _not_ be used.
574 if (!Url.isEmpty()) {
575 // delay loading so that the window shows up
577 QTimer::singleShot(500, this, SLOT(openFile()));
578 } else if (KdenliveSettings::openlastproject()) {
579 QTimer::singleShot(500, this, SLOT(openLastFile()));
580 } else { //if (m_timelineArea->count() == 0) {
584 if (!clipsToLoad.isEmpty() && m_activeDocument) {
585 QStringList list = clipsToLoad.split(',');
587 foreach(QString path, list) {
588 kDebug() << QDir::current().absoluteFilePath(path);
589 urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
591 m_projectList->slotAddClip(urls);
594 #ifndef NO_JOGSHUTTLE
595 activateShuttleDevice();
596 #endif /* NO_JOGSHUTTLE */
597 m_projectListDock->raise();
599 actionCollection()->addAssociatedWidget(m_clipMonitor->container());
600 actionCollection()->addAssociatedWidget(m_projectMonitor->container());
603 MainWindow::~MainWindow()
608 m_effectStack->slotClipItemSelected(NULL, 0);
609 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
611 if (m_projectMonitor) m_projectMonitor->stop();
612 if (m_clipMonitor) m_clipMonitor->stop();
614 delete m_activeTimeline;
615 delete m_effectStack;
616 delete m_transitionConfig;
617 delete m_activeDocument;
618 delete m_projectMonitor;
619 delete m_clipMonitor;
620 delete m_shortcutRemoveFocus;
621 delete[] m_transitions;
622 Mlt::Factory::close();
626 bool MainWindow::queryClose()
628 if (m_renderWidget) {
629 int waitingJobs = m_renderWidget->waitingJobsCount();
630 if (waitingJobs > 0) {
631 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")))) {
632 case KMessageBox::Yes :
633 // create script with waiting jobs and start it
634 if (m_renderWidget->startWaitingRenderJobs() == false) return false;
636 case KMessageBox::No :
637 // Don't do anything, jobs will be deleted
645 if (m_monitorManager) m_monitorManager->stopActiveMonitor();
646 // warn the user to save if document is modified and we have clips in our project list
647 if (m_activeDocument && m_activeDocument->isModified() &&
648 ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) ||
649 !m_projectList->documentClipList().isEmpty())) {
653 if (m_activeDocument->url().fileName().isEmpty())
654 message = i18n("Save changes to document?");
656 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
657 switch (KMessageBox::warningYesNoCancel(this, message)) {
658 case KMessageBox::Yes :
659 // save document here. If saving fails, return false;
661 case KMessageBox::No :
662 // User does not want to save the changes, clear recovery files
663 m_activeDocument->m_autosave->resize(0);
672 void MainWindow::loadPlugins()
674 foreach(QObject * plugin, QPluginLoader::staticInstances()) {
675 populateMenus(plugin);
678 QStringList directories = KGlobal::dirs()->findDirs("module", QString());
680 filters << "libkdenlive*";
681 foreach(const QString & folder, directories) {
682 kDebug() << "Parsing plugin folder: " << folder;
683 QDir pluginsDir(folder);
684 foreach(const QString & fileName,
685 pluginsDir.entryList(filters, QDir::Files)) {
687 * Avoid loading the same plugin twice when there is more than one
690 if (!m_pluginFileNames.contains(fileName)) {
691 kDebug() << "Found plugin: " << fileName;
692 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
693 QObject *plugin = loader.instance();
695 populateMenus(plugin);
696 m_pluginFileNames += fileName;
698 kDebug() << "Error loading plugin: " << fileName << ", " << loader.errorString();
704 void MainWindow::populateMenus(QObject *plugin)
706 QMenu *addMenu = static_cast<QMenu*>(factory()->container("generators", this));
707 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(plugin);
709 addToMenu(plugin, iGenerator->generators(KdenliveSettings::producerslist()), addMenu, SLOT(generateClip()),
713 void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
714 QMenu *menu, const char *member,
715 QActionGroup *actionGroup)
717 kDebug() << "// ADD to MENU" << texts;
718 foreach(const QString & text, texts) {
719 QAction *action = new QAction(text, plugin);
720 action->setData(text);
721 connect(action, SIGNAL(triggered()), this, member);
722 menu->addAction(action);
725 action->setCheckable(true);
726 actionGroup->addAction(action);
731 void MainWindow::aboutPlugins()
733 //PluginDialog dialog(pluginsDir.path(), m_pluginFileNames, this);
738 void MainWindow::generateClip()
740 QAction *action = qobject_cast<QAction *>(sender());
741 ClipGenerator *iGenerator = qobject_cast<ClipGenerator *>(action->parent());
743 KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(),
744 QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height());
745 if (!clipUrl.isEmpty()) {
746 m_projectList->slotAddClip(QList <QUrl> () << clipUrl);
750 void MainWindow::saveProperties(KConfigGroup &config)
752 // save properties here,used by session management
754 KMainWindow::saveProperties(config);
758 void MainWindow::readProperties(const KConfigGroup &config)
760 // read properties here,used by session management
761 KMainWindow::readProperties(config);
762 QString Lastproject = config.group("Recent Files").readPathEntry("File1", QString());
763 openFile(KUrl(Lastproject));
766 void MainWindow::slotReloadEffects()
768 initEffects::parseCustomEffectsFile();
769 m_effectList->reloadEffectList(m_effectsMenu, m_effectActions);
772 #ifndef NO_JOGSHUTTLE
773 void MainWindow::activateShuttleDevice()
779 if (KdenliveSettings::enableshuttle() == false) return;
781 m_jogProcess = new JogShuttle(KdenliveSettings::shuttledevice());
782 m_jogShuttle = new JogShuttleAction(m_jogProcess, JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons()));
784 connect(m_jogShuttle, SIGNAL(rewindOneFrame()), m_monitorManager, SLOT(slotRewindOneFrame()));
785 connect(m_jogShuttle, SIGNAL(forwardOneFrame()), m_monitorManager, SLOT(slotForwardOneFrame()));
786 connect(m_jogShuttle, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
787 connect(m_jogShuttle, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
788 connect(m_jogShuttle, SIGNAL(action(const QString&)), this, SLOT(slotDoAction(const QString&)));
790 #endif /* NO_JOGSHUTTLE */
792 void MainWindow::slotDoAction(const QString& action_name)
794 QAction* action = actionCollection()->action(action_name);
796 fprintf(stderr, "%s", QString("shuttle action '%1' unknown\n").arg(action_name).toAscii().constData());
802 void MainWindow::configureNotifications()
804 KNotifyConfigWidget::configure(this);
807 void MainWindow::slotFullScreen()
809 KToggleFullScreenAction::setFullScreen(this, actionCollection()->action("fullscreen")->isChecked());
812 void MainWindow::slotAddEffect(const QDomElement effect)
814 if (!m_activeDocument) return;
815 if (effect.isNull()) {
816 kDebug() << "--- ERROR, TRYING TO APPEND NULL EFFECT";
819 QDomElement effectToAdd = effect.cloneNode().toElement();
821 int ix = m_effectStack->isTrackMode(&ok);
822 if (ok) m_activeTimeline->projectView()->slotAddTrackEffect(effectToAdd, m_activeDocument->tracksCount() - ix);
823 else m_activeTimeline->projectView()->slotAddEffect(effectToAdd, GenTime(), -1);
826 void MainWindow::slotRaiseMonitor(bool clipMonitor)
828 if (clipMonitor) m_clipMonitorDock->raise();
829 else m_projectMonitorDock->raise();
832 void MainWindow::slotUpdateClip(const QString &id)
834 if (!m_activeDocument) return;
835 m_activeTimeline->projectView()->slotUpdateClip(id);
838 void MainWindow::slotConnectMonitors()
840 m_projectList->setRenderer(m_projectMonitor->render);
841 //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &)));
842 connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap<QString, QString>)), this, SLOT(slotDeleteProjectClips(QStringList, QMap<QString, QString>)));
843 connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
844 connect(m_projectList, SIGNAL(showClipProperties(QList <DocClipBase *>, QMap<QString, QString>)), this, SLOT(slotShowClipProperties(QList <DocClipBase *>, QMap<QString, QString>)));
845 connect(m_projectList, SIGNAL(getFileProperties(const QDomElement, const QString &, int, bool, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement, const QString &, int, bool, bool)));
846 connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
847 connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool, bool)));
849 connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &, bool)));
850 connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(const QString &, bool)), m_projectList, SLOT(slotRemoveInvalidProxy(const QString &, bool)));
852 connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(const QString &, bool)), m_projectList, SLOT(slotRefreshClipThumbnail(const QString &, bool)));
854 connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
855 connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
857 connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
859 connect(m_clipMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
860 connect(m_projectMonitor, SIGNAL(saveZone(Render *, QPoint)), this, SLOT(slotSaveZone(Render *, QPoint)));
863 void MainWindow::slotAdjustClipMonitor()
865 m_clipMonitorDock->updateGeometry();
866 m_clipMonitorDock->adjustSize();
867 m_clipMonitor->resetSize();
870 void MainWindow::slotAdjustProjectMonitor()
872 m_projectMonitorDock->updateGeometry();
873 m_projectMonitorDock->adjustSize();
874 m_projectMonitor->resetSize();
878 class NameGrabbingKActionCollection {
880 NameGrabbingKActionCollection(KActionCollection* collection, QStringList& action_names)
881 : m_collection(collection), m_action_names(action_names) {
882 m_action_names.clear();
884 KAction* addAction(const QString& action_name) {
885 m_action_names << action_name;
886 return m_collection->addAction(action_name);
888 void addAction(const QString& action_name, QAction* action) {
889 m_action_names << action_name;
890 m_collection->addAction(action_name, action);
892 operator KActionCollection*() { return m_collection; }
893 const QStringList& actionNames() const { return m_action_names; }
895 KActionCollection* m_collection;
896 QStringList& m_action_names;
899 void MainWindow::setupActions()
902 NameGrabbingKActionCollection collection(actionCollection(), m_action_names);
903 m_timecodeFormat = new KComboBox(this);
904 m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
905 m_timecodeFormat->addItem(i18n("Frames"));
906 if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
907 connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
909 m_statusProgressBar = new QProgressBar(this);
910 m_statusProgressBar->setMinimum(0);
911 m_statusProgressBar->setMaximum(100);
912 m_statusProgressBar->setMaximumWidth(150);
913 m_statusProgressBar->setVisible(false);
915 KToolBar *toolbar = new KToolBar("statusToolBar", this, Qt::BottomToolBarArea);
916 toolbar->setMovable(false);
917 KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
918 QColor buttonBg = scheme.background(KColorScheme::LinkBackground).color();
919 QColor buttonBord = scheme.foreground(KColorScheme::LinkText).color();
920 QColor buttonBord2 = scheme.shade(KColorScheme::LightShade);
921 statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize()));
922 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());
923 QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}";
925 //create edit mode buttons
926 m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this);
927 m_normalEditTool->setShortcut(i18nc("Normal editing", "n"));
928 toolbar->addAction(m_normalEditTool);
929 m_normalEditTool->setCheckable(true);
930 m_normalEditTool->setChecked(true);
932 m_overwriteEditTool = new KAction(KIcon("kdenlive-overwrite-edit"), i18n("Overwrite mode"), this);
933 //m_overwriteEditTool->setShortcut(i18nc("Overwrite mode shortcut", "o"));
934 toolbar->addAction(m_overwriteEditTool);
935 m_overwriteEditTool->setCheckable(true);
936 m_overwriteEditTool->setChecked(false);
938 m_insertEditTool = new KAction(KIcon("kdenlive-insert-edit"), i18n("Insert mode"), this);
939 //m_insertEditTool->setShortcut(i18nc("Insert mode shortcut", "i"));
940 toolbar->addAction(m_insertEditTool);
941 m_insertEditTool->setCheckable(true);
942 m_insertEditTool->setChecked(false);
943 // not implemented yet
944 m_insertEditTool->setEnabled(false);
946 QActionGroup *editGroup = new QActionGroup(this);
947 editGroup->addAction(m_normalEditTool);
948 editGroup->addAction(m_overwriteEditTool);
949 editGroup->addAction(m_insertEditTool);
950 editGroup->setExclusive(true);
951 connect(editGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeEdit(QAction *)));
952 //connect(m_overwriteEditTool, SIGNAL(toggled(bool)), this, SLOT(slotSetOverwriteMode(bool)));
954 toolbar->addSeparator();
956 // create tools buttons
957 m_buttonSelectTool = new KAction(KIcon("kdenlive-select-tool"), i18n("Selection tool"), this);
958 m_buttonSelectTool->setShortcut(i18nc("Selection tool shortcut", "s"));
959 toolbar->addAction(m_buttonSelectTool);
960 m_buttonSelectTool->setCheckable(true);
961 m_buttonSelectTool->setChecked(true);
963 m_buttonRazorTool = new KAction(KIcon("edit-cut"), i18n("Razor tool"), this);
964 m_buttonRazorTool->setShortcut(i18nc("Razor tool shortcut", "x"));
965 toolbar->addAction(m_buttonRazorTool);
966 m_buttonRazorTool->setCheckable(true);
967 m_buttonRazorTool->setChecked(false);
969 m_buttonSpacerTool = new KAction(KIcon("kdenlive-spacer-tool"), i18n("Spacer tool"), this);
970 m_buttonSpacerTool->setShortcut(i18nc("Spacer tool shortcut", "m"));
971 toolbar->addAction(m_buttonSpacerTool);
972 m_buttonSpacerTool->setCheckable(true);
973 m_buttonSpacerTool->setChecked(false);
975 QActionGroup *toolGroup = new QActionGroup(this);
976 toolGroup->addAction(m_buttonSelectTool);
977 toolGroup->addAction(m_buttonRazorTool);
978 toolGroup->addAction(m_buttonSpacerTool);
979 toolGroup->setExclusive(true);
980 toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
982 QWidget * actionWidget;
983 int max = toolbar->iconSizeDefault() + 2;
984 actionWidget = toolbar->widgetForAction(m_normalEditTool);
985 actionWidget->setMaximumWidth(max);
986 actionWidget->setMaximumHeight(max - 4);
988 actionWidget = toolbar->widgetForAction(m_insertEditTool);
989 actionWidget->setMaximumWidth(max);
990 actionWidget->setMaximumHeight(max - 4);
992 actionWidget = toolbar->widgetForAction(m_overwriteEditTool);
993 actionWidget->setMaximumWidth(max);
994 actionWidget->setMaximumHeight(max - 4);
996 actionWidget = toolbar->widgetForAction(m_buttonSelectTool);
997 actionWidget->setMaximumWidth(max);
998 actionWidget->setMaximumHeight(max - 4);
1000 actionWidget = toolbar->widgetForAction(m_buttonRazorTool);
1001 actionWidget->setMaximumWidth(max);
1002 actionWidget->setMaximumHeight(max - 4);
1004 actionWidget = toolbar->widgetForAction(m_buttonSpacerTool);
1005 actionWidget->setMaximumWidth(max);
1006 actionWidget->setMaximumHeight(max - 4);
1008 toolbar->setStyleSheet(style1);
1009 connect(toolGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotChangeTool(QAction *)));
1011 toolbar->addSeparator();
1012 m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this);
1013 toolbar->addAction(m_buttonFitZoom);
1014 m_buttonFitZoom->setCheckable(false);
1016 m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this);
1017 toolbar->addAction(m_zoomOut);
1018 m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus);
1020 m_zoomSlider = new QSlider(Qt::Horizontal, this);
1021 m_zoomSlider->setMaximum(13);
1022 m_zoomSlider->setPageStep(1);
1023 m_zoomSlider->setInvertedAppearance(true);
1025 m_zoomSlider->setMaximumWidth(150);
1026 m_zoomSlider->setMinimumWidth(100);
1027 toolbar->addWidget(m_zoomSlider);
1029 m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this);
1030 toolbar->addAction(m_zoomIn);
1031 m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus);
1033 actionWidget = toolbar->widgetForAction(m_buttonFitZoom);
1034 actionWidget->setMaximumWidth(max);
1035 actionWidget->setMaximumHeight(max - 4);
1036 actionWidget->setStyleSheet(styleBorderless);
1038 actionWidget = toolbar->widgetForAction(m_zoomIn);
1039 actionWidget->setMaximumWidth(max);
1040 actionWidget->setMaximumHeight(max - 4);
1041 actionWidget->setStyleSheet(styleBorderless);
1043 actionWidget = toolbar->widgetForAction(m_zoomOut);
1044 actionWidget->setMaximumWidth(max);
1045 actionWidget->setMaximumHeight(max - 4);
1046 actionWidget->setStyleSheet(styleBorderless);
1048 connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int)));
1049 connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int)));
1050 connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom()));
1051 connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn()));
1052 connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut()));
1054 toolbar->addSeparator();
1056 //create automatic audio split button
1057 m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this);
1058 toolbar->addAction(m_buttonAutomaticSplitAudio);
1059 m_buttonAutomaticSplitAudio->setCheckable(true);
1060 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
1061 connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio()));
1063 m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this);
1064 toolbar->addAction(m_buttonVideoThumbs);
1065 m_buttonVideoThumbs->setCheckable(true);
1066 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
1067 connect(m_buttonVideoThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchVideoThumbs()));
1069 m_buttonAudioThumbs = new KAction(KIcon("kdenlive-show-audiothumb"), i18n("Show audio thumbnails"), this);
1070 toolbar->addAction(m_buttonAudioThumbs);
1071 m_buttonAudioThumbs->setCheckable(true);
1072 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
1073 connect(m_buttonAudioThumbs, SIGNAL(triggered()), this, SLOT(slotSwitchAudioThumbs()));
1075 m_buttonShowMarkers = new KAction(KIcon("kdenlive-show-markers"), i18n("Show markers comments"), this);
1076 toolbar->addAction(m_buttonShowMarkers);
1077 m_buttonShowMarkers->setCheckable(true);
1078 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
1079 connect(m_buttonShowMarkers, SIGNAL(triggered()), this, SLOT(slotSwitchMarkersComments()));
1081 m_buttonSnap = new KAction(KIcon("kdenlive-snap"), i18n("Snap"), this);
1082 toolbar->addAction(m_buttonSnap);
1083 m_buttonSnap->setCheckable(true);
1084 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
1085 connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap()));
1087 actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio);
1088 actionWidget->setMaximumWidth(max);
1089 actionWidget->setMaximumHeight(max - 4);
1091 actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs);
1092 actionWidget->setMaximumWidth(max);
1093 actionWidget->setMaximumHeight(max - 4);
1095 actionWidget = toolbar->widgetForAction(m_buttonAudioThumbs);
1096 actionWidget->setMaximumWidth(max);
1097 actionWidget->setMaximumHeight(max - 4);
1099 actionWidget = toolbar->widgetForAction(m_buttonShowMarkers);
1100 actionWidget->setMaximumWidth(max);
1101 actionWidget->setMaximumHeight(max - 4);
1103 actionWidget = toolbar->widgetForAction(m_buttonSnap);
1104 actionWidget->setMaximumWidth(max);
1105 actionWidget->setMaximumHeight(max - 4);
1107 m_messageLabel = new StatusBarMessageLabel(this);
1108 m_messageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
1110 statusBar()->addWidget(m_messageLabel, 10);
1111 statusBar()->addWidget(m_statusProgressBar, 0);
1112 statusBar()->addPermanentWidget(toolbar);
1113 statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
1114 statusBar()->addPermanentWidget(m_timecodeFormat);
1115 //statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 3);
1117 collection.addAction("normal_mode", m_normalEditTool);
1118 collection.addAction("overwrite_mode", m_overwriteEditTool);
1119 collection.addAction("insert_mode", m_insertEditTool);
1120 collection.addAction("select_tool", m_buttonSelectTool);
1121 collection.addAction("razor_tool", m_buttonRazorTool);
1122 collection.addAction("spacer_tool", m_buttonSpacerTool);
1124 collection.addAction("automatic_split_audio", m_buttonAutomaticSplitAudio);
1125 collection.addAction("show_video_thumbs", m_buttonVideoThumbs);
1126 collection.addAction("show_audio_thumbs", m_buttonAudioThumbs);
1127 collection.addAction("show_markers", m_buttonShowMarkers);
1128 collection.addAction("snap", m_buttonSnap);
1129 collection.addAction("zoom_fit", m_buttonFitZoom);
1130 collection.addAction("zoom_in", m_zoomIn);
1131 collection.addAction("zoom_out", m_zoomOut);
1133 m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this);
1134 collection.addAction("project_find", m_projectSearch);
1135 connect(m_projectSearch, SIGNAL(triggered(bool)), this, SLOT(slotFind()));
1136 m_projectSearch->setShortcut(Qt::Key_Slash);
1138 m_projectSearchNext = new KAction(KIcon("go-down-search"), i18n("Find Next"), this);
1139 collection.addAction("project_find_next", m_projectSearchNext);
1140 connect(m_projectSearchNext, SIGNAL(triggered(bool)), this, SLOT(slotFindNext()));
1141 m_projectSearchNext->setShortcut(Qt::Key_F3);
1142 m_projectSearchNext->setEnabled(false);
1144 KAction* profilesAction = new KAction(KIcon("document-new"), i18n("Manage Project Profiles"), this);
1145 collection.addAction("manage_profiles", profilesAction);
1146 connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles()));
1148 KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas");
1149 KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles");
1150 KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles");
1151 KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles");
1153 KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this);
1154 collection.addAction("run_wizard", wizAction);
1155 connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard()));
1157 KAction* projectAction = new KAction(KIcon("configure"), i18n("Project Settings"), this);
1158 collection.addAction("project_settings", projectAction);
1159 connect(projectAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProjectSettings()));
1161 KAction* projectRender = new KAction(KIcon("media-record"), i18n("Render"), this);
1162 collection.addAction("project_render", projectRender);
1163 projectRender->setShortcut(Qt::CTRL + Qt::Key_Return);
1164 connect(projectRender, SIGNAL(triggered(bool)), this, SLOT(slotRenderProject()));
1166 KAction* projectClean = new KAction(KIcon("edit-clear"), i18n("Clean Project"), this);
1167 collection.addAction("project_clean", projectClean);
1168 connect(projectClean, SIGNAL(triggered(bool)), this, SLOT(slotCleanProject()));
1170 KAction* projectAdjust = new KAction(KIcon(), i18n("Adjust Profile to Current Clip"), this);
1171 collection.addAction("project_adjust_profile", projectAdjust);
1172 connect(projectAdjust, SIGNAL(triggered(bool)), m_projectList, SLOT(adjustProjectProfileToItem()));
1174 KAction* monitorPlay = new KAction(KIcon("media-playback-start"), i18n("Play"), this);
1175 KShortcut playShortcut;
1176 playShortcut.setPrimary(Qt::Key_Space);
1177 playShortcut.setAlternate(Qt::Key_K);
1178 monitorPlay->setShortcut(playShortcut);
1179 collection.addAction("monitor_play", monitorPlay);
1180 connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay()));
1182 KAction* monitorPause = new KAction(KIcon("media-playback-stop"), i18n("Pause"), this);
1183 collection.addAction("monitor_pause", monitorPause);
1184 connect(monitorPause, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPause()));
1186 m_playZone = new KAction(KIcon("media-playback-start"), i18n("Play Zone"), this);
1187 m_playZone->setShortcut(Qt::CTRL + Qt::Key_Space);
1188 collection.addAction("monitor_play_zone", m_playZone);
1189 connect(m_playZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlayZone()));
1191 m_loopZone = new KAction(KIcon("media-playback-start"), i18n("Loop Zone"), this);
1192 m_loopZone->setShortcut(Qt::ALT + Qt::Key_Space);
1193 collection.addAction("monitor_loop_zone", m_loopZone);
1194 connect(m_loopZone, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotLoopZone()));
1196 m_loopClip = new KAction(KIcon("media-playback-start"), i18n("Loop selected clip"), this);
1197 m_loopClip->setEnabled(false);
1198 collection.addAction("monitor_loop_clip", m_loopClip);
1199 connect(m_loopClip, SIGNAL(triggered(bool)), m_projectMonitor, SLOT(slotLoopClip()));
1201 KAction *dvdWizard = new KAction(KIcon("media-optical"), i18n("DVD Wizard"), this);
1202 collection.addAction("dvd_wizard", dvdWizard);
1203 connect(dvdWizard, SIGNAL(triggered(bool)), this, SLOT(slotDvdWizard()));
1205 KAction *transcodeClip = new KAction(KIcon("edit-copy"), i18n("Transcode Clips"), this);
1206 collection.addAction("transcode_clip", transcodeClip);
1207 connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip()));
1209 KAction *markIn = collection.addAction("mark_in");
1210 markIn->setText(i18n("Set Zone In"));
1211 markIn->setShortcut(Qt::Key_I);
1212 connect(markIn, SIGNAL(triggered(bool)), this, SLOT(slotSetInPoint()));
1214 KAction *markOut = collection.addAction("mark_out");
1215 markOut->setText(i18n("Set Zone Out"));
1216 markOut->setShortcut(Qt::Key_O);
1217 connect(markOut, SIGNAL(triggered(bool)), this, SLOT(slotSetOutPoint()));
1219 KAction *switchMon = collection.addAction("switch_monitor");
1220 switchMon->setText(i18n("Switch monitor"));
1221 switchMon->setShortcut(Qt::Key_T);
1222 connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
1224 KAction *fullMon = collection.addAction("monitor_fullscreen");
1225 fullMon->setText(i18n("Switch monitor fullscreen"));
1226 fullMon->setIcon(KIcon("view-fullscreen"));
1227 connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
1229 KAction *insertTree = collection.addAction("insert_project_tree");
1230 insertTree->setText(i18n("Insert zone in project tree"));
1231 insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
1232 connect(insertTree, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTree()));
1234 KAction *insertTimeline = collection.addAction("insert_timeline");
1235 insertTimeline->setText(i18n("Insert zone in timeline"));
1236 insertTimeline->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_I);
1237 connect(insertTimeline, SIGNAL(triggered(bool)), this, SLOT(slotInsertZoneToTimeline()));
1239 KAction *resizeStart = new KAction(KIcon(), i18n("Resize Item Start"), this);
1240 collection.addAction("resize_timeline_clip_start", resizeStart);
1241 resizeStart->setShortcut(Qt::Key_1);
1242 connect(resizeStart, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemStart()));
1244 KAction *resizeEnd = new KAction(KIcon(), i18n("Resize Item End"), this);
1245 collection.addAction("resize_timeline_clip_end", resizeEnd);
1246 resizeEnd->setShortcut(Qt::Key_2);
1247 connect(resizeEnd, SIGNAL(triggered(bool)), this, SLOT(slotResizeItemEnd()));
1249 KAction* monitorSeekBackward = new KAction(KIcon("media-seek-backward"), i18n("Rewind"), this);
1250 monitorSeekBackward->setShortcut(Qt::Key_J);
1251 collection.addAction("monitor_seek_backward", monitorSeekBackward);
1252 connect(monitorSeekBackward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewind()));
1254 KAction* monitorSeekBackwardOneFrame = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Frame"), this);
1255 monitorSeekBackwardOneFrame->setShortcut(Qt::Key_Left);
1256 collection.addAction("monitor_seek_backward-one-frame", monitorSeekBackwardOneFrame);
1257 connect(monitorSeekBackwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneFrame()));
1259 KAction* monitorSeekBackwardOneSecond = new KAction(KIcon("media-skip-backward"), i18n("Rewind 1 Second"), this);
1260 monitorSeekBackwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Left);
1261 collection.addAction("monitor_seek_backward-one-second", monitorSeekBackwardOneSecond);
1262 connect(monitorSeekBackwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotRewindOneSecond()));
1264 KAction* monitorSeekSnapBackward = new KAction(KIcon("media-seek-backward"), i18n("Go to Previous Snap Point"), this);
1265 monitorSeekSnapBackward->setShortcut(Qt::ALT + Qt::Key_Left);
1266 collection.addAction("monitor_seek_snap_backward", monitorSeekSnapBackward);
1267 connect(monitorSeekSnapBackward, SIGNAL(triggered(bool)), this, SLOT(slotSnapRewind()));
1269 KAction* monitorSeekForward = new KAction(KIcon("media-seek-forward"), i18n("Forward"), this);
1270 monitorSeekForward->setShortcut(Qt::Key_L);
1271 collection.addAction("monitor_seek_forward", monitorSeekForward);
1272 connect(monitorSeekForward, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForward()));
1274 KAction* clipStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Clip Start"), this);
1275 clipStart->setShortcut(Qt::Key_Home);
1276 collection.addAction("seek_clip_start", clipStart);
1277 connect(clipStart, SIGNAL(triggered(bool)), this, SLOT(slotClipStart()));
1279 KAction* clipEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Clip End"), this);
1280 clipEnd->setShortcut(Qt::Key_End);
1281 collection.addAction("seek_clip_end", clipEnd);
1282 connect(clipEnd, SIGNAL(triggered(bool)), this, SLOT(slotClipEnd()));
1284 KAction* zoneStart = new KAction(KIcon("media-seek-backward"), i18n("Go to Zone Start"), this);
1285 zoneStart->setShortcut(Qt::SHIFT + Qt::Key_I);
1286 collection.addAction("seek_zone_start", zoneStart);
1287 connect(zoneStart, SIGNAL(triggered(bool)), this, SLOT(slotZoneStart()));
1289 KAction* zoneEnd = new KAction(KIcon("media-seek-forward"), i18n("Go to Zone End"), this);
1290 zoneEnd->setShortcut(Qt::SHIFT + Qt::Key_O);
1291 collection.addAction("seek_zone_end", zoneEnd);
1292 connect(zoneEnd, SIGNAL(triggered(bool)), this, SLOT(slotZoneEnd()));
1294 KAction* projectStart = new KAction(KIcon("go-first"), i18n("Go to Project Start"), this);
1295 projectStart->setShortcut(Qt::CTRL + Qt::Key_Home);
1296 collection.addAction("seek_start", projectStart);
1297 connect(projectStart, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotStart()));
1299 KAction* projectEnd = new KAction(KIcon("go-last"), i18n("Go to Project End"), this);
1300 projectEnd->setShortcut(Qt::CTRL + Qt::Key_End);
1301 collection.addAction("seek_end", projectEnd);
1302 connect(projectEnd, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotEnd()));
1304 KAction* monitorSeekForwardOneFrame = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Frame"), this);
1305 monitorSeekForwardOneFrame->setShortcut(Qt::Key_Right);
1306 collection.addAction("monitor_seek_forward-one-frame", monitorSeekForwardOneFrame);
1307 connect(monitorSeekForwardOneFrame, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneFrame()));
1309 KAction* monitorSeekForwardOneSecond = new KAction(KIcon("media-skip-forward"), i18n("Forward 1 Second"), this);
1310 monitorSeekForwardOneSecond->setShortcut(Qt::SHIFT + Qt::Key_Right);
1311 collection.addAction("monitor_seek_forward-one-second", monitorSeekForwardOneSecond);
1312 connect(monitorSeekForwardOneSecond, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotForwardOneSecond()));
1314 KAction* monitorSeekSnapForward = new KAction(KIcon("media-seek-forward"), i18n("Go to Next Snap Point"), this);
1315 monitorSeekSnapForward->setShortcut(Qt::ALT + Qt::Key_Right);
1316 collection.addAction("monitor_seek_snap_forward", monitorSeekSnapForward);
1317 connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward()));
1319 KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this);
1320 deleteItem->setShortcut(Qt::Key_Delete);
1321 collection.addAction("delete_timeline_clip", deleteItem);
1322 connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem()));
1324 /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this);
1325 collection.addAction("change_clip_speed", editTimelineClipSpeed);
1326 editTimelineClipSpeed->setData("change_speed");
1327 connect(editTimelineClipSpeed, SIGNAL(triggered(bool)), this, SLOT(slotChangeClipSpeed()));*/
1329 KAction *stickTransition = collection.addAction("auto_transition");
1330 stickTransition->setData(QString("auto"));
1331 stickTransition->setCheckable(true);
1332 stickTransition->setEnabled(false);
1333 stickTransition->setText(i18n("Automatic Transition"));
1334 connect(stickTransition, SIGNAL(triggered(bool)), this, SLOT(slotAutoTransition()));
1336 KAction* groupClip = new KAction(KIcon("object-group"), i18n("Group Clips"), this);
1337 groupClip->setShortcut(Qt::CTRL + Qt::Key_G);
1338 collection.addAction("group_clip", groupClip);
1339 connect(groupClip, SIGNAL(triggered(bool)), this, SLOT(slotGroupClips()));
1341 KAction* ungroupClip = new KAction(KIcon("object-ungroup"), i18n("Ungroup Clips"), this);
1342 collection.addAction("ungroup_clip", ungroupClip);
1343 ungroupClip->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G);
1344 ungroupClip->setData("ungroup_clip");
1345 connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips()));
1347 KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this);
1348 collection.addAction("edit_item_duration", editItemDuration);
1349 connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration()));
1351 KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this);
1352 collection.addAction("clip_in_project_tree", clipInProjectTree);
1353 connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree()));
1355 /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this);
1356 collection.addAction("clip_to_project_tree", clipToProjectTree);
1357 connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/
1359 KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this);
1360 insertOvertwrite->setShortcut(Qt::Key_V);
1361 collection.addAction("overwrite_to_in_point", insertOvertwrite);
1362 connect(insertOvertwrite, SIGNAL(triggered(bool)), this, SLOT(slotInsertClipOverwrite()));
1364 KAction* selectTimelineClip = new KAction(KIcon("edit-select"), i18n("Select Clip"), this);
1365 selectTimelineClip->setShortcut(Qt::Key_Plus);
1366 collection.addAction("select_timeline_clip", selectTimelineClip);
1367 connect(selectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineClip()));
1369 KAction* deselectTimelineClip = new KAction(KIcon("edit-select"), i18n("Deselect Clip"), this);
1370 deselectTimelineClip->setShortcut(Qt::Key_Minus);
1371 collection.addAction("deselect_timeline_clip", deselectTimelineClip);
1372 connect(deselectTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineClip()));
1374 KAction* selectAddTimelineClip = new KAction(KIcon("edit-select"), i18n("Add Clip To Selection"), this);
1375 selectAddTimelineClip->setShortcut(Qt::ALT + Qt::Key_Plus);
1376 collection.addAction("select_add_timeline_clip", selectAddTimelineClip);
1377 connect(selectAddTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineClip()));
1379 KAction* selectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Select Transition"), this);
1380 selectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Plus);
1381 collection.addAction("select_timeline_transition", selectTimelineTransition);
1382 connect(selectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectTimelineTransition()));
1384 KAction* deselectTimelineTransition = new KAction(KIcon("edit-select"), i18n("Deselect Transition"), this);
1385 deselectTimelineTransition->setShortcut(Qt::SHIFT + Qt::Key_Minus);
1386 collection.addAction("deselect_timeline_transition", deselectTimelineTransition);
1387 connect(deselectTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotDeselectTimelineTransition()));
1389 KAction* selectAddTimelineTransition = new KAction(KIcon("edit-select"), i18n("Add Transition To Selection"), this);
1390 selectAddTimelineTransition->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Plus);
1391 collection.addAction("select_add_timeline_transition", selectAddTimelineTransition);
1392 connect(selectAddTimelineTransition, SIGNAL(triggered(bool)), this, SLOT(slotSelectAddTimelineTransition()));
1394 KAction* cutTimelineClip = new KAction(KIcon("edit-cut"), i18n("Cut Clip"), this);
1395 cutTimelineClip->setShortcut(Qt::SHIFT + Qt::Key_R);
1396 collection.addAction("cut_timeline_clip", cutTimelineClip);
1397 connect(cutTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotCutTimelineClip()));
1399 KAction* addClipMarker = new KAction(KIcon("bookmark-new"), i18n("Add Marker"), this);
1400 collection.addAction("add_clip_marker", addClipMarker);
1401 connect(addClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotAddClipMarker()));
1403 KAction* deleteClipMarker = new KAction(KIcon("edit-delete"), i18n("Delete Marker"), this);
1404 collection.addAction("delete_clip_marker", deleteClipMarker);
1405 connect(deleteClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotDeleteClipMarker()));
1407 KAction* deleteAllClipMarkers = new KAction(KIcon("edit-delete"), i18n("Delete All Markers"), this);
1408 collection.addAction("delete_all_clip_markers", deleteAllClipMarkers);
1409 connect(deleteAllClipMarkers, SIGNAL(triggered(bool)), this, SLOT(slotDeleteAllClipMarkers()));
1411 KAction* editClipMarker = new KAction(KIcon("document-properties"), i18n("Edit Marker"), this);
1412 editClipMarker->setData(QString("edit_marker"));
1413 collection.addAction("edit_clip_marker", editClipMarker);
1414 connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
1416 KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
1417 addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
1418 collection.addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
1419 connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
1421 KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
1422 collection.addAction("split_audio", splitAudio);
1423 connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
1425 KAction* audioOnly = new KAction(KIcon("document-new"), i18n("Audio Only"), this);
1426 collection.addAction("clip_audio_only", audioOnly);
1427 audioOnly->setData("clip_audio_only");
1428 audioOnly->setCheckable(true);
1430 KAction* videoOnly = new KAction(KIcon("document-new"), i18n("Video Only"), this);
1431 collection.addAction("clip_video_only", videoOnly);
1432 videoOnly->setData("clip_video_only");
1433 videoOnly->setCheckable(true);
1435 KAction* audioAndVideo = new KAction(KIcon("document-new"), i18n("Audio and Video"), this);
1436 collection.addAction("clip_audio_and_video", audioAndVideo);
1437 audioAndVideo->setData("clip_audio_and_video");
1438 audioAndVideo->setCheckable(true);
1440 m_clipTypeGroup = new QActionGroup(this);
1441 m_clipTypeGroup->addAction(audioOnly);
1442 m_clipTypeGroup->addAction(videoOnly);
1443 m_clipTypeGroup->addAction(audioAndVideo);
1444 connect(m_clipTypeGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotUpdateClipType(QAction *)));
1445 m_clipTypeGroup->setEnabled(false);
1447 KAction *insertSpace = new KAction(KIcon(), i18n("Insert Space"), this);
1448 collection.addAction("insert_space", insertSpace);
1449 connect(insertSpace, SIGNAL(triggered()), this, SLOT(slotInsertSpace()));
1451 KAction *removeSpace = new KAction(KIcon(), i18n("Remove Space"), this);
1452 collection.addAction("delete_space", removeSpace);
1453 connect(removeSpace, SIGNAL(triggered()), this, SLOT(slotRemoveSpace()));
1455 KAction *insertTrack = new KAction(KIcon(), i18n("Insert Track"), this);
1456 collection.addAction("insert_track", insertTrack);
1457 connect(insertTrack, SIGNAL(triggered()), this, SLOT(slotInsertTrack()));
1459 KAction *deleteTrack = new KAction(KIcon(), i18n("Delete Track"), this);
1460 collection.addAction("delete_track", deleteTrack);
1461 connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
1463 KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this);
1464 collection.addAction("config_tracks", configTracks);
1465 connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack()));
1467 KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this);
1468 collection.addAction("add_guide", addGuide);
1469 connect(addGuide, SIGNAL(triggered()), this, SLOT(slotAddGuide()));
1471 QAction *delGuide = new KAction(KIcon("edit-delete"), i18n("Delete Guide"), this);
1472 collection.addAction("delete_guide", delGuide);
1473 connect(delGuide, SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
1475 QAction *editGuide = new KAction(KIcon("document-properties"), i18n("Edit Guide"), this);
1476 collection.addAction("edit_guide", editGuide);
1477 connect(editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
1479 QAction *delAllGuides = new KAction(KIcon("edit-delete"), i18n("Delete All Guides"), this);
1480 collection.addAction("delete_all_guides", delAllGuides);
1481 connect(delAllGuides, SIGNAL(triggered()), this, SLOT(slotDeleteAllGuides()));
1483 QAction *pasteEffects = new KAction(KIcon("edit-paste"), i18n("Paste Effects"), this);
1484 collection.addAction("paste_effects", pasteEffects);
1485 pasteEffects->setData("paste_effects");
1486 connect(pasteEffects , SIGNAL(triggered()), this, SLOT(slotPasteEffects()));
1488 QAction *showTimeline = new KAction(i18n("Show Timeline"), this);
1489 collection.addAction("show_timeline", showTimeline);
1490 showTimeline->setCheckable(true);
1491 showTimeline->setChecked(true);
1492 connect(showTimeline, SIGNAL(triggered(bool)), this, SLOT(slotShowTimeline(bool)));
1494 QAction *showTitleBar = new KAction(i18n("Show Title Bars"), this);
1495 collection.addAction("show_titlebars", showTitleBar);
1496 showTitleBar->setCheckable(true);
1497 connect(showTitleBar, SIGNAL(triggered(bool)), this, SLOT(slotShowTitleBars(bool)));
1498 showTitleBar->setChecked(KdenliveSettings::showtitlebars());
1499 slotShowTitleBars(KdenliveSettings::showtitlebars());
1502 //const QByteArray state = layoutGroup.readEntry("layout1", QByteArray());
1504 /*QAction *maxCurrent = new KAction(i18n("Maximize Current Widget"), this);
1505 collection.addAction("maximize_current", maxCurrent);
1506 maxCurrent->setCheckable(true);
1507 maxCurrent->setChecked(false);
1508 connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/
1510 m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection);
1511 KStandardAction::quit(this, SLOT(close()), collection);
1512 KStandardAction::open(this, SLOT(openFile()), collection);
1513 m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection);
1514 KStandardAction::saveAs(this, SLOT(saveFileAs()), collection);
1515 KStandardAction::openNew(this, SLOT(newFile()), collection);
1516 // TODO: make the following connection to slotEditKeys work
1517 KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection);
1518 KStandardAction::preferences(this, SLOT(slotPreferences()), collection);
1519 KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection);
1520 KStandardAction::copy(this, SLOT(slotCopy()), collection);
1521 KStandardAction::paste(this, SLOT(slotPaste()), collection);
1522 KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection);
1524 KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection);
1525 undo->setEnabled(false);
1526 connect(m_commandStack, SIGNAL(canUndoChanged(bool)), undo, SLOT(setEnabled(bool)));
1528 KAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), collection);
1529 redo->setEnabled(false);
1530 connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool)));
1533 //TODO: Add status tooltip to actions ?
1534 connect(collection, SIGNAL(actionHovered(QAction*)),
1535 this, SLOT(slotDisplayActionMessage(QAction*)));*/
1538 QAction *addClip = new KAction(KIcon("kdenlive-add-clip"), i18n("Add Clip"), this);
1539 collection.addAction("add_clip", addClip);
1540 connect(addClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddClip()));
1542 QAction *addColorClip = new KAction(KIcon("kdenlive-add-color-clip"), i18n("Add Color Clip"), this);
1543 collection.addAction("add_color_clip", addColorClip);
1544 connect(addColorClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddColorClip()));
1546 QAction *addSlideClip = new KAction(KIcon("kdenlive-add-slide-clip"), i18n("Add Slideshow Clip"), this);
1547 collection.addAction("add_slide_clip", addSlideClip);
1548 connect(addSlideClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddSlideshowClip()));
1550 QAction *addTitleClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Title Clip"), this);
1551 collection.addAction("add_text_clip", addTitleClip);
1552 connect(addTitleClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleClip()));
1554 QAction *addTitleTemplateClip = new KAction(KIcon("kdenlive-add-text-clip"), i18n("Add Template Title"), this);
1555 collection.addAction("add_text_template_clip", addTitleTemplateClip);
1556 connect(addTitleTemplateClip , SIGNAL(triggered()), m_projectList, SLOT(slotAddTitleTemplateClip()));
1558 QAction *addFolderButton = new KAction(KIcon("folder-new"), i18n("Create Folder"), this);
1559 collection.addAction("add_folder", addFolderButton);
1560 connect(addFolderButton , SIGNAL(triggered()), m_projectList, SLOT(slotAddFolder()));
1562 QAction *clipProperties = new KAction(KIcon("document-edit"), i18n("Clip Properties"), this);
1563 collection.addAction("clip_properties", clipProperties);
1564 clipProperties->setData("clip_properties");
1565 connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
1566 clipProperties->setEnabled(false);
1568 QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
1569 collection.addAction("edit_clip", openClip);
1570 openClip->setData("edit_clip");
1571 connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
1572 openClip->setEnabled(false);
1574 QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
1575 collection.addAction("delete_clip", deleteClip);
1576 deleteClip->setData("delete_clip");
1577 connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
1578 deleteClip->setEnabled(false);
1580 QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
1581 collection.addAction("reload_clip", reloadClip);
1582 reloadClip->setData("reload_clip");
1583 connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
1584 reloadClip->setEnabled(false);
1586 QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
1587 collection.addAction("stopmotion", stopMotion);
1588 connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
1590 QMenu *addClips = new QMenu();
1591 addClips->addAction(addClip);
1592 addClips->addAction(addColorClip);
1593 addClips->addAction(addSlideClip);
1594 addClips->addAction(addTitleClip);
1595 addClips->addAction(addTitleTemplateClip);
1596 addClips->addAction(addFolderButton);
1598 addClips->addAction(reloadClip);
1599 addClips->addAction(clipProperties);
1600 addClips->addAction(openClip);
1601 addClips->addAction(deleteClip);
1602 m_projectList->setupMenu(addClips, addClip);
1604 // Setup effects and transitions actions.
1605 m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent());
1606 //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection);
1607 KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection);
1608 m_transitions = new KAction*[transitions.count()];
1609 for (int i = 0; i < transitions.count(); i++) {
1610 QStringList effectInfo = transitions.effectIdInfo(i);
1611 m_transitions[i] = new KAction(effectInfo.at(0), this);
1612 m_transitions[i]->setData(effectInfo);
1613 m_transitions[i]->setIconVisibleInMenu(false);
1614 QString id = effectInfo.at(2);
1615 if (id.isEmpty()) id = effectInfo.at(1);
1616 transitionActions->addAction("transition_" + id, m_transitions[i]);
1618 //m_effectsActionCollection->readSettings();
1620 //connect(collection, SIGNAL( clearStatusText() ),
1621 //statusBar(), SLOT( clear() ) );
1624 void MainWindow::slotDisplayActionMessage(QAction *a)
1626 statusBar()->showMessage(a->data().toString(), 3000);
1629 void MainWindow::loadLayouts()
1631 QMenu *saveLayout = (QMenu*)(factory()->container("layout_save_as", this));
1632 if (m_loadLayout == NULL || saveLayout == NULL) return;
1633 KSharedConfigPtr config = KGlobal::config();
1634 KConfigGroup layoutGroup(config, "Layouts");
1635 QStringList entries = layoutGroup.keyList();
1636 QList<QAction *> loadActions = m_loadLayout->actions();
1637 QList<QAction *> saveActions = saveLayout->actions();
1638 for (int i = 1; i < 5; i++) {
1639 // Rename the layouts actions
1640 foreach(const QString & key, entries) {
1641 if (key.endsWith(QString("_%1").arg(i))) {
1642 // Found previously saved layout
1643 QString layoutName = key.section("_", 0, -2);
1644 for (int j = 0; j < loadActions.count(); j++) {
1645 if (loadActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1646 loadActions[j]->setText(layoutName);
1647 loadActions[j]->setData(key);
1651 for (int j = 0; j < saveActions.count(); j++) {
1652 if (saveActions.at(j)->data().toString().endsWith("_" + QString::number(i))) {
1653 saveActions[j]->setText(i18n("Save as %1").arg(layoutName));
1654 saveActions[j]->setData(key);
1663 void MainWindow::slotLoadLayout(QAction *action)
1665 if (!action) return;
1666 QString layoutId = action->data().toString();
1667 if (layoutId.isEmpty()) return;
1668 KSharedConfigPtr config = KGlobal::config();
1669 KConfigGroup layouts(config, "Layouts");
1670 //QByteArray geom = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1671 QByteArray state = QByteArray::fromBase64(layouts.readEntry(layoutId).toAscii());
1672 //restoreGeometry(geom);
1673 restoreState(state);
1676 void MainWindow::slotSaveLayout(QAction *action)
1678 QString originallayoutName = action->data().toString();
1679 int layoutId = originallayoutName.section('_', -1).toInt();
1681 QString layoutName = QInputDialog::getText(this, i18n("Save Layout"), i18n("Layout name:"), QLineEdit::Normal, originallayoutName.section('_', 0, -2));
1682 if (layoutName.isEmpty()) return;
1683 KSharedConfigPtr config = KGlobal::config();
1684 KConfigGroup layouts(config, "Layouts");
1685 layouts.deleteEntry(originallayoutName);
1687 QByteArray st = saveState();
1688 layoutName.append("_" + QString::number(layoutId));
1689 layouts.writeEntry(layoutName, st.toBase64());
1693 void MainWindow::saveOptions()
1695 KdenliveSettings::self()->writeConfig();
1696 KSharedConfigPtr config = KGlobal::config();
1697 m_fileOpenRecent->saveEntries(KConfigGroup(config, "Recent Files"));
1698 KConfigGroup treecolumns(config, "Project Tree");
1699 treecolumns.writeEntry("columns", m_projectList->headerInfo());
1703 void MainWindow::readOptions()
1705 KSharedConfigPtr config = KGlobal::config();
1706 m_fileOpenRecent->loadEntries(KConfigGroup(config, "Recent Files"));
1707 KConfigGroup initialGroup(config, "version");
1708 bool upgrade = false;
1709 if (initialGroup.exists()) {
1710 if (initialGroup.readEntry("version", QString()).section(' ', 0, 0) != QString(version).section(' ', 0, 0)) {
1714 if (initialGroup.readEntry("version") == "0.7") {
1715 //Add new settings from 0.7.1
1716 if (KdenliveSettings::defaultprojectfolder().isEmpty()) {
1717 QString path = QDir::homePath() + "/kdenlive";
1718 if (KStandardDirs::makeDir(path) == false) {
1719 kDebug() << "/// ERROR CREATING PROJECT FOLDER: " << path;
1720 } else KdenliveSettings::setDefaultprojectfolder(path);
1726 if (!initialGroup.exists() || upgrade) {
1727 // this is our first run, show Wizard
1728 Wizard *w = new Wizard(upgrade, this);
1729 if (w->exec() == QDialog::Accepted && w->isOk()) {
1730 w->adjustSettings();
1731 initialGroup.writeEntry("version", version);
1737 KConfigGroup treecolumns(config, "Project Tree");
1738 const QByteArray state = treecolumns.readEntry("columns", QByteArray());
1739 if (!state.isEmpty())
1740 m_projectList->setHeaderInfo(state);
1743 void MainWindow::slotRunWizard()
1745 Wizard *w = new Wizard(false, this);
1746 if (w->exec() == QDialog::Accepted && w->isOk()) {
1747 w->adjustSettings();
1752 void MainWindow::newFile(bool showProjectSettings, bool force)
1754 if (!m_timelineArea->isEnabled() && !force)
1756 m_fileRevert->setEnabled(false);
1757 QString profileName = KdenliveSettings::default_profile();
1758 KUrl projectFolder = KdenliveSettings::defaultprojectfolder();
1759 QMap <QString, QString> documentProperties;
1760 QPoint projectTracks(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks());
1761 if (!showProjectSettings) {
1762 // set up default properties
1763 documentProperties.insert("enableproxy", QString::number((int) KdenliveSettings::enableproxy()));
1764 documentProperties.insert("generateproxy", QString::number((int) KdenliveSettings::generateproxy()));
1765 documentProperties.insert("proxyminsize", QString::number(KdenliveSettings::proxyminsize()));
1766 documentProperties.insert("proxyparams", KdenliveSettings::proxyparams());
1767 documentProperties.insert("proxyextension", KdenliveSettings::proxyextension());
1768 documentProperties.insert("generateimageproxy", QString::number((int) KdenliveSettings::generateimageproxy()));
1769 documentProperties.insert("proxyimageminsize", QString::number(KdenliveSettings::proxyimageminsize()));
1770 if (!KdenliveSettings::activatetabs())
1771 if (!closeCurrentDocument())
1774 ProjectSettings *w = new ProjectSettings(NULL, QStringList(), projectTracks.x(), projectTracks.y(), KdenliveSettings::defaultprojectfolder(), false, true, this);
1775 if (w->exec() != QDialog::Accepted)
1777 if (!KdenliveSettings::activatetabs())
1778 if (!closeCurrentDocument())
1780 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs())
1781 slotSwitchVideoThumbs();
1782 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs())
1783 slotSwitchAudioThumbs();
1784 profileName = w->selectedProfile();
1785 projectFolder = w->selectedFolder();
1786 projectTracks = w->tracks();
1787 documentProperties.insert("enableproxy", QString::number((int) w->useProxy()));
1788 documentProperties.insert("generateproxy", QString::number((int) w->generateProxy()));
1789 documentProperties.insert("proxyminsize", QString::number(w->proxyMinSize()));
1790 documentProperties.insert("proxyparams", w->proxyParams());
1791 documentProperties.insert("proxyextension", w->proxyExtension());
1792 documentProperties.insert("generateimageproxy", QString::number((int) w->generateImageProxy()));
1793 documentProperties.insert("proxyimageminsize", QString::number(w->proxyImageMinSize()));
1796 m_timelineArea->setEnabled(true);
1797 m_projectList->setEnabled(true);
1799 KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
1800 doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
1802 TrackView *trackView = new TrackView(doc, &ok, this);
1803 m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description());
1806 //m_timelineArea->setEnabled(false);
1807 //m_projectList->setEnabled(false);
1811 if (m_timelineArea->count() == 1) {
1812 connectDocumentInfo(doc);
1813 connectDocument(trackView, doc);
1815 m_timelineArea->setTabBarHidden(false);
1816 m_monitorManager->activateMonitor("clip");
1817 m_closeAction->setEnabled(m_timelineArea->count() > 1);
1820 void MainWindow::activateDocument()
1822 if (m_timelineArea->currentWidget() == NULL || !m_timelineArea->isEnabled()) return;
1823 TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
1824 KdenliveDoc *currentDoc = currentTab->document();
1825 connectDocumentInfo(currentDoc);
1826 connectDocument(currentTab, currentDoc);
1829 bool MainWindow::closeCurrentDocument(bool saveChanges)
1831 QWidget *w = m_timelineArea->currentWidget();
1832 if (!w) return true;
1833 // closing current document
1834 int ix = m_timelineArea->currentIndex() + 1;
1835 if (ix == m_timelineArea->count()) ix = 0;
1836 m_timelineArea->setCurrentIndex(ix);
1837 TrackView *tabToClose = (TrackView *) w;
1838 KdenliveDoc *docToClose = tabToClose->document();
1839 if (docToClose && docToClose->isModified() && saveChanges) {
1841 if (m_activeDocument->url().fileName().isEmpty())
1842 message = i18n("Save changes to document?");
1844 message = i18n("The project <b>\"%1\"</b> has been changed.\nDo you want to save your changes?").arg(m_activeDocument->url().fileName());
1845 switch (KMessageBox::warningYesNoCancel(this, message)) {
1846 case KMessageBox::Yes :
1847 // save document here. If saving fails, return false;
1848 if (saveFile() == false) return false;
1850 case KMessageBox::Cancel :
1857 m_clipMonitor->slotSetXml(NULL);
1858 m_timelineArea->removeTab(m_timelineArea->indexOf(w));
1859 if (m_timelineArea->count() == 1) {
1860 m_timelineArea->setTabBarHidden(true);
1861 m_closeAction->setEnabled(false);
1863 if (docToClose == m_activeDocument) {
1864 delete m_activeDocument;
1865 m_activeDocument = NULL;
1866 m_effectStack->clear();
1867 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
1871 if (w == m_activeTimeline) {
1872 delete m_activeTimeline;
1873 m_activeTimeline = NULL;
1880 bool MainWindow::saveFileAs(const QString &outputFileName)
1882 QString currentSceneList;
1883 m_monitorManager->stopActiveMonitor();
1885 if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
1888 // Save timeline thumbnails
1889 m_activeTimeline->projectView()->saveThumbnails();
1890 m_activeDocument->setUrl(KUrl(outputFileName));
1891 if (m_activeDocument->m_autosave == NULL) {
1892 m_activeDocument->m_autosave = new KAutoSaveFile(KUrl(outputFileName), this);
1893 } else m_activeDocument->m_autosave->setManagedFile(KUrl(outputFileName));
1894 setCaption(m_activeDocument->description());
1895 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
1896 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), m_activeDocument->url().path());
1897 m_activeDocument->setModified(false);
1898 m_fileOpenRecent->addUrl(KUrl(outputFileName));
1899 m_fileRevert->setEnabled(true);
1903 bool MainWindow::saveFileAs()
1905 QString outputFile = KFileDialog::getSaveFileName(m_activeDocument->projectFolder(), getMimeType());
1906 if (outputFile.isEmpty()) {
1909 if (QFile::exists(outputFile)) {
1910 // Show the file dialog again if the user does not want to overwrite the file
1911 if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", outputFile)) == KMessageBox::No)
1912 return saveFileAs();
1914 return saveFileAs(outputFile);
1917 bool MainWindow::saveFile()
1919 if (!m_activeDocument) return true;
1920 if (m_activeDocument->url().isEmpty()) {
1921 return saveFileAs();
1923 bool result = saveFileAs(m_activeDocument->url().path());
1924 m_activeDocument->m_autosave->resize(0);
1929 void MainWindow::openFile()
1931 if (!m_startUrl.isEmpty()) {
1932 openFile(m_startUrl);
1933 m_startUrl = KUrl();
1936 KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType());
1937 if (url.isEmpty()) return;
1938 m_fileOpenRecent->addUrl(url);
1942 void MainWindow::openLastFile()
1944 KSharedConfigPtr config = KGlobal::config();
1945 KUrl::List urls = m_fileOpenRecent->urls();
1946 //WARNING: this is buggy, we get a random url, not the last one. Bug in KRecentFileAction?
1947 if (urls.isEmpty()) newFile(false);
1948 else openFile(urls.last());
1951 void MainWindow::openFile(const KUrl &url)
1953 // Check if the document is already opened
1954 const int ct = m_timelineArea->count();
1955 bool isOpened = false;
1957 for (i = 0; i < ct; i++) {
1958 TrackView *tab = (TrackView *) m_timelineArea->widget(i);
1959 KdenliveDoc *doc = tab->document();
1960 if (doc->url() == url) {
1966 m_timelineArea->setCurrentIndex(i);
1970 if (!KdenliveSettings::activatetabs()) if (!closeCurrentDocument()) return;
1972 // Check for backup file
1973 QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
1974 if (!staleFiles.isEmpty()) {
1975 if (KMessageBox::questionYesNo(this,
1976 i18n("Auto-saved files exist. Do you want to recover them now?"),
1977 i18n("File Recovery"),
1978 KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) {
1979 recoverFiles(staleFiles);
1982 // remove the stale files
1983 foreach(KAutoSaveFile * stale, staleFiles) {
1984 stale->open(QIODevice::ReadWrite);
1989 m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
1990 m_messageLabel->repaint();
1991 doOpenFile(url, NULL);
1994 void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
1996 if (!m_timelineArea->isEnabled()) return;
1997 m_fileRevert->setEnabled(true);
1999 // Recreate stopmotion widget on document change
2001 delete m_stopmotion;
2002 m_stopmotion = NULL;
2005 KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
2006 progressDialog.setAllowCancel(false);
2007 progressDialog.progressBar()->setMaximum(4);
2008 progressDialog.show();
2009 progressDialog.progressBar()->setValue(0);
2010 qApp->processEvents();
2012 KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
2014 progressDialog.progressBar()->setValue(1);
2015 progressDialog.progressBar()->setMaximum(4);
2016 progressDialog.setLabelText(i18n("Loading project"));
2017 qApp->processEvents();
2019 if (stale == NULL) {
2020 stale = new KAutoSaveFile(url, doc);
2021 doc->m_autosave = stale;
2023 doc->m_autosave = stale;
2024 doc->setUrl(stale->managedFile());
2025 doc->setModified(true);
2026 stale->setParent(doc);
2028 connectDocumentInfo(doc);
2030 progressDialog.progressBar()->setValue(2);
2031 qApp->processEvents();
2034 TrackView *trackView = new TrackView(doc, &ok, this);
2036 progressDialog.progressBar()->setValue(3);
2037 qApp->processEvents();
2039 m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
2041 m_timelineArea->setEnabled(false);
2042 m_projectList->setEnabled(false);
2043 KMessageBox::sorry(this, i18n("Cannot open file %1.\nProject is corrupted.", url.path()));
2044 slotGotProgressInfo(QString(), -1);
2045 newFile(false, true);
2048 m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
2049 trackView->setDuration(trackView->duration());
2050 trackView->projectView()->initCursorPos(m_projectMonitor->render->seekPosition().frames(doc->fps()));
2052 if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false);
2053 slotGotProgressInfo(QString(), -1);
2054 m_projectMonitor->adjustRulerSize(trackView->duration());
2055 m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
2056 m_clipMonitor->refreshMonitor(true);
2058 progressDialog.progressBar()->setValue(4);
2061 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
2063 foreach(KAutoSaveFile * stale, staleFiles) {
2064 /*if (!stale->open(QIODevice::QIODevice::ReadOnly)) {
2065 // show an error message; we could not steal the lockfile
2066 // maybe another application got to the file before us?
2070 kDebug() << "// OPENING RECOVERY: " << stale->fileName() << "\nMANAGED: " << stale->managedFile().path();
2071 // the stalefiles also contain ".lock" files so we must ignore them... bug in KAutoSaveFile?
2072 if (!stale->fileName().endsWith(".lock")) doOpenFile(KUrl(stale->fileName()), stale);
2073 else KIO::NetAccess::del(KUrl(stale->fileName()), this);
2077 void MainWindow::parseProfiles(const QString &mltPath)
2079 //KdenliveSettings::setDefaulttmpfolder();
2080 if (!mltPath.isEmpty()) {
2081 KdenliveSettings::setMltpath(mltPath + "/share/mlt/profiles/");
2082 KdenliveSettings::setRendererpath(mltPath + "/bin/melt");
2085 if (KdenliveSettings::mltpath().isEmpty())
2086 KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
2088 if (KdenliveSettings::rendererpath().isEmpty() || KdenliveSettings::rendererpath().endsWith("inigo")) {
2089 QString meltPath = QString(MLT_PREFIX) + QString("/bin/melt");
2090 if (!QFile::exists(meltPath))
2091 meltPath = KStandardDirs::findExe("melt");
2092 KdenliveSettings::setRendererpath(meltPath);
2095 if (KdenliveSettings::rendererpath().isEmpty()) {
2096 // Cannot find the MLT melt renderer, ask for location
2097 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of MLT)"), this);
2098 if (getUrl->exec() == QDialog::Rejected) {
2101 KUrl rendererPath = getUrl->selectedUrl();
2103 if (rendererPath.isEmpty()) ::exit(0);
2104 KdenliveSettings::setRendererpath(rendererPath.path());
2107 QStringList profilesFilter;
2108 profilesFilter << "*";
2109 QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2110 if (profilesList.isEmpty()) {
2111 // Cannot find MLT path, try finding melt
2112 QString profilePath = KdenliveSettings::rendererpath();
2113 if (!profilePath.isEmpty()) {
2114 profilePath = profilePath.section('/', 0, -3);
2115 KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/");
2116 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2118 if (profilesList.isEmpty()) {
2119 // Cannot find the MLT profiles, ask for location
2120 KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this);
2121 getUrl->fileDialog()->setMode(KFile::Directory);
2122 if (getUrl->exec() == QDialog::Rejected) {
2125 KUrl mltPath = getUrl->selectedUrl();
2127 if (mltPath.isEmpty()) ::exit(0);
2128 KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash));
2129 profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
2133 kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath();
2135 // Parse again MLT profiles to build a list of available video formats
2136 if (profilesList.isEmpty()) parseProfiles();
2140 void MainWindow::slotEditProfiles()
2142 ProfilesDialog *w = new ProfilesDialog;
2143 if (w->exec() == QDialog::Accepted) {
2144 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2145 if (d) d->checkProfile();
2150 void MainWindow::slotDetectAudioDriver()
2152 /* WARNING: do not use this method because sometimes detects wrong driver (pulse instead of alsa),
2153 leading to no audio output, see bug #934 */
2155 //decide which audio driver is really best, in some cases SDL is wrong
2156 if (KdenliveSettings::audiodrivername().isEmpty()) {
2158 KProcess readProcess;
2159 //PulseAudio needs to be selected if it exists, the ALSA pulse pcm device is not fast enough.
2160 if (!KStandardDirs::findExe("pactl").isEmpty()) {
2161 readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
2162 readProcess.setProgram("pactl", QStringList() << "stat");
2163 readProcess.execute(2000); // Kill it after 2 seconds
2165 QString result = QString(readProcess.readAllStandardOutput());
2166 kDebug() << "// / / / / / READING PACTL: ";
2168 if (!result.isEmpty()) {
2170 kDebug() << "// / / / / PULSEAUDIO DETECTED";
2174 KdenliveSettings::setAutoaudiodrivername(driver);
2178 void MainWindow::slotEditProjectSettings()
2180 QPoint p = m_activeDocument->getTracksCount();
2181 ProjectSettings *w = new ProjectSettings(m_projectList, m_activeTimeline->projectView()->extractTransitionsLumas(), p.x(), p.y(), m_activeDocument->projectFolder().path(), true, !m_activeDocument->isModified(), this);
2183 if (w->exec() == QDialog::Accepted) {
2184 QString profile = w->selectedProfile();
2185 m_activeDocument->setProjectFolder(w->selectedFolder());
2187 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2189 if (m_renderWidget) m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2190 if (KdenliveSettings::videothumbnails() != w->enableVideoThumbs()) slotSwitchVideoThumbs();
2191 if (KdenliveSettings::audiothumbnails() != w->enableAudioThumbs()) slotSwitchAudioThumbs();
2192 if (m_activeDocument->profilePath() != profile) slotUpdateProjectProfile(profile);
2193 if (m_activeDocument->getDocumentProperty("proxyparams") != w->proxyParams()) {
2194 m_activeDocument->setModified();
2195 m_activeDocument->setDocumentProperty("proxyparams", w->proxyParams());
2196 if (m_activeDocument->clipManager()->clipsCount() > 0 && KMessageBox::questionYesNo(this, i18n("You have changed the proxy parameters. Do you want to recreate all proxy clips for this project?")) == KMessageBox::Yes) {
2197 //TODO: rebuild all proxies
2198 //m_projectList->rebuildProxies();
2201 if (m_activeDocument->getDocumentProperty("proxyextension") != w->proxyExtension()) {
2202 m_activeDocument->setModified();
2203 m_activeDocument->setDocumentProperty("proxyextension", w->proxyExtension());
2205 if (m_activeDocument->getDocumentProperty("generateproxy") != QString::number((int) w->generateProxy())) {
2206 m_activeDocument->setModified();
2207 m_activeDocument->setDocumentProperty("generateproxy", QString::number((int) w->generateProxy()));
2209 if (m_activeDocument->getDocumentProperty("proxyminsize") != QString::number(w->proxyMinSize())) {
2210 m_activeDocument->setModified();
2211 m_activeDocument->setDocumentProperty("proxyminsize", QString::number(w->proxyMinSize()));
2213 if (m_activeDocument->getDocumentProperty("generateimageproxy") != QString::number((int) w->generateImageProxy())) {
2214 m_activeDocument->setModified();
2215 m_activeDocument->setDocumentProperty("generateimageproxy", QString::number((int) w->generateImageProxy()));
2217 if (m_activeDocument->getDocumentProperty("proxyimageminsize") != QString::number(w->proxyImageMinSize())) {
2218 m_activeDocument->setModified();
2219 m_activeDocument->setDocumentProperty("proxyimageminsize", QString::number(w->proxyImageMinSize()));
2221 if (QString::number((int) w->useProxy()) != m_activeDocument->getDocumentProperty("enableproxy")) {
2222 m_activeDocument->setDocumentProperty("enableproxy", QString::number((int) w->useProxy()));
2223 m_activeDocument->setModified();
2224 slotUpdateProxySettings();
2230 void MainWindow::slotUpdateProjectProfile(const QString &profile)
2232 double dar = m_activeDocument->dar();
2234 // Recreate the stopmotion widget if profile changes
2236 delete m_stopmotion;
2237 m_stopmotion = NULL;
2240 // Deselect current effect / transition
2241 m_effectStack->slotClipItemSelected(NULL, 0);
2242 m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
2243 m_clipMonitor->slotSetXml(NULL);
2244 bool updateFps = m_activeDocument->setProfilePath(profile);
2245 KdenliveSettings::setCurrent_profile(profile);
2246 KdenliveSettings::setProject_fps(m_activeDocument->fps());
2247 setCaption(m_activeDocument->description(), m_activeDocument->isModified());
2249 m_activeDocument->clipManager()->clearUnusedProducers();
2250 m_monitorManager->resetProfiles(m_activeDocument->timecode());
2251 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2252 m_effectStack->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode());
2253 m_projectList->updateProjectFormat(m_activeDocument->timecode());
2254 if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());
2255 m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description());
2256 //m_activeDocument->clipManager()->resetProducersList(m_projectMonitor->render->producersList());
2257 if (dar != m_activeDocument->dar()) m_projectList->reloadClipThumbnails();
2258 if (updateFps) m_activeTimeline->updateProjectFps();
2259 m_activeDocument->setModified(true);
2260 m_commandStack->activeStack()->clear();
2261 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2262 slotUpdateMousePosition(0);
2263 // We need to desactivate & reactivate monitors to get a refresh
2264 //m_monitorManager->switchMonitors();
2268 void MainWindow::slotRenderProject()
2270 if (!m_renderWidget) {
2271 QString projectfolder = m_activeDocument ? m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) : KdenliveSettings::defaultprojectfolder();
2272 m_renderWidget = new RenderWidget(projectfolder, m_projectList->useProxy(), this);
2273 connect(m_renderWidget, SIGNAL(shutdown()), this, SLOT(slotShutdown()));
2274 connect(m_renderWidget, SIGNAL(selectedRenderProfile(QMap <QString, QString>)), this, SLOT(slotSetDocumentRenderProfile(QMap <QString, QString>)));
2275 connect(m_renderWidget, SIGNAL(prepareRenderingData(bool, bool, const QString&)), this, SLOT(slotPrepareRendering(bool, bool, const QString&)));
2276 connect(m_renderWidget, SIGNAL(abortProcess(const QString &)), this, SIGNAL(abortRenderJob(const QString &)));
2277 connect(m_renderWidget, SIGNAL(openDvdWizard(const QString &, const QString &)), this, SLOT(slotDvdWizard(const QString &, const QString &)));
2278 if (m_activeDocument) {
2279 m_renderWidget->setProfile(m_activeDocument->mltProfile());
2280 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2281 m_renderWidget->setDocumentPath(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2282 m_renderWidget->setRenderProfile(m_activeDocument->getRenderProperties());
2285 slotCheckRenderStatus();
2286 m_renderWidget->show();
2287 m_renderWidget->showNormal();
2289 // What are the following lines supposed to do?
2290 //m_activeTimeline->tracksNumber();
2291 //m_renderWidget->enableAudio(false);
2292 //m_renderWidget->export_audio;
2295 void MainWindow::slotCheckRenderStatus()
2297 // Make sure there are no missing clips
2299 m_renderWidget->missingClips(m_projectList->hasMissingClips());
2302 void MainWindow::setRenderingProgress(const QString &url, int progress)
2305 m_renderWidget->setRenderJob(url, progress);
2308 void MainWindow::setRenderingFinished(const QString &url, int status, const QString &error)
2311 m_renderWidget->setRenderStatus(url, status, error);
2314 void MainWindow::slotCleanProject()
2316 if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
2317 m_projectList->cleanup();
2320 void MainWindow::slotUpdateMousePosition(int pos)
2322 if (m_activeDocument)
2323 switch (m_timecodeFormat->currentIndex()) {
2325 statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
2328 statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
2332 void MainWindow::slotUpdateDocumentState(bool modified)
2334 if (!m_activeDocument) return;
2335 setCaption(m_activeDocument->description(), modified);
2336 m_saveAction->setEnabled(modified);
2338 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Link));
2339 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("document-save"));
2341 m_timelineArea->setTabTextColor(m_timelineArea->currentIndex(), palette().color(QPalette::Text));
2342 m_timelineArea->setTabIcon(m_timelineArea->currentIndex(), KIcon("kdenlive"));
2346 void MainWindow::connectDocumentInfo(KdenliveDoc *doc)
2348 if (m_activeDocument) {
2349 if (m_activeDocument == doc) return;
2350 disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2352 connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int)));
2355 void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
2357 //m_projectMonitor->stop();
2358 m_closeAction->setEnabled(m_timelineArea->count() > 1);
2359 kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////";
2360 if (m_activeDocument) {
2361 if (m_activeDocument == doc) return;
2362 if (m_activeTimeline) {
2363 disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int)));
2364 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeTimeline, SLOT(slotSetZone(QPoint)));
2365 disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int)));
2366 disconnect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2367 disconnect(m_notesWidget, SIGNAL(textChanged()), m_activeDocument, SLOT(setModified()));
2368 disconnect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_activeDocument, SLOT(setModified()));
2369 disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified()));
2370 disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2372 disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), m_activeDocument, SLOT(checkProjectClips()));
2374 disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2375 disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2376 disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2377 disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2378 disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2379 disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2380 disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
2381 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2382 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2383 disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2384 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2385 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2386 disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2387 disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2388 disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2389 disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2390 disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2391 disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2392 disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2393 disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2394 disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2395 disconnect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2396 disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2397 disconnect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), m_activeTimeline->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2398 disconnect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), m_activeTimeline->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2399 disconnect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), m_activeTimeline->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2400 disconnect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2401 disconnect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2402 disconnect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), m_activeTimeline->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2403 disconnect(m_transitionConfig, SIGNAL(seekTimeline(int)), m_activeTimeline->projectView() , SLOT(setCursorPos(int)));
2404 disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2405 disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2406 disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
2407 disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2408 disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2409 disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2410 disconnect(m_projectList, SIGNAL(refreshClip(const QString &)), m_activeTimeline->projectView(), SLOT(slotRefreshThumbs(const QString &)));
2411 m_effectStack->clear();
2413 //m_activeDocument->setRenderer(NULL);
2414 disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
2415 disconnect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2416 m_clipMonitor->stop();
2418 KdenliveSettings::setCurrent_profile(doc->profilePath());
2419 KdenliveSettings::setProject_fps(doc->fps());
2420 m_monitorManager->resetProfiles(doc->timecode());
2421 m_projectList->setDocument(doc);
2422 m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
2423 m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
2424 connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
2425 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
2426 connect(m_projectList, SIGNAL(refreshClip(const QString &, bool)), trackView->projectView(), SLOT(slotRefreshThumbs(const QString &, bool)));
2427 connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
2429 connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
2430 connect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &)));
2431 connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString)));
2433 connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&)));
2436 connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
2437 connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int)));
2438 connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int)));
2439 connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int)));
2440 connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo()));
2441 connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
2442 connect(trackView->projectView(), SIGNAL(forceClipProcessing(const QString &)), m_projectList, SLOT(slotForceProcessing(const QString &)));
2443 connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
2444 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), trackView, SLOT(slotSetZone(QPoint)));
2445 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), m_projectList, SLOT(slotUpdateClipCut(QPoint)));
2446 connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2447 connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified()));
2448 connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int)));
2449 connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers()), doc, SLOT(checkProjectClips()));
2451 connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
2452 connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
2453 connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
2454 connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
2455 connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
2457 connect(doc, SIGNAL(deleteTimelineClip(const QString &)), trackView, SLOT(slotDeleteClip(const QString &)));
2458 connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
2459 connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
2460 connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
2462 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
2463 connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
2464 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
2465 connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
2467 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
2468 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
2469 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
2470 m_zoomSlider->setValue(doc->zoom().x());
2471 connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
2472 connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
2473 connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
2474 connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
2476 connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int)));
2477 connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
2479 connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
2480 connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
2482 connect(m_effectStack, SIGNAL(updateEffect(ClipItem*, int, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, int, QDomElement, QDomElement, int)));
2483 connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString)));
2484 connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, int, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, int, QDomElement)));
2485 connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, int, bool)));
2486 connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int, int)));
2487 connect(m_effectStack, SIGNAL(refreshEffectStack(ClipItem*)), trackView->projectView(), SLOT(slotRefreshEffects(ClipItem*)));
2488 connect(m_transitionConfig, SIGNAL(transitionUpdated(Transition *, QDomElement)), trackView->projectView() , SLOT(slotTransitionUpdated(Transition *, QDomElement)));
2489 connect(m_transitionConfig, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2490 connect(m_effectStack, SIGNAL(seekTimeline(int)), trackView->projectView() , SLOT(setCursorPos(int)));
2491 connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
2492 connect(m_effectStack, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2494 connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
2495 connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
2496 connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
2497 connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
2498 connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus()));
2501 trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this)));
2502 m_activeTimeline = trackView;
2503 if (m_renderWidget) {
2504 slotCheckRenderStatus();
2505 m_renderWidget->setProfile(doc->mltProfile());
2506 m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration());
2507 m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash));
2508 m_renderWidget->setRenderProfile(doc->getRenderProperties());
2510 //doc->setRenderer(m_projectMonitor->render);
2511 m_commandStack->setActiveStack(doc->commandStack());
2512 KdenliveSettings::setProject_display_ratio(doc->dar());
2513 //doc->clipManager()->checkAudioThumbs();
2515 //m_overView->setScene(trackView->projectScene());
2516 //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber()));
2517 //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio);
2519 setCaption(doc->description(), doc->isModified());
2520 m_saveAction->setEnabled(doc->isModified());
2521 m_normalEditTool->setChecked(true);
2522 m_activeDocument = doc;
2523 m_activeTimeline->updateProjectFps();
2524 m_activeDocument->checkProjectClips();
2526 m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2528 //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
2529 slotUpdateMousePosition(0);
2530 // set tool to select tool
2531 m_buttonSelectTool->setChecked(true);
2534 void MainWindow::slotZoneMoved(int start, int end)
2536 m_activeDocument->setZone(start, end);
2537 m_projectMonitor->slotZoneMoved(start, end);
2540 void MainWindow::slotGuidesUpdated()
2543 m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration());
2546 void MainWindow::slotEditKeys()
2548 KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this);
2549 dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
2550 dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions"));
2554 void MainWindow::slotPreferences(int page, int option)
2557 * An instance of your dialog could be already created and could be
2558 * cached, in which case you want to display the cached dialog
2559 * instead of creating another one
2561 if (m_stopmotion) m_stopmotion->slotLive(false);
2562 if (KConfigDialog::showDialog("settings")) {
2563 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
2564 if (page != -1) d->showPage(page, option);
2568 // KConfigDialog didn't find an instance of this dialog, so lets
2571 // Get the mappable actions in localized form
2572 QMap<QString, QString> actions;
2573 KActionCollection* collection = actionCollection();
2574 foreach (const QString& action_name, m_action_names) {
2575 actions[collection->action(action_name)->text()] = action_name;
2578 KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(actions, this);
2579 connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
2580 connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
2582 connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
2585 if (page != -1) dialog->showPage(page, option);
2588 void MainWindow::slotUpdateCaptureFolder()
2592 if (m_activeDocument) m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
2593 else m_recMonitor->slotUpdateCaptureFolder(KdenliveSettings::defaultprojectfolder());
2597 void MainWindow::updateConfiguration()
2599 //TODO: we should apply settings to all projects, not only the current one
2600 if (m_activeTimeline) {
2601 m_activeTimeline->refresh();
2602 m_activeTimeline->projectView()->checkAutoScroll();
2603 m_activeTimeline->projectView()->checkTrackHeight();
2604 if (m_activeDocument)
2605 m_activeDocument->clipManager()->checkAudioThumbs();
2607 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2608 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2609 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2610 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2612 // Update list of transcoding profiles
2614 #ifndef NO_JOGSHUTTLE
2615 activateShuttleDevice();
2616 #endif /* NO_JOGSHUTTLE */
2620 void MainWindow::slotSwitchSplitAudio()
2622 KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio());
2623 m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio());
2626 void MainWindow::slotSwitchVideoThumbs()
2628 KdenliveSettings::setVideothumbnails(!KdenliveSettings::videothumbnails());
2629 if (m_activeTimeline)
2630 m_activeTimeline->projectView()->slotUpdateAllThumbs();
2631 m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails());
2634 void MainWindow::slotSwitchAudioThumbs()
2636 KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
2637 if (m_activeTimeline) {
2638 m_activeTimeline->refresh();
2639 m_activeTimeline->projectView()->checkAutoScroll();
2640 if (m_activeDocument)
2641 m_activeDocument->clipManager()->checkAudioThumbs();
2643 m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
2646 void MainWindow::slotSwitchMarkersComments()
2648 KdenliveSettings::setShowmarkers(!KdenliveSettings::showmarkers());
2649 if (m_activeTimeline)
2650 m_activeTimeline->refresh();
2651 m_buttonShowMarkers->setChecked(KdenliveSettings::showmarkers());
2654 void MainWindow::slotSwitchSnap()
2656 KdenliveSettings::setSnaptopoints(!KdenliveSettings::snaptopoints());
2657 m_buttonSnap->setChecked(KdenliveSettings::snaptopoints());
2661 void MainWindow::slotDeleteItem()
2663 if (QApplication::focusWidget() &&
2664 QApplication::focusWidget()->parentWidget() &&
2665 QApplication::focusWidget()->parentWidget()->parentWidget() &&
2666 QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) {
2667 m_projectList->slotRemoveClip();
2670 QWidget *widget = QApplication::focusWidget();
2672 if (widget == m_effectStackDock) {
2673 m_effectStack->slotItemDel();
2676 widget = widget->parentWidget();
2679 // effect stack has no focus
2680 if (m_activeTimeline)
2681 m_activeTimeline->projectView()->deleteSelectedClips();
2685 void MainWindow::slotUpdateClipMarkers(DocClipBase *clip)
2687 if (m_clipMonitor->isActive())
2688 m_clipMonitor->checkOverlay();
2689 m_clipMonitor->updateMarkers(clip);
2692 void MainWindow::slotAddClipMarker()
2694 DocClipBase *clip = NULL;
2696 if (m_projectMonitor->isActive()) {
2697 if (m_activeTimeline) {
2698 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2700 pos = GenTime((int)((m_projectMonitor->position() - item->startPos() + item->cropStart()).frames(m_activeDocument->fps()) * item->speed() + 0.5), m_activeDocument->fps());
2701 clip = item->baseClip();
2705 clip = m_clipMonitor->activeClip();
2706 pos = m_clipMonitor->position();
2709 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2712 QString id = clip->getId();
2713 CommentedTime marker(pos, i18n("Marker"));
2714 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this);
2715 if (d.exec() == QDialog::Accepted)
2716 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2719 void MainWindow::slotDeleteClipMarker()
2721 DocClipBase *clip = NULL;
2723 if (m_projectMonitor->isActive()) {
2724 if (m_activeTimeline) {
2725 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2727 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2728 clip = item->baseClip();
2732 clip = m_clipMonitor->activeClip();
2733 pos = m_clipMonitor->position();
2736 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2740 QString id = clip->getId();
2741 QString comment = clip->markerComment(pos);
2742 if (comment.isEmpty()) {
2743 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2746 m_activeTimeline->projectView()->slotDeleteClipMarker(comment, id, pos);
2749 void MainWindow::slotDeleteAllClipMarkers()
2751 DocClipBase *clip = NULL;
2752 if (m_projectMonitor->isActive()) {
2753 if (m_activeTimeline) {
2754 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2756 clip = item->baseClip();
2760 clip = m_clipMonitor->activeClip();
2763 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2766 m_activeTimeline->projectView()->slotDeleteAllClipMarkers(clip->getId());
2769 void MainWindow::slotEditClipMarker()
2771 DocClipBase *clip = NULL;
2773 if (m_projectMonitor->isActive()) {
2774 if (m_activeTimeline) {
2775 ClipItem *item = m_activeTimeline->projectView()->getActiveClipUnderCursor();
2777 pos = (m_projectMonitor->position() - item->startPos() + item->cropStart()) / item->speed();
2778 clip = item->baseClip();
2782 clip = m_clipMonitor->activeClip();
2783 pos = m_clipMonitor->position();
2786 m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
2790 QString id = clip->getId();
2791 QString oldcomment = clip->markerComment(pos);
2792 if (oldcomment.isEmpty()) {
2793 m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
2797 CommentedTime marker(pos, oldcomment);
2798 MarkerDialog d(clip, marker, m_activeDocument->timecode(), i18n("Edit Marker"), this);
2799 if (d.exec() == QDialog::Accepted) {
2800 m_activeTimeline->projectView()->slotAddClipMarker(id, d.newMarker().time(), d.newMarker().comment());
2801 if (d.newMarker().time() != pos) {
2802 // remove old marker
2803 m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString());
2808 void MainWindow::slotAddMarkerGuideQuickly()
2810 if (!m_activeTimeline || !m_activeDocument)
2813 if (m_clipMonitor->isActive()) {
2814 DocClipBase *clip = m_clipMonitor->activeClip();
2815 GenTime pos = m_clipMonitor->position();
2818 m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
2822 m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
2824 m_activeTimeline->projectView()->slotAddGuide(false);
2828 void MainWindow::slotAddGuide()
2830 if (m_activeTimeline)
2831 m_activeTimeline->projectView()->slotAddGuide();
2834 void MainWindow::slotInsertSpace()
2836 if (m_activeTimeline)
2837 m_activeTimeline->projectView()->slotInsertSpace();
2840 void MainWindow::slotRemoveSpace()
2842 if (m_activeTimeline)
2843 m_activeTimeline->projectView()->slotRemoveSpace();
2846 void MainWindow::slotInsertTrack(int ix)
2848 m_projectMonitor->activateMonitor();
2849 if (m_activeTimeline)
2850 m_activeTimeline->projectView()->slotInsertTrack(ix);
2851 if (m_activeDocument)
2852 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2855 void MainWindow::slotDeleteTrack(int ix)
2857 m_projectMonitor->activateMonitor();
2858 if (m_activeTimeline)
2859 m_activeTimeline->projectView()->slotDeleteTrack(ix);
2860 if (m_activeDocument)
2861 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2864 void MainWindow::slotConfigTrack(int ix)
2866 m_projectMonitor->activateMonitor();
2867 if (m_activeTimeline)
2868 m_activeTimeline->projectView()->slotConfigTracks(ix);
2869 if (m_activeDocument)
2870 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
2873 void MainWindow::slotEditGuide()
2875 if (m_activeTimeline)
2876 m_activeTimeline->projectView()->slotEditGuide();
2879 void MainWindow::slotDeleteGuide()
2881 if (m_activeTimeline)
2882 m_activeTimeline->projectView()->slotDeleteGuide();
2885 void MainWindow::slotDeleteAllGuides()
2887 if (m_activeTimeline)
2888 m_activeTimeline->projectView()->slotDeleteAllGuides();
2891 void MainWindow::slotCutTimelineClip()
2893 if (m_activeTimeline)
2894 m_activeTimeline->projectView()->cutSelectedClips();
2897 void MainWindow::slotInsertClipOverwrite()
2899 if (m_activeTimeline) {
2900 QStringList data = m_clipMonitor->getZoneInfo();
2901 m_activeTimeline->projectView()->insertZoneOverwrite(data, m_activeTimeline->inPoint());
2905 void MainWindow::slotSelectTimelineClip()
2907 if (m_activeTimeline)
2908 m_activeTimeline->projectView()->selectClip(true);
2911 void MainWindow::slotSelectTimelineTransition()
2913 if (m_activeTimeline)
2914 m_activeTimeline->projectView()->selectTransition(true);
2917 void MainWindow::slotDeselectTimelineClip()
2919 if (m_activeTimeline)
2920 m_activeTimeline->projectView()->selectClip(false, true);
2923 void MainWindow::slotDeselectTimelineTransition()
2925 if (m_activeTimeline)
2926 m_activeTimeline->projectView()->selectTransition(false, true);
2929 void MainWindow::slotSelectAddTimelineClip()
2931 if (m_activeTimeline)
2932 m_activeTimeline->projectView()->selectClip(true, true);
2935 void MainWindow::slotSelectAddTimelineTransition()
2937 if (m_activeTimeline)
2938 m_activeTimeline->projectView()->selectTransition(true, true);
2941 void MainWindow::slotGroupClips()
2943 if (m_activeTimeline)
2944 m_activeTimeline->projectView()->groupClips();
2947 void MainWindow::slotUnGroupClips()
2949 if (m_activeTimeline)
2950 m_activeTimeline->projectView()->groupClips(false);
2953 void MainWindow::slotEditItemDuration()
2955 if (m_activeTimeline)
2956 m_activeTimeline->projectView()->editItemDuration();
2959 void MainWindow::slotAddProjectClip(KUrl url)
2961 if (m_activeDocument)
2962 m_activeDocument->slotAddClipFile(url, QString());
2965 void MainWindow::slotAddTransition(QAction *result)
2967 if (!result) return;
2968 QStringList info = result->data().toStringList();
2969 if (info.isEmpty()) return;
2970 QDomElement transition = transitions.getEffectByTag(info.at(1), info.at(2));
2971 if (m_activeTimeline && !transition.isNull()) {
2972 m_activeTimeline->projectView()->slotAddTransitionToSelectedClips(transition.cloneNode().toElement());
2976 void MainWindow::slotAddVideoEffect(QAction *result)
2978 if (!result) return;
2979 const int EFFECT_VIDEO = 1;
2980 const int EFFECT_AUDIO = 2;
2981 QStringList info = result->data().toStringList();
2983 if (info.isEmpty() || info.size() < 3) return;
2984 QDomElement effect ;
2985 if (info.at(2) == QString::number((int) EFFECT_VIDEO))
2986 effect = videoEffects.getEffectByTag(info.at(0), info.at(1));
2987 else if (info.at(2) == QString::number((int) EFFECT_AUDIO))
2988 effect = audioEffects.getEffectByTag(info.at(0), info.at(1));
2990 effect = customEffects.getEffectByTag(info.at(0), info.at(1));
2991 if (!effect.isNull()) slotAddEffect(effect);
2992 else m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2").arg(info.at(0)).arg(info.at(1)), ErrorMessage);
2996 void MainWindow::slotZoomIn()
2998 m_zoomSlider->setValue(m_zoomSlider->value() - 1);
2999 slotShowZoomSliderToolTip();
3002 void MainWindow::slotZoomOut()
3004 m_zoomSlider->setValue(m_zoomSlider->value() + 1);
3005 slotShowZoomSliderToolTip();
3008 void MainWindow::slotFitZoom()
3010 if (m_activeTimeline)
3011 m_zoomSlider->setValue(m_activeTimeline->fitZoom());
3014 void MainWindow::slotSetZoom(int value)
3016 value = qMax(m_zoomSlider->minimum(), value);
3017 value = qMin(m_zoomSlider->maximum(), value);
3019 if (m_activeTimeline)
3020 m_activeTimeline->slotChangeZoom(value);
3022 m_zoomOut->setEnabled(value < m_zoomSlider->maximum());
3023 m_zoomIn->setEnabled(value > m_zoomSlider->minimum());
3024 slotUpdateZoomSliderToolTip(value);
3026 m_zoomSlider->blockSignals(true);
3027 m_zoomSlider->setValue(value);
3028 m_zoomSlider->blockSignals(false);
3031 void MainWindow::slotShowZoomSliderToolTip(int zoomlevel)
3033 if (zoomlevel != -1)
3034 slotUpdateZoomSliderToolTip(zoomlevel);
3036 QPoint global = m_zoomSlider->rect().topLeft();
3037 global.ry() += m_zoomSlider->height() / 2;
3038 QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global));
3039 QApplication::sendEvent(m_zoomSlider, &toolTipEvent);
3042 void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
3044 m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel)));
3047 void MainWindow::slotGotProgressInfo(const QString &message, int progress)
3049 m_statusProgressBar->setValue(progress);
3050 if (progress >= 0) {
3051 if (!message.isEmpty())
3052 m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message);
3053 m_statusProgressBar->setVisible(true);
3054 } else if (progress == -2) {
3055 if (!message.isEmpty())
3056 m_messageLabel->setMessage(message, ErrorMessage);
3057 m_statusProgressBar->setVisible(false);
3059 m_messageLabel->setMessage(QString(), DefaultMessage);
3060 m_statusProgressBar->setVisible(false);
3064 void MainWindow::slotShowClipProperties(DocClipBase *clip)
3066 if (clip->clipType() == TEXT) {
3067 QString titlepath = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "titles/";
3068 if (!clip->getProperty("resource").isEmpty() && clip->getProperty("xmldata").isEmpty()) {
3069 // template text clip
3071 // Get the list of existing templates
3073 filter << "*.kdenlivetitle";
3074 QStringList templateFiles = QDir(titlepath).entryList(filter, QDir::Files);
3076 QDialog *dia = new QDialog(this);
3077 Ui::TemplateClip_UI dia_ui;
3078 dia_ui.setupUi(dia);
3080 const QString templatePath = clip->getProperty("resource");
3081 for (int i = 0; i < templateFiles.size(); ++i) {
3082 dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), titlepath + templateFiles.at(i));
3083 if (templatePath == KUrl(titlepath + templateFiles.at(i)).path()) ix = i;
3085 if (ix != -1) dia_ui.template_list->comboBox()->setCurrentIndex(ix);
3086 else dia_ui.template_list->comboBox()->insertItem(0, templatePath);
3087 dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle");
3088 //warning: setting base directory doesn't work??
3089 KUrl startDir(titlepath);
3090 dia_ui.template_list->fileDialog()->setUrl(startDir);
3091 dia_ui.description->setText(clip->getProperty("description"));
3092 if (dia->exec() == QDialog::Accepted) {
3093 QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
3094 if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText();
3096 QMap <QString, QString> newprops;
3098 if (KUrl(textTemplate).path() != templatePath) {
3099 // The template was changed
3100 newprops.insert("resource", textTemplate);
3103 if (dia_ui.description->toPlainText() != clip->getProperty("description")) {
3104 newprops.insert("description", dia_ui.description->toPlainText());
3107 QString newtemplate = newprops.value("xmltemplate");
3108 if (newtemplate.isEmpty()) newtemplate = templatePath;
3110 // template modified we need to update xmldata
3111 QString description = newprops.value("description");
3112 if (description.isEmpty()) description = clip->getProperty("description");
3113 else newprops.insert("templatetext", description);
3114 //newprops.insert("xmldata", m_projectList->generateTemplateXml(newtemplate, description).toString());
3115 if (!newprops.isEmpty()) {
3116 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3117 m_activeDocument->commandStack()->push(command);
3123 QString path = clip->getProperty("resource");
3124 TitleWidget *dia_ui = new TitleWidget(KUrl(), m_activeDocument->timecode(), titlepath, m_projectMonitor->render, this);
3126 doc.setContent(clip->getProperty("xmldata"));
3127 dia_ui->setXml(doc);
3128 if (dia_ui->exec() == QDialog::Accepted) {
3129 QMap <QString, QString> newprops;
3130 newprops.insert("xmldata", dia_ui->xml().toString());
3131 if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) {
3132 // duration changed, we need to update duration
3133 newprops.insert("out", QString::number(dia_ui->outPoint()));
3134 int currentLength = QString(clip->producerProperty("length")).toInt();
3135 if (currentLength <= dia_ui->outPoint())
3136 newprops.insert("length", QString::number(dia_ui->outPoint() + 1));
3137 else newprops.insert("length", clip->producerProperty("length"));
3139 if (!path.isEmpty()) {
3140 // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
3141 if (KMessageBox::questionYesNo(this, i18n("You are editing an external title clip (%1). Do you want to save your changes to the title file or save the changes for this project only?", path), i18n("Save Title"), KGuiItem(i18n("Save to title file")), KGuiItem(i18n("Save in project only"))) == KMessageBox::Yes) {
3142 // save to external file
3143 dia_ui->saveTitle(path);
3144 } else newprops.insert("resource", QString());
3146 EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
3147 m_activeDocument->commandStack()->push(command);
3148 //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
3149 m_activeDocument->setModified(true);
3153 //m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
3157 // any type of clip but a title
3158 ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
3159 connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
3160 connect(dia, SIGNAL(applyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)), this, SLOT(slotApplyNewClipProperties(const QString, QMap <QString, QString> , QMap <QString, QString> , bool, bool)));
3165 void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
3167 if (newprops.isEmpty()) return;
3168 EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
3169 m_activeDocument->commandStack()->push(command);
3170 m_activeDocument->setModified();
3173 // update clip occurences in timeline
3174 m_activeTimeline->projectView()->slotUpdateClip(id, reload);
3179 void MainWindow::slotShowClipProperties(QList <DocClipBase *> cliplist, QMap<QString, QString> commonproperties)
3181 ClipProperties dia(cliplist, m_activeDocument->timecode(), commonproperties, this);
3182 if (dia.exec() == QDialog::Accepted) {
3183 QUndoCommand *command = new QUndoCommand();
3184 command->setText(i18n("Edit clips"));
3185 QMap <QString, QString> newImageProps = dia.properties();
3186 // Transparency setting applies only for images
3187 QMap <QString, QString> newProps = newImageProps;
3188 newProps.remove("transparency");
3190 for (int i = 0; i < cliplist.count(); i++) {
3191 DocClipBase *clip = cliplist.at(i);
3192 if (clip->clipType() == IMAGE)
3193 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newImageProps, true, command);
3195 new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newProps, true, command);
3197 m_activeDocument->commandStack()->push(command);
3198 for (int i = 0; i < cliplist.count(); i++)
3199 m_activeTimeline->projectView()->slotUpdateClip(cliplist.at(i)->getId(), dia.needsTimelineReload());
3203 void MainWindow::customEvent(QEvent* e)
3205 if (e->type() == QEvent::User)
3206 m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
3208 void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
3214 m_effectStack->raiseWindow(m_effectStackDock);
3217 void MainWindow::slotActivateTransitionView(Transition *t)
3220 m_transitionConfig->raiseWindow(m_transitionConfigDock);
3223 void MainWindow::slotSnapRewind()
3225 if (m_projectMonitor->isActive()) {
3226 if (m_activeTimeline)
3227 m_activeTimeline->projectView()->slotSeekToPreviousSnap();
3229 m_clipMonitor->slotSeekToPreviousSnap();
3233 void MainWindow::slotSnapForward()
3235 if (m_projectMonitor->isActive()) {
3236 if (m_activeTimeline)
3237 m_activeTimeline->projectView()->slotSeekToNextSnap();
3239 m_clipMonitor->slotSeekToNextSnap();
3243 void MainWindow::slotClipStart()
3245 if (m_projectMonitor->isActive()) {
3246 if (m_activeTimeline)
3247 m_activeTimeline->projectView()->clipStart();
3251 void MainWindow::slotClipEnd()
3253 if (m_projectMonitor->isActive()) {
3254 if (m_activeTimeline)
3255 m_activeTimeline->projectView()->clipEnd();
3259 void MainWindow::slotZoneStart()
3261 if (m_projectMonitor->isActive())
3262 m_projectMonitor->slotZoneStart();
3264 m_clipMonitor->slotZoneStart();
3267 void MainWindow::slotZoneEnd()
3269 if (m_projectMonitor->isActive())
3270 m_projectMonitor->slotZoneEnd();
3272 m_clipMonitor->slotZoneEnd();
3275 void MainWindow::slotChangeTool(QAction * action)
3277 if (action == m_buttonSelectTool)
3278 slotSetTool(SELECTTOOL);
3279 else if (action == m_buttonRazorTool)
3280 slotSetTool(RAZORTOOL);
3281 else if (action == m_buttonSpacerTool)
3282 slotSetTool(SPACERTOOL);
3285 void MainWindow::slotChangeEdit(QAction * action)
3287 if (!m_activeTimeline)
3290 if (action == m_overwriteEditTool)
3291 m_activeTimeline->projectView()->setEditMode(OVERWRITEEDIT);
3292 else if (action == m_insertEditTool)
3293 m_activeTimeline->projectView()->setEditMode(INSERTEDIT);
3295 m_activeTimeline->projectView()->setEditMode(NORMALEDIT);
3298 void MainWindow::slotSetTool(PROJECTTOOL tool)
3300 if (m_activeDocument && m_activeTimeline) {
3301 //m_activeDocument->setTool(tool);
3305 message = i18n("Ctrl + click to use spacer on current track only");
3308 message = i18n("Click on a clip to cut it");
3311 message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
3314 m_messageLabel->setMessage(message, InformationMessage);
3315 m_activeTimeline->projectView()->setTool(tool);
3319 void MainWindow::slotCopy()
3321 if (m_activeDocument && m_activeTimeline)
3322 m_activeTimeline->projectView()->copyClip();
3325 void MainWindow::slotPaste()
3327 if (m_activeDocument && m_activeTimeline)
3328 m_activeTimeline->projectView()->pasteClip();
3331 void MainWindow::slotPasteEffects()
3333 if (m_activeDocument && m_activeTimeline)
3334 m_activeTimeline->projectView()->pasteClipEffects();
3337 void MainWindow::slotFind()
3339 if (!m_activeDocument || !m_activeTimeline) return;
3340 m_projectSearch->setEnabled(false);
3341 m_findActivated = true;
3342 m_findString.clear();
3343 m_activeTimeline->projectView()->initSearchStrings();
3344 statusBar()->showMessage(i18n("Starting -- find text as you type"));
3345 m_findTimer.start(5000);
3346 qApp->installEventFilter(this);
3349 void MainWindow::slotFindNext()
3351 if (m_activeTimeline && m_activeTimeline->projectView()->findNextString(m_findString))
3352 statusBar()->showMessage(i18n("Found: %1", m_findString));
3354 statusBar()->showMessage(i18n("Reached end of project"));
3355 m_findTimer.start(4000);
3358 void MainWindow::findAhead()
3360 if (m_activeTimeline && m_activeTimeline->projectView()->findString(m_findString)) {
3361 m_projectSearchNext->setEnabled(true);
3362 statusBar()->showMessage(i18n("Found: %1", m_findString));
3364 m_projectSearchNext->setEnabled(false);
3365 statusBar()->showMessage(i18n("Not found: %1", m_findString));
3369 void MainWindow::findTimeout()
3371 m_projectSearchNext->setEnabled(false);
3372 m_findActivated = false;
3373 m_findString.clear();
3374 statusBar()->showMessage(i18n("Find stopped"), 3000);
3375 if (m_activeTimeline) m_activeTimeline->projectView()->clearSearchStrings();
3376 m_projectSearch->setEnabled(true);
3377 removeEventFilter(this);
3380 void MainWindow::slotClipInTimeline(const QString &clipId)
3382 if (m_activeTimeline && m_activeDocument) {
3383 QList<ItemInfo> matching = m_activeTimeline->projectView()->findId(clipId);
3385 QMenu *inTimelineMenu = static_cast<QMenu*>(factory()->container("clip_in_timeline", this));
3386 inTimelineMenu->clear();
3388 QList <QAction *> actionList;
3390 for (int i = 0; i < matching.count(); ++i) {
3391 QString track = QString::number(matching.at(i).track);
3392 QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos);
3394 QAction *a = new QAction(track + ": " + start, this);
3395 a->setData(QStringList() << track << start);
3396 connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline()));
3397 while (j < actionList.count()) {
3398 if (actionList.at(j)->text() > a->text()) break;
3401 actionList.insert(j, a);
3403 inTimelineMenu->addActions(actionList);
3405 if (matching.empty())
3406 inTimelineMenu->setEnabled(false);
3408 inTimelineMenu->setEnabled(true);
3412 void MainWindow::slotClipInProjectTree()
3414 if (m_activeTimeline) {
3415 const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips();
3416 if (clipIds.isEmpty())
3418 m_projectListDock->raise();
3419 for (int i = 0; i < clipIds.count(); i++)
3420 m_projectList->selectItemById(clipIds.at(i));
3421 if (m_projectMonitor->isActive())
3422 slotSwitchMonitors();
3426 /*void MainWindow::slotClipToProjectTree()
3428 if (m_activeTimeline) {
3429 const QList<ClipItem *> clips = m_activeTimeline->projectView()->selectedClipItems();
3430 if (clips.isEmpty()) return;
3431 for (int i = 0; i < clips.count(); i++) {
3432 m_projectList->slotAddXmlClip(clips.at(i)->itemXml());
3434 //m_projectList->selectItemById(clipIds.at(i));
3438 void MainWindow::slotSelectClipInTimeline()
3440 if (m_activeTimeline) {
3441 QAction *action = qobject_cast<QAction *>(sender());
3442 QStringList data = action->data().toStringList();
3443 m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1));
3447 void MainWindow::keyPressEvent(QKeyEvent *ke)
3449 if (m_findActivated) {
3450 if (ke->key() == Qt::Key_Backspace) {
3451 m_findString = m_findString.left(m_findString.length() - 1);
3453 if (!m_findString.isEmpty())
3458 m_findTimer.start(4000);
3461 } else if (ke->key() == Qt::Key_Escape) {
3465 } else if (ke->key() == Qt::Key_Space || !ke->text().trimmed().isEmpty()) {
3466 m_findString += ke->text();
3470 m_findTimer.start(4000);
3475 KXmlGuiWindow::keyPressEvent(ke);
3480 /** Gets called when the window gets hidden */
3481 void MainWindow::hideEvent(QHideEvent */*event*/)
3483 if (isMinimized() && m_monitorManager)
3484 m_monitorManager->stopActiveMonitor();
3487 bool MainWindow::eventFilter(QObject *obj, QEvent *event)
3489 if (m_findActivated) {
3490 if (event->type() == QEvent::ShortcutOverride) {
3491 QKeyEvent* ke = (QKeyEvent*) event;
3492 if (ke->text().trimmed().isEmpty()) return false;
3499 // pass the event on to the parent class
3500 return QMainWindow::eventFilter(obj, event);
3505 void MainWindow::slotSaveZone(Render *render, QPoint zone)
3507 KDialog *dialog = new KDialog(this);
3508 dialog->setCaption("Save clip zone");
3509 dialog->setButtons(KDialog::Ok | KDialog::Cancel);
3511 QWidget *widget = new QWidget(dialog);
3512 dialog->setMainWidget(widget);
3514 QVBoxLayout *vbox = new QVBoxLayout(widget);
3515 QLabel *label1 = new QLabel(i18n("Save clip zone as:"), this);
3516 QString path = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash);
3517 path.append("untitled.mlt");
3518 KUrlRequester *url = new KUrlRequester(KUrl(path), this);
3519 url->setFilter("video/mlt-playlist");
3520 QLabel *label2 = new QLabel(i18n("Description:"), this);
3521 KLineEdit *edit = new KLineEdit(this);
3522 vbox->addWidget(label1);
3523 vbox->addWidget(url);
3524 vbox->addWidget(label2);
3525 vbox->addWidget(edit);
3526 if (dialog->exec() == QDialog::Accepted)
3527 render->saveZone(url->url(), edit->text(), zone);
3531 void MainWindow::slotSetInPoint()
3533 if (m_clipMonitor->isActive())
3534 m_clipMonitor->slotSetZoneStart();
3536 m_projectMonitor->slotSetZoneStart();
3537 //else m_activeTimeline->projectView()->setInPoint();
3540 void MainWindow::slotSetOutPoint()
3542 if (m_clipMonitor->isActive())
3543 m_clipMonitor->slotSetZoneEnd();
3545 m_projectMonitor->slotSetZoneEnd();
3546 // else m_activeTimeline->projectView()->setOutPoint();
3549 void MainWindow::slotResizeItemStart()
3551 if (m_activeTimeline)
3552 m_activeTimeline->projectView()->setInPoint();
3555 void MainWindow::slotResizeItemEnd()
3557 if (m_activeTimeline)
3558 m_activeTimeline->projectView()->setOutPoint();
3561 int MainWindow::getNewStuff(const QString &configFile)
3563 KNS3::Entry::List entries;
3564 #if KDE_IS_VERSION(4,3,80)
3565 KNS3::DownloadDialog dialog(configFile);
3567 entries = dialog.changedEntries();
3568 foreach(const KNS3::Entry & entry, entries) {
3569 if (entry.status() == KNS3::Entry::Installed)
3570 kDebug() << "// Installed files: " << entry.installedFiles();
3573 KNS::Engine engine(0);
3574 if (engine.init(configFile))
3575 entries = engine.downloadDialogModal(this);
3576 foreach(KNS::Entry * entry, entries) {
3577 if (entry->status() == KNS::Entry::Installed)
3578 kDebug() << "// Installed files: " << entry->installedFiles();
3580 #endif /* KDE_IS_VERSION(4,3,80) */
3581 return entries.size();
3584 void MainWindow::slotGetNewTitleStuff()
3586 if (getNewStuff("kdenlive_titles.knsrc") > 0)
3587 TitleWidget::refreshTitleTemplates();
3590 void MainWindow::slotGetNewLumaStuff()
3592 if (getNewStuff("kdenlive_wipes.knsrc") > 0) {
3593 initEffects::refreshLumas();
3594 m_activeTimeline->projectView()->reloadTransitionLumas();
3598 void MainWindow::slotGetNewRenderStuff()
3600 if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0)
3602 m_renderWidget->reloadProfiles();
3605 void MainWindow::slotGetNewMltProfileStuff()
3607 if (getNewStuff("kdenlive_projectprofiles.knsrc") > 0) {
3608 // update the list of profiles in settings dialog
3609 KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
3615 void MainWindow::slotAutoTransition()
3617 if (m_activeTimeline)
3618 m_activeTimeline->projectView()->autoTransition();
3621 void MainWindow::slotSplitAudio()
3623 if (m_activeTimeline)
3624 m_activeTimeline->projectView()->splitAudio();
3627 void MainWindow::slotUpdateClipType(QAction *action)
3629 if (m_activeTimeline) {
3630 if (action->data().toString() == "clip_audio_only") m_activeTimeline->projectView()->setAudioOnly();
3631 else if (action->data().toString() == "clip_video_only") m_activeTimeline->projectView()->setVideoOnly();
3632 else m_activeTimeline->projectView()->setAudioAndVideo();
3636 void MainWindow::slotDvdWizard(const QString &url, const QString &profile)
3638 // We must stop the monitors since we create a new on in the dvd wizard
3639 m_clipMonitor->stop();
3640 m_projectMonitor->stop();
3641 DvdWizard w(url, profile, this);
3643 m_projectMonitor->start();
3646 void MainWindow::slotShowTimeline(bool show)
3648 if (show == false) {
3649 m_timelineState = saveState();
3650 centralWidget()->setHidden(true);
3652 centralWidget()->setHidden(false);
3653 restoreState(m_timelineState);
3657 void MainWindow::slotMaximizeCurrent(bool /*show*/)
3659 //TODO: is there a way to maximize current widget?
3662 m_timelineState = saveState();
3663 QWidget *par = focusWidget()->parentWidget();
3664 while (par->parentWidget() && par->parentWidget() != this)
3665 par = par->parentWidget();
3666 kDebug() << "CURRENT WIDGET: " << par->objectName();
3669 //centralWidget()->setHidden(false);
3670 //restoreState(m_timelineState);
3674 void MainWindow::loadTranscoders()
3676 QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
3679 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
3680 KConfigGroup transConfig(config, "Transcoding");
3682 QMap< QString, QString > profiles = transConfig.entryMap();
3683 QMapIterator<QString, QString> i(profiles);
3684 while (i.hasNext()) {
3686 QStringList data = i.value().split(";", QString::SkipEmptyParts);
3687 QAction *a = transMenu->addAction(i.key());
3689 if (data.count() > 1)
3690 a->setToolTip(data.at(1));
3691 connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
3695 void MainWindow::slotTranscode(KUrl::List urls)
3700 if (urls.isEmpty()) {
3701 QAction *action = qobject_cast<QAction *>(sender());
3702 QStringList data = action->data().toStringList();
3703 params = data.at(0);
3704 if (data.count() > 1) desc = data.at(1);
3705 if (data.count() > 2) condition = data.at(2);
3706 urls << m_projectList->getConditionalUrls(condition);
3707 urls.removeAll(KUrl());
3709 if (urls.isEmpty()) {
3710 m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
3713 ClipTranscode *d = new ClipTranscode(urls, params, desc);
3714 connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
3716 //QProcess::startDetached("ffmpeg", parameters);
3719 void MainWindow::slotTranscodeClip()
3721 KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
3722 if (urls.isEmpty()) return;
3723 slotTranscode(urls);
3726 void MainWindow::slotSetDocumentRenderProfile(QMap <QString, QString> props)
3728 if (m_activeDocument == NULL) return;
3729 QMapIterator<QString, QString> i(props);
3730 while (i.hasNext()) {
3732 m_activeDocument->setDocumentProperty(i.key(), i.value());
3734 m_activeDocument->setModified(true);
3738 void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
3740 if (m_activeDocument == NULL || m_renderWidget == NULL) return;
3742 QString playlistPath;
3745 QString scriptsFolder = m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "scripts/";
3746 QString path = m_renderWidget->getFreeScriptName();
3747 scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
3748 if (!ok || scriptPath.isEmpty()) return;
3749 scriptPath.prepend(scriptsFolder);
3750 QFile f(scriptPath);
3752 if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
3755 playlistPath = scriptPath + ".mlt";
3757 KTemporaryFile temp;
3758 temp.setAutoRemove(false);
3759 temp.setSuffix(".mlt");
3761 playlistPath = temp.fileName();
3763 QString playlistContent = m_projectMonitor->sceneList();
3764 if (!chapterFile.isEmpty()) {
3767 if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
3769 in = m_activeTimeline->inPoint();
3770 out = m_activeTimeline->outPoint();
3773 QDomElement chapters = doc.createElement("chapters");
3774 chapters.setAttribute("fps", m_activeDocument->fps());
3775 doc.appendChild(chapters);
3777 QDomElement guidesxml = m_activeDocument->guidesXml();
3778 QDomNodeList nodes = guidesxml.elementsByTagName("guide");
3779 for (int i = 0; i < nodes.count(); i++) {
3780 QDomElement e = nodes.item(i).toElement();
3782 QString comment = e.attribute("comment");
3783 int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
3784 if (time >= in && time < out) {
3785 if (zoneOnly) time = time - in;
3786 QDomElement chapter = doc.createElement("chapter");
3787 chapters.appendChild(chapter);
3788 chapter.setAttribute("title", comment);
3789 chapter.setAttribute("time", time);
3793 if (chapters.childNodes().count() > 0) {
3794 if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
3795 // Always insert a guide in pos 0
3796 QDomElement chapter = doc.createElement("chapter");
3797 chapters.insertBefore(chapter, QDomNode());
3798 chapter.setAttribute("title", i18n("Start"));
3799 chapter.setAttribute("time", "0");
3801 // save chapters file
3802 QFile file(chapterFile);
3803 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3804 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3806 file.write(doc.toString().toUtf8());
3807 if (file.error() != QFile::NoError) {
3808 kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
3815 if (m_renderWidget->automaticAudioExport()) {
3816 exportAudio = m_activeTimeline->checkProjectAudio();
3817 } else exportAudio = m_renderWidget->selectedAudioExport();
3819 // Do we want proxy rendering
3820 if (m_projectList->useProxy() && !m_renderWidget->proxyRendering()) {
3822 doc.setContent(playlistContent);
3823 QString root = doc.documentElement().attribute("root");
3825 // replace proxy clips with originals
3826 QMap <QString, QString> proxies = m_projectList->getProxies();
3829 QDomNodeList producers = doc.elementsByTagName("producer");
3830 QString producerResource;
3832 for (uint n = 0; n < producers.length(); n++) {
3833 QDomElement e = producers.item(n).toElement();
3834 producerResource = EffectsList::property(e, "resource");
3835 if (producerResource.contains('?')) {
3836 suffix = "?" + producerResource.section('?', 1);
3837 producerResource = producerResource.section('?', 0, 0);
3839 else suffix.clear();
3840 if (!producerResource.isEmpty()) {
3841 if (proxies.contains(producerResource)) {
3842 EffectsList::setProperty(e, "resource", proxies.value(producerResource) + suffix);
3843 // We need to delete the "aspect_ratio" property because proxy clips
3844 // sometimes have different ratio than original clips
3845 EffectsList::removeProperty(e, "aspect_ratio");
3847 else if (!root.isEmpty() && producerResource.startsWith(root) && proxies.contains(producerResource.remove(0, root.count() + 1))) {
3848 EffectsList::setProperty(e, "resource", proxies.value(producerResource.remove(0, root.count() + 1)) + suffix);
3849 // We need to delete the "aspect_ratio" property because proxy clips
3850 // sometimes have different ratio than original clips
3851 EffectsList::removeProperty(e, "aspect_ratio");
3856 /*QMapIterator<QString, QString> i(proxies);
3857 while (i.hasNext()) {
3859 // Replace all keys with their values (proxy path with original path)
3860 QString key = i.key();
3861 playlistContent.replace(key, i.value());
3862 if (!root.isEmpty() && key.startsWith(root)) {
3863 // in case the resource path in MLT playlist is relative
3864 key.remove(0, root.count() + 1);
3865 playlistContent.replace(key, i.value());
3868 playlistContent = doc.toString();
3871 // Do save scenelist
3872 QFile file(playlistPath);
3873 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
3874 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3877 file.write(playlistContent.toUtf8());
3878 if (file.error() != QFile::NoError) {
3879 m_messageLabel->setMessage(i18n("Cannot write to file %1").arg(playlistPath), ErrorMessage);
3884 m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath, exportAudio);
3887 void MainWindow::slotUpdateTimecodeFormat(int ix)
3889 KdenliveSettings::setFrametimecode(ix == 1);
3890 m_clipMonitor->updateTimecodeFormat();
3891 m_projectMonitor->updateTimecodeFormat();
3892 m_transitionConfig->updateTimecodeFormat();
3893 m_effectStack->updateTimecodeFormat();
3894 //m_activeTimeline->projectView()->clearSelection();
3895 m_activeTimeline->updateRuler();
3898 void MainWindow::slotRemoveFocus()
3900 statusBar()->setFocus();
3901 statusBar()->clearFocus();
3904 void MainWindow::slotRevert()
3906 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;
3907 KUrl url = m_activeDocument->url();
3908 if (closeCurrentDocument(false))
3909 doOpenFile(url, NULL);
3913 void MainWindow::slotShutdown()
3915 if (m_activeDocument) m_activeDocument->setModified(false);
3917 QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
3918 if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
3919 QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
3920 smserver.call("logout", 1, 2, 2);
3921 } else if (interface && interface->isServiceRegistered("org.gnome.SessionManager")) {
3922 QDBusInterface smserver("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager");
3923 smserver.call("Shutdown");
3927 void MainWindow::slotUpdateTrackInfo()
3929 if (m_activeDocument)
3930 m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
3933 void MainWindow::slotChangePalette(QAction *action, const QString &themename)
3935 // Load the theme file
3937 if (action == NULL) theme = themename;
3938 else theme = action->data().toString();
3939 KdenliveSettings::setColortheme(theme);
3940 // Make palette for all widgets.
3941 QPalette plt = kapp->palette();
3942 if (theme.isEmpty()) {
3943 plt = QApplication::desktop()->palette();
3945 KSharedConfigPtr config = KSharedConfig::openConfig(theme);
3947 // Since there currently is a bug (or feature change) in KGlobalSettings::createApplicationPalette, we need
3948 // to do the palette loading stuff ourselves...
3949 //plt = KGlobalSettings::createApplicationPalette(config);
3951 QPalette::ColorGroup states[3] = { QPalette::Active, QPalette::Inactive,
3952 QPalette::Disabled };
3953 // TT thinks tooltips shouldn't use active, so we use our active colors for all states
3954 KColorScheme schemeTooltip(QPalette::Active, KColorScheme::Tooltip, config);
3956 for ( int i = 0; i < 3 ; i++ ) {
3957 QPalette::ColorGroup state = states[i];
3958 KColorScheme schemeView(state, KColorScheme::View, config);
3959 KColorScheme schemeWindow(state, KColorScheme::Window, config);
3960 KColorScheme schemeButton(state, KColorScheme::Button, config);
3961 KColorScheme schemeSelection(state, KColorScheme::Selection, config);
3963 plt.setBrush( state, QPalette::WindowText, schemeWindow.foreground() );
3964 plt.setBrush( state, QPalette::Window, schemeWindow.background() );
3965 plt.setBrush( state, QPalette::Base, schemeView.background() );
3966 plt.setBrush( state, QPalette::Text, schemeView.foreground() );
3967 plt.setBrush( state, QPalette::Button, schemeButton.background() );
3968 plt.setBrush( state, QPalette::ButtonText, schemeButton.foreground() );
3969 plt.setBrush( state, QPalette::Highlight, schemeSelection.background() );
3970 plt.setBrush( state, QPalette::HighlightedText, schemeSelection.foreground() );
3971 plt.setBrush( state, QPalette::ToolTipBase, schemeTooltip.background() );
3972 plt.setBrush( state, QPalette::ToolTipText, schemeTooltip.foreground() );
3974 plt.setColor( state, QPalette::Light, schemeWindow.shade( KColorScheme::LightShade ) );
3975 plt.setColor( state, QPalette::Midlight, schemeWindow.shade( KColorScheme::MidlightShade ) );
3976 plt.setColor( state, QPalette::Mid, schemeWindow.shade( KColorScheme::MidShade ) );
3977 plt.setColor( state, QPalette::Dark, schemeWindow.shade( KColorScheme::DarkShade ) );
3978 plt.setColor( state, QPalette::Shadow, schemeWindow.shade( KColorScheme::ShadowShade ) );
3980 plt.setBrush( state, QPalette::AlternateBase, schemeView.background( KColorScheme::AlternateBackground) );
3981 plt.setBrush( state, QPalette::Link, schemeView.foreground( KColorScheme::LinkText ) );
3982 plt.setBrush( state, QPalette::LinkVisited, schemeView.foreground( KColorScheme::VisitedText ) );
3985 kapp->setPalette(plt);
3986 const QObjectList children = statusBar()->children();
3988 foreach(QObject * child, children) {
3989 if (child->isWidgetType())
3990 ((QWidget*)child)->setPalette(plt);
3991 const QObjectList subchildren = child->children();
3992 foreach(QObject * subchild, subchildren) {
3993 if (subchild->isWidgetType())
3994 ((QWidget*)subchild)->setPalette(plt);
3997 if (m_activeTimeline) {
3998 m_activeTimeline->projectView()->updatePalette();
4003 QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
4005 // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
4006 const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
4007 const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
4008 const QSize bitsSize(24, 2);
4009 const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
4010 const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
4012 QPixmap pixmap(23, 16);
4013 pixmap.fill(Qt::black); // ### use some color other than black for borders?
4015 KConfigGroup group(config, "WM");
4016 QPainter p(&pixmap);
4017 KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
4018 p.fillRect(1, 1, 7, 7, windowScheme.background());
4019 p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
4021 KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
4022 p.fillRect(8, 1, 7, 7, buttonScheme.background());
4023 p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
4025 p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
4026 p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
4028 KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
4029 p.fillRect(1, 8, 7, 7, viewScheme.background());
4030 p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
4032 KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
4033 p.fillRect(8, 8, 7, 7, selectionScheme.background());
4034 p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
4036 p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
4037 p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
4043 void MainWindow::slotSwitchMonitors()
4045 m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive());
4046 if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
4047 else m_projectList->focusTree();
4050 void MainWindow::slotSwitchFullscreen()
4052 if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
4053 else m_clipMonitor->slotSwitchFullScreen();
4056 void MainWindow::slotInsertZoneToTree()
4058 if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
4059 QStringList info = m_clipMonitor->getZoneInfo();
4060 m_projectList->slotAddClipCut(info.at(0), info.at(1).toInt(), info.at(2).toInt());
4063 void MainWindow::slotInsertZoneToTimeline()
4065 if (m_activeTimeline == NULL || m_clipMonitor->activeClip() == NULL) return;
4066 QStringList info = m_clipMonitor->getZoneInfo();
4067 m_activeTimeline->projectView()->insertClipCut(m_clipMonitor->activeClip(), info.at(1).toInt(), info.at(2).toInt());
4071 void MainWindow::slotDeleteProjectClips(QStringList ids, QMap<QString, QString> folderids)
4073 if (m_activeDocument && m_activeTimeline) {
4074 if (!ids.isEmpty()) {
4075 for (int i = 0; i < ids.size(); ++i) {
4076 m_activeTimeline->slotDeleteClip(ids.at(i));
4078 m_activeDocument->clipManager()->slotDeleteClips(ids);
4080 if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids);
4081 m_activeDocument->setModified(true);
4085 void MainWindow::slotShowTitleBars(bool show)
4087 QList <QDockWidget *> docks = findChildren<QDockWidget *>();
4088 for (int i = 0; i < docks.count(); i++) {
4089 QDockWidget* dock = docks.at(i);
4091 dock->setTitleBarWidget(0);
4093 if (!dock->isFloating()) {
4094 dock->setTitleBarWidget(new QWidget);
4098 KdenliveSettings::setShowtitlebars(show);
4101 void MainWindow::slotSwitchTitles()
4103 slotShowTitleBars(!KdenliveSettings::showtitlebars());
4106 QString MainWindow::getMimeType()
4108 QString mimetype = "application/x-kdenlive";
4109 KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
4110 if (!mime) mimetype = "*.kdenlive";
4114 void MainWindow::slotMonitorRequestRenderFrame(bool request)
4117 m_projectMonitor->render->sendFrameForAnalysis = true;
4120 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4121 if (m_gfxScopesList.at(i)->isVisible() && tabifiedDockWidgets(m_gfxScopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4128 qDebug() << "Any scope accepting new frames? " << request;
4131 m_projectMonitor->render->sendFrameForAnalysis = false;
4135 void MainWindow::slotUpdateGfxScopeFrameRequest()
4137 // We need a delay to make sure widgets are hidden after a close event for example
4138 QTimer::singleShot(500, this, SLOT(slotDoUpdateGfxScopeFrameRequest()));
4141 void MainWindow::slotDoUpdateGfxScopeFrameRequest()
4144 bool request = false;
4145 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4146 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled()) {
4147 kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->widgetName();
4153 if (!m_projectMonitor->effectSceneDisplayed()) {
4154 m_projectMonitor->render->sendFrameForAnalysis = false;
4156 m_clipMonitor->render->sendFrameForAnalysis = false;
4158 m_projectMonitor->render->sendFrameForAnalysis = true;
4159 m_clipMonitor->render->sendFrameForAnalysis = true;
4163 void MainWindow::slotUpdateAudioScopeFrameRequest()
4165 QTimer::singleShot(500, this, SLOT(slotDoUpdateAudioScopeFrameRequest()));
4168 void MainWindow::slotDoUpdateAudioScopeFrameRequest()
4170 bool request = false;
4171 for (int i = 0; i < m_audioScopesList.count(); i++) {
4172 if (!m_audioScopesList.at(i)->visibleRegion().isEmpty() && m_audioScopesList.at(i)->autoRefreshEnabled()) {
4173 kDebug() << "AUDIO SCOPE VISIBLE: " << m_audioScopesList.at(i)->widgetName();
4178 // Handle audio signal separately (no common interface)
4179 if (!m_audiosignal->visibleRegion().isEmpty() && m_audiosignal->monitoringEnabled()) {
4180 kDebug() << "AUDIO SCOPE VISIBLE: " << "audiosignal";
4184 qDebug() << "Scopes Requesting Audio data: " << request;
4186 KdenliveSettings::setMonitor_audio(request);
4187 m_monitorManager->slotUpdateAudioMonitoring();
4190 void MainWindow::slotUpdateColorScopes()
4192 bool request = false;
4193 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4194 // Check if we need the renderer to send a new frame for update
4195 if (!m_gfxScopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
4196 static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
4199 if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
4200 else m_projectMonitor->render->sendFrameUpdate();
4204 void MainWindow::slotOpenStopmotion()
4206 if (m_stopmotion == NULL) {
4207 m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
4208 connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
4209 for (int i = 0; i < m_gfxScopesList.count(); i++) {
4210 // Check if we need the renderer to send a new frame for update
4211 /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
4212 connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_gfxScopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
4213 //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
4216 m_stopmotion->show();
4219 void MainWindow::slotDeleteClip(const QString &id)
4221 QList <ClipProperties *> list = findChildren<ClipProperties *>();
4222 for (int i = 0; i < list.size(); ++i) {
4223 list.at(i)->disableClipId(id);
4225 m_projectList->slotDeleteClip(id);
4228 void MainWindow::slotUpdateProxySettings()
4230 if (m_renderWidget) m_renderWidget->updateProxyConfig(m_projectList->useProxy());
4231 if (KdenliveSettings::enableproxy())
4232 KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/");
4233 m_projectList->updateProxyConfig();
4236 void MainWindow::slotInsertNotesTimecode()
4238 int frames = m_projectMonitor->render->seekPosition().frames(m_activeDocument->fps());
4239 QString position = m_activeDocument->timecode().getTimecodeFromFrames(frames);
4240 m_notesWidget->insertHtml("<a href=\"" + QString::number(frames) + "\">" + position + "</a> ");
4243 #include "mainwindow.moc"