Plasma
#include <Plasma/Theme>
Public Types | |
enum | ColorRole { TextColor = 0, HighlightColor = 1, BackgroundColor = 2, ButtonTextColor = 4, ButtonBackgroundColor = 8, LinkColor = 16, VisitedLinkColor = 32, ButtonHoverColor = 64, ButtonFocusColor = 128, ViewTextColor = 256, ViewBackgroundColor = 512, ViewHoverColor = 1024, ViewFocusColor = 2048 } |
enum | FontRole { DefaultFont = 0, DesktopFont, SmallestFont } |
Public Slots | |
void | settingsChanged () |
Signals | |
void | themeChanged () |
Public Member Functions | |
Theme (QObject *parent=0) | |
Theme (const QString &themeName, QObject *parent=0) | |
~Theme () | |
Q_INVOKABLE QString | animationPath (const QString &name) const |
Q_INVOKABLE QColor | color (ColorRole role) const |
Q_INVOKABLE KSharedConfigPtr | colorScheme () const |
Q_INVOKABLE bool | currentThemeHasImage (const QString &name) const |
bool | findInCache (const QString &key, QPixmap &pix) |
bool | findInCache (const QString &key, QPixmap &pix, unsigned int lastModified) |
bool | findInRectsCache (const QString &image, const QString &element, QRectF &rect) const |
Q_INVOKABLE QFont | font (FontRole role) const |
Q_INVOKABLE QFontMetrics | fontMetrics () const |
KUrl | homepage () const |
Q_INVOKABLE 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 |
void | releaseRectsCache (const QString &image) |
void | setCacheLimit (int kbytes) |
Q_INVOKABLE void | setFont (const QFont &font, FontRole role=DefaultFont) |
void | setThemeName (const QString &themeName) |
void | setUseGlobalSettings (bool useGlobal) |
Q_INVOKABLE QString | styleSheet (const QString &css=QString()) const |
QString | themeName () const |
int | toolTipDelay () const |
bool | useGlobalSettings () const |
bool | useNativeWidgetStyle () const |
Q_INVOKABLE QString | wallpaperPath (const QSize &size=QSize()) const |
Q_INVOKABLE bool | windowTranslucencyEnabled () const |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Static Public Member Functions | |
static Theme * | defaultTheme () |
static KPluginInfo::List | listThemeInfo () |
static PackageStructure::Ptr | packageStructure () |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
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) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Properties | |
QString | themeName |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Detailed Description
Interface to the Plasma theme.
Accessed via Plasma::Theme::defaultTheme() e.g:
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
Constructor & Destructor Documentation
|
explicit |
Default constructor.
Usually you want to use the singleton instead.
- See also
- defaultTheme
- Parameters
-
parent the parent object
Construct a theme.
Usually you want to use the singleton instead.
- See also
- defaultTheme
- Parameters
-
themeName the name of the theme to create parent the parent object
- Since
- 4.3
Member Function Documentation
KSharedConfigPtr Plasma::Theme::colorScheme | ( | ) | const |
bool Plasma::Theme::currentThemeHasImage | ( | const QString & | name | ) | const |
|
static |
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
- Returns
- true when pixmap was found and loaded from cache, false otherwise
- Since
- 4.3
bool Plasma::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
QFontMetrics Plasma::Theme::fontMetrics | ( | ) | const |
KUrl Plasma::Theme::homepage | ( | ) | const |
void Plasma::Theme::insertIntoCache | ( | const QString & | key, |
const QPixmap & | pix, | ||
const QString & | id | ||
) |
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 inser 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
void Plasma::Theme::invalidateRectsCache | ( | const QString & | image | ) |
QStringList Plasma::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
|
static |
|
static |
void Plasma::Theme::releaseRectsCache | ( | const QString & | image | ) |
Frees up memory used by cached information for a given image without removing the permenant record of it on disk.
- See also
- invalidateRectsCache
- Parameters
-
image the path to the image the cache is assoiated with
void Plasma::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.
void Plasma::Theme::setFont | ( | const QFont & | font, |
FontRole | role = DefaultFont |
||
) |
void Plasma::Theme::setThemeName | ( | const QString & | themeName | ) |
|
slot |
void Plasma::Theme::setUseGlobalSettings | ( | bool | useGlobal | ) |
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
|
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.
QString Plasma::Theme::themeName | ( | ) | const |
- Returns
- the name of the theme.
int Plasma::Theme::toolTipDelay | ( | ) | const |
bool Plasma::Theme::useGlobalSettings | ( | ) | const |
bool Plasma::Theme::useNativeWidgetStyle | ( | ) | const |
bool Plasma::Theme::windowTranslucencyEnabled | ( | ) | const |
Property Documentation
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.