Jamboarder (Talk | contribs) (→Current Theme Elements) |
Jamboarder (Talk | contribs) (→Backgrounds) |
||
| Line 69: | Line 69: | ||
* '''hint-stretch-borders''': if it exists, the borders will not be tiled but rather will be stretched to fit | * '''hint-stretch-borders''': if it exists, the borders will not be tiled but rather will be stretched to fit | ||
| + | * '''hint-tile-center''': if it exists, the center will not be scaled but rather will be tiled to fit. | ||
* '''hint-no-border-padding''': If this element exists, padding will not be added for the borders, and content will therefore be able to use the entire area. | * '''hint-no-border-padding''': If this element exists, padding will not be added for the borders, and content will therefore be able to use the entire area. | ||
* '''hint-apply-color-scheme''': If this element exists, the svg will be colorized using the color scheme colors. Colorization tapers off on either side of an HSV color value/intensity of 127. | * '''hint-apply-color-scheme''': If this element exists, the svg will be colorized using the color scheme colors. Colorization tapers off on either side of an HSV color value/intensity of 127. | ||
libplasma provides the Theme class so Plasma elements and other applications, such as KRunner, that need to graphically hint or theme interface elements. This is not a replacement for QStyle, but rather provides standard elements for things such as box backgrounds.
This allows for easy re-theming of the desktop while also keeping elements on the desktop more consistent with each other.
See also Plasma widgets.
Contents |
Themes are stored in share/apps/desktoptheme. A theme is described by a .desktop file in share/apps/desktoptheme. The contents of which might look like this:
[Desktop Entry]
Name=Oxygen
Comment=Theme done in the Oxygen style
X-KDE-PluginInfo-Author=The Oxygen Project X-KDE-PluginInfo-Email=kde-artists@kde.org X-KDE-PluginInfo-Name=default X-KDE-PluginInfo-Version=pre0.1 X-KDE-PluginInfo-Website=http://plasma.kde.org X-KDE-PluginInfo-Category= X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true
The X-KDE-PluginInfo-Name entry must contain the name of the subdirectory in share/apps/desktoptheme where the SVG files for this theme exist.
Beneath this directory one will find the following file structure:
Theme elements are accessed by path. Whether this maps to literal paths on disk or not is not guaranteed and considered an implementation detail of Plasma::Theme.
Therefore, to access the dialog background, one might create an svg in this manner:
Plasma::Theme theme;
QSvgRenderer svg(theme.image("dialog/background"));
It is generally recommended to use Plasma::Svg instead of QSvgRenderer directly, however. Remember to call resize() on the Plasma::Svg before painting with it!
Plasma::Svg svg("dialog/background");
svg.resize(size());
If you use Plasma::Svg, changes to the theme are automatically picked up. Otherwise, you can connect to the changed() signal in the Plasma::Theme class. This signal is emitted whenever the theme is changed, which may be triggered by the user switching the theme used or system changes such as a composite manager becoming available.
All background svg's (except for desktop wallpapers) must have the following named elements, all of which will be painted at the native size (and can therefore be bitmaps), except for the center which will be scaled:
Additionally, the following elements can be used to control the rendering of the backgrounds:
Themes get installed to share/apps/desktoptheme. Each theme is stored in a subdirectory with the following file structure
In the folder share/apps/desktoptheme/opaque the same hierarchy can be found: when compositing is disabled files in this folder are preferred over the corresponding ones listed above. Only background for top level windows are appropriate to go in this folder.
Since top-level windows will be shaped according to the transparency of the svg and window shapes don't support alpha-blending, if the svg has rounded borders they should have a shape that don't require antialiasing, like the following example.