Package: plasma-framework
Version: 5.28.0-2
Severity: normal
Tags: patch upstream

Dear Maintainer,

plasma-framework version 5.28, which is currently in Debian testing,
contains a bug, which leads to distorted/stretched icons on the Desktop
(or within the folderview widget).

This bug is very annoying as Desktop icons are sth. you always get in
touch with.

Fortunately, this issue is known by the upstream-developers and has
been fixed short time after releasing version 5.28, see:

https://bugs.kde.org/show_bug.cgi?id=355592

The provided patch is clear and applies without any conflicts (to
Debian's codebase):

https://commits.kde.org/plasma-framework/d46a91ea57f19e33e6f3a08ec86084b7e11a8e1a

I am using Debian testing (/stretch).

Please consider to integrate the patch (in one of the) upcoming Debian
revision(s).

(I also attached a "quilt patch" in case that it could be useful...)

Thanks a lot and regards, Gerhard


-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64
 (x86_64)

Kernel: Linux 4.9.0-3-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages plasma-framework depends on:
ii  kio                                      5.28.0-2
ii  kpackagetool5                            5.28.1-1
ii  libc6                                    2.24-10
ii  libegl1-mesa [libegl1-x11]               13.0.6-1+b2
ii  libgl1-mesa-glx [libgl1]                 13.0.6-1+b2
ii  libkf5activities5                        5.28.0-1
ii  libkf5calendarevents5                    5.28.0-1
ii  libkf5configcore5                        5.28.0-2
ii  libkf5configgui5                         5.28.0-2
ii  libkf5coreaddons5                        5.28.0-2
ii  libkf5declarative5                       5.28.0-1
ii  libkf5i18n5                              5.28.0-2
ii  libkf5iconthemes5                        5.28.0-2
ii  libkf5kiocore5                           5.28.0-2
ii  libkf5notifications5                     5.28.0-1
ii  libkf5package5                           5.28.1-1
ii  libkf5plasma5                            5.28.0-2
ii  libkf5plasmaquick5                       5.28.0-2
ii  libkf5quickaddons5                       5.28.0-1
ii  libkf5service-bin                        5.28.0-1
ii  libkf5service5                           5.28.0-1
ii  libkf5windowsystem5                      5.28.0-2
ii  libkf5xmlgui5                            5.28.0-1
ii  libqt5core5a                             5.7.1+dfsg-3+b1
ii  libqt5gui5                               5.7.1+dfsg-3+b1
ii  libqt5qml5                               5.7.1-2+b2
ii  libqt5quick5                             5.7.1-2+b2
ii  libqt5widgets5                           5.7.1+dfsg-3+b1
ii  libqt5x11extras5                         5.7.1~20161021-2
ii  libstdc++6                               6.3.0-18
ii  libx11-6                                 2:1.6.4-3
ii  libxcb-composite0                        1.12-1
ii  libxcb-damage0                           1.12-1
ii  libxcb1                                  1.12-1
ii  qml-module-org-kde-kquickcontrols        5.28.0-1
ii  qml-module-org-kde-kquickcontrolsaddons  5.28.0-1
ii  qml-module-qtquick-controls              5.7.1~20161021-2

plasma-framework recommends no packages.

plasma-framework suggests no packages.

-- no debconf information
>From abcdc21037033f3b09ab45e2ccd0ae2b277074c3 Mon Sep 17 00:00:00 2001
From: "Gerhard A. Dittes" <maestro.gera...@gmail.com>
Date: Fri, 26 May 2017 16:36:16 +0200
Subject: [PATCH] Add patch "[Icon Item] Support non-square icons".

The fix is picked from upstream (w/o changes), see:
https://bugs.kde.org/show_bug.cgi?id=355592
---
 .../Icon-Item-Support-non-square-icons.patch       | 166 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 167 insertions(+)
 create mode 100644 debian/patches/Icon-Item-Support-non-square-icons.patch

diff --git a/debian/patches/Icon-Item-Support-non-square-icons.patch 
b/debian/patches/Icon-Item-Support-non-square-icons.patch
new file mode 100644
index 0000000..1a8e754
--- /dev/null
+++ b/debian/patches/Icon-Item-Support-non-square-icons.patch
@@ -0,0 +1,166 @@
+Description: Pick "[Icon Item] Support non-square icons" (d46a91e).
+
+This fixes KDE#355592.
+
+--- plasma-framework-5.28.0.orig/autotests/iconitemtest.cpp
++++ plasma-framework-5.28.0/autotests/iconitemtest.cpp
+@@ -441,5 +441,44 @@ void IconItemTest::windowChanged()
+     QCOMPARE(grabImage(item), img);
+ }
+ 
++void IconItemTest::paintedSize()
++{
++    QQuickItem *item = createIconItem();
++
++    QCOMPARE(item->property("paintedWidth").toInt(), 
item->property("implicitWidth").toInt());
++    QCOMPARE(item->property("paintedHeight").toInt(), 
item->property("implicitHeight").toInt());
++
++    item->setWidth(40);
++    item->setHeight(40);
++
++    QCOMPARE(item->property("paintedWidth").toInt(), 32);
++    QCOMPARE(item->property("paintedHeight").toInt(), 32);
++
++    QIcon landscapeIcon(QPixmap(40, 35));
++    item->setProperty("source", landscapeIcon);
++    grabImage(item); // basically just to force loading the pixmap
++
++    // expanded to fit IconItem size whilst keeping aspect ratio
++    // width should be rounded to icon size, ie. 32 is next smallest
++    QCOMPARE(item->property("paintedWidth").toInt(), 32);
++    // height should still match aspect ratio, so *not* 24!
++    QCOMPARE(item->property("paintedHeight").toInt(), 28);
++
++    QIcon portraitIcon(QPixmap(15, 40));
++    item->setProperty("source", portraitIcon);
++    grabImage(item);
++
++    QCOMPARE(item->property("paintedWidth").toInt(), 12);
++    QCOMPARE(item->property("paintedHeight").toInt(), 32);
++
++    item->setWidth(400);
++    item->setHeight(400);
++
++    grabImage(item);
++
++    QCOMPARE(item->property("paintedWidth").toInt(), 150);
++    QCOMPARE(item->property("paintedHeight").toInt(), 400);
++}
++
+ QTEST_MAIN(IconItemTest)
+ 
+--- plasma-framework-5.28.0.orig/autotests/iconitemtest.h
++++ plasma-framework-5.28.0/autotests/iconitemtest.h
+@@ -54,6 +54,7 @@ private Q_SLOTS:
+     void animatingActiveChange();
+     void animatingEnabledChange();
+     void windowChanged();
++    void paintedSize();
+ 
+ private:
+     QQuickItem *createIconItem();
+--- plasma-framework-5.28.0.orig/src/declarativeimports/core/iconitem.cpp
++++ plasma-framework-5.28.0/src/declarativeimports/core/iconitem.cpp
+@@ -309,12 +309,37 @@ bool IconItem::isValid() const
+ 
+ int IconItem::paintedWidth() const
+ {
+-    return Units::roundToIconSize(qMin(boundingRect().size().width(), 
boundingRect().size().height()));
++    return paintedSize(boundingRect().size()).width();
+ }
+ 
+ int IconItem::paintedHeight() const
+ {
+-    return Units::roundToIconSize(qMin(boundingRect().size().width(), 
boundingRect().size().height()));
++    return paintedSize(boundingRect().size()).height();
++}
++
++QSize IconItem::paintedSize(const QSizeF &containerSize) const
++{
++    const QSize &actualContainerSize = (containerSize.isValid() ? 
containerSize : boundingRect().size()).toSize();
++
++    const QSize paintedSize = m_iconPixmap.size().scaled(actualContainerSize, 
Qt::KeepAspectRatio);
++
++    const int width = paintedSize.width();
++    const int height = paintedSize.height();
++
++    if (width == height) {
++        return QSize(Units::roundToIconSize(width), 
Units::roundToIconSize(height));
++    }
++
++    // if we don't have a square image, we still want it to be rounded to 
icon size
++    // but we cannot just blindly round both as we might erroneously change a 
50x45 image to be 48x32
++    // instead, round the bigger of the two and then downscale the smaller 
with the ratio
++    if (width > height) {
++        const int roundedWidth = Units::roundToIconSize(width);
++        return QSize(roundedWidth, qRound(height * (roundedWidth / 
static_cast<qreal>(width))));
++    } else {
++        const int roundedHeight = Units::roundToIconSize(height);
++        return QSize(qRound(width * (roundedHeight / 
static_cast<qreal>(height))), roundedHeight);
++    }
+ }
+ 
+ void IconItem::setStatus(Plasma::Svg::Status status)
+@@ -366,10 +391,8 @@ QSGNode* IconItem::updatePaintNode(QSGNo
+         animatingNode->setProgress(m_animValue);
+ 
+         if (m_sizeChanged) {
+-            const int iconSize = 
Units::roundToIconSize(qMin(boundingRect().size().width(), 
boundingRect().size().height()));
+-            const QRect destRect(QPointF(boundingRect().center() - 
QPointF(iconSize/2, iconSize/2)).toPoint(),
+-                                 QSize(iconSize, iconSize));
+-
++            const QSize newSize = paintedSize();
++            const QRect destRect(QPointF(boundingRect().center() - 
QPointF(newSize.width(), newSize.height()) / 2).toPoint(), newSize);
+             animatingNode->setRect(destRect);
+             m_sizeChanged = false;
+         }
+@@ -387,10 +410,8 @@ QSGNode* IconItem::updatePaintNode(QSGNo
+         }
+ 
+         if (m_sizeChanged) {
+-            const int iconSize = 
Units::roundToIconSize(qMin(boundingRect().size().width(), 
boundingRect().size().height()));
+-            const QRect destRect(QPointF(boundingRect().center() - 
QPointF(iconSize/2, iconSize/2)).toPoint(),
+-                                 QSize(iconSize, iconSize));
+-
++            const QSize newSize = paintedSize();
++            const QRect destRect(QPointF(boundingRect().center() - 
QPointF(newSize.width(), newSize.height()) / 2).toPoint(), newSize);
+             textureNode->setRect(destRect);
+             m_sizeChanged = false;
+         }
+@@ -489,10 +510,16 @@ void IconItem::loadPixmap()
+         result = KIconLoader::global()->iconEffect()->apply(result, 
KIconLoader::Desktop, KIconLoader::ActiveState);
+     }
+ 
++    const QSize oldPaintedSize = paintedSize();
++
+     m_oldIconPixmap = m_iconPixmap;
+     m_iconPixmap = result;
+     m_textureChanged = true;
+ 
++    if (oldPaintedSize != paintedSize()) {
++        emit paintedSizeChanged();
++    }
++
+     //don't animate initial setting
+     if ((m_animated || m_allowNextAnimation) && !m_oldIconPixmap.isNull() && 
!m_sizeChanged && !m_blockNextAnimation) {
+         m_animValue = 0.0;
+@@ -528,8 +555,7 @@ void IconItem::geometryChanged(const QRe
+             update();
+         }
+ 
+-        if (Units::roundToIconSize(qMin(oldGeometry.size().width(), 
oldGeometry.size().height())) !=
+-            Units::roundToIconSize(qMin(newGeometry.size().width(), 
newGeometry.size().height()))) {
++        if (paintedSize(oldGeometry.size()) != 
paintedSize(newGeometry.size())) {
+             emit paintedSizeChanged();
+         }
+     }
+--- plasma-framework-5.28.0.orig/src/declarativeimports/core/iconitem.h
++++ plasma-framework-5.28.0/src/declarativeimports/core/iconitem.h
+@@ -176,6 +176,7 @@ private Q_SLOTS:
+ 
+ private:
+     void loadPixmap();
++    QSize paintedSize(const QSizeF &containerSize = QSizeF()) const;
+ 
+     //all the ways we can set an source. Only one of them will be valid
+     QIcon m_icon;
diff --git a/debian/patches/series b/debian/patches/series
index a01aa28..7b0bbf2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@ correctly-forward-status-from-applets-to-containment.patch
 it-must-also-be-possible-for-the-status-to-be-decreased-a.patch
 set-default-hints-when-repr-doesn-t-export-Layout.patch
 Ref-deref-DataEngines-even-if-the-metadata-is-invalid.patch
+Icon-Item-Support-non-square-icons.patch
-- 
2.11.0

Reply via email to