Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorServices::IconThemeResolver Class Reference

XDG Icon Theme Specification 0.13 resolver. More...

#include <phosphor-services/include/PhosphorServices/IconThemeResolver.h>

Inheritance diagram for PhosphorServices::IconThemeResolver:
[legend]

Signals

void themeChanged ()
 

Public Member Functions

void setThemeName (const QString &themeName)
 Force a theme override.
 
QString themeName () const
 
QImage iconForName (const QString &name, int size, int scale=1, const QString &extraThemeDir={}) const
 Look up an icon by name.
 

Static Public Member Functions

static IconThemeResolverinstance ()
 Process-wide singleton. Created lazily on first call.
 
static QImage decodePixmaps (const QList< QPair< QSize, QByteArray > > &pixmaps, int size)
 Bypass theme lookup and decode a raw IconPixmap byte stream straight off the wire (ARGB32 in network byte order).
 

Detailed Description

XDG Icon Theme Specification 0.13 resolver.

https://specifications.freedesktop.org/icon-theme-spec/latest/

Singleton because the parsed theme index is expensive to build (walking /usr/share/icons/* parses dozens of index.theme files) and the same theme tree is reused across every tray item. iconForName() returns the best-match QImage by walking the active theme + inherited parents + Hicolor fallback, using the spec's distance algorithm to pick a size when no exact match exists.

Member Function Documentation

◆ decodePixmaps()

static QImage PhosphorServices::IconThemeResolver::decodePixmaps ( const QList< QPair< QSize, QByteArray > > &  pixmaps,
int  size 
)
static

Bypass theme lookup and decode a raw IconPixmap byte stream straight off the wire (ARGB32 in network byte order).

Picks the pixmap closest to size from the list and converts.

◆ iconForName()

QImage PhosphorServices::IconThemeResolver::iconForName ( const QString &  name,
int  size,
int  scale = 1,
const QString &  extraThemeDir = {} 
) const

Look up an icon by name.

extraThemeDir is the SNI item's IconThemePath (if any) — when set, it's prepended to the search path so an app's custom theme wins over the system one. size is the desired logical-pixel size; scale is the device pixel ratio (1 for traditional, 2 for HiDPI). Returns an empty QImage when no match exists.

◆ instance()

static IconThemeResolver * PhosphorServices::IconThemeResolver::instance ( )
static

Process-wide singleton. Created lazily on first call.

◆ setThemeName()

void PhosphorServices::IconThemeResolver::setThemeName ( const QString &  themeName)

Force a theme override.

Empty string => fall back to detection from Qt's icon theme name + GTK env hints.

◆ themeChanged

void PhosphorServices::IconThemeResolver::themeChanged ( )
signal

◆ themeName()

QString PhosphorServices::IconThemeResolver::themeName ( ) const

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