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
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2021-04-18 18:52:47 +02:00
parent f01d2e6db1
commit 465158476a

View file

@ -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.
{ // Add an actual Menu entry.
QMainWindow* main_widget = reinterpret_cast<QMainWindow*>(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<QMenu*> obs_menus = main_widget->menuBar()->findChildren<QMenu*>(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()) {