| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
ThemeStyleSheetLoader Class Reference

`#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)

## Detailed Description

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().

## Member Function Documentation

## ◆ load()

QString ThemeStyleSheetLoader::load | ( | const QString & | name,
|  | const TokenMap & | tokens,
|  | bool | 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;
- every literal wsmode% occurrence replaced by the string "dark" or "light" — intended for picking mode-specific asset filenames inside image: url(...) rules, e.g. image: url(:/stock_icons/14x14/x-filter-dropdown.wsmode%.png); The wsmode% placeholder takes no arguments and is a plain text substitution; it runs before the wstheme(...) regex pass.

Returns an empty QString on any of:

- name is empty or contains illegal characters / path traversal attempts (.., leading /, leading ., backslash, etc.)
- The resource file cannot be opened.

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.

Parameters

  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.

The documentation for this class was generated from the following files:

- /builds/wireshark/wireshark/ui/qt/utils/themes/theme_stylesheet_loader.h
- /builds/wireshark/wireshark/ui/qt/utils/themes/theme_stylesheet_loader.cpp