]> git.sesse.net Git - kdenlive/blobdiff - src/mainwindow.cpp
Audio Spectrum: Moved FFT calculation to FFTTools for re-use
[kdenlive] / src / mainwindow.cpp
index 2963da2cfc3742cf0b7debba1be65005897d5b33..517acdc30282dc8034f44acd75fa2f46f89eb0d2 100644 (file)
 #include "kdenlive-config.h"
 #include "cliptranscode.h"
 #include "ui_templateclip_ui.h"
-#include "vectorscope.h"
-#include "waveform.h"
-#include "rgbparade.h"
-#include "histogram.h"
+#include "colorscopes/vectorscope.h"
+#include "colorscopes/waveform.h"
+#include "colorscopes/rgbparade.h"
+#include "colorscopes/histogram.h"
+#include "audiospectrum.h"
+#include "spectrogram.h"
 
 #include <KApplication>
 #include <KAction>
@@ -96,6 +98,7 @@
 #endif /* KDE_IS_VERSION(4,3,80) */
 #include <KToolBar>
 #include <KColorScheme>
+#include <KProgressDialog>
 
 #include <QTextStream>
 #include <QTimer>
 static const char version[] = VERSION;
 
 static const int ID_TIMELINE_POS = 0;
-
 namespace Mlt
 {
 class Producer;
 };
 
+Q_DECLARE_METATYPE(QVector<int16_t>)
+
 EffectsList MainWindow::videoEffects;
 EffectsList MainWindow::audioEffects;
 EffectsList MainWindow::customEffects;
@@ -129,9 +133,10 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
 #ifndef NO_JOGSHUTTLE
     m_jogProcess(NULL),
 #endif /* NO_JOGSHUTTLE */
-    m_findActivated(false)
+    m_findActivated(false),
+    m_stopmotion(NULL)
 {
-
+    qRegisterMetaType<QVector<int16_t> > ();
     // Create DBus interface
     new MainWindowAdaptor(this);
     QDBusConnection dbus = QDBusConnection::sessionBus();
@@ -180,7 +185,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
 
     m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this);
     m_clipMonitorDock->setObjectName("clip_monitor");
-    m_clipMonitor = new Monitor("clip", m_monitorManager, QString());
+    m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), m_timelineArea);
     m_clipMonitorDock->setWidget(m_clipMonitor);
     addDockWidget(Qt::TopDockWidgetArea, m_clipMonitorDock);
 
@@ -274,14 +279,48 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     m_audiosignalDock->setObjectName("audiosignal");
     m_audiosignalDock->setWidget(m_audiosignal);
     addDockWidget(Qt::TopDockWidgetArea, m_audiosignalDock);
