HAL
settings_item_text.cpp
Go to the documentation of this file.
2 
5 
6 namespace hal
7 {
8  SettingsItemText::SettingsItemText(const QString& label, const QString& tag, const QString& defVal, const QString& cat, const QString& descr, bool isGlobal)
9  {
10  mLabel = label;
11  mTag = tag;
12  mValue = defVal;
13  mDefaultValue = defVal;
14  mCategory = cat;
15  mDescription = descr;
17 
19  }
20 
22  {
23  return mValue;
24  }
25 
27  {
28  return mDefaultValue;
29  }
30 
32  {
33  QString newDefaultValue = dv.toString();
34 
35  if(mDefaultValue == newDefaultValue)
36  return;
37 
38  bool hasDefaultValue = (mValue == mDefaultValue);
39  mDefaultValue = newDefaultValue;
40 
41  if (hasDefaultValue) setValue(mDefaultValue);
42  }
43 
45  {
46  QString newValue = v.toString();
47 
48  if(mValue == newValue)
49  return;
50 
51  mValue = newValue;
52 
54  Q_EMIT stringChanged(mValue);
55  }
56 
58  {
59  return new SettingsWidgetText(this, parent);
60  }
61 }
virtual QString tag() const
virtual QString label() const
virtual bool isGlobal() const
virtual void setValue(const QVariant &v) override
virtual QVariant defaultValue() const override
virtual QVariant value() const override
virtual SettingsWidget * editWidget(QWidget *parent=nullptr) override
SettingsItemText(const QString &label, const QString &tag, const QString &defVal, const QString &cat=QString(), const QString &desc=QString(), bool isGlobal=true)
void stringChanged(const QString &text)
virtual void setDefaultValue(const QVariant &dv) override
void registerSetting(SettingsItem *item)
static SettingsManager * instance()
The base class for all specific SettingsWidgets.
A SettingsWidget representing a textfield.
Q_EMITQ_EMIT
QObject * parent() const const
QString toString() const const