Add a lock on changing the display type
This commit is contained in:
@@ -20,12 +20,13 @@
|
|||||||
|
|
||||||
namespace olive {
|
namespace olive {
|
||||||
|
|
||||||
RationalSlider::RationalSlider(DisplayType display_type, rational timebase, QWidget *parent) :
|
RationalSlider::RationalSlider(rational timebase, QWidget *parent) :
|
||||||
SliderBase(SliderBase::kRational, parent),
|
SliderBase(SliderBase::kRational, parent),
|
||||||
display_type_(display_type),
|
display_type_(kTimecode),
|
||||||
decimal_places_(2),
|
decimal_places_(2),
|
||||||
autotrim_decimal_places_(false),
|
autotrim_decimal_places_(false),
|
||||||
timebase_(timebase)
|
timebase_(timebase),
|
||||||
|
lock_display_type_(false)
|
||||||
{
|
{
|
||||||
connect(this, SIGNAL(ValueChanged(QVariant)), this, SLOT(ConvertValue(QVariant)));
|
connect(this, SIGNAL(ValueChanged(QVariant)), this, SLOT(ConvertValue(QVariant)));
|
||||||
connect(this, &SliderBase::changeRationalDisplayType, this, &RationalSlider::changeDisplayType);
|
connect(this, &SliderBase::changeRationalDisplayType, this, &RationalSlider::changeDisplayType);
|
||||||
@@ -106,6 +107,16 @@ void RationalSlider::SetDisplayType(const RationalSlider::DisplayType &type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RationalSlider::SetLockDisplayType(bool e)
|
||||||
|
{
|
||||||
|
lock_display_type_ = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RationalSlider::LockDisplayType()
|
||||||
|
{
|
||||||
|
return lock_display_type_;
|
||||||
|
}
|
||||||
|
|
||||||
QString RationalSlider::ValueToString(const QVariant &v)
|
QString RationalSlider::ValueToString(const QVariant &v)
|
||||||
{
|
{
|
||||||
double time = v.value<rational>().toDouble();
|
double time = v.value<rational>().toDouble();
|
||||||
@@ -179,9 +190,11 @@ void RationalSlider::ConvertValue(QVariant v)
|
|||||||
|
|
||||||
void RationalSlider::changeDisplayType()
|
void RationalSlider::changeDisplayType()
|
||||||
{
|
{
|
||||||
// Loop through the display types
|
if (!LockDisplayType()) {
|
||||||
SetDisplayType(static_cast<RationalSlider::DisplayType>(((int)(display_type_)+1)%4));
|
// Loop through the display types
|
||||||
ForceLabelUpdate();
|
SetDisplayType(static_cast<RationalSlider::DisplayType>(((int)(display_type_) + 1) % 4));
|
||||||
|
ForceLabelUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RationalSlider::ChangeTimecodeDisplayType()
|
void RationalSlider::ChangeTimecodeDisplayType()
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
kFloat
|
kFloat
|
||||||
};
|
};
|
||||||
|
|
||||||
RationalSlider(DisplayType display_type, rational timebase, QWidget* parent = nullptr);
|
RationalSlider(rational timebase, QWidget* parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the sliders value as a rational
|
* @brief Returns the sliders value as a rational
|
||||||
@@ -58,6 +58,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetValue(const rational& d);
|
void SetValue(const rational& d);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the sliders default value
|
||||||
|
*/
|
||||||
void SetDefaultValue(const rational& r);
|
void SetDefaultValue(const rational& r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,6 +88,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetDisplayType(const DisplayType& type);
|
void SetDisplayType(const DisplayType& type);
|
||||||
|
|
||||||
|
void SetLockDisplayType(bool e);
|
||||||
|
|
||||||
|
bool LockDisplayType();
|
||||||
|
|
||||||
void SetAutoTrimDecimalPlaces(bool e);
|
void SetAutoTrimDecimalPlaces(bool e);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -116,6 +123,7 @@ private:
|
|||||||
|
|
||||||
rational timebase_;
|
rational timebase_;
|
||||||
|
|
||||||
|
bool lock_display_type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,6 @@ const QVariant &SliderBase::ClampValue(const QVariant &v)
|
|||||||
if (has_min_ && value < min) {
|
if (has_min_ && value < min) {
|
||||||
return min_value_;
|
return min_value_;
|
||||||
}else if (has_max_ && value > max) {
|
}else if (has_max_ && value > max) {
|
||||||
printf("MAX: %f\n", max_value_.value<rational>().toDouble());
|
|
||||||
return max_value_;
|
return max_value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user