Plasma::Theme
#include <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 | styleSheet |
QString | themeName |
bool | useGlobalSettings |
QString | wallpaperPath |
![]() | |
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 |
bool | findInCache (const QString &key, QPixmap &pix, unsigned int lastModified=0) |
bool | findInRectsCache (const QString &image, const QString &element, QRectF &rect) const |
QString | imagePath (const QString &name) const |
void | insertIntoCache (const QString &key, const QPixmap &pix) |
void | insertIntoCache (const QString &key, const QPixmap &pix, const QString &id) |
void | insertIntoRectsCache (const QString &image, const QString &element, const QRectF &rect) |
void | invalidateRectsCache (const QString &image) |
QStringList | listCachedRectKeys (const QString &image) const |
KPluginMetaData | metadata () const |
Q_INVOKABLE QSizeF | mSize (const QFont &font=QGuiApplication::font()) const |
QPalette | palette () const |
KPluginInfo | pluginInfo () const |
void | releaseRectsCache (const QString &image) |
void | setCacheLimit (int kbytes) |
void | setThemeName (const QString &themeName) |
void | setUseGlobalSettings (bool useGlobal) |
QFont | smallestFont () const |
QString | styleSheet (const QString &css=QString()) 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 |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () 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 () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, 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 |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
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 | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | 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 | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Static Public Member Functions | |
static QPalette | globalPalette () |
![]() | |
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) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Additional Inherited Members | |
![]() | |
typedef | QObjectList |
![]() | |
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 |
QObject * | sender () 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.
Member Enumeration Documentation
◆ ColorRole
Constructor & Destructor Documentation
◆ Theme() [1/2]
|
explicit |
◆ Theme() [2/2]
Member Function Documentation
◆ adaptiveTransparencyEnabled()
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):
- Returns
- Whether or not to enable the adaptive transparency
- Since
- 5.20
◆ backgroundContrast()
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
- Since
- 5.0
- See also
- backgroundContrastEnabled
◆ 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):
- Returns
- Whether or not to enable the contrasteffect
- Since
- 5.0
◆ backgroundIntensity()
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
- Since
- 5.0
- See also
- backgroundContrastEnabled
◆ backgroundSaturation()
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
- Since
- 5.0
- See also
- backgroundContrastEnabled
◆ blurBehindEnabled()
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 true
.
The configuration in the metadata.desktop file of the theme could look like this:
- Returns
- Whether or not to enable blurring of what is behind
- Since
- 5.57
◆ color()
◆ colorScheme()
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.
◆ currentThemeHasImage()
bool Theme::currentThemeHasImage | ( | const QString & | name | ) | const |
◆ defaultFont()
QFont Plasma::Theme::defaultFont | ( | ) | const |
- Returns
- The default application font
- Since
- 5.0
◆ defaultFontChanged
|
signal |
Notifier for change of defaultFont property.
◆ findInCache()
This is an overloaded member provided to check with file timestamp where cache is still valid.
- Parameters
-
key the name to use in the cache for this image pix the pixmap object to populate with the resulting data if found lastModified if non-zero, the time stamp is also checked on the file, and must be newer than the timestamp to be loaded
- Note
- Since KF 5.75, a lastModified value of 0 is deprecated. If used, it will now always return false. Use a proper file timestamp instead so modification can be properly tracked.
- Returns
- true when pixmap was found and loaded from cache, false otherwise
- Since
- 4.3
◆ findInRectsCache()
bool Theme::findInRectsCache | ( | const QString & | image, |
const QString & | element, | ||
QRectF & | rect | ||
) | const |
Tries to load the rect of a sub element from a disk cache.
- Parameters
-
image path of the image we want to check element sub element we want to retrieve rect output parameter of the element rect found in cache if not found or if we are sure it doesn't exist it will be QRect()
- Returns
- true if the element was found in cache or if we are sure the element doesn't exist
◆ imagePath()
◆ insertIntoCache() [1/2]
◆ insertIntoCache() [2/2]
Insert specified pixmap into the cache.
If the cache already contains pixmap with the specified key then it is overwritten. The actual insert is delayed for optimization reasons and the id parameter is used to discard repeated inserts in the delay time, useful when for instance the graphics to insert comes from a quickly resizing object: the frames between the start and destination sizes aren't useful in the cache and just cause overhead.
- Parameters
-
key the name to use in the cache for this pixmap pix the pixmap data to store in the cache id a name that identifies the caller class of this function in an unique fashion. This is needed to limit disk writes of the cache. If an image with the same id changes quickly, only the last size where insertIntoCache was called is actually stored on disk
- Since
- 4.3
◆ insertIntoRectsCache()
◆ invalidateRectsCache()
void Theme::invalidateRectsCache | ( | const QString & | image | ) |
◆ listCachedRectKeys()
QStringList Theme::listCachedRectKeys | ( | const QString & | image | ) | const |
Returns a list of all keys of cached rects for the given image.
- Parameters
-
image path of the image for which the keys should be returned
- Returns
- a QStringList whose elements are the entry keys in the rects cache
- Since
- 4.6
◆ metadata()
KPluginMetaData Theme::metadata | ( | ) | const |
◆ mSize()
QSizeF 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: This allows you to dynamically scale elements of your user interface with different font settings and different physical outputs (with different DPI).
- Parameters
-
font The 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
◆ palette()
QPalette Plasma::Theme::palette | ( | ) | const |
Returns a QPalette with the colors set as defined by the theme.
- Since
- 5.68
◆ pluginInfo()
KPluginInfo Theme::pluginInfo | ( | ) | const |
- Returns
- plugin info for this theme, with information such as name, description, author, website etc
- Since
- 5.0
- Deprecated:
- since 5.67, use KPluginMetaData
◆ releaseRectsCache()
void Theme::releaseRectsCache | ( | const QString & | image | ) |
Frees up memory used by cached information for a given image without removing the permanent record of it on disk.
- See also
- invalidateRectsCache
- Parameters
-
image the path to the image the cache is associated with
◆ setCacheLimit()
void Theme::setCacheLimit | ( | int | kbytes | ) |
Sets the maximum size of the cache (in kilobytes).
If cache gets bigger the limit then some entries are removed Setting cache limit to 0 disables automatic cache size limiting.
Note that the cleanup might not be done immediately, so the cache might temporarily (for a few seconds) grow bigger than the limit.
◆ setThemeName()
void Theme::setThemeName | ( | const QString & | themeName | ) |
◆ setUseGlobalSettings()
void Theme::setUseGlobalSettings | ( | bool | useGlobal | ) |
◆ smallestFont()
QFont Plasma::Theme::smallestFont | ( | ) | const |
- Returns
- The smallest readable font
- Since
- 5.0
◆ smallestFontChanged
|
signal |
Notifier for change of smallestFont property.
◆ styleSheet()
Provides a Plasma::Theme-themed stylesheet for hybrid (web / native Plasma) widgets.
You can use this method to retrieve a basic default stylesheet, or to theme your custom stylesheet you use for example in Plasma::WebView. The QString you can pass into this method does not have to be a valid stylesheet, in fact you can use this method to replace color placeholders with the theme's color in any QString.
In order to use this method with a custom stylesheet, just put for example textcolor in your QString and it will be replaced with the theme's text (or foreground) color.
Just like in many other methods for retrieving theme information, do not forget to update your stylesheet upon the themeChanged() signal.
The following tags will be replaced by corresponding colors from Plasma::Theme:
textcolor backgroundcolor buttonbackgroundcolor
link activatedlink hoveredlink visitedlink
fontfamily fontsize smallfontsize
- Parameters
-
css a stylesheet to theme, leave empty for a default stylesheet containing theming for some commonly used elements, body text and links, for example.
- Returns
- a piece of CSS that sets the most commonly used style elements to a theme matching Plasma::Theme.
- Since
- 4.5
◆ 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.
◆ useGlobalSettings()
bool Plasma::Theme::useGlobalSettings | ( | ) | const |
- Returns
- true if the global settings are followed, false if application specific settings are used.
◆ wallpaperPath()
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:18:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.