]> git.sesse.net Git - kdenlive/blobdiff - src/customruler.cpp
Improve reloading of externally modified clips (wait for 1.5 second before reloading...
[kdenlive] / src / customruler.cpp
index e840c20db0cf6bc5d509ee89710516103d4a573f..6606b77024bc8b666351fe24a767d29b63db194c 100644 (file)
@@ -18,6 +18,7 @@
  ***************************************************************************/
 
 #include "customruler.h"
+#include "kdenlivesettings.h"
 
 #include <KDebug>
 #include <KIcon>
@@ -81,6 +82,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);
 }
@@ -103,13 +106,16 @@ void CustomRuler::slotDeleteGuide()
     m_view->slotDeleteGuide(m_clickedGuide);
 }
 
+void CustomRuler::slotGoToGuide(QAction *act)
+{
+    m_view->initCursorPos(act->data().toInt());
+}
+
 void CustomRuler::setZone(QPoint p)
 {
-    int min = qMin(m_zoneStart, p.x());
-    int max = qMax(m_zoneEnd, p.y());
     m_zoneStart = p.x();
     m_zoneEnd = p.y();
-    update(min * m_factor - 2, 0, (max - min) * m_factor + 4, height());
+    update();
 }
 
 void CustomRuler::mouseReleaseEvent(QMouseEvent * /*event*/)
@@ -125,6 +131,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;
     }
@@ -154,7 +161,7 @@ void CustomRuler::mouseMoveEvent(QMouseEvent * event)
         if (m_moveCursor == RULER_CURSOR) {
             QPoint diff = event->pos() - m_clickPoint;
             if (m_mouseMove == NO_MOVE) {
-                if (qAbs(diff.x()) >= QApplication::startDragDistance()) {
+                if (!KdenliveSettings::verticalzoom() || qAbs(diff.x()) >= QApplication::startDragDistance()) {
                     m_mouseMove = HORIZONTAL_MOVE;
                 } else if (qAbs(diff.y()) >= QApplication::startDragDistance()) {
                     m_mouseMove = VERTICAL_MOVE;
@@ -188,16 +195,20 @@ void CustomRuler::mouseMoveEvent(QMouseEvent * event)
         if (event->y() <= 10) setCursor(Qt::ArrowCursor);
         else if (qAbs(pos - m_zoneStart * m_factor) < 4) {
             setCursor(KCursor("left_side", Qt::SizeHorCursor));
-            setToolTip(i18n("Zone start: %1", m_timecode.getTimecodeFromFrames(m_zoneStart)));
+            if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone start: %1", m_zoneStart));
+            else setToolTip(i18n("Zone start: %1", m_timecode.getTimecodeFromFrames(m_zoneStart)));
         } else if (qAbs(pos - m_zoneEnd * m_factor) < 4) {
             setCursor(KCursor("right_side", Qt::SizeHorCursor));
-            setToolTip(i18n("Zone end: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd)));
+            if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone end: %1", m_zoneEnd));
+            else setToolTip(i18n("Zone end: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd)));
         } else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * m_factor) < 4) {
             setCursor(Qt::SizeHorCursor);
-            setToolTip(i18n("Zone duration: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd - m_zoneStart)));
+            if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone duration: %1", m_zoneEnd - m_zoneStart));
+            else setToolTip(i18n("Zone duration: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd - m_zoneStart)));
         } else {
             setCursor(Qt::ArrowCursor);
-            setToolTip(i18n("Position: %1", m_timecode.getTimecodeFromFrames(pos)));
+            if (KdenliveSettings::frametimecode()) setToolTip(i18n("Position: %1", (int)(pos / m_factor)));
+            else setToolTip(i18n("Position: %1", m_timecode.getTimecodeFromFrames(pos / m_factor)));
         }
     }
 }