Plasma
Plasma::Theme Class Reference
Interface to the Plasma theme. More...
#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 } |
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 |
| Q_INVOKABLE QString | imagePath (const QString &name) const |
| void | insertIntoCache (const QString &key, const QPixmap &pix, const QString &id) |
| void | insertIntoCache (const QString &key, const QPixmap &pix) |
| 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 |
| bool | useGlobalSettings () const |
| bool | useNativeWidgetStyle () const |
| Q_INVOKABLE QString | wallpaperPath (const QSize &size=QSize()) const |
| Q_INVOKABLE bool | windowTranslucencyEnabled () const |
Static Public Member Functions | |
| static Theme * | defaultTheme () |
| static KPluginInfo::List | listThemeInfo () |
| static PackageStructure::Ptr | packageStructure () |
Properties | |
| QString | themeName |
Detailed Description
Interface to the Plasma theme.
Accessed via Plasma::Theme::defaultTheme() e.g:
QString imagePath = Plasma::Theme::defaultTheme()->imagePath("widgets/clock")
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
- Enumerator:
Constructor & Destructor Documentation
| Plasma::Theme::Theme | ( | QObject * | parent = 0 | ) | [explicit] |
Default constructor.
Usually you want to use the singleton instead.
- See also:
- defaultTheme
- parent the parent object
| Plasma::Theme::Theme | ( | const QString & | themeName, |
| QObject * | parent = 0 |
||
| ) | [explicit] |
Construct a theme.
Usually you want to use the singleton instead.
- See also:
- defaultTheme
- themeName the name of the theme to create
- parent the parent object
- Since:
- 4.3
Member Function Documentation
| QString Plasma::Theme::animationPath | ( | const QString & | name | ) | const |
| QColor Plasma::Theme::color | ( | ColorRole | role | ) | const |
| KSharedConfigPtr Plasma::Theme::colorScheme | ( | ) | const |
| bool Plasma::Theme::currentThemeHasImage | ( | const QString & | name | ) | const |
| Theme * Plasma::Theme::defaultTheme | ( | ) | [static] |
| bool Plasma::Theme::findInCache | ( | const QString & | key, |
| QPixmap & | pix | ||
| ) |
| bool Plasma::Theme::findInCache | ( | const QString & | key, |
| QPixmap & | pix, | ||
| unsigned int | lastModified | ||
| ) |
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.
- 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
| QFont Plasma::Theme::font | ( | FontRole | role | ) | const |
| QFontMetrics Plasma::Theme::fontMetrics | ( | ) | const |
| QString Plasma::Theme::imagePath | ( | const QString & | name | ) | const |
| void Plasma::Theme::insertIntoCache | ( | const QString & | key, |
| const QPixmap & | pix | ||
| ) |
| 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::insertIntoRectsCache | ( | const QString & | image, |
| const QString & | element, | ||
| const QRectF & | rect | ||
| ) |
| void Plasma::Theme::invalidateRectsCache | ( | const QString & | image | ) |
| QStringList Plasma::Theme::listCachedRectKeys | ( | const QString & | image | ) | const |
| KPluginInfo::List Plasma::Theme::listThemeInfo | ( | ) | [static] |
| PackageStructure::Ptr Plasma::Theme::packageStructure | ( | ) | [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
- 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 | ) |
| void Plasma::Theme::settingsChanged | ( | ) | [slot] |
| void Plasma::Theme::setUseGlobalSettings | ( | bool | useGlobal | ) |
| QString Plasma::Theme::styleSheet | ( | const QString & | css = QString() | ) | const |
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
| void Plasma::Theme::themeChanged | ( | ) | [signal] |
Emitted when the user changes the theme.
SVGs should be reloaded at that point
| QString Plasma::Theme::themeName | ( | ) | const |
- Returns:
- the name of the theme.
| bool Plasma::Theme::useGlobalSettings | ( | ) | const |
| bool Plasma::Theme::useNativeWidgetStyle | ( | ) | const |
| QString Plasma::Theme::wallpaperPath | ( | const QSize & | size = QSize() | ) | const |
| bool Plasma::Theme::windowTranslucencyEnabled | ( | ) | const |
Property Documentation
The documentation for this class was generated from the following files:
KDE 4.6 API Reference