style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -33,14 +33,14 @@ DecimalSliderBase::DecimalSliderBase(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void DecimalSliderBase::SetAutoTrimDecimalPlaces(bool e)
|
||||
void DecimalSliderBase::set_auto_trim_decimal_places(bool e)
|
||||
{
|
||||
autotrim_decimal_places_ = e;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
QString DecimalSliderBase::FloatToString(double val, int decimal_places,
|
||||
QString DecimalSliderBase::float_to_string(double val, int decimal_places,
|
||||
bool autotrim_decimal_places)
|
||||
{
|
||||
QString s = QString::number(val, 'f', decimal_places);
|
||||
@@ -54,11 +54,11 @@ QString DecimalSliderBase::FloatToString(double val, int decimal_places,
|
||||
return s;
|
||||
}
|
||||
|
||||
void DecimalSliderBase::SetDecimalPlaces(int i)
|
||||
void DecimalSliderBase::set_decimal_places(int i)
|
||||
{
|
||||
decimal_places_ = i;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DECIMALSLIDERBASE_H
|
||||
#define DECIMALSLIDERBASE_H
|
||||
#ifndef OAK_DECIMALSLIDERBASE_H
|
||||
#define OAK_DECIMALSLIDERBASE_H
|
||||
|
||||
#include "numericsliderbase.h"
|
||||
|
||||
@@ -31,19 +31,19 @@ class DecimalSliderBase : public NumericSliderBase {
|
||||
public:
|
||||
DecimalSliderBase(QWidget *parent = nullptr);
|
||||
|
||||
int GetDecimalPlaces() const
|
||||
int get_decimal_places() const
|
||||
{
|
||||
return decimal_places_;
|
||||
}
|
||||
void SetDecimalPlaces(int i);
|
||||
void set_decimal_places(int i);
|
||||
|
||||
bool GetAutoTrimDecimalPlaces() const
|
||||
bool get_auto_trim_decimal_places() const
|
||||
{
|
||||
return autotrim_decimal_places_;
|
||||
};
|
||||
void SetAutoTrimDecimalPlaces(bool e);
|
||||
void set_auto_trim_decimal_places(bool e);
|
||||
|
||||
static QString FloatToString(double val, int decimal_places,
|
||||
static QString float_to_string(double val, int decimal_places,
|
||||
bool autotrim_decimal_places);
|
||||
|
||||
private:
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // DECIMALSLIDERBASE_H
|
||||
#endif // OAK_DECIMALSLIDERBASE_H
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
bool NumericSliderBase::effects_slider_is_being_dragged_ = false;
|
||||
bool NumericSliderBase::effects_slider_is_being_dragged = false;
|
||||
|
||||
NumericSliderBase::NumericSliderBase(QWidget *parent)
|
||||
: SliderBase(parent)
|
||||
@@ -44,60 +44,60 @@ NumericSliderBase::NumericSliderBase(QWidget *parent)
|
||||
// Numeric sliders are draggable, so we have a cursor that indicates that
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
|
||||
connect(label(), &SliderLabel::LabelPressed, this,
|
||||
&NumericSliderBase::LabelPressed);
|
||||
connect(label(), &SliderLabel::label_pressed, this,
|
||||
&NumericSliderBase::label_pressed);
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetDragMultiplier(const double &d)
|
||||
void NumericSliderBase::set_drag_multiplier(const double &d)
|
||||
{
|
||||
drag_multiplier_ = d;
|
||||
}
|
||||
|
||||
void NumericSliderBase::LabelPressed()
|
||||
void NumericSliderBase::label_pressed()
|
||||
{
|
||||
drag_ladder_ = new SliderLadder(drag_multiplier_, ladder_element_count_,
|
||||
GetFormattedValueToString(99999999));
|
||||
connect(drag_ladder_, &SliderLadder::DraggedByValue, this,
|
||||
&NumericSliderBase::LadderDragged);
|
||||
connect(drag_ladder_, &SliderLadder::Released, this,
|
||||
&NumericSliderBase::LadderReleased);
|
||||
get_formatted_value_to_string(99999999));
|
||||
connect(drag_ladder_, &SliderLadder::dragged_by_value, this,
|
||||
&NumericSliderBase::ladder_dragged);
|
||||
connect(drag_ladder_, &SliderLadder::released, this,
|
||||
&NumericSliderBase::ladder_released);
|
||||
|
||||
drag_ladder_->SetValue(GetFormattedValueToString());
|
||||
drag_ladder_->set_value(get_formatted_value_to_string());
|
||||
drag_ladder_->resize(drag_ladder_->sizeHint());
|
||||
RepositionLadder();
|
||||
reposition_ladder();
|
||||
drag_ladder_->show();
|
||||
|
||||
drag_start_value_ = GetValueInternal();
|
||||
drag_start_value_ = get_value_internal();
|
||||
}
|
||||
|
||||
void NumericSliderBase::LadderDragged(int value, double multiplier)
|
||||
void NumericSliderBase::ladder_dragged(int value, double multiplier)
|
||||
{
|
||||
dragged_ = true;
|
||||
|
||||
dragged_diff_ += value * multiplier;
|
||||
|
||||
// Store current value to try and prevent any unnecessary signalling if the value doesn't change
|
||||
QVariant pre_set_value = GetValueInternal();
|
||||
QVariant pre_set_value = get_value_internal();
|
||||
|
||||
setting_drag_value_ = true;
|
||||
SetValueInternal(
|
||||
AdjustDragDistanceInternal(drag_start_value_, dragged_diff_));
|
||||
set_value_internal(
|
||||
adjust_drag_distance_internal(drag_start_value_, dragged_diff_));
|
||||
setting_drag_value_ = false;
|
||||
|
||||
if (GetValueInternal() != pre_set_value) {
|
||||
if (get_value_internal() != pre_set_value) {
|
||||
// We retrieve the value instead of storing it ourselves because SetValueInternal may do extra
|
||||
// processing (such as clamping).
|
||||
drag_ladder_->SetValue(GetFormattedValueToString());
|
||||
drag_ladder_->set_value(get_formatted_value_to_string());
|
||||
|
||||
if (!UsingLadders()) {
|
||||
RepositionLadder();
|
||||
if (!using_ladders()) {
|
||||
reposition_ladder();
|
||||
}
|
||||
|
||||
ValueSignalEvent(GetValueInternal());
|
||||
value_signal_event(get_value_internal());
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::LadderReleased()
|
||||
void NumericSliderBase::ladder_released()
|
||||
{
|
||||
drag_ladder_->deleteLater();
|
||||
drag_ladder_ = nullptr;
|
||||
@@ -105,24 +105,24 @@ void NumericSliderBase::LadderReleased()
|
||||
|
||||
if (dragged_) {
|
||||
// This was a drag, send another value changed event
|
||||
ValueSignalEvent(GetValueInternal());
|
||||
value_signal_event(get_value_internal());
|
||||
|
||||
dragged_ = false;
|
||||
} else {
|
||||
ShowEditor();
|
||||
show_editor();
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::RepositionLadder()
|
||||
void NumericSliderBase::reposition_ladder()
|
||||
{
|
||||
if (drag_ladder_) {
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
drag_ladder_->move(
|
||||
QCursor::pos() -
|
||||
QPoint(drag_ladder_->width() / 2, drag_ladder_->height() / 2));
|
||||
} else {
|
||||
QPoint label_global_pos = label()->mapToGlobal(label()->pos());
|
||||
int text_width = QtUtils::QFontMetricsWidth(label()->fontMetrics(),
|
||||
int text_width = QtUtils::q_font_metrics_width(label()->fontMetrics(),
|
||||
label()->text());
|
||||
|
||||
if (label()->alignment() & Qt::AlignRight) {
|
||||
@@ -141,83 +141,83 @@ void NumericSliderBase::RepositionLadder()
|
||||
drag_ladder_->move(ladder_x, ladder_y);
|
||||
}
|
||||
|
||||
drag_ladder_->StartListeningToMouseInput();
|
||||
drag_ladder_->start_listening_to_mouse_input();
|
||||
}
|
||||
}
|
||||
|
||||
bool NumericSliderBase::IsDragging() const
|
||||
bool NumericSliderBase::is_dragging() const
|
||||
{
|
||||
return drag_ladder_;
|
||||
}
|
||||
|
||||
bool NumericSliderBase::UsingLadders() const
|
||||
bool NumericSliderBase::using_ladders() const
|
||||
{
|
||||
return ladder_element_count_ > 0 &&
|
||||
OLIVE_CONFIG("UseSliderLadders").toBool();
|
||||
OAK_CONFIG("UseSliderLadders").toBool();
|
||||
}
|
||||
|
||||
QVariant NumericSliderBase::AdjustValue(const QVariant &value) const
|
||||
QVariant NumericSliderBase::adjust_value(const QVariant &value) const
|
||||
{
|
||||
// Clamps between min/max
|
||||
if (has_min_ && ValueLessThan(value, min_value_)) {
|
||||
if (has_min_ && value_less_than(value, min_value_)) {
|
||||
return min_value_;
|
||||
} else if (has_max_ && ValueGreaterThan(value, max_value_)) {
|
||||
} else if (has_max_ && value_greater_than(value, max_value_)) {
|
||||
return max_value_;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetOffset(const QVariant &v)
|
||||
void NumericSliderBase::set_offset(const QVariant &v)
|
||||
{
|
||||
offset_ = v;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
QVariant NumericSliderBase::AdjustDragDistanceInternal(const QVariant &start,
|
||||
QVariant NumericSliderBase::adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const
|
||||
{
|
||||
return start.toDouble() + drag;
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetMinimumInternal(const QVariant &v)
|
||||
void NumericSliderBase::set_minimum_internal(const QVariant &v)
|
||||
{
|
||||
min_value_ = v;
|
||||
has_min_ = true;
|
||||
|
||||
// Limit value by this new minimum value
|
||||
if (ValueLessThan(GetValueInternal(), min_value_)) {
|
||||
SetValueInternal(min_value_);
|
||||
if (value_less_than(get_value_internal(), min_value_)) {
|
||||
set_value_internal(min_value_);
|
||||
}
|
||||
}
|
||||
|
||||
void NumericSliderBase::SetMaximumInternal(const QVariant &v)
|
||||
void NumericSliderBase::set_maximum_internal(const QVariant &v)
|
||||
{
|
||||
max_value_ = v;
|
||||
has_max_ = true;
|
||||
|
||||
// Limit value by this new maximum value
|
||||
if (ValueGreaterThan(GetValueInternal(), max_value_)) {
|
||||
SetValueInternal(max_value_);
|
||||
if (value_greater_than(get_value_internal(), max_value_)) {
|
||||
set_value_internal(max_value_);
|
||||
}
|
||||
}
|
||||
|
||||
bool NumericSliderBase::ValueGreaterThan(const QVariant &lhs,
|
||||
bool NumericSliderBase::value_greater_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const
|
||||
{
|
||||
return lhs.toDouble() > rhs.toDouble();
|
||||
}
|
||||
|
||||
bool NumericSliderBase::ValueLessThan(const QVariant &lhs,
|
||||
bool NumericSliderBase::value_less_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const
|
||||
{
|
||||
return lhs.toDouble() < rhs.toDouble();
|
||||
}
|
||||
|
||||
bool NumericSliderBase::CanSetValue() const
|
||||
bool NumericSliderBase::can_set_value() const
|
||||
{
|
||||
return !IsDragging() || setting_drag_value_;
|
||||
return !is_dragging() || setting_drag_value_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NUMERICSLIDERBASE_H
|
||||
#define NUMERICSLIDERBASE_H
|
||||
#ifndef OAK_NUMERICSLIDERBASE_H
|
||||
#define OAK_NUMERICSLIDERBASE_H
|
||||
|
||||
#include "sliderbase.h"
|
||||
|
||||
@@ -32,41 +32,41 @@ class NumericSliderBase : public SliderBase {
|
||||
public:
|
||||
NumericSliderBase(QWidget *parent = nullptr);
|
||||
|
||||
void SetLadderElementCount(int b)
|
||||
void set_ladder_element_count(int b)
|
||||
{
|
||||
ladder_element_count_ = b;
|
||||
}
|
||||
|
||||
void SetDragMultiplier(const double &d);
|
||||
void set_drag_multiplier(const double &d);
|
||||
|
||||
void SetOffset(const QVariant &v);
|
||||
void set_offset(const QVariant &v);
|
||||
|
||||
bool IsDragging() const;
|
||||
bool is_dragging() const;
|
||||
|
||||
protected:
|
||||
const QVariant &GetOffset() const
|
||||
const QVariant &get_offset() const
|
||||
{
|
||||
return offset_;
|
||||
}
|
||||
|
||||
virtual QVariant AdjustDragDistanceInternal(const QVariant &start,
|
||||
virtual QVariant adjust_drag_distance_internal(const QVariant &start,
|
||||
const double &drag) const;
|
||||
|
||||
void SetMinimumInternal(const QVariant &v);
|
||||
void set_minimum_internal(const QVariant &v);
|
||||
|
||||
void SetMaximumInternal(const QVariant &v);
|
||||
void set_maximum_internal(const QVariant &v);
|
||||
|
||||
virtual bool ValueGreaterThan(const QVariant &lhs,
|
||||
virtual bool value_greater_than(const QVariant &lhs,
|
||||
const QVariant &rhs) const;
|
||||
|
||||
virtual bool ValueLessThan(const QVariant &lhs, const QVariant &rhs) const;
|
||||
virtual bool value_less_than(const QVariant &lhs, const QVariant &rhs) const;
|
||||
|
||||
virtual bool CanSetValue() const override;
|
||||
virtual bool can_set_value() const override;
|
||||
|
||||
private:
|
||||
bool UsingLadders() const;
|
||||
bool using_ladders() const;
|
||||
|
||||
virtual QVariant AdjustValue(const QVariant &value) const override;
|
||||
virtual QVariant adjust_value(const QVariant &value) const override;
|
||||
|
||||
SliderLadder *drag_ladder_;
|
||||
|
||||
@@ -93,18 +93,18 @@ private:
|
||||
/**
|
||||
* @brief An effects slider somewhere is being dragged
|
||||
*/
|
||||
static bool effects_slider_is_being_dragged_;
|
||||
static bool effects_slider_is_being_dragged;
|
||||
|
||||
private slots:
|
||||
void LabelPressed();
|
||||
void label_pressed();
|
||||
|
||||
void RepositionLadder();
|
||||
void reposition_ladder();
|
||||
|
||||
void LadderDragged(int value, double multiplier);
|
||||
void ladder_dragged(int value, double multiplier);
|
||||
|
||||
void LadderReleased();
|
||||
void ladder_released();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NUMERICSLIDERBASE_H
|
||||
#endif // OAK_NUMERICSLIDERBASE_H
|
||||
|
||||
@@ -50,51 +50,51 @@ SliderBase::SliderBase(QWidget *parent)
|
||||
editor_ = new FocusableLineEdit(this);
|
||||
addWidget(editor_);
|
||||
|
||||
connect(label_, &SliderLabel::focused, this, &SliderBase::ShowEditor);
|
||||
connect(label_, &SliderLabel::RequestReset, this, &SliderBase::ResetValue);
|
||||
connect(editor_, &FocusableLineEdit::Confirmed, this,
|
||||
&SliderBase::LineEditConfirmed);
|
||||
connect(editor_, &FocusableLineEdit::Cancelled, this,
|
||||
&SliderBase::LineEditCancelled);
|
||||
connect(label_, &SliderLabel::focused, this, &SliderBase::show_editor);
|
||||
connect(label_, &SliderLabel::request_reset, this, &SliderBase::reset_value);
|
||||
connect(editor_, &FocusableLineEdit::confirmed, this,
|
||||
&SliderBase::line_edit_confirmed);
|
||||
connect(editor_, &FocusableLineEdit::cancelled, this,
|
||||
&SliderBase::line_edit_cancelled);
|
||||
}
|
||||
|
||||
void SliderBase::SetAlignment(Qt::Alignment alignment)
|
||||
void SliderBase::set_alignment(Qt::Alignment alignment)
|
||||
{
|
||||
label_->setAlignment(alignment);
|
||||
editor_->setAlignment(alignment);
|
||||
}
|
||||
|
||||
bool SliderBase::IsTristate() const
|
||||
bool SliderBase::is_tristate() const
|
||||
{
|
||||
return tristate_;
|
||||
}
|
||||
|
||||
void SliderBase::SetTristate()
|
||||
void SliderBase::set_tristate()
|
||||
{
|
||||
tristate_ = true;
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
const QVariant &SliderBase::GetValueInternal() const
|
||||
const QVariant &SliderBase::get_value_internal() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
void SliderBase::SetValueInternal(const QVariant &v)
|
||||
void SliderBase::set_value_internal(const QVariant &v)
|
||||
{
|
||||
if (!CanSetValue()) {
|
||||
if (!can_set_value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
value_ = AdjustValue(v);
|
||||
value_ = adjust_value(v);
|
||||
|
||||
// Disable tristate
|
||||
tristate_ = false;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderBase::SetDefaultValue(const QVariant &v)
|
||||
void SliderBase::set_default_value(const QVariant &v)
|
||||
{
|
||||
default_value_ = v;
|
||||
}
|
||||
@@ -102,12 +102,12 @@ void SliderBase::SetDefaultValue(const QVariant &v)
|
||||
void SliderBase::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
super::changeEvent(e);
|
||||
}
|
||||
|
||||
bool SliderBase::GetLabelSubstitution(const QVariant &v, QString *out) const
|
||||
bool SliderBase::get_label_substitution(const QVariant &v, QString *out) const
|
||||
{
|
||||
for (auto it = label_substitutions_.constBegin();
|
||||
it != label_substitutions_.constEnd(); it++) {
|
||||
@@ -120,41 +120,41 @@ bool SliderBase::GetLabelSubstitution(const QVariant &v, QString *out) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void SliderBase::UpdateLabel()
|
||||
void SliderBase::update_label()
|
||||
{
|
||||
QString s;
|
||||
|
||||
if (tristate_) {
|
||||
s = tr("---");
|
||||
} else if (GetLabelSubstitution(GetValueInternal(), &s)) {
|
||||
} else if (get_label_substitution(get_value_internal(), &s)) {
|
||||
// String will already be set, just pass through
|
||||
} else {
|
||||
s = GetFormattedValueToString();
|
||||
s = get_formatted_value_to_string();
|
||||
}
|
||||
|
||||
label_->setText(s);
|
||||
}
|
||||
|
||||
QVariant SliderBase::AdjustValue(const QVariant &value) const
|
||||
QVariant SliderBase::adjust_value(const QVariant &value) const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool SliderBase::CanSetValue() const
|
||||
bool SliderBase::can_set_value() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SliderBase::ValueSignalEvent(const QVariant &value)
|
||||
void SliderBase::value_signal_event(const QVariant &value)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
}
|
||||
|
||||
void SliderBase::ShowEditor()
|
||||
void SliderBase::show_editor()
|
||||
{
|
||||
// This was a simple click
|
||||
// Load label's text into editor
|
||||
editor_->setText(ValueToString(value_));
|
||||
editor_->setText(value_to_string(value_));
|
||||
|
||||
// Show editor
|
||||
setCurrentWidget(editor_);
|
||||
@@ -164,21 +164,21 @@ void SliderBase::ShowEditor()
|
||||
editor_->selectAll();
|
||||
}
|
||||
|
||||
void SliderBase::LineEditConfirmed()
|
||||
void SliderBase::line_edit_confirmed()
|
||||
{
|
||||
bool is_valid = true;
|
||||
QVariant test_val = StringToValue(editor_->text(), &is_valid);
|
||||
QVariant test_val = string_to_value(editor_->text(), &is_valid);
|
||||
|
||||
// Ensure editor doesn't signal that the focus is lost
|
||||
editor_->blockSignals(true);
|
||||
label_->blockSignals(true);
|
||||
|
||||
if (is_valid) {
|
||||
SetValueInternal(test_val);
|
||||
set_value_internal(test_val);
|
||||
|
||||
setCurrentWidget(label_);
|
||||
|
||||
ValueSignalEvent(value_);
|
||||
value_signal_event(value_);
|
||||
} else {
|
||||
QMessageBox::critical(
|
||||
this, tr("Invalid Value"),
|
||||
@@ -193,7 +193,7 @@ void SliderBase::LineEditConfirmed()
|
||||
label_->blockSignals(false);
|
||||
}
|
||||
|
||||
void SliderBase::LineEditCancelled()
|
||||
void SliderBase::line_edit_cancelled()
|
||||
{
|
||||
// Ensure editor doesn't signal that the focus is lost
|
||||
editor_->blockSignals(true);
|
||||
@@ -206,33 +206,33 @@ void SliderBase::LineEditCancelled()
|
||||
label_->blockSignals(false);
|
||||
}
|
||||
|
||||
void SliderBase::ResetValue()
|
||||
void SliderBase::reset_value()
|
||||
{
|
||||
if (default_value_.isValid()) {
|
||||
SetValueInternal(default_value_);
|
||||
ValueSignalEvent(value_);
|
||||
set_value_internal(default_value_);
|
||||
value_signal_event(value_);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderBase::SetFormat(const QString &s, const bool plural)
|
||||
void SliderBase::set_format(const QString &s, const bool plural)
|
||||
{
|
||||
custom_format_ = s;
|
||||
format_plural_ = plural;
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderBase::ClearFormat()
|
||||
void SliderBase::clear_format()
|
||||
{
|
||||
custom_format_.clear();
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
bool SliderBase::IsFormatPlural() const
|
||||
bool SliderBase::is_format_plural() const
|
||||
{
|
||||
return format_plural_;
|
||||
}
|
||||
|
||||
QString SliderBase::GetFormat() const
|
||||
QString SliderBase::get_format() const
|
||||
{
|
||||
if (custom_format_.isEmpty()) {
|
||||
return QStringLiteral("%1");
|
||||
@@ -241,17 +241,17 @@ QString SliderBase::GetFormat() const
|
||||
}
|
||||
}
|
||||
|
||||
QString SliderBase::GetFormattedValueToString() const
|
||||
QString SliderBase::get_formatted_value_to_string() const
|
||||
{
|
||||
return GetFormattedValueToString(GetValueInternal());
|
||||
return get_formatted_value_to_string(get_value_internal());
|
||||
}
|
||||
|
||||
QString SliderBase::GetFormattedValueToString(const QVariant &v) const
|
||||
QString SliderBase::get_formatted_value_to_string(const QVariant &v) const
|
||||
{
|
||||
if (format_plural_) {
|
||||
return tr(GetFormat().toUtf8().constData(), nullptr, v.toInt());
|
||||
return tr(get_format().toUtf8().constData(), nullptr, v.toInt());
|
||||
} else {
|
||||
return GetFormat().arg(ValueToString(v));
|
||||
return get_format().arg(value_to_string(v));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERBASE_H
|
||||
#define SLIDERBASE_H
|
||||
#ifndef OAK_SLIDERBASE_H
|
||||
#define OAK_SLIDERBASE_H
|
||||
|
||||
#include <QStackedWidget>
|
||||
|
||||
@@ -36,65 +36,65 @@ class SliderBase : public QStackedWidget {
|
||||
public:
|
||||
SliderBase(QWidget *parent = nullptr);
|
||||
|
||||
void SetAlignment(Qt::Alignment alignment);
|
||||
void set_alignment(Qt::Alignment alignment);
|
||||
|
||||
bool IsTristate() const;
|
||||
void SetTristate();
|
||||
bool is_tristate() const;
|
||||
void set_tristate();
|
||||
|
||||
void SetFormat(const QString &s, const bool plural = false);
|
||||
void ClearFormat();
|
||||
void set_format(const QString &s, const bool plural = false);
|
||||
void clear_format();
|
||||
|
||||
bool IsFormatPlural() const;
|
||||
bool is_format_plural() const;
|
||||
|
||||
void SetDefaultValue(const QVariant &v);
|
||||
void set_default_value(const QVariant &v);
|
||||
|
||||
QString GetFormattedValueToString(const QVariant &v) const;
|
||||
QString get_formatted_value_to_string(const QVariant &v) const;
|
||||
|
||||
void InsertLabelSubstitution(const QVariant &value, const QString &label)
|
||||
void insert_label_substitution(const QVariant &value, const QString &label)
|
||||
{
|
||||
label_substitutions_.append({ value, label });
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SetColor(const QColor &c)
|
||||
void set_color(const QColor &c)
|
||||
{
|
||||
label_->SetColor(c);
|
||||
label_->set_color(c);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void ShowEditor();
|
||||
void show_editor();
|
||||
|
||||
protected slots:
|
||||
void UpdateLabel();
|
||||
void update_label();
|
||||
|
||||
protected:
|
||||
const QVariant &GetValueInternal() const;
|
||||
const QVariant &get_value_internal() const;
|
||||
|
||||
void SetValueInternal(const QVariant &v);
|
||||
void set_value_internal(const QVariant &v);
|
||||
|
||||
QString GetFormat() const;
|
||||
QString get_format() const;
|
||||
|
||||
QString GetFormattedValueToString() const;
|
||||
QString get_formatted_value_to_string() const;
|
||||
|
||||
SliderLabel *label()
|
||||
{
|
||||
return label_;
|
||||
}
|
||||
|
||||
virtual QString ValueToString(const QVariant &v) const = 0;
|
||||
virtual QString value_to_string(const QVariant &v) const = 0;
|
||||
|
||||
virtual QVariant StringToValue(const QString &s, bool *ok) const = 0;
|
||||
virtual QVariant string_to_value(const QString &s, bool *ok) const = 0;
|
||||
|
||||
virtual QVariant AdjustValue(const QVariant &value) const;
|
||||
virtual QVariant adjust_value(const QVariant &value) const;
|
||||
|
||||
virtual bool CanSetValue() const;
|
||||
virtual bool can_set_value() const;
|
||||
|
||||
virtual void ValueSignalEvent(const QVariant &value) = 0;
|
||||
virtual void value_signal_event(const QVariant &value) = 0;
|
||||
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
bool GetLabelSubstitution(const QVariant &v, QString *out) const;
|
||||
bool get_label_substitution(const QVariant &v, QString *out) const;
|
||||
|
||||
SliderLabel *label_;
|
||||
|
||||
@@ -112,13 +112,13 @@ private:
|
||||
QVector<QPair<QVariant, QString>> label_substitutions_;
|
||||
|
||||
private slots:
|
||||
void LineEditConfirmed();
|
||||
void line_edit_confirmed();
|
||||
|
||||
void LineEditCancelled();
|
||||
void line_edit_cancelled();
|
||||
|
||||
void ResetValue();
|
||||
void reset_value();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERBASE_H
|
||||
#endif // OAK_SLIDERBASE_H
|
||||
|
||||
@@ -54,7 +54,7 @@ SliderLabel::SliderLabel(QWidget *parent)
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
void SliderLabel::SetColor(const QColor &c)
|
||||
void SliderLabel::set_color(const QColor &c)
|
||||
{
|
||||
// Prevent infinite loop in changeEvent when we set the stylesheet
|
||||
override_color_enabled_ = false;
|
||||
@@ -78,9 +78,9 @@ void SliderLabel::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
if (e->modifiers() & Qt::AltModifier) {
|
||||
emit RequestReset();
|
||||
emit request_reset();
|
||||
} else {
|
||||
emit LabelPressed();
|
||||
emit label_pressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void SliderLabel::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
if (!(e->modifiers() & Qt::AltModifier)) {
|
||||
emit LabelReleased();
|
||||
emit label_released();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ void SliderLabel::changeEvent(QEvent *event)
|
||||
QWidget::changeEvent(event);
|
||||
|
||||
if (override_color_enabled_ && event->type() == QEvent::StyleChange) {
|
||||
SetColor(override_color_);
|
||||
set_color(override_color_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLABEL_H
|
||||
#define SLIDERLABEL_H
|
||||
#ifndef OAK_SLIDERLABEL_H
|
||||
#define OAK_SLIDERLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
@@ -34,7 +34,7 @@ class SliderLabel : public QLabel {
|
||||
public:
|
||||
SliderLabel(QWidget *parent);
|
||||
|
||||
void SetColor(const QColor &c);
|
||||
void set_color(const QColor &c);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e) override;
|
||||
@@ -46,15 +46,15 @@ protected:
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
signals:
|
||||
void LabelPressed();
|
||||
void label_pressed();
|
||||
|
||||
void LabelReleased();
|
||||
void label_released();
|
||||
|
||||
void focused();
|
||||
|
||||
void RequestReset();
|
||||
void request_reset();
|
||||
|
||||
void ChangeSliderType();
|
||||
void change_slider_type();
|
||||
|
||||
private:
|
||||
bool override_color_enabled_;
|
||||
@@ -63,4 +63,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERLABEL_H
|
||||
#endif // OAK_SLIDERLABEL_H
|
||||
|
||||
@@ -50,7 +50,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
setFrameShape(QFrame::Box);
|
||||
setLineWidth(1);
|
||||
|
||||
if (!OLIVE_CONFIG("UseSliderLadders").toBool()) {
|
||||
if (!OAK_CONFIG("UseSliderLadders").toBool()) {
|
||||
nb_outer_values = 0;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
SliderLadderElement *start_element =
|
||||
new SliderLadderElement(drag_multiplier, width_hint);
|
||||
active_element_ = elements_.size();
|
||||
start_element->SetHighlighted(true);
|
||||
start_element->set_highlighted(true);
|
||||
elements_.append(start_element);
|
||||
|
||||
for (int i = 0; i < nb_outer_values; i++) {
|
||||
@@ -76,11 +76,11 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
}
|
||||
|
||||
if (elements_.size() == 1) {
|
||||
elements_.first()->SetMultiplierVisible(false);
|
||||
elements_.first()->set_multiplier_visible(false);
|
||||
}
|
||||
|
||||
drag_timer_.setInterval(10);
|
||||
connect(&drag_timer_, &QTimer::timeout, this, &SliderLadder::TimerUpdate);
|
||||
connect(&drag_timer_, &QTimer::timeout, this, &SliderLadder::timer_update);
|
||||
|
||||
screen_ = nullptr;
|
||||
foreach (QScreen *screen, qApp->screens()) {
|
||||
@@ -90,7 +90,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
}
|
||||
}
|
||||
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
drag_start_x_ = -1;
|
||||
wrap_count_ = 0;
|
||||
} else {
|
||||
@@ -110,7 +110,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values,
|
||||
|
||||
SliderLadder::~SliderLadder()
|
||||
{
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
if (wrap_count_ != 0) {
|
||||
// If wrapped, restore cursor to ladder
|
||||
QCursor::setPos(pos() + rect().center());
|
||||
@@ -126,14 +126,14 @@ SliderLadder::~SliderLadder()
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLadder::SetValue(const QString &s)
|
||||
void SliderLadder::set_value(const QString &s)
|
||||
{
|
||||
foreach (SliderLadderElement *e, elements_) {
|
||||
e->SetValue(s);
|
||||
e->set_value(s);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLadder::StartListeningToMouseInput()
|
||||
void SliderLadder::start_listening_to_mouse_input()
|
||||
{
|
||||
QMetaObject::invokeMethod(&drag_timer_, "start", Qt::QueuedConnection);
|
||||
}
|
||||
@@ -151,18 +151,18 @@ void SliderLadder::closeEvent(QCloseEvent *event)
|
||||
|
||||
drag_timer_.stop();
|
||||
|
||||
emit Released();
|
||||
emit released();
|
||||
|
||||
QFrame::closeEvent(event);
|
||||
}
|
||||
|
||||
void SliderLadder::TimerUpdate()
|
||||
void SliderLadder::timer_update()
|
||||
{
|
||||
int ladder_left = this->x();
|
||||
int ladder_right = this->x() + this->width() - 1;
|
||||
int now_pos = QCursor::pos().x();
|
||||
|
||||
if (UsingLadders()) {
|
||||
if (using_ladders()) {
|
||||
bool is_under_mouse = (now_pos >= ladder_left &&
|
||||
now_pos <= ladder_right && wrap_count_ == 0);
|
||||
|
||||
@@ -180,8 +180,8 @@ void SliderLadder::TimerUpdate()
|
||||
}
|
||||
|
||||
int makeup_value = anchor - drag_start_x_;
|
||||
emit DraggedByValue(makeup_value,
|
||||
elements_.at(active_element_)->GetMultiplier());
|
||||
emit dragged_by_value(makeup_value,
|
||||
elements_.at(active_element_)->get_multiplier());
|
||||
|
||||
drag_start_x_ = -1;
|
||||
}
|
||||
@@ -191,9 +191,9 @@ void SliderLadder::TimerUpdate()
|
||||
for (int i = 0; i < elements_.size(); i++) {
|
||||
if (elements_.at(i)->underMouse()) {
|
||||
if (i != active_element_) {
|
||||
elements_.at(active_element_)->SetHighlighted(false);
|
||||
elements_.at(active_element_)->set_highlighted(false);
|
||||
active_element_ = i;
|
||||
elements_.at(active_element_)->SetHighlighted(true);
|
||||
elements_.at(active_element_)->set_highlighted(true);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -210,8 +210,8 @@ void SliderLadder::TimerUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
emit DraggedByValue(now_pos - drag_start_x_,
|
||||
elements_.at(active_element_)->GetMultiplier());
|
||||
emit dragged_by_value(now_pos - drag_start_x_,
|
||||
elements_.at(active_element_)->get_multiplier());
|
||||
|
||||
// Determine if cursor is at desktop edge, if so wrap around to other side
|
||||
if (screen_) {
|
||||
@@ -268,12 +268,12 @@ void SliderLadder::TimerUpdate()
|
||||
multiplier *= 100.0;
|
||||
}
|
||||
|
||||
emit DraggedByValue(x_mvmt + y_mvmt, multiplier);
|
||||
emit dragged_by_value(x_mvmt + y_mvmt, multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SliderLadder::UsingLadders() const
|
||||
bool SliderLadder::using_ladders() const
|
||||
{
|
||||
return elements_.size() > 1;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ SliderLadderElement::SliderLadderElement(const double &multiplier,
|
||||
label_ = new QLabel();
|
||||
label_->setAlignment(Qt::AlignCenter);
|
||||
label_->setFixedWidth(
|
||||
QtUtils::QFontMetricsWidth(label_->fontMetrics(), width_hint));
|
||||
QtUtils::q_font_metrics_width(label_->fontMetrics(), width_hint));
|
||||
layout->addWidget(label_);
|
||||
|
||||
QPalette p = palette();
|
||||
@@ -301,10 +301,10 @@ SliderLadderElement::SliderLadderElement(const double &multiplier,
|
||||
|
||||
setAutoFillBackground(true);
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::SetHighlighted(bool e)
|
||||
void SliderLadderElement::set_highlighted(bool e)
|
||||
{
|
||||
highlighted_ = e;
|
||||
|
||||
@@ -314,24 +314,24 @@ void SliderLadderElement::SetHighlighted(bool e)
|
||||
setBackgroundRole(QPalette::Window);
|
||||
}
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::SetValue(const QString &value)
|
||||
void SliderLadderElement::set_value(const QString &value)
|
||||
{
|
||||
value_ = value;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::SetMultiplierVisible(bool e)
|
||||
void SliderLadderElement::set_multiplier_visible(bool e)
|
||||
{
|
||||
multiplier_visible_ = e;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void SliderLadderElement::UpdateLabel()
|
||||
void SliderLadderElement::update_label()
|
||||
{
|
||||
if (multiplier_visible_) {
|
||||
QString val_text;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLADDER_H
|
||||
#define SLIDERLADDER_H
|
||||
#ifndef OAK_SLIDERLADDER_H
|
||||
#define OAK_SLIDERLADDER_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
@@ -37,19 +37,19 @@ public:
|
||||
SliderLadderElement(const double &multiplier, QString width_hint,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
void SetHighlighted(bool e);
|
||||
void set_highlighted(bool e);
|
||||
|
||||
void SetValue(const QString &value);
|
||||
void set_value(const QString &value);
|
||||
|
||||
void SetMultiplierVisible(bool e);
|
||||
void set_multiplier_visible(bool e);
|
||||
|
||||
double GetMultiplier() const
|
||||
double get_multiplier() const
|
||||
{
|
||||
return multiplier_;
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateLabel();
|
||||
void update_label();
|
||||
|
||||
QLabel *label_;
|
||||
|
||||
@@ -69,9 +69,9 @@ public:
|
||||
|
||||
virtual ~SliderLadder() override;
|
||||
|
||||
void SetValue(const QString &s);
|
||||
void set_value(const QString &s);
|
||||
|
||||
void StartListeningToMouseInput();
|
||||
void start_listening_to_mouse_input();
|
||||
|
||||
protected:
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
@@ -79,12 +79,12 @@ protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void DraggedByValue(int value, double multiplier);
|
||||
void dragged_by_value(int value, double multiplier);
|
||||
|
||||
void Released();
|
||||
void released();
|
||||
|
||||
private:
|
||||
bool UsingLadders() const;
|
||||
bool using_ladders() const;
|
||||
|
||||
int drag_start_x_;
|
||||
int drag_start_y_;
|
||||
@@ -99,9 +99,9 @@ private:
|
||||
QScreen *screen_;
|
||||
|
||||
private slots:
|
||||
void TimerUpdate();
|
||||
void timer_update();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERLADDER_H
|
||||
#endif // OAK_SLIDERLADDER_H
|
||||
|
||||
Reference in New Issue
Block a user