diff --git a/src/appshell/qml/platform/AppMenuBar.qml b/src/appshell/qml/platform/AppMenuBar.qml index cd3943c0f40b2..75b589d8caaa1 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: { 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 5578ee3bbae96..b4f1b0396a89f 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 ad8b87a02dede..01de287d8c430 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/MuseScore/UiComponents/StyledMenuLoader.qml b/src/framework/uicomponents/qml/MuseScore/UiComponents/StyledMenuLoader.qml index 59e2376aa7f28..6da142b06cd60 100644 --- a/src/framework/uicomponents/qml/MuseScore/UiComponents/StyledMenuLoader.qml +++ b/src/framework/uicomponents/qml/MuseScore/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/MuseScore/UiComponents/internal/StyledMenu.qml b/src/framework/uicomponents/qml/MuseScore/UiComponents/internal/StyledMenu.qml index 06a72e4e98322..fc69573b94820 100644 --- a/src/framework/uicomponents/qml/MuseScore/UiComponents/internal/StyledMenu.qml +++ b/src/framework/uicomponents/qml/MuseScore/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() } }) }