Plasma.Theme

KDE 4.2 PyKDE API Reference

- KDE's Python API

# Theme Class Reference

`from PyKDE4.plasma import *`

Inherits: QObject
Namespace: Plasma

## Detailed Description

Theme plasma/theme.h <Plasma/Theme>

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.

## Enumerations
ColorRole | { TextColor, HighlightColor, BackgroundColor, ButtonTextColor, ButtonBackgroundColor }
FontRole | { DefaultFont, DesktopFont }
## Signals
| themeChanged ()
## Methods
| __init__ (self, QObject parent=0)
QColor | color (self, Plasma.Theme.ColorRole role)
KSharedConfigPtr | colorScheme (self)
bool | currentThemeHasImage (self, QString name)
bool | findInCache (self, QString key, QPixmap pix)
bool | findInRectsCache (self, QString image, QString element, QRectF rect)
QFont | font (self, Plasma.Theme.FontRole role)
QFontMetrics | fontMetrics (self)
QString | imagePath (self, QString name)
| insertIntoCache (self, QString key, QPixmap pix)
| insertIntoRectsCache (self, QString image, QString element, QRectF rect)
| invalidateRectsCache (self, QString image)
| releaseRectsCache (self, QString image)
| setCacheLimit (self, int kbytes)
| setFont (self, QFont font, Plasma.Theme.FontRole role=Plasma.Theme.DefaultFont)
| setThemeName (self, QString themeName)
| setUseGlobalSettings (self, bool useGlobal)
| settingsChanged (self)
| themeChanged (self)
QString | themeName (self)
bool | useGlobalSettings (self)
QString | wallpaperPath (self, QSize size=QSize())
bool | windowTranslucencyEnabled (self)
## Static Methods
Plasma.Theme | defaultTheme ()
Plasma.PackageStructure.Ptr | packageStructure ()

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Default constructor. Usually you want to use the singleton instead.

QColor color | ( | self, |
|  | Plasma.Theme.ColorRole | role
| ) |  |  |

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

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

KSharedConfigPtr colorScheme | ( |  | self ) |

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 currentThemeHasImage | ( | self, |
|  | QString | name
| ) |  |  |

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

@arg 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

Plasma.Theme defaultTheme | ( |  | ) |

Singleton pattern accessor

bool findInCache | ( | self, |
|  | QString | key,
|  | QPixmap | pix
| ) |  |  |

Tries to load pixmap with the specified key from cache.

Returns:
  true when pixmap was found and loaded from cache, false otherwise

bool findInRectsCache | ( | self, |
|  | QString | image,
|  | QString | element,
|  | QRectF | rect
| ) |  |  |

Tries to load the rect of a sub element from a disk cache

@arg image path of the image we want to check @arg element sub element we want to retrieve @arg 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 font | ( | self, |
|  | Plasma.Theme.FontRole | role
| ) |  |  |

Returns the font to be used by themed items

@arg role which role (usage pattern) to get the font for

QFontMetrics fontMetrics | ( |  | self ) |

Returns the font metrics for the font to be used by themed items

QString imagePath | ( | self, |
|  | QString | name
| ) |  |  |

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

@arg 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

insertIntoCache | ( | self, |
|  | QString | key,
|  | QPixmap | pix
| ) |  |  |

Insert specified pixmap into the cache. If the cache already contains pixmap with the specified key then it is overwritten.

insertIntoRectsCache | ( | self, |
|  | QString | image,
|  | QString | element,
|  | QRectF | rect
| ) |  |  |

Inserts a rectangle of a sub element of an image into a disk cache

@arg image path of the image we want to insert information @arg element sub element we want insert the rect @arg rect element rectangle

invalidateRectsCache | ( | self, |
|  | QString | image
| ) |  |  |

Discards all the information about a given image from the rectangle disk cache

@arg image the path to the image the cache is assoiated with

Plasma.PackageStructure.Ptr packageStructure | ( |  | ) |

Returns:
  a package structure representing a Theme

releaseRectsCache | ( | self, |
|  | 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

@arg image the path to the image the cache is assoiated with

setCacheLimit | ( | self, |
|  | 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.

setFont | ( | self, |
|  | QFont | font,
|  | Plasma.Theme.FontRole | role=Plasma.Theme.DefaultFont
| ) |  |  |

Sets the default font to be used with themed items. Defaults to the application wide default font.

@arg font the new font @arg role which role (usage pattern) to set the font for

setThemeName | ( | self, |
|  | QString | themeName
| ) |  |  |

Sets the current theme being used.

setUseGlobalSettings | ( | self, |
|  | bool | useGlobal
| ) |  |  |

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

@arg useGlobal pass in true to follow the global settings

settingsChanged | ( |  | self ) |

Notifies the Theme object that the theme settings have changed and should be read from the config file

themeChanged | ( |  | self ) |

Emitted when the user changes the theme. SVGs should be reloaded at that point

Signal syntax:
  `QObject.connect(source, SIGNAL("themeChanged()"), target_slot)`

QString themeName | ( |  | self ) |

Returns:
  the name of the theme.

bool useGlobalSettings | ( |  | self ) |

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

QString wallpaperPath | ( | self, |
|  | QSize | size=QSize()
| ) |  |  |

Retreives the default wallpaper associated with this theme.

@arg size the 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

bool windowTranslucencyEnabled | ( |  | self ) |

Returns if the window manager effects (e.g. translucency, compositing) is active or not

## Enumeration Documentation

ColorRole

Enumerator:

  TextColor = 0 |
  HighlightColor = 1 |
  BackgroundColor = 2 |
  ButtonTextColor = 4 |
  ButtonBackgroundColor = 8 |

FontRole

background color for buttons

Enumerator:

  DefaultFont = 0 |
  DesktopFont |