HAL
settings_item_keybind.cpp
Go to the documentation of this file.
4 
5 
6 namespace hal
7 {
8 
9  SettingsItemKeybind::SettingsItemKeybind(const QString& label, const QString& tag, const QKeySequence& defVal, const QString& cat, const QString& descr, bool isGlobal)
10  {
11  mLabel = label;
12  mTag = tag;
13  mValue = defVal;
14  mDefaultValue = defVal;
15  mCategory = cat;
16  mDescription = descr;
18 
20  }
21 
23  {
24  return mValue;
25  }
26 
28  {
29  return mDefaultValue;
30  }
31 
33  {
34  QKeySequence newDefaultValue = dv.toString();
35 
36  if(mDefaultValue == newDefaultValue)
37  return;
38 
39  bool hasDefaultValue = (mValue == mDefaultValue);
40  mDefaultValue = newDefaultValue;
41 
42  if (hasDefaultValue) setValue(mDefaultValue);
43  }
44 
46  {
47  QKeySequence newValue = v.toString();
48 
49  if(mValue == newValue)
50  return;
51 
52  mValue = newValue;
53 
56  }
57 
59  {
60  return new SettingsWidgetKeybind(this, parent);
61  }
62 }
virtual QString tag() const
virtual QString label() const
virtual bool isGlobal() const
virtual SettingsWidget * editWidget(QWidget *parent=nullptr) override
virtual void setDefaultValue(const QVariant &dv) override
void keySequenceChanged(QKeySequence value)
virtual void setValue(const QVariant &v) override
virtual QVariant defaultValue() const override
virtual QVariant value() const override
SettingsItemKeybind(const QString &label, const QString &tag, const QKeySequence &defVal, const QString &cat=QString(), const QString &desc=QString(), bool isGlobal=true)
void registerSetting(SettingsItem *item)
static SettingsManager * instance()
The base class for all specific SettingsWidgets.
A setting to configure keybinds.
Q_EMITQ_EMIT
QObject * parent() const const
QString toString() const const