-    if (m_projectMonitor){
-       connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)) );
+    connect(m_audiosignal, SIGNAL(updateAudioMonitoring()), m_monitorManager, SLOT(slotUpdateAudioMonitoring()));
+    /*if (m_projectMonitor) {
+        connect(m_projectMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
     }
-    if (m_clipMonitor){
-       connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)) );
-    }
-    //connect(m_histogramDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
-    //connect(m_histogram, SIGNAL(requestAutoRefresh(bool)), this, SLOT(slotUpdateScopeFrameRequest()));
+    if (m_clipMonitor) {
+        connect(m_clipMonitor->render, SIGNAL(showAudioSignal(const QByteArray&)), m_audiosignal, SLOT(showAudio(const QByteArray&)));
+    }*/
+
+    m_audioSpectrum = new AudioSpectrum();
+    m_audioSpectrumDock = new QDockWidget(i18n("AudioSpectrum"), this);
+    m_audioSpectrumDock->setObjectName(m_audioSpectrum->widgetName());
+    m_audioSpectrumDock->setWidget(m_audioSpectrum);
+    addDockWidget(Qt::TopDockWidgetArea, m_audioSpectrumDock);
+
+    m_spectrogram = new Spectrogram();
+    m_spectrogramDock = new QDockWidget(i18n("Spectrogram"), this);
+    m_spectrogramDock->setObjectName(m_spectrogram->widgetName());
+    m_spectrogramDock->setWidget(m_spectrogram);
+    addDockWidget(Qt::TopDockWidgetArea, m_spectrogramDock);
+
+    // Connect the audio signal to the audio scope slots
+    bool b = true;
+    if (m_projectMonitor) {
+        qDebug() << "project monitor connected";
+        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
+                     m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
+        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, const int&, const int&, const int&)),
+                     m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, const int&, const int&, const int&)));
+        b &= connect(m_projectMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
+                     m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
+    }
+    if (m_clipMonitor) {
+        qDebug() << "clip monitor connected";
+        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>, int, int, int)),
+                     m_audioSpectrum, SLOT(slotReceiveAudio(QVector<int16_t>, int, int, int)));
+        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(const QVector<int16_t>&, int, int, int)),
+                     m_audiosignal, SLOT(slotReceiveAudio(const QVector<int16_t>&, int, int, int)));
+        b &= connect(m_clipMonitor->render, SIGNAL(audioSamplesSignal(QVector<int16_t>,int,int,int)),
+                     m_spectrogram, SLOT(slotReceiveAudio(QVector<int16_t>,int,int,int)));
+    }
+    // Ensure connections were set up correctly
+    Q_ASSERT(b);
 
     m_undoViewDock = new QDockWidget(i18n("Undo History"), this);
     m_undoViewDock->setObjectName("undo_history");
@@ -339,6 +378,20 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
         layoutActions->addAction("save_layout" + QString::number(i), save);
     }
 
+    KAction *action;
+    // Stop motion actions. Beware of the order, we MUST use the same order in stopmotion/stopmotion.cpp
+    m_stopmotion_actions = new KActionCategory(i18n("Stop Motion"), actionCollection());
+    action = new KAction(KIcon("media-record"), i18n("Capture frame"), this);
+    action->setShortcut(Qt::Key_Space);
+    //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+    m_stopmotion_actions->addAction("stopmotion_capture", action);
+    action = new KAction(i18n("Switch live / captured frame"), this);
+    //action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+    m_stopmotion_actions->addAction("stopmotion_switch", action);
+    action = new KAction(KIcon("edit-paste"), i18n("Show last frame over video"), this);
+    action->setCheckable(true);
+    action->setChecked(false);
+    m_stopmotion_actions->addAction("stopmotion_overlay", action);
     setupGUI();
 
 
@@ -377,7 +430,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
                                       static_cast<QMenu*>(factory()->container("transcoders", this)),
                                       clipInTimeline);
 
-    KAction *action;
     // build themes menus
     QMenu *themesMenu = static_cast<QMenu*>(factory()->container("themes_menu", this));
     QActionGroup *themegroup = new QActionGroup(this);
@@ -501,9 +553,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor);
     slotConnectMonitors();
 
-    // Disable drop B frames, see Kdenlive issue #1330, see also kdenlivesettingsdialog.cpp
-    KdenliveSettings::setDropbframes(false);
-
     // Open or create a file.  Command line argument passed in Url has
     // precedence, then "openlastproject", then just a plain empty file.
     // If opening Url fails, openlastproject will _not_ be used.
@@ -531,10 +580,16 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
     activateShuttleDevice();
 #endif /* NO_JOGSHUTTLE */
     m_projectListDock->raise();
