]> git.lyx.org Git - features.git/commitdiff
Fix using system theme icons with Qt 5 (#10052)
authorScott Kostyshak <skostysh@lyx.org>
Mon, 23 May 2016 00:39:46 +0000 (20:39 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Mon, 23 May 2016 00:56:12 +0000 (20:56 -0400)
With Qt 5, our code did not correctly detect when icons were
available and thus tried to use nonexistent icons.

QIcon::hasThemeIcon(theme_icon) returns true when theme_icon is
empty. We now rely on the behavior that QIcon::isNull() returns true
if the icon is empty.

The same code is used with Qt 4 and Qt 5.

src/frontends/qt4/GuiApplication.cpp

index 6fb5499981d07fdf36eb972153b98f4f84dbab46..8b613794df03bfbe45baeb78d251d41d0a3dbadd 100644 (file)
@@ -600,12 +600,16 @@ QIcon getIcon(FuncRequest const & f, bool unknown)
 {
 #if (QT_VERSION >= 0x040600)
        if (lyxrc.use_system_theme_icons) {
+               // use the icons from system theme that are available
                QString action = toqstr(lyxaction.getActionName(f.action()));
                if (!f.argument().empty())
                        action += " " + toqstr(f.argument());
                QString const theme_icon = themeIconName(action);
-               if (QIcon::hasThemeIcon(theme_icon))
-                       return QIcon::fromTheme(theme_icon);
+               if (QIcon::hasThemeIcon(theme_icon)) {
+                       QIcon const thmicn = QIcon::fromTheme(theme_icon);
+                       if (!thmicn.isNull())
+                               return thmicn;
+               }
        }
 #endif