X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Ftimecode.cpp;h=789b286103d2bf0659513ec0c6fc04da94b64cf9;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=0e1fee55cd40c1a3e1e7fb093006505bf65616f3;hpb=9f5a8d1e6c378bf63d66c98e0c270fd86e73b6f1;p=kdenlive diff --git a/src/timecode.cpp b/src/timecode.cpp index 0e1fee55..789b2861 100644 --- a/src/timecode.cpp +++ b/src/timecode.cpp @@ -117,7 +117,7 @@ bool Timecode::df() const return m_dropFrameTimecode; } -const QString Timecode::mask(GenTime t) const +const QString Timecode::mask(const GenTime& t) const { if (t < GenTime()) { if (m_dropFrameTimecode) return "#99:99:99,99"; @@ -145,7 +145,6 @@ int Timecode::getFrameCount(const QString &duration) const if (duration.isEmpty()) { return 0; } - int hours, minutes, seconds, frames; int offset = 0; if (duration.at(0) == '-') { @@ -166,7 +165,7 @@ int Timecode::getFrameCount(const QString &duration) const int frameNumber = ((m_displayedFramesPerSecond * 3600 * hours) + (m_displayedFramesPerSecond * 60 * minutes) + (m_displayedFramesPerSecond * seconds) + frames) - (m_dropFrames * (totalMinutes - floor(totalMinutes / 10))); return frameNumber; } - return (int)(hours * 3600.0 + minutes * 60.0 + seconds * m_realFps + frames); + return (int)((hours * 3600.0 + minutes * 60.0 + seconds) * m_realFps + frames); } QString Timecode::getDisplayTimecode(const GenTime & time, bool frameDisplay) const @@ -211,7 +210,7 @@ const QString Timecode::getTimecodeFromFrames(int frames) const //static -QString Timecode::getStringTimecode(int frames, const double &fps) +QString Timecode::getStringTimecode(int frames, const double &fps, bool showFrames) { // Returns the timecode in an hh:mm:ss format @@ -222,6 +221,7 @@ QString Timecode::getStringTimecode(int frames, const double &fps) } int seconds = (int)(frames / fps); + int frms = frames % (int) (fps + 0.5); int minutes = seconds / 60; seconds = seconds % 60; int hours = minutes / 60; @@ -234,6 +234,10 @@ QString Timecode::getStringTimecode(int frames, const double &fps) text.append(QString::number(minutes).rightJustified(2, '0', false)); text.append(':'); text.append(QString::number(seconds).rightJustified(2, '0', false)); + if (showFrames) { + text.append('.'); + text.append(QString::number(frms).rightJustified(2, '0', false)); + } return text; }