diff --git a/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp index 145fef8392..802744d0c0 100644 --- a/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp @@ -117,7 +117,7 @@ void IOWindow::CreateMainLayout() void IOWindow::ConfigChanged() { - const auto old_state = blockSignals(true); + const QSignalBlocker blocker(this); m_expression_text->setPlainText(QString::fromStdString(m_reference->GetExpression())); m_expression_text->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); @@ -128,8 +128,6 @@ void IOWindow::ConfigChanged() UpdateDeviceList(); UpdateOptionList(); - - blockSignals(old_state); } void IOWindow::ConnectWidgets() diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingNumeric.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingNumeric.cpp index 2c7b1fd4e8..cab6c68d9b 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingNumeric.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingNumeric.cpp @@ -38,9 +38,8 @@ void MappingDouble::fixup(QString& input) const void MappingDouble::ConfigChanged() { - const bool old_state = blockSignals(true); + const QSignalBlocker blocker(this); setValue(m_setting.GetValue()); - blockSignals(old_state); } MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::NumericSetting* setting) @@ -56,7 +55,6 @@ MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::NumericSettingblockSignals(true); + const QSignalBlocker blocker(m_devices_combo); m_devices_combo->clear(); @@ -292,8 +292,6 @@ void MappingWindow::OnGlobalDevicesChanged() } m_devices_combo->addItem(tr("All devices")); - - m_devices_combo->blockSignals(old_state); } void MappingWindow::SetMappingType(MappingWindow::Type type) diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.cpp b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.cpp index 70c418b305..e90b9b0634 100644 --- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.cpp @@ -29,7 +29,7 @@ WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget( CreateTurntableLayout(); CreateMainLayout(); - ChangeExtensionType(Type::NONE); + ChangeExtensionType(WiimoteEmu::ExtensionNumber::NONE); } void WiimoteEmuExtension::CreateClassicLayout() @@ -210,12 +210,14 @@ InputConfig* WiimoteEmuExtension::GetConfig() return Wiimote::GetConfig(); } -void WiimoteEmuExtension::ChangeExtensionType(WiimoteEmuExtension::Type type) +void WiimoteEmuExtension::ChangeExtensionType(u32 type) { - m_classic_box->setHidden(type != Type::CLASSIC_CONTROLLER); - m_drums_box->setHidden(type != Type::DRUMS); - m_guitar_box->setHidden(type != Type::GUITAR); - m_none_box->setHidden(type != Type::NONE); - m_nunchuk_box->setHidden(type != Type::NUNCHUK); - m_turntable_box->setHidden(type != Type::TURNTABLE); + using WiimoteEmu::ExtensionNumber; + + m_none_box->setHidden(type != ExtensionNumber::NONE); + m_nunchuk_box->setHidden(type != ExtensionNumber::NUNCHUK); + m_classic_box->setHidden(type != ExtensionNumber::CLASSIC); + m_guitar_box->setHidden(type != ExtensionNumber::GUITAR); + m_drums_box->setHidden(type != ExtensionNumber::DRUMS); + m_turntable_box->setHidden(type != ExtensionNumber::TURNTABLE); } diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.h b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.h index 9aaf44b2a0..bebeef1d62 100644 --- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.h +++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuExtension.h @@ -6,6 +6,8 @@ #include "DolphinQt/Config/Mapping/MappingWidget.h" +#include "Core/HW/WiimoteEmu/ExtensionPort.h" + class QGroupBox; class QHBoxLayout; @@ -13,21 +15,11 @@ class WiimoteEmuExtension final : public MappingWidget { Q_OBJECT public: - enum class Type - { - NONE, - CLASSIC_CONTROLLER, - DRUMS, - GUITAR, - NUNCHUK, - TURNTABLE - }; - explicit WiimoteEmuExtension(MappingWindow* window); InputConfig* GetConfig() override; - void ChangeExtensionType(Type type); + void ChangeExtensionType(u32 type); private: void LoadSettings() override; diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp index 29ba6f19ef..288fe37bde 100644 --- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp @@ -48,10 +48,7 @@ void WiimoteEmuGeneral::CreateMainLayout() m_extension_combo = new QComboBox(); for (const auto& attachment : ce_extension->GetAttachmentList()) - { - // TODO: Figure out how to localize this - m_extension_combo->addItem(QString::fromStdString(attachment->GetName())); - } + m_extension_combo->addItem(tr(attachment->GetName().c_str())); extension->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); @@ -74,30 +71,21 @@ void WiimoteEmuGeneral::Connect(MappingWindow* window) { connect(m_extension_combo, static_cast(&QComboBox::currentIndexChanged), this, &WiimoteEmuGeneral::OnAttachmentChanged); - connect(window, &MappingWindow::Update, this, &WiimoteEmuGeneral::Update); + connect(window, &MappingWindow::ConfigChanged, this, &WiimoteEmuGeneral::ConfigChanged); } void WiimoteEmuGeneral::OnAttachmentChanged(int extension) { - const QString value = m_extension_combo->currentText(); - - static const QMap value_map = { - {QStringLiteral("None"), WiimoteEmuExtension::Type::NONE}, - {QStringLiteral("Classic"), WiimoteEmuExtension::Type::CLASSIC_CONTROLLER}, - {QStringLiteral("Drums"), WiimoteEmuExtension::Type::DRUMS}, - {QStringLiteral("Guitar"), WiimoteEmuExtension::Type::GUITAR}, - {QStringLiteral("Nunchuk"), WiimoteEmuExtension::Type::NUNCHUK}, - {QStringLiteral("Turntable"), WiimoteEmuExtension::Type::TURNTABLE}}; - - m_extension_widget->ChangeExtensionType(value_map[value]); + m_extension_widget->ChangeExtensionType(extension); auto* ce_extension = static_cast( Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Attachments)); ce_extension->SetSelectedAttachment(extension); + SaveSettings(); } -void WiimoteEmuGeneral::Update() +void WiimoteEmuGeneral::ConfigChanged() { auto* ce_extension = static_cast( Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Attachments)); @@ -107,7 +95,6 @@ void WiimoteEmuGeneral::Update() void WiimoteEmuGeneral::LoadSettings() { - Update(); Wiimote::LoadConfig(); } diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h index ad346aabf3..d692f9d9dd 100644 --- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h +++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h @@ -23,7 +23,7 @@ private: void CreateMainLayout(); void Connect(MappingWindow* window); void OnAttachmentChanged(int index); - void Update(); + void ConfigChanged(); // Extensions QComboBox* m_extension_combo;