LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-30-2021, 10:35 PM   #1
kingbeowulf
Senior Member
 
Registered: Oct 2003
Location: WA
Distribution: Slackware
Posts: 1,112
Blog Entries: 11

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Exclamation mumble-1.3.4 missing SVG icons in Slackware64-Current (15.0)


Building mumble-1.3.4 for a Slackbuilds.org update, I also tested on 64-but Current and noted a whole host of mssing icons in the menu, themes. It looks like the KDE Frameworks 5 package kiconthemes-5.80.0 broke SVG icon display. Downgrading to kiconthemes-5.79.0 fixes the issue. This seems to effect some other non-KDE5 QT5 application as well. Details:

Missing icons with KDE Frameworks 5.80.0 #4853
Bug 434451 - SVG icons in custom Qt application stopped rendering

Figuring out how to patch this is a bit beyond skill given KDE's build complexity. A comparison between master and v.5.80.0 with numerous fixes, including this one, is here:
https://github.com/KDE/kiconthemes/c....80.0...master
 
Old 03-30-2021, 11:31 PM   #2
kingbeowulf
Senior Member
 
Registered: Oct 2003
Location: WA
Distribution: Slackware
Posts: 1,112

Original Poster
Blog Entries: 11

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
yay! I got it to work. patched kiconthemes-5.80.0 with patch diff from master and the icons are back. whoop! Finally took the time to figure out the KDE build tree. It's pretty well documented!
  1. Add patch to source/kde/kde/patch/kiconthemes/kiconthemes.patch
  2. Create source/kde/kde/patch/kiconthemes.patch command file
  3. Run build
  4. Profit!
Patch to include all commits from v5.80.0 to master for source/kde/kde/patch/kiconthemes/kiconthemes.patch:
Code:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd6f360..02cd717 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.5)
 
-set(KF_VERSION "5.80.0") # handled by release scripts
+set(KF_VERSION "5.81.0") # handled by release scripts
 set(KF_DEP_VERSION "5.80.0") # handled by release scripts
 project(KIconThemes VERSION ${KF_VERSION})
 
@@ -56,7 +56,7 @@ find_package(KF5ItemViews ${KF_DEP_VERSION} REQUIRED)
 remove_definitions(-DQT_NO_CAST_FROM_ASCII)
 remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
 add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
