From b9bea58f0f6e72af995d2b0b6109dc3fdc046740 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 13 May 2025 01:03:37 -0500 Subject: [PATCH] DolphinQt: Move "Controllers" to main settings window. --- Source/Core/DolphinQt/CMakeLists.txt | 4 +- .../Core/DolphinQt/Config/ControllersPane.cpp | 35 +++++++++++++ .../Core/DolphinQt/Config/ControllersPane.h | 23 +++++++++ .../DolphinQt/Config/ControllersWindow.cpp | 51 ------------------- .../Core/DolphinQt/Config/ControllersWindow.h | 31 ----------- .../Core/DolphinQt/Config/SettingsWindow.cpp | 14 ++--- Source/Core/DolphinQt/Config/SettingsWindow.h | 13 +++-- Source/Core/DolphinQt/DolphinQt.vcxproj | 4 +- Source/Core/DolphinQt/MainWindow.cpp | 17 ++----- Source/Core/DolphinQt/MainWindow.h | 2 - 10 files changed, 82 insertions(+), 112 deletions(-) create mode 100644 Source/Core/DolphinQt/Config/ControllersPane.cpp create mode 100644 Source/Core/DolphinQt/Config/ControllersPane.h delete mode 100644 Source/Core/DolphinQt/Config/ControllersWindow.cpp delete mode 100644 Source/Core/DolphinQt/Config/ControllersWindow.h diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 96a053e869..a86b41cd68 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -69,8 +69,8 @@ add_executable(dolphin-emu Config/ControllerInterface/DualShockUDPClientWidget.h Config/ControllerInterface/ServerStringValidator.cpp Config/ControllerInterface/ServerStringValidator.h - Config/ControllersWindow.cpp - Config/ControllersWindow.h + Config/ControllersPane.cpp + Config/ControllersPane.h Config/FilesystemWidget.cpp Config/FilesystemWidget.h Config/FreeLookWidget.cpp diff --git a/Source/Core/DolphinQt/Config/ControllersPane.cpp b/Source/Core/DolphinQt/Config/ControllersPane.cpp new file mode 100644 index 0000000000..161557c9ca --- /dev/null +++ b/Source/Core/DolphinQt/Config/ControllersPane.cpp @@ -0,0 +1,35 @@ +// Copyright 2025 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "DolphinQt/Config/ControllersPane.h" + +#include + +#include "DolphinQt/Config/CommonControllersWidget.h" +#include "DolphinQt/Config/GamecubeControllersWidget.h" +#include "DolphinQt/Config/WiimoteControllersWidget.h" + +ControllersPane::ControllersPane() +{ + CreateMainLayout(); +} + +void ControllersPane::showEvent(QShowEvent* event) +{ + QWidget::showEvent(event); + + m_wiimote_controllers->UpdateBluetoothAvailableStatus(); +} + +void ControllersPane::CreateMainLayout() +{ + auto* const layout = new QVBoxLayout{this}; + + auto* const gamecube_controllers = new GamecubeControllersWidget(this); + m_wiimote_controllers = new WiimoteControllersWidget(this); + auto* const common = new CommonControllersWidget(this); + + layout->addWidget(gamecube_controllers); + layout->addWidget(m_wiimote_controllers); + layout->addWidget(common); +} diff --git a/Source/Core/DolphinQt/Config/ControllersPane.h b/Source/Core/DolphinQt/Config/ControllersPane.h new file mode 100644 index 0000000000..2c632ced95 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ControllersPane.h @@ -0,0 +1,23 @@ +// Copyright 2025 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +class WiimoteControllersWidget; + +class ControllersPane final : public QWidget +{ + Q_OBJECT +public: + ControllersPane(); + +protected: + void showEvent(QShowEvent* event) override; + +private: + void CreateMainLayout(); + + WiimoteControllersWidget* m_wiimote_controllers; +}; diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.cpp b/Source/Core/DolphinQt/Config/ControllersWindow.cpp deleted file mode 100644 index 5f6029a977..0000000000 --- a/Source/Core/DolphinQt/Config/ControllersWindow.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "DolphinQt/Config/ControllersWindow.h" - -#include -#include - -#include "DolphinQt/Config/CommonControllersWidget.h" -#include "DolphinQt/Config/GamecubeControllersWidget.h" -#include "DolphinQt/Config/WiimoteControllersWidget.h" -#include "DolphinQt/QtUtils/QtUtils.h" -#include "DolphinQt/QtUtils/WrapInScrollArea.h" - -ControllersWindow::ControllersWindow(QWidget* parent) : QDialog(parent) -{ - setWindowTitle(tr("Controller Settings")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - - m_gamecube_controllers = new GamecubeControllersWidget(this); - m_wiimote_controllers = new WiimoteControllersWidget(this); - m_common = new CommonControllersWidget(this); - CreateMainLayout(); - ConnectWidgets(); -} - -void ControllersWindow::showEvent(QShowEvent* event) -{ - QDialog::showEvent(event); - m_wiimote_controllers->UpdateBluetoothAvailableStatus(); -} - -void ControllersWindow::CreateMainLayout() -{ - auto* layout = new QVBoxLayout(); - m_button_box = new QDialogButtonBox(QDialogButtonBox::Close); - - layout->addWidget(m_gamecube_controllers); - layout->addWidget(m_wiimote_controllers); - layout->addWidget(m_common); - layout->addStretch(); - layout->addWidget(m_button_box); - - WrapInScrollArea(this, layout); - QtUtils::AdjustSizeWithinScreen(this); -} - -void ControllersWindow::ConnectWidgets() -{ - connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); -} diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.h b/Source/Core/DolphinQt/Config/ControllersWindow.h deleted file mode 100644 index 234110e804..0000000000 --- a/Source/Core/DolphinQt/Config/ControllersWindow.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -class CommonControllersWidget; -class GamecubeControllersWidget; -class QDialogButtonBox; -class QShowEvent; -class WiimoteControllersWidget; - -class ControllersWindow final : public QDialog -{ - Q_OBJECT -public: - explicit ControllersWindow(QWidget* parent); - -protected: - void showEvent(QShowEvent* event) override; - -private: - void CreateMainLayout(); - void ConnectWidgets(); - - QDialogButtonBox* m_button_box; - GamecubeControllersWidget* m_gamecube_controllers; - WiimoteControllersWidget* m_wiimote_controllers; - CommonControllersWidget* m_common; -}; diff --git a/Source/Core/DolphinQt/Config/SettingsWindow.cpp b/Source/Core/DolphinQt/Config/SettingsWindow.cpp index 3bf63f955a..0c8ebefcbb 100644 --- a/Source/Core/DolphinQt/Config/SettingsWindow.cpp +++ b/Source/Core/DolphinQt/Config/SettingsWindow.cpp @@ -9,6 +9,9 @@ #include #include +#include "Common/EnumUtils.h" + +#include "DolphinQt/Config/ControllersPane.h" #include "DolphinQt/QtUtils/QtUtils.h" #include "DolphinQt/QtUtils/WrapInScrollArea.h" #include "DolphinQt/Settings/AdvancedPane.h" @@ -133,7 +136,9 @@ SettingsWindow::SettingsWindow(QWidget* parent) : StackedSettingsWindow{parent} { setWindowTitle(tr("Settings")); + // If you change the order, don't forget to update the SettingsWindowPaneIndex enum. AddWrappedPane(new GeneralPane, tr("General")); + AddWrappedPane(new ControllersPane, tr("Controllers")); AddWrappedPane(new InterfacePane, tr("Interface")); AddWrappedPane(new AudioPane, tr("Audio")); AddWrappedPane(new PathPane, tr("Paths")); @@ -144,12 +149,7 @@ SettingsWindow::SettingsWindow(QWidget* parent) : StackedSettingsWindow{parent} OnDoneCreatingPanes(); } -void SettingsWindow::SelectAudioPane() +void SettingsWindow::SelectPane(SettingsWindowPaneIndex index) { - ActivatePane(static_cast(TabIndex::Audio)); -} - -void SettingsWindow::SelectGeneralPane() -{ - ActivatePane(static_cast(TabIndex::General)); + ActivatePane(Common::ToUnderlying(index)); } diff --git a/Source/Core/DolphinQt/Config/SettingsWindow.h b/Source/Core/DolphinQt/Config/SettingsWindow.h index b1217bb41b..6bccda70b1 100644 --- a/Source/Core/DolphinQt/Config/SettingsWindow.h +++ b/Source/Core/DolphinQt/Config/SettingsWindow.h @@ -31,10 +31,16 @@ private: QListWidget* m_navigation_list; }; -enum class TabIndex +enum class SettingsWindowPaneIndex : int { General = 0, - Audio = 2 + Controllers, + Interface, + Audio, + Paths, + GameCube, + Wii, + Advanced, }; class SettingsWindow final : public StackedSettingsWindow @@ -43,6 +49,5 @@ class SettingsWindow final : public StackedSettingsWindow public: explicit SettingsWindow(QWidget* parent = nullptr); - void SelectGeneralPane(); - void SelectAudioPane(); + void SelectPane(SettingsWindowPaneIndex); }; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 67216273f2..dc67819d75 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -68,7 +68,7 @@ - + @@ -293,7 +293,7 @@ - + diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index c3923641e9..744d58ca4a 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -77,7 +77,6 @@ #include "DolphinQt/AboutDialog.h" #include "DolphinQt/Achievements/AchievementsWindow.h" #include "DolphinQt/CheatsManager.h" -#include "DolphinQt/Config/ControllersWindow.h" #include "DolphinQt/Config/FreeLookWindow.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" #include "DolphinQt/Config/LogConfigWidget.h" @@ -1283,16 +1282,8 @@ void MainWindow::HideRenderWidget(bool reinit, bool is_exit) void MainWindow::ShowControllersWindow() { - if (!m_controllers_window) - { - m_controllers_window = new ControllersWindow(this); - InstallHotkeyFilter(m_controllers_window); - } - - SetQWidgetWindowDecorations(m_controllers_window); - m_controllers_window->show(); - m_controllers_window->raise(); - m_controllers_window->activateWindow(); + ShowSettingsWindow(); + m_settings_window->SelectPane(SettingsWindowPaneIndex::Controllers); } void MainWindow::ShowFreeLookWindow() @@ -1331,13 +1322,13 @@ void MainWindow::ShowSettingsWindow() void MainWindow::ShowAudioWindow() { ShowSettingsWindow(); - m_settings_window->SelectAudioPane(); + m_settings_window->SelectPane(SettingsWindowPaneIndex::Audio); } void MainWindow::ShowGeneralWindow() { ShowSettingsWindow(); - m_settings_window->SelectGeneralPane(); + m_settings_window->SelectPane(SettingsWindowPaneIndex::General); } void MainWindow::ShowAboutDialog() diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index bc795ed88c..934574044a 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -27,7 +27,6 @@ class BreakpointWidget; struct BootParameters; class CheatsManager; class CodeWidget; -class ControllersWindow; class DiscordHandler; class DragEnterEvent; class FIFOPlayerWindow; @@ -246,7 +245,6 @@ private: u32 m_state_slot = 1; std::unique_ptr m_pending_boot; - ControllersWindow* m_controllers_window = nullptr; SettingsWindow* m_settings_window = nullptr; GraphicsWindow* m_graphics_window = nullptr; FIFOPlayerWindow* m_fifo_window = nullptr;