]> git.sesse.net Git - kdenlive/blobdiff - src/monitor.cpp
const'ref
[kdenlive] / src / monitor.cpp
index 9b118b273d992a44e5118c5e3884661dad436a93..0920da0a781ba1d289692ecc93ea7909b0cce1a1 100644 (file)
@@ -31,6 +31,7 @@
 #include <KFileDialog>
 #include <KApplication>
 #include <KMessageBox>
+#include <KSelectAction>
 
 #include <QMouseEvent>
 #include <QStylePainter>
 #include <QLabel>
 #include <QIntValidator>
 #include <QVBoxLayout>
+#include <QSlider>
 
 
 #define SEEK_INACTIVE (-1)
 
 
 Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile, QWidget *parent) :
-    AbstractMonitor(id, manager, parent),
-    render(NULL),
-    m_currentClip(NULL),
-    m_overlay(NULL),
-    m_scale(1),
-    m_length(2),
-    m_dragStarted(false),
-    m_contextMenu(NULL),
-    m_effectWidget(NULL),
-    m_selectedClip(NULL),
-    m_loopClipTransition(true),
+    AbstractMonitor(id, manager, parent)
+    , render(NULL)
+    , m_currentClip(NULL)
+    , m_overlay(NULL)
+    , m_scale(1)
+    , m_length(2)
+    , m_dragStarted(false)
+    , m_loopClipAction(NULL)
+    , m_contextMenu(NULL)
+    , m_effectWidget(NULL)
+    , m_selectedClip(NULL)
+    , m_loopClipTransition(true)
 #ifdef USE_OPENGL
-    m_glWidget(NULL),
+    , m_glWidget(NULL)
 #endif
-    m_editMarker(NULL)
+    m_editMarker(NULL)
 {
     QVBoxLayout *layout = new QVBoxLayout;
     layout->setContentsMargins(0, 0, 0, 0);
@@ -118,7 +121,7 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil
             m_markerMenu = new QMenu(i18n("Go to marker..."), this);
             m_markerMenu->setEnabled(false);
             m_configMenu->addMenu(m_markerMenu);
-            connect(m_markerMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToMarker(QAction *)));
+            connect(m_markerMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToMarker(QAction*)));
         }
         m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"), this, SLOT(slotSetSizeOneToOne()));
         m_configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"), this, SLOT(slotSetSizeOneToTwo()));
@@ -146,7 +149,8 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil
     setLayout(layout);
     setMinimumHeight(200);
 
-    if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
+    if (profile.isEmpty())
+        profile = KdenliveSettings::current_profile();
 
     bool monitorCreated = false;
 #ifdef Q_WS_MAC
@@ -194,7 +198,7 @@ Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profil
 
     if (id == Kdenlive::projectMonitor) {
         m_effectWidget = new MonitorEditWidget(render, videoBox);
-       connect(m_effectWidget, SIGNAL(showEdit(bool, bool)), this, SLOT(slotShowEffectScene(bool, bool)));
+       connect(m_effectWidget, SIGNAL(showEdit(bool,bool)), this, SLOT(slotShowEffectScene(bool,bool)));
         m_toolbar->addAction(m_effectWidget->getVisibilityAction());
         videoBox->layout()->addWidget(m_effectWidget);
         m_effectWidget->hide();
@@ -226,7 +230,7 @@ QWidget *Monitor::container()
 }
 
 #ifdef USE_OPENGL
