NDEVR
API Documentation
QTIconManager

Manages all Icons and Pixmaps used by the UI in the NDEVR Engine. More...

Collaboration diagram for QTIconManager:
[legend]

Static Public Member Functions

static void AddIconEngine (NDEVRIconEngine *engine)
 Registers an icon rendering engine.
static void addIconTheme (const IconThemeSettings &theme)
 Registers a new icon theme.
static void AddResolver (PixmapResolver *resolver)
 Registers a pixmap resolver for resolving custom pixmap resources.
static QImage AutoCrop (const QImage &pixmap, int margin=0, bool preserve_ratio=false)
 Removes transparent borders from an image, optionally adding a margin.
static QImage CleanupImageForIcon (const QImage &image)
 Cleans up an image to make it suitable for use as an icon.
static void ClearWindowIcon (QWidget *widget)
 Clears the window icon previously set on a widget.
static Buffer< std::pair< LABColor, LABColor > > ConvertColorPalette (const Buffer< std::pair< RGBColor, RGBColor > > &palette)
 Converts an RGB color palette to LAB color space for perceptual color operations.
static void ConvertColorTheme (const Buffer< std::pair< LABColor, LABColor > > &color, QImage &image, bool preserve_brightness, bool preserve_alpha)
 Applies a LAB color theme conversion directly to a QImage.
static void ConvertColorTheme (const Buffer< std::pair< RGBColor, RGBColor > > &colors, const Buffer< File > &in, const File &out_location, bool preserve_brightness, bool preserve_alpha, Log *log=nullptr)
 Converts a set of icon files from one color theme to another.
static void ConvertColorTheme (const Buffer< std::pair< RGBColor, RGBColor > > &colors, const File &in_location, const File &out_location, bool preserve_brightness, bool preserve_alpha, Log *log=nullptr)
 Converts icon files at a given location from one color theme to another.
static const QPixmap & disabledPixmap (const StringView &icon_name)
 Returns a cached disabled (grayed-out) version of the given icon.
static const IconThemeSettingsEffectiveIconTheme ()
 Returns the currently effective icon theme, accounting for any overrides.
static QImage FillBackground (const QImage &pixmap, RGBColor color)
 Fills the transparent background of an image with the specified color.
static void GetIconResource (const std::function< void(const StringView &, const QIcon &)> &on_finished, const StringView &icon, const IconThemeSettings &theme, QIcon::Mode mode=QIcon::Mode::Normal)
 Asynchronously fetches an icon resource using a specific theme, invoking the callback when ready.
static void GetIconResource (const std::function< void(const StringView &, const QIcon &)> &on_finished, const StringView &icon, QIcon::Mode mode=QIcon::Mode::Normal)
 Asynchronously fetches an icon resource using the current theme, invoking the callback when ready.
static QIcon GetIconResourceBlocking (const StringView &icon, const IconThemeSettings &theme, QIcon::Mode mode=QIcon::Mode::Normal)
 Synchronously fetches an icon resource using a specific theme.
static QIcon GetIconResourceBlocking (const StringView &icon, QIcon::Mode mode=QIcon::Mode::Normal)
 Synchronously fetches an icon resource using the current theme.
static void GetPixmapResource (const std::function< void(const StringView &, const QPixmap &)> &on_finished, const StringView &pixmap, QIcon::Mode mode=QIcon::Mode::Normal, const QSize &requested_size=QSize())
 Asynchronously fetches a pixmap resource, invoking the callback when ready.
static String GetSVGPath (const StringView &icon, const IconThemeSettings &theme)
 Returns the file path to an SVG icon resource for the given theme.
static String IconCacheLocation (const StringView &icon, const IconThemeSettings &theme)
 Returns the cache file path for a rendered icon.
static const Buffer< IconThemeSettings > & iconThemes ()
 Returns all registered icon themes.
static String ImageCacheLocation (const StringView &icon)
 Returns the cache file path for a rendered image.
static QPixmap LocalPixmapResource (const StringView &pixmap, QIcon::Mode mode=QIcon::Mode::Normal, const QSize &requested_size=QSize())
 Synchronously resolves a local pixmap resource.
static const IconThemeSettingsNDEVRIconTheme ()
 Returns the default NDEVR icon theme.
static constexpr const char * NDEVRThemeLocation ()
 Returns the file path prefix for the default NDEVR icon theme resources.
static const IconThemeSettingsOutlineIconTheme ()
 Returns the built-in outline icon theme.
static void PostIconResourceLoad (const StringView &id)
 Notifies any pending callbacks that an icon resource has finished loading.
static bool RequestSet (const StringView &pixmap_resource, QPixmap map, QIcon::Mode mode=QIcon::Mode::Normal)
 Stores a pixmap for the given resource identifier in available resolvers.
