RFC: Herding your program’s icons, how?

Friedrich W. H. Kossebau kossebau at kde.org
Thu Apr 26 14:36:41 BST 2012


(cc: to kde-bindings for heads-up, follow-ups please only on kde-core-devel)

How to get all icon-ids in your codebase?

Just blogged* about this, but then more something for this ml.

* http://frinring.wordpress.com/2012/04/26/herding-your-programs-icons-how/

When seeing for the icon-ids used in Calligra, I have used a simple approach 
to get at least most of them, doing a grep for lines with “KIcon(“. That gave 
me more than 1000 lines for Calligra, and almost all also directly used an 
icon-id, so there was chance to do a check and create a report for these.

Now this is quite unsatisfying to not be able to easily get a list of _all_ 
the icon resources used in your codebase, and having to do manually extraction 
is not nice. How do you deal with this in your project?


Ideally icon-ids would be kind-of tagged when used, so like gettext is able to 
extract all strings which need a translation, some geticon would be able to 
extract all icon-ids. The result could then be used to check the icon-ids 
against the icons available from the icon themes and the icons installed from 
the project itself, ideally automatically (as doing that manually is… pretty 
boring, time-consuming and error-prone).

I could imagine that there could be some macros




which would resolve to

    KIcon(QLatin1String("some-icon"))  // kicon("...") is even more readable



and would enable to automatically extract these icon-ids (with metadata like 
file, line, etc). It should be backward-compatible, as it is just some mark-up 
which resolves to what there was before. And while there is nothing to enforce 
that all icon-ids are marked up, the same problem exists with i18n, so 
something we are okay with.

With that markup IDEs might be even able to check the validness of icon-ids or 
offer code-completion, perhaps even with preview of the actual icon :) 


What about icons used in UI files, will they still pass KIconLoader or 
whatever makes the icon being picked from the usual places?

Are there other usages of icon-ids which might not be catchable this way?

Would something similar work for non-C++ languages?

What could be better keywords for the macros?

What do you think in general? Comments, other/better proposals welcome!


More information about the kde-core-devel mailing list