Plasma::Theme Class

Interface to the Plasma theme. More...

Header: #include <Plasma/Theme>
CMake: find_package(Plasma REQUIRED)
target_link_libraries(mytarget PRIVATE Plasma::Plasma)
Inherits: QObject

Public Types

enum ColorRole { TextColor, BackgroundColor, HighlightColor, HoverColor, FocusColor, …, DisabledTextColor }

Properties

Public Functions

Theme(QObject *parent = nullptr)
Theme(const QString &themeName, QObject *parent = nullptr)
bool adaptiveTransparencyEnabled() const
qreal backgroundContrast() const
bool backgroundContrastEnabled() const
qreal backgroundIntensity() const
QString backgroundPath(const QString &image) const
qreal backgroundSaturation() const
bool blurBehindEnabled() const
QColor color(Plasma::Theme::ColorRole role, Kirigami::Platform::PlatformTheme::ColorSet group = Kirigami::Platform::PlatformTheme::ColorSet::Window) const
KSharedConfigPtr colorScheme() const
bool currentThemeHasImage(const QString &name) const
(since 6.6) QString defaultWallpaperTheme() const
QString imagePath(const QString &name) const
KPluginMetaData metadata() const
QPalette palette() const
void setThemeName(const QString &themeName)
void setUseGlobalSettings(bool useGlobal)
QString themeName() const
bool useGlobalSettings() const

Static Public Members

KSharedConfigPtr globalColorScheme()
QPalette globalPalette()

Detailed Description

Plasma::Theme provides access to a common and standardized set of graphic elements stored in SVG format. This allows artists to create single packages of SVGs that will affect the look and feel of all workspace components.

Plasma::Theme can also be used directly to retrieve file system paths to SVGs by name.

Member Type Documentation

enum Theme::ColorRole

ConstantValueDescription
Plasma::Theme::TextColor0The text color to be used by items resting on the background
Plasma::Theme::BackgroundColor1The default background color
Plasma::Theme::HighlightColor2The text highlight color to be used by items resting on the background
Plasma::Theme::HoverColor3Color for hover effect on view
Plasma::Theme::FocusColor4Color for focus effect on view
Plasma::Theme::LinkColor5Color for clickable links
Plasma::Theme::VisitedLinkColor6Color visited clickable links
Plasma::Theme::HighlightedTextColor7Color contrasting with HighlightColor, to be used for instance with
Plasma::Theme::PositiveTextColor8Color of foreground objects with a "positive message" connotation (usually green)
Plasma::Theme::NeutralTextColor9Color of foreground objects with a "neutral message" connotation (usually yellow)
Plasma::Theme::NegativeTextColor10Color of foreground objects with a "negative message" connotation (usually red)
Plasma::Theme::DisabledTextColor (since 5.64)11color of disabled text

Property Documentation

[read-only] backgroundContrast : const qreal

Access functions:

qreal backgroundContrast() const

[read-only] backgroundIntensity : const qreal

Access functions:

qreal backgroundIntensity() const

[read-only] backgroundSaturation : const qreal

Access functions:

qreal backgroundSaturation() const

[read-only] palette : const QPalette

Access functions:

QPalette palette() const

[read-only] themeName : const QString

Access functions:

QString themeName() const

[read-only] useGlobalSettings : const bool

Access functions:

bool useGlobalSettings() const

Member Function Documentation

[explicit] Theme::Theme(QObject *parent = nullptr)

Default constructor. It will be the global theme configured in plasmarc

parent the parent object

[explicit] Theme::Theme(const QString &themeName, QObject *parent = nullptr)

Construct a theme. It will be a custom theme instance of themeName.

themeName the name of the theme to create

parent the parent object

bool Theme::adaptiveTransparencyEnabled() const

This method allows Plasma to enable and disable the adaptive transparency option of the panel, which allows user to decide whether the panel should be always transparent, always opaque or only opaque when a window is maximized. The configuration in the metadata.desktop file of the theme could look like this (for a lighter background):

[AdaptiveTransparency]
enabled=true

