diff --git a/README.md b/README.md index 0e9b224..12aef64 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/lsfg-vk-ui/rsc/UI.qml b/lsfg-vk-ui/rsc/UI.qml index e1d5447..5cf3b87 100644 --- a/lsfg-vk-ui/rsc/UI.qml +++ b/lsfg-vk-ui/rsc/UI.qml @@ -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 } } } diff --git a/lsfg-vk-ui/src/backend.hpp b/lsfg-vk-ui/src/backend.hpp index 692fd67..ed39e14 100644 --- a/lsfg-vk-ui/src/backend.hpp +++ b/lsfg-vk-ui/src/backend.hpp @@ -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(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