|
QtCanpool 3.3.0
|
Application-wide theme engine. 更多...
#include <qxtheme/qxthememanager.h>

Public 成员函数 | |
| Theme | theme () const |
| The theme that is currently applied. | |
| bool | isDark () const |
| Convenience wrapper around isDarkTheme(theme()). | |
| bool | followSystemTheme () const |
| True when the theme follows the operating system colour scheme. | |
| void | setFollowSystemTheme (bool on) |
| Enables or disables following the system colour scheme. | |
| Theme | systemLightTheme () const |
| Theme used while following the system and the system is light. | |
| Theme | systemDarkTheme () const |
| Theme used while following the system and the system is dark. | |
| void | setSystemThemePair (Theme lightTheme, Theme darkTheme) |
| Overrides the pair used while following the system. | |
| QxCore::QxSettings * | settings () const |
| The settings object backing persistence; created on first use from the application name, and owned by the manager. | |
| void | setSettings (QxCore ::QxSettings *settings) |
| Replaces the settings object. | |
| QString | styleSheet (Theme theme) const |
| Style sheet that apply() would install for theme. | |
| void | setStyleSheetFile (Theme theme, const QString &fileName) |
| Points theme at an external style sheet. | |
| void | setStyleSheet (Theme theme, const QString &css) |
| Supplies the style sheet of theme inline, which takes precedence over any file. | |
| void | setTheme (Theme theme) |
| Applies theme, persists it as the explicit choice and emits themeChanged(). | |
| void | apply () |
| Re-installs the palette and style sheet of the current theme. | |
| void | refreshSystemTheme () |
| Re-evaluates the system colour scheme. | |
| void | themeChanged (Theme theme) |
| Emitted after a theme has been applied. | |
| void | followSystemThemeChanged (bool on) |
| Emitted when following the system colour scheme is toggled. | |
静态 Public 成员函数 | |
| static QxThemeManager * | instance () |
| The process-wide instance, created on first use. | |
Protected 成员函数 | |
| QxThemeManager (QObject *parent=0) | |
| ~QxThemeManager () override | |
Application-wide theme engine.
The ribbon library could already swap a style sheet, but nothing owned the decision: no persistence, no palette, no reaction to the operating system switching to dark mode, and no way to re-apply a theme to a window that was already on screen. QxThemeManager closes that gap.
Typical use, right after QApplication is constructed:
The selection is stored through QxSettings, so the next launch restores it. Switching at run time calls QApplication::setPalette() and QApplication::setStyleSheet(), which is enough for Qt to re-polish every widget: QxRibbon and QxDock widgets pick the change up through their existing QEvent::StyleChange handling.
The engine does not link against qxribbon. The built-in style sheets are looked up in the qxribbon resource bundle at run time, which only resolves when that library is part of the process; use setStyleSheetFile() or setStyleSheet() to supply your own.
在文件 qxthememanager.h 第 41 行定义.
|
explicitprotected |
在文件 qxthememanager.cpp 第 151 行定义.
|
overrideprotected |
在文件 qxthememanager.cpp 第 159 行定义.
| void QxTheme::QxThemeManager::apply | ( | ) |
Re-installs the palette and style sheet of the current theme.
在文件 qxthememanager.cpp 第 315 行定义.
| bool QxTheme::QxThemeManager::followSystemTheme | ( | ) | const |
True when the theme follows the operating system colour scheme.
在文件 qxthememanager.cpp 第 185 行定义.
| void QxTheme::QxThemeManager::followSystemThemeChanged | ( | bool | on | ) |
Emitted when following the system colour scheme is toggled.
|
static |
The process-wide instance, created on first use.
Construct it after QApplication, otherwise there is nothing to apply the theme to. The instance is intentionally never destroyed: it outlives QApplication, so tearing it down would only risk a dangling connection.
在文件 qxthememanager.cpp 第 164 行定义.
| bool QxTheme::QxThemeManager::isDark | ( | ) | const |
Convenience wrapper around isDarkTheme(theme()).
在文件 qxthememanager.cpp 第 180 行定义.
| void QxTheme::QxThemeManager::refreshSystemTheme | ( | ) |
Re-evaluates the system colour scheme.
Called automatically on the platforms that report a change; call it manually on platforms that do not (see followSystemTheme()). No-op while following is disabled.
在文件 qxthememanager.cpp 第 342 行定义.
| void QxTheme::QxThemeManager::setFollowSystemTheme | ( | bool | on | ) |
Enables or disables following the system colour scheme.
Turning it on applies the matching theme immediately and keeps it in sync afterwards. The flag itself is persisted; the theme it derives is not, so the stored value stays the user's explicit choice.
在文件 qxthememanager.cpp 第 191 行定义.
| void QxTheme::QxThemeManager::setSettings | ( | QxCore ::QxSettings * | settings | ) |
Replaces the settings object.
Ownership is transferred to the manager. Already stored values are re-read, so this is also the way to point a test at a hermetic file.
在文件 qxthememanager.cpp 第 246 行定义.
| void QxTheme::QxThemeManager::setStyleSheet | ( | Theme | theme, |
| const QString & | css | ||
| ) |
Supplies the style sheet of theme inline, which takes precedence over any file.
Pass an empty string to drop the override.
在文件 qxthememanager.cpp 第 295 行定义.
| void QxTheme::QxThemeManager::setStyleSheetFile | ( | Theme | theme, |
| const QString & | fileName | ||
| ) |
Points theme at an external style sheet.
The registration lives for the lifetime of the process; pass an empty name to fall back to the built-in resource.
在文件 qxthememanager.cpp 第 284 行定义.
| void QxTheme::QxThemeManager::setTheme | ( | Theme | theme | ) |
Applies theme, persists it as the explicit choice and emits themeChanged().
Following the system, if enabled, stays enabled and takes over again on the next system change.
在文件 qxthememanager.cpp 第 306 行定义.
| QxCore::QxSettings * QxTheme::QxThemeManager::settings | ( | ) | const |
The settings object backing persistence; created on first use from the application name, and owned by the manager.
在文件 qxthememanager.cpp 第 240 行定义.
| QString QxTheme::QxThemeManager::styleSheet | ( | Theme | theme | ) | const |
Style sheet that apply() would install for theme.
在文件 qxthememanager.cpp 第 261 行定义.
| Theme QxTheme::QxThemeManager::systemDarkTheme | ( | ) | const |
Theme used while following the system and the system is dark.
在文件 qxthememanager.cpp 第 219 行定义.
| Theme QxTheme::QxThemeManager::systemLightTheme | ( | ) | const |
Theme used while following the system and the system is light.
在文件 qxthememanager.cpp 第 213 行定义.
| Theme QxTheme::QxThemeManager::theme | ( | ) | const |
The theme that is currently applied.
在文件 qxthememanager.cpp 第 174 行定义.
| void QxTheme::QxThemeManager::themeChanged | ( | Theme | theme | ) |
Emitted after a theme has been applied.