Cleanup monitor ruler, display zone duration on change

parent 75884cfa
......@@ -628,6 +628,11 @@ void GLWidget::requestRefresh()
}
}
QString GLWidget::frameToTime(int frames) const
{
return m_consumer ? m_consumer->frames_to_time(frames, mlt_time_smpte_df) : QStringLiteral("-");
}
void GLWidget::refresh()
{
m_refreshTimer.stop();
......
......@@ -138,6 +138,7 @@ protected:
void wheelEvent(QWheelEvent *event) override;
/** @brief Update producer, should ONLY be called from monitor */
int setProducer(Mlt::Producer *producer, bool isActive, int position = -1);
QString frameToTime(int frames) const;
public slots:
void seek(int pos);
......
......@@ -1656,6 +1656,7 @@ void Monitor::onFrameDisplayed(const SharedFrame &frame)
if (!m_glMonitor->checkFrameNumber(position, m_id == Kdenlive::ClipMonitor ? 1 : TimelineModel::seekDuration + 1)) {
m_playAction->setActive(false);
}
checkDrops(m_glMonitor->droppedFrames());
}
void Monitor::checkDrops(int dropped)
......@@ -1997,12 +1998,6 @@ void Monitor::prepareAudioThumb(int channels, QVariantList &audioCache)
m_glMonitor->setAudioThumb(channels, audioCache);
}
void Monitor::slotUpdateQmlTimecode(const QString &tc)
{
checkDrops(m_glMonitor->droppedFrames());
m_glMonitor->getControllerProxy()->setTimecode(tc);
}
void Monitor::slotSwitchAudioMonitor()
{
if (!m_audioMeterWidget->isValid) {
......@@ -2037,13 +2032,6 @@ void Monitor::updateQmlDisplay(int currentOverlay)
m_glMonitor->rootObject()->setProperty("showMarkers", currentOverlay & 0x04);
m_glMonitor->rootObject()->setProperty("showFps", currentOverlay & 0x20);
m_glMonitor->rootObject()->setProperty("showTimecode", currentOverlay & 0x02);
bool showTimecodeRelatedInfo = ((currentOverlay & 0x02) != 0) || ((currentOverlay & 0x20) != 0);
m_timePos->sendTimecode(showTimecodeRelatedInfo);
if (showTimecodeRelatedInfo) {
connect(m_timePos, &TimecodeDisplay::emitTimeCode, this, &Monitor::slotUpdateQmlTimecode, Qt::UniqueConnection);
} else {
disconnect(m_timePos, &TimecodeDisplay::emitTimeCode, this, &Monitor::slotUpdateQmlTimecode);
}
m_glMonitor->rootObject()->setProperty("showAudiothumb", currentOverlay & 0x10);
}
......
......@@ -264,8 +264,6 @@ private slots:
void slotEditInlineMarker();
/** @brief Pass keypress event to mainwindow */
void doKeyPressEvent(QKeyEvent *);
/** @brief The timecode was updated, refresh qml display */
void slotUpdateQmlTimecode(const QString &tc);
/** @brief There was an error initializing Movit */
void gpuError();
void setOffsetX(int x);
......
......@@ -181,17 +181,6 @@ QPoint MonitorProxy::zone() const
return QPoint(m_zoneIn, m_zoneOut);
}
const QString &MonitorProxy::timecode() const
{
return m_timecode;
}
void MonitorProxy::setTimecode(const QString &tc)
{
m_timecode = tc;
emit timecodeChanged();
}
QImage MonitorProxy::extractFrame(int frame_position, const QString &path, int width, int height, bool useSourceProfile)
{
if (width == -1) {
......@@ -260,3 +249,7 @@ void MonitorProxy::activateClipMonitor(bool isClipMonitor)
pCore->monitorManager()->activateMonitor(isClipMonitor ? Kdenlive::ClipMonitor : Kdenlive::ProjectMonitor);
}
QString MonitorProxy::toTimecode(int frames) const
{
return KdenliveSettings::frametimecode() ? QString::number(frames) : q->frameToTime(frames);
}
......@@ -43,7 +43,6 @@ class MonitorProxy : public QObject
Q_PROPERTY(int rulerHeight READ rulerHeight NOTIFY rulerHeightChanged)
Q_PROPERTY(QString markerComment READ markerComment NOTIFY markerCommentChanged)
Q_PROPERTY(int overlayType READ overlayType WRITE setOverlayType NOTIFY overlayTypeChanged)
Q_PROPERTY(QString timecode READ timecode NOTIFY timecodeChanged)
public:
MonitorProxy(GLWidget *parent);
......@@ -69,9 +68,8 @@ public:
void setZone(QPoint zone);
void resetZone();
QPoint zone() const;
const QString &timecode() const;
void setTimecode(const QString &tc);
QImage extractFrame(int frame_position, const QString &path = QString(), int width = -1, int height = -1, bool useSourceProfile = false);
Q_INVOKABLE QString toTimecode(int frames) const;
signals:
void positionChanged();
......@@ -84,7 +82,6 @@ signals:
void removeSnap(int);
void triggerAction(const QString &name);
void overlayTypeChanged();
void timecodeChanged();
void seekNextKeyframe();
void seekPreviousKeyframe();
void addRemoveKeyframe();
......@@ -97,7 +94,6 @@ private:
int m_zoneIn;
int m_zoneOut;
QString m_markerComment;
QString m_timecode;
};
#endif
......@@ -9,6 +9,12 @@ Rectangle {
id: ruler
color: activePalette.window
Timer {
id: zoneToolTipTimer
interval: 3000; running: false;
}
function updateRuler()
{
root.timeScale = width / root.duration
......@@ -55,12 +61,24 @@ Rectangle {
opacity: 0.7
x: markerBase.x
radius: 2
width: mlabel.width + 4
height: mlabel.height
width: mlabel.contentWidth
height: mlabel.contentHeight
anchors {
bottom: parent.verticalCenter
bottom: parent.top
}
color: model.color
Text {
id: mlabel
visible: true //mouseOverRuler && Math.abs(root.mouseRulerPos - markerBase.x) < 4
text: model.comment
font.pixelSize: root.baseUnit
anchors {
fill: parent
//topMargin: 2
//leftMargin: 2
}
color: 'white'
}
MouseArea {
z: 10
anchors.fill: parent
......@@ -68,25 +86,15 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
//onDoubleClicked: timeline.editMarker(clipRoot.binId, model.frame)
//onClicked: timeline.position = (clipRoot.x + markerBase.x) / timeline.scaleFactor
}
}
Text {
id: mlabel
visible: mouseOverRuler && Math.abs(root.mouseRulerPos - markerBase.x) < 4
text: model.comment
font.pixelSize: root.baseUnit
x: markerBase.x
anchors {
bottom: parent.verticalCenter
topMargin: 2
leftMargin: 2
onClicked: {
controller.requestSeekPosition(markerBase.x / root.timeScale)
}
}
color: 'white'
}
}
}
MouseArea {
id: rulerMouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: root.mouseOverRuler = true;
......@@ -105,6 +113,24 @@ Rectangle {
}
}
}
// Zone duration indicator
Rectangle {
visible: zoneToolTipTimer.running || rulerMouseArea.containsMouse || trimInMouseArea.containsMouse || trimInMouseArea.pressed || trimOutMouseArea.containsMouse || trimOutMouseArea.pressed
width: inLabel.contentWidth
height: inLabel.contentHeight
property int centerPos: zone.x + zone.width / 2 - inLabel.contentWidth / 2
x: centerPos < 0 ? 0 : centerPos > ruler.width - inLabel.contentWidth ? ruler.width - inLabel.contentWidth : centerPos
color: activePalette.highlight
anchors.bottom: ruler.top
Label {
id: inLabel
anchors.fill: parent
text: trimInMouseArea.containsMouse || trimInMouseArea.pressed ? controller.toTimecode(controller.zoneIn) + '>' + controller.toTimecode(controller.zoneOut - controller.zoneIn) : trimOutMouseArea.containsMouse || trimOutMouseArea.pressed ? controller.toTimecode(controller.zoneOut - controller.zoneIn) + '<' + controller.toTimecode(controller.zoneOut) : controller.toTimecode(controller.zoneOut - controller.zoneIn)
font.pixelSize: root.baseUnit
color: activePalette.highlightedText
}
}
// monitor zone
Rectangle {
id: zone
......@@ -115,75 +141,60 @@ Rectangle {
anchors.bottom: parent.bottom
height: ruler.height / 2
opacity: 0.4
Rectangle {
id: trimIn
anchors.left: parent.left
anchors.leftMargin: 0
height: parent.height
width: 5
color: 'lawngreen'
opacity: 0
Drag.active: trimInMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: trimInMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
onPressed: {
parent.anchors.left = undefined
}
onReleased: {
parent.anchors.left = zone.left
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
controller.zoneIn = controller.zoneIn + Math.round(trimIn.x / root.timeScale)
}
onXChanged: zoneToolTipTimer.start()
onWidthChanged: zoneToolTipTimer.start()
}
Rectangle {
id: trimIn
x: zone.x
y: zone.y
height: zone.height
width: 5
color: 'lawngreen'
opacity: trimInMouseArea.containsMouse || trimInMouseArea.drag.active ? 0.5 : 0
Drag.active: trimInMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: trimInMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
drag.minimumX: 0
drag.maximumX: ruler.width
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
controller.zoneIn = Math.round(trimIn.x / root.timeScale)
}
onEntered: parent.opacity = 0.5
onExited: parent.opacity = 0
}
}
Rectangle {
id: trimOut
anchors.right: parent.right
anchors.rightMargin: 0
height: parent.height
width: 5
color: 'darkred'
opacity: 0
Drag.active: trimOutMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: trimOutMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
onPressed: {
parent.anchors.right = undefined
}
onReleased: {
parent.anchors.right = zone.right
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
controller.zoneOut = controller.zoneIn + Math.round((trimOut.x + trimOut.width) / root.timeScale)
}
}
Rectangle {
id: trimOut
x: zone.x + zone.width - width
y: zone.y
height: zone.height
width: 5
color: 'darkred'
opacity: trimOutMouseArea.containsMouse || trimOutMouseArea.drag.active ? 0.5 : 0
Drag.active: trimOutMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: trimOutMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
drag.minimumX: 0
drag.maximumX: ruler.width
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
controller.zoneOut = Math.round((trimOut.x + trimOut.width) / root.timeScale)
}
onEntered: parent.opacity = 0.5
onExited: parent.opacity = 0
}
}
}
......
......@@ -147,7 +147,7 @@ Item {
color: "white"
style: Text.Outline;
styleColor: "black"
text: controller.timecode
text: controller.toTimecode(controller.position)
font.pixelSize: root.baseUnit
visible: root.showTimecode
anchors {
......
......@@ -114,7 +114,7 @@ Item {
color: "white"
style: Text.Outline;
styleColor: "black"
text: controller.timecode
text: controller.toTimecode(controller.position)
font.pixelSize: root.baseUnit
visible: root.showTimecode
anchors {
......
......@@ -224,15 +224,6 @@ void TimecodeDisplay::setValue(const GenTime &value)
setValue((int)value.frames(m_timecode.fps()));
}
void TimecodeDisplay::sendTimecode(bool send)
{
if (send) {
connect(lineEdit(), &QLineEdit::textChanged, this, &TimecodeDisplay::emitTimeCode, Qt::UniqueConnection);
} else {
disconnect(lineEdit(), &QLineEdit::textChanged, this, &TimecodeDisplay::emitTimeCode);
}
}
void TimecodeDisplay::slotEditingFinished()
{
lineEdit()->deselect();
......
......@@ -85,8 +85,6 @@ public:
void stepBy(int steps) override;
const QString displayText() const;
/** @brief Send a signal every time the timecode changes. */
void sendTimecode(bool send);
private:
/** timecode for widget */
......@@ -114,8 +112,6 @@ private slots:
signals:
void timeCodeEditingFinished(int value = -1);
/** @brief Emit timecode on every change if requested. */
void emitTimeCode(const QString &);
protected:
void keyPressEvent(QKeyEvent *e) override;
......
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