Files
oak-editor/app/widget/slider/timeslider.cpp
T
itsmattkc abb4c440fb core: added signalling for timecode display changes
Allows targeted application-wide UI updates for when the user changes the
timecode display so that the response is immediate.
2020-03-18 14:09:31 +11:00

43 lines
1.1 KiB
C++

#include "timeslider.h"
#include "common/timecodefunctions.h"
#include "core.h"
TimeSlider::TimeSlider(QWidget *parent) :
IntegerSlider(parent)
{
SetMinimum(0);
connect(Core::instance(), &Core::TimecodeDisplayChanged, this, &TimeSlider::TimecodeDisplayChanged);
}
void TimeSlider::SetTimebase(const rational &timebase)
{
timebase_ = timebase;
// Refresh label since we have a new timebase to generate a timecode with
UpdateLabel(Value());
}
QString TimeSlider::ValueToString(const QVariant &v)
{
if (timebase_.isNull()) {
// We can't generate a timecode without a timebase, so we just return the number
return IntegerSlider::ValueToString(v);
}
return Timecode::timestamp_to_timecode(v.toLongLong(),
timebase_,
Core::instance()->GetTimecodeDisplay());
}
QVariant TimeSlider::StringToValue(const QString &s, bool *ok)
{
return QVariant::fromValue(Timecode::timecode_to_timestamp(s, timebase_, Core::instance()->GetTimecodeDisplay(), ok));
}
void TimeSlider::TimecodeDisplayChanged()
{
UpdateLabel(Value());
}