HAL
settings_item_slider.cpp
Go to the documentation of this file.
4 
5 #include <algorithm>
6 
7 namespace hal
8 {
9  SettingsItemSlider::SettingsItemSlider(const QString& label, const QString& tag, int defVal, const QString& cat, const QString& desc, bool isGlobal)
10  {
11  mMinimum = 0;
12  mMaximum = 100;
13 
14  mLabel = label;
15  mTag = tag;
16  mValue = defVal;
17  mDefaultValue = defVal;
18  mCategory = cat;
19  mDescription = desc;
21 
23  }
24 
25  void SettingsItemSlider::setRange(int min, int max)
26  {
27  mMinimum = min;
28  mMaximum = max;
29  }
30 
32  {
33  return mValue;
34  }
35 
37  {
38  return mDefaultValue;
39  }
40 
42  {
43  int newDefaultValue = dv.toInt();
44 
45  if(mDefaultValue == newDefaultValue)
46  return;
47 
48  bool hasDefaultValue = (mValue == mDefaultValue);
49  mDefaultValue = newDefaultValue;
50 
51  if (hasDefaultValue) setValue(mDefaultValue);
52  }
53 
55  {
56  int newValue = v.toInt();
57 
58  if(mValue == newValue)
59  return;
60 
61  mValue = newValue;
62 
64  Q_EMIT intChanged(v.toInt());
65  }
66 
68  {
69  //SettingsWidgetSlider* editWidget = new SettingsWidgetSlider(this, parent);
70  //connect(editWidget, &SettingsWidgetSlider::valueChanged, this, &SettingsItemSlider::handleValueChanged);
71  return new SettingsWidgetSlider(this, parent);
72  }
73 }
virtual QString tag() const
virtual QString label() const
virtual bool isGlobal() const
void setRange(int min, int max)
virtual SettingsWidget * editWidget(QWidget *parent=nullptr) override
SettingsItemSlider(const QString &label, const QString &tag, int defVal, const QString &cat=QString(), const QString &desc=QString(), bool isGlobal=true)
virtual void setValue(const QVariant &v) override
virtual void setDefaultValue(const QVariant &dv) override
virtual QVariant value() const override
void intChanged(int value)
virtual QVariant defaultValue() const override
void registerSetting(SettingsItem *item)
static SettingsManager * instance()
The base class for all specific SettingsWidgets.
A SettingsWidget representing a slider.
Q_EMITQ_EMIT
QObject * parent() const const
int toInt(bool *ok) const const