static void SetLightingTheme (const IconThemeSettings &theme)
 Sets the user's icon theme.
static void SetOverrideTheme (IconThemeSettings *theme)
 Sets a temporary override theme that takes precedence over the user's saved theme.
static void SetWindowIcon (const StringView &s, QWidget *widget)
 Sets the window icon for a widget to the specified icon resource.

Static Public Attributes

static Resource< IconThemeSettingss_icon_theme
 Resource holding the user's selected icon theme.
static Resource< IconThemeSettings * > s_overide_icon_theme
 Resource holding the override icon theme pointer.

Static Protected Member Functions

static File GetImagePath (const StringView &icon)
 Returns the file path for an image resource.
static QIcon icon (const StringView &icon, const IconThemeSettings &theme, QIcon::Mode mode=QIcon::Mode::Normal)
 Resolves an icon using a specific theme.
static QIcon icon (const StringView &icon, QIcon::Mode mode=QIcon::Mode::Normal)
 Resolves an icon using the current theme.
static QPixmap pixmap (const StringView &pixmap, QIcon::Mode mode=QIcon::Mode::Normal, const QSize &requested_size=QSize())
 Resolves a pixmap resource.

Detailed Description

Manages all Icons and Pixmaps used by the UI in the NDEVR Engine.


Icons may be fetched remotely so callbacks are used to specify the action to take when the resource is retrieved.

Definition at line 242 of file QTIconManager.h.

Member Function Documentation

◆ AddIconEngine()

void QTIconManager::AddIconEngine ( NDEVRIconEngine * engine)
static

Registers an icon rendering engine.

Parameters
[in]engineThe engine to add.

◆ addIconTheme()

void QTIconManager::addIconTheme ( const IconThemeSettings & theme)
static

Registers a new icon theme.

Parameters
[in]themeThe icon theme settings to add.

◆ AddResolver()

void QTIconManager::AddResolver ( PixmapResolver * resolver)
static

Registers a pixmap resolver for resolving custom pixmap resources.

Parameters
[in]resolverThe resolver to add.

◆ AutoCrop()

QImage QTIconManager::AutoCrop ( const QImage & pixmap,
int margin = 0,
bool preserve_ratio = false )
static

Removes transparent borders from an image, optionally adding a margin.

Parameters
[in]pixmapThe source image to crop.
[in]marginThe margin in pixels to preserve around the content.
[in]preserve_ratioWhether to preserve the original aspect ratio.
Returns
The cropped QImage.

References pixmap().

◆ CleanupImageForIcon()

QImage QTIconManager::CleanupImageForIcon ( const QImage & image)
static

Cleans up an image to make it suitable for use as an icon.

Parameters
[in]imageThe source image.
Returns
The cleaned-up QImage.

◆ ClearWindowIcon()

void QTIconManager::ClearWindowIcon ( QWidget * widget)
static

Clears the window icon previously set on a widget.

Parameters
[in]widgetThe widget whose window icon to clear.

◆ ConvertColorPalette()

Buffer< std::pair< LABColor, LABColor > > QTIconManager::ConvertColorPalette ( const Buffer< std::pair< RGBColor, RGBColor > > & palette)
static

Converts an RGB color palette to LAB color space for perceptual color operations.

Parameters
[in]paletteThe RGB color pairs to convert.
Returns
The equivalent LAB color pairs.

◆ ConvertColorTheme() [1/3]

void QTIconManager::ConvertColorTheme ( const Buffer< std::pair< LABColor, LABColor > > & color,
QImage & image,
bool preserve_brightness,
bool preserve_alpha )
static

Applies a LAB color theme conversion directly to a QImage.

Parameters
[in]colorThe LAB color mapping pairs.
[in]imageThe image to modify in-place.
[in]preserve_brightnessWhether to preserve the original brightness.
[in]preserve_alphaWhether to preserve the original alpha channel.

◆ ConvertColorTheme() [2/3]

void QTIconManager::ConvertColorTheme ( const Buffer< std::pair< RGBColor, RGBColor > > & colors,
const Buffer< File > & in,
const File & out_location,
bool preserve_brightness,
bool preserve_alpha,
Log * log = nullptr )
static

Converts a set of icon files from one color theme to another.

Parameters
[in]colorsThe RGB color mapping pairs (source to destination).
[in]inThe input files to convert.
[in]out_locationThe output directory for converted files.
[in]preserve_brightnessWhether to preserve the original brightness of pixels.
[in]preserve_alphaWhether to preserve the original alpha channel.
[in]logOptional log for reporting progress or errors.

◆ ConvertColorTheme() [3/3]

