summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/CommonControllersWidget.cpp
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/DolphinQt/Config/CommonControllersWidget.cpp
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/DolphinQt/Config/CommonControllersWidget.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/CommonControllersWidget.cpp68
1 files changed, 68 insertions, 0 deletions
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();
+}