]> git.sesse.net Git - kdenlive/commitdiff
Use enum instead of string to identify monitors
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Mar 2012 20:46:48 +0000 (21:46 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Mar 2012 20:46:48 +0000 (21:46 +0100)
15 files changed:
src/abstractmonitor.h
src/definitions.h
src/dvdwizardchapters.cpp
src/mainwindow.cpp
src/mltdevicecapture.cpp
src/monitor.cpp
src/monitor.h
src/monitormanager.cpp
src/monitormanager.h
src/recmonitor.cpp
src/recmonitor.h
src/renderer.cpp
src/renderer.h
src/stopmotion/stopmotion.cpp
src/stopmotion/stopmotion.h

index df3f9db1e3face99d97f5263c1ea24536c4a2569..8a6922048f745941a21f6706a6a1205738eb4d19 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef ABSTRACTMONITOR_H
 #define ABSTRACTMONITOR_H
 
+#include "definitions.h"
+
 #include <QObject>
 #include <QVector>
 #include <QWidget>
@@ -74,7 +76,7 @@ Q_OBJECT public:
      *  @param name A unique identifier for this renderer
      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
      *  @param profile The MLT profile used for the renderer (default one will be used if empty). */
-    AbstractRender(const QString &name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), m_name(name) {};
+    AbstractRender(Kdenlive::MONITORID name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), m_name(name) {};
 
     /** @brief Destroy the MLT Renderer. */
     virtual ~AbstractRender() {};
@@ -105,14 +107,17 @@ class AbstractMonitor : public QWidget
 {
     Q_OBJECT
 public:
-    AbstractMonitor(QWidget *parent = 0): QWidget(parent) {};
+    AbstractMonitor(Kdenlive::MONITORID id, QWidget *parent = 0): QWidget(parent) {m_id = id;};
+    Kdenlive::MONITORID id() {return m_id;};
     virtual ~AbstractMonitor() {};
     virtual AbstractRender *abstractRender() = 0;
-    virtual const QString name() const = 0;
 
 public slots:
     virtual void stop() = 0;
     virtual void start() = 0;
+
+protected:
+    Kdenlive::MONITORID m_id;
 };
 
 #endif
index 1b27cf8b6874c8b202cdae19ec791b3aef84ea58..2355f34869dfde53b750dd6e64ffa840d7dcf7a8 100644 (file)
 const int MAXCLIPDURATION = 15000;
 
 namespace Kdenlive {
-  const QString clipMonitor("clipMonitor");
+  enum MONITORID { noMonitor, clipMonitor, projectMonitor, recordMonitor, stopmotionMonitor, dvdMonitor };
+  /*const QString clipMonitor("clipMonitor");
   const QString recordMonitor("recordMonitor");
   const QString projectMonitor("projectMonitor");
-  const QString stopmotionMonitor("stopmotionMonitor");
+  const QString stopmotionMonitor("stopmotionMonitor");*/
 }
 
 enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11, RUBBERSELECTION = 12};
