• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

Plasma::Theme

Plasma::Theme Class Reference

Interface to the Plasma theme. More...

#include <Plasma/Theme>

Inheritance diagram for Plasma::Theme:

Inheritance graph
[legend]

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)
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)
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 (QObject *parent=0)
QString themeName () const
bool useGlobalSettings () const
Q_INVOKABLE QString wallpaperPath (const QSize &size=QSize()) const
Q_INVOKABLE bool windowTranslucencyEnabled () const
 ~Theme ()

Static Public Member Functions

static Theme * defaultTheme ()
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.

Definition at line 55 of file theme.h.


Member Enumeration Documentation

enum Plasma::Theme::ColorRole

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 61 of file theme.h.

enum Plasma::Theme::FontRole

Enumerator:
DefaultFont  The standard text font.
DesktopFont  The standard text font.

Definition at line 70 of file theme.h.


Constructor & Destructor Documentation

Plasma::Theme::Theme ( QObject *  parent = 0  )  [explicit]

Default constructor.

Usually you want to use the singleton instead.

Definition at line 235 of file theme.cpp.

Plasma::Theme::~Theme (  ) 

Definition at line 256 of file theme.cpp.


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 485 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 480 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 469 of file theme.cpp.

Theme * Plasma::Theme::defaultTheme (  )  [static]

Singleton pattern accessor.

Definition at line 230 of file theme.cpp.

bool Plasma::Theme::findInCache ( const 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

Definition at line 563 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 575 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 518 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 535 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 386 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.

Definition at line 568 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 602 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 625 of file theme.cpp.

PackageStructure::Ptr Plasma::Theme::packageStructure (  )  [static]

Returns:
a package structure representing a Theme

Definition at line 268 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 633 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 641 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 512 of file theme.cpp.

void Plasma::Theme::setThemeName ( const QString &  themeName  ) 

Sets the current theme being used.

Definition at line 282 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 277 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 546 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 558 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 419 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 541 of file theme.cpp.


Property Documentation

QString Plasma::Theme::themeName [read]

Definition at line 58 of file theme.h.


The documentation for this class was generated from the following files:
  • theme.h
  • theme.cpp

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal