DolphinQt: Make the mapping window clear button use ControllerEmu's clear functionality.

This commit is contained in:
Jordan Woyak 2019-02-06 17:40:58 -06:00
parent 46918f420d
commit 64c3c52ef3
10 changed files with 12 additions and 44 deletions

View File

@ -26,13 +26,6 @@ void MappingBool::Connect()
});
}
void MappingBool::Clear()
{
m_setting->SetValue(false);
m_parent->SaveSettings();
Update();
}
void MappingBool::Update()
{
setChecked(m_setting->GetValue());

View File

@ -18,7 +18,6 @@ class MappingBool : public QCheckBox
public:
MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
void Clear();
void Update();
private:

View File

@ -28,13 +28,6 @@ void MappingNumeric::Connect()
});
}
void MappingNumeric::Clear()
{
m_setting->SetValue(m_setting->m_default_value);
m_parent->SaveSettings();
Update();
}
void MappingNumeric::Update()
{
setValue(m_setting->GetValue() * 100);

View File

@ -19,7 +19,6 @@ class MappingNumeric : public QSpinBox
public:
MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* ref);
void Clear();
void Update();
private:

View File

@ -26,13 +26,6 @@ void MappingRadio::Connect()
});
}
void MappingRadio::Clear()
{
m_setting->SetValue(false);
m_parent->SaveSettings();
Update();
}
void MappingRadio::Update()
{
setChecked(m_setting->GetValue());

View File

@ -18,7 +18,6 @@ class MappingRadio : public QRadioButton
public:
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
void Clear();
void Update();
private:

View File

@ -24,7 +24,6 @@
MappingWidget::MappingWidget(MappingWindow* window) : m_parent(window)
{
connect(window, &MappingWindow::ClearFields, this, &MappingWidget::OnClearFields);
connect(window, &MappingWindow::Update, this, &MappingWidget::Update);
connect(window, &MappingWindow::Save, this, &MappingWidget::SaveSettings);
}
@ -141,21 +140,6 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
return group_box;
}
void MappingWidget::OnClearFields()
{
for (auto* button : m_buttons)
button->Clear();
for (auto* spinbox : m_numerics)
spinbox->Clear();
for (auto* checkbox : m_bools)
checkbox->Clear();
for (auto* radio : m_radio)
radio->Clear();
}
void MappingWidget::Update()
{
for (auto* button : m_buttons)

View File

@ -60,8 +60,6 @@ protected:
QGroupBox* CreateGroupBox(const QString& name, ControllerEmu::ControlGroup* group);
private:
void OnClearFields();
MappingWindow* m_parent;
bool m_first = true;
std::vector<MappingBool*> m_bools;

View File

@ -143,7 +143,7 @@ void MappingWindow::ConnectWidgets()
connect(m_devices_refresh, &QPushButton::clicked, this, &MappingWindow::RefreshDevices);
connect(m_devices_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MappingWindow::OnDeviceChanged);
connect(m_reset_clear, &QPushButton::clicked, this, [this] { emit ClearFields(); });
connect(m_reset_clear, &QPushButton::clicked, this, &MappingWindow::OnClearFieldsPressed);
connect(m_reset_default, &QPushButton::clicked, this, &MappingWindow::OnDefaultFieldsPressed);
connect(m_profiles_save, &QPushButton::clicked, this, &MappingWindow::OnSaveProfilePressed);
connect(m_profiles_load, &QPushButton::clicked, this, &MappingWindow::OnLoadProfilePressed);
@ -380,6 +380,16 @@ void MappingWindow::OnDefaultFieldsPressed()
emit Save();
}
void MappingWindow::OnClearFieldsPressed()
{
// Loading an empty inifile section clears everything.
IniFile::Section sec;
m_controller->LoadConfig(&sec);
m_controller->UpdateReferences(g_controller_interface);
emit Update();
emit Save();
}
bool MappingWindow::IsIterativeInput() const
{
return m_iterative_input->isChecked();

View File

@ -56,7 +56,6 @@ public:
signals:
void Update();
void ClearFields();
void Save();
private:
@ -75,6 +74,7 @@ private:
void OnLoadProfilePressed();
void OnSaveProfilePressed();
void OnDefaultFieldsPressed();
void OnClearFieldsPressed();
void OnDeviceChanged(int index);
void OnGlobalDevicesChanged();