Permalink
Browse files

Qt: Switch to QSignalBlocker for scoped signal blocking

  • Loading branch information...
Techjar committed Aug 23, 2018
1 parent 74cbc6c commit 1547b185c753e75ac65483cf1e694e4f007b71d9
@@ -12,6 +12,7 @@
#include <QLabel>
#include <QMessageBox>
#include <QRadioButton>
#include <QSignalBlocker>
#include <QVBoxLayout>
#include "Core/Config/GraphicsSettings.h"
@@ -300,7 +301,7 @@ void GeneralWidget::OnBackendChanged(const QString& backend_name)
{
m_backend_combo->setCurrentIndex(m_backend_combo->findData(QVariant(backend_name)));
const bool old = m_adapter_combo->blockSignals(true);
const QSignalBlocker blocker(m_adapter_combo);
m_adapter_combo->clear();
@@ -318,6 +319,4 @@ void GeneralWidget::OnBackendChanged(const QString& backend_name)
QStringLiteral("") :
tr("%1 doesn't support this feature.")
.arg(tr(g_video_backend->GetDisplayName().c_str())));
m_adapter_combo->blockSignals(old);
}
@@ -4,6 +4,8 @@
#include "DolphinQt/Config/Graphics/GraphicsBool.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
@@ -22,9 +24,8 @@ GraphicsBool::GraphicsBool(const QString& label, const Config::ConfigInfo<bool>&
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
bool old = blockSignals(true);
const QSignalBlocker blocker(this);
setChecked(Config::Get(m_setting) ^ m_reverse);
blockSignals(old);
});
}
@@ -4,6 +4,8 @@
#include "DolphinQt/Config/Graphics/GraphicsChoice.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
@@ -21,9 +23,8 @@ GraphicsChoice::GraphicsChoice(const QStringList& options, const Config::ConfigI
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
bool old = blockSignals(true);
const QSignalBlocker blocker(this);
setCurrentIndex(Config::Get(m_setting));
blockSignals(old);
});
}
@@ -4,6 +4,8 @@
#include "DolphinQt/Config/Graphics/GraphicsRadio.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
@@ -20,9 +22,8 @@ GraphicsRadioInt::GraphicsRadioInt(const QString& label, const Config::ConfigInf
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
bool old = blockSignals(true);
const QSignalBlocker blocker(this);
setChecked(Config::Get(m_setting) == m_value);
blockSignals(old);
});
}
@@ -4,6 +4,8 @@
#include "DolphinQt/Config/Graphics/GraphicsSlider.h"
#include <QSignalBlocker>
#include "Common/Config/Config.h"
#include "DolphinQt/Settings.h"
@@ -25,9 +27,8 @@ GraphicsSlider::GraphicsSlider(int minimum, int maximum, const Config::ConfigInf
bf.setBold(Config::GetActiveLayerForConfig(m_setting) != Config::LayerType::Base);
setFont(bf);
bool old = blockSignals(true);
const QSignalBlocker blocker(this);
setValue(Config::Get(m_setting));
blockSignals(old);
});
}
@@ -7,6 +7,7 @@
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QSignalBlocker>
#include <QVBoxLayout>
#include "Core/Config/GraphicsSettings.h"
@@ -132,7 +133,7 @@ void HacksWidget::ConnectWidgets()
void HacksWidget::LoadSettings()
{
const bool old = m_accuracy->blockSignals(true);
const QSignalBlocker blocker(m_accuracy);
auto samples = Config::Get(Config::GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES);
int slider_pos = 0;
@@ -161,8 +162,6 @@ void HacksWidget::LoadSettings()
Config::LayerType::Base);
m_accuracy_label->setFont(bf);
m_accuracy->blockSignals(old);
}
void HacksWidget::SaveSettings()
@@ -8,6 +8,7 @@
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>
#include <QSignalBlocker>
#include "Core/NetPlayClient.h"
#include "Core/NetPlayServer.h"
@@ -82,15 +83,14 @@ int PadMappingDialog::exec()
for (size_t i = 0; i < combo_group.size(); i++)
{
auto& combo = combo_group[i];
const bool old = combo->blockSignals(true);
const QSignalBlocker blocker(combo);
combo->clear();
combo->addItems(players);
const auto index = gc ? m_pad_mapping[i] : m_wii_mapping[i];
combo->setCurrentIndex(index == -1 ? 0 : index);
combo->blockSignals(old);
}
}

0 comments on commit 1547b18

Please sign in to comment.