Qt: Fix another usage of QObject::disconnect()

This commit is contained in:
Stenzek 2025-07-22 20:26:44 +10:00
parent a5826ea6ae
commit 2e56f5d3ae
No known key found for this signature in database
2 changed files with 14 additions and 13 deletions

View File

@ -154,10 +154,8 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(SettingsWindow* dialog, QWidget* pa
&ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked); &ConsoleSettingsWidget::onEnableCPUClockSpeedControlChecked);
connect(m_ui.cpuClockSpeed, &QSlider::valueChanged, this, &ConsoleSettingsWidget::onCPUClockSpeedValueChanged); connect(m_ui.cpuClockSpeed, &QSlider::valueChanged, this, &ConsoleSettingsWidget::onCPUClockSpeedValueChanged);
SettingWidgetBinder::SetAvailability(m_ui.cpuExecutionModeLabel, SettingWidgetBinder::SetAvailability(
!m_dialog->hasGameTrait(GameDatabase::Trait::ForceInterpreter)); m_ui.cpuExecutionMode, !m_dialog->hasGameTrait(GameDatabase::Trait::ForceInterpreter), m_ui.cpuExecutionModeLabel);
SettingWidgetBinder::SetAvailability(m_ui.cpuExecutionMode,
!m_dialog->hasGameTrait(GameDatabase::Trait::ForceInterpreter));
calculateCPUClockValue(); calculateCPUClockValue();
} }

View File

@ -1497,12 +1497,22 @@ static inline void BindWidgetToFolderSetting(SettingsInterface* sif, QLineEdit*
} }
template<typename WidgetType> template<typename WidgetType>
static inline void SetAvailability(WidgetType* widget, bool available) static inline void DisconnectWidget(WidgetType* widget)
{
using Accessor = SettingAccessor<WidgetType>;
Accessor::disconnect(widget);
}
template<typename WidgetType>
static inline void SetAvailability(WidgetType* widget, bool available, QLabel* widget_label = nullptr)
{ {
if (available) if (available)
return; return;
widget->disconnect(); if (widget_label)
widget_label->setEnabled(false);
DisconnectWidget(widget);
if constexpr (std::is_same_v<WidgetType, QComboBox>) if constexpr (std::is_same_v<WidgetType, QComboBox>)
{ {
@ -1530,11 +1540,4 @@ static inline void SetAvailability(WidgetType* widget, bool available)
widget->setEnabled(false); widget->setEnabled(false);
} }
template<typename WidgetType>
static inline void DisconnectWidget(WidgetType* widget)
{
using Accessor = SettingAccessor<WidgetType>;
Accessor::disconnect(widget);
}
} // namespace SettingWidgetBinder } // namespace SettingWidgetBinder