XDGKit v0.1.0-1
XDG Utilities for C++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
XDGIconThemeManager Class Reference

Utility for finding icons. More...

#include <XDGIconThemeManager.h>

Public Member Functions

XDGKitkit () const noexcept
 Handle to the parent kit.
 
const std::vector< std::filesystem::path > & searchDirs () const noexcept
 Retrieves the directories to search for icon themes, in order of precedence.
 
const std::map< std::string, std::shared_ptr< XDGIconTheme > > & themes () const noexcept
 Retrieves all discovered icon themes.
 
const XDGIconfindIcon (const std::string &icon, int32_t size, int32_t scale=1, uint32_t extensions=XDGIcon::PNG|XDGIcon::SVG, const std::vector< std::string > &themes={ "" }, uint32_t contexts=XDGIconDirectory::AnyContext) const noexcept
 Searches for an icon within the specified themes.
 

Detailed Description

Utility for finding icons.

Member Function Documentation

◆ kit()

XDGKit & kit ( ) const
inlinenoexcept

Handle to the parent kit.

◆ searchDirs()

const std::vector< std::filesystem::path > & searchDirs ( ) const
inlinenoexcept

Retrieves the directories to search for icon themes, in order of precedence.

The default search directories in order are:

  • $HOME/.icons
  • $HOME/.local/share/icons
  • $XDG_DATA_DIRS/icons
  • /usr/share/pixmaps
Returns
A constant reference to a vector containing the search directories.

◆ themes()

const std::map< std::string, std::shared_ptr< XDGIconTheme > > & themes ( ) const
inlinenoexcept

Retrieves all discovered icon themes.

Returns
A constant reference to an unordered map where the key is the theme's directory basename, and the value is the corresponding XDGIconTheme object.

◆ findIcon()

const XDGIcon * findIcon ( const std::string &  icon,
int32_t  size,
int32_t  scale = 1,
uint32_t  extensions = XDGIcon::PNG | XDGIcon::SVG,
const std::vector< std::string > &  themes = { "" },
uint32_t  contexts = XDGIconDirectory::AnyContext 
) const
noexcept

Searches for an icon within the specified themes.

This function attempts to locate an icon that matches the provided criteria (name, size, scale, and extensions) within the given list of themes.

Parameters
iconThe name of the icon to search for.
sizeThe desired nominal size of the icon.
scaleThe scale factor of the icon. Defaults to 1.
extensionsFlags indicating the acceptable image file extensions.
themesA list of theme names to search, in the specified order. An empty string ("") serves as a placeholder to search in all themes available.
contextsFlags to limit the search to the given XDGIconDirectory::Context (s).
Returns
A pointer to the closest matching icon, or nullptr if no match is found.