X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsmallruler.cpp;h=d5b99032b95fa3b8b4cb6461491193260fde748a;hb=5d4746e4c3e8665de83e6d281dcd08a46cd22c31;hp=2d45f57ea49d1b7b821bb38fd87aefea6842d039;hpb=fe156af311a975e3a4be1b9a736d0436010cae59;p=kdenlive diff --git a/src/smallruler.cpp b/src/smallruler.cpp index 2d45f57e..d5b99032 100644 --- a/src/smallruler.cpp +++ b/src/smallruler.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -43,10 +43,11 @@ SmallRuler::SmallRuler(Monitor *monitor, Render *render, QWidget *parent) : m_zoneStart = 10; m_zoneEnd = 60; KSharedConfigPtr config = KSharedConfig::openConfig(KdenliveSettings::colortheme()); - m_zoneBrush = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, config); + m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, config).brush(this).color(); + m_zoneColor.setAlpha(180); setMouseTracking(true); - setMinimumHeight(8); + setMinimumHeight(QFontInfo(font()).pixelSize()); adjustScale(m_maxval); } @@ -107,13 +108,13 @@ void SmallRuler::setZone(int start, int end) updatePixmap(); } -void SmallRuler::setMarkers(QList < CommentedTime > list) +void SmallRuler::setMarkers(const QList &list) { m_markers = list; updatePixmap(); } -QPoint SmallRuler::zone() +QPoint SmallRuler::zone() const { return QPoint(m_zoneStart, m_zoneEnd); } @@ -121,6 +122,7 @@ QPoint SmallRuler::zone() // virtual void SmallRuler::mousePressEvent(QMouseEvent * event) { + m_render->setActiveMonitor(); const int pos = event->x() / m_scale; if (event->button() == Qt::RightButton) { // Right button clicked, move selection zone @@ -148,7 +150,7 @@ void SmallRuler::mouseReleaseEvent(QMouseEvent * event) void SmallRuler::leaveEvent(QEvent * event) { QWidget::leaveEvent(event); - if (m_cursorColor == palette().highlight()) { + if (m_cursorColor == palette().link()) { m_cursorColor = palette().text(); update(); } @@ -168,10 +170,10 @@ void SmallRuler::mouseMoveEvent(QMouseEvent * event) else { if (m_cursorColor == palette().text() && qAbs(pos - m_cursorFramePosition) * m_scale < 7) { // Mouse is over cursor - m_cursorColor = palette().highlight(); + m_cursorColor = palette().link(); update(); } - else if (m_cursorColor == palette().highlight() && qAbs(pos - m_cursorFramePosition) * m_scale >= 7) { + else if (m_cursorColor == palette().link() && qAbs(pos - m_cursorFramePosition) * m_scale >= 7) { m_cursorColor = palette().text(); update(); } @@ -180,7 +182,7 @@ void SmallRuler::mouseMoveEvent(QMouseEvent * event) } else if (qAbs((pos - m_zoneEnd) * m_scale) < 4) { setToolTip(i18n("Zone end: %1", m_monitor->getTimecodeFromFrames(m_zoneEnd))); } - for (int i = 0; i < m_markers.count(); i++) { + for (int i = 0; i < m_markers.count(); ++i) { if (qAbs((pos - m_markers.at(i).time().frames(m_monitor->fps())) * m_scale) < 4) { // We are on a marker QString markerxt = m_monitor->getMarkerThumb(m_markers.at(i).time()); @@ -240,9 +242,7 @@ void SmallRuler::updatePixmap() const int zoneStart = (int)(m_zoneStart * m_scale); const int zoneEnd = (int)(m_zoneEnd * m_scale); - p.setPen(Qt::NoPen); - p.setBrush(m_zoneBrush.brush(this)); - p.drawRect(zoneStart, 0, zoneEnd - zoneStart, height()); + p.fillRect(zoneStart, 0, zoneEnd - zoneStart, height(), QBrush(m_zoneColor)); // draw ruler p.setPen(palette().midlight().color()); @@ -262,7 +262,7 @@ void SmallRuler::updatePixmap() } // draw markers if (!m_markers.isEmpty()) { - for (int i = 0; i < m_markers.count(); i++) { + for (int i = 0; i < m_markers.count(); ++i) { int pos = m_markers.at(i).time().frames(m_monitor->fps()) * m_scale; p.setPen(CommentedTime::markerColor(m_markers.at(i).markerType())); p.drawLine(pos, 0, pos, 9); @@ -287,21 +287,22 @@ void SmallRuler::paintEvent(QPaintEvent *e) int cursorPos = m_cursorFramePosition * m_scale; // draw pointer QPolygon pa(3); - pa.setPoints(3, cursorPos - 6, 7, cursorPos + 6, 7, cursorPos/*+0*/, 0); + pa.setPoints(3, cursorPos - 6, height() - 1, cursorPos + 6, height() - 1, cursorPos/*+0*/, height() - 8); p.setBrush(m_cursorColor); p.setPen(Qt::NoPen); p.drawPolygon(pa); // Draw seeking pointer if (m_lastSeekPosition != SEEK_INACTIVE && m_lastSeekPosition != m_cursorFramePosition) { - p.fillRect(m_lastSeekPosition * m_scale - 1, 0, 3, height(), palette().highlight()); + p.fillRect(m_lastSeekPosition * m_scale - 1, 0, 3, height(), palette().linkVisited()); } } void SmallRuler::updatePalette() { KSharedConfigPtr config = KSharedConfig::openConfig(KdenliveSettings::colortheme()); - m_zoneBrush = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, config); + m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor, config).brush(this).color(); + m_zoneColor.setAlpha(180); updatePixmap(); }