-add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054F00)
+add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055000)
 add_definitions(-DQT_NO_FOREACH)
 
 add_definitions(-DTRANSLATION_DOMAIN=\"kiconthemes5\")
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 579c246..c820130 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -16,6 +16,7 @@ kiconthemes_tests(
   kiconloader_resourcethemetest
   kicontheme_unittest
   kiconengine_unittest
+  kiconengine_scaled_unittest
   kicondialog_unittest
 )
 
diff --git a/autotests/kiconengine_scaled_unittest.cpp b/autotests/kiconengine_scaled_unittest.cpp
new file mode 100644
index 0000000..e7e3e89
--- /dev/null
+++ b/autotests/kiconengine_scaled_unittest.cpp
@@ -0,0 +1,58 @@
+/*
+    SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
+
+    SPDX-License-Identifier: LGPL-2.0-or-later
+*/
+
+#include <QStandardPaths>
+#include <QTest>
+
+#include <KIconEngine>
+#include <KIconLoader>
+
+static int setupEnvBeforeQApplication = []() {
+    qunsetenv("QT_SCREEN_SCALE_FACTORS");
+    qputenv("QT_SCALE_FACTOR", "2.0");
+    return 1;
+}();
+
+class KIconEngine_Scaled_UnitTest : public QObject
+{
+    Q_OBJECT
+
+private Q_SLOTS:
+    void initTestCase()
+    {
+        QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+        QStandardPaths::setTestModeEnabled(true);
+    }
+
+    void testCenterIcon()
+    {
+        QIcon icon(new KIconEngine(QStringLiteral(":/test-22x22.png"), KIconLoader::global()));
+        QVERIFY(!icon.isNull());
+
+        QWindow w;
+        QCOMPARE(w.devicePixelRatio(), 2.0);
+        auto image = icon.pixmap(&w, QSize(22, 22)).toImage();
+        QCOMPARE(image.devicePixelRatio(), 2.0);
+        QCOMPARE(image.size(), QSize(44, 44));
+
+        QImage unscaled;
+        QVERIFY(unscaled.load(QStringLiteral(":/test-22x22.png")));
+        QVERIFY(!unscaled.isNull());
+        QCOMPARE(unscaled.size(), QSize(22, 22));
+        unscaled.setDevicePixelRatio(2.0);
+        unscaled = unscaled.convertToFormat(image.format()).scaled(44, 44, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+        QCOMPARE(image, unscaled);
+
+        // center vertically
+        QVERIFY(icon.pixmap(&w, QSize(22, 26)).toImage().copy(0, 4, 44, 44) == image);
+        // center horizontally
+        QVERIFY(icon.pixmap(&w, QSize(26, 22)).toImage().copy(4, 0, 44, 44) == image);
+    }
+};
+
+QTEST_MAIN(KIconEngine_Scaled_UnitTest)
+
+#include "kiconengine_scaled_unittest.moc"
diff --git a/autotests/kiconengine_unittest.cpp b/autotests/kiconengine_unittest.cpp
index ad215f7..66ec455 100644
--- a/autotests/kiconengine_unittest.cpp
+++ b/autotests/kiconengine_unittest.cpp
@@ -122,6 +122,26 @@ private Q_SLOTS:
         QVERIFY(icon.pixmap(26, 22).toImage().copy(2, 0, 22, 22) == image);
     }
 
+    void testNonSquareSvg()
+    {
+        QIcon icon(new KIconEngine(QStringLiteral(":/nonsquare.svg"), KIconLoader::global()));
+        QVERIFY(!icon.isNull());
+
+        // verify we get the content fully fitted in when asking for the right aspect ratio
+        const QImage image = icon.pixmap(40, 20).toImage();
+        QCOMPARE(image.pixelColor(0, 0), QColor(255, 0, 0));
+        QCOMPARE(image.pixelColor(19, 9), QColor(255, 0, 0));
+        QCOMPARE(image.pixelColor(39, 0), QColor(0, 255, 0));
+        QCOMPARE(image.pixelColor(20, 9), QColor(0, 255, 0));
+        QCOMPARE(image.pixelColor(0, 19), QColor(0, 0, 255));
+        QCOMPARE(image.pixelColor(19, 10), QColor(0, 0, 255));
+        QCOMPARE(image.pixelColor(39, 19), QColor(255, 255, 0));
+        QCOMPARE(image.pixelColor(20, 10), QColor(255, 255, 0));
+
+        // and now with a wrong aspect ratio
+        QCOMPARE(icon.pixmap(40, 40).toImage().convertToFormat(image.format()).copy(0, 10, 40, 20), image);
+    }
+
 private:
     QDir testIconsDir;
 };
diff --git a/autotests/kiconloader_unittest.cpp b/autotests/kiconloader_unittest.cpp
index ab6b641..813215d 100644
--- a/autotests/kiconloader_unittest.cpp
+++ b/autotests/kiconloader_unittest.cpp
@@ -7,6 +7,7 @@
 
 #include <kiconloader.h>
 
+#include <QDir>
 #include <QRegularExpression>
 #include <QStandardPaths>
 #include <QTest>
@@ -255,9 +256,10 @@ private Q_SLOTS:
             QPixmap pix = icon.pixmap(QSize(22, 22));
             QVERIFY(!pix.isNull());
         }
-        QCOMPARE(icon.actualSize(QSize(96, 22)), QSize(22, 22));
-        QCOMPARE(icon.actualSize(QSize(22, 96)), QSize(22, 22));
-        QCOMPARE(icon.actualSize(QSize(22, 16)), QSize(16, 16));
+        // Qt's implementation of actualSize does not crop to squares, ensure we don't do that either
+        QCOMPARE(icon.actualSize(QSize(96, 22)), QSize(96, 22));
+        QCOMPARE(icon.actualSize(QSize(22, 96)), QSize(22, 96));
+        QCOMPARE(icon.actualSize(QSize(22, 16)), QSize(22, 16));
 
         // Can we ask for a really small size?
         {
@@ -494,6 +496,20 @@ private Q_SLOTS:
         uintToHex(testColorWithAlpha.rgba(), argbHex.data());
         QCOMPARE(argbHex, QStringLiteral("7b6496c8"));
     }
