From c33fb2adbda09828138c4457df1a63f74b28a2b3 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 28 Feb 2023 19:29:41 +0100 Subject: [PATCH] Qt: Add a context menu to the toolbar's Settings button when the game is running A new small context menu that allows to select between global settings and game settings. --- pcsx2-qt/MainWindow.cpp | 17 +++++++++++++++++ pcsx2-qt/MainWindow.h | 4 ++++ pcsx2-qt/MainWindow.ui | 17 ++++++++++++++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 343d83b986..1489972d47 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -254,6 +254,10 @@ void MainWindow::setupAdditionalUi() m_status_vps_widget->setFixedSize(125, 16); m_status_vps_widget->hide(); + m_settings_toolbar_menu = new QMenu(m_ui.toolBar); + m_settings_toolbar_menu->addAction(m_ui.actionSettings); + m_settings_toolbar_menu->addAction(m_ui.actionViewGameProperties); + for (u32 scale = 0; scale <= 10; scale++) { QAction* action = m_ui.menuWindowSize->addAction((scale == 0) ? tr("Internal Resolution") : tr("%1x Scale").arg(scale)); @@ -316,6 +320,7 @@ void MainWindow::connectSignals() connect(m_ui.menuLoadState, &QMenu::aboutToShow, this, &MainWindow::onLoadStateMenuAboutToShow); connect(m_ui.menuSaveState, &QMenu::aboutToShow, this, &MainWindow::onSaveStateMenuAboutToShow); connect(m_ui.actionSettings, &QAction::triggered, [this]() { doSettings(); }); + connect(m_ui.actionSettings2, &QAction::triggered, this, &MainWindow::onSettingsTriggeredFromToolbar); connect(m_ui.actionInterfaceSettings, &QAction::triggered, [this]() { doSettings("Interface"); }); connect(m_ui.actionGameListSettings, &QAction::triggered, [this]() { doSettings("Game List"); }); connect(m_ui.actionEmulationSettings, &QAction::triggered, [this]() { doSettings("Emulation"); }); @@ -1013,6 +1018,18 @@ void MainWindow::onToolsVideoCaptureToggled(bool checked) g_emu_thread->beginCapture(path); } +void MainWindow::onSettingsTriggeredFromToolbar() +{ + if (s_vm_valid) + { + m_settings_toolbar_menu->exec(QCursor::pos()); + } + else + { + doSettings(); + } +} + void MainWindow::saveStateToConfig() { if (!isVisible()) diff --git a/pcsx2-qt/MainWindow.h b/pcsx2-qt/MainWindow.h index 54c8f945c2..a7554b1eb3 100644 --- a/pcsx2-qt/MainWindow.h +++ b/pcsx2-qt/MainWindow.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -170,6 +171,7 @@ private Q_SLOTS: void onBlockDumpActionToggled(bool checked); void onShowAdvancedSettingsToggled(bool checked); void onToolsVideoCaptureToggled(bool checked); + void onSettingsTriggeredFromToolbar(); // Input Recording void onInputRecNewActionTriggered(); @@ -283,6 +285,8 @@ private: QLabel* m_status_vps_widget = nullptr; QLabel* m_status_resolution_widget = nullptr; + QMenu* m_settings_toolbar_menu = nullptr; + QString m_current_disc_path; QString m_current_elf_override; QString m_current_game_serial; diff --git a/pcsx2-qt/MainWindow.ui b/pcsx2-qt/MainWindow.ui index afa86a0fc6..2945a0961e 100644 --- a/pcsx2-qt/MainWindow.ui +++ b/pcsx2-qt/MainWindow.ui @@ -79,7 +79,6 @@ - @@ -246,7 +245,7 @@ - + @@ -523,7 +522,19 @@ .. - &Settings... + &Settings + + + QAction::PreferencesRole + + + + + + .. + + + &Settings QAction::PreferencesRole