Plasma::Theme Class Reference
Interface to the Plasma theme.
More...
#include <Plasma/Theme>
List of all members.
Public Types |
enum | ColorRole {
TextColor = 0,
HighlightColor = 1,
BackgroundColor = 2,
ButtonTextColor = 4,
ButtonBackgroundColor = 8
} |
enum | FontRole { DefaultFont = 0,
DesktopFont
} |
Public Slots |
void | settingsChanged () |
Signals |
void | themeChanged () |
Public Member Functions |
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, unsigned int lastModified) |
bool | findInCache (const QString &key, QPixmap &pix) |
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) |
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) |
| Theme (const QString &themeName, QObject *parent=0) |
| Theme (QObject *parent=0) |
QString | themeName () const |
bool | useGlobalSettings () const |
bool | useNativeWidgetStyle () const |
Q_INVOKABLE QString | wallpaperPath (const QSize &size=QSize()) const |
Q_INVOKABLE bool | windowTranslucencyEnabled () const |
| ~Theme () |
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:
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 56 of file theme.h.
Member Enumeration Documentation
- Enumerator:
TextColor |
the text color to be used by items resting on the background
|
HighlightColor |
the text higlight color to be used by items resting on the background
|
BackgroundColor |
the default background color
|
ButtonTextColor |
|
ButtonBackgroundColor |
text color for buttons
|
Definition at line 62 of file theme.h.
- Enumerator:
DefaultFont |
The standard text font.
|
DesktopFont |
The standard text font.
|
Definition at line 71 of file theme.h.
Constructor & Destructor Documentation
Plasma::Theme::Theme |
( |
QObject * |
parent = 0 |
) |
[explicit] |
Default constructor.
Usually you want to use the singleton instead.
- See also:
- defaultTheme
Definition at line 284 of file theme.cpp.
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
Definition at line 291 of file theme.cpp.
Plasma::Theme::~Theme |
( |
|
) |
|
Member Function Documentation
QColor Plasma::Theme::color |
( |
ColorRole |
role |
) |
const |
Returns the text color to be used by items resting on the background.
- role which role (usage pattern) to get the color for
Definition at line 581 of file theme.cpp.
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 576 of file theme.cpp.
bool Plasma::Theme::currentThemeHasImage |
( |
const QString & |
name |
) |
const |
Checks if this theme has an image named in a certain way.
- 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
Definition at line 565 of file theme.cpp.
Theme * Plasma::Theme::defaultTheme |
( |
|
) |
[static] |
Singleton pattern accessor.
Definition at line 279 of file theme.cpp.
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
Definition at line 682 of file theme.cpp.
bool Plasma::Theme::findInCache |
( |
const QString & |
key, |
|
|
QPixmap & |
pix | |
|
) |
| | |
Tries to load pixmap with the specified key from cache.
- Parameters:
-
| key | the name to use in the cache for this image |
| pix | the pixmap object to populate with the resulting data if found |
- Returns:
- true when pixmap was found and loaded from cache, false otherwise
Definition at line 666 of file theme.cpp.
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
Definition at line 713 of file theme.cpp.
QFont Plasma::Theme::font |
( |
FontRole |
role |
) |
const |
Returns the font to be used by themed items.
- role which role (usage pattern) to get the font for
Definition at line 614 of file theme.cpp.
QFontMetrics Plasma::Theme::fontMetrics |
( |
|
) |
const |
Returns the font metrics for the font to be used by themed items.
Definition at line 633 of file theme.cpp.
QString Plasma::Theme::imagePath |
( |
const QString & |
name |
) |
const |
Retrieve the path for an SVG image in the current theme.
- 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
Definition at line 477 of file theme.cpp.
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 |
- Since:
- 4.3
Definition at line 698 of file theme.cpp.
void Plasma::Theme::insertIntoCache |
( |
const QString & |
key, |
|
|
const QPixmap & |
pix | |
|
) |
| | |
Insert specified pixmap into the cache.
If the cache already contains pixmap with the specified key then it is overwritten.
- Parameters:
-
| key | the name to use in the cache for this pixmap |
| pix | the pixmap data to store in the cache |
Definition at line 691 of file theme.cpp.
void Plasma::Theme::insertIntoRectsCache |
( |
const QString & |
image, |
|
|
const QString & |
element, |
|
|
const QRectF & |
rect | |
|
) |
| | |
Inserts a rectangle of a sub element of an image into a disk cache.
- image path of the image we want to insert information
- element sub element we want insert the rect
- rect element rectangle
Definition at line 746 of file theme.cpp.
void Plasma::Theme::invalidateRectsCache |
( |
const QString & |
image |
) |
|
Discards all the information about a given image from the rectangle disk cache.
- image the path to the image the cache is assoiated with
Definition at line 769 of file theme.cpp.
KPluginInfo::List Plasma::Theme::listThemeInfo |
( |
|
) |
[static] |
- Returns:
- a list of all known themes
- Since:
- 4.3
Definition at line 323 of file theme.cpp.
- Returns:
- a package structure representing a Theme
Definition at line 314 of file theme.cpp.
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
Definition at line 777 of file theme.cpp.
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.
Definition at line 787 of file theme.cpp.
void Plasma::Theme::setFont |
( |
const QFont & |
font, |
|
|
FontRole |
role = DefaultFont | |
|
) |
| | |
Sets the default font to be used with themed items.
Defaults to the application wide default font.
- font the new font
- role which role (usage pattern) to set the font for
Definition at line 608 of file theme.cpp.
void Plasma::Theme::setThemeName |
( |
const QString & |
themeName |
) |
|
Sets the current theme being used.
Definition at line 343 of file theme.cpp.
void Plasma::Theme::settingsChanged |
( |
|
) |
[slot] |
Notifies the Theme object that the theme settings have changed and should be read from the config file.
Definition at line 338 of file theme.cpp.
void Plasma::Theme::setUseGlobalSettings |
( |
bool |
useGlobal |
) |
|
Tells the theme whether to follow the global settings or use application specific settings.
- useGlobal pass in true to follow the global settings
Definition at line 644 of file theme.cpp.
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 |
- Returns:
- true if the global settings are followed, false if application specific settings are used.
Definition at line 656 of file theme.cpp.
bool Plasma::Theme::useNativeWidgetStyle |
( |
|
) |
const |
- Returns:
- true if the native widget styles should be used instead of themed widgets. Defaults is false.
Definition at line 661 of file theme.cpp.
QString Plasma::Theme::wallpaperPath |
( |
const QSize & |
size = QSize() |
) |
const |
Retreives the default wallpaper associated with this theme.
- 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
Definition at line 515 of file theme.cpp.
bool Plasma::Theme::windowTranslucencyEnabled |
( |
|
) |
const |
Returns if the window manager effects (e.g.
translucency, compositing) is active or not
Definition at line 639 of file theme.cpp.
Property Documentation
QString Plasma::Theme::themeName [read] |
The documentation for this class was generated from the following files: