Implementing desktop icons

Asked by Richard Qian

Instead of using builtin svg icons (which can look blurred when shrinked enough), is there a way of implementing desktop icons used in most GTK and KDE programs (as in /usr/share/icons/) in this program? This could allow qpdfview to integrate better with the rest of the desktop (as of having a unified look and feel) and potentially allow for using smaller icon sizes.

Question information

Language:
English Edit question
Status:
Solved
For:
qpdfview Edit question
Assignee:
No assignee Edit question
Solved by:
Adam Reichold
Solved:
Last query:
Last reply:
Revision history for this message
Best Adam Reichold (adamreichold) said :
#1

Hello Richard,

qpdfview will already prefer to use any installed FreeDesktop.org-compliant icon theme over its own fallback icons, i.e. it only uses the SVG icons if no system-wide icon themes are found. There are two exceptions to this: The application-specific icons which have no counterpart in the icon naming specification. And depending on the desktop environment or window manager you use, Qt will sometimes be unable to detect your icon theme. (I think a user of LXDE was the first to report such problems.)

However, there is a workaround for the second problem: You manually specify the name of your preferred icon theme by setting "iconTheme=nameOfYourPreferredIconTheme" in the section "[mainWindow]" of qpdfview's main configuration file, usually located at "~/.config/qpdfview/qpdfview.conf". (If you need more detailed instructions how to do this, just ask or maybe try to search the archive of the mailing list [1].)

Best regards, Adam.

[1] https://launchpad.net/~qpdfview

Revision history for this message
Richard Qian (worldblender) said :
#2

I folllowed your advice, and I got a specific icon theme to work. Now for the problem 2, if Qt is unable to detect my icon theme, then what is there that I can do to manually set the icon theme for all other Qt-only programs?

Revision history for this message
Richard Qian (worldblender) said :
#3

Thanks Adam Reichold, that solved my question.

Revision history for this message
Adam Reichold (adamreichold) said :
#4

Hello again,

I don't think there is a generic solution on the application level, but you could of course try to fix Qt's icon theme detection. The exact preconditions under which this works are not clear to me yet, but I think you will need "gconf" and/or a suitable "gtkrc" present on your system. Some people also reported that they had to set environment variables, but I don't really remember. I suggest searching various forums for the details. (Or if this is really important to you, the details can be found in method "QGuiPlatformPlugin::systemIconThemeName()" in file "src/gui/kernel/qguiplatformplugin.cpp" of the Qt 4 source.)

The application itself setting the name of the icon theme that will be requested by Qt is a workaround at best. We only added this, because the situation seems somewhat unclear and it could possibly spare some users a "gconf" dependency.

Regards, Adam.

Revision history for this message
Richard Qian (worldblender) said :
#5

In case that I would like to contribute code to other Qt-only applications, what code is there I can use or implement that will help any Qt-only application use freedesktop.org compliant icon themes?

Revision history for this message
Adam Reichold (adamreichold) said :
#6

Hello Richard,

if by that you mean where in qpdfview the icon theme is requested, this e.g. is lines 92 to 95 in "mainwindow.cpp" using the settings proxy defined in "settings.{h,cpp}". But basically, it comes down to calling "QIcon::setThemeName(QString)" with a name that is obtained via explicit configuration or by parsing the configuration files of the desktop environment or window manager in question. Hope this helps...

Best regards, Adam.

P.S.: Of course, I think improving the icon theme detection in Qt would be the best way forward as all Qt-only application would benefit from this.