Icon themes for pure Qt applications
Recently, I went to package the JuffEd text editor for Ubuntu (it’s on REVU now), and I was surprised that it used bundled Tango icons by default. Then I looked at the code and saw that support for XDG icon themes was really hackish, and didn’t work with inherited themes such as gnome-colors flavors.
It’s strange that support for “stock icons” is not in Qt, unlike GTK, but still, I’d like non-KDE Qt applications to support them properly. So, yesterday, I wrote a small library to properly implement the icon theme specification.
If you’re writing a Qt application dealing with icons, there are two classes of note in that library:
XdgIconManagerkeeps the list of themes installed in the system, and returns themes by human-readable names or directory names, or the user’s default theme.XdgIconThemelooks up icons by names such asdocument-newand returns the full path to the file. If used from GUI applications, it can also return aQPixmap, rescaled to the required size if there is no exact match.