]> git.sesse.net Git - kdenlive/commitdiff
Make it easier to edit timecode by selecting the digit after the cursor
authorTill Theato <root@ttill.de>
Sat, 6 Nov 2010 21:16:59 +0000 (21:16 +0000)
committerTill Theato <root@ttill.de>
Sat, 6 Nov 2010 21:16:59 +0000 (21:16 +0000)
svn path=/trunk/kdenlive/; revision=5078

src/monitor.cpp
src/timecodedisplay.cpp
src/timecodedisplay.h

index ad2b114f77849f9fbc7ecb418fb6f5a7c01c2ee5..96b76be3004a503ce30a8b570d412d6a26c820f9 100644 (file)
@@ -1095,6 +1095,8 @@ void VideoContainer::wheelEvent(QWheelEvent * event)
 
 void VideoContainer::mouseDoubleClickEvent(QMouseEvent * event)
 {
+    Q_UNUSED(event);
+
     if (!KdenliveSettings::openglmonitors())
         switchFullScreen();
 }
index 72bbd863e0e62c4e7860293d7b9fa013a7d3871c..55d5fd08525d8a6f3ea6fd8067e388164616e925 100644 (file)
@@ -46,6 +46,7 @@ TimecodeDisplay::TimecodeDisplay(Timecode t, QWidget *parent)
     connect(uparrow, SIGNAL(clicked()), this, SLOT(slotValueUp()));
     connect(downarrow, SIGNAL(clicked()), this, SLOT(slotValueDown()));
     connect(lineedit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
+    connect(lineedit, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(slotCursorPositionChanged(int, int)));
 }
 
 void TimecodeDisplay::slotValueUp()
@@ -172,4 +173,26 @@ void TimecodeDisplay::setValue(GenTime value)
     setValue(m_timecode.getTimecode(value));
 }
 
+void TimecodeDisplay::slotCursorPositionChanged(int oldPos, int newPos)
+{
+    lineedit->blockSignals(true);
+    QString text = lineedit->text();
+
+    if (newPos < text.size() && !text.at(newPos).isDigit()) {
+        // char at newPos is a separator (':' or ';')
+
+        // make it possible move the cursor backwards at separators
+        if (newPos == oldPos - 1)
+            lineedit->setSelection(newPos, -1);
+        else
+            lineedit->setSelection(newPos + 2, -1);
+    } else if (newPos < text.size()) {
+        lineedit->setSelection(newPos + 1, -1);
+    } else {
+        lineedit->setSelection(newPos, -1);
+    }
+
+    lineedit->blockSignals(false);
+}
+
 #include <timecodedisplay.moc>
index dc1b8f8961607e688c7661c0db448290eee6f919..28045886efa149c6ee5bd9e824efe6a84c30a2c8 100644 (file)
@@ -98,6 +98,11 @@ private slots:
     void slotValueUp();
     void slotValueDown();
 
+    /** @brief Updates the selection when the cursor position changed.
+     * The digit after the cursor will be selected.
+     * This makes it easier to edit the timecode. */
+    void slotCursorPositionChanged(int oldPos, int newPos);
+
 signals:
     /**
      * Emitted every time the value changes (by calling setValue() or