summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-06-06 12:30:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-12 16:22:10 +0200
commit2799b41d6b6c3ae28acc2c1daad029d9817fc6ad (patch)
tree2ec389dd0e7db2e3edb5635009fb23d293f63206
parentf04f0b8b4ed83025c02fdbed6ebb8105dee51479 (diff)
downloadqtquickcontrols-2799b41d6b6c3ae28acc2c1daad029d9817fc6ad.tar.gz
Menu: Don't open disabled submenus
Task-number: QTBUG-39384 Change-Id: I5310c6efb0a7045f6f89c6347551a0043d8e0ca6 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r--src/controls/MenuBar.qml20
-rw-r--r--src/controls/Private/MenuContentItem.qml4
2 files changed, 19 insertions, 5 deletions
diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml
index 0fe56ef1..4d577930 100644
--- a/src/controls/MenuBar.qml
+++ b/src/controls/MenuBar.qml
@@ -174,8 +174,13 @@ MenuBarPrivate {
Keys.onLeftPressed: {
if (d.openedMenuIndex > 0) {
- d.preselectMenuItem = true
- d.openedMenuIndex--
+ var idx = d.openedMenuIndex - 1
+ while (idx >= 0 && !root.menus[idx].enabled)
+ idx--
+ if (idx >= 0) {
+ d.preselectMenuItem = true
+ d.openedMenuIndex = idx
+ }
} else {
event.accepted = false;
}
@@ -183,8 +188,13 @@ MenuBarPrivate {
Keys.onRightPressed: {
if (d.openedMenuIndex !== -1 && d.openedMenuIndex < root.menus.length - 1) {
- d.preselectMenuItem = true
- d.openedMenuIndex++
+ var idx = d.openedMenuIndex + 1
+ while (idx < root.menus.length && !root.menus[idx].enabled)
+ idx++
+ if (idx < root.menus.length) {
+ d.preselectMenuItem = true
+ d.openedMenuIndex = idx
+ }
} else {
event.accepted = false;
}
@@ -223,6 +233,8 @@ MenuBarPrivate {
Connections {
target: d
onOpenedMenuIndexChanged: {
+ if (!__menuItem.enabled)
+ return;
if (d.openedMenuIndex === index) {
if (__menuItem.__usingDefaultStyle)
__menuItem.style = d.style.menuStyle
diff --git a/src/controls/Private/MenuContentItem.qml b/src/controls/Private/MenuContentItem.qml
index dbbf26a9..669cde2f 100644
--- a/src/controls/Private/MenuContentItem.qml
+++ b/src/controls/Private/MenuContentItem.qml
@@ -165,7 +165,7 @@ Loader {
itemsModel: __menu.items
minWidth: __menu.__minimumWidth
maxHeight: d.style ? d.style.__maxPopupHeight : 0
- onTriggered: d.triggerAndDismiss(item)
+ onTriggered: if (item.__menuItem.enabled) d.triggerAndDismiss(item)
}
Component {
@@ -199,6 +199,8 @@ Loader {
active: visible
function __showSubMenu(immediately) {
+ if (!__menuItem.enabled)
+ return;
if (immediately) {
if (__menu.__currentIndex === __menuItemIndex) {
if (__menuItem.__usingDefaultStyle)