Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
ThemePaletteBuilder Class Reference

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

Detailed Description

Builds the QApplication::palette() from the current theme's token map and mode, and pushes it via QApplication::setPalette().

The baseline palette comes from:

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.

Member Function Documentation

◆ apply()

void ThemePaletteBuilder::apply ( const TokenMap &  tokens,
bool  isDarkMode,
const QHash< QString, ThemeManager::ThemeToken > &  tokenNameCache,
const QHash< QString, QPalette::ColorRole > &  paletteRoleCache,
const QPalette &  osBaseline 
)
static

Convenience wrapper: calls build() and pushes the result via QApplication::setPalette().

◆ build()

QPalette ThemePaletteBuilder::build ( const TokenMap &  tokens,
bool  isDarkMode,
const QHash< QString, ThemeManager::ThemeToken > &  tokenNameCache,
const QHash< QString, QPalette::ColorRole > &  paletteRoleCache,
const QPalette &  osBaseline 
)
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().

Parameters
tokensPopulated theme token map (brand, accent, optional palette overrides).
isDarkModeWhich side of color pairs to use.
tokenNameCacheMap "palettewindow" → ThemeToken::PaletteWindow (etc.), shared with the parser/QSS loader.
paletteRoleCacheMap "palettewindow" → QPalette::Window (etc.) — Qt's 21 palette-role keys by lowercased enumerator name.
osBaselinePristine 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.

◆ builtInDarkPalette()

QPalette ThemePaletteBuilder::builtInDarkPalette ( )
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.

◆ builtInLightPalette()

QPalette ThemePaletteBuilder::builtInLightPalette ( )
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.


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