KIconTheme

Search for usage in LXR

#include <kicontheme.h>

Public Member Functions

 KIconTheme (const KIconTheme &)=delete
 
 KIconTheme (const QString &name, const QString &appName=QString(), const QString &basePathHint=QString())
 
int defaultSize (KIconLoader::Group group) const
 
int depth () const
 
QString description () const
 
QString dir () const
 
QString example () const
 
bool followsColorScheme () const
 
bool hasContext (KIconLoader::Context context) const
 
QString iconPath (const QString &name, int size, KIconLoader::MatchType match) const
 
QString iconPath (const QString &name, int size, KIconLoader::MatchType match, qreal scale) const
 
QString iconPathByName (const QString &name, int size, KIconLoader::MatchType match) const
 
QString iconPathByName (const QString &name, int size, KIconLoader::MatchType match, qreal scale) const
 
QStringList inherits () const
 
QString internalName () const
 
bool isHidden () const
 
bool isValid () const
 
QString name () const
 
KIconThemeoperator= (const KIconTheme &)=delete
 
QStringList queryIcons (int size, KIconLoader::Context context=KIconLoader::Any) const
 
QStringList queryIconsByContext (int size, KIconLoader::Context context=KIconLoader::Any) const
 
QList< int > querySizes (KIconLoader::Group group) const
 
QString screenshot () const
 

Static Public Member Functions

static QString current ()
 
static QString defaultThemeName ()
 
static void forceThemeForTests (const QString &themeName)
 
static void initTheme ()
 
static QStringList list ()
 
static void reconfigure ()
 

Detailed Description

Class to use/access icon themes in KDE. This class is used by the iconloader but can be used by others too.

Warning
You should not use this class externally. This class is exported because the KCM needs it.
See also
KIconLoader

Definition at line 33 of file kicontheme.h.

Constructor & Destructor Documentation

◆ KIconTheme()

KIconTheme::KIconTheme ( const QString & name,
const QString & appName = QString(),
const QString & basePathHint = QString() )
explicit

Load an icon theme by name.

Parameters
namethe name of the theme (e.g. "hicolor" or "keramik")
appNamethe name of the application. Can be null. This argument allows applications to have themed application icons.
basePathHintoptional hint where to search the app themes. This is appended at the end of the search paths

Definition at line 335 of file kicontheme.cpp.

◆ ~KIconTheme()

KIconTheme::~KIconTheme ( )

Definition at line 468 of file kicontheme.cpp.

Member Function Documentation

◆ current()

QString KIconTheme::current ( )
static

Returns the current icon theme.

Returns
the name of the current theme

Definition at line 646 of file kicontheme.cpp.

◆ defaultSize()

int KIconTheme::defaultSize ( KIconLoader::Group group) const

The default size of this theme for a certain icon group.

Parameters
groupThe icon group. See KIconLoader::Group.
Returns
The default size in pixels for the given icon group.

Definition at line 524 of file kicontheme.cpp.

◆ defaultThemeName()

QString KIconTheme::defaultThemeName ( )
static

Returns the default icon theme.

Returns
the name of the default theme name

Definition at line 738 of file kicontheme.cpp.

◆ depth()

int KIconTheme::depth ( ) const

The minimum display depth required for this theme.

This can either be 8 or 32.

Returns
the minimum bpp (8 or 32)

Definition at line 519 of file kicontheme.cpp.

◆ description()

QString KIconTheme::description ( ) const

A description for the icon theme.

Returns
a human-readable description of the theme, QString() if there is none

Definition at line 484 of file kicontheme.cpp.

◆ dir()

QString KIconTheme::dir ( ) const

Returns the toplevel theme directory.

Returns
the directory of the theme

Definition at line 499 of file kicontheme.cpp.

◆ example()

QString KIconTheme::example ( ) const

Return the name of the "example" icon.

This can be used to present the theme to the user.

Returns
the name of the example icon, QString() if there is none

Definition at line 489 of file kicontheme.cpp.

◆ followsColorScheme()

bool KIconTheme::followsColorScheme ( ) const

If true, this theme is made of SVG icons that will be colorized following the system color scheme.

This is necessary for monochrome themes that should look visible on both light and dark color schemes.

Returns
true if the SVG will be colorized with a stylesheet.
Since
5.22

Definition at line 623 of file kicontheme.cpp.

◆ forceThemeForTests()

void KIconTheme::forceThemeForTests ( const QString & themeName)
static

Force a current theme and disable automatic resolution of the current theme in favor of the forced theme.

To reset a forced theme, simply set an empty themeName.

Parameters
themeNamename of the theme to force as current theme, or an empty string to unset theme forcing.
Note
This should only be used when a very precise expectation about the current theme is present. Most notably in unit tests this can be used to force a given theme.
Warning
A forced theme persists across reconfigure() calls!
See also
current
Since
5.23

Definition at line 678 of file kicontheme.cpp.

◆ hasContext()

bool KIconTheme::hasContext ( KIconLoader::Context context) const

Returns true if the theme has any icons for the given context.

Definition at line 596 of file kicontheme.cpp.

◆ iconPath() [1/2]

QString KIconTheme::iconPath ( const QString & name,
int size,
KIconLoader::MatchType match ) const

Lookup an icon in the theme.

