slider: reviewed and conformed code

This commit is contained in:
itsmattkc
2020-05-09 18:53:00 +10:00
parent cd5a6a6b78
commit d653070a9d
9 changed files with 59 additions and 44 deletions
@@ -80,7 +80,6 @@ VideoStreamProperties::VideoStreamProperties(ImageStreamPtr stream) :
imgseq_start_time_ = new IntegerSlider();
imgseq_start_time_->SetMinimum(0);
imgseq_start_time_->SetValue(video_stream->start_time());
imgseq_start_time_->SetDefaultValue(video_stream->start_time());
imgseq_layout->addWidget(imgseq_start_time_, imgseq_row, 1);
imgseq_row++;
@@ -90,7 +89,6 @@ VideoStreamProperties::VideoStreamProperties(ImageStreamPtr stream) :
imgseq_end_time_ = new IntegerSlider();
imgseq_end_time_->SetMinimum(0);
imgseq_end_time_->SetValue(video_stream->start_time() + video_stream->duration() - 1);
imgseq_end_time_->SetDefaultValue(video_stream->start_time() + video_stream->duration() - 1);
imgseq_layout->addWidget(imgseq_end_time_, imgseq_row, 1);
video_layout->addWidget(imgseq_group, row, 0, 1, 2);
+3 -1
View File
@@ -112,9 +112,11 @@ SpeedDurationDialog::SpeedDurationDialog(const rational& timebase, const QList<C
duration_slider_ = new TimeSlider();
duration_slider_->SetTimebase(timebase_);
duration_slider_->SetMinimum(1);
duration_slider_->SetDefaultValue(Timecode::time_to_timestamp(clips_.first()->length(), timebase_));
speed_layout->addWidget(duration_slider_, row, 1);
// Calculate duration that would occur if the speed was 100%
duration_slider_->SetDefaultValue(GetUnadjustedLengthTimestamp(clips_.first()));
if (same_duration) {
duration_slider_->SetValue(Timecode::time_to_timestamp(clips_.first()->length(), timebase_));
} else {
+13
View File
@@ -386,9 +386,22 @@ void NodeInput::GetDependencies(QList<Node *> &list, bool traverse, bool exclusi
QVariant NodeInput::GetDefaultValue() const
{
if (default_value_.isEmpty()) {
return QVariant();
}
return combine_track_values_into_normal_value(default_value_);
}
QVariant NodeInput::GetDefaultValueForTrack(int track) const
{
if (default_value_.isEmpty()) {
return QVariant();
}
return default_value_.at(track);
}
QList<Node *> NodeInput::GetDependencies(bool traverse, bool exclusive_only) const
{
QList<Node *> list;
+2
View File
@@ -279,6 +279,8 @@ public:
QVariant GetDefaultValue() const;
QVariant GetDefaultValueForTrack(int track) const;
QList<Node*> GetDependencies(bool traverse = true, bool exclusive_only = false) const;
QList<Node*> GetExclusiveDependencies() const;
@@ -92,11 +92,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
case NodeParam::kInt:
{
IntegerSlider* slider = new IntegerSlider();
if (!input_->get_standard_value().isNull()) {
slider->SetDefaultValue(input_->get_standard_value());
} else {
slider->SetDefaultValue(0);
}
slider->SetDefaultValue(input_->GetDefaultValue());
widgets_.append(slider);
connect(slider, &IntegerSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
break;
@@ -369,11 +365,7 @@ void NodeParamViewWidgetBridge::CreateSliders(int count)
{
for (int i=0;i<count;i++) {
FloatSlider* fs = new FloatSlider();
if (!input_->get_standard_value().isNull()) {
fs->SetDefaultValue(input_->get_split_standard_value().at(i));
} else {
fs->SetDefaultValue(0.0f);
}
fs->SetDefaultValue(input_->GetDefaultValueForTrack(i));
widgets_.append(fs);
connect(fs, &FloatSlider::ValueChanged, this, &NodeParamViewWidgetBridge::WidgetCallback);
}
+9 -10
View File
@@ -23,7 +23,6 @@
#include <QDebug>
#include <QEvent>
#include <QMessageBox>
#include <QGuiApplication>
OLIVE_NAMESPACE_ENTER
@@ -46,13 +45,13 @@ SliderBase::SliderBase(Mode mode, QWidget *parent) :
editor_ = new FocusableLineEdit(this);
addWidget(editor_);
connect(label_, SIGNAL(drag_start()), this, SLOT(LabelPressed()));
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()));
connect(label_, &SliderLabel::drag_start, this, &SliderBase::LabelPressed);
connect(label_, &SliderLabel::dragged, this, &SliderBase::LabelDragged);
connect(label_, &SliderLabel::drag_stop, this, &SliderBase::LabelClicked);
connect(label_, &SliderLabel::focused, this, &SliderBase::LabelClicked);
connect(label_, &SliderLabel::RequestReset, this, &SliderBase::ResetValue);
connect(editor_, &FocusableLineEdit::Confirmed, this, &SliderBase::LineEditConfirmed);
connect(editor_, &FocusableLineEdit::Cancelled, this, &SliderBase::LineEditCancelled);
// Set valid cursor based on mode
switch (mode_) {
@@ -141,7 +140,7 @@ void SliderBase::SetValue(const QVariant &v)
void SliderBase::SetDefaultValue(const QVariant &v)
{
default_value_ = ClampValue(v);
default_value_ = v;
}
void SliderBase::SetMinimumInternal(const QVariant &v)
@@ -333,7 +332,7 @@ void SliderBase::LineEditCancelled()
label_->blockSignals(false);
}
void SliderBase::ValueReset()
void SliderBase::ResetValue()
{
if (!default_value_.isNull()) {
SetValue(default_value_);
+1 -1
View File
@@ -124,7 +124,7 @@ private slots:
void LineEditCancelled();
void ValueReset();
void ResetValue();
};
OLIVE_NAMESPACE_EXIT
+27 -18
View File
@@ -31,7 +31,8 @@
OLIVE_NAMESPACE_ENTER
SliderLabel::SliderLabel(QWidget *parent) :
QLabel(parent)
QLabel(parent),
dragging_(false)
{
QPalette p = palette();
@@ -53,12 +54,13 @@ SliderLabel::SliderLabel(QWidget *parent) :
setFocusPolicy(Qt::TabFocus);
}
void SliderLabel::mousePressEvent(QMouseEvent *)
void SliderLabel::mousePressEvent(QMouseEvent *e)
{
if (QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) {
emit ResetResult();
}else {
emit drag_start();
if (e->modifiers() & Qt::AltModifier) {
emit RequestReset();
} else {
#if defined(Q_OS_MAC)
CGAssociateMouseAndMouseCursorPosition(false);
@@ -69,14 +71,18 @@ void SliderLabel::mousePressEvent(QMouseEvent *)
static_cast<QGuiApplication*>(QApplication::instance())->setOverrideCursor(Qt::BlankCursor);
#endif
emit drag_start();
dragging_ = true;
}
}
void SliderLabel::mouseMoveEvent(QMouseEvent *)
{
if (QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) {
// do nothing
}else {
if (dragging_) {
int32_t x_mvmt, y_mvmt;
// Keep cursor in the same position
@@ -92,23 +98,26 @@ void SliderLabel::mouseMoveEvent(QMouseEvent *)
#endif
emit dragged(x_mvmt + y_mvmt);
}
}
void SliderLabel::mouseReleaseEvent(QMouseEvent *)
{
if (QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier)) {
//do nothing
} else {
// Emit a clicked signal
emit drag_stop();
}
if (dragging_) {
#if defined(Q_OS_MAC)
CGAssociateMouseAndMouseCursorPosition(true);
CGDisplayShowCursor(kCGDirectMainDisplay);
CGAssociateMouseAndMouseCursorPosition(true);
CGDisplayShowCursor(kCGDirectMainDisplay);
#else
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
#endif
emit drag_stop();
dragging_ = false;
}
}
void SliderLabel::focusInEvent(QFocusEvent *event)
+2 -2
View File
@@ -51,12 +51,12 @@ signals:
void focused();
void ResetResult();
void RequestReset();
private:
QPoint drag_start_;
bool cancel_mm_event_;
bool dragging_;
};