Code cleanup: move all monitor qml overlay handling in new class

parent 241af1e8
......@@ -9,7 +9,7 @@ Item {
// default size, but scalable by user
height: 300; width: 400
property string comment
property string markerText
property string timecode
property point profile
property double scale
......@@ -99,7 +99,7 @@ Item {
objectName: "markertext"
activeFocusOnPress: true
onEditingFinished: {
root.comment = marker.displayText
root.markerText = marker.displayText
marker.focus = false
root.editCurrentMarker()
}
......@@ -109,6 +109,7 @@ Item {
bottom: parent.bottom
}
visible: root.showMarkers && text != ""
text: root.markerText
maximumLength: 20
style: TextFieldStyle {
textColor: "white"
......
......@@ -8,7 +8,7 @@ Item {
// default size, but scalable by user
height: 300; width: 400
property string comment
property string markerText
property string timecode
property point profile
property double scale
......@@ -66,7 +66,7 @@ Item {
objectName: "markertext"
activeFocusOnPress: true
onEditingFinished: {
root.comment = marker.displayText
root.markerText = marker.displayText
marker.focus = false
root.editCurrentMarker()
}
......@@ -77,6 +77,7 @@ Item {
}
visible: root.showMarkers && text != ""
maximumLength: 20
text: root.markerText
style: TextFieldStyle {
textColor: "white"
background: Rectangle {
......
......@@ -115,9 +115,11 @@ enum ProjectTool {
enum MonitorSceneType {
MonitorSceneNone = 0,
MonitorSceneDefault,
MonitorSceneGeometry,
MonitorSceneCorners,
MonitorSceneRoto
MonitorSceneRoto,
MonitorSceneSplit
};
enum TransitionType {
......
......@@ -644,7 +644,7 @@ MonitorSceneType CollapsibleEffect::needsMonitorEffectScene() const
if (m_paramWidget)
return m_paramWidget->needsMonitorEffectScene();
else
return MonitorSceneNone;
return MonitorSceneDefault;
}
void CollapsibleEffect::setRange(int inPoint , int outPoint)
......
......@@ -190,7 +190,7 @@ void EffectStackEdit::initEffectScene(int pos)
MonitorSceneType EffectStackEdit::needsMonitorEffectScene() const
{
if (!m_paramWidget) return MonitorSceneNone;
if (!m_paramWidget) return MonitorSceneDefault;
return m_paramWidget->needsMonitorEffectScene();
}
......
......@@ -52,7 +52,7 @@ EffectStackView2::EffectStackView2(Monitor *projectMonitor, QWidget *parent) :
m_draggedEffect(NULL),
m_draggedGroup(NULL),
m_groupIndex(0),
m_monitorSceneWanted(MonitorSceneNone),
m_monitorSceneWanted(MonitorSceneDefault),
m_trackInfo(),
m_transition(NULL)
{
......@@ -132,7 +132,7 @@ void EffectStackView2::slotTransitionItemSelected(Transition* t, int nextTrack,
void EffectStackView2::slotRenderPos(int pos)
{
if (m_effects.isEmpty()) return;
if (m_monitorSceneWanted != MonitorSceneNone) slotCheckMonitorPosition(pos);
if (m_monitorSceneWanted != MonitorSceneDefault) slotCheckMonitorPosition(pos);
if (m_status == TIMELINE_CLIP && m_clipref) pos = pos - m_clipref->startPos().frames(KdenliveSettings::project_fps());
for (int i = 0; i< m_effects.count(); ++i)
......@@ -189,8 +189,8 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c, Monitor *m)
if (m_clipref == NULL) {
//TODO: clear list, reset paramdesc and info
// If monitor scene is displayed, hide it
if (m_monitorSceneWanted != MonitorSceneNone) {
m_monitorSceneWanted = MonitorSceneNone;
if (m_monitorSceneWanted != MonitorSceneDefault) {
m_monitorSceneWanted = MonitorSceneDefault;
m_effectMetaInfo.monitor->slotShowEffectScene(m_monitorSceneWanted);
}
m_status = EMPTY;
......@@ -248,8 +248,8 @@ void EffectStackView2::slotMasterClipItemSelected(ClipController* c, Monitor *m)
if (m_masterclipref == NULL) {
//TODO: clear list, reset paramdesc and info
// If monitor scene is displayed, hide it
if (m_monitorSceneWanted != MonitorSceneNone) {
m_monitorSceneWanted = MonitorSceneNone;
if (m_monitorSceneWanted != MonitorSceneDefault) {
m_monitorSceneWanted = MonitorSceneDefault;
m_effectMetaInfo.monitor->slotShowEffectScene(m_monitorSceneWanted);
}
m_status = EMPTY;
......@@ -288,7 +288,7 @@ void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo &info, Moni
void EffectStackView2::setupListView()
{
blockSignals(true);
m_monitorSceneWanted = MonitorSceneNone;
m_monitorSceneWanted = MonitorSceneDefault;
m_draggedEffect = NULL;
m_draggedGroup = NULL;
disconnect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
......@@ -557,9 +557,9 @@ void EffectStackView2::startDrag()
void EffectStackView2::slotUpdateEffectState(bool disable, int index, MonitorSceneType needsMonitorEffectScene)
{
if (m_monitorSceneWanted != MonitorSceneNone && disable) {
m_monitorSceneWanted = MonitorSceneNone;
m_effectMetaInfo.monitor->slotShowEffectScene(MonitorSceneNone);
if (m_monitorSceneWanted != MonitorSceneDefault && disable) {
m_monitorSceneWanted = MonitorSceneDefault;
m_effectMetaInfo.monitor->slotShowEffectScene(MonitorSceneDefault);
}
else if (!disable && m_monitorSceneWanted == needsMonitorEffectScene) {
m_monitorSceneWanted = needsMonitorEffectScene;
......@@ -607,17 +607,17 @@ void EffectStackView2::slotSeekTimeline(int pos)
void EffectStackView2::slotCheckMonitorPosition(int renderPos)
{
if (m_monitorSceneWanted != MonitorSceneNone) {
if (m_monitorSceneWanted != MonitorSceneDefault) {
if (m_status == TIMELINE_TRACK || m_status == MASTER_CLIP || (m_clipref && renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) {
if (!m_effectMetaInfo.monitor->effectSceneDisplayed(m_monitorSceneWanted)) {
m_effectMetaInfo.monitor->slotShowEffectScene(m_monitorSceneWanted);
}
} else {
m_effectMetaInfo.monitor->slotShowEffectScene(MonitorSceneNone);
m_effectMetaInfo.monitor->slotShowEffectScene(MonitorSceneDefault);
}
}
else {
m_effectMetaInfo.monitor->slotShowEffectScene(MonitorSceneNone);
m_effectMetaInfo.monitor->slotShowEffectScene(MonitorSceneDefault);
}
}
......@@ -634,7 +634,7 @@ int EffectStackView2::trackIndex() const
void EffectStackView2::clear()
{
m_effects.clear();
m_monitorSceneWanted = MonitorSceneNone;
m_monitorSceneWanted = MonitorSceneDefault;
QWidget *view = m_ui.container->takeWidget();
if (view) {
delete view;
......
......@@ -102,7 +102,7 @@ ParameterContainer::ParameterContainer(const QDomElement &effect, const ItemInfo
m_geometryWidget(NULL),
m_metaInfo(metaInfo),
m_effect(effect),
m_monitorEffectScene(MonitorSceneNone)
m_monitorEffectScene(MonitorSceneDefault)
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
......
......@@ -40,7 +40,7 @@ CornersWidget::CornersWidget(Monitor *monitor, const QDomElement& e, int minFram
m_pos(0)
{
m_monitor->slotShowEffectScene(MonitorSceneCorners);
connect(m_monitor, SIGNAL(effectChanged(QVariantList)), this, SLOT(slotUpdateGeometry(QVariantList)));
connect(m_monitor, &Monitor::effectPointsChanged, this, &CornersWidget::slotUpdateGeometry);
connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateItem()));
}
......
......@@ -52,7 +52,7 @@ GeometryWidget::GeometryWidget(Monitor* monitor, const Timecode &timecode, int c
{
m_ui.setupUi(this);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
connect(m_monitor, SIGNAL(effectChanged(QRect)), this, SLOT(slotUpdateGeometry(QRect)));
connect(m_monitor, &Monitor::effectChanged, this, &GeometryWidget::slotUpdateGeometryRect);
/*MonitorEditWidget *edit = monitor->getEffectEdit();
edit->removeCustomControls();
edit->addCustomButton(KoIconUtils::themedIcon("draw-path"), i18n("Show path"), this, SLOT(slotShowPath(bool)), true, KdenliveSettings::onmonitoreffects_geometryshowpath());
......@@ -607,7 +607,7 @@ void GeometryWidget::slotUpdateGeometry()
emit parameterChanged();
}
void GeometryWidget::slotUpdateGeometry(const QRect r)
void GeometryWidget::slotUpdateGeometryRect(const QRect r)
{
Mlt::GeometryItem item;
int pos = 0;
......
......@@ -137,7 +137,7 @@ private slots:
/** @brief Updates the Mlt::Geometry object. */
void slotUpdateGeometry();
void slotUpdateGeometry(const QRect r);
void slotUpdateGeometryRect(const QRect r);
/** @brief Updates the spinBoxes according to the rect. */
void slotUpdateProperties();
......
......@@ -8,4 +8,5 @@ set(kdenlive_SRCS
monitor/recmonitor.cpp
monitor/smallruler.cpp
monitor/sharedframe.cpp
monitor/qmlmanager.cpp
PARENT_SCOPE)
......@@ -204,20 +204,6 @@ void GLWidget::initializeGL()
m_initSem.release();
}
void GLWidget::effectRectChanged()
{
if (!rootObject()) return;
const QRect rect = rootObject()->property("framesize").toRect();
emit effectChanged(rect);
}
void GLWidget::effectPolygonChanged()
{
if (!rootObject()) return;
QVariantList points = rootObject()->property("centerPoints").toList();
emit effectChanged(points);
}
void GLWidget::resizeGL(int width, int height)
{
int x, y, w, h;
......@@ -969,38 +955,10 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
return error;
}
void GLWidget::slotShowEffectScene(MonitorSceneType sceneType)
{
QObject *item = rootObject();
if (!item) return;
switch (sceneType) {
case MonitorSceneGeometry:
QObject::connect(item, SIGNAL(effectChanged()), this, SLOT(effectRectChanged()), Qt::UniqueConnection);
item->setProperty("profile", QPoint(m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("framesize", QRect(0, 0, m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("scale", (double) m_rect.width() / m_monitorProfile->width() * m_zoom);
item->setProperty("center", m_rect.center());
break;
case MonitorSceneCorners:
QObject::connect(item, SIGNAL(effectPolygonChanged()), this, SLOT(effectPolygonChanged()), Qt::UniqueConnection);
item->setProperty("profile", QPoint(m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("framesize", QRect(0, 0, m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("scale", (double) m_rect.width() / m_monitorProfile->width() * m_zoom);
item->setProperty("center", m_rect.center());
break;
case MonitorSceneRoto:
//TODO
break;
default:
item->setProperty("profile", QPoint(m_monitorProfile->width(), m_monitorProfile->height()));
item->setProperty("scale", (double) m_rect.width() / m_monitorProfile->width() * m_zoom);
break;
}
}
float GLWidget::zoom() const
{
return m_zoom;// * m_monitorProfile->width() / m_rect.width();
return m_zoom;
}
float GLWidget::scale() const
......@@ -1053,6 +1011,11 @@ QSize GLWidget::profileSize() const
return QSize(m_monitorProfile->width(), m_monitorProfile->height());
}
QRect GLWidget::displayRect() const
{
return m_rect;
}
QPoint GLWidget::offset() const
{
return QPoint(m_offset.x() - (m_monitorProfile->width() * m_zoom - width()) / 2,
......
......@@ -83,6 +83,7 @@ public:
Mlt::Consumer *consumer();
Mlt::Producer *producer();
QSize profileSize() const;
QRect displayRect() const;
/** @brief set to true if we want to emit a QImage of the frame for analysis */
bool sendFrameForAnalysis;
void updateGamma();
......@@ -104,7 +105,6 @@ public slots:
void setZoom(float zoom);
void setOffsetX(int x);
void setOffsetY(int y);
void slotShowEffectScene(MonitorSceneType sceneType);
void slotSwitchAudioOverlay(bool enable);
void initializeGL();
......@@ -124,8 +124,6 @@ signals:
void switchFullScreen(bool minimizeOnly = false);
void mouseSeek(int eventDelta, bool fast);
void startDrag();
void effectChanged(const QRect);
void effectChanged(const QVariantList);
void analyseFrame(QImage);
void audioSamplesSignal(const audioShortVector&,int,int,int);
void showContextMenu(const QPoint);
......@@ -173,8 +171,6 @@ private slots:
void resizeGL(int width, int height);
void updateTexture(GLuint yName, GLuint uName, GLuint vName);
void paintGL();
void effectRectChanged();
void effectPolygonChanged();
void slotError(QQuickWindow::SceneGraphError error, const QString &message);
protected:
......
This diff is collapsed.
......@@ -51,6 +51,7 @@ class QQuickItem;
class QScrollBar;
class RecManager;
class QToolButton;
class QmlManager;
class QuickEventEater : public QObject
{
......@@ -175,6 +176,8 @@ private:
SmallRuler *m_ruler;
/** @brief Widget holding the window for the QQuickView **/
QWidget *m_videoWidget;
/** @brief Manager for qml overlay for the QQuickView **/
QmlManager *m_qmlManager;
Mlt::Filter *m_splitEffect;
Mlt::Producer *m_splitProducer;
......@@ -207,13 +210,9 @@ private:
QAction *m_editMarker;
KMessageWidget *m_infoMessage;
int m_forceSizeFactor;
/** @brief The base item of the qml view in monitor, used to set properties on the view that affect display **/
QQuickItem *m_rootItem;
QQuickItem *m_markerItem;
MonitorSceneType m_lastMonitorSceneType;
void adjustScrollBars(float horizontal, float vertical);
void loadMasterQml();
void loadMonitorScene();
void loadQmlScene(MonitorSceneType type);
void updateQmlDisplay(int currentOverlay);
private slots:
......@@ -310,7 +309,7 @@ signals:
/** @brief Request a zone extraction (ffmpeg transcoding). */
void extractZone(const QString &id);
void effectChanged(const QRect);
void effectChanged(QVariantList);
void effectPointsChanged(QVariantList);
void addKeyframe();
void seekToKeyframe(int);
void addClipToProject(QUrl);
......
/***************************************************************************
* Copyright (C) 2016 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "qmlmanager.h"
#include "qml/qmlaudiothumb.h"
#include <QQuickView>
QmlManager::QmlManager(QQuickView *view) :
QObject(view)
, m_view(view)
, m_sceneType(MonitorSceneNone)
{
}
void QmlManager::enableAudioThumbs(bool enable)
{
QmlAudioThumb *audioThumbDisplay = m_view->rootObject()->findChild<QmlAudioThumb *>("audiothumb");
if (audioThumbDisplay) audioThumbDisplay->setProperty("stateVisible", enable);
}
MonitorSceneType QmlManager::sceneType() const
{
return m_sceneType;
}
void QmlManager::setProperty(const QString &name, const QVariant &value)
{
m_view->rootObject()->setProperty(name.toUtf8().constData(), value);
}
void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize profile, QRect displayRect, double zoom)
{
if (type == m_sceneType) {
// Scene type already active
return;
}
if (id == Kdenlive::DvdMonitor) {
return;
}
m_sceneType = type;
QQuickItem *root;
switch (type) {
case MonitorSceneGeometry:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitoreffectscene.qml")));
root = m_view->rootObject();
QObject::connect(root, SIGNAL(effectChanged()), this, SLOT(effectRectChanged()), Qt::UniqueConnection);
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("framesize", QRect(0, 0, profile.width(), profile.height()));
root->setProperty("scale", (double) displayRect.width() / profile.width() * zoom);
root->setProperty("center", displayRect.center());
break;
case MonitorSceneCorners:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorcornerscene.qml")));
root = m_view->rootObject();
QObject::connect(root, SIGNAL(effectPolygonChanged()), this, SLOT(effectPolygonChanged()), Qt::UniqueConnection);
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("framesize", QRect(0, 0, profile.width(), profile.height()));
root->setProperty("scale", (double) displayRect.width() / profile.width() * zoom);
root->setProperty("center", displayRect.center());
break;
case MonitorSceneRoto:
//TODO
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorcornerscene.qml")));
root = m_view->rootObject();
QObject::connect(root, SIGNAL(effectPolygonChanged()), this, SLOT(effectPolygonChanged()), Qt::UniqueConnection);
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("framesize", QRect(0, 0, profile.width(), profile.height()));
root->setProperty("scale", (double) displayRect.width() / profile.width() * zoom);
root->setProperty("center", displayRect.center());
break;
case MonitorSceneSplit:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorsplit.qml")));
break;
default:
m_view->setSource(QUrl(id == Kdenlive::ClipMonitor ? QStringLiteral("qrc:/qml/kdenliveclipmonitor.qml") : QStringLiteral("qrc:/qml/kdenlivemonitor.qml")));
root = m_view->rootObject();
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("scale", (double) displayRect.width() / profile.width() * zoom);
break;
}
//m_glMonitor->setAudioThumb();
}
void QmlManager::effectRectChanged()
{
if (!m_view->rootObject()) return;
const QRect rect = m_view->rootObject()->property("framesize").toRect();
qDebug()<<" - - -EFFECT RECT: "<<rect;
emit effectChanged(rect);
}
void QmlManager::effectPolygonChanged()
{
if (!m_view->rootObject()) return;
QVariantList points = m_view->rootObject()->property("centerPoints").toList();
emit effectPointsChanged(points);
}
/***************************************************************************
* Copyright (C) 2016 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/*!
* @class QmlManager
* @brief Manages all Qml monitor overlays
* @author Jean-Baptiste Mardelle
*/
#ifndef QMLMANAGER_H
#define QMLMANAGER_H
#include "definitions.h"
class QQuickView;
class QmlManager : public QObject
{
Q_OBJECT
public:
explicit QmlManager(QQuickView *view);
/** @brief Show / hide audio thumbnail preview */
void enableAudioThumbs(bool enable);
/** @brief return current active scene type */
MonitorSceneType sceneType() const;
/** @brief Set a property on the root item */
void setProperty(const QString &name, const QVariant &value);
/** @brief Load a monitor scene */
void setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize profile, QRect displayRect, double zoom);
private:
QQuickView *m_view;
MonitorSceneType m_sceneType;
private slots:
void effectRectChanged();
void effectPolygonChanged();
signals:
void effectChanged(const QRect);
void effectPointsChanged(const QVariantList);
};
#endif
......@@ -86,7 +86,7 @@ RotoWidget::~RotoWidget()
if (m_monitor) {
/*MonitorEditWidget *edit = m_monitor->getEffectEdit();
edit->removeCustomControls();*/
m_monitor->slotShowEffectScene(MonitorSceneNone);
m_monitor->slotShowEffectScene(MonitorSceneDefault);
}
}
......
......@@ -266,7 +266,7 @@ void TransitionSettings::slotTransitionItemSelected(Transition* t, int nextTrack
m_usedTransition = NULL;
ItemInfo info;
m_effectEdit->transferParamDesc(QDomElement(), info, false);
m_effectEdit->monitor()->slotShowEffectScene(MonitorSceneNone);
m_effectEdit->monitor()->slotShowEffectScene(MonitorSceneDefault);
}
}
......@@ -305,18 +305,18 @@ void TransitionSettings::slotCheckMonitorPosition(int renderPos)
{
if (!isEnabled()) return;
MonitorSceneType sceneType = m_effectEdit->needsMonitorEffectScene();
if (sceneType != MonitorSceneNone) {
if (sceneType != MonitorSceneDefault) {
if (renderPos >= m_usedTransition->startPos().frames(KdenliveSettings::project_fps()) && renderPos < m_usedTransition->endPos().frames(KdenliveSettings::project_fps())) {
if (!m_effectEdit->monitor()->effectSceneDisplayed(sceneType)) {
m_effectEdit->monitor()->slotShowEffectScene(sceneType);
m_effectEdit->initEffectScene(renderPos - m_usedTransition->startPos().frames(KdenliveSettings::project_fps()));
}
} else {
m_effectEdit->monitor()->slotShowEffectScene(MonitorSceneNone);
m_effectEdit->monitor()->slotShowEffectScene(MonitorSceneDefault);
}
}
else {
m_effectEdit->monitor()->slotShowEffectScene(MonitorSceneNone);
m_effectEdit->monitor()->slotShowEffectScene(MonitorSceneDefault);
}
}
......
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