+
+    actionCollection()->addAssociatedWidget(m_clipMonitor->container());
+    actionCollection()->addAssociatedWidget(m_projectMonitor->container());
 }
 
 MainWindow::~MainWindow()
 {
+    if (m_stopmotion) {
+        delete m_stopmotion;
+    }
     m_effectStack->slotClipItemSelected(NULL, 0);
     m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
 
@@ -554,7 +609,7 @@ MainWindow::~MainWindow()
 void MainWindow::queryQuit()
 {
     if (queryClose()) {
-        kapp->quit();
+        close();
     }
 }
 
@@ -734,7 +789,6 @@ void MainWindow::activateShuttleDevice()
     connect(m_jogProcess, SIGNAL(forward1()), m_monitorManager, SLOT(slotForwardOneFrame()));
     connect(m_jogProcess, SIGNAL(rewind(double)), m_monitorManager, SLOT(slotRewind(double)));
     connect(m_jogProcess, SIGNAL(forward(double)), m_monitorManager, SLOT(slotForward(double)));
-    connect(m_jogProcess, SIGNAL(stop()), m_monitorManager, SLOT(slotPlay()));
     connect(m_jogProcess, SIGNAL(button(int)), this, SLOT(slotShuttleButton(int)));
 }
 
@@ -853,7 +907,7 @@ void MainWindow::setupActions()
 
     KActionCollection* collection = actionCollection();
     m_timecodeFormat = new KComboBox(this);
-    m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
+    m_timecodeFormat->addItem(i18n("hh:mm:ss:ff"));
     m_timecodeFormat->addItem(i18n("Frames"));
     if (KdenliveSettings::frametimecode()) m_timecodeFormat->setCurrentIndex(1);
     connect(m_timecodeFormat, SIGNAL(activated(int)), this, SLOT(slotUpdateTimecodeFormat(int)));
@@ -1169,6 +1223,11 @@ void MainWindow::setupActions()
     switchMon->setShortcut(Qt::Key_T);
     connect(switchMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchMonitors()));
 
+    KAction *fullMon = collection->addAction("monitor_fullscreen");
+    fullMon->setText(i18n("Switch monitor fullscreen"));
+    fullMon->setIcon(KIcon("view-fullscreen"));
+    connect(fullMon, SIGNAL(triggered(bool)), this, SLOT(slotSwitchFullscreen()));
+
     KAction *insertTree = collection->addAction("insert_project_tree");
     insertTree->setText(i18n("Insert zone in project tree"));
     insertTree->setShortcut(Qt::CTRL + Qt::Key_I);
@@ -1355,6 +1414,11 @@ void MainWindow::setupActions()
     collection->addAction("edit_clip_marker", editClipMarker);
     connect(editClipMarker, SIGNAL(triggered(bool)), this, SLOT(slotEditClipMarker()));
 
+    KAction *addMarkerGuideQuickly = new KAction(KIcon("bookmark-new"), i18n("Add Marker/Guide quickly"), this);
+    addMarkerGuideQuickly->setShortcut(Qt::Key_Asterisk);
+    collection->addAction("add_marker_guide_quickly", addMarkerGuideQuickly);
+    connect(addMarkerGuideQuickly, SIGNAL(triggered(bool)), this, SLOT(slotAddMarkerGuideQuickly()));
+
     KAction* splitAudio = new KAction(KIcon("document-new"), i18n("Split Audio"), this);
     collection->addAction("split_audio", splitAudio);
     connect(splitAudio, SIGNAL(triggered(bool)), this, SLOT(slotSplitAudio()));
@@ -1520,6 +1584,10 @@ void MainWindow::setupActions()
     connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
     reloadClip->setEnabled(false);
 
+    QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
+    collection->addAction("stopmotion", stopMotion);
+    connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
+
     QMenu *addClips = new QMenu();
     addClips->addAction(addClip);
     addClips->addAction(addColorClip);
