PDA

View Full Version : user option to change SVG icon color



ravas
1st June 2016, 07:30
I'd like to allow users to change the color of all the actions' icons, which are SVG.
I understand that I just need to loop through the icons and do a string replacement,
but I don't know how to access each action's SVG data.
QIcon doesn't seem to offer a way to get the file path.

I guess I could just subclass QIcon and add a public file path attribute...

anda_skoa
1st June 2016, 08:43
You could also attach the file name as a dynamic property on each action.

Cheers,
_

ravas
8th June 2016, 20:49
That's a useful feature -- I didn't know about it.

So I've figured out how to read the data and change it,
but I'm uncertain of the proper way to update the action's icon.
Do I need to save it as a temporary file and then give that path to QIcon?
I'd rather not edit the resource file (if that's even possible).

Does QIcon convert SVG into a pixmap anyhow?
Would converting the data to a pixmap be preferable?

ravas
9th June 2016, 05:05
I've decided to allow users to generate an alternative set of icons in the folder of their choice.

anda_skoa
9th June 2016, 07:07
Do I need to save it as a temporary file and then give that path to QIcon?

If you look at the documentation of QIcon, you will see that is has more than one constructor.



I'd rather not edit the resource file (if that's even possible).

No, that wouldn't even be possible.
Resources are part of the program's binary code.



Does QIcon convert SVG into a pixmap anyhow?

Very likely.



Would converting the data to a pixmap be preferable?
Preferable to what?

Cheers,
_

ravas
9th June 2016, 18:14
I did look at the QIcon constructor list; that's why I asked about converting to pixmap.
But nevermind... it was an errant thought. I'm happy generating an alternative set (the full set isn't even 1mb).