From 8ce151e5ee50abd6f3888cb0c0bbfbb912217faf Mon Sep 17 00:00:00 2001 From: Igor Korsukov Date: Tue, 14 Jul 2026 11:40:52 +0200 Subject: [PATCH] added compat actions to navigation controller --- .../ui/internal/navigationcontroller.cpp | 28 +++++++++++++++++++ framework/ui/internal/navigationcontroller.h | 5 +++- framework/ui/tests/CMakeLists.txt | 1 + framework/ui/tests/environment.cpp | 4 ++- .../ui/tests/navigationcontroller_tests.cpp | 4 +++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/framework/ui/internal/navigationcontroller.cpp b/framework/ui/internal/navigationcontroller.cpp index ff3e50b824..6cbcf861ac 100644 --- a/framework/ui/internal/navigationcontroller.cpp +++ b/framework/ui/internal/navigationcontroller.cpp @@ -49,6 +49,7 @@ #define MYLOG() LOGN() #endif +using namespace muse; using namespace muse::ui; static const muse::UriQuery DEV_SHOW_CONTROLS_URI("muse://devtools/keynav/controls?modal=false"); @@ -300,6 +301,33 @@ void NavigationController::init() d->onRequest(this, TRIGGER_CONTROL_COMMAND, [this]() { doTriggerControl(); return muse::make_ok(); }); + // compat + { + static const std::map compatActionToCommand = { + { "nav-next-section", NEXT_SECTION_COMMAND }, + { "nav-prev-section", PREV_SECTION_COMMAND }, + { "nav-next-panel", NEXT_PANEL_COMMAND }, + { "nav-prev-panel", PREV_PANEL_COMMAND }, + { "nav-next-tab", NEXT_PANEL_COMMAND }, + { "nav-prev-tab", PREV_PANEL_COMMAND }, + { "nav-trigger-control", TRIGGER_CONTROL_COMMAND }, + { "nav-right", RIGHT_COMMAND }, + { "nav-left", LEFT_COMMAND }, + { "nav-up", UP_COMMAND }, + { "nav-down", DOWN_COMMAND }, + { "nav-escape", ESCAPE_COMMAND }, + { "nav-first-control", FIRST_CONTROL_COMMAND }, + { "nav-last-control", LAST_CONTROL_COMMAND }, + { "nav-nextrow-control", NEXTROW_CONTROL_COMMAND }, + { "nav-prevrow-control", PREVROW_CONTROL_COMMAND }, + }; + + auto ad = actionsDispatcher(); + for (const auto& [action, command] : compatActionToCommand) { + ad->reg(this, action, [d, command]() { d->dispatch(command); }); + } + } + qApp->installEventFilter(this); } diff --git a/framework/ui/internal/navigationcontroller.h b/framework/ui/internal/navigationcontroller.h index 245663236a..a640bdcc4e 100644 --- a/framework/ui/internal/navigationcontroller.h +++ b/framework/ui/internal/navigationcontroller.h @@ -28,6 +28,8 @@ #include "modularity/ioc.h" #include "rcommand/commandable.h" #include "rcommand/icommanddispatcher.h" +#include "actions/actionable.h" +#include "actions/iactionsdispatcher.h" #include "async/asyncable.h" #include "ui/imainwindow.h" #include "interactive/iinteractive.h" @@ -36,10 +38,11 @@ namespace muse::ui { class NavigationController : public QObject, public INavigationController, public Contextable, public async::Asyncable, - public rcommand::Commandable + public rcommand::Commandable, public actions::Actionable { public: ContextInject dispatcher = { this }; + ContextInject actionsDispatcher = { this }; ContextInject interactive = { this }; ContextInject mainWindow = { this }; diff --git a/framework/ui/tests/CMakeLists.txt b/framework/ui/tests/CMakeLists.txt index ceb7d2b2a6..9a8882a0e2 100644 --- a/framework/ui/tests/CMakeLists.txt +++ b/framework/ui/tests/CMakeLists.txt @@ -32,6 +32,7 @@ set(MODULE_TEST_SRC set(MODULE_TEST_LINK muse_rcommand + muse_actions muse_ui # Linking a non-qml module (or its tests) to its qml counterpart should # generally be avoided, but for the ui module we have to make an exception. diff --git a/framework/ui/tests/environment.cpp b/framework/ui/tests/environment.cpp index 2095a275c6..6b658e744e 100644 --- a/framework/ui/tests/environment.cpp +++ b/framework/ui/tests/environment.cpp @@ -24,10 +24,12 @@ #include "log.h" #include "framework/rcommand/rcommandmodule.h" +#include "framework/actions/actionsmodule.h" static muse::testing::SuiteEnvironment ui_senv( { - new muse::rcommand::RCommandModule() + new muse::rcommand::RCommandModule(), + new muse::actions::ActionsModule() }, nullptr, []() { diff --git a/framework/ui/tests/navigationcontroller_tests.cpp b/framework/ui/tests/navigationcontroller_tests.cpp index 500593fa9a..3aa267dc23 100644 --- a/framework/ui/tests/navigationcontroller_tests.cpp +++ b/framework/ui/tests/navigationcontroller_tests.cpp @@ -28,6 +28,7 @@ #include "ui/internal/navigationcontroller.h" #include "rcommand/internal/commanddispatcher.h" +#include "actions/internal/actionsdispatcher.h" #include "ui/navigationcommands.h" #include "global/tests/mocks/applicationmock.h" @@ -54,7 +55,9 @@ class Ui_NavigationControllerTests : public ::testing::Test m_controller = std::make_shared(nullptr); m_dispatcher = std::make_shared(); + m_actionsDispatcher = std::make_shared(iocCtx); m_controller->dispatcher.set(m_dispatcher); + m_controller->actionsDispatcher.set(m_actionsDispatcher); m_mainWindow = std::make_shared(); ON_CALL(*m_mainWindow, qWindow()).WillByDefault(Return(&m_window)); @@ -294,6 +297,7 @@ class Ui_NavigationControllerTests : public ::testing::Test std::shared_ptr m_controller; std::shared_ptr m_dispatcher; + std::shared_ptr m_actionsDispatcher; std::shared_ptr m_mainWindow; std::shared_ptr m_applicationMock;