Skip to content
Permalink
Browse files

DolphinQt: Fix "Default" and "Clear" buttons not updating the display…

…ed extension.
  • Loading branch information...
jordan-woyak committed Apr 27, 2019
1 parent 687907e commit 74a997da65e868183412134eadefea834a0a9f86
@@ -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()
@@ -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<bool>* setting)
@@ -56,7 +55,6 @@ MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::NumericSetting<bo

void MappingBool::ConfigChanged()
{
const bool old_state = blockSignals(true);
const QSignalBlocker blocker(this);
setChecked(m_setting.GetValue());
blockSignals(old_state);
}
@@ -258,7 +258,7 @@ void MappingWindow::RefreshDevices()

void MappingWindow::OnGlobalDevicesChanged()
{
const auto old_state = m_devices_combo->blockSignals(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)
@@ -29,7 +29,7 @@ WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(
CreateTurntableLayout();
CreateMainLayout();

ChangeExtensionType(Type::NONE);
ChangeExtensionType(WiimoteEmu::ExtensionNumber::NONE);
}

void WiimoteEmuExtension::CreateClassicLayout()
@@ -212,12 +212,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);
}
@@ -6,28 +6,20 @@

#include "DolphinQt/Config/Mapping/MappingWidget.h"

#include "Core/HW/WiimoteEmu/ExtensionPort.h"

class QGroupBox;
class QHBoxLayout;

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;
@@ -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<void (QComboBox::*)(int)>(&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<QString, WiimoteEmuExtension::Type> 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<ControllerEmu::Attachments*>(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Attachments));
ce_extension->SetSelectedAttachment(extension);

SaveSettings();
}

void WiimoteEmuGeneral::Update()
void WiimoteEmuGeneral::ConfigChanged()
{
auto* ce_extension = static_cast<ControllerEmu::Attachments*>(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Attachments));
@@ -107,7 +95,6 @@ void WiimoteEmuGeneral::Update()

void WiimoteEmuGeneral::LoadSettings()
{
Update();
Wiimote::LoadConfig();
}

@@ -23,7 +23,7 @@ class WiimoteEmuGeneral final : public MappingWidget
void CreateMainLayout();
void Connect(MappingWindow* window);
void OnAttachmentChanged(int index);
void Update();
void ConfigChanged();

// Extensions
QComboBox* m_extension_combo;

0 comments on commit 74a997d

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