@@ -1826,15 +1894,8 @@ bool MainWindow::saveFileAs(const QString &outputFileName)
 {
     QString currentSceneList;
     m_monitorManager->stopActiveMonitor();
-    if (KdenliveSettings::dropbframes()) {
-        KdenliveSettings::setDropbframes(false);
-        m_activeDocument->clipManager()->updatePreviewSettings();
-        currentSceneList = m_projectMonitor->sceneList();
-        KdenliveSettings::setDropbframes(true);
-        m_activeDocument->clipManager()->updatePreviewSettings();
-    } else currentSceneList = m_projectMonitor->sceneList();
-
-    if (m_activeDocument->saveSceneList(outputFileName, currentSceneList) == false)
+
+    if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
         return false;
 
     // Save timeline thumbnails
@@ -1947,7 +2008,27 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
 {
     if (!m_timelineArea->isEnabled()) return;
     m_fileRevert->setEnabled(true);
-    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this);
+
+    // Recreate stopmotion widget on document change
+    if (m_stopmotion) {
+        delete m_stopmotion;
+        m_stopmotion = NULL;
+    }
+
+    KProgressDialog progressDialog(this, i18n("Loading project"), i18n("Loading project"));
+    progressDialog.setAllowCancel(false);
+    progressDialog.progressBar()->setMaximum(4);
+    progressDialog.show();
+    progressDialog.progressBar()->setValue(0);
+    qApp->processEvents();
+
+    KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
+
+    progressDialog.progressBar()->setValue(1);
+    progressDialog.progressBar()->setMaximum(4);
+    progressDialog.setLabelText(i18n("Loading project"));
+    qApp->processEvents();
+
     if (stale == NULL) {
         stale = new KAutoSaveFile(url, doc);
         doc->m_autosave = stale;
@@ -1958,8 +2039,16 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
         stale->setParent(doc);
     }
     connectDocumentInfo(doc);
+
+    progressDialog.progressBar()->setValue(2);
+    qApp->processEvents();
+
     bool ok;
     TrackView *trackView = new TrackView(doc, &ok, this);
+
+    progressDialog.progressBar()->setValue(3);
+    qApp->processEvents();
+
     m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
     if (!ok) {
         m_timelineArea->setEnabled(false);
@@ -1978,6 +2067,8 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
     m_projectMonitor->adjustRulerSize(trackView->duration());
     m_projectMonitor->slotZoneMoved(trackView->inPoint(), trackView->outPoint());
     m_clipMonitor->refreshMonitor(true);
+
+    progressDialog.progressBar()->setValue(4);
 }
 
 void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
@@ -2120,6 +2211,12 @@ void MainWindow::slotUpdateProjectProfile(const QString &profile)
 {
     double dar = m_activeDocument->dar();
 
+    // Recreate the stopmotion widget if profile changes
+    if (m_stopmotion) {
+        delete m_stopmotion;
+        m_stopmotion = NULL;
+    }
+
     // Deselect current effect / transition
     m_effectStack->slotClipItemSelected(NULL, 0);
     m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
@@ -2257,7 +2354,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
             disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
             disconnect(m_activeDocument, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
-            disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
+            disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
             disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
             disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
             disconnect(m_activeDocument, SIGNAL(deleteTimelineClip(const QString &)), m_activeTimeline, SLOT(slotDeleteClip(const QString &)));
@@ -2294,7 +2391,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
         }
         //m_activeDocument->setRenderer(NULL);
         disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
-        disconnect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
+        disconnect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
         m_clipMonitor->stop();
     }
     KdenliveSettings::setCurrent_profile(doc->profilePath());
@@ -2304,7 +2401,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     m_transitionConfig->updateProjectFormat(doc->mltProfile(), doc->timecode(), doc->tracksList());
     m_effectStack->updateProjectFormat(doc->mltProfile(), doc->timecode());
     connect(m_projectList, SIGNAL(clipSelected(DocClipBase *, QPoint)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint)));
-    connect(m_projectList, SIGNAL(refreshClip()), m_clipMonitor, SLOT(refreshMonitor()));
+    connect(m_projectList, SIGNAL(refreshClip()), m_monitorManager, SLOT(slotRefreshCurrentMonitor()));
     connect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), trackView->projectView(), SLOT(slotUpdateClip(const QString &, bool)));
 
     connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified()));
@@ -2331,7 +2428,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
 
     connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool)));
     connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList()));
