diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-12-03 13:12:27 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-12-03 17:18:12 +0000 |
commit | 5801239f70614e94f4a977b4122079c4ce2c232c (patch) | |
tree | 9f4e2ee124e2a08c969b80cefb7ed224c063a723 /src/templates | |
parent | 6f9c52781a6ae2c84cb8b6e849a18856aef60f80 (diff) |
Promote Button::highlighted to AbstractButton
Change-Id: I0e17a6c25dfd89fdb547720e9a626c2ec9d7765a
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates')
-rw-r--r-- | src/templates/qquickabstractbutton.cpp | 27 | ||||
-rw-r--r-- | src/templates/qquickabstractbutton_p.h | 5 | ||||
-rw-r--r-- | src/templates/qquickabstractbutton_p_p.h | 1 | ||||
-rw-r--r-- | src/templates/qquickbutton.cpp | 41 | ||||
-rw-r--r-- | src/templates/qquickbutton_p.h | 13 |
5 files changed, 33 insertions, 54 deletions
diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp index 74058daf..d2f1c7ec 100644 --- a/src/templates/qquickabstractbutton.cpp +++ b/src/templates/qquickabstractbutton.cpp @@ -109,7 +109,7 @@ static const int AUTO_REPEAT_INTERVAL = 100; */ QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() : - pressed(false), checked(false), checkable(false), autoExclusive(false), autoRepeat(false), + pressed(false), checked(false), checkable(false), highlighted(false), autoExclusive(false), autoRepeat(false), delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton), label(Q_NULLPTR), indicator(Q_NULLPTR), group(Q_NULLPTR) { } @@ -297,6 +297,31 @@ void QQuickAbstractButton::setCheckable(bool checkable) } /*! + \qmlproperty bool Qt.labs.controls::AbstractButton::highlighted + + This property holds whether the button is highlighted. + + A button can be highlighted in order to draw the user's attention towards + it. It has no effect on keyboard interaction. + + The default value is \c false. +*/ +bool QQuickAbstractButton::isHighlighted() const +{ + Q_D(const QQuickAbstractButton); + return d->highlighted; +} + +void QQuickAbstractButton::setHighlighted(bool highlighted) +{ + Q_D(QQuickAbstractButton); + if (highlighted != d->highlighted) { + d->highlighted = highlighted; + emit highlightedChanged(); + } +} + +/*! \qmlproperty bool Qt.labs.controls::AbstractButton::autoExclusive This property holds whether auto-exclusivity is enabled. diff --git a/src/templates/qquickabstractbutton_p.h b/src/templates/qquickabstractbutton_p.h index 24998520..080b340b 100644 --- a/src/templates/qquickabstractbutton_p.h +++ b/src/templates/qquickabstractbutton_p.h @@ -62,6 +62,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickAbstractButton : public QQuickControl Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) + Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL) Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL) Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) @@ -83,6 +84,9 @@ public: bool isCheckable() const; void setCheckable(bool checkable); + bool isHighlighted() const; + void setHighlighted(bool highlighted); + bool autoExclusive() const; void setAutoExclusive(bool exclusive); @@ -108,6 +112,7 @@ Q_SIGNALS: void pressedChanged(); void checkedChanged(); void checkableChanged(); + void highlightedChanged(); void autoExclusiveChanged(); void autoRepeatChanged(); void indicatorChanged(); diff --git a/src/templates/qquickabstractbutton_p_p.h b/src/templates/qquickabstractbutton_p_p.h index ed0a8d9d..ade0b6bf 100644 --- a/src/templates/qquickabstractbutton_p_p.h +++ b/src/templates/qquickabstractbutton_p_p.h @@ -78,6 +78,7 @@ public: bool pressed; bool checked; bool checkable; + bool highlighted; bool autoExclusive; bool autoRepeat; int delayTimer; diff --git a/src/templates/qquickbutton.cpp b/src/templates/qquickbutton.cpp index 4f5df5fa..b323cb0b 100644 --- a/src/templates/qquickbutton.cpp +++ b/src/templates/qquickbutton.cpp @@ -83,47 +83,8 @@ QT_BEGIN_NAMESPACE \sa {Customizing Button}, {Button Controls} */ -class QQuickButtonPrivate : public QQuickAbstractButtonPrivate +QQuickButton::QQuickButton(QQuickItem *parent) : QQuickAbstractButton(parent) { -public: - QQuickButtonPrivate(); - - bool highlighted; -}; - -QQuickButtonPrivate::QQuickButtonPrivate() : - highlighted(false) -{ -} - -QQuickButton::QQuickButton(QQuickItem *parent) : - QQuickAbstractButton(*(new QQuickButtonPrivate), parent) -{ -} - -/*! - \qmlproperty bool Qt.labs.controls::Button::highlighted - - This property holds whether the button is highlighted. - - A button can be highlighted in order to draw the user's attention towards - it. It has no effect on keyboard interaction. - - The default value is \c false. -*/ -bool QQuickButton::isHighlighted() const -{ - Q_D(const QQuickButton); - return d->highlighted; -} - -void QQuickButton::setHighlighted(bool highlighted) -{ - Q_D(QQuickButton); - if (highlighted != d->highlighted) { - d->highlighted = highlighted; - emit highlightedChanged(); - } } QFont QQuickButton::defaultFont() const diff --git a/src/templates/qquickbutton_p.h b/src/templates/qquickbutton_p.h index 5b9c7df5..3863566e 100644 --- a/src/templates/qquickbutton_p.h +++ b/src/templates/qquickbutton_p.h @@ -52,28 +52,15 @@ QT_BEGIN_NAMESPACE -class QQuickButtonPrivate; - class Q_LABSTEMPLATES_EXPORT QQuickButton : public QQuickAbstractButton { Q_OBJECT - Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL) public: explicit QQuickButton(QQuickItem *parent = Q_NULLPTR); - bool isHighlighted() const; - void setHighlighted(bool highlighted); - -Q_SIGNALS: - void highlightedChanged(); - protected: QFont defaultFont() const Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickButton) - Q_DECLARE_PRIVATE(QQuickButton) }; Q_DECLARE_TYPEINFO(QQuickButton, Q_COMPLEX_TYPE); |