X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsmallruler.cpp;h=4011bf3c7b537deec8d1967ed77eeb8cbaacc44d;hb=e38a9c69552502be9d432d4e0699bff9a1557c68;hp=c002c5c46c4a03978b4d592595ca2ac49023a019;hpb=82635dca197cca75664c4add06a10e847210fc1f;p=kdenlive diff --git a/src/smallruler.cpp b/src/smallruler.cpp index c002c5c4..4011bf3c 100644 --- a/src/smallruler.cpp +++ b/src/smallruler.cpp @@ -19,12 +19,15 @@ #include "smallruler.h" +#include "kdenlivesettings.h" #include +#include #include #include + SmallRuler::SmallRuler(MonitorManager *manager, QWidget *parent) : QWidget(parent), m_scale(1), @@ -33,8 +36,9 @@ SmallRuler::SmallRuler(MonitorManager *manager, QWidget *parent) : { m_zoneStart = 10; m_zoneEnd = 60; - m_zoneColor = QColor(133, 255, 143); + m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color(); setMouseTracking(true); + setMinimumHeight(10); } void SmallRuler::adjustScale(int maximum) @@ -121,16 +125,17 @@ void SmallRuler::mouseMoveEvent(QMouseEvent * event) } } -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 @@ -150,25 +155,26 @@ void SmallRuler::updatePixmap() const int zoneEnd = (int)(m_zoneEnd * m_scale); p.fillRect(zoneStart, height() / 2 - 1, zoneEnd - zoneStart, height() / 2, m_zoneColor); - // draw markers - if (!m_markers.isEmpty()) { - p.setPen(Qt::red); - for (int i = 0; i < m_markers.count(); i++) { - p.drawLine(m_markers.at(i) * m_scale, 0, m_markers.at(i) * m_scale, 9); - } - } - p.setPen(palette().dark().color()); + // draw ruler + p.setPen(palette().text().color()); // draw the little marks fend = m_scale * m_small; if (fend > 2) for (f = 0; f < width(); f += fend) { - p.drawLine((int)f, 0, (int)f, 3); - } + p.drawLine((int)f, 0, (int)f, 3); + } // draw medium marks fend = m_scale * m_medium; if (fend > 2) for (f = 0; f < width(); f += fend) { - p.drawLine((int)f, 0, (int)f, 6); + p.drawLine((int)f, 0, (int)f, 6); + } + // draw markers + if (!m_markers.isEmpty()) { + p.setPen(Qt::red); + for (int i = 0; i < m_markers.count(); i++) { + p.drawLine(m_markers.at(i) * m_scale, 0, m_markers.at(i) * m_scale, 9); } + } p.end(); update(); } @@ -185,7 +191,7 @@ void SmallRuler::paintEvent(QPaintEvent *e) // draw pointer QPolygon pa(3); pa.setPoints(3, m_cursorPosition - 5, 10, m_cursorPosition + 5, 10, m_cursorPosition/*+0*/, 5); - p.setBrush(palette().dark().color()); + p.setBrush(palette().text().color()); p.setPen(Qt::NoPen); p.drawPolygon(pa); }