void QTIconManager::ConvertColorTheme ( const Buffer< std::pair< RGBColor, RGBColor > > & colors,
const File & in_location,
const File & out_location,
bool preserve_brightness,
bool preserve_alpha,
Log * log = nullptr )
static

Converts icon files at a given location from one color theme to another.

Parameters
[in]colorsThe RGB color mapping pairs (source to destination).
[in]in_locationThe input directory containing files to convert.
[in]out_locationThe output directory for converted files.
[in]preserve_brightnessWhether to preserve the original brightness of pixels.
[in]preserve_alphaWhether to preserve the original alpha channel.
[in]logOptional log for reporting progress or errors.

◆ disabledPixmap()

const QPixmap & QTIconManager::disabledPixmap ( const StringView & icon_name)
static

Returns a cached disabled (grayed-out) version of the given icon.

Parameters
[in]icon_nameThe icon resource identifier.
Returns
A reference to the disabled QPixmap.

◆ EffectiveIconTheme()

const IconThemeSettings & QTIconManager::EffectiveIconTheme ( )
static

Returns the currently effective icon theme, accounting for any overrides.

Returns
A reference to the effective icon theme settings.

◆ FillBackground()

QImage QTIconManager::FillBackground ( const QImage & pixmap,
RGBColor color )
static

Fills the transparent background of an image with the specified color.

Parameters
[in]pixmapThe source image.
[in]colorThe background fill color.
Returns
A new QImage with the filled background.

References pixmap().

◆ GetIconResource() [1/2]

void QTIconManager::GetIconResource ( const std::function< void(const StringView &, const QIcon &)> & on_finished,
const StringView & icon,
const IconThemeSettings & theme,
QIcon::Mode mode = QIcon::Mode::Normal )
static

Asynchronously fetches an icon resource using a specific theme, invoking the callback when ready.

Parameters
[in]on_finishedCallback receiving the icon name and the resolved QIcon.
[in]iconThe icon resource identifier.
[in]themeThe icon theme settings to apply.
[in]modeThe icon mode.

References icon().

◆ GetIconResource() [2/2]

void QTIconManager::GetIconResource ( const std::function< void(const StringView &, const QIcon &)> & on_finished,
const StringView & icon,
QIcon::Mode mode = QIcon::Mode::Normal )
static

Asynchronously fetches an icon resource using the current theme, invoking the callback when ready.

Parameters
[in]on_finishedCallback receiving the icon name and the resolved QIcon.
[in]iconThe icon resource identifier.
[in]modeThe icon mode.

References icon().

◆ GetIconResourceBlocking() [1/2]

QIcon QTIconManager::GetIconResourceBlocking ( const StringView & icon,
const IconThemeSettings & theme,
QIcon::Mode mode = QIcon::Mode::Normal )
static

Synchronously fetches an icon resource using a specific theme.

Parameters
[in]iconThe icon resource identifier.
[in]themeThe icon theme settings to apply.
[in]modeThe icon mode.
Returns
The resolved QIcon.

References icon().

◆ GetIconResourceBlocking() [2/2]

QIcon QTIconManager::GetIconResourceBlocking ( const StringView & icon,
QIcon::Mode mode = QIcon::Mode::Normal )
static

Synchronously fetches an icon resource using the current theme.

Parameters
[in]iconThe icon resource identifier.
[in]modeThe icon mode.
Returns
The resolved QIcon.

References icon().

Referenced by BuildActionProgramLogic::addMenuItems().

◆ GetImagePath()

File QTIconManager::GetImagePath ( const StringView & icon)
staticprotected

Returns the file path for an image resource.

Parameters
[in]iconThe icon resource identifier.
Returns
The file path.

References icon().

◆ GetPixmapResource()

void QTIconManager::GetPixmapResource ( const std::function< void(const StringView &, const QPixmap &)> & on_finished,
const StringView & pixmap,
QIcon::Mode mode = QIcon::Mode::Normal,
const QSize & requested_size = QSize() )
static

Asynchronously fetches a pixmap resource, invoking the callback when ready.

Parameters
[in]on_finishedCallback receiving the pixmap name and the resolved QPixmap.
[in]pixmapThe pixmap resource identifier.
[in]modeThe icon mode.
[in]requested_sizeThe desired pixmap size.

References pixmap().

◆ GetSVGPath()

String QTIconManager::GetSVGPath ( const StringView & icon,
const IconThemeSettings & theme )
static

Returns the file path to an SVG icon resource for the given theme.

Parameters
[in]iconThe icon resource identifier.
[in]themeThe icon theme settings.
Returns
The file path to the SVG.

References icon().

◆ icon() [1/2]

QIcon QTIconManager::icon ( const StringView & icon,
const IconThemeSettings & theme,
QIcon::Mode mode = QIcon::Mode::Normal )
staticprotected

