#include "util/ThemeManager.hpp" #include #include #include #include namespace velox::gui { namespace { Q_LOGGING_CATEGORY(lcTheme, "velox.gui.theme") QString loadQss(const QString &resourcePath) { QFile f(resourcePath); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { qCWarning(lcTheme, "could not load %s", qUtf8Printable(resourcePath)); return {}; } return QString::fromUtf8(f.readAll()); } } // namespace ThemeManager::ThemeManager(QObject *parent) : QObject(parent) { connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, &ThemeManager::onColorSchemeChanged); } void ThemeManager::apply() { const bool dark = QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark; const QString qss = loadQss(dark ? QStringLiteral(":/qss/dark.qss") : QStringLiteral(":/qss/idm-like.qss")); if (!qss.isEmpty()) { qApp->setStyleSheet(qss); } } void ThemeManager::onColorSchemeChanged() { apply(); } } // namespace velox::gui