From 27e1577da90c04b642f86d23c5884cebf22df1a0 Mon Sep 17 00:00:00 2001 From: Michael M Date: Fri, 3 Nov 2017 14:31:17 -0700 Subject: [PATCH] Qt MappingWindow: move controller type into constructor --- .../DolphinQt2/Config/ControllersWindow.cpp | 14 ++++------- .../DolphinQt2/Config/ControllersWindow.h | 2 -- .../Config/Mapping/MappingWindow.cpp | 23 ++++--------------- .../DolphinQt2/Config/Mapping/MappingWindow.h | 5 ++-- Source/Core/DolphinQt2/MainWindow.cpp | 6 ++--- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/Source/Core/DolphinQt2/Config/ControllersWindow.cpp b/Source/Core/DolphinQt2/Config/ControllersWindow.cpp index ed8e08a91f..be22be811c 100644 --- a/Source/Core/DolphinQt2/Config/ControllersWindow.cpp +++ b/Source/Core/DolphinQt2/Config/ControllersWindow.cpp @@ -78,12 +78,6 @@ ControllersWindow::ControllersWindow(QWidget* parent) : QDialog(parent) CreateMainLayout(); LoadSettings(); ConnectWidgets(); - - for (size_t i = 0; i < m_gc_mappings.size(); i++) - m_gc_mappings[i] = new MappingWindow(this, static_cast(i)); - - for (size_t i = 0; i < m_wiimote_mappings.size(); i++) - m_wiimote_mappings[i] = new MappingWindow(this, static_cast(i)); } void ControllersWindow::CreateGamecubeLayout() @@ -440,8 +434,8 @@ void ControllersWindow::OnGCPadConfigure() default: return; } - m_gc_mappings[index]->ChangeMappingType(type); - m_gc_mappings[index]->exec(); + + MappingWindow(this, type, static_cast(index)).exec(); } void ControllersWindow::OnWiimoteConfigure() @@ -468,8 +462,8 @@ void ControllersWindow::OnWiimoteConfigure() default: return; } - m_wiimote_mappings[index]->ChangeMappingType(type); - m_wiimote_mappings[index]->exec(); + + MappingWindow(this, type, static_cast(index)).exec(); } void ControllersWindow::UnimplementedButton() diff --git a/Source/Core/DolphinQt2/Config/ControllersWindow.h b/Source/Core/DolphinQt2/Config/ControllersWindow.h index 171e44ca3c..3a1def39ad 100644 --- a/Source/Core/DolphinQt2/Config/ControllersWindow.h +++ b/Source/Core/DolphinQt2/Config/ControllersWindow.h @@ -51,7 +51,6 @@ private: QDialogButtonBox* m_button_box; // Gamecube - std::array m_gc_mappings; QGroupBox* m_gc_box; QGridLayout* m_gc_layout; std::array m_gc_controller_boxes; @@ -59,7 +58,6 @@ private: std::array m_gc_groups; // Wii Remote - std::array m_wiimote_mappings; QGroupBox* m_wiimote_box; QGridLayout* m_wiimote_layout; std::array m_wiimote_labels; diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp index 7e83e0e4ae..60efad03c6 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp @@ -32,12 +32,12 @@ #include "DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.h" #include "DolphinQt2/Settings.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/Device.h" #include "InputCommon/InputConfig.h" -#include "InputCommon/ControllerInterface/ControllerInterface.h" - -MappingWindow::MappingWindow(QWidget* parent, int port_num) : QDialog(parent), m_port(port_num) +MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num) + : QDialog(parent), m_port(port_num) { setWindowTitle(tr("Port %1").arg(port_num + 1)); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -47,6 +47,7 @@ MappingWindow::MappingWindow(QWidget* parent, int port_num) : QDialog(parent), m CreateResetLayout(); CreateMainLayout(); ConnectWidgets(); + SetMappingType(type); } void MappingWindow::CreateDevicesLayout() @@ -237,13 +238,8 @@ void MappingWindow::RefreshDevices() }); } -void MappingWindow::ChangeMappingType(MappingWindow::Type type) +void MappingWindow::SetMappingType(MappingWindow::Type type) { - if (m_mapping_type == type) - return; - - ClearWidgets(); - m_controller = nullptr; MappingWidget* widget; @@ -297,8 +293,6 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type) widget->LoadSettings(); - m_profiles_combo->clear(); - m_config = widget->GetConfig(); if (m_config) @@ -320,13 +314,6 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type) if (m_controller != nullptr) RefreshDevices(); - - m_mapping_type = type; -} - -void MappingWindow::ClearWidgets() -{ - m_tab_widget->clear(); } void MappingWindow::AddWidget(const QString& name, QWidget* widget) diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h index 3a7a308433..b7c0060f99 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h @@ -46,8 +46,7 @@ public: MAPPING_HOTKEYS }; - explicit MappingWindow(QWidget* parent, int port_num); - void ChangeMappingType(Type type); + explicit MappingWindow(QWidget* parent, Type type, int port_num); int GetPort() const; const ciface::Core::DeviceQualifier& GetDeviceQualifier() const; @@ -59,6 +58,7 @@ signals: void ClearFields(); private: + void SetMappingType(Type type); void CreateDevicesLayout(); void CreateProfilesLayout(); void CreateResetLayout(); @@ -67,7 +67,6 @@ private: void SetLayoutComplex(bool is_complex); void AddWidget(const QString& name, QWidget* widget); - void ClearWidgets(); void RefreshDevices(); diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index e92f794f6f..3c7d265aea 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -73,6 +73,8 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW setUnifiedTitleAndToolBarOnMac(true); setAcceptDrops(true); + InitControllers(); + CreateComponents(); ConnectGameList(); @@ -81,7 +83,6 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW ConnectStack(); ConnectMenuBar(); - InitControllers(); InitCoreCallbacks(); NetPlayInit(); @@ -154,7 +155,7 @@ void MainWindow::CreateComponents() m_stack = new QStackedWidget(this); m_controllers_window = new ControllersWindow(this); m_settings_window = new SettingsWindow(this); - m_hotkey_window = new MappingWindow(this, 0); + m_hotkey_window = new MappingWindow(this, MappingWindow::Type::MAPPING_HOTKEYS, 0); m_log_widget = new LogWidget(this); m_log_config_widget = new LogConfigWidget(this); @@ -570,7 +571,6 @@ void MainWindow::ShowAboutDialog() void MainWindow::ShowHotkeyDialog() { - m_hotkey_window->ChangeMappingType(MappingWindow::Type::MAPPING_HOTKEYS); m_hotkey_window->show(); m_hotkey_window->raise(); m_hotkey_window->activateWindow();