Parameters
nameThe name of the icon, with extension.
sizeThe desired size of the icon.
matchThe matching mode. KIconLoader::MatchExact returns an icon only if matches exactly. KIconLoader::MatchBest returns the best matching icon.
Returns
An absolute path to the file of the icon if it's found, QString() otherwise.
See also
KIconLoader::isValid will return true, and false otherwise.

Definition at line 628 of file kicontheme.cpp.

◆ iconPath() [2/2]

QString KIconTheme::iconPath ( const QString & name,
int size,
KIconLoader::MatchType match,
qreal scale ) const

Lookup an icon in the theme.

Parameters
nameThe name of the icon, with extension.
sizeThe desired size of the icon.
matchThe matching mode. KIconLoader::MatchExact returns an icon only if matches exactly. KIconLoader::MatchBest returns the best matching icon.
scaleThe scale of the icon group.
Returns
An absolute path to the file of the icon if it's found, QString() otherwise.
See also
KIconLoader::isValid will return true, and false otherwise.
Since
5.48

Definition at line 633 of file kicontheme.cpp.

◆ iconPathByName() [1/2]

QString KIconTheme::iconPathByName ( const QString & name,
int size,
KIconLoader::MatchType match ) const

Lookup an icon in the theme.

Parameters
nameThe name of the icon, without extension.
sizeThe desired size of the icon.
matchThe matching mode. KIconLoader::MatchExact returns an icon only if matches exactly. KIconLoader::MatchBest returns the best matching icon.
Returns
An absolute path to the file of the icon if it's found, QString() otherwise.
See also
KIconLoader::isValid will return true, and false otherwise.
Since
5.22

Definition at line 607 of file kicontheme.cpp.

◆ iconPathByName() [2/2]

QString KIconTheme::iconPathByName ( const QString & name,
int size,
KIconLoader::MatchType match,
qreal scale ) const

Lookup an icon in the theme.

Parameters
nameThe name of the icon, without extension.
sizeThe desired size of the icon.
matchThe matching mode. KIconLoader::MatchExact returns an icon only if matches exactly. KIconLoader::MatchBest returns the best matching icon.
scaleThe scale of the icon group.
Returns
An absolute path to the file of the icon if it's found, QString() otherwise.
See also
KIconLoader::isValid will return true, and false otherwise.
Since
5.48

Definition at line 612 of file kicontheme.cpp.

◆ inherits()

QStringList KIconTheme::inherits ( ) const

The themes this icon theme falls back on.

Returns
a list of icon themes that are used as fall-backs

Definition at line 504 of file kicontheme.cpp.

◆ initTheme()

void KIconTheme::initTheme ( )
static

Enforces the Breeze icon theme (including our KIconEngine for re-coloring).

If the user has configured a different icon set, that one will be taken.

(following the settings in the application configuration with fallback to kdeglobals)

Must be called before the construction of the first Q(Core)Application, as it might need to modify plugin loading and installs a startup function.

If the application is already using the KDE platform theme, the icon set will not be touched and the platform theme will ensure proper theming.

Does setup the needed KColorSchemeManager to follow the system color mode starting with version 6.6.

Since
6.3

Definition at line 56 of file kicontheme.cpp.

◆ internalName()

QString KIconTheme::internalName ( ) const

The internal name of the icon theme (same as the name argument passed to the constructor).

Returns
the internal name of the theme

Definition at line 479 of file kicontheme.cpp.

◆ isHidden()

bool KIconTheme::isHidden ( ) const

The icon theme should be hidden to the user?

Returns
true if the icon theme is hidden

Definition at line 514 of file kicontheme.cpp.

◆ isValid()

bool KIconTheme::isValid ( ) const

The icon theme exists?

Returns
true if the icon theme is valid

Definition at line 509 of file kicontheme.cpp.

◆ list()

QStringList KIconTheme::list ( )
static

List all icon themes installed on the system, global and local.

Returns
the list of all icon themes

Definition at line 685 of file kicontheme.cpp.

◆ name()

QString KIconTheme::name ( ) const

The stylized name of the icon theme.

Returns
the (human-readable) name of the theme

Definition at line 474 of file kicontheme.cpp.

◆ queryIcons()

QStringList KIconTheme::queryIcons ( int size,
KIconLoader::Context context = KIconLoader::Any ) const

Query available icons for a size and context.

Parameters
sizethe size of the icons
contextthe context of the icons
Returns
the list of icon names

Definition at line 547 of file kicontheme.cpp.

◆ queryIconsByContext()

QStringList KIconTheme::queryIconsByContext ( int size,
KIconLoader::Context context = KIconLoader::Any ) const

Query available icons for a context and preferred size.

Parameters
sizethe size of the icons
contextthe context of the icons
Returns
the list of icon names

Definition at line 568 of file kicontheme.cpp.

◆ querySizes()

QList< int > KIconTheme::querySizes ( KIconLoader::Group group) const

Query available sizes for a group.

Parameters
groupThe icon group. See KIconLoader::Group.
Returns
a list of available sizes for the given group

Definition at line 533 of file kicontheme.cpp.

◆ reconfigure()

void KIconTheme::reconfigure ( )
static

Reconfigure the theme.

Definition at line 731 of file kicontheme.cpp.

◆ screenshot()

QString KIconTheme::screenshot ( ) const

Return the name of the screenshot.

Returns
the name of the screenshot, QString() if there is none

Definition at line 494 of file kicontheme.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.