Skip to content
Permalink
Browse files

DolphinQt: Make the mapping window clear button use ControllerEmu's c…

…lear functionality.
  • Loading branch information...
jordan-woyak committed Feb 6, 2019
1 parent 46918f4 commit 64c3c52ef381f8aa2d2f04261d553b3d62c5b7c6
@@ -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());
@@ -18,7 +18,6 @@ class MappingBool : public QCheckBox
public:
MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);

void Clear();
void Update();

private:
@@ -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);
@@ -19,7 +19,6 @@ class MappingNumeric : public QSpinBox
public:
MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* ref);

void Clear();
void Update();

private:
@@ -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());
@@ -18,7 +18,6 @@ class MappingRadio : public QRadioButton
public:
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);

void Clear();
void Update();

private:
@@ -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)
@@ -60,8 +60,6 @@ class MappingWidget : public QWidget
QGroupBox* CreateGroupBox(const QString& name, ControllerEmu::ControlGroup* group);

private:
void OnClearFields();

MappingWindow* m_parent;
bool m_first = true;
std::vector<MappingBool*> m_bools;
@@ -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();
@@ -56,7 +56,6 @@ class MappingWindow final : public QDialog

signals:
void Update();
void ClearFields();
void Save();

private:
@@ -75,6 +74,7 @@ class MappingWindow final : public QDialog
void OnLoadProfilePressed();
void OnSaveProfilePressed();
void OnDefaultFieldsPressed();
void OnClearFieldsPressed();
void OnDeviceChanged(int index);
void OnGlobalDevicesChanged();

0 comments on commit 64c3c52

Please sign in to comment.
You can’t perform that action at this time.