Qt MappingWindow: move controller type into constructor

This commit is contained in:
Michael M 2017-11-03 14:31:17 -07:00
parent bb38b39952
commit 27e1577da9
5 changed files with 14 additions and 36 deletions

View File

@ -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<int>(i));
for (size_t i = 0; i < m_wiimote_mappings.size(); i++)
m_wiimote_mappings[i] = new MappingWindow(this, static_cast<int>(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<int>(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<int>(index)).exec();
}
void ControllersWindow::UnimplementedButton()

View File

@ -51,7 +51,6 @@ private:
QDialogButtonBox* m_button_box;
// Gamecube
std::array<MappingWindow*, 4> m_gc_mappings;
QGroupBox* m_gc_box;
QGridLayout* m_gc_layout;
std::array<QComboBox*, 4> m_gc_controller_boxes;
@ -59,7 +58,6 @@ private:
std::array<QHBoxLayout*, 4> m_gc_groups;
// Wii Remote
std::array<MappingWindow*, 4> m_wiimote_mappings;
QGroupBox* m_wiimote_box;
QGridLayout* m_wiimote_layout;
std::array<QLabel*, 4> m_wiimote_labels;

View File

@ -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)

View File

@ -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();

View File

@ -73,6 +73,8 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
setUnifiedTitleAndToolBarOnMac(true);
setAcceptDrops(true);
InitControllers();
CreateComponents();
ConnectGameList();
@ -81,7 +83,6 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> 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();