Plasma::Stylesheet?

Sebastian Kügler sebas at kde.org
Thu May 6 14:13:29 CEST 2010


Hey,

I'd like to get in my work on stylesheet support in Plasma, before the feature freeze 
on May, 11th.

Right now, Stylesheet is a standalone class that give you a QString stylesheet() that 
uses Plasma::Theme's colouring and font sizing. This is useful basically whenever you 
want to use non-trivial HTML in your applet (or other Plasma code).

During Tokamak4, Aaron and I sat together to discuss how we want this in Plasma and 
we came to the preliminary conclusion that it'd best be added as a method to 
Plasma::Theme, so you basically get QString Plasma::Theme::stylesheet().

Thinking about this, it might be too limited, as I'd like to support custom 
stylesheets as well, basically what I have in mind is:

Stylesheet *css = new Plasma::StyleSheet("somecssfile.css");
QString myStyle = css->styleSheet();
connect(css, SIGNAL(styleSheetChanged()), this, SLOT(updateStyleSheet()));

The updater mechanism monitors changes to our CSS file. and makes the app reload when 
the stylesheet changes on disk or when the Plasma theme changes -- very quick "edit / 
test" cycles this way. It currently looks roughly like this:

http://websvn.kde.org/trunk/playground/base/plasma/applets/crystal/stylesheet.h?view=markup

(Merging of course means the usual d-pointer stuff, and of course adding docs, don't 
worry about that just yet.)

The reason to support custom-provided stylesheets would be to make more complex 
styles possible, I'm using Stylesheet for example for layouting HTML emails in Lion 
Mail and for a Dashboard in the Crystal applet, both use custom tags. The Welcome 
widget would be another nice example. This thing is part of the Silk stuff I've been 
working on, to provide more visual consistency between "webby" interfaces and our 
native Plasma stuff.

Question: Should I still go with the "add method to Plasma::Theme" approach (I don't 
see how to nicely add support for css files per user in that case), or should I 
continue with a separate class, Plasma::StyleSheet?

Thanks for your input,
-- 
sebas

http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9


More information about the Plasma-devel mailing list