LibreOffice Module vcl (master) 1
Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
vcl::IconThemeSelector Class Reference

This class helps to choose an icon theme from a list of installed themes. More...

#include <IconThemeSelector.hxx>

Public Member Functions

 IconThemeSelector ()
 
OUString SelectIconTheme (const std::vector< IconThemeInfo > &installedThemes, const OUString &theme) const
 Select an icon theme from the list of installed themes. More...
 
OUString SelectIconThemeForDesktopEnvironment (const std::vector< IconThemeInfo > &installedThemes, const OUString &desktopEnvironment) const
 Select the standard icon theme for a desktop environment from a list of installed themes. More...
 
void SetUseHighContrastTheme (bool)
 
bool SetPreferredIconTheme (const OUString &, bool bDarkIconTheme)
 Returns true if the PreferredIconTheme was changed. More...
 
bool operator== (const vcl::IconThemeSelector &) const
 
bool operator!= (const vcl::IconThemeSelector &) const
 

Static Private Member Functions

static OUString ReturnFallback (const std::vector< IconThemeInfo > &installedThemes)
 Return the first element of the themes, or the fallback if the vector is empty. More...
 
static OUString GetIconThemeForDesktopEnvironment (const OUString &desktopEnvironment, bool bPreferDarkIconTheme)
 

Private Attributes

OUString mPreferredIconTheme
 
bool mUseHighContrastTheme
 
bool mPreferDarkIconTheme
 

Static Private Attributes

static constexpr OUStringLiteral FALLBACK_LIGHT_ICON_THEME_ID = u"colibre"
 The name of the icon themes which are used as fallbacks. More...
 
static constexpr OUStringLiteral FALLBACK_DARK_ICON_THEME_ID = u"colibre_dark"
 

Friends

class ::IconThemeSelectorTest
 

Detailed Description

This class helps to choose an icon theme from a list of installed themes.

The following factors influence the selection:

  1. When high contrast mode is enabled, the high contrast icon theme is selected (if it is installed).
  2. When a preferred theme has been set (e.g., in the gnome desktop settings), that theme is selected.

Definition at line 31 of file IconThemeSelector.hxx.

Constructor & Destructor Documentation

◆ IconThemeSelector()

vcl::IconThemeSelector::IconThemeSelector ( )

Definition at line 47 of file IconThemeSelector.cxx.

Member Function Documentation

◆ GetIconThemeForDesktopEnvironment()

OUString vcl::IconThemeSelector::GetIconThemeForDesktopEnvironment ( const OUString &  desktopEnvironment,
bool  bPreferDarkIconTheme 
)
staticprivate

◆ operator!=()

bool vcl::IconThemeSelector::operator!= ( const vcl::IconThemeSelector other) const

Definition at line 185 of file IconThemeSelector.cxx.

◆ operator==()

bool vcl::IconThemeSelector::operator== ( const vcl::IconThemeSelector other) const

◆ ReturnFallback()

OUString vcl::IconThemeSelector::ReturnFallback ( const std::vector< IconThemeInfo > &  installedThemes)
staticprivate

Return the first element of the themes, or the fallback if the vector is empty.

Definition at line 191 of file IconThemeSelector.cxx.

References FALLBACK_LIGHT_ICON_THEME_ID.

Referenced by SelectIconTheme(), and SelectIconThemeForDesktopEnvironment().

◆ SelectIconTheme()

OUString vcl::IconThemeSelector::SelectIconTheme ( const std::vector< IconThemeInfo > &  installedThemes,
const OUString &  theme 
) const

Select an icon theme from the list of installed themes.

If high contrast mode has been enabled, the highcontrast theme will be selected (if it is available).

Precondition
installedThemes must not be empty

Definition at line 124 of file IconThemeSelector.cxx.

References Application::GetSettings(), vcl::IconThemeInfo::HIGH_CONTRAST_ID_BRIGHT, vcl::IconThemeInfo::HIGH_CONTRAST_ID_DARK, Color::IsDark(), mUseHighContrastTheme, name, and ReturnFallback().

◆ SelectIconThemeForDesktopEnvironment()

OUString vcl::IconThemeSelector::SelectIconThemeForDesktopEnvironment ( const std::vector< IconThemeInfo > &  installedThemes,
const OUString &  desktopEnvironment 
) const

Select the standard icon theme for a desktop environment from a list of installed themes.

If a preferred theme has been set, this one will take precedence.

The same logic as in SelectIconTheme() will apply.

Precondition
installedThemes must not be empty

Definition at line 105 of file IconThemeSelector.cxx.

References GetIconThemeForDesktopEnvironment(), mPreferDarkIconTheme, mPreferredIconTheme, and ReturnFallback().

◆ SetPreferredIconTheme()

bool vcl::IconThemeSelector::SetPreferredIconTheme ( const OUString &  theme,
bool  bDarkIconTheme 
)

Returns true if the PreferredIconTheme was changed.

Definition at line 151 of file IconThemeSelector.cxx.

References mPreferDarkIconTheme, and mPreferredIconTheme.

◆ SetUseHighContrastTheme()

void vcl::IconThemeSelector::SetUseHighContrastTheme ( bool  v)

Definition at line 145 of file IconThemeSelector.cxx.

References mUseHighContrastTheme, and v.

Friends And Related Function Documentation

◆ ::IconThemeSelectorTest

friend class ::IconThemeSelectorTest
friend

Definition at line 91 of file IconThemeSelector.hxx.

Member Data Documentation

◆ FALLBACK_DARK_ICON_THEME_ID

constexpr OUStringLiteral vcl::IconThemeSelector::FALLBACK_DARK_ICON_THEME_ID = u"colibre_dark"
staticconstexprprivate

Definition at line 82 of file IconThemeSelector.hxx.

Referenced by GetIconThemeForDesktopEnvironment().

◆ FALLBACK_LIGHT_ICON_THEME_ID

constexpr OUStringLiteral vcl::IconThemeSelector::FALLBACK_LIGHT_ICON_THEME_ID = u"colibre"
staticconstexprprivate

The name of the icon themes which are used as fallbacks.

Definition at line 81 of file IconThemeSelector.hxx.

Referenced by GetIconThemeForDesktopEnvironment(), and ReturnFallback().

◆ mPreferDarkIconTheme

bool vcl::IconThemeSelector::mPreferDarkIconTheme
private

◆ mPreferredIconTheme

OUString vcl::IconThemeSelector::mPreferredIconTheme
private

◆ mUseHighContrastTheme

bool vcl::IconThemeSelector::mUseHighContrastTheme
private

Definition at line 88 of file IconThemeSelector.hxx.

Referenced by operator==(), SelectIconTheme(), and SetUseHighContrastTheme().


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