Resolves an icon using a specific theme.

Parameters
[in]iconThe icon resource identifier.
[in]themeThe icon theme settings.
[in]modeThe icon mode.
Returns
The resolved QIcon.

References icon().

◆ icon() [2/2]

QIcon QTIconManager::icon ( const StringView & icon,
QIcon::Mode mode = QIcon::Mode::Normal )
staticprotected

Resolves an icon using the current theme.

Parameters
[in]iconThe icon resource identifier.
[in]modeThe icon mode.
Returns
The resolved QIcon.

References icon().

Referenced by GetIconResource(), GetIconResource(), GetIconResourceBlocking(), GetIconResourceBlocking(), GetImagePath(), GetSVGPath(), icon(), icon(), IconCacheLocation(), and ImageCacheLocation().

◆ IconCacheLocation()

String QTIconManager::IconCacheLocation ( const StringView & icon,
const IconThemeSettings & theme )
static

Returns the cache file path for a rendered icon.

Parameters
[in]iconThe icon resource identifier.
[in]themeThe icon theme settings.
Returns
The cache file path.

References icon().

◆ iconThemes()

const Buffer< IconThemeSettings > & QTIconManager::iconThemes ( )
static

Returns all registered icon themes.

Returns
A reference to the buffer of icon theme settings.

◆ ImageCacheLocation()

String QTIconManager::ImageCacheLocation ( const StringView & icon)
static

Returns the cache file path for a rendered image.

Parameters
[in]iconThe image resource identifier.
Returns
The cache file path.

References icon().

◆ LocalPixmapResource()

QPixmap QTIconManager::LocalPixmapResource ( const StringView & pixmap,
QIcon::Mode mode = QIcon::Mode::Normal,
const QSize & requested_size = QSize() )
static

Synchronously resolves a local pixmap resource.

Parameters
[in]pixmapThe pixmap resource identifier.
[in]modeThe icon mode.
[in]requested_sizeThe desired pixmap size.
Returns
The resolved QPixmap.

References pixmap().

◆ NDEVRIconTheme()

const IconThemeSettings & QTIconManager::NDEVRIconTheme ( )
static

Returns the default NDEVR icon theme.

Returns
A reference to the NDEVR theme settings.

◆ NDEVRThemeLocation()

constexpr const char * QTIconManager::NDEVRThemeLocation ( )
inlinestaticconstexpr

Returns the file path prefix for the default NDEVR icon theme resources.

Returns
A string literal path.

Definition at line 419 of file QTIconManager.h.

◆ OutlineIconTheme()

const IconThemeSettings & QTIconManager::OutlineIconTheme ( )
static

Returns the built-in outline icon theme.

Returns
A reference to the outline theme settings.

◆ pixmap()

QPixmap QTIconManager::pixmap ( const StringView & pixmap,
QIcon::Mode mode = QIcon::Mode::Normal,
const QSize & requested_size = QSize() )
staticprotected

Resolves a pixmap resource.

Parameters
[in]pixmapThe pixmap resource identifier.
[in]modeThe icon mode.
[in]requested_sizeThe desired pixmap size.
Returns
The resolved QPixmap.

References pixmap().

Referenced by AutoCrop(), FillBackground(), GetPixmapResource(), LocalPixmapResource(), and pixmap().

◆ PostIconResourceLoad()

void QTIconManager::PostIconResourceLoad ( const StringView & id)
static

Notifies any pending callbacks that an icon resource has finished loading.

Parameters
[in]idThe resource identifier that was loaded.

◆ RequestSet()

bool QTIconManager::RequestSet ( const StringView & pixmap_resource,
QPixmap map,
QIcon::Mode mode = QIcon::Mode::Normal )
static

Stores a pixmap for the given resource identifier in available resolvers.

Parameters
[in]pixmap_resourceThe resource identifier.
[in]mapThe pixmap to store.
[in]modeThe icon mode.
Returns
True if the pixmap was successfully stored.

◆ SetLightingTheme()

void QTIconManager::SetLightingTheme ( const IconThemeSettings & theme)
static

Sets the user's icon theme.

The selection is persisted to INI files for the next session.

Parameters
[in]themeThe icon theme settings to apply.

◆ SetOverrideTheme()

void QTIconManager::SetOverrideTheme ( IconThemeSettings * theme)
static

Sets a temporary override theme that takes precedence over the user's saved theme.

Parameters
[in]themePointer to the override theme settings, or nullptr to clear.

◆ SetWindowIcon()

void QTIconManager::SetWindowIcon ( const StringView & s,
QWidget * widget )
static

Sets the window icon for a widget to the specified icon resource.

Parameters
[in]sThe icon resource identifier.
[in]widgetThe widget whose window icon to set.

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