|
Wireshark 5.1.0
The Wireshark network protocol analyzer
|
#include <theme_stylesheet_loader.h>
Public Types | |
| using | TokenMap = QHash<ThemeManager::ThemeToken, ThemeColorPair> |
Static Public Member Functions | |
| static QString | load (const QString &name, const TokenMap &tokens, bool isDarkMode) |
| static QString | resolvePaletteRoles (const QString &sheet, const QPalette &palette) |
Loads a QSS stylesheet from the built-in :/stylesheets/ resource tree and resolves every wstheme(RoleName) token by looking up RoleName in the current theme's color map.
Split out of ThemeManager so the loader logic — stylesheet path sanitization, QSS read, token regex, role-enum lookup — lives alongside the other theme helpers under ui/qt/utils/themes/.
Stateless: every call reads fresh resource contents and resolves tokens against the token map the caller provides. ThemeManager is the usual caller and passes its own themeColors_ / isDarkMode().
|
static |
Load :/stylesheets/<name>.qss and return its contents with every wstheme(RoleName) token replaced by the resolved #rrggbb hex of the corresponding ThemeToken, picked from tokens using isDarkMode to choose the light/dark side.
Returns an empty QString on any of:
Tokens that don't resolve (unknown role name or missing color in the map) are stripped from the output and a qWarning is emitted — Qt's QSS parser is all-or-nothing per object, so leaving a literal wstheme(Foo) in place would silently drop the entire rule on the first typo; stripping keeps the rest of the rules valid and the warning surfaces the typo.
| name | Logical name under :/stylesheets/, without extension (e.g. "widgets/learn-card"). |
| tokens | Current theme's color map. |
| isDarkMode | Which side of color pairs to select. |
|
static |
Replaces every palette(<role>) in sheet with palette's Active color for that role. Qt resolves palette() in style sheets against the application palette, not the widget's, so a sheet previewing another palette resolves the references itself. Role names are the ones Qt's style sheet grammar accepts, derived from QPalette::ColorRole. A name that matches no role is left as written (Qt ignores it on the live page too) and logged with qWarning once per name.
| sheet | Style sheet text. |
| palette | Palette whose Active colors are substituted. |