]> git.sesse.net Git - kdenlive/blobdiff - src/markerdialog.cpp
Fix dropframe timecode, patch from John T. Mertz
[kdenlive] / src / markerdialog.cpp
index c437aa82d3505a0a88b98905999e795cea873ec7..2f9ff112928e55f7f144f3fbc9c7d60a9e39ec3b 100644 (file)
@@ -31,7 +31,8 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
         m_producer(NULL),
         m_profile(NULL),
         m_clip(clip),
-        m_tc(tc)
+        m_tc(tc),
+        m_frameDisplay(KdenliveSettings::frametimecode())
 {
     setFont(KGlobalSettings::toolBarFont());
     m_fps = m_tc.fps();
@@ -82,10 +83,12 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons
         connect(marker_position, SIGNAL(textChanged(const QString &)), this, SIGNAL(updateThumb()));
     } else clip_thumb->setHidden(true);
 
-    if (KdenliveSettings::frametimecode()) {
-        marker_position->setInputMask("000000000000");
-        marker_position->setText(QString::number((int) t.time().frames(m_fps)));
-    } else marker_position->setText(tc.getTimecode(t.time()));
+    if (m_frameDisplay) {
+        QValidator *valid = new QIntValidator(this);
+        marker_position->setInputMask("");
+        marker_position->setValidator(valid);
+    } else marker_position->setInputMask(tc.inputMask());
+    marker_position->setText(tc.getDisplayTimecode(t.time(), m_frameDisplay));
 
     marker_comment->setText(t.comment());
     marker_comment->selectAll();
@@ -107,9 +110,7 @@ MarkerDialog::~MarkerDialog()
 void MarkerDialog::slotUpdateThumb()
 {
     m_previewTimer->stop();
-    int pos;
-    if (KdenliveSettings::frametimecode()) pos = marker_position->text().toInt();
-    else pos = m_tc.getFrameCount(marker_position->text());
+    int pos = m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay);
     int width = 100.0 * m_dar;
     if (width % 2 == 1) width++;
     QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, width, 100));
@@ -119,30 +120,23 @@ void MarkerDialog::slotUpdateThumb()
 
 void MarkerDialog::slotTimeUp()
 {
-    int duration;
-    if (KdenliveSettings::frametimecode()) duration = marker_position->text().toInt();
-    else duration = m_tc.getFrameCount(marker_position->text());
+    int duration = m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay);
     if (m_clip && duration >= m_clip->duration().frames(m_fps)) return;
     duration ++;
-    if (KdenliveSettings::frametimecode()) marker_position->setText(QString::number(duration));
-    else marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
+    marker_position->setText(m_tc.getDisplayTimecode(GenTime(duration, m_fps), m_frameDisplay));
 }
 
 void MarkerDialog::slotTimeDown()
 {
-    int duration;
-    if (KdenliveSettings::frametimecode()) duration = marker_position->text().toInt();
-    else duration = m_tc.getFrameCount(marker_position->text());
+    int duration = m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay);
     if (duration <= 0) return;
     duration --;
-    if (KdenliveSettings::frametimecode()) marker_position->setText(QString::number(duration));
-    else marker_position->setText(m_tc.getTimecode(GenTime(duration, m_fps)));
+    marker_position->setText(m_tc.getDisplayTimecode(GenTime(duration, m_fps), m_frameDisplay));
 }
 
 CommentedTime MarkerDialog::newMarker()
 {
-    if (KdenliveSettings::frametimecode()) return CommentedTime(GenTime(marker_position->text().toInt(), m_fps), marker_comment->text());
-    return CommentedTime(GenTime(m_tc.getFrameCount(marker_position->text()), m_fps), marker_comment->text());
+    return CommentedTime(GenTime(m_tc.getDisplayFrameCount(marker_position->text(), m_frameDisplay), m_fps), marker_comment->text());
 }
 
 void MarkerDialog::wheelEvent(QWheelEvent * event)