diff --git a/src/appshell/qml/platform/AppMenuBar.qml b/src/appshell/qml/platform/AppMenuBar.qml index 3b76416dceeaf..1a57ffac7a746 100644 --- a/src/appshell/qml/platform/AppMenuBar.qml +++ b/src/appshell/qml/platform/AppMenuBar.qml @@ -205,11 +205,20 @@ ListView { id: menuLoader property string menuId: "" + property bool hasSiblingMenus: true onHandleMenuItem: function(itemId) { Qt.callLater(appMenuModel.handleMenuItem, itemId) } + onOpenPrevMenu: { + appMenuModel.openPrevMenu() + } + + onOpenNextMenu: { + appMenuModel.openNextMenu() + } + onOpened: { appMenuModel.openedMenuId = menuLoader.menuId } diff --git a/src/appshell/view/navigableappmenumodel.cpp b/src/appshell/view/navigableappmenumodel.cpp index 3a7b274cbbe58..2e4d5e52c4575 100644 --- a/src/appshell/view/navigableappmenumodel.cpp +++ b/src/appshell/view/navigableappmenumodel.cpp @@ -84,6 +84,20 @@ void NavigableAppMenuModel::handleMenuItem(const QString& itemId) AppMenuModel::handleMenuItem(itemId); } +void NavigableAppMenuModel::openPrevMenu() +{ + restoreMUNavigationSystemState(); + navigate(Qt::Key_Left); + activateHighlightedMenu(); +} + +void NavigableAppMenuModel::openNextMenu() +{ + restoreMUNavigationSystemState(); + navigate(Qt::Key_Right); + activateHighlightedMenu(); +} + void NavigableAppMenuModel::openMenu(const QString& menuId, bool byHover) { bool navigationStarted = isNavigationStarted(); @@ -330,7 +344,6 @@ bool NavigableAppMenuModel::processEventForAppMenu(QEvent* event) default: break; } - return false; } diff --git a/src/appshell/view/navigableappmenumodel.h b/src/appshell/view/navigableappmenumodel.h index f504d9d92a007..14cdb0622e329 100644 --- a/src/appshell/view/navigableappmenumodel.h +++ b/src/appshell/view/navigableappmenumodel.h @@ -48,6 +48,8 @@ class NavigableAppMenuModel : public AppMenuModel Q_INVOKABLE void load() override; Q_INVOKABLE void handleMenuItem(const QString& itemId) override; Q_INVOKABLE void openMenu(const QString& menuId, bool byHover); + Q_INVOKABLE void openPrevMenu(); + Q_INVOKABLE void openNextMenu(); bool isNavigationStarted() const; bool isMenuOpened() const; diff --git a/src/framework/uicomponents/qml/Muse/UiComponents/StyledMenuLoader.qml b/src/framework/uicomponents/qml/Muse/UiComponents/StyledMenuLoader.qml index 57c69af8398cd..50acab3d9e698 100644 --- a/src/framework/uicomponents/qml/Muse/UiComponents/StyledMenuLoader.qml +++ b/src/framework/uicomponents/qml/Muse/UiComponents/StyledMenuLoader.qml @@ -29,11 +29,14 @@ Loader { id: loader signal handleMenuItem(string itemId) + signal openPrevMenu() + signal openNextMenu() signal opened() signal closed(bool force) property alias menu: loader.item property var menuAnchorItem: null + property bool hasSiblingMenus: loader.hasSiblingMenus property alias isMenuOpened: loader.active @@ -62,6 +65,14 @@ Loader { Qt.callLater(loader.handleMenuItem, itemId) } + onOpenPrevMenu: { + Qt.callLater(loader.openPrevMenu) + } + + onOpenNextMenu: { + Qt.callLater(loader.openNextMenu) + } + onClosed: function(force) { Qt.callLater(prv.unloadMenu, force) } diff --git a/src/framework/uicomponents/qml/Muse/UiComponents/internal/StyledMenu.qml b/src/framework/uicomponents/qml/Muse/UiComponents/internal/StyledMenu.qml index b0e6e31582db6..6c64eff04bdc9 100644 --- a/src/framework/uicomponents/qml/Muse/UiComponents/internal/StyledMenu.qml +++ b/src/framework/uicomponents/qml/Muse/UiComponents/internal/StyledMenu.qml @@ -35,6 +35,8 @@ MenuView { property int preferredAlign: Qt.AlignRight // Left, HCenter, Right signal handleMenuItem(string itemId) + signal openPrevMenu() + signal openNextMenu() property alias width: content.width property alias height: content.height @@ -138,6 +140,10 @@ MenuView { case NavigationEvent.Right: var selectedItem = prv.selectedItem() if (!Boolean(selectedItem) || !selectedItem.hasSubMenu) { + if (loader.hasSiblingMenus) { + root.close(true) + root.openNextMenu() + } return } @@ -159,7 +165,10 @@ MenuView { root.navigationParentControl.requestActive() } - root.close() + if(loader.hasSiblingMenus) { + root.close() + root.openPrevMenu() + } break case NavigationEvent.Up: case NavigationEvent.Down: @@ -180,6 +189,7 @@ MenuView { var menuLoaderComponent = Qt.createComponent("../StyledMenuLoader.qml"); root.subMenuLoader = menuLoaderComponent.createObject(root) root.subMenuLoader.menuAnchorItem = root.anchorItem + root.subMenuLoader.hasSiblingMenus = loader.hasSiblingMenus root.subMenuLoader.handleMenuItem.connect(function(itemId) { Qt.callLater(root.handleMenuItem, itemId) @@ -195,6 +205,7 @@ MenuView { if (force) { root.close(true) + root.openNextMenu() } }) }