diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/guiSQLiteStudio/common/configradiobutton.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/common/configradiobutton.h')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/common/configradiobutton.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/common/configradiobutton.h b/SQLiteStudio3/guiSQLiteStudio/common/configradiobutton.h new file mode 100644 index 0000000..b972c26 --- /dev/null +++ b/SQLiteStudio3/guiSQLiteStudio/common/configradiobutton.h @@ -0,0 +1,46 @@ +#ifndef CONFIGRADIOBUTTON_H +#define CONFIGRADIOBUTTON_H + +#include "guiSQLiteStudio_global.h" +#include <QRadioButton> +#include <QVariant> + +/** + * @brief Config-oriented radio button. + * + * It's just like a usual QRadioButton, except it has a value assigned to it + * and when the radio is toggled on, the signal is emitted to inform about it. + * To inform about the button being toggled off a different signal is emitted. + * It also has a slot to be called when the associated property in the application + * has changed and needs to be reflected in the button - the button checks + * if the value of the property reflects the button's assigned value + * and toggles on or off approprietly. In that case the signals are not emitted. + */ +class GUI_API_EXPORT ConfigRadioButton : public QRadioButton +{ + Q_OBJECT + + Q_PROPERTY(QVariant assignedValue READ getAssignedValue WRITE setAssignedValue) + + public: + explicit ConfigRadioButton(QWidget *parent = 0); + + QVariant getAssignedValue() const; + void setAssignedValue(const QVariant& value); + + private: + QVariant assignedValue; + bool handlingSlot = false; + + signals: + void toggledOn(const QVariant& assignedBalue); + void toggledOff(const QVariant& assignedBalue); + + private slots: + void handleToggled(bool checked); + + public slots: + void alignToValue(const QVariant& value); +}; + +#endif // CONFIGRADIOBUTTON_H |