Returns Whether or not to enable the adaptive transparency

qreal Theme::backgroundContrast() const

This method allows Plasma to set a background contrast effect for a given theme, improving readability. The value is read from the "contrast" key in the "ContrastEffect" group in the Theme's metadata file.

Returns The contrast provided to the contrasteffect

Note: Getter function for property backgroundContrast.

See also backgroundContrastEnabled.

bool Theme::backgroundContrastEnabled() const

This method allows Plasma to enable and disable the background contrast effect for a given theme, improving readability. The value is read from the "enabled" key in the "ContrastEffect" group in the Theme's metadata file. The configuration in the metadata.desktop file of the theme could look like this (for a lighter background):

[ContrastEffect]
enabled=true
contrast=0.45
intensity=0.45
saturation=1.7

Returns Whether or not to enable the contrasteffect

qreal Theme::backgroundIntensity() const

This method allows Plasma to set a background contrast effect for a given theme, improving readability. The value is read from the "intensity" key in the "ContrastEffect" group in the Theme's metadata file.

Returns The intensity provided to the contrasteffect

Note: Getter function for property backgroundIntensity.

See also backgroundContrastEnabled.

QString Theme::backgroundPath(const QString &image) const

qreal Theme::backgroundSaturation() const

This method allows Plasma to set a background contrast effect for a given theme, improving readability. The value is read from the "saturation" key in the "ContrastEffect" group in the Theme's metadata file.

Returns The saturation provided to the contrasteffect

Note: Getter function for property backgroundSaturation.

See also backgroundContrastEnabled.

bool Theme::blurBehindEnabled() const

This method allows Plasma to enable and disable the blurring of what is behind the background for a given theme. The value is read from the "enabled" key in the "BlurBehindEffect" group in the Theme's metadata file. Default is @c true.

The configuration in the metadata.desktop file of the theme could look like this:

[BlurBehindEffect]
enabled=false

Returns Whether or not to enable blurring of what is behind

QColor Theme::color(Plasma::Theme::ColorRole role, Kirigami::Platform::PlatformTheme::ColorSet group = Kirigami::Platform::PlatformTheme::ColorSet::Window) const

Returns the text color to be used by items resting on the background

role which role (usage pattern) to get the color for

group which group we want a color of

KSharedConfigPtr Theme::colorScheme() const

Returns the color scheme configurationthat goes along this theme.

This can be used with KStatefulBrush and KColorScheme to determine the proper colours to use along with the visual elements in this theme.

bool Theme::currentThemeHasImage(const QString &name) const

Checks if this theme has an image named in a certain way

name the name of the file in the theme directory (without the ".svg" part or a leading slash)

Returns true if the image exists for this theme

[since 6.6] QString Theme::defaultWallpaperTheme() const

Returns the default wallpaper theme associated with this theme.

This function was introduced in 6.6.

[static] KSharedConfigPtr Theme::globalColorScheme()

[static] QPalette Theme::globalPalette()

QString Theme::imagePath(const QString &name) const

Retrieve the path for an SVG image in the current theme.

name the name of the file in the theme directory (without the ".svg" part or a leading slash)

Returns the full path to the requested file for the current theme

KPluginMetaData Theme::metadata() const

Returns plugin metadata for this theme, with information such as name, description, author, website etc

QPalette Theme::palette() const

Returns a QPalette with the colors set as defined by the theme.

Note: Getter function for property palette.

void Theme::setThemeName(const QString &themeName)

Sets the current theme being used.

See also themeName().

void Theme::setUseGlobalSettings(bool useGlobal)

Tells the theme whether to follow the global settings or use application specific settings

useGlobal pass in true to follow the global settings

See also useGlobalSettings().

QString Theme::themeName() const

Returns the name of the theme.

Note: Getter function for property themeName.

See also setThemeName().

bool Theme::useGlobalSettings() const

Returns true if the global settings are followed, false if application specific settings are used.

Note: Getter function for property useGlobalSettings.

See also setUseGlobalSettings().