]> git.sesse.net Git - kdenlive/commitdiff
Improve displaying of negative timecodes
authorTill Theato <root@ttill.de>
Sat, 25 Sep 2010 21:41:33 +0000 (21:41 +0000)
committerTill Theato <root@ttill.de>
Sat, 25 Sep 2010 21:41:33 +0000 (21:41 +0000)
svn path=/trunk/kdenlive/; revision=4934

src/customtrackview.cpp
src/timecode.cpp

index 16318c831ca82bf45f9148018df43b4de183db90..05850070339ad26c1c115499828ae12b59e1c798 100644 (file)
@@ -405,7 +405,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                 QString crop = m_document->timecode().getDisplayTimecode(m_dragItem->cropStart(), KdenliveSettings::frametimecode());
                 QString duration = m_document->timecode().getDisplayTimecode(m_dragItem->cropDuration(), KdenliveSettings::frametimecode());
                 QString offset = m_document->timecode().getDisplayTimecode(m_dragItem->cropStart() - m_dragItemInfo.cropStart, KdenliveSettings::frametimecode());
-                emit displayMessage(i18n("Crop from start:") + " " + crop + " " + i18n("Duration:") + " " + duration + " " + i18n("Offset: ") + offset, InformationMessage);
+                emit displayMessage(i18n("Crop from start:") + ' ' + crop + ' ' + i18n("Duration:") + ' ' + duration + ' ' + i18n("Offset:") + ' ' + offset, InformationMessage);
             } else if (m_operationMode == RESIZEEND && move) {
                 m_document->renderer()->pause();
                 if (!m_controlModifier && m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
@@ -417,7 +417,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                 }
                 QString duration = m_document->timecode().getDisplayTimecode(m_dragItem->cropDuration(), KdenliveSettings::frametimecode());
                 QString offset = m_document->timecode().getDisplayTimecode(m_dragItem->cropDuration() - m_dragItemInfo.cropDuration, KdenliveSettings::frametimecode());
-                emit displayMessage(i18n("Duration:") + " " + duration + " " + i18n("Offset: ") + offset, InformationMessage);
+                emit displayMessage(i18n("Duration:") + ' ' + duration + ' ' + i18n("Offset:") + ' ' + offset, InformationMessage);
             } else if (m_operationMode == FADEIN && move) {
                 ((ClipItem*) m_dragItem)->setFadeIn((int)(mappedXPos - m_dragItem->startPos().frames(m_document->fps())));
             } else if (m_operationMode == FADEOUT && move) {
index bcea5d5c1caeaaa664be01b598ef8b4c725e836d..3b5749773f5a3ffe26051b57e0a88c6ae0b5746c 100644 (file)
@@ -217,12 +217,21 @@ const QString Timecode::getTimecodeFromFrames(int frames) const
 QString Timecode::getStringTimecode(int frames, const double &fps)
 {
     // Returns the timecode in an hh:mm:ss format
+
+    bool negative = false;
+    if (frames < 0) {
+        negative = true;
+        frames = qAbs(frames);
+    }
+
     int seconds = (int)(frames / fps);
     int minutes = seconds / 60;
     seconds = seconds % 60;
     int hours = minutes / 60;
     minutes = minutes % 60;
     QString text;
+    if (negative)
+        text.append('-');
     text.append(QString::number(hours).rightJustified(2, '0', false));
     text.append(':');
     text.append(QString::number(minutes).rightJustified(2, '0', false));
@@ -237,6 +246,13 @@ QString Timecode::getEasyTimecode(const GenTime & time, const double &fps)
 {
     // Returns the timecode in an easily read display, like 3 min. 5 sec.
     int frames = (int) time.frames(fps);
+
+    bool negative = false;
+    if (frames < 0) {
+        negative = true;
+        frames = qAbs(frames);
+    }
+
     int seconds = (int)(frames / fps);
     frames = frames - ((int)(fps * seconds));
 
@@ -248,6 +264,8 @@ QString Timecode::getEasyTimecode(const GenTime & time, const double &fps)
     QString text;
     bool trim = false;
 
+    if (negative)
+        text.append('-');
     if (hours != 0) {
         text.append(QString::number(hours).rightJustified(2, '0', false));
         text.append(' ' + i18n("hour") + ' ');
@@ -291,6 +309,13 @@ const QString Timecode::getTimecodeHH_MM_SS_FF(int frames) const
     if (m_dropFrameTimecode) {
         return getTimecodeDropFrame(frames);
     }
+
+    bool negative = false;
+    if (frames < 0) {
+        negative = true;
+        frames = qAbs(frames);
+    }
+
     int seconds = frames / m_displayedFramesPerSecond;
     frames = frames % m_displayedFramesPerSecond;
 
@@ -300,6 +325,8 @@ const QString Timecode::getTimecodeHH_MM_SS_FF(int frames) const
     minutes = minutes % 60;
 
     QString text;
+    if (negative)
+        text.append('-');
     text.append(QString::number(hours).rightJustified(2, '0', false));
     text.append(':');
     text.append(QString::number(minutes).rightJustified(2, '0', false));
@@ -314,6 +341,13 @@ const QString Timecode::getTimecodeHH_MM_SS_FF(int frames) const
 const QString Timecode::getTimecodeHH_MM_SS_HH(const GenTime & time) const
 {
     int hundredths = (int)(time.seconds() * 100);
+
+    bool negative = false;
+    if (hundredths < 0) {
+        negative = true;
+        hundredths = qAbs(hundredths);
+    }
+
     int seconds = hundredths / 100;
     hundredths = hundredths % 100;
     int minutes = seconds / 60;
@@ -322,7 +356,8 @@ const QString Timecode::getTimecodeHH_MM_SS_HH(const GenTime & time) const
     minutes = minutes % 60;
 
     QString text;
-
+    if (negative)
+        text.append('-');
     text.append(QString::number(hours).rightJustified(2, '0', false));
     text.append(':');
     text.append(QString::number(minutes).rightJustified(2, '0', false));
@@ -359,6 +394,12 @@ const QString Timecode::getTimecodeDropFrame(int framenumber) const
     //Given an int called framenumber and a double called framerate
     //Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.
 
+    bool negative = false;
+    if (framenumber < 0) {
+        negative = true;
+        framenumber = qAbs(framenumber);
+    }
+
     int d = floor(framenumber / m_framesPer10Minutes);
     int m = framenumber % m_framesPer10Minutes;
 
@@ -374,6 +415,8 @@ const QString Timecode::getTimecodeDropFrame(int framenumber) const
     int hours = floor(floor(floor(framenumber / m_displayedFramesPerSecond) / 60) / 60);
 
     QString text;
+    if (negative)
+        text.append('-');
     text.append(QString::number(hours).rightJustified(2, '0', false));
     text.append(':');
     text.append(QString::number(minutes).rightJustified(2, '0', false));