refactor(cleanup): ui backwards compat fixes

This commit is contained in:
PancakeTAS 2025-12-25 02:44:43 +01:00
parent b57e364fab
commit 9ba851ba08
3 changed files with 25 additions and 17 deletions

View file

@ -19,7 +19,7 @@ This will extract lsfg-vk to `~/.local`. Please **keep track of the files that w
4. The graphical interface requires Qt6 and Qt6 Quick in order to run. If you do not have these installed, install the following packages:
```bash
sudo apt install qt6-qpa-plugins libqt6quick6 # On Debian/Ubuntu-based systems
sudo apt install qt6-qpa-plugins libqt6quick6 qml6-module-qtquick-controls qml6-module-qtquick-layouts qml6-module-qtquick-window qml6-module-qtquick-dialogs # On Debian/Ubuntu-based systems
sudo pacman -S qt6-declarative qt6-base # On Arch-based systems
sudo dnf install qt6-qtdeclarative qt6-qtbase # On Fedora
```

View file

@ -237,8 +237,8 @@ ApplicationWindow {
Layout.fillWidth: true
model: ["None"]
currentValue: backend.pacing_mode
onActivated: (index) => backend.pacing_mode = model[index]
currentIndex: backend.pacing_mode
onActivated: (index) => backend.pacing_mode = index
}
}
@ -250,8 +250,8 @@ ApplicationWindow {
Layout.fillWidth: true
model: backend.gpus
currentValue: backend.gpu
onActivated: (index) => backend.gpu = model[index]
currentIndex: backend.gpu
onActivated: (index) => backend.gpu = index
}
}
}

View file

@ -32,9 +32,9 @@ namespace lsfgvk::ui {
Q_PROPERTY(size_t multiplier READ getMultiplier WRITE multiplierUpdated NOTIFY refreshUI)
Q_PROPERTY(float flow_scale READ getFlowScale WRITE flowScaleUpdated NOTIFY refreshUI)
Q_PROPERTY(bool performance_mode READ getPerformanceMode WRITE performanceModeUpdated NOTIFY refreshUI)
Q_PROPERTY(QString pacing_mode READ getPacingMode WRITE pacingModeUpdated NOTIFY refreshUI)
Q_PROPERTY(int pacing_mode READ getPacingMode WRITE pacingModeUpdated NOTIFY refreshUI)
Q_PROPERTY(QStringList gpus READ calculateGPUList NOTIFY refreshUI)
Q_PROPERTY(QString gpu READ getGPU WRITE gpuUpdated NOTIFY refreshUI)
Q_PROPERTY(int gpu READ getGPU WRITE gpuUpdated NOTIFY refreshUI)
public:
explicit Backend();
@ -82,19 +82,20 @@ namespace lsfgvk::ui {
VALIDATE_AND_GET_PROFILE(false)
return conf.performance_mode;
}
[[nodiscard]] QString getPacingMode() const {
VALIDATE_AND_GET_PROFILE("None")
[[nodiscard]] int getPacingMode() const {
VALIDATE_AND_GET_PROFILE(0)
switch (conf.pacing) {
case ls::Pacing::None: return "None";
case ls::Pacing::None: return 0;
}
throw std::runtime_error("Unknown pacing type in backend");
}
[[nodiscard]] QStringList calculateGPUList() const {
return this->m_gpu_list;
}
[[nodiscard]] QString getGPU() const {
VALIDATE_AND_GET_PROFILE("Default")
return QString::fromStdString(conf.gpu.value_or("Default"));
[[nodiscard]] int getGPU() const {
VALIDATE_AND_GET_PROFILE(0)
auto gpu = QString::fromStdString(conf.gpu.value_or("Default"));
return static_cast<int>(this->m_gpu_list.indexOf(gpu));
}
#undef VALIDATE_AND_GET_PROFILE
@ -147,14 +148,21 @@ namespace lsfgvk::ui {
conf.performance_mode = performance_mode;
MARK_DIRTY()
}
void pacingModeUpdated(const QString& pacing_mode) {
void pacingModeUpdated(int pacing_mode) {
VALIDATE_AND_GET_PROFILE()
if (pacing_mode == "None")
conf.pacing = ls::Pacing::None;
if (pacing_mode == 0)
switch (pacing_mode) {
case 0:
conf.pacing = ls::Pacing::None;
break;
default:
throw std::runtime_error("Unknown pacing mode in backend");
}
MARK_DIRTY()
}
void gpuUpdated(const QString& gpu) {
void gpuUpdated(int gpu_idx) {
VALIDATE_AND_GET_PROFILE()
const auto& gpu = this->m_gpu_list.at(gpu_idx);
if (gpu.trimmed().isEmpty() || gpu == "Default")
conf.gpu = std::nullopt;
else