]> git.sesse.net Git - kdenlive/blobdiff - src/customruler.cpp
Fix color of warning message in render widget
[kdenlive] / src / customruler.cpp
index 1c7d78e1ba7991cf6d1e82bae2856ff3bc74d8b5..2d07ee52ce46b9d5a9e29e17655877f8a4580c60 100644 (file)
@@ -24,6 +24,7 @@
 #include <KIcon>
 #include <KCursor>
 #include <KGlobalSettings>
+#include <KColorScheme>
 
 #include <QApplication>
 #include <QMouseEvent>
@@ -67,7 +68,7 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
     QFontMetricsF fontMetrics(font());
     LABEL_SIZE = fontMetrics.ascent() - 2;
     m_scale = 3;
-    m_zoneColor = QColor(133, 255, 143);
+    m_zoneColor = KStatefulBrush(KColorScheme::View, KColorScheme::PositiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme())).brush(this).color();
     littleMarkDistance = FRAME_SIZE;
     mediumMarkDistance = FRAME_SIZE * m_timecode.fps();
     bigMarkDistance = FRAME_SIZE * m_timecode.fps() * 60;
@@ -82,6 +83,8 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent) :
     connect(m_deleteGuide , SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
     QAction *delAllGuides = m_contextMenu->addAction(KIcon("edit-delete"), i18n("Delete All Guides"));
     connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides()));
+    m_goMenu = m_contextMenu->addMenu(i18n("Go To"));
+    connect(m_goMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotGoToGuide(QAction *)));
     setMouseTracking(true);
     setMinimumHeight(20);
 }
@@ -104,6 +107,12 @@ void CustomRuler::slotDeleteGuide()
     m_view->slotDeleteGuide(m_clickedGuide);
 }
 
+void CustomRuler::slotGoToGuide(QAction *act)
+{
+    m_view->setCursorPos(act->data().toInt(), true);
+    m_view->initCursorPos(act->data().toInt());
+}
+
 void CustomRuler::setZone(QPoint p)
 {
     m_zoneStart = p.x();
@@ -124,6 +133,7 @@ void CustomRuler::mousePressEvent(QMouseEvent * event)
         m_clickedGuide = m_view->hasGuide((int)(pos / m_factor), (int)(5 / m_factor + 1));
         m_editGuide->setEnabled(m_clickedGuide > 0);
         m_deleteGuide->setEnabled(m_clickedGuide > 0);
+        m_view->buildGuidesMenu(m_goMenu);
         m_contextMenu->exec(event->globalPos());
         return;
     }
@@ -146,7 +156,10 @@ void CustomRuler::mousePressEvent(QMouseEvent * event)
 void CustomRuler::mouseMoveEvent(QMouseEvent * event)
 {
     if (event->buttons() == Qt::LeftButton) {
-        int pos = (int)((event->x() + offset()) / m_factor);
+        int pos;
+        if (m_moveCursor == RULER_START || m_moveCursor == RULER_END) {
+            pos = m_view->getSnapPointForPos((int)((event->x() + offset()) / m_factor));
+        } else pos = (int)((event->x() + offset()) / m_factor);
         int zoneStart = m_zoneStart;
         int zoneEnd = m_zoneEnd;
         if (pos < 0) pos = 0;
@@ -327,18 +340,23 @@ void CustomRuler::paintEvent(QPaintEvent *e)
     const int value  = m_view->cursorPos() * m_factor - m_offset;
     int minval = (e->rect().left() + m_offset) / FRAME_SIZE - 1;
     const int maxval = (e->rect().right() + m_offset) / FRAME_SIZE + 1;
-    if (minval < 0) minval = 0;
+    if (minval < 0)
+        minval = 0;
 
     double f, fend;
     const int offsetmax = maxval * FRAME_SIZE;
 
-    p.setPen(palette().dark().color());
+    p.setPen(palette().text().color());
 
     // draw time labels
     int offsetmin = (e->rect().left() + m_offset) / m_textSpacing;
     offsetmin = offsetmin * m_textSpacing;
     for (f = offsetmin; f < offsetmax; f += m_textSpacing) {
-        QString lab = m_timecode.getTimecodeFromFrames((int)(f / m_factor + 0.5));
+        QString lab;
+        if (KdenliveSettings::frametimecode())
+            lab = QString::number((int)(f / m_factor + 0.5));
+        else
+            lab = m_timecode.getTimecodeFromFrames((int)(f / m_factor + 0.5));
         p.drawText(f - m_offset + 2, LABEL_SIZE, lab);
     }
 
@@ -346,22 +364,28 @@ void CustomRuler::paintEvent(QPaintEvent *e)
     offsetmin = offsetmin * littleMarkDistance;
     // draw the little marks
     fend = m_scale * littleMarkDistance;
-    if (fend > 5) for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
+    if (fend > 5) {
+        for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
             p.drawLine((int)f, LITTLE_MARK_X1, (int)f, LITTLE_MARK_X2);
+    }
 
     offsetmin = (e->rect().left() + m_offset) / mediumMarkDistance;
     offsetmin = offsetmin * mediumMarkDistance;
     // draw medium marks
     fend = m_scale * mediumMarkDistance;
-    if (fend > 5) for (f = offsetmin - m_offset - fend; f < offsetmax - m_offset + fend; f += fend)
+    if (fend > 5) {
+        for (f = offsetmin - m_offset - fend; f < offsetmax - m_offset + fend; f += fend)
             p.drawLine((int)f, MIDDLE_MARK_X1, (int)f, MIDDLE_MARK_X2);
+    }
 
     offsetmin = (e->rect().left() + m_offset) / bigMarkDistance;
     offsetmin = offsetmin * bigMarkDistance;
     // draw big marks
     fend = m_scale * bigMarkDistance;
-    if (fend > 5) for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
+    if (fend > 5) {
+        for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
             p.drawLine((int)f, BIG_MARK_X1, (int)f, BIG_MARK_X2);
+    }
 
     // draw zone cursors
     int off = offset();