[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Traverso-devel] Theming: fonts, colors, etc
From: |
Nicola Döbelin |
Subject: |
Re: [Traverso-devel] Theming: fonts, colors, etc |
Date: |
Wed, 31 Jan 2007 17:05:02 +0100 |
Hi,
> Currently only colors are stored in the theming file, I'd like to improve
> that
> situation a bit, please have a look at the 'new' format and help me figure
> out if this makes sense, if I forgot something, and so on.
That looks very flexible. Just a couple of ideas (which may already be realized
by your suggestion):
We're asking for object->property in the source code, and if the XML parser
finds a corresponding entry in the XML file, its value is returned. If the
entry doesn't exist, we should suggest a default value, just as in QSettings.
In the following snipplet you classify the properties, e.g. all colors are
grouped in a <colors></colors> block.
<object name="VUMeter" >
<colors>
<color name="background" red="120" green="200" blue="255" />
</colors>
<gradients>
<gradient name="background" type="linear" />
</gradients>
<fonts>
<font name ="cliptitel" size="9" type="Helvetica" />
</fonts>
</object>
I have absolutely no experience with XML, so I may be totally wrong, but like
this you need special functions for each class, e.g. get_color for colors,
get_font for fonts etc. If there's a new type, the themer must be updated. E.g.
if in future we need QPixmaps, a get_pixmap function must be added.
OTOH if the themer would have one function get_value(object, property), return
the value as a string, and leave it to the source code to interpret it, we
would be much more flexible. The above XML could looke like this for example:
<object name="VUMeter" >
<property name="color:background" value="#99aaff" />
<property name="gradient:background" value="#ffffff;#cccccc" />
<property name="font:cliptitle" value="(whatever QFont::toString()
returns)" />
</object>
At first this looks much less convenient, especially because decoding the value
of e.g. a gradient requires some effort. Getting a font value would be:
QString s = themer()->get_value("VUMeter", "font:cliptitle");
QFont f;
f.fromString(s);
But if we later decide to have more properties, e.g. by adding a background
pixmap, the changes would be trivial:
<object name="VUMeter" >
<property name="color:background" value="#99aaff" />
<property name="gradient:background" value="#ffffff;#cccccc" />
<property name="font:cliptitle" value="(whatever QFont::toString()
returns)" />
<property name="pixmap:bg_tile" value="/usr/share/traverso/bg.png"
/>
</object>
Loading the pixmap would be:
QString s = themer()->get_value("VUMeter", "pixmap:bg_tile");
QPixmap p(s);
No modifications to themer required.
For very difficult cases we still could add helper functions, e.g. for gradients
QGradient g = themer()->get_value("VUMeter",
"gradient:background").toGradient()
which would do the decoding.
It's a bit like QSettings, which always returns QVariant and uses QVariant's
casting functions to convert it to a different type.
I hope that's not utter nonsense... ;-)
Regards
Nic
--
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail