From 465158476aee20da90ffed44327504cfcbbe75b5 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sun, 18 Apr 2021 18:52:47 +0200 Subject: [PATCH] ui: Insert StreamFX menu before OBS "Help" menu Instead of adding ourselves as the last entry which seems to confuse the MacOS Qt implementation, we instead insert ourselves before the Help menu. This should hopefully prevent the StreamFX menu from overriding the OBS About entry. Fixes #323 --- source/ui/ui.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/ui/ui.cpp b/source/ui/ui.cpp index d6034f4c..02bfb450 100644 --- a/source/ui/ui.cpp +++ b/source/ui/ui.cpp @@ -158,12 +158,20 @@ void streamfx::ui::handler::on_obs_loaded() connect(_about_action, &QAction::triggered, this, &streamfx::ui::handler::on_action_about); } - // Add an actual Menu entry. - QMainWindow* main_widget = reinterpret_cast(obs_frontend_get_main_window()); - _menu_action = new QAction(main_widget); - _menu_action->setMenu(_menu); - _menu_action->setText(QString::fromUtf8(D_TRANSLATE(_i18n_menu.data()))); - main_widget->menuBar()->addAction(_menu_action); + { // Add an actual Menu entry. + QMainWindow* main_widget = reinterpret_cast(obs_frontend_get_main_window()); + _menu_action = new QAction(main_widget); + _menu_action->setMenu(_menu); + _menu_action->setText(QString::fromUtf8(D_TRANSLATE(_i18n_menu.data()))); + + // For unknown reasons, the "About StreamFX" menu replaces the OBS about menu. + QList obs_menus = main_widget->menuBar()->findChildren(QString(), Qt::FindDirectChildrenOnly); + if (QMenu* help_menu = obs_menus.at(1); help_menu) { + main_widget->menuBar()->insertAction(help_menu->menuAction(), _menu_action); + } else { + main_widget->menuBar()->addAction(_menu_action); + } + } // Show the 'About StreamFX' dialog if that has not happened yet. if (!have_shown_about_streamfx()) {