+
+    void testQDirSetSearchPaths()
+    {
+        // setup search path for testprefix: => we shall find the iconinspecialsearchpath.svg afterwards, see e.g. bug 434451
+        QDir::setSearchPaths("testprefix", QStringList(":/searchpathdefineddir"));
+        QPixmap pix = KIconLoader::global()->loadIcon(QStringLiteral("testprefix:iconinspecialsearchpath.svg"),
+                                                      KIconLoader::NoGroup,
+                                                      24,
+                                                      KIconLoader::DefaultState,
+                                                      QStringList(),
+                                                      nullptr,
+                                                      true);
+        QVERIFY(!pix.isNull());
+    }
 };
 
 QTEST_MAIN(KIconLoader_UnitTest)
diff --git a/autotests/nonsquare.svg b/autotests/nonsquare.svg
new file mode 100644
index 0000000..18a4c3b
--- /dev/null
+++ b/autotests/nonsquare.svg
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    SPDX-License-Identifier: CC0-1.0
+    SPDX-FileCopyrightText: none
+-->
+<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="20" height="10" version="1.1">
+    <rect y="0" x="0" height="5" width="10" style="fill:#ff0000;fill-opacity:1;stroke:none"/>
+    <rect y="0" x="10" height="5" width="10" style="fill:#00ff00;fill-opacity:1;stroke:none"/>
+    <rect y="5" x="0" height="5" width="10" style="fill:#0000ff;fill-opacity:1;stroke:none"/>
+    <rect y="5" x="10" height="5" width="10" style="fill:#ffff00;fill-opacity:1;stroke:none"/>
+</svg>
diff --git a/autotests/resources.qrc b/autotests/resources.qrc
index 8ac73d1..4f4cd0c 100644
--- a/autotests/resources.qrc
+++ b/autotests/resources.qrc
@@ -7,7 +7,9 @@
     <file>oxygen.theme</file>
     <file>breeze.theme</file>
     <file>coloredsvgicon.svg</file>
+    <file>nonsquare.svg</file>
     <file alias="/icons/themeinresource/index.theme">breeze.theme</file>
     <file alias="/icons/themeinresource/22x22/appsNoContext/someiconintheme.png">test-22x22.png</file>
+    <file alias="/searchpathdefineddir/iconinspecialsearchpath.svg">coloredsvgicon.svg</file>
 </qresource>
 </RCC>
diff --git a/src/kiconengine.cpp b/src/kiconengine.cpp
index 27a757c..3fb9479 100644
--- a/src/kiconengine.cpp
+++ b/src/kiconengine.cpp
@@ -47,10 +47,7 @@ static inline int qIconModeToKIconState(QIcon::Mode mode)
 
 QSize KIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
 {
-    Q_UNUSED(state)
-    Q_UNUSED(mode)
-    const int iconSize = qMin(size.width(), size.height());
-    return QSize(iconSize, iconSize);
+    return QIconEngine::actualSize(size, mode, state);
 }
 
 void KIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
@@ -85,21 +82,22 @@ QPixmap KIconEngine::createPixmap(const QSize &size, qreal scale, QIcon::Mode mo
     const QSize scaledSize = size / scale;
 
     const int kstate = qIconModeToKIconState(mode);
-    const int iconSize = qMin(scaledSize.width(), scaledSize.height());
-    QPixmap pix = mIconLoader.data()->loadScaledIcon(mIconName, KIconLoader::Desktop, scale, iconSize, kstate, mOverlays);
+    QPixmap pix = mIconLoader.data()->loadScaledIcon(mIconName, KIconLoader::Desktop, scale, scaledSize, kstate, mOverlays);
 
     if (pix.size() == size) {
         return pix;
     }
 
     QPixmap pix2(size);
-    auto dpr = pix.devicePixelRatio();
-    pix2.setDevicePixelRatio(dpr);
+    pix2.setDevicePixelRatio(scale);
     pix2.fill(QColor(0, 0, 0, 0));
 
     QPainter painter(&pix2);
-    const QPoint newTopLeft((pix2.width() - pix.width()) / (2 * dpr), (pix2.height() - pix.height()) / (2 * dpr));
-    painter.drawPixmap(newTopLeft, pix);
+    painter.setRenderHint(QPainter::SmoothPixmapTransform);
+    const QSizeF targetSize = pix.size().scaled(scaledSize, Qt::KeepAspectRatio);
+    QRectF targetRect({0, 0}, targetSize);
+    targetRect.moveCenter(QRectF(pix2.rect()).center() / scale);
+    painter.drawPixmap(targetRect, pix, pix.rect());
 
     return pix2;
 }
