Plasma::Theme

Search for usage in LXR

#include <Plasma/Theme>

Inheritance diagram for Plasma::Theme:

Public Types

enum  ColorGroup {
  NormalColorGroup = 0 , ButtonColorGroup = 1 , ViewColorGroup = 2 , ComplementaryColorGroup = 3 ,
  HeaderColorGroup , ToolTipColorGroup
}
 
enum  ColorRole {
  TextColor = 0 , BackgroundColor = 1 , HighlightColor = 2 , HoverColor = 3 ,
  FocusColor = 4 , LinkColor = 5 , VisitedLinkColor = 6 , HighlightedTextColor = 7 ,
  PositiveTextColor = 8 , NeutralTextColor = 9 , NegativeTextColor = 10 , DisabledTextColor = 11
}
 

Properties

QFont defaultFont
 
QPalette palette
 
QFont smallestFont
 
QString themeName
 
bool useGlobalSettings
 
QString wallpaperPath
 
- Properties inherited from QObject
 objectName
 

Signals

void defaultFontChanged ()
 
void smallestFontChanged ()
 
void themeChanged ()
 

Public Member Functions

 Theme (const QString &themeName, QObject *parent=nullptr)
 
 Theme (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 (ColorRole role, ColorGroup group=NormalColorGroup) const
 
KSharedConfigPtr colorScheme () const
 
bool currentThemeHasImage (const QString &name) const
 
QFont defaultFont () const
 
QString imagePath (const QString &name) const
 
KPluginMetaData metadata () const
 
Q_INVOKABLE QSizeF mSize (const QFont &font=QGuiApplication::font()) const
 
QPalette palette () const
 
void setThemeName (const QString &themeName)
 
void setUseGlobalSettings (bool useGlobal)
 
QFont smallestFont () const
 
QString themeName () const
 
bool useGlobalSettings () const
 
QString wallpaperPath (const QSize &size=QSize()) const
 
Q_INVOKABLE QString wallpaperPathForSize (int width=-1, int height=-1) const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static KSharedConfigPtr globalColorScheme ()
 
static QPalette globalPalette ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

Interface to the Plasma theme.

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::Svg uses Plasma::Theme internally to locate and load the appropriate SVG data. Alternatively, Plasma::Theme can be used directly to retrieve file system paths to SVGs by name.

Definition at line 39 of file theme.h.

Member Enumeration Documentation

◆ ColorGroup

enum Plasma::Theme::ColorGroup

Definition at line 70 of file theme.h.

◆ ColorRole

Enumerator
TextColor 

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

BackgroundColor 

the default background color

HighlightColor 

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

HoverColor 

color for hover effect on view

FocusColor 

color for focus effect on view

LinkColor 

color for clickable links

VisitedLinkColor 

color visited clickable links

HighlightedTextColor 

color contrasting with HighlightColor, to be used for instance with

PositiveTextColor 

color of foreground objects with a "positive message" connotation (usually green)

NeutralTextColor 

color of foreground objects with a "neutral message" connotation (usually yellow)

NegativeTextColor 

color of foreground objects with a "negative message" connotation (usually red)

DisabledTextColor 

color of disabled text

Since
5.64

Definition at line 54 of file theme.h.

Property Documentation

◆ defaultFont

QFont Plasma::Theme::defaultFont
read

Definition at line 48 of file theme.h.

◆ palette

QPalette Plasma::Theme::palette
read

Definition at line 51 of file theme.h.

◆ smallestFont

QFont Plasma::Theme::smallestFont
read

Definition at line 49 of file theme.h.

◆ themeName

QString Plasma::Theme::themeName
read

Definition at line 43 of file theme.h.

◆ useGlobalSettings

bool Plasma::Theme::useGlobalSettings
read

Definition at line 44 of file theme.h.

◆ wallpaperPath

QString Plasma::Theme::wallpaperPath
read

Definition at line 45 of file theme.h.

Constructor & Destructor Documentation

◆ Theme() [1/2]

Plasma::Theme::Theme ( QObject * parent = nullptr)
explicit

Default constructor.

It will be the global theme configured in plasmarc

Parameters
parentthe parent object

Definition at line 34 of file theme.cpp.

◆ Theme() [2/2]

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

Construct a theme.

It will be a custom theme instance of themeName.

Parameters
themeNamethe name of the theme to create
parentthe parent object
Since
4.3

Definition at line 52 of file theme.cpp.

◆ ~Theme()

Plasma::Theme::~Theme ( )
override

Definition at line 75 of file theme.cpp.

Member Function Documentation

◆ adaptiveTransparencyEnabled()

bool Plasma::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
Since
5.20

Definition at line 302 of file theme.cpp.

◆ backgroundContrast()

qreal Plasma::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
Since
5.0
See also
backgroundContrastEnabled

Definition at line 307 of file theme.cpp.

◆ backgroundContrastEnabled()

bool Plasma::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
Since
5.0

Definition at line 297 of file theme.cpp.

◆ backgroundIntensity()

qreal Plasma::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
Since
5.0
See also
backgroundContrastEnabled

Definition at line 322 of file theme.cpp.

◆ backgroundPath()

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

Definition at line 159 of file theme.cpp.

◆ backgroundSaturation()

qreal Plasma::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
Since
5.0
See also
backgroundContrastEnabled

Definition at line 334 of file theme.cpp.

◆ blurBehindEnabled()

bool Plasma::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 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
Since
5.57

Definition at line 342 of file theme.cpp.

◆ color()

QColor Plasma::Theme::color ( ColorRole role,
ColorGroup group = NormalColorGroup ) const

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

Parameters
rolewhich role (usage pattern) to get the color for
groupwhich group we want a color of

Definition at line 255 of file theme.cpp.

◆ colorScheme()

KSharedConfigPtr Plasma::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.

Definition at line 250 of file theme.cpp.

◆ currentThemeHasImage()

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

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

Parameters
namethe 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

Definition at line 236 of file theme.cpp.

◆ defaultFont()

QFont Plasma::Theme::defaultFont ( ) const
Returns
The default application font
Since
5.0

Definition at line 282 of file theme.cpp.

◆ defaultFontChanged

void Plasma::Theme::defaultFontChanged ( )
signal

Notifier for change of defaultFont property.

◆ globalColorScheme()

KSharedConfigPtr Plasma::Theme::globalColorScheme ( )
static

Definition at line 178 of file theme.cpp.

◆ globalPalette()

QPalette Plasma::Theme::globalPalette ( )
static

Definition at line 169 of file theme.cpp.

◆ imagePath()

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

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

Parameters
namethe 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

Definition at line 123 of file theme.cpp.

◆ metadata()

KPluginMetaData Plasma::Theme::metadata ( ) const
Returns
plugin metadata for this theme, with information such as name, description, author, website etc
Since
5.95

Definition at line 277 of file theme.cpp.

◆ mSize()

QSizeF Plasma::Theme::mSize ( const QFont & font = QGuiApplication::font()) const

Returns the size of the letter "M" as rendered on the screen with the given font.

This values gives you a base size that:

  • scales dependent on the DPI of the screen
  • Scales with the default font as set by the user You can use it like this in QML Items:
    width: PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height
    height: width
    }
    This allows you to dynamically scale elements of your user interface with different font settings and different physical outputs (with different DPI).
    Parameters
    fontThe font to use for the metrics.
    Returns
    The size of the letter "M" as rendered on the screen with the given font.
    Since
    5.0