-    connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), m_projectList, SLOT(slotDeleteClip(const QString &)));
+    connect(doc, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
     connect(doc, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
     connect(doc, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
 
@@ -2406,7 +2503,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
 #ifndef   Q_WS_MAC
     m_recMonitor->slotUpdateCaptureFolder(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash));
 #endif
-    if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings();
     //Update the mouse position display so it will display in DF/NDF format by default based on the project setting.
     slotUpdateMousePosition(0);
     // set tool to select tool
@@ -2440,6 +2536,7 @@ void MainWindow::slotPreferences(int page, int option)
      * cached, in which case you want to display the cached dialog
      * instead of creating another one
      */
+    if (m_stopmotion) m_stopmotion->slotLive(false);
     if (KConfigDialog::showDialog("settings")) {
         KdenliveSettingsDialog* d = static_cast <KdenliveSettingsDialog*>(KConfigDialog::exists("settings"));
         if (page != -1) d->showPage(page, option);
@@ -2452,11 +2549,9 @@ void MainWindow::slotPreferences(int page, int option)
     connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
     //connect(dialog, SIGNAL(doResetProfile()), this, SLOT(slotDetectAudioDriver()));
     connect(dialog, SIGNAL(doResetProfile()), m_monitorManager, SLOT(slotResetProfiles()));
-    connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
 #ifndef Q_WS_MAC
     connect(dialog, SIGNAL(updateCaptureFolder()), this, SLOT(slotUpdateCaptureFolder()));
 #endif
-    //connect(dialog, SIGNAL(updatePreviewSettings()), this, SLOT(slotUpdatePreviewSettings()));
     dialog->show();
     if (page != -1) dialog->showPage(page, option);
 }
@@ -2470,14 +2565,6 @@ void MainWindow::slotUpdateCaptureFolder()
 #endif
 }
 
-void MainWindow::slotUpdatePreviewSettings()
-{
-    if (m_activeDocument) {
-        m_clipMonitor->slotSetXml(NULL);
-        m_activeDocument->updatePreviewSettings();
-    }
-}
-
 void MainWindow::updateConfiguration()
 {
     //TODO: we should apply settings to all projects, not only the current one
@@ -2689,6 +2776,26 @@ void MainWindow::slotEditClipMarker()
     }
 }
 
+void MainWindow::slotAddMarkerGuideQuickly()
+{
+    if (!m_activeTimeline || !m_activeDocument)
+        return;
+
+    if (m_clipMonitor->isActive()) {
+        DocClipBase *clip = m_clipMonitor->activeClip();
+        GenTime pos = m_clipMonitor->position();
+
+        if (!clip) {
+            m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
+            return;
+        }
+
+        m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false));
+    } else {
+        m_activeTimeline->projectView()->slotAddGuide(false);
+    }
+}
+
 void MainWindow::slotAddGuide()
 {
     if (m_activeTimeline)
@@ -3003,6 +3110,13 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
                 // duration changed, we need to update duration
                 newprops.insert("out", QString::number(dia_ui->outPoint()));
             }
+            if (!path.isEmpty()) {
+                // we are editing an external file, asked if we want to detach from that file or save the result to that title file.
+                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) {
+                    // save to external file
+                    dia_ui->saveTitle(path);
+                } else newprops.insert("resource", QString());
+            }
             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
             m_activeDocument->commandStack()->push(command);
             //m_activeTimeline->projectView()->slotUpdateClip(clip->getId());
@@ -3015,19 +3129,23 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
     }
 
     // any type of clip but a title
-    ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
-    connect(&dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
-    if (dia.exec() == QDialog::Accepted) {
-        QMap <QString, QString> newprops = dia.properties();
-        if (newprops.isEmpty()) return;
-        EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
-        m_activeDocument->commandStack()->push(command);
-        m_activeDocument->setModified();
+    ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
+    connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString)));
+    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)));
+    dia->show();
+}
 
