From d3c5d2ce0b15bac7a502f5aef4b3b5ec72ee8e09 Mon Sep 17 00:00:00 2001 From: Sebastian Beckmann Date: Sat, 7 Jun 2025 18:30:59 +0200 Subject: [PATCH] frontend: Set Frontend-API QActions role to NoRole When no role is set, the default is QAction::TextHeuristicRole. This means that the text of the item gets fuzzy-matched in Qt against a set of possible strings that could indicate that the menu should be in the application menu on macOS. For us this meant however that on some languages, the translation of "WebSocket Server Settings" would begin with "Config", and as such the related QAction replaces our "Settings" action for the PreferencesRole, and clicking "Preferences..." in the application menu would open the websocket settings. It should probably be considered a bug in Qt that implicit matches via TextHeuristicRole can overwrite ones that are explicitly set (like our PreferencesRole). However we explicitly set our roles ourselves anyways and there is no scenario where a plugin should overwrite them, we can just default actions added via the Frontend API to be NoRole; and worry about the Qt bug later. --- frontend/OBSStudioAPI.cpp | 5 ++++- frontend/widgets/OBSBasic_Docks.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/OBSStudioAPI.cpp b/frontend/OBSStudioAPI.cpp index a4bcafba7..47c832c4b 100644 --- a/frontend/OBSStudioAPI.cpp +++ b/frontend/OBSStudioAPI.cpp @@ -314,7 +314,9 @@ bool OBSStudioAPI::obs_frontend_replay_buffer_active() void *OBSStudioAPI::obs_frontend_add_tools_menu_qaction(const char *name) { main->ui->menuTools->setEnabled(true); - return (void *)main->ui->menuTools->addAction(QT_UTF8(name)); + QAction *action = main->ui->menuTools->addAction(QT_UTF8(name)); + action->setMenuRole(QAction::NoRole); + return static_cast(action); } void OBSStudioAPI::obs_frontend_add_tools_menu_item(const char *name, obs_frontend_cb callback, void *private_data) @@ -326,6 +328,7 @@ void OBSStudioAPI::obs_frontend_add_tools_menu_item(const char *name, obs_fronte }; QAction *action = main->ui->menuTools->addAction(QT_UTF8(name)); + action->setMenuRole(QAction::NoRole); QObject::connect(action, &QAction::triggered, func); } diff --git a/frontend/widgets/OBSBasic_Docks.cpp b/frontend/widgets/OBSBasic_Docks.cpp index c2bdaf7ec..caeb675ae 100644 --- a/frontend/widgets/OBSBasic_Docks.cpp +++ b/frontend/widgets/OBSBasic_Docks.cpp @@ -210,6 +210,7 @@ QAction *OBSBasic::AddDockWidget(QDockWidget *dock) QAction *action = ui->menuDocks->addAction(dock->windowTitle()); #endif action->setCheckable(true); + action->setMenuRole(QAction::NoRole); assignDockToggle(dock, action); oldExtraDocks.push_back(dock); oldExtraDockNames.push_back(dock->objectName());