Qt: Connect tweak/hack settings to Qt frontend

This commit is contained in:
Albert Liu
2020-06-14 14:43:16 -07:00
parent 53a2b8c03d
commit b7d9ce98e8
4 changed files with 85 additions and 7 deletions

View File

@@ -10,6 +10,7 @@
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSlider>
#include <QtWidgets/QSpinBox>
namespace SettingWidgetBinder {
@@ -111,6 +112,25 @@ struct SettingAccessor<QSlider>
}
};
template<>
struct SettingAccessor<QSpinBox>
{
static bool getBoolValue(const QSpinBox* widget) { return widget->value() > 0; }
static void setBoolValue(QSpinBox* widget, bool value) { widget->setValue(value ? 1 : 0); }
static int getIntValue(const QSpinBox* widget) { return widget->value(); }
static void setIntValue(QSpinBox* widget, int value) { widget->setValue(value); }
static QString getStringValue(const QSpinBox* widget) { return QStringLiteral("%1").arg(widget->value()); }
static void setStringValue(QSpinBox* widget, const QString& value) { widget->setValue(value.toInt()); }
template<typename F>
static void connectValueChanged(QSpinBox* widget, F func)
{
widget->connect(widget, QOverload<int>::of(&QSpinBox::valueChanged), func);
}
};
template<>
struct SettingAccessor<QAction>
{
@@ -213,4 +233,4 @@ void BindWidgetToEnumSetting(QtHostInterface* hi, WidgetType* widget, const QStr
});
}
} // namespace SettingWidgetBinder
} // namespace SettingWidgetBinder