From 9f01179941c57bb279f6b9bff5afa74506281f10 Mon Sep 17 00:00:00 2001 From: milonekrone Date: Wed, 14 Jan 2026 16:05:07 +0100 Subject: [PATCH] Add src/xmbconfig.cpp --- src/xmbconfig.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/xmbconfig.cpp diff --git a/src/xmbconfig.cpp b/src/xmbconfig.cpp new file mode 100644 index 0000000..0d35eca --- /dev/null +++ b/src/xmbconfig.cpp @@ -0,0 +1,37 @@ +#include "xmbconfig.h" +#include "apppaths.h" + +#include +#include + +static QString absIfRelative(const QString& base, const QString& path) { + if (path.isEmpty()) return path; + if (QDir::isAbsolutePath(path)) return path; + return QDir(base).filePath(path); +} + +bool XmbConfig::load() { + const QString root = AppPaths::configRoot(); + const QString cfgPath = QDir(root).filePath("xmb.conf"); + + QSettings s(cfgPath, QSettings::IniFormat); + s.setFallbacksEnabled(true); + + // Defaults (wenn config nicht existiert, bleibt’s stabil) + const QString assets = AppPaths::assetsRoot(); + + const auto orderStr = s.value("XMB/order", "Settings,Photos,Videos,Games,Steam").toString(); + m_order = orderStr.split(',', Qt::SkipEmptyParts); + for (auto& v : m_order) v = v.trimmed(); + + m_iconPath = absIfRelative(root, s.value("Assets/icon_path", QDir(assets).filePath("icons")).toString()); + m_soundPath = absIfRelative(root, s.value("Assets/sound_path", QDir(assets).filePath("sounds")).toString()); + m_fontBoot = absIfRelative(root, s.value("Assets/font_boot", QDir(assets).filePath("fonts/boot.ttf")).toString()); + m_bootAnimation = absIfRelative(root, s.value("Assets/boot_animation", QDir(assets).filePath("boot/boot.qml")).toString()); + + m_fps = s.value("UI/fps", 60).toInt(); + if (m_fps < 30) m_fps = 30; + if (m_fps > 240) m_fps = 240; + + return true; +}