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

@ -18,6 +18,25 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(QtHostInterface* host_interface,
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToWindow,
QStringLiteral("Logging/LogToWindow"));
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.logToFile, QStringLiteral("Logging/LogToFile"));
// Tweaks/Hacks section
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.dmaMaxSliceTicks,
QStringLiteral("Hacks/DMAHaltTicks"));
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.dmaHaltTicks,
QStringLiteral("Hacks/DMAMaxSliceTicks"));
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.gpuFIFOSize, QStringLiteral("Hacks/GPUFIFOSize"));
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.gpuMaxRunAhead,
QStringLiteral("Hacks/GPUMaxRunAhead"));
connect(m_ui.resetToDefaultButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::onResetToDefaultClicked);
}
AdvancedSettingsWidget::~AdvancedSettingsWidget() = default;
void AdvancedSettingsWidget::onResetToDefaultClicked()
{
m_ui.dmaMaxSliceTicks->setValue(static_cast<int>(Settings::DEFAULT_DMA_MAX_SLICE_TICKS));
m_ui.dmaHaltTicks->setValue(static_cast<int>(Settings::DEFAULT_DMA_HALT_TICKS));
m_ui.gpuFIFOSize->setValue(static_cast<int>(Settings::DEFAULT_GPU_FIFO_SIZE));
m_ui.gpuMaxRunAhead->setValue(static_cast<int>(Settings::DEFAULT_GPU_MAX_RUN_AHEAD));
}

View File

@ -18,5 +18,7 @@ public:
private:
Ui::AdvancedSettingsWidget m_ui;
void onResetToDefaultClicked();
QtHostInterface* m_host_interface;
};

View File

@ -110,12 +110,22 @@
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>DMA Max Slice Size:</string>
<string>DMA Max Slice Ticks:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="dmaMaxSliceSize"/>
<widget class="QSpinBox" name="dmaMaxSliceTicks">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
@ -125,10 +135,30 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="dmaHaltTicks"/>
<widget class="QSpinBox" name="dmaHaltTicks">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="gpuFIFOSize"/>
<widget class="QSpinBox" name="gpuFIFOSize">
<property name="minimum">
<number>16</number>
</property>
<property name="maximum">
<number>4096</number>
</property>
<property name="value">
<number>16</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
@ -145,10 +175,17 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="gpuMaxRunAhead"/>
<widget class="QSpinBox" name="gpuMaxRunAhead">
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="resetToDefaultButton">
<property name="text">
<string>Reset To Default</string>
</property>

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