Skip to content

Commit d3c5d2c

Browse files
sebastian-s-beckmannRytoEX
authored andcommitted
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.
1 parent 059fd62 commit d3c5d2c

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

frontend/OBSStudioAPI.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ bool OBSStudioAPI::obs_frontend_replay_buffer_active()
314314
void *OBSStudioAPI::obs_frontend_add_tools_menu_qaction(const char *name)
315315
{
316316
main->ui->menuTools->setEnabled(true);
317-
return (void *)main->ui->menuTools->addAction(QT_UTF8(name));
317+
QAction *action = main->ui->menuTools->addAction(QT_UTF8(name));
318+
action->setMenuRole(QAction::NoRole);
319+
return static_cast<void *>(action);
318320
}
319321

320322
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
326328
};
327329

328330
QAction *action = main->ui->menuTools->addAction(QT_UTF8(name));
331+
action->setMenuRole(QAction::NoRole);
329332
QObject::connect(action, &QAction::triggered, func);
330333
}
331334

frontend/widgets/OBSBasic_Docks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ QAction *OBSBasic::AddDockWidget(QDockWidget *dock)
210210
QAction *action = ui->menuDocks->addAction(dock->windowTitle());
211211
#endif
212212
action->setCheckable(true);
213+
action->setMenuRole(QAction::NoRole);
213214
assignDockToggle(dock, action);
214215
oldExtraDocks.push_back(dock);
215216
oldExtraDockNames.push_back(dock->objectName());

0 commit comments

Comments
 (0)