diff --git a/src/kiconengineplugin.json b/src/kiconengineplugin.json
index a5b4228..bc09e41 100644
--- a/src/kiconengineplugin.json
+++ b/src/kiconengineplugin.json
@@ -1,4 +1,4 @@
 {
-    "Keys": [ "KIconEngine", "svg", "svgz", "svg.gz" ]
+    "Keys": [ "KIconEngine" ]
 }
 
diff --git a/src/kiconloader.cpp b/src/kiconloader.cpp
index 2c2def3..3a6bf2b 100644
--- a/src/kiconloader.cpp
+++ b/src/kiconloader.cpp
@@ -92,19 +92,6 @@ color:%7;\
 }
 }
 
-/**
- * Checks for relative paths quickly on UNIX-alikes, slowly on everything else.
- */
-static bool pathIsRelative(const QString &path)
-{
-#ifdef Q_OS_UNIX
-    // catch both /xxx/yyy and :/xxx/yyy for resources
-    return (!path.isEmpty() && path[0] != QLatin1Char('/') && path[0] != QLatin1Char(':'));
-#else
-    return QDir::isRelativePath(path);
-#endif
-}
-
 /**
  * Holds a QPixmap for this process, along with its associated path on disk.
  */
@@ -238,7 +225,7 @@ class KIconLoaderPrivate
     /**
      * @internal
      */
-    bool initIconThemes();
+    void initIconThemes();
 
     /**
      * @internal
@@ -307,14 +294,14 @@ class KIconLoaderPrivate
      * and icon state information to valid states. All parameters except the
      * name can be modified as well to be valid.
      */
-    void normalizeIconMetadata(KIconLoader::Group &group, int &size, int &state) const;
+    void normalizeIconMetadata(KIconLoader::Group &group, QSize &size, int &state) const;
 
     /**
      * @internal
      * Used with KIconLoader::loadIcon to get a base key name from the given
      * icon metadata. Ensure the metadata is normalized first.
      */
-    QString makeCacheKey(const QString &name, KIconLoader::Group group, const QStringList &overlays, int size, qreal scale, int state) const;
+    QString makeCacheKey(const QString &name, KIconLoader::Group group, const QStringList &overlays, const QSize &size, qreal scale, int state) const;
 
     /**
      * @internal
@@ -331,7 +318,7 @@ class KIconLoaderPrivate
      * @p size is only used for scalable images, but if non-zero non-scalable
      * images will be resized anyways.
      */
-    QImage createIconImage(const QString &path, int size = 0, qreal scale = 1.0, KIconLoader::States state = KIconLoader::DefaultState);
+    QImage createIconImage(const QString &path, const QSize &size = {}, qreal scale = 1.0, KIconLoader::States state = KIconLoader::DefaultState);
 
     /**
      * @internal
@@ -640,11 +627,10 @@ void KIconLoaderPrivate::init(const QString &_appname, const QStringList &extraS
     }
 }
 
-bool KIconLoaderPrivate::initIconThemes()
+void KIconLoaderPrivate::initIconThemes()
 {
     if (mIconThemeInited) {
-        // If mpThemeRoot isn't 0 then initing has succeeded
-        return (mpThemeRoot != nullptr);
+        return;
     }
     // qCDebug(KICONTHEMES);
     mIconThemeInited = true;
@@ -655,12 +641,10 @@ bool KIconLoaderPrivate::initIconThemes()
         delete def;
         // warn, as this is actually a small penalty hit
         qCDebug(KICONTHEMES) << "Couldn't find current icon theme, falling back to default.";
+
+        // this can't fail, as defaultThemeName() == hicolor is in a resource of this library itself as last fallback!
         def = new KIconTheme(KIconTheme::defaultThemeName(), appname);
-        if (!def->isValid()) {
-            qWarning() << "Error: standard icon theme" << KIconTheme::defaultThemeName() << "not found!";
-            delete def;
-            return false;
-        }
+        Q_ASSERT(def->isValid());
     }
     mpThemeRoot = new KIconThemeNode(def);
     mThemesInTree.append(def->internalName());
@@ -674,8 +658,6 @@ bool KIconLoaderPrivate::initIconThemes()
     searchPaths.append(QStringLiteral("icons")); // was xdgdata-icon in KStandardDirs
     // These are not in the icon spec, but e.g. GNOME puts some icons there anyway.
     searchPaths.append(QStringLiteral("pixmaps")); // was xdgdata-pixmaps in KStandardDirs
-
-    return true;
 }
 
 KIconLoader::~KIconLoader() = default;
@@ -832,15 +814,15 @@ QString KIconLoaderPrivate::removeIconExtension(const QString &name) const
     return name;
 }
 
-void KIconLoaderPrivate::normalizeIconMetadata(KIconLoader::Group &group, int &size, int &state) const
+void KIconLoaderPrivate::normalizeIconMetadata(KIconLoader::Group &group, QSize &size, int &state) const
 {
     if ((state < 0) || (state >= KIconLoader::LastState)) {
         qWarning() << "Illegal icon state:" << state;
         state = KIconLoader::DefaultState;
     }
 
-    if (size < 0) {
-        size = 0;
+    if (size.width() < 0 || size.height() < 0) {
+        size = {};
     }
 
     // For "User" icons, bail early since the size should be based on the size on disk,
@@ -855,16 +837,16 @@ void KIconLoaderPrivate::normalizeIconMetadata(KIconLoader::Group &group, int &s
     }
 
     // If size == 0, use default size for the specified group.
-    if (size == 0) {
+    if (size.isNull()) {
         if (group < 0) {
             qWarning() << "Neither size nor group specified!";
             group = KIconLoader::Desktop;
         }
-        size = mpGroups[group].size;
+        size = QSize(mpGroups[group].size, mpGroups[group].size);
     }
 }
 
-QString KIconLoaderPrivate::makeCacheKey(const QString &name, KIconLoader::Group group, const QStringList &overlays, int size, qreal scale, int state) const
+QString KIconLoaderPrivate::makeCacheKey(const QString &name, KIconLoader::Group group, const QStringList &overlays, const QSize &size, qreal scale, int state) const
 {
     // The KSharedDataCache is shared so add some namespacing. The following code
     // uses QStringBuilder (new in Qt 4.6)
@@ -873,7 +855,7 @@ QString KIconLoaderPrivate::makeCacheKey(const QString &name, KIconLoader::Group
     return (group == KIconLoader::User ? QLatin1String("$kicou_") : QLatin1String("$kico_"))
             % name
             % QLatin1Char('_')
-            % QString::number(size)
+            % (size.width() == size.height() ? QString::number(size.height()) : QString::number(size.height()) % QLatin1Char('x') % QString::number(size.width()))
             % QLatin1Char('@')
             % QString::number(scale, 'f', 1)
             % QLatin1Char('_')
@@ -939,13 +921,13 @@ QByteArray KIconLoaderPrivate::processSvg(const QString &path, KIconLoader::Stat
     return processedContents;
 }
 
-QImage KIconLoaderPrivate::createIconImage(const QString &path, int size, qreal scale, KIconLoader::States state)
+QImage KIconLoaderPrivate::createIconImage(const QString &path, const QSize &size, qreal scale, KIconLoader::States state)
 {
     // TODO: metadata in the theme to make it do this only if explicitly supported?
     QImageReader reader;
     QBuffer buffer;
 
-    if (q->theme()->followsColorScheme() && (path.endsWith(QLatin1String("svg")) || path.endsWith(QLatin1String("svgz")))) {
+    if (q->theme() && q->theme()->followsColorScheme() && (path.endsWith(QLatin1String("svg")) || path.endsWith(QLatin1String("svgz")))) {
         buffer.setData(processSvg(path, state));
         reader.setDevice(&buffer);
     } else {
@@ -956,8 +938,18 @@ QImage KIconLoaderPrivate::createIconImage(const QString &path, int size, qreal
         return QImage();
     }
 
-    if (size != 0) {
-        reader.setScaledSize(QSize(size * scale, size * scale));
+    if (!size.isNull()) {
+        // ensure we keep aspect ratio
+        const QSize wantedSize = size * scale;
+        QSize finalSize(reader.size());
+        if (finalSize.isNull()) {
+            // nothing to scale
+            finalSize = wantedSize;
+        } else {
+            // like QSvgIconEngine::pixmap try to keep aspect ratio
+            finalSize.scale(wantedSize, Qt::KeepAspectRatio);
+        }
+        reader.setScaledSize(finalSize);
     }
 
     return reader.read();
@@ -1200,15 +1192,14 @@ QString KIconLoader::iconPath(const QString &_name, int group_or_size, bool canR
 
 QString KIconLoader::iconPath(const QString &_name, int group_or_size, bool canReturnNull, qreal scale) const
 {
-    if (!d->initIconThemes()) {
-        return QString();
-    }
-
-    if (_name.isEmpty() || !pathIsRelative(_name)) {
+    // we need to honor resource :/ paths and QDir::searchPaths => use QDir::isAbsolutePath, see bug 434451
+    if (_name.isEmpty() || QDir::isAbsolutePath(_name)) {
         // we have either an absolute path or nothing to work with
         return _name;
     }
 
+    d->initIconThemes();
+
     QString name = d->removeIconExtension(_name);
 
     QString path;
@@ -1303,14 +1294,29 @@ QPixmap KIconLoader::loadScaledIcon(const QString &_name,
                                     const QStringList &overlays,
                                     QString *path_store,
                                     bool canReturnNull) const
+{
+    return loadScaledIcon(_name, group, scale, QSize(size, size), state, overlays, path_store, canReturnNull);
+}
+
+QPixmap KIconLoader::loadScaledIcon(const QString &_name,
+                                    KIconLoader::Group group,
+                                    qreal scale,
+                                    const QSize &_size,
+                                    int state,
+                                    const QStringList &overlays,
+                                    QString *path_store,
+                                    bool canReturnNull) const
+
 {
     QString name = _name;
     bool favIconOverlay = false;
 
-    if (size < 0 || _name.isEmpty()) {
+    if (_size.width() < 0 || _size.height() < 0 || _name.isEmpty()) {
         return QPixmap();
     }
 
+    QSize size = _size;
+
     /*
      * This method works in a kind of pipeline, with the following steps:
      * 1. Sanity checks.
@@ -1327,7 +1333,8 @@ QPixmap KIconLoader::loadScaledIcon(const QString &_name,
         name = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + name + QStringLiteral(".png");
     }
 
-    bool absolutePath = !pathIsRelative(name);
+    // we need to honor resource :/ paths and QDir::searchPaths => use QDir::isAbsolutePath, see bug 434451
+    const bool absolutePath = QDir::isAbsolutePath(name);
     if (!absolutePath) {
         name = d->removeIconExtension(name);
     }
@@ -1367,11 +1374,9 @@ QPixmap KIconLoader::loadScaledIcon(const QString &_name,
     }
 
     // Image is not cached... go find it and apply effects.
-    if (!d->initIconThemes()) {
-        return QPixmap();
-    }
+    d->initIconThemes();
 
-    favIconOverlay = favIconOverlay && size > 22;
+    favIconOverlay = favIconOverlay && std::min(size.height(), size.width()) > 22;
 
     // First we look for non-User icons. If we don't find one we'd search in
     // the User space anyways...
@@ -1379,7 +1384,7 @@ QPixmap KIconLoader::loadScaledIcon(const QString &_name,
         if (absolutePath && !favIconOverlay) {
             path = name;
         } else {
-            path = d->findMatchingIconWithGenericFallbacks(favIconOverlay ? QStringLiteral("text-html") : name, size, scale);
+            path = d->findMatchingIconWithGenericFallbacks(favIconOverlay ? QStringLiteral("text-html") : name, std::min(size.height(), size.width()), scale);
         }
     }
 
@@ -1391,7 +1396,7 @@ QPixmap KIconLoader::loadScaledIcon(const QString &_name,
     // Still can't find it? Use "unknown" if we can't return null.
     // We keep going in the function so we can ensure this result gets cached.
     if (path.isEmpty() && !canReturnNull) {
-        path = d->unknownIconPath(size, scale);
+        path = d->unknownIconPath(std::min(size.height(), size.width()), scale);
         iconWasUnknown = true;
     }
 
diff --git a/src/kiconloader.h b/src/kiconloader.h
index 72a49db..ee92bce 100644
--- a/src/kiconloader.h
+++ b/src/kiconloader.h
@@ -11,6 +11,7 @@
 #define KICONLOADER_H
 
 #include <QObject>
+#include <QSize>
 #include <QString>
 #include <QStringList>
 #include <memory>
@@ -282,6 +283,49 @@ class KICONTHEMES_EXPORT KIconLoader : public QObject
                            QString *path_store = nullptr,
                            bool canReturnNull = false) const;
 
+    /**
+     * Loads an icon. It will try very hard to find an icon which is
+     * suitable. If no exact match is found, a close match is searched.
+     * If neither an exact nor a close match is found, a null pixmap or
+     * the "unknown" pixmap is returned, depending on the value of the
+     * @p canReturnNull parameter.
+     *
+     * @param name The name of the icon, without extension.
+     * @param group The icon group. This will specify the size of and effects to
+     * be applied to the icon.
+     * @param scale The scale of the icon group to use. If no icon exists in the
+     * scaled group, a 1x icon with its size multiplied by the scale will be
+     * loaded instead.
+     * @param size If nonzero, this overrides the size specified by @p group.
+     *             See KIconLoader::StdSizes. The icon will be fit into @p size
+     *             without changing the aspect ratio, which particularly matters
+     *             for non-square icons.
+     * @param state The icon state: @p DefaultState, @p ActiveState or
+     * @p DisabledState. Depending on the user's preferences, the iconloader
+     * may apply a visual effect to hint about its state.
+     * @param overlays a list of emblem icons to overlay, by name
+     *                 @see drawOverlays
+     * @param path_store If not null, the path of the icon is stored here,
+     *        if the icon was found. If the icon was not found @p path_store
+     *        is unaltered even if the "unknown" pixmap was returned.
+     * @param canReturnNull Can return a null pixmap? If false, the
+     *        "unknown" pixmap is returned when no appropriate icon has been
+     *        found. <em>Note:</em> a null pixmap can still be returned in the
+     *        event of invalid parameters, such as empty names, negative sizes,
+     *        and etc.
+     * @return the QPixmap. Can be null when not found, depending on
+     *         @p canReturnNull.
+     * @since 5.81
+     */
+    QPixmap loadScaledIcon(const QString &name,
+                           KIconLoader::Group group,
+                           qreal scale,
+                           const QSize &size = {},
+                           int state = KIconLoader::DefaultState,
+                           const QStringList &overlays = QStringList(),
+                           QString *path_store = nullptr,
+                           bool canReturnNull = false) const;
+
     /**
      * Loads an icon for a mimetype.
      * This is basically like loadIcon except that extra desktop themes are loaded if necessary.
the source/kde/kde/patch/kiconthemes.patch command file to apply the patch:
Code:
# Fix svg icon etc error in non KDE qt5:
cat $CWD/patch/kiconthemes/kiconthemes.patch | patch -p1 --verbose || { touch ${SLACK_KDE_BUILD_DIR}/${PKGNAME}.failed ; continue ; }
Now run the build to create the updated package:
Code:
UPGRADE=no ./kde.SlackBuild frameworks:kiconthemes
New package is located in /tmp/kde_build/
 
3 members found this post helpful.
Old 04-14-2021, 02:38 PM   #3
kingbeowulf
Senior Member
 
Registered: Oct 2003
Location: WA
Distribution: Slackware
Posts: 1,112

Original Poster
Blog Entries: 11

Rep: Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545Reputation: 545
Latest Current KDE updates fixed the issue with mumble svg icons: kiconthemes-2.81.0
 
  


Reply

Tags
kde plasma 5, kiconthemes, mumble, slackware -current


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Mumble error building (Slackware64 -Current Ponce-git) Gugur Slackware 3 02-28-2018 06:43 AM
Mumble Error: "Mumble failed to initialize a database in any of the possible locations." Brosef_Stalin Linux - Software 0 07-09-2016 05:52 AM
mumble on slackware64 13 carta.bianca Slackware 0 12-13-2009 12:35 PM
LXer: SVG Web: Google Brings SVG Support to Internet Explorer LXer Syndicated Linux News 0 08-25-2009 04:12 PM
Mumble, murmur, django and mumble-django. Linux.tar.gz Linux - Software 2 02-10-2009 02:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration