Commit 1f4bbabf authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Move speed indicator in qml overlay.

Fixes !170
parent 482eb8a5
......@@ -691,6 +691,7 @@ bool GLWidget::checkFrameNumber(int pos, int offset, bool isPlaying)
}
m_producer->seek(m_isZoneMode ? m_proxy->zoneIn() : m_loopIn);
m_producer->set_speed(1.0);
m_proxy->setSpeed(1.);
m_consumer->set("refresh", 1);
return true;
}
......@@ -700,6 +701,7 @@ bool GLWidget::checkFrameNumber(int pos, int offset, bool isPlaying)
if (pos >= (maxPos - 1) && !(speed < 0.)) {
// Playing past last clip, pause
m_producer->set_speed(0);
m_proxy->setSpeed(0);
m_consumer->set("refresh", 0);
m_consumer->purge();
m_proxy->setPosition(qMax(0, maxPos));
......@@ -708,6 +710,7 @@ bool GLWidget::checkFrameNumber(int pos, int offset, bool isPlaying)
} else if (pos <= 0 && speed < 0.) {
// rewinding reached 0, pause
m_producer->set_speed(0);
m_proxy->setSpeed(0);
m_consumer->set("refresh", 0);
m_consumer->purge();
m_proxy->setPosition(0);
......@@ -913,6 +916,7 @@ int GLWidget::setProducer(const std::shared_ptr<Mlt::Producer> &producer, bool i
}
// redundant check. postcondition of above is m_producer != null
m_producer->set_speed(0);
m_proxy->setSpeed(0);
error = reconfigure();
if (error == 0) {
// The profile display aspect ratio may have changed.
......@@ -1616,6 +1620,7 @@ void GLWidget::switchPlay(bool play, double speed)
}
double current_speed = m_producer->get_speed();
m_producer->set_speed(speed);
m_proxy->setSpeed(speed);
if (qFuzzyCompare(speed, 1.0) || speed < -6. || speed > 6.) {
m_consumer->set("scrub_audio", 0);
} else {
......@@ -1632,6 +1637,7 @@ void GLWidget::switchPlay(bool play, double speed)
} else {
emit paused();
m_producer->set_speed(0);
m_proxy->setSpeed(0);
m_producer->seek(m_consumer->position() + 1);
m_consumer->purge();
m_consumer->start();
......@@ -1646,6 +1652,7 @@ bool GLWidget::playZone(bool loop)
}
m_producer->seek(m_proxy->zoneIn());
m_producer->set_speed(0);
m_proxy->setSpeed(0);
m_consumer->purge();
m_producer->set("out", m_proxy->zoneOut());
m_producer->set_speed(1.0);
......@@ -1683,6 +1690,7 @@ bool GLWidget::loopClip(QPoint inOut)
m_loopIn = inOut.x();
m_producer->seek(inOut.x());
m_producer->set_speed(0);
m_proxy->setSpeed(0);
m_consumer->purge();
m_producer->set("out", inOut.y());
m_producer->set_speed(1.0);
......@@ -1754,6 +1762,7 @@ void GLWidget::stop()
resetZoneMode();
}
m_producer->set_speed(0.0);
m_proxy->setSpeed(0);
}
if (m_consumer) {
m_consumer->purge();
......
......@@ -50,7 +50,6 @@
#include <KRecentDirs>
#include <KSelectAction>
#include <KWindowConfig>
#include <KColorScheme>
#include <kio_version.h>
#include "kdenlive_debug.h"
......@@ -248,13 +247,6 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_toolbar->addWidget(scalingAction);
m_toolbar->addSeparator();
m_speedLabel = new QLabel(this);
m_speedLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Button);
QColor bg = scheme.background(KColorScheme::PositiveBackground).color();
m_speedLabel->setStyleSheet(QString("padding-left: %4; padding-right: %4;background-color: rgb(%1,%2,%3);").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(m_speedLabel->sizeHint().height()/4));
m_toolbar->addWidget(m_speedLabel);
m_speedLabel->setFixedWidth(0);
if (id == Kdenlive::ClipMonitor) {
// Add options for recording
m_recManager = new RecManager(this);
......@@ -1307,15 +1299,12 @@ void Monitor::slotRewind(double speed)
if (currentspeed > -1) {
m_glMonitor->purgeCache();
speed = -1;
resetSpeedInfo();
} else {
m_speedIndex++;
if (m_speedIndex > 4) {
m_speedIndex = 0;
}
speed = -MonitorManager::speedArray[m_speedIndex];
m_speedLabel->setFixedWidth(QWIDGETSIZE_MAX);
m_speedLabel->setText(QString("x%1").arg(speed));
}
}
updatePlayAction(true);
......@@ -1332,7 +1321,6 @@ void Monitor::slotForward(double speed, bool allowNormalPlay)
if (currentspeed < 1) {
if (allowNormalPlay) {
m_glMonitor->purgeCache();
resetSpeedInfo();
updatePlayAction(true);
m_glMonitor->switchPlay(true, 1);
return;
......@@ -1346,8 +1334,6 @@ void Monitor::slotForward(double speed, bool allowNormalPlay)
m_speedIndex = 0;
}
speed = MonitorManager::speedArray[m_speedIndex];
m_speedLabel->setFixedWidth(QWIDGETSIZE_MAX);
m_speedLabel->setText(QString("x%1").arg(speed));
}
updatePlayAction(true);
m_glMonitor->switchPlay(true, speed);
......@@ -1469,7 +1455,6 @@ void Monitor::switchPlay(bool play)
emit pCore->autoScrollChanged();
}
m_glMonitor->switchPlay(play);
resetSpeedInfo();
}
void Monitor::updatePlayAction(bool play)
......@@ -1501,7 +1486,6 @@ void Monitor::slotSwitchPlay()
} else {
m_droppedTimer.stop();
}
resetSpeedInfo();
}
void Monitor::slotPlay()
......@@ -2435,7 +2419,6 @@ void Monitor::slotStart()
}
m_glMonitor->switchPlay(false);
m_glMonitor->getControllerProxy()->setPosition(0);
resetSpeedInfo();
}
void Monitor::slotEnd()
......@@ -2444,7 +2427,6 @@ void Monitor::slotEnd()
return;
}
m_glMonitor->switchPlay(false);
resetSpeedInfo();
if (m_id == Kdenlive::ClipMonitor) {
m_glMonitor->getControllerProxy()->setPosition(m_glMonitor->duration() - 1);
} else {
......@@ -2452,13 +2434,6 @@ void Monitor::slotEnd()
}
}
void Monitor::resetSpeedInfo()
{
m_speedIndex = -1;
m_speedLabel->setFixedWidth(0);
m_speedLabel->clear();
}
void Monitor::addSnapPoint(int pos)
{
m_snaps->addPoint(pos);
......
......@@ -225,7 +225,6 @@ private:
MonitorAudioLevel *m_audioMeterWidget;
QTimer m_droppedTimer;
double m_displayedFps;
QLabel *m_speedLabel;
int m_speedIndex;
QMetaObject::Connection m_switchConnection;
......@@ -234,8 +233,6 @@ private:
void updateQmlDisplay(int currentOverlay);
/** @brief Create temporary Mlt::Tractor holding a clip and it's effectless clone */
void buildSplitEffect(Mlt::Producer *original);
/** @brief Reset and hide speed info label */
void resetSpeedInfo();
private slots:
void slotSetThumbFrame();
......
......@@ -39,6 +39,7 @@ MonitorProxy::MonitorProxy(GLWidget *parent)
, m_zoneIn(0)
, m_zoneOut(-1)
, m_hasAV(false)
, m_speed(0)
, m_clipType(0)
, m_clipId(-1)
, m_seekFinished(true)
......@@ -395,3 +396,12 @@ void MonitorProxy::setWidgetKeyBinding(const QString &text) const
{
pCore->setWidgetKeyBinding(text);
}
void MonitorProxy::setSpeed(double speed)
{
if (qAbs(m_speed) > 1. || qAbs(speed) > 1.) {
// check if we have or had a speed > 1 or < -1
m_speed = speed;
emit speedChanged();
}
}
......@@ -50,6 +50,7 @@ class MonitorProxy : public QObject
Q_PROPERTY(QList <int> audioStreams MEMBER m_audioStreams NOTIFY audioThumbChanged)
Q_PROPERTY(QList <int> audioChannels MEMBER m_audioChannels NOTIFY audioThumbChanged)
Q_PROPERTY(int overlayType READ overlayType WRITE setOverlayType NOTIFY overlayTypeChanged)
Q_PROPERTY(double speed MEMBER m_speed NOTIFY speedChanged)
Q_PROPERTY(QColor thumbColor1 READ thumbColor1 NOTIFY colorsChanged)
Q_PROPERTY(QColor thumbColor2 READ thumbColor2 NOTIFY colorsChanged)
Q_PROPERTY(bool autoKeyframe READ autoKeyframe NOTIFY autoKeyframeChanged)
......@@ -115,6 +116,8 @@ public:
void setTimeCode(TimecodeDisplay *td);
/** @brief When the producer changes, ensure we reset the stored position*/
void resetPosition();
/** @brief Used to display qml info about speed*/
void setSpeed(double speed);
signals:
void positionChanged(int);
......@@ -145,6 +148,7 @@ signals:
void profileChanged();
void autoKeyframeChanged();
void timecodeChanged();
void speedChanged();
private:
GLWidget *q;
......@@ -152,6 +156,7 @@ private:
int m_zoneIn;
int m_zoneOut;
bool m_hasAV;
double m_speed;
QList <int> m_audioStreams;
QList <int> m_audioChannels;
QString m_markerComment;
......
......@@ -437,6 +437,22 @@ Item {
bottomMargin: overlayMargin
}
}
Label {
id: labelSpeed
font: fixedFont
anchors {
left: parent.left
top: parent.top
}
visible: Math.abs(controller.speed) > 1
text: "x" + controller.speed
color: "white"
background: Rectangle {
color: "darkgreen"
}
padding: 5
horizontalAlignment: TextInput.AlignHCenter
}
Label {
id: inPoint
font: fixedFont
......
......@@ -160,6 +160,22 @@ Item {
bottomMargin: root.zoomOffset
}
}
Label {
id: labelSpeed
font: fixedFont
anchors {
left: parent.left
top: parent.top
}
visible: Math.abs(controller.speed) > 1
text: "x" + controller.speed
color: "white"
background: Rectangle {
color: "darkgreen"
}
padding: 5
horizontalAlignment: TextInput.AlignHCenter
}
Label {
id: inPoint
font: fixedFont
......
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