diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-06-15 00:16:57 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-06-21 12:14:31 +0000 |
commit | 1ffede10a0b2d2f0dc64fcce4f54263d9d30e57e (patch) | |
tree | ceb41443e1aab54322ba8afa90d3e85796c3276b /src/quicktemplates2/qquickmenu_p.h | |
parent | 39b4ac1e79415e8da2545a9a9002a9d674da77a1 (diff) |
Add Menu::currentIndex
De-couple current index management from the content item. Instead of
manipulating the content item's current index directly from C++, offer
a currentIndex property that can be visualized by the style, also when
not using a ListView. This is essentially the same technique ComboBox
uses to control the highlighted index in the popup ListView.
[ChangeLog][Controls][Menu] Added currentIndex property for styling
purposes.
Change-Id: Idf7746d9c08fc9ca9a0dfd15225ebae5a29243c9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickmenu_p.h')
-rw-r--r-- | src/quicktemplates2/qquickmenu_p.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickmenu_p.h b/src/quicktemplates2/qquickmenu_p.h index 24763d19..401dffcd 100644 --- a/src/quicktemplates2/qquickmenu_p.h +++ b/src/quicktemplates2/qquickmenu_p.h @@ -69,6 +69,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenu : public QQuickPopup Q_PROPERTY(bool cascade READ cascade WRITE setCascade NOTIFY cascadeChanged FINAL REVISION 3) Q_PROPERTY(qreal overlap READ overlap WRITE setOverlap NOTIFY overlapChanged FINAL REVISION 3) Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL REVISION 3) + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL REVISION 3) Q_CLASSINFO("DefaultProperty", "contentData") public: @@ -107,6 +108,9 @@ public: QQmlComponent *delegate() const; void setDelegate(QQmlComponent *delegate); + int currentIndex() const; + void setCurrentIndex(int index); + Q_REVISION(3) Q_INVOKABLE void popup(QQmlV4Function *args); protected: @@ -120,6 +124,7 @@ Q_SIGNALS: Q_REVISION(3) void cascadeChanged(); Q_REVISION(3) void overlapChanged(); Q_REVISION(3) void delegateChanged(); + Q_REVISION(3) void currentIndexChanged(); protected: void timerEvent(QTimerEvent *event) override; |