-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooleanobject.h
More file actions
41 lines (34 loc) · 1002 Bytes
/
booleanobject.h
File metadata and controls
41 lines (34 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef BOOLEANOBJECT_H
#define BOOLEANOBJECT_H
#include <QObject>
#include <QSettings>
class BooleanObject : public QObject
{
Q_OBJECT
public:
explicit BooleanObject(bool valueAndDefault, QString const& settingsKey, QObject *parent = nullptr);
/// Returns the bool value.
bool value() const;
/// Returns the associated settings key.
QString const& settingsKey() const;
/// Returns the default value associated with the
/// current instance.
bool defaultValue() const;
/// Implicit conversion operator.
inline operator bool() const {
return this->value();
}
public slots:
/// Sets the current value.
void setValue(bool value);
/// Registers the settings to the changed value setting so
/// it's updated when the value changes.
void attachSettings(QSettings *settings);
signals:
void valueChanged(bool newValue);
private:
bool m_value;
bool m_default;
QString m_settingsKey;
};
#endif // BOOLEANOBJECT_H