Fix focus problems for submenues in context menues

This commit is contained in:
miruka 2021-03-02 09:34:31 -04:00
parent 902f13ab68
commit d828312a24
2 changed files with 3 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import CppUtils 0.1
Menu { Menu {
id: menu id: menu
property bool isSubMenu: false
property var previouslyFocused: null property var previouslyFocused: null
// MenuItems that open popups (or other elements taking focus when opened) // MenuItems that open popups (or other elements taking focus when opened)
@ -57,6 +58,7 @@ Menu {
} }
onAboutToShow: { onAboutToShow: {
if (isSubMenu) return
previouslyFocused = window.activeFocusItem previouslyFocused = window.activeFocusItem
focusOnClosed = Qt.binding(() => previouslyFocused) focusOnClosed = Qt.binding(() => previouslyFocused)
} }

View File

@ -149,6 +149,7 @@ HTile {
HMenu { HMenu {
title: qsTr("Notifications") title: qsTr("Notifications")
isSubMenu: true
HMenuItem { HMenuItem {
text: qsTr("Use default account settings") text: qsTr("Use default account settings")