time ruler interactivity
This commit is contained in:
@@ -24,5 +24,7 @@ set(OLIVE_SOURCES
|
||||
common/qobjectlistcast.h
|
||||
common/qtversionabstraction.h
|
||||
common/qtversionabstraction.cpp
|
||||
common/timecodefunctions.h
|
||||
common/timecodefunctions.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -1,2 +1,24 @@
|
||||
#include "timecodefunctions.h"
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
QString padded(int arg, int padding) {
|
||||
return QString("%1").arg(arg, padding, 10, QChar('0'));
|
||||
}
|
||||
|
||||
QString olive::timestamp_to_timecode(const rational ×tamp)
|
||||
{
|
||||
double timestamp_dbl = timestamp.ToDouble();
|
||||
|
||||
int total_seconds = qFloor(timestamp_dbl);
|
||||
|
||||
int hours = total_seconds / 3600;
|
||||
int mins = total_seconds / 60 - hours * 60;
|
||||
int secs = total_seconds - mins * 60;
|
||||
int fraction = qRound((timestamp_dbl - total_seconds) * 1000);
|
||||
|
||||
return QString("%1:%2:%3.%4").arg(padded(hours, 2),
|
||||
padded(mins, 2),
|
||||
padded(secs, 2),
|
||||
padded(fraction, 3));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#ifndef TIMECODEFUNCTIONS_H
|
||||
#define TIMECODEFUNCTIONS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "common/rational.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
QString timestamp_to_timecode(const rational& timestamp);
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMECODEFUNCTIONS_H
|
||||
|
||||
Reference in New Issue
Block a user