index 807e1803fee4c3a567ba828f3e630d87b90e4f14..52464b3f6a10bfa296046876f91dcc283923e024 100644 (file)
@@ -148,7 +148,7 @@ void DvdWizardChapters::setVobFiles(bool isPal, bool isWide, const QStringList &
     if (isWide) profile.append("_wide");
     m_manager->resetProfiles(m_tc);
     if (m_monitor == NULL) {
-        m_monitor = new Monitor("chapter", m_manager, profile, this);
+        m_monitor = new Monitor(Kdenlive::dvdMonitor, m_manager, profile, this);
         //m_monitor->start();
         QVBoxLayout *vbox = new QVBoxLayout;
         vbox->addWidget(m_monitor);
index 3de2d7722bd581d41373fb13943cd365adebdfd7..5dd50a74b10dfd043e2ea9014c45b4e56f01a149 100644 (file)
@@ -1650,7 +1650,7 @@ void MainWindow::setupActions()
     connect(proxyClip, SIGNAL(toggled(bool)), m_projectList, SLOT(slotProxyCurrentItem(bool)));
 
     QAction *stopMotion = new KAction(KIcon("image-x-generic"), i18n("Stop Motion Capture"), this);
-    collection.addAction(Kdenlive::stopmotionMonitor, stopMotion);
+    collection.addAction("stopmotion", stopMotion);
     connect(stopMotion , SIGNAL(triggered()), this, SLOT(slotOpenStopmotion()));
 
     QMenu *addClips = new QMenu();
index b45acbb7c8c56043e6bb6c9a4f6e1ed766a546d4..26dbf48d1dc2bc80fbf010f5845eba8fe456852b 100644 (file)
@@ -77,7 +77,7 @@ static void rec_consumer_frame_preview(mlt_consumer, MltDeviceCapture * self, ml
 
 
 MltDeviceCapture::MltDeviceCapture(QString profile, VideoPreviewContainer *surface, QWidget *parent) :
-    AbstractRender("capture", parent),
+    AbstractRender(Kdenlive::recordMonitor, parent),
     doCapture(0),
     sendFrameForAnalysis(false),
     processingImage(false),
index 1160dff2c1d8fe6ad1d1c9c05edf179d7b6b3eec..7786b5076d2176e933159da28f65a0357dc4c1a2 100644 (file)
 #include <QVBoxLayout>
 
 
-Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget *parent) :
-    AbstractMonitor(parent),
+Monitor::Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile, QWidget *parent) :
+    AbstractMonitor(id, parent),
     render(NULL),
-    m_name(name),
     m_monitorManager(manager),
     m_currentClip(NULL),
     m_ruler(new SmallRuler(m_monitorManager)),
@@ -55,6 +54,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
     m_length(0),
     m_dragStarted(false),
     m_monitorRefresh(NULL),
+    m_contextMenu(NULL),
     m_effectWidget(NULL),
     m_selectedClip(NULL),
     m_loopClipTransition(true),
@@ -77,13 +77,13 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
     // Monitor ruler
     layout->addWidget(m_ruler);
     // Tool bar buttons
-    m_toolbar = new QToolBar(name, this);
+    m_toolbar = new QToolBar(this);
     m_toolbar->setIconSize(QSize(s, s));
 
     m_playIcon = KIcon("media-playback-start");
     m_pauseIcon = KIcon("media-playback-pause");
 
-    if (name != "chapter") {
+    if (id != Kdenlive::dvdMonitor) {
         m_toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
         m_toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd()));
     } else {
@@ -108,7 +108,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
 
     playButton->setDefaultAction(m_playAction);
 
-    if (name != "chapter") {
+    if (id != Kdenlive::dvdMonitor) {
         QToolButton *configButton = new QToolButton(m_toolbar);
         m_configMenu = new QMenu(i18n("Misc..."), this);
         configButton->setIcon(KIcon("system-run"));
@@ -116,7 +116,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
         configButton->setPopupMode(QToolButton::QToolButton::InstantPopup);
         m_toolbar->addWidget(configButton);
 
-        if (name == Kdenlive::clipMonitor) {
+        if (id == Kdenlive::clipMonitor) {
             m_markerMenu = new QMenu(i18n("Go to marker..."), this);
             m_markerMenu->setEnabled(false);
             m_configMenu->addMenu(m_markerMenu);
@@ -166,7 +166,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
         m_monitorRefresh = new MonitorRefresh;
         lay->addWidget(m_monitorRefresh);
         m_videoBox->setLayout(lay);
-        render = new Render(m_name, (int) m_monitorRefresh->winId(), profile, this);
+        render = new Render(m_id, (int) m_monitorRefresh->winId(), profile, this);
         m_monitorRefresh->setRenderer(render);
     }
 #ifdef USE_OPENGL
@@ -182,7 +182,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
     connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
     connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
 
-    if (name != Kdenlive::clipMonitor) {
+    if (id != Kdenlive::clipMonitor) {
         connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
         connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
         connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
@@ -192,7 +192,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget
 
     if (m_monitorRefresh) m_monitorRefresh->show();
 
-    if (name == Kdenlive::projectMonitor) {
+    if (id == Kdenlive::projectMonitor) {
         m_effectWidget = new MonitorEditWidget(render, m_videoBox);
         m_toolbar->addAction(m_effectWidget->getVisibilityAction());
         lay->addWidget(m_effectWidget);
@@ -225,15 +225,10 @@ QWidget *Monitor::container()
     return m_videoBox;
 }
 
-const QString Monitor::name() const
-{
-    return m_name;
-}
-
 #ifdef USE_OPENGL
 bool Monitor::createOpenGlWidget(QWidget *parent, const QString profile)
 {
-    render = new Render(m_name, 0, profile, this);
+    render = new Render(id(), 0, profile, this);
     m_glWidget = new VideoGLWidget(parent);
     if (m_glWidget == NULL) {
         // Creation failed, we are in trouble...
@@ -271,7 +266,7 @@ void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMe
     }
 
     //TODO: add save zone to timeline monitor when fixed
-    if (m_name == Kdenlive::clipMonitor) {
+    if (m_id == Kdenlive::clipMonitor) {
         m_contextMenu->addMenu(m_markerMenu);
         m_contextMenu->addAction(KIcon("document-save"), i18n("Save zone"), this, SLOT(slotSaveZone()));
         QAction *extractZone = m_configMenu->addAction(KIcon("document-new"), i18n("Extract Zone"), this, SLOT(slotExtractCurrentZone()));
@@ -280,7 +275,7 @@ void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMe
     QAction *extractFrame = m_configMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
     m_contextMenu->addAction(extractFrame);
 
-    if (m_name != Kdenlive::clipMonitor) {
+    if (m_id != Kdenlive::clipMonitor) {
         QAction *splitView = m_contextMenu->addAction(KIcon("view-split-left-right"), i18n("Split view"), render, SLOT(slotSplitView(bool)));
         splitView->setCheckable(true);
         m_configMenu->addAction(splitView);
@@ -453,7 +448,7 @@ void Monitor::mousePressEvent(QMouseEvent * event)
             m_dragStarted = true;
             m_DragStartPosition = event->pos();
         }
-    } else if (!m_effectWidget || !m_effectWidget->isVisible()) {
+    } else if (m_contextMenu && (!m_effectWidget || !m_effectWidget->isVisible())) {
         m_contextMenu->popup(event->globalPos());
     }
 }
@@ -605,12 +600,12 @@ void Monitor::slotExtractCurrentFrame()
 
 bool Monitor::isActive() const
 {
-    return m_monitorManager->isActive(m_name);
+    return m_monitorManager->isActive(m_id);
 }
 
 bool Monitor::activateMonitor()
 {
-    return m_monitorManager->activateMonitor(m_name);
+    return m_monitorManager->activateMonitor(m_id);
 }
 
 void Monitor::setTimePos(const QString &pos)
@@ -1005,7 +1000,7 @@ void Monitor::slotSetSelectedClip(Transition* item)
 
 void Monitor::slotEffectScene(bool show)
 {
-    if (m_name == Kdenlive::projectMonitor) {
+    if (m_id == Kdenlive::projectMonitor) {
         if (m_monitorRefresh) {
             m_monitorRefresh->setVisible(!show);
         } else {
index da39bc1aef8e1770767019f2d3493ded955ac5ee..8794c89c542ed82ccb3036bec90115469d342136 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "gentime.h"
 #include "renderer.h"
+#include "definitions.h"
 #include "timecodedisplay.h"
 #include "abstractmonitor.h"
 #ifdef USE_OPENGL
@@ -100,12 +101,11 @@ class Monitor : public AbstractMonitor
     Q_OBJECT
 
 public:
-    Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
+    Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
     ~Monitor();
     Render *render;
     AbstractRender *abstractRender();
     void resetProfile(const QString &profile);
-    const QString name() const;
     void resetSize();
     bool isActive() const;
     void pause();
@@ -142,7 +142,7 @@ protected:
     //virtual void paintEvent(QPaintEvent * event);
 
 private:
-    QString m_name;
+    Kdenlive::MONITORID m_name;
     MonitorManager *m_monitorManager;
     DocClipBase *m_currentClip;
     SmallRuler *m_ruler;
index fa51ca4d72f8f21c59e17ed6444c0977143127d7..aa9bdfdf3d26b415480fac68404c063803c98184 100644 (file)
@@ -63,26 +63,26 @@ void MonitorManager::removeMonitor(AbstractMonitor *monitor)
     m_monitorsList.removeAll(monitor);
 }
 
-AbstractMonitor* MonitorManager::monitor(const QString monitorName)
+AbstractMonitor* MonitorManager::monitor(Kdenlive::MONITORID monitorName)
 {
     AbstractMonitor *monitor = NULL;
     for (int i = 0; i < m_monitorsList.size(); i++) {
-       if (m_monitorsList[i]->name() == monitorName) {
+        if (m_monitorsList[i]->id() == monitorName) {
            monitor = m_monitorsList[i];
        }
     }
     return monitor;
 }
 
-bool MonitorManager::activateMonitor(const QString &name)
+bool MonitorManager::activateMonitor(Kdenlive::MONITORID name)
 {
     if (m_clipMonitor == NULL || m_projectMonitor == NULL)
         return false;
-    if (m_activeMonitor && m_activeMonitor->name() == name)
+    if (m_activeMonitor && m_activeMonitor->id() == name)
         return false;
     m_activeMonitor = NULL;
     for (int i = 0; i < m_monitorsList.count(); i++) {
-        if (m_monitorsList.at(i)->name() == name) {
+        if (m_monitorsList.at(i)->id() == name) {
             m_activeMonitor = m_monitorsList.at(i);
         }
         else m_monitorsList.at(i)->stop();
@@ -97,9 +97,9 @@ bool MonitorManager::activateMonitor(const QString &name)
     return (m_activeMonitor != NULL);
 }
 
-bool MonitorManager::isActive(const QString &name) const
+bool MonitorManager::isActive(Kdenlive::MONITORID id) const
 {
-    return m_activeMonitor ? m_activeMonitor->name() == name: false;
+    return m_activeMonitor ? m_activeMonitor->id() == id: false;
 }
 
 void MonitorManager::slotSwitchMonitors(bool activateClip)
@@ -198,10 +198,10 @@ void MonitorManager::slotResetProfiles()
 {
     if (m_projectMonitor == NULL || m_clipMonitor == NULL) return;
     blockSignals(true);
-    QString active = m_activeMonitor ? m_activeMonitor->name() : QString();
+    Kdenlive::MONITORID active = m_activeMonitor ? m_activeMonitor->id() : Kdenlive::noMonitor;
     m_clipMonitor->resetProfile(KdenliveSettings::current_profile());
     m_projectMonitor->resetProfile(KdenliveSettings::current_profile());
-    if (!active.isEmpty()) activateMonitor(active);
+    if (active != Kdenlive::noMonitor) activateMonitor(active);
     blockSignals(false);
     if (m_activeMonitor) m_activeMonitor->parentWidget()->raise();
     emit checkColorScopes();
index 5468fdf781b54185ac7dcb20bdc65ec912e54524..7064a33a4d16c10f3c2b5c48a72ae674aa706391 100644 (file)
@@ -42,7 +42,7 @@ public:
     /** Searches for a monitor with the given name.
        @return NULL, if no monitor could be found, or the monitor otherwise.
     */
-    AbstractMonitor *monitor(const QString monitorName);
+    AbstractMonitor *monitor(Kdenlive::MONITORID monitorName);
     void updateScopeSource();
     void clearScopeSource();
 
@@ -50,8 +50,8 @@ public slots:
 
     /** @brief Activates a monitor.
      * @param name name of the monitor to activate */
-    bool activateMonitor(const QString &name = QString());
-    bool isActive(const QString &name) const;
+    bool activateMonitor(Kdenlive::MONITORID);
+    bool isActive(Kdenlive::MONITORID id) const;
     void slotPlay();
     void slotPause();
     void slotPlayZone();
index 5e88caefc47f4ffbae0b397fcfbce78e2106c771..b9edc9afb17cc658899e751aa5f5b35a8243f927 100644 (file)
@@ -43,9 +43,8 @@
 #include <QDir>
 
 
-RecMonitor::RecMonitor(QString name, MonitorManager *manager, QWidget *parent) :
-    AbstractMonitor(parent),
-    m_name(name),
+RecMonitor::RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidget *parent) :
+    AbstractMonitor(name, parent),
     m_isCapturing(false),
     m_didCapture(false),
     m_isPlaying(false),
@@ -181,10 +180,6 @@ RecMonitor::~RecMonitor()
     if (m_captureDevice) delete m_captureDevice;
 }
 
-const QString RecMonitor::name() const
-{
-    return m_name;
-}
 
 void RecMonitor::stop()
 {
index 3324fb8938d38c2f9637d93b985869c0d128440a..325d1489cfa97406affd3f5b40194f44847fa6c6 100644 (file)
@@ -52,10 +52,9 @@ class RecMonitor : public AbstractMonitor, public Ui::RecMonitor_UI
     Q_OBJECT
 
 public:
-    explicit RecMonitor(QString name, MonitorManager *manager, QWidget *parent = 0);
+    explicit RecMonitor(Kdenlive::MONITORID name, MonitorManager *manager, QWidget *parent = 0);
     virtual ~RecMonitor();
 
-    const QString name() const;
     AbstractRender *abstractRender();
     void analyseFrames(bool analyse);
     enum CAPTUREDEVICE {FIREWIRE = 0, VIDEO4LINUX = 1, SCREENGRAB = 2, BLACKMAGIC = 3};
@@ -64,7 +63,6 @@ protected:
     virtual void mousePressEvent(QMouseEvent * event);
 
 private:
-    QString m_name;
     KDateTime m_captureTime;
     /** @brief Provide feedback about dvgrab operations */
     QLabel m_dvinfo;
index 5352051857cd9d21b0c5eb550a76b63d22bd5860..85b08d345e4e04696ccf46451b5f2767dfe6f1cd 100644 (file)
@@ -103,7 +103,7 @@ static void consumer_gl_frame_show(mlt_consumer, Render * self, mlt_frame frame_
     }
 }
 
-Render::Render(const QString & rendererName, int winid, QString profile, QWidget *parent) :
+Render::Render(Kdenlive::MONITORID rendererName, int winid, QString profile, QWidget *parent) :
     AbstractRender(rendererName, parent),
     m_name(rendererName),
     m_mltConsumer(NULL),
@@ -1578,11 +1578,6 @@ int Render::seekFramePosition() const
     return 0;
 }
 
-const QString & Render::rendererName() const
-{
-    return m_name;
-}
-
 void Render::emitFrameUpdated(Mlt::Frame& frame)
 {
     mlt_image_format format = mlt_image_rgb24a;
index 1b8d133e0ab9cdd22e3477c240a980dcbabb476e..9a7c54f3b0cfb3f4e63530e3f9d30ec185441ed6 100644 (file)
@@ -99,7 +99,7 @@ Q_OBJECT public:
      *  @param rendererName A unique identifier for this renderer
      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
      *  @param profile The MLT profile used for the renderer (default one will be used if empty). */
-    Render(const QString &rendererName, int winid, QString profile = QString(), QWidget *parent = 0);
+    Render(Kdenlive::MONITORID rendererName, int winid, QString profile = QString(), QWidget *parent = 0);
 
     /** @brief Destroy the MLT Renderer. */
     virtual ~Render();
@@ -154,9 +154,6 @@ Q_OBJECT public:
 
     void saveZone(KUrl url, QString desc, QPoint zone);
 
-    /** @brief Returns the name of the renderer. */
-    const QString & rendererName() const;
-
     /** @brief Returns the speed at which the renderer is currently playing.
      *
      * It returns 0.0 when the renderer is not playing anything. */
@@ -309,7 +306,7 @@ private:
      *
      * Useful to identify the renderers by what they do - e.g. background
      * rendering, workspace monitor, etc. */
-    QString m_name;
+    Kdenlive::MONITORID m_name;
     Mlt::Consumer * m_mltConsumer;
     Mlt::Producer * m_mltProducer;
     Mlt::Profile *m_mltProfile;
index 2b49df755d3813326b19197eff0cecae165844ee..d858410c03ef6bf471f7f72eb98cee3887285f65 100644 (file)
@@ -16,7 +16,6 @@
  ***************************************************************************/
 
 #include "stopmotion.h"
-#include "definitions.h"
 #ifdef USE_BLACKMAGIC
 #include "blackmagic/devices.h"
 #endif
@@ -95,7 +94,7 @@ void MyLabel::paintEvent(QPaintEvent* event)
 
 
 StopmotionMonitor::StopmotionMonitor(QWidget *parent) :
-    AbstractMonitor(parent),
+    AbstractMonitor(Kdenlive::stopmotionMonitor, parent),
     m_captureDevice(NULL)
 {
 }
@@ -114,7 +113,7 @@ AbstractRender *StopmotionMonitor::abstractRender()
     return m_captureDevice;
 }
 
-const QString StopmotionMonitor::name() const
+Kdenlive::MONITORID StopmotionMonitor::id() const
 {
     return Kdenlive::stopmotionMonitor;
 }
index 3e115276c5d3102d80d2ca1b185f1fc518ce0a24..fb1dee8e212101e47b9d0f7b9e01f5d94ec48950 100644 (file)
@@ -19,6 +19,7 @@
 #define STOPMOTION_H
 
 #include "ui_stopmotion_ui.h"
+#include "definitions.h"
 
 #include <KUrl>
 #include <QLabel>
@@ -64,7 +65,7 @@ public:
     StopmotionMonitor(QWidget *parent);
     ~StopmotionMonitor();
     AbstractRender *abstractRender();
-    const QString name() const;
+    Kdenlive::MONITORID id() const;
     void setRender(MltDeviceCapture *render);
 
 private: