Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Oct 2020 09:32:08 +0000 (UTC)
From:      Adriaan de Groot <adridg@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r551754 - in head/x11-themes/kf5-qqc2-desktop-style: . files
Message-ID:  <202010090932.0999W8LX028414@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adridg
Date: Fri Oct  9 09:32:08 2020
New Revision: 551754
URL: https://svnweb.freebsd.org/changeset/ports/551754

Log:
  Fix QIcon button styling from qrc:/ with KDE Plasma style
  
  Another QQC2 style fix; this is going to land eventually in KF5 5.76,
  but applies to 5.74 (current ports version) and 5.75 (upcoming).
  
  Reported upstream as and obtained from
  	https://bugs.kde.org/show_bug.cgi?id=427449
  	https://invent.kde.org/frameworks/qqc2-desktop-style/-/merge_requests/35
  
  The symptoms are toolbar icons in QML-based applications would not
  be rendered (at all), while switching styles to Qt-internal styles
  or disabling styling entirely would render the icons; this was
  spotted by swills@ while packaging Redis Desktop Manager.
  
  Reported by:	swills
  Obtained from:	KDE

Added:
  head/x11-themes/kf5-qqc2-desktop-style/files/
  head/x11-themes/kf5-qqc2-desktop-style/files/patch-git-015891bf58b5f96ae142920bba48b92fe31ea0e4.patch   (contents, props changed)
Modified:
  head/x11-themes/kf5-qqc2-desktop-style/Makefile

Modified: head/x11-themes/kf5-qqc2-desktop-style/Makefile
==============================================================================
--- head/x11-themes/kf5-qqc2-desktop-style/Makefile	Fri Oct  9 08:48:04 2020	(r551753)
+++ head/x11-themes/kf5-qqc2-desktop-style/Makefile	Fri Oct  9 09:32:08 2020	(r551754)
@@ -2,7 +2,7 @@
 
 PORTNAME=	qqc2-desktop-style
 DISTVERSION=	${KDE_FRAMEWORKS_VERSION}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	x11-themes kde kde-frameworks
 
 MAINTAINER=	kde@FreeBSD.org

Added: head/x11-themes/kf5-qqc2-desktop-style/files/patch-git-015891bf58b5f96ae142920bba48b92fe31ea0e4.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11-themes/kf5-qqc2-desktop-style/files/patch-git-015891bf58b5f96ae142920bba48b92fe31ea0e4.patch	Fri Oct  9 09:32:08 2020	(r551754)
@@ -0,0 +1,116 @@
+Add support for qrc icons to StyleItem
+
+BUG: 427449
+
+diff --git plugin/kquickstyleitem.cpp plugin/kquickstyleitem.cpp
+index b1cf5b1..f280661 100644
+--- plugin/kquickstyleitem.cpp
++++ plugin/kquickstyleitem.cpp
+@@ -179,14 +179,8 @@ void KQuickStyleItem::initStyleOption()
+         QStyleOptionButton *opt = qstyleoption_cast<QStyleOptionButton*>(m_styleoption);
+         opt->text = text();
+ 
+-        const QVariant icon = m_properties[QStringLiteral("icon")];
+-        if (icon.canConvert<QIcon>()) {
+-            opt->icon = icon.value<QIcon>();
+-        } else if (icon.canConvert<QUrl>() && icon.value<QUrl>().isLocalFile()) {
+-            opt->icon = QIcon(icon.value<QUrl>().toLocalFile());
+-        } else if (icon.canConvert<QString>()) {
+-            opt->icon = m_theme->iconFromTheme(icon.value<QString>(), m_properties[QStringLiteral("iconColor")].value<QColor>());
+-        }
++        opt->icon = iconFromIconProperty();
++
+         auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(), m_properties[QStringLiteral("iconHeight")].toInt());
+         if (iconSize.isEmpty()) {
+             int e = KQuickStyleItem::style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, nullptr);
+@@ -303,12 +297,9 @@ void KQuickStyleItem::initStyleOption()
+ 
+         opt->activeSubControls = QStyle::SC_ToolButton;
+         opt->text = text();
+-        const QVariant icon = m_properties[QStringLiteral("icon")];
+-        if (icon.canConvert<QIcon>()) {
+-            opt->icon = icon.value<QIcon>();
+-        } else if (icon.canConvert<QString>()) {
+-            opt->icon = m_theme->iconFromTheme(icon.value<QString>(), m_properties[QStringLiteral("iconColor")].value<QColor>());
+-        }
++
++        opt->icon = iconFromIconProperty();
++
+         auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(), m_properties[QStringLiteral("iconHeight")].toInt());
+         if (iconSize.isEmpty()) {
+             int e = KQuickStyleItem::style()->pixelMetric(QStyle::PM_ToolBarIconSize, m_styleoption, nullptr);
+@@ -483,8 +474,7 @@ void KQuickStyleItem::initStyleOption()
+                                                           QStyleOptionMenuItem::NonExclusive;
+                 }
+             }
+-            if (m_properties[QStringLiteral("icon")].canConvert<QIcon>())
+-                opt->icon = m_properties[QStringLiteral("icon")].value<QIcon>();
++            opt->icon = iconFromIconProperty();
+             setProperty("_q_showUnderlined", m_hints[QStringLiteral("showUnderlined")].toBool());
+ 
+             const QFont font = qApp->font(m_itemType == ComboBoxItem ?"QComboMenuItem" : "QMenu");
+@@ -507,14 +497,8 @@ void KQuickStyleItem::initStyleOption()
+             opt->state |= QStyle::State_NoChange;
+         opt->text = text();
+ 
+-        const QVariant icon = m_properties[QStringLiteral("icon")];
+-        if (icon.canConvert<QIcon>()) {
+-            opt->icon = icon.value<QIcon>();
+-        } else if (icon.canConvert<QUrl>() && icon.value<QUrl>().isLocalFile()) {
+-            opt->icon = QIcon(icon.value<QUrl>().toLocalFile());
+-        } else if (icon.canConvert<QString>()) {
+-            opt->icon = m_theme->iconFromTheme(icon.value<QString>(), m_properties[QStringLiteral("iconColor")].value<QColor>());
+-        }
++        opt->icon = iconFromIconProperty();
++
+         auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(), m_properties[QStringLiteral("iconHeight")].toInt());
+         if (iconSize.isEmpty()) {
+             int e = KQuickStyleItem::style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, nullptr);
+@@ -742,6 +726,35 @@ void KQuickStyleItem::initStyleOption()
+ 
+ }
+ 
++QIcon KQuickStyleItem::iconFromIconProperty() const
++{
++    QIcon icon;
++    const QVariant iconProperty = m_properties[QStringLiteral("icon")];
++    switch(iconProperty.type()){
++    case QVariant::Icon:
++        icon = iconProperty.value<QIcon>();
++        break;
++    case QVariant::Url:
++    case QVariant::String: {
++        QString iconSource = iconProperty.toString();
++        if (iconSource.startsWith(QLatin1String("qrc:/"))) {
++            iconSource = iconSource.mid(3);
++        } else if (iconSource.startsWith(QLatin1String("file:/"))) {
++            iconSource = QUrl(iconSource).path();
++        }
++        if (iconSource.contains(QLatin1String("/"))) {
++            icon = QIcon(iconSource);
++        } else {
++            icon = m_theme->iconFromTheme(iconSource, m_properties[QStringLiteral("iconColor")].value<QColor>());
++        }
++    }
++        break;
++    default:
++        break;
++    }
++    return icon;
++}
++
+ const char* KQuickStyleItem::classNameForItem() const
+ {
+     switch(m_itemType) {
+diff --git plugin/kquickstyleitem_p.h plugin/kquickstyleitem_p.h
+index 5dbfebf..80c0958 100644
+--- plugin/kquickstyleitem_p.h
++++ plugin/kquickstyleitem_p.h
+@@ -256,6 +256,7 @@ protected:
+     bool eventFilter(QObject *watched, QEvent *event) override;
+ 
+ private:
++    QIcon iconFromIconProperty() const;
+     const char* classNameForItem() const;
+     QSize sizeFromContents(int width, int height);
+     qreal baselineOffset();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010090932.0999W8LX028414>