|
Wireshark 4.7.0
The Wireshark network protocol analyzer
|
#include <theme_palette_builder.h>
Public Types | |
| using | TokenMap = QHash< ThemeManager::ThemeToken, ThemeColorPair > |
Static Public Member Functions | |
| static QPalette | build (const TokenMap &tokens, bool isDarkMode, const QHash< QString, ThemeManager::ThemeToken > &tokenNameCache, const QHash< QString, QPalette::ColorRole > &paletteRoleCache, const QPalette &osBaseline) |
| static void | apply (const TokenMap &tokens, bool isDarkMode, const QHash< QString, ThemeManager::ThemeToken > &tokenNameCache, const QHash< QString, QPalette::ColorRole > &paletteRoleCache, const QPalette &osBaseline) |
| static QPalette | builtInDarkPalette () |
| static QPalette | builtInLightPalette () |
Builds the QApplication::palette() from the current theme's token map and mode, and pushes it via QApplication::setPalette().
The baseline palette comes from:
osBaseline snapshot. ThemeManager captures this from the platform style at construction time (when the palette is pristine) and refreshes it whenever the effective scheme flips. Reading QApplication::palette() here would be wrong: once the builder has pushed any palette via setPalette(), subsequent reads return that customized palette — so consecutive theme switches would accumulate overrides instead of restarting from a clean OS baseline.builtInLightPalette() / builtInDarkPalette()). The Linux platform themes (gnome/gtk3/qt6ct) silently ignore QStyleHints::setColorScheme() and pin both the hint and standardPalette() to the OS value, which makes "Dark mode on a Light OS" (or vice versa) impossible to honor without supplying our own palette. Old Fusion has the same problem. osBaseline is ignored on these platforms.Theme-provided palette overrides (the palette: section of theme.jsonc) are applied on top of the baseline. Brand-driven roles (Highlight, Link, Accent, HighlightedText) are always overlaid last, so themes don't need to set them.
|
static |
Convenience wrapper: calls build() and pushes the result via QApplication::setPalette().
|
static |
Build and return the full QPalette from the token map without pushing it to QApplication. Callers that need the palette value before it is applied (e.g. to derive tokens first) should call this and then push the result themselves via QApplication::setPalette().
| tokens | Populated theme token map (brand, accent, optional palette overrides). |
| isDarkMode | Which side of color pairs to use. |
| tokenNameCache | Map "palettewindow" → ThemeToken::PaletteWindow (etc.), shared with the parser/QSS loader. |
| paletteRoleCache | Map "palettewindow" → QPalette::Window (etc.) — Qt's 21 palette-role keys by lowercased enumerator name. |
| osBaseline | Pristine OS palette snapshot supplied by ThemeManager; used as the baseline on macOS and Windows Qt ≥ 6.8. Ignored on Linux and Windows Qt < 6.8. |
|
static |
Built-in dark QPalette used as the baseline on non-macOS platforms when the current mode is dark. Based on https://gist.github.com/QuantumCD/6245215 with Disabled-group coverage added.
|
static |
Built-in light QPalette used as the baseline on non-macOS platforms when the current mode is light. Mirrors Qt Fusion's default light palette so the visual identity stays familiar when our override replaces the system's.