16#ifndef QX_THEME_STYLESHEET_PREFIX
17#define QX_THEME_STYLESHEET_PREFIX ":/qxribbon/res/stylesheets/"
30const ThemeInfo kThemeInfo[] = {
31 {
"light-yellow",
"Light Yellow",
"light_yellow.css",
false},
32 {
"light-office2013",
"Light Office 2013",
"light_office2013.css",
false},
33 {
"light-classic",
"Light Classic",
"light_classic.css",
false},
34 {
"light-fancy",
"Light Fancy",
"light_fancy.css",
false},
35 {
"dark-wps",
"Dark WPS",
"dark_wps.css",
true},
36 {
"dark-officeplus",
"Dark Office Plus",
"dark_officeplus.css",
true},
37 {
"custom",
"Custom",
"",
false},
40const int kThemeCount = int(
sizeof(kThemeInfo) /
sizeof(kThemeInfo[0]));
43bool isValidTheme(Theme theme)
45 const int index = int(theme);
46 return index >= 0 && index < kThemeCount;
49const ThemeInfo *infoOf(Theme theme)
51 return isValidTheme(theme) ? &kThemeInfo[int(theme)] :
Q_NULLPTR;
58 const ThemeInfo *info = infoOf(theme);
59 return info ? QString::fromLatin1(info->id) : QString();
64 const ThemeInfo *info = infoOf(theme);
65 return info ? QString::fromLatin1(info->name) : QString();
70 for (
int i = 0; i < kThemeCount; ++i) {
71 if (
id == QLatin1String(kThemeInfo[i].
id)) {
80 const ThemeInfo *info = infoOf(theme);
81 return info ? info->dark :
false;
86 const ThemeInfo *info = infoOf(theme);
87 if (!info || info->fileName[0] ==
'\0') {
100 if (!
file.open(QIODevice::ReadOnly | QIODevice::Text)) {
103 return QString::fromUtf8(
file.readAll());
bool isDarkTheme(Theme theme)
True for the themes that draw on a dark background.
Theme themeFromId(const QString &id, Theme fallback)
Resolves an id produced by themeId(); fallback is returned for unknown ids.
QString themeStyleSheet(Theme theme)
Content of the built-in style sheet, empty when the resource is missing.
QString themeId(Theme theme)
Stable identifier written to the configuration.
Theme
The themes understood by QxThemeManager.
QString themeName(Theme theme)
Human readable name, suitable for a settings dialog.
QString themeStyleSheetPath(Theme theme)
Resource path of the style sheet shipped with theme, empty for Custom.
#define Q_NULLPTR
Copyleft (C) 2025 maminjie canpool@163.com SPDX-License-Identifier: MulanPSL-2.0
#define QX_THEME_STYLESHEET_PREFIX
Where the built-in style sheets are looked up.
#define QX_THEME_BEGIN_NAMESPACE
#define QX_THEME_END_NAMESPACE