Use json file based themes instead of code to create them (theme editor + theme mode settings)

This commit is contained in:
luisangelsm
2026-03-02 21:23:39 +01:00
parent 87fada611d
commit 547e48cc04
42 changed files with 2776 additions and 1145 deletions

View File

@ -0,0 +1,57 @@
#ifndef THEME_REPOSITORY_H
#define THEME_REPOSITORY_H
#include "theme_meta.h"
#include <QJsonObject>
#include <QList>
#include <QString>
struct ThemeListEntry {
QString id;
QString displayName;
ThemeVariant variant;
bool isBuiltin;
};
class ThemeRepository
{
public:
explicit ThemeRepository(const QString &qrcPrefix, const QString &userThemesDir);
QList<ThemeListEntry> availableThemes() const;
bool contains(const QString &themeId) const;
QJsonObject loadThemeJson(const QString &themeId) const;
QString saveUserTheme(QJsonObject themeJson);
bool deleteUserTheme(const QString &themeId);
QString importThemeFromFile(const QString &filePath);
void refresh();
private:
QString qrcPrefix;
QString userThemesDir;
struct BuiltinEntry {
QString id;
QString resourcePath;
ThemeMeta meta;
};
QList<BuiltinEntry> builtins;
struct UserEntry {
QString id;
QString filePath;
ThemeMeta meta;
};
QList<UserEntry> userThemes;
void scanBuiltins();
void scanUserThemes();
static ThemeMeta extractMeta(const QJsonObject &json);
static QJsonObject readJsonFile(const QString &path);
QString filePathForUserTheme(const QString &uuid) const;
};
#endif // THEME_REPOSITORY_H