From 0e7542cec59d37f319c0767e6365ede9b0306021 Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Sun, 30 Mar 2025 19:08:52 +0100 Subject: [PATCH] Qt: Add option to disable global menus on Linux/macOS --- pcsx2-qt/MainWindow.cpp | 21 +++++++++++++++++-- pcsx2-qt/MainWindow.h | 1 + pcsx2-qt/Settings/InterfaceSettingsWidget.cpp | 10 +++++++++ pcsx2-qt/Settings/InterfaceSettingsWidget.h | 1 + pcsx2-qt/Settings/InterfaceSettingsWidget.ui | 21 ++++++++++++------- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 80c05d515e..615143db58 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -108,6 +108,11 @@ MainWindow::MainWindow() pxAssert(!g_main_window); g_main_window = this; +#ifndef _WIN32 + bool enable_global_menus = Host::GetBaseBoolSettingValue("UI", "GlobalMenus", true); + QGuiApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, !enable_global_menus); +#endif + // Native window rendering is broken in wayland. // Let's work around it by disabling it for every widget besides // DisplayWidget. @@ -1829,6 +1834,15 @@ void MainWindow::onLanguageChanged() }); } +void MainWindow::onGlobalMenusChanged() +{ + recreate(); + + QtHost::RunOnUIThread([] { + g_main_window->doSettings("Interface"); + }); +} + void MainWindow::onInputRecNewActionTriggered() { const bool wasPaused = s_vm_paused; @@ -2683,8 +2697,11 @@ SettingsWindow* MainWindow::getSettingsWindow() if (!m_settings_window) { m_settings_window = new SettingsWindow(); - connect(m_settings_window->getInterfaceSettingsWidget(), &InterfaceSettingsWidget::themeChanged, this, &MainWindow::onThemeChanged); - connect(m_settings_window->getInterfaceSettingsWidget(), &InterfaceSettingsWidget::languageChanged, this, &MainWindow::onLanguageChanged); + + InterfaceSettingsWidget* widget = m_settings_window->getInterfaceSettingsWidget(); + connect(widget, &InterfaceSettingsWidget::themeChanged, this, &MainWindow::onThemeChanged); + connect(widget, &InterfaceSettingsWidget::languageChanged, this, &MainWindow::onLanguageChanged); + connect(widget, &InterfaceSettingsWidget::globalMenusChanged, this, &MainWindow::onGlobalMenusChanged); connect(m_settings_window->getGameListSettingsWidget(), &GameListSettingsWidget::preferEnglishGameListChanged, this, [] { g_main_window->m_game_list_widget->refreshGridCovers(); }); diff --git a/pcsx2-qt/MainWindow.h b/pcsx2-qt/MainWindow.h index d7b50c7a5b..fbc23cffc3 100644 --- a/pcsx2-qt/MainWindow.h +++ b/pcsx2-qt/MainWindow.h @@ -174,6 +174,7 @@ private Q_SLOTS: void updateLanguage(); void onThemeChanged(); void onLanguageChanged(); + void onGlobalMenusChanged(); void onScreenshotActionTriggered(); void onSaveGSDumpActionTriggered(); void onBlockDumpActionToggled(bool checked); diff --git a/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp b/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp index 4c86126034..b2d6bd2d2f 100644 --- a/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp +++ b/pcsx2-qt/Settings/InterfaceSettingsWidget.cpp @@ -108,6 +108,13 @@ InterfaceSettingsWidget::InterfaceSettingsWidget(SettingsWindow* dialog, QWidget SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.language, "UI", "Language", QtHost::GetDefaultLanguage()); connect(m_ui.language, QOverload::of(&QComboBox::currentIndexChanged), [this]() { emit languageChanged(); }); +#ifndef _WIN32 + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.globalMenus, "UI", "GlobalMenus", true); + connect(m_ui.globalMenus, &QCheckBox::checkStateChanged, [this]() { emit globalMenusChanged(); }); +#else + m_ui.globalMenus->hide(); +#endif + // Per-game settings is special, we don't want to bind it if we're editing per-game settings. if (!dialog->isPerGameSettings()) { @@ -181,6 +188,9 @@ InterfaceSettingsWidget::InterfaceSettingsWidget(SettingsWindow* dialog, QWidget dialog->registerWidgetHelp( m_ui.disableWindowResizing, tr("Disable Window Resizing"), tr("Unchecked"), tr("Prevents the main window from being resized.")); + dialog->registerWidgetHelp( + m_ui.globalMenus, tr("Enable Global Menus"), tr("Checked"), + tr("Display menu bars in a system-wide location if possible rather than at the top of each window.")); onRenderToSeparateWindowChanged(); } diff --git a/pcsx2-qt/Settings/InterfaceSettingsWidget.h b/pcsx2-qt/Settings/InterfaceSettingsWidget.h index df491a4c16..ad0e500e41 100644 --- a/pcsx2-qt/Settings/InterfaceSettingsWidget.h +++ b/pcsx2-qt/Settings/InterfaceSettingsWidget.h @@ -20,6 +20,7 @@ public: Q_SIGNALS: void themeChanged(); void languageChanged(); + void globalMenusChanged(); private Q_SLOTS: void onRenderToSeparateWindowChanged(); diff --git a/pcsx2-qt/Settings/InterfaceSettingsWidget.ui b/pcsx2-qt/Settings/InterfaceSettingsWidget.ui index 05874a1a92..db230ddb44 100644 --- a/pcsx2-qt/Settings/InterfaceSettingsWidget.ui +++ b/pcsx2-qt/Settings/InterfaceSettingsWidget.ui @@ -7,7 +7,7 @@ 0 0 698 - 512 + 574 @@ -138,6 +138,12 @@ Preferences + + + + + + @@ -145,9 +151,6 @@ - - - @@ -155,8 +158,12 @@ - - + + + + Enable Global Menus + + @@ -215,7 +222,7 @@ - Qt::Orientation::Vertical + Qt::Vertical