Reply to topic

Mini howto: systray icons with text color

User avatar notmart
KDE Developer
Posts
220
Karma
1
OS
Hi all,
I'm posting here in a new thread a small description on how to make systray icons that follow whatever text color is defined in the plasma theme.
It's a bit complicated, but since is a repetitive job shouldn't be hard after getting used (and if doesn't work, i can fix them as well afterwards)

First of all, a good news. This already works in plasma1, so will be easier to test (for the current icons, to be really sure it was working i did a theme with red text ;)

An example of an icon "treated" is:
http://quickgit.kde.org/?p=plasma-frame ... gz&o=plain

this is just the kmix icon from the current plasma next theme.

* open that audio.svgz icon
* go in the xml view (yep we'll have to use a lot of it ;) ctrl+shift+x
* open the node <svg:defs id=""> (the id will be different for each file, that's not important
* open the subnode <svg:style id="current-color-scheme">
* under it there is a text node that just look like a normal stylesheet, that would just have to be copied and pasted on all the icons
* replicate this in your icon (new element node under its <svg:defs> node then new text node, and paste the stylesheet, adjusting .ColorScheme-Text can make an idea how the final icon will look directly in inkscape

now, the actual graphic elements:
* select a shape (the <svg:path> node, not the group)
* locate in the panel on the right hand, an attribute called "style", create if it doesn't exists
* put fill:currentColor as value for style, deleting everything that was already there
* add a new attribute, "class" and give it the value "ColorScheme-Text"

at this point, on plasma that shape will always be rendered with the text color.
transparency can be adjusted, but not as the color transparency (the color sliders can't be touched anymore at this point or will break) but as the opacity of the shape
kdeuserk
Registered Member
Posts
207
Karma
0
Great! Thank you for that howto!

Do you think something similar could be created for widget applications? There could be two options doing this: Either transforming the whole icon set when the color setting of icons is selected in System settings or rendering it in the application directly.
I think the latter one would have the disadvantage of gtk applications not being able to do this, so you would be able to set a dark theme for gtk applications, but not a icon color suited for dark backgrounds.
Furthermore the latter one would not require any changes in the applications themselves.

What do you think?
User avatar notmart
KDE Developer
Posts
220
Karma
1
OS
kdeuserk wrote:Great! Thank you for that howto!

Do you think something similar could be created for widget applications? There could be two options doing this: Either transforming the whole icon set when the color setting of icons is selected in System settings or rendering it in the application directly.


Do you mean for widgets as in buttons and so on in plasma or for the icons in applications?

things like buttons may use that, as long they don't have gradients or embedded pixmaps (the guidelines so far for widgets to be very flat would help to allow this, at least in part)

icons in applications are pretty much forced to be png (maybe technically feasible for some applications, but not sure is overly a good idea)
kdeuserk
Registered Member
Posts
207
Karma
0
Both :-)

I was mainly referring to icons in applications.
Idea would have been: Not the application is responsible for setting the color depending on the text color, but a process triggered when setting either the color scheme of widgets or the icon theme in system settings: This would rebuilt the icon set used by application to use the color.
On my machine I can use svg icons just fine most of the time. Is png still needed with today's standards?
Even if png was needed, it should not be that complicated to convert the svgs with set color to png, but it would certainly take longer and take up more disk space.
So even if someone was willing to implement this, it would need to be optional.
So we would need kind of a icon cache.

The benefits would be clear: Monochrome icon sets will always be "readable".
Of course the icon set used, would have to support that, as in case of plasma.
User avatar notmart
KDE Developer
Posts
220
Karma
1
OS
kdeuserk wrote:Both :-)

I was mainly referring to icons in applications.
Idea would have been: Not the application is responsible for setting the color depending on the text color, but a process triggered when setting either the color scheme of widgets or the icon theme in system settings: This would rebuilt the icon set used by application to use the color.
On my machine I can use svg icons just fine most of the time. Is png still needed with today's standards?
Even if png was needed, it should not be that complicated to convert the svgs with set color to png, but it would certainly take longer and take up more disk space.
So even if someone was willing to implement this, it would need to be optional.
So we would need kind of a icon cache.

The benefits would be clear: Monochrome icon sets will always be "readable".
Of course the icon set used, would have to support that, as in case of plasma.


for plasma widgets, i think it's definitely worth a try. Only thing it pretty much forbids from using gradients, but that's not necessarly a bad thing :p

for icons there are two problems:
* most applications cannot depend from the plasma library that is needed to do this trick for stylesheets on svgs
* and since the svg support in Qt and plasma is very limited, it isn't enough for most of the icons. for sure not for oxygen ones.
The new icon set will probably be much simpler but unlikely to completely fit the limited tinysvg specification qt uses. (and even if it was supported, some oxygen icons take minutes to render with inkscape even with decent cpus)

I think that some toolbar icons would be nice if they were rendered as svgs with dynamic colors... technically is still an open problem tough.
kdeuserk
Registered Member
Posts
207
Karma
0
Thanks for your replies!

That was the reason why I described a "second" option: Suppose you have a compatible svg icon set (with all the identifiers for the elements which colors should be flexible): Now you have a tool that converts you that icon set to use the colors you specify in system settings for applications.
So in the end, the application has to do nothing but using the by the tool manipulated icon set to fit the current color scheme. So this would be done global. It would be like rebuilding an icon cache.

Usage example: You select a dark theme for applications. Now our "tool" is triggered that recolors our icon set, for the use in applications. We could also convert the recolored svgs to pngs if that would be beneficial (because you stated, png is still the better option).

I am having difficulties with describing exactly what I think. I hope you get the point.

Looking forward to hearing your feedback!

(Of course the approach you are thinking of would be ideal, but very limited: GTK applications for example would not support that and existing Qt/KDE application would have to be modified. My idea is, if you change the color scheme of oxygen for example, the icon set should be "rebuilt"/recolored to be compatible to the selected color scheme, so even gtk applications would fit just perfectly, even if neither of the applications support special render settings for svgs on their own.)

 
Reply to topic

Bookmarks



Who is online

Registered users: acrux, Baidu [Spider], bassamanator, Bing [Bot], Google [Bot], ipwizard, norobot, pareekyashovardhan, samidon, Sogou [Bot], zachalexy