mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #13702 from CostPerUnit/master
MappingWidget: Add Advanced Configuration Button to Point And Point Passthrough "Enable" boxes
This commit is contained in:
@ -893,7 +893,8 @@ void IRPassthroughMappingIndicator::Draw()
|
||||
|
||||
p.scale(1.0, -1.0);
|
||||
|
||||
auto pen = GetInputDotPen(m_ir_group.enabled ? GetAdjustedInputColor() : GetRawInputColor());
|
||||
auto pen =
|
||||
GetInputDotPen(m_ir_group.enabled.GetValue() ? GetAdjustedInputColor() : GetRawInputColor());
|
||||
|
||||
for (std::size_t i = 0; i != WiimoteEmu::CameraLogic::NUM_POINTS; ++i)
|
||||
{
|
||||
|
@ -102,15 +102,48 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||
break;
|
||||
}
|
||||
|
||||
if (indicator)
|
||||
// Mapping indicator.
|
||||
if (indicator != nullptr)
|
||||
{
|
||||
const auto indicator_layout = new QBoxLayout(QBoxLayout::Direction::Down);
|
||||
auto* const indicator_layout = new QBoxLayout(QBoxLayout::Direction::Down);
|
||||
indicator_layout->addWidget(indicator);
|
||||
indicator_layout->setAlignment(Qt::AlignCenter);
|
||||
form_layout->addRow(indicator_layout);
|
||||
|
||||
connect(this, &MappingWidget::Update, indicator, qOverload<>(&MappingIndicator::update));
|
||||
}
|
||||
|
||||
// "Enabled" checkbox.
|
||||
if (group->HasEnabledSetting())
|
||||
{
|
||||
AddSettingWidget(form_layout, group->enabled_setting.get());
|
||||
|
||||
auto enable_labels = [form_layout, start_index = form_layout->rowCount()](bool enabled) {
|
||||
// Skipping the "Enabled" checkbox row itself and the mapping indicator, if it exists.
|
||||
for (int i = start_index; i < form_layout->count(); ++i)
|
||||
{
|
||||
auto* const item = form_layout->itemAt(i, QFormLayout::LabelRole);
|
||||
if (item == nullptr)
|
||||
continue;
|
||||
|
||||
auto* const widget = item->widget();
|
||||
if (widget == nullptr)
|
||||
continue;
|
||||
|
||||
widget->setEnabled(enabled);
|
||||
}
|
||||
};
|
||||
|
||||
connect(this, &MappingWidget::Update, this, [group, enable_labels, enabled = true]() mutable {
|
||||
if (enabled == group->enabled_setting->GetValue())
|
||||
return;
|
||||
enable_labels(enabled = !enabled);
|
||||
});
|
||||
}
|
||||
|
||||
// "Calibrate" button.
|
||||
if (indicator != nullptr)
|
||||
{
|
||||
const bool need_calibration = group->type == ControllerEmu::GroupType::Cursor ||
|
||||
group->type == ControllerEmu::GroupType::Stick ||
|
||||
group->type == ControllerEmu::GroupType::Tilt ||
|
||||
@ -131,28 +164,6 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||
|
||||
AddSettingWidgets(form_layout, group, ControllerEmu::SettingVisibility::Normal);
|
||||
|
||||
if (group->default_value != ControllerEmu::ControlGroup::DefaultValue::AlwaysEnabled)
|
||||
{
|
||||
QLabel* group_enable_label = new QLabel(tr("Enable"));
|
||||
QCheckBox* group_enable_checkbox = new QCheckBox();
|
||||
group_enable_checkbox->setChecked(group->enabled);
|
||||
form_layout->insertRow(0, group_enable_label, group_enable_checkbox);
|
||||
auto enable_group_by_checkbox = [group, form_layout, group_enable_label,
|
||||
group_enable_checkbox] {
|
||||
group->enabled = group_enable_checkbox->isChecked();
|
||||
for (int i = 0; i < form_layout->count(); ++i)
|
||||
{
|
||||
QWidget* widget = form_layout->itemAt(i)->widget();
|
||||
if (widget != nullptr && widget != group_enable_label && widget != group_enable_checkbox)
|
||||
widget->setEnabled(group->enabled);
|
||||
}
|
||||
};
|
||||
enable_group_by_checkbox();
|
||||
connect(group_enable_checkbox, &QCheckBox::toggled, this, enable_group_by_checkbox);
|
||||
connect(this, &MappingWidget::ConfigChanged, this,
|
||||
[group_enable_checkbox, group] { group_enable_checkbox->setChecked(group->enabled); });
|
||||
}
|
||||
|
||||
const auto advanced_setting_count =
|
||||
std::ranges::count(group->numeric_settings, ControllerEmu::SettingVisibility::Advanced,
|
||||
&ControllerEmu::NumericSettingBase::GetVisibility);
|
||||
@ -201,36 +212,42 @@ void MappingWidget::AddSettingWidgets(QFormLayout* layout, ControllerEmu::Contro
|
||||
if (setting->GetVisibility() != visibility)
|
||||
continue;
|
||||
|
||||
QWidget* setting_widget = nullptr;
|
||||
AddSettingWidget(layout, setting.get());
|
||||
}
|
||||
}
|
||||
|
||||
switch (setting->GetType())
|
||||
{
|
||||
case ControllerEmu::SettingType::Double:
|
||||
setting_widget = new MappingDouble(
|
||||
this, static_cast<ControllerEmu::NumericSetting<double>*>(setting.get()));
|
||||
break;
|
||||
void MappingWidget::AddSettingWidget(QFormLayout* layout,
|
||||
ControllerEmu::NumericSettingBase* setting)
|
||||
{
|
||||
QWidget* setting_widget = nullptr;
|
||||
|
||||
case ControllerEmu::SettingType::Bool:
|
||||
setting_widget =
|
||||
new MappingBool(this, static_cast<ControllerEmu::NumericSetting<bool>*>(setting.get()));
|
||||
break;
|
||||
switch (setting->GetType())
|
||||
{
|
||||
case ControllerEmu::SettingType::Double:
|
||||
setting_widget =
|
||||
new MappingDouble(this, static_cast<ControllerEmu::NumericSetting<double>*>(setting));
|
||||
break;
|
||||
|
||||
default:
|
||||
// FYI: Widgets for additional types can be implemented as needed.
|
||||
break;
|
||||
}
|
||||
case ControllerEmu::SettingType::Bool:
|
||||
setting_widget =
|
||||
new MappingBool(this, static_cast<ControllerEmu::NumericSetting<bool>*>(setting));
|
||||
break;
|
||||
|
||||
if (setting_widget)
|
||||
{
|
||||
const auto hbox = new QHBoxLayout;
|
||||
default:
|
||||
// FYI: Widgets for additional types can be implemented as needed.
|
||||
break;
|
||||
}
|
||||
|
||||
hbox->addWidget(setting_widget);
|
||||
setting_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
if (setting_widget != nullptr)
|
||||
{
|
||||
auto* const hbox = new QHBoxLayout;
|
||||
|
||||
hbox->addWidget(CreateSettingAdvancedMappingButton(*setting));
|
||||
hbox->addWidget(setting_widget);
|
||||
setting_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
layout->addRow(tr(setting->GetUIName()), hbox);
|
||||
}
|
||||
hbox->addWidget(CreateSettingAdvancedMappingButton(*setting));
|
||||
|
||||
layout->addRow(tr(setting->GetUIName()), hbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,11 @@ protected:
|
||||
int columns);
|
||||
void CreateControl(const ControllerEmu::Control* control, QFormLayout* layout, bool indicator);
|
||||
QPushButton* CreateSettingAdvancedMappingButton(ControllerEmu::NumericSettingBase& setting);
|
||||
|
||||
void AddSettingWidget(QFormLayout* layout, ControllerEmu::NumericSettingBase* setting);
|
||||
void AddSettingWidgets(QFormLayout* layout, ControllerEmu::ControlGroup* group,
|
||||
ControllerEmu::SettingVisibility visibility);
|
||||
|
||||
void ShowAdvancedControlGroupDialog(ControllerEmu::ControlGroup* group);
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user