-        if (dia.needsTimelineRefresh()) {
-            // update clip occurences in timeline
-            m_activeTimeline->projectView()->slotUpdateClip(clip->getId(), dia.needsTimelineReload());
-        }
+
+void MainWindow::slotApplyNewClipProperties(const QString id, QMap <QString, QString> props, QMap <QString, QString> newprops, bool refresh, bool reload)
+{
+    if (newprops.isEmpty()) return;
+    EditClipCommand *command = new EditClipCommand(m_projectList, id, props, newprops, true);
+    m_activeDocument->commandStack()->push(command);
+    m_activeDocument->setModified();
+
+    if (refresh) {
+        // update clip occurences in timeline
+        m_activeTimeline->projectView()->slotUpdateClip(id, reload);
     }
 }
 
@@ -3791,6 +3909,12 @@ void MainWindow::slotSwitchMonitors()
     else m_projectList->focusTree();
 }
 
+void MainWindow::slotSwitchFullscreen()
+{
+    if (m_projectMonitor->isActive()) m_projectMonitor->slotSwitchFullScreen();
+    else m_clipMonitor->slotSwitchFullScreen();
+}
+
 void MainWindow::slotInsertZoneToTree()
 {
     if (!m_clipMonitor->isActive() || m_clipMonitor->activeClip() == NULL) return;
@@ -3824,12 +3948,11 @@ void MainWindow::slotShowTitleBars(bool show)
 {
     QList <QDockWidget *> docks = findChildren<QDockWidget *>();
     for (int i = 0; i < docks.count(); i++) {
-        QDockWidget* dock=docks.at(i);
-        qDebug() << dock->objectName() ;
-        if (show){
-            dock->setTitleBarWidget(0);        
-        }else{
-            if (!dock->isFloating()){
+        QDockWidget* dock = docks.at(i);
+        if (show) {
+            dock->setTitleBarWidget(0);
+        } else {
+            if (!dock->isFloating()) {
                 dock->setTitleBarWidget(new QWidget);
             }
         }
@@ -3857,7 +3980,7 @@ void MainWindow::slotMonitorRequestRenderFrame(bool request)
         return;
     } else {
         for (int i = 0; i < m_scopesList.count(); i++) {
-            if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
+            if (m_scopesList.at(i)->isVisible() && tabifiedDockWidgets(m_scopesList.at(i)).isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
                 request = true;
                 break;
             }
@@ -3879,8 +4002,8 @@ void MainWindow::slotDoUpdateScopeFrameRequest()
     // Check scopes
     bool request = false;
     for (int i = 0; i < m_scopesList.count(); i++) {
-        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
-            kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
+        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled()) {
+            kDebug() << "SCOPE VISIBLE: " << static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->widgetName();
             request = true;
             break;
         }
@@ -3900,8 +4023,8 @@ void MainWindow::slotUpdateColorScopes()
     bool request = false;
     for (int i = 0; i < m_scopesList.count(); i++) {
         // Check if we need the renderer to send a new frame for update
-        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
-        static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
+        if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;
+        static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget())->slotActiveMonitorChanged(m_clipMonitor->isActive());
     }
     if (request) {
         if (m_clipMonitor->isActive()) m_clipMonitor->render->sendFrameUpdate();
@@ -3909,5 +4032,29 @@ void MainWindow::slotUpdateColorScopes()
     }
 }
 
+void MainWindow::slotOpenStopmotion()
+{
+    if (m_stopmotion == NULL) {
+        m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
+        connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
+        for (int i = 0; i < m_scopesList.count(); i++) {
+            // Check if we need the renderer to send a new frame for update
+            /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
+            connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractGfxScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
+            //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
+        }
+    }
+    m_stopmotion->show();
+}
+
+void MainWindow::slotDeleteClip(const QString &id)
+{
+    QList <ClipProperties *> list = findChildren<ClipProperties *>();
+    for (int i = 0; i < list.size(); ++i) {
+        list.at(i)->disableClipId(id);
+    }
+    m_projectList->slotDeleteClip(id);
+}
+
 #include "mainwindow.moc"