diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-04-26 15:51:50 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-27 16:02:50 +0000 |
commit | d6b32468667a4890cef6061f08c353a0d0cba43e (patch) | |
tree | 270287bd5725b4de6a8edc1b2809eb4adbd51e65 /src/quicktemplates2/qquickmenuitem.cpp | |
parent | 9e79b19a305960a3df7bd1c90675ba00cd972153 (diff) |
Move highlighted to subclasses that actually use it
Change-Id: I70468b35b2a3a03c6e2d557a67443291697c8b42
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickmenuitem.cpp')
-rw-r--r-- | src/quicktemplates2/qquickmenuitem.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp index d9740910..7c9ede7d 100644 --- a/src/quicktemplates2/qquickmenuitem.cpp +++ b/src/quicktemplates2/qquickmenuitem.cpp @@ -78,6 +78,21 @@ QT_BEGIN_NAMESPACE \sa {Customizing MenuItem}, {Menu Controls} */ +class QQuickMenuItemPrivate : public QQuickAbstractButtonPrivate +{ + Q_DECLARE_PUBLIC(QQuickMenuItem) + +public: + QQuickMenuItemPrivate(); + + bool highlighted; +}; + +QQuickMenuItemPrivate::QQuickMenuItemPrivate() : + highlighted(false) +{ +} + /*! \qmlsignal void QtQuick.Controls::MenuItem::triggered() @@ -85,7 +100,7 @@ QT_BEGIN_NAMESPACE */ QQuickMenuItem::QQuickMenuItem(QQuickItem *parent) : - QQuickAbstractButton(parent) + QQuickAbstractButton(*(new QQuickMenuItemPrivate), parent) { connect(this, &QQuickAbstractButton::clicked, this, &QQuickMenuItem::triggered); } @@ -106,6 +121,32 @@ QFont QQuickMenuItem::defaultFont() const return QQuickControlPrivate::themeFont(QPlatformTheme::MenuItemFont); } +/*! + \qmlproperty bool QtQuick.Controls::MenuItem::highlighted + + This property holds whether the menu item is highlighted. + + A menu item 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 QQuickMenuItem::isHighlighted() const +{ + Q_D(const QQuickMenuItem); + return d->highlighted; +} + +void QQuickMenuItem::setHighlighted(bool highlighted) +{ + Q_D(QQuickMenuItem); + if (highlighted == d->highlighted) + return; + + d->highlighted = highlighted; + emit highlightedChanged(); +} + #ifndef QT_NO_ACCESSIBILITY QAccessible::Role QQuickMenuItem::accessibleRole() const { |