Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ThemedIcon Class Reference

A QIcon that renders an SVG silhouette recoloured to a ThemeManager token, tracking light/dark and theme changes automatically. More...

#include <themed_icon.h>

Inheritance diagram for ThemedIcon:

Public Member Functions

 ThemedIcon (const QString &svg_resource_path, ThemeManager::ThemeToken token, QSize size=QSize(14, 14))
 ThemedIcon (const char *name)
 Convenience constructor for creating a themed icon from a stock name.
 ThemedIcon (const QString &name)
 Convenience constructor for creating a themed icon from a stock name.
 ThemedIcon (const QString &svg_resource_path, ThemeManager::ThemeToken token, ThemeManager::ThemeToken active_token, ThemeManager::ThemeToken selected_token=ThemeManager::NoRole, QSize size=QSize(14, 14))
 Stateful variant: distinct colours per interaction mode.
void setPalette (const QPalette &palette)
 Set a custom palette for drawing this icon instead of the application palette.

Detailed Description

A QIcon that renders an SVG silhouette recoloured to a ThemeManager token, tracking light/dark and theme changes automatically.

Companion to StockIcon. StockIcon selects a pre-made, per-mode raster resource; ThemedIcon renders one SVG and tints it to a live theme colour, so a single asset follows the active theme without per-mode variants. The tint uses CompositionMode_SourceIn, which flattens the rendered shape to the resolved colour — the source SVG's own colours (even gradients) don't matter, only its alpha silhouette.

It is part of the theme system and deliberately speaks ThemeManager tokens only: there are no QColor or QPalette overloads. Use a palette token (e.g. ThemeManager::PaletteText) for monochrome glyphs that should follow the text colour, or an accent token (e.g. ThemeManager::AccentSuccess) for a functional colour.

Theme tracking needs no caller code: the backing engine resolves the token colour at paint time and keys its pixmap cache on that colour, so a theme or light/dark flip is a natural cache miss and re-renders on the next repaint.

Constructor & Destructor Documentation

◆ ThemedIcon() [1/4]

ThemedIcon::ThemedIcon ( const QString & svg_resource_path,
ThemeManager::ThemeToken token,
QSize size = QSize(14, 14) )
explicit
Parameters
svg_resource_pathQt resource path of the SVG, e.g. ":/svg_icons/filter-clear.svg".
tokenTheme colour token the glyph is tinted to.
sizeNominal render size used when a caller requests a null size.

◆ ThemedIcon() [2/4]

ThemedIcon::ThemedIcon ( const char * name)
inlineexplicit

Convenience constructor for creating a themed icon from a stock name.

Parameters
nameThe base name of the SVG icon resource without a path or .svg extension.

◆ ThemedIcon() [3/4]

ThemedIcon::ThemedIcon ( const QString & name)
inlineexplicit

Convenience constructor for creating a themed icon from a stock name.

Parameters
nameThe base name of the SVG icon resource without a path or .svg extension.

◆ ThemedIcon() [4/4]

ThemedIcon::ThemedIcon ( const QString & svg_resource_path,
ThemeManager::ThemeToken token,
ThemeManager::ThemeToken active_token,
ThemeManager::ThemeToken selected_token = ThemeManager::NoRole,
QSize size = QSize(14, 14) )
explicit

Stateful variant: distinct colours per interaction mode.

token colours the resting glyph (QIcon::Normal); active_token the hovered glyph (QIcon::Active); selected_token the pressed/selected glyph (QIcon::Selected, falling back to active_token). A QToolButton requests these modes itself on hover/press, so state recolouring needs no QSS — which matters because QSS cannot recolour an SVG glyph's fill. Pass NoRole for a mode to keep the single-token behaviour (a slight emphasis of token).

Member Function Documentation

◆ setPalette()

void ThemedIcon::setPalette ( const QPalette & palette)

Set a custom palette for drawing this icon instead of the application palette.

Affects every copy of this icon. By default the application palette is used.


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