X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsmallruler.cpp;h=c7e0ec1765e6524ae909ce4c317615d1f3ae9742;hb=d5b4fe2e78d8b2645cdc2ac007c1006a151875c0;hp=9097fe90d7afefbbe7a07840799d07abfeb3e57d;hpb=214311bba3810cb8bebbce7946b85eec378afdbb;p=kdenlive diff --git a/src/smallruler.cpp b/src/smallruler.cpp index 9097fe90..c7e0ec17 100644 --- a/src/smallruler.cpp +++ b/src/smallruler.cpp @@ -25,14 +25,16 @@ #include #include -SmallRuler::SmallRuler(QWidget *parent) : +SmallRuler::SmallRuler(MonitorManager *manager, QWidget *parent) : QWidget(parent), m_scale(1), - m_maxval(25) + m_maxval(25), + m_manager(manager) { m_zoneStart = 10; m_zoneEnd = 60; m_zoneColor = QColor(133, 255, 143); + setMouseTracking(true); } void SmallRuler::adjustScale(int maximum) @@ -108,18 +110,28 @@ void SmallRuler::mouseMoveEvent(QMouseEvent * event) { const int pos = event->x() / m_scale; if (event->buttons() & Qt::LeftButton) emit seekRenderer((int) pos); + else { + if (qAbs((pos - m_zoneStart) * m_scale) < 4) { + setToolTip(i18n("Zone start: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneStart))); + } else if (qAbs((pos - m_zoneEnd) * m_scale) < 4) { + setToolTip(i18n("Zone end: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneEnd))); + } else if (pos > m_zoneStart && pos < m_zoneEnd) { + setToolTip(i18n("Zone duration: %1", m_manager->timecode().getTimecodeFromFrames(m_zoneEnd - m_zoneStart))); + } else setToolTip(i18n("Position: %1", m_manager->timecode().getTimecodeFromFrames(pos))); + } } -void SmallRuler::slotNewValue(int value) +bool SmallRuler::slotNewValue(int value) { + if (value == m_cursorFramePosition) return false; m_cursorFramePosition = value; int oldPos = m_cursorPosition; m_cursorPosition = value * m_scale; - if (oldPos == m_cursorPosition) return; const int offset = 6; const int x = qMin(oldPos, m_cursorPosition); const int w = qAbs(oldPos - m_cursorPosition); update(x - offset, 4, w + 2 * offset, 6); + return true; } //virtual