Definition at line 292 of file theme.cpp.

◆ palette()

QPalette Plasma::Theme::palette ( ) const

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

Since
5.68

Definition at line 164 of file theme.cpp.

◆ setThemeName()

void Plasma::Theme::setThemeName ( const QString & themeName)

Sets the current theme being used.

Definition at line 91 of file theme.cpp.

◆ setUseGlobalSettings()

void Plasma::Theme::setUseGlobalSettings ( bool useGlobal)

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

Parameters
useGlobalpass in true to follow the global settings

Definition at line 260 of file theme.cpp.

◆ smallestFont()

QFont Plasma::Theme::smallestFont ( ) const
Returns
The smallest readable font
Since
5.0

Definition at line 287 of file theme.cpp.

◆ smallestFontChanged

void Plasma::Theme::smallestFontChanged ( )
signal

Notifier for change of smallestFont property.

◆ themeChanged

void Plasma::Theme::themeChanged ( )
signal

Emitted when the user changes the theme.

Stylesheet usage, colors, etc. should be updated at this point. However, SVGs should not be repainted in response to this signal; connect to Svg::repaintNeeded() instead for that, as Svg objects need repainting not only when themeChanged() is emitted; moreover Svg objects connect to and respond appropriately to themeChanged() internally, emitting Svg::repaintNeeded() at an appropriate time.

◆ themeName()

QString Plasma::Theme::themeName ( ) const
Returns
the name of the theme.

Definition at line 118 of file theme.cpp.

◆ useGlobalSettings()

bool Plasma::Theme::useGlobalSettings ( ) const
Returns
true if the global settings are followed, false if application specific settings are used.

Definition at line 272 of file theme.cpp.

◆ wallpaperPath()

QString Plasma::Theme::wallpaperPath ( const QSize & size = QSize()) const

Retrieves the default wallpaper associated with this theme.

Parameters
sizethe target height and width of the wallpaper; if an invalid size is passed in, then a default size will be provided instead.
Returns
the full path to the wallpaper image

Definition at line 187 of file theme.cpp.

◆ wallpaperPathForSize()

QString Plasma::Theme::wallpaperPathForSize ( int width = -1,
int height = -1 ) const

Definition at line 231 of file theme.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 Fri Jul 19 2024 11:58:06 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.