Implement Alt Click to default on sliders

The following sliders now have Alt Click functionality:
 - Nodes (What it's initialy set too or 0 if not)
 - Export Dialog Dimensions~ (Defaults to Sequence width/height)
 - Export Compression Settings~
    - Advanced (0)
 - Speed/Duration
    - Speed (100%)
    - Duration (clip length)
 - Stream Properties Image sequence
    - Start Index (1)
    - End Index (sequence length)

Sliders with no default value set ignore an Alt
Click.

Added SliderBase::SetDefaultValue() which sets the
default value of a slider.

Added ValueReset() to SliderBase signals which is
called if a slider is Alt Clicked on. Only updates
if default_value_ is not Null.
This commit is contained in:
Thomas Wilshaw
2020-05-07 22:14:37 +01:00
parent 502ce85828
commit cb1127936a
10 changed files with 69 additions and 18 deletions
+15 -1
View File
@@ -23,6 +23,7 @@
#include <QDebug>
#include <QEvent>
#include <QMessageBox>
#include <QGuiApplication>
OLIVE_NAMESPACE_ENTER
@@ -49,6 +50,7 @@ SliderBase::SliderBase(Mode mode, QWidget *parent) :
connect(label_, SIGNAL(dragged(int)), this, SLOT(LabelDragged(int)));
connect(label_, SIGNAL(drag_stop()), this, SLOT(LabelClicked()));
connect(label_, SIGNAL(focused()), this, SLOT(LabelClicked()));
connect(label_, SIGNAL(ResetResult()), this, SLOT(ValueReset()));
connect(editor_, SIGNAL(Confirmed()), this, SLOT(LineEditConfirmed()));
connect(editor_, SIGNAL(Cancelled()), this, SLOT(LineEditCancelled()));
@@ -137,6 +139,11 @@ void SliderBase::SetValue(const QVariant &v)
UpdateLabel(value_);
}
void SliderBase::SetDefaultValue(const QVariant &v)
{
default_value_ = ClampValue(v);
}
void SliderBase::SetMinimumInternal(const QVariant &v)
{
min_value_ = v;
@@ -241,7 +248,6 @@ void SliderBase::LabelClicked()
emit ValueChanged(value_);
} else {
// This was a simple click
// Load label's text into editor
editor_->setText(ValueToString(value_));
@@ -327,4 +333,12 @@ void SliderBase::LineEditCancelled()
label_->blockSignals(false);
}
void SliderBase::ValueReset()
{
if (!default_value_.isNull()) {
SetValue(default_value_);
emit ValueChanged(value_);
}
}
OLIVE_NAMESPACE_EXIT