HAL
settings_item_checkbox.cpp
Go to the documentation of this file.
4 
5 namespace hal
6 {
7  SettingsItemCheckbox::SettingsItemCheckbox(const QString& label, const QString& tag, bool defVal, const QString& cat, const QString& descr, bool isGlobal)
8  {
9  mLabel = label;
10  mTag = tag;
11  mValue = defVal;
12  mDefaultValue = defVal;
13  mCategory = cat;
14  mDescription = descr;
16 
18  }
19 
21  {
22  return mValue;
23  }
24 
26  {
27  return mDefaultValue;
28  }
29 
31  {
32  bool newDefaultValue = dv.toBool();
33 
34  if(mDefaultValue == newDefaultValue)
35  return;
36 
37  bool hasDefaultValue = (mValue == mDefaultValue);
38  mDefaultValue = newDefaultValue;
39 
40  if (hasDefaultValue) setValue(mDefaultValue);
41  }
42 
44  {
45  bool newValue = v.toBool();
46 
47  if(mValue == newValue)
48  return;
49 
50  mValue = newValue;
51 
53  Q_EMIT boolChanged(mValue);
54  }
55 
57  {
58  return new SettingsWidgetCheckbox(this, parent);
59  }
60 }
virtual SettingsWidget * editWidget(QWidget *parent=nullptr) override
virtual QVariant defaultValue() const override
virtual QVariant value() const override
SettingsItemCheckbox(const QString &label, const QString &tag, bool defVal, const QString &cat=QString(), const QString &descr=QString(), bool isGlobal=true)
virtual void setValue(const QVariant &v) override
virtual void setDefaultValue(const QVariant &dv) override
virtual QString tag() const
virtual QString label() const
virtual bool isGlobal() const
void registerSetting(SettingsItem *item)
static SettingsManager * instance()
A SettingsWidget representing a checkbox.
The base class for all specific SettingsWidgets.
Q_EMITQ_EMIT
QObject * parent() const const
bool toBool() const const