Use enum instead of string to identify monitors

parent 8749ea70
......@@ -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
......@@ -32,10 +32,11 @@
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};
......
......@@ -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);
......
......@@ -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();
......
......@@ -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),
......
......@@ -43,10 +43,9 @@
#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 {
......
......@@ -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;
......
......@@ -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();
......
......@@ -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();
......
......@@ -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()
{
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment