[Interest] pre-processing for Qt widget stylesheet

Hamish Moffatt hamish at risingsoftware.com
Fri Aug 14 09:02:25 CEST 2015


On 12/08/15 17:01, Alejandro Exojo wrote:
> The problem is that Sass is more than a template engine. Is a language crafted
> for generating CSS. It has functions for colors, understands selector
> inheritance, and a lot more. See for example:
>
> http://sassymothereffingtextshadow.com/
>
> OK, probably not the best example, since very rarely you make use of loops in
> Sass code. The next is something not easily achievable with a normal template
> language, and is one of the most interesting use cases:
>
> http://sass-lang.com/guide#topic-3
>
> The only solution I can think of, unless libsass has hooks for extension
> points for your problems, is pre and post process the Sass/CSS code. Try to
> see if there is some way that you can "tag" the elements with the invalid
> pseudo-classes (a diferent pseudo-class or an ad-hoc class that you use for
> that), and use some regular expression to do replacements.
>

I found a one line change to the libsass sources to allow the 
"!selected" selector, and a workaround for the rgba issue, so now I have 
libsass working on my application.

This makes maintaining a complex style sheet much easier: variables for 
colours, much easier to read descriptions of various states etc. Next 
I'll start making use of maths and constants to take my screen dpi into 
effect.

With regard to Konstantin's suggestion to pre-compile the stylesheet for 
different DPI settings, that doesn't really work - Windows allows the 
user to choose any custom font scaling they want. 100% ("96 dpi"), 125% 
("120 dpi") and 150% ("144 dpi") are just the presets.


Hamish



More information about the Interest mailing list