summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-01-27 13:06:20 +0100
committerGitHub <noreply@github.com>2021-01-27 13:06:20 +0100
commit093978b2e0c1c6a438cd1ce8fecf62300ec6bed3 (patch)
tree15afee5919f4d582c9a4b9200675abe7220d9327 /Source/Core
parentd8bea87aa376185fd89e73ad3b0016dc39bb745a (diff)
parent67b9e94e4db3134f52b4cf85990f3bd144d23ab6 (diff)
Merge pull request #9466 from iwubcode/common_controllers_widget
DolphinQt: Move common controller interface logic to its own widget
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/CMakeLists.txt2
-rw-r--r--Source/Core/DolphinQt/Config/CommonControllersWidget.cpp68
-rw-r--r--Source/Core/DolphinQt/Config/CommonControllersWidget.h35
-rw-r--r--Source/Core/DolphinQt/Config/ControllersWindow.cpp34
-rw-r--r--Source/Core/DolphinQt/Config/ControllersWindow.h9
-rw-r--r--Source/Core/DolphinQt/DolphinQt.vcxproj2
6 files changed, 112 insertions, 38 deletions
diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt
index 6bc5e7fa77..24a2ec9b35 100644
--- a/Source/Core/DolphinQt/CMakeLists.txt
+++ b/Source/Core/DolphinQt/CMakeLists.txt
@@ -59,6 +59,8 @@ add_executable(dolphin-emu
Config/CheatCodeEditor.h
Config/CheatWarningWidget.cpp
Config/CheatWarningWidget.h
+ Config/CommonControllersWidget.cpp
+ Config/CommonControllersWidget.h
Config/ControllerInterface/DualShockUDPClientAddServerDialog.cpp
Config/ControllerInterface/DualShockUDPClientAddServerDialog.h
Config/ControllerInterface/DualShockUDPClientWidget.cpp
diff --git a/Source/Core/DolphinQt/Config/CommonControllersWidget.cpp b/Source/Core/DolphinQt/Config/CommonControllersWidget.cpp
new file mode 100644
index 0000000000..6b29b0cc0b
--- /dev/null
+++ b/Source/Core/DolphinQt/Config/CommonControllersWidget.cpp
@@ -0,0 +1,68 @@
+// Copyright 2021 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "DolphinQt/Config/CommonControllersWidget.h"
+
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+#include "Core/ConfigManager.h"
+#include "Core/Core.h"
+
+#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
+
+CommonControllersWidget::CommonControllersWidget(QWidget* parent) : QWidget(parent)
+{
+ CreateLayout();
+ LoadSettings();
+ ConnectWidgets();
+}
+
+void CommonControllersWidget::CreateLayout()
+{
+ // i18n: This is "common" as in "shared", not the opposite of "uncommon"
+ m_common_box = new QGroupBox(tr("Common"));
+ m_common_layout = new QVBoxLayout();
+ m_common_bg_input = new QCheckBox(tr("Background Input"));
+ m_common_configure_controller_interface = new QPushButton(tr("Alternate Input Sources"));
+
+ m_common_layout->addWidget(m_common_bg_input);
+ m_common_layout->addWidget(m_common_configure_controller_interface);
+
+ m_common_box->setLayout(m_common_layout);
+
+ auto* layout = new QVBoxLayout;
+ layout->setMargin(0);
+ layout->setAlignment(Qt::AlignTop);
+ layout->addWidget(m_common_box);
+ setLayout(layout);
+}
+
+void CommonControllersWidget::ConnectWidgets()
+{
+ connect(m_common_bg_input, &QCheckBox::toggled, this, &CommonControllersWidget::SaveSettings);
+ connect(m_common_configure_controller_interface, &QPushButton::clicked, this,
+ &CommonControllersWidget::OnControllerInterfaceConfigure);
+}
+
+void CommonControllersWidget::OnControllerInterfaceConfigure()
+{
+ ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this);
+ window->setAttribute(Qt::WA_DeleteOnClose, true);
+ window->setWindowModality(Qt::WindowModality::WindowModal);
+ window->show();
+}
+
+void CommonControllersWidget::LoadSettings()
+{
+ m_common_bg_input->setChecked(SConfig::GetInstance().m_BackgroundInput);
+}
+
+void CommonControllersWidget::SaveSettings()
+{
+ SConfig::GetInstance().m_BackgroundInput = m_common_bg_input->isChecked();
+ SConfig::GetInstance().SaveSettings();
+}
diff --git a/Source/Core/DolphinQt/Config/CommonControllersWidget.h b/Source/Core/DolphinQt/Config/CommonControllersWidget.h
new file mode 100644
index 0000000000..db1203fad4
--- /dev/null
+++ b/Source/Core/DolphinQt/Config/CommonControllersWidget.h
@@ -0,0 +1,35 @@
+// Copyright 2021 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <QWidget>
+
+#include <array>
+
+class QCheckBox;
+class QGroupBox;
+class QVBoxLayout;
+class QPushButton;
+
+class CommonControllersWidget final : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit CommonControllersWidget(QWidget* parent);
+
+private:
+ void OnControllerInterfaceConfigure();
+
+ void CreateLayout();
+ void ConnectWidgets();
+
+ void LoadSettings();
+ void SaveSettings();
+
+ QGroupBox* m_common_box;
+ QVBoxLayout* m_common_layout;
+ QCheckBox* m_common_bg_input;
+ QPushButton* m_common_configure_controller_interface;
+};
diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.cpp b/Source/Core/DolphinQt/Config/ControllersWindow.cpp
index 82e6da599b..42465f1a8c 100644
--- a/Source/Core/DolphinQt/Config/ControllersWindow.cpp
+++ b/Source/Core/DolphinQt/Config/ControllersWindow.cpp
@@ -31,7 +31,7 @@
#include "Core/IOS/IOS.h"
#include "Core/IOS/USB/Bluetooth/BTReal.h"
-#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"
+#include "DolphinQt/Config/CommonControllersWidget.h"
#include "DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
@@ -68,7 +68,7 @@ ControllersWindow::ControllersWindow(QWidget* parent) : QDialog(parent)
CreateGamecubeLayout();
CreateWiimoteLayout();
- CreateCommonLayout();
+ m_common = new CommonControllersWidget(this);
CreateMainLayout();
LoadSettings();
ConnectWidgets();
@@ -204,20 +204,6 @@ void ControllersWindow::CreateWiimoteLayout()
m_wiimote_layout->addWidget(m_wiimote_refresh, continuous_scanning_row, 3);
}
-void ControllersWindow::CreateCommonLayout()
-{
- // i18n: This is "common" as in "shared", not the opposite of "uncommon"
- m_common_box = new QGroupBox(tr("Common"));
- m_common_layout = new QVBoxLayout();
- m_common_bg_input = new QCheckBox(tr("Background Input"));
- m_common_configure_controller_interface = new QPushButton(tr("Alternate Input Sources"));
-
- m_common_layout->addWidget(m_common_bg_input);
- m_common_layout->addWidget(m_common_configure_controller_interface);
-
- m_common_box->setLayout(m_common_layout);
-}
-
void ControllersWindow::CreateMainLayout()
{
auto* layout = new QVBoxLayout();
@@ -225,7 +211,7 @@ void ControllersWindow::CreateMainLayout()
layout->addWidget(m_gc_box);
layout->addWidget(m_wiimote_box);
- layout->addWidget(m_common_box);
+ layout->addWidget(m_common);
layout->addStretch();
layout->addWidget(m_button_box);
@@ -246,9 +232,6 @@ void ControllersWindow::ConnectWidgets()
connect(m_wiimote_continuous_scanning, &QCheckBox::toggled, this,
&ControllersWindow::OnWiimoteModeChanged);
- connect(m_common_bg_input, &QCheckBox::toggled, this, &ControllersWindow::SaveSettings);
- connect(m_common_configure_controller_interface, &QPushButton::clicked, this,
- &ControllersWindow::OnControllerInterfaceConfigure);
connect(m_wiimote_continuous_scanning, &QCheckBox::toggled, this,
&ControllersWindow::SaveSettings);
connect(m_wiimote_real_balance_board, &QCheckBox::toggled, this,
@@ -457,14 +440,6 @@ void ControllersWindow::OnWiimoteConfigure()
window->show();
}
-void ControllersWindow::OnControllerInterfaceConfigure()
-{
- ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this);
- window->setAttribute(Qt::WA_DeleteOnClose, true);
- window->setWindowModality(Qt::WindowModality::WindowModal);
- window->show();
-}
-
void ControllersWindow::LoadSettings()
{
for (size_t i = 0; i < m_wiimote_groups.size(); i++)
@@ -483,8 +458,6 @@ void ControllersWindow::LoadSettings()
m_wiimote_ciface->setChecked(SConfig::GetInstance().connect_wiimotes_for_ciface);
m_wiimote_continuous_scanning->setChecked(SConfig::GetInstance().m_WiimoteContinuousScanning);
- m_common_bg_input->setChecked(SConfig::GetInstance().m_BackgroundInput);
-
if (SConfig::GetInstance().m_bt_passthrough_enabled)
m_wiimote_passthrough->setChecked(true);
else
@@ -499,7 +472,6 @@ void ControllersWindow::SaveSettings()
SConfig::GetInstance().connect_wiimotes_for_ciface = m_wiimote_ciface->isChecked();
SConfig::GetInstance().m_WiimoteContinuousScanning = m_wiimote_continuous_scanning->isChecked();
SConfig::GetInstance().m_bt_passthrough_enabled = m_wiimote_passthrough->isChecked();
- SConfig::GetInstance().m_BackgroundInput = m_common_bg_input->isChecked();
WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, m_wiimote_real_balance_board->isChecked() ?
WiimoteSource::Real :
diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.h b/Source/Core/DolphinQt/Config/ControllersWindow.h
index 93807be9b6..b835f09366 100644
--- a/Source/Core/DolphinQt/Config/ControllersWindow.h
+++ b/Source/Core/DolphinQt/Config/ControllersWindow.h
@@ -8,6 +8,7 @@
#include <array>
+class CommonControllersWidget;
class MappingWindow;
class QDialogButtonBox;
class QCheckBox;
@@ -16,7 +17,6 @@ class QHBoxLayout;
class QGridLayout;
class QGroupBox;
class QLabel;
-class QVBoxLayout;
class QPushButton;
class QRadioButton;
@@ -36,11 +36,9 @@ private:
void OnWiimoteRefreshPressed();
void OnGCPadConfigure();
void OnWiimoteConfigure();
- void OnControllerInterfaceConfigure();
void CreateGamecubeLayout();
void CreateWiimoteLayout();
- void CreateCommonLayout();
void CreateMainLayout();
void ConnectWidgets();
void LoadSettings();
@@ -75,8 +73,5 @@ private:
QPushButton* m_wiimote_refresh;
// Common
- QGroupBox* m_common_box;
- QVBoxLayout* m_common_layout;
- QCheckBox* m_common_bg_input;
- QPushButton* m_common_configure_controller_interface;
+ CommonControllersWidget* m_common;
};
diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj
index 840233cc5e..a3ebddbd13 100644
--- a/Source/Core/DolphinQt/DolphinQt.vcxproj
+++ b/Source/Core/DolphinQt/DolphinQt.vcxproj
@@ -49,6 +49,7 @@
<ClCompile Include="Config\ARCodeWidget.cpp" />
<ClCompile Include="Config\CheatCodeEditor.cpp" />
<ClCompile Include="Config\CheatWarningWidget.cpp" />
+ <ClCompile Include="Config\CommonControllersWidget.cpp" />
<ClCompile Include="Config\ControllerInterface\ControllerInterfaceWindow.cpp" />
<ClCompile Include="Config\ControllerInterface\DualShockUDPClientAddServerDialog.cpp" />
<ClCompile Include="Config\ControllerInterface\DualShockUDPClientWidget.cpp" />
@@ -220,6 +221,7 @@
<QtMoc Include="CheatsManager.h" />
<QtMoc Include="Config\ARCodeWidget.h" />
<QtMoc Include="Config\CheatWarningWidget.h" />
+ <QtMoc Include="Config\CommonControllersWidget.h" />
<QtMoc Include="Config\ControllerInterface\ControllerInterfaceWindow.h" />
<QtMoc Include="Config\ControllerInterface\DualShockUDPClientAddServerDialog.h" />
<QtMoc Include="Config\ControllerInterface\DualShockUDPClientWidget.h" />