Qt: Connect tweak/hack settings to Qt frontend
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user