-bool Monitor::createOpenGlWidget(QWidget *parent, const QString profile)
+bool Monitor::createOpenGlWidget(QWidget *parent, const QString &profile)
 {
     render = new Render(id(), 0, profile, this);
     m_glWidget = new VideoGLWidget(parent);
@@ -250,7 +254,7 @@ void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMe
     if (markerMenu) {
         m_contextMenu->addMenu(markerMenu);
         QList <QAction *>list = markerMenu->actions();
-        for (int i = 0; i < list.count(); i++) {
+        for (int i = 0; i < list.count(); ++i) {
             if (list.at(i)->data().toString() == "edit_marker") {
                 m_editMarker = list.at(i);
                 break;
@@ -293,10 +297,9 @@ void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMe
     dropFrames->setCheckable(true);
     dropFrames->setChecked(true);
     connect(dropFrames, SIGNAL(toggled(bool)), this, SLOT(slotSwitchDropFrames(bool)));
-
+    
     m_configMenu->addAction(showTips);
     m_configMenu->addAction(dropFrames);
-
 }
 
 void Monitor::slotGoToMarker(QAction *action)
@@ -372,7 +375,7 @@ void Monitor::updateMarkers(DocClipBase *source)
         QList <CommentedTime> markers = m_currentClip->commentedSnapMarkers();
         if (!markers.isEmpty()) {
             QList <int> marks;
-            for (int i = 0; i < markers.count(); i++) {
+            for (int i = 0; i < markers.count(); ++i) {
                 int pos = (int) markers.at(i).time().frames(m_monitorManager->timecode().fps());
                 marks.append(pos);
                 QString position = m_monitorManager->timecode().getTimecode(markers.at(i).time()) + ' ' + markers.at(i).comment();
@@ -385,6 +388,11 @@ void Monitor::updateMarkers(DocClipBase *source)
     }
 }
 
+void Monitor::setMarkers(const QList<CommentedTime> &markers)
+{
+    m_ruler->setMarkers(markers);
+}
+
 void Monitor::slotSeekToPreviousSnap()
 {
     if (m_currentClip) slotSeek(getSnapForPos(true).frames(m_monitorManager->timecode().fps()));
@@ -453,6 +461,7 @@ void Monitor::slotSetZoneEnd()
 // virtual
 void Monitor::mousePressEvent(QMouseEvent * event)
 {
+    if (render) render->setActiveMonitor();
     if (event->button() != Qt::RightButton) {
         if (videoBox->geometry().contains(event->pos()) && (!m_overlay || !m_overlay->underMouse())) {
             m_dragStarted = true;
@@ -603,13 +612,13 @@ void Monitor::slotExtractCurrentFrame()
     fs->setMode(KFile::File);
     fs->setConfirmOverwrite(true);
     fs->setKeepLocation(true);
-    fs->exec();
-    QString path;
-    if (fs) path = fs->selectedFile();
-    delete fs;
-    if (!path.isEmpty()) {
-        frame.save(path);
+    if (fs->exec()) {
+        QString path = fs->selectedFile();
+        if (!path.isEmpty()) {
+            frame.save(path);
+        }
     }
+    delete fs;
 }
 
 void Monitor::setTimePos(const QString &pos)
@@ -865,7 +874,7 @@ void Monitor::slotLoopClip()
 void Monitor::updateClipProducer(Mlt::Producer *prod)
 {
     if (render == NULL) return;
-   render->setProducer(prod, render->seekFramePosition());
+    render->setProducer(prod, render->seekFramePosition());
 }
 
 void Monitor::slotSetClipProducer(DocClipBase *clip, QPoint zone, bool forceUpdate, int position)
@@ -873,7 +882,6 @@ void Monitor::slotSetClipProducer(DocClipBase *clip, QPoint zone, bool forceUpda
     if (render == NULL) return;
     if (clip == NULL && m_currentClip != NULL) {
        m_currentClip->lastSeekPosition = render->seekFramePosition();
-        kDebug()<<"// SETTING NULL CLIP MONITOR";
         m_currentClip = NULL;
         m_length = -1;
         render->setProducer(NULL, -1);
@@ -890,7 +898,7 @@ void Monitor::slotSetClipProducer(DocClipBase *clip, QPoint zone, bool forceUpda
         if (render->setProducer(prod, position) == -1) {
             // MLT CONSUMER is broken
             kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
-        }
+        } else start();
     } else {
         if (m_currentClip) {
             slotActivateMonitor();
@@ -924,7 +932,7 @@ void Monitor::slotSaveZone()
     //render->setSceneList(doc, 0);
 }
 
-void Monitor::setCustomProfile(const QString &profile, Timecode tc)
+void Monitor::setCustomProfile(const QString &profile, const Timecode &tc)
 {
     m_timePos->updateTimeCode(tc);
     if (render == NULL) return;
@@ -952,7 +960,7 @@ void Monitor::resetProfile(const QString &profile)
         m_effectWidget->resetProfile(render);
 }
 
-void Monitor::saveSceneList(QString path, QDomElement info)
+void Monitor::saveSceneList(const QString &path, const QDomElement &info)
 {
     if (render == NULL) return;
     render->saveSceneList(path, info);
@@ -964,7 +972,7 @@ const QString Monitor::sceneList()
     return render->sceneList();
 }
 
-void Monitor::setClipZone(QPoint pos)
+void Monitor::setClipZone(const QPoint &pos)
 {
     if (m_currentClip == NULL) return;
     m_currentClip->setZone(pos);
@@ -1032,10 +1040,10 @@ QStringList Monitor::getZoneInfo() const
 void Monitor::slotSetSelectedClip(AbstractClipItem* item)
 {
     if (item) {
-        m_loopClipAction->setEnabled(true);
+        if (m_loopClipAction) m_loopClipAction->setEnabled(true);
         m_selectedClip = item;
     } else {
-        m_loopClipAction->setEnabled(false);
+        if (m_loopClipAction) m_loopClipAction->setEnabled(false);
     }
 }
 
@@ -1147,7 +1155,7 @@ QString Monitor::getMarkerThumb(GenTime pos)
 {
     if (!m_currentClip) return QString();
     if (!m_currentClip->getClipHash().isEmpty()) {
-       QString url = m_monitorManager->getProjectFolder() + "thumbs/" + m_currentClip->getClipHash() + '#' + QString::number(pos.frames(m_monitorManager->timecode().fps())) + ".png";
+       QString url = m_monitorManager->getProjectFolder() + "thumbs/" + m_currentClip->getClipHash() + '#' + QString::number((int) pos.frames(m_monitorManager->timecode().fps())) + ".png";
         if (QFile::exists(url)) return url;
     }
     return QString();