PKGBUILDs/syncthingtray/qt6/0002-Fix-rendering-issues-w...

61 lines
3.7 KiB
Diff

From e2c1f4ebe4a1f520cdbe24844d2fef750b85b8ec Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Thu, 21 Dec 2023 18:50:30 +0100
Subject: [PATCH 2/2] Fix rendering issues with Syncthing icon with Qt
6.7.0beta1
It looks like Qt Svg supports masking as of 6.7 which revealed a bug in the
code for making Syncthing icons. The mask for the emblem area was also
accidentally applied in case no emblem is shown. This change adds the mask
only when an emblem is shown.
---
syncthingmodel/syncthingicons.cpp | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/syncthingmodel/syncthingicons.cpp b/syncthingmodel/syncthingicons.cpp
index 3f27cde..b2aab59 100644
--- a/syncthingmodel/syncthingicons.cpp
+++ b/syncthingmodel/syncthingicons.cpp
@@ -93,9 +93,20 @@ QByteArray makeSyncthingIcon(const StatusIconColorSet &colors, StatusEmblem stat
"</g>"
),
};
+ static const auto emblemAreaMaskAttribute = QStringLiteral(" mask=\"url(#bitemask)\"");
+ static const auto emblemAreaMask = QStringLiteral(
+ "<mask id=\"bitemask\" maskUnits=\"userSpaceOnUse\">"
+ "<g>"
+ "<rect id=\"mask-bg\" x=\"0\" y=\"0\" width=\"16\" height=\"16\" style=\"fill:#ffffff\"/>"
+ "<circle id=\"mask-subtract\" cx=\"11.5\" cy=\"11.5\" r=\"5.5\" style=\"fill:#000000\"/>"
+ "</g>"
+ "</mask>"
+ );
static const auto normalStrokeWidth = QStringLiteral("0.81771719"), thickStrokeWidth = QStringLiteral("1.22");
static const auto normalCircleRadius = QStringLiteral("1.22"), largeCircleRadius = QStringLiteral("1.5");
const auto &emblemData = emblems[static_cast<int>(statusEmblem)];
+ const auto &emblemAreaMaskAttributeData = statusEmblem != StatusEmblem::None ? emblemAreaMaskAttribute : emblems[0];
+ const auto &emblemAreaMaskData = statusEmblem != StatusEmblem::None ? emblemAreaMask : emblems[0];
const auto &strokeWidthF = strokeWidth == StatusIconStrokeWidth::Normal ? normalStrokeWidth : thickStrokeWidth;
const auto &circleRadius = strokeWidth == StatusIconStrokeWidth::Normal ? normalCircleRadius : largeCircleRadius;
return (QStringLiteral(
@@ -105,15 +116,9 @@ QByteArray makeSyncthingIcon(const StatusIconColorSet &colors, StatusEmblem stat
"<linearGradient id=\"grad\" gradientUnits=\"userSpaceOnUse\" x1=\"8\" y1=\"0\" x2=\"8\" y2=\"16\">"
"<stop offset=\"0\" style=\"stop-color:") % gradientStartColor % QStringLiteral("\"/>"
"<stop offset=\"1\" style=\"stop-color:") % gradientEndColor % QStringLiteral("\"/>"
- "</linearGradient>"
- "<mask id=\"bitemask\" maskUnits=\"userSpaceOnUse\">"
- "<g>"
- "<rect id=\"mask-bg\" x=\"0\" y=\"0\" width=\"16\" height=\"16\" style=\"fill:#ffffff\"/>"
- "<circle id=\"mask-subtract\" cx=\"11.5\" cy=\"11.5\" r=\"5.5\" style=\"fill:#000000\"/>"
- "</g>"
- "</mask>"
+ "</linearGradient>") % emblemAreaMaskData % QStringLiteral(
"</defs>"
- "<g id=\"syncthing-logo\" mask=\"url(#bitemask)\">"
+ "<g id=\"syncthing-logo\"") % emblemAreaMaskAttributeData % QStringLiteral(">"
"<circle id=\"outer\" cx=\"8\" cy=\"8\" r=\"8\" style=\"fill:url(#grad)\"/>"
"<circle id=\"inner\" cx=\"8\" cy=\"7.9727402\" r=\"5.9557071\" style=\"fill:none;stroke:") % strokeColor % QStringLiteral(";stroke-width:") % strokeWidthF % QStringLiteral("\"/>"
"<line id=\"arm-l\" x1=\"9.1993189\" y1=\"8.776825\" x2=\"2.262351\" y2=\"9.4173737\" style=\"stroke:") % strokeColor % QStringLiteral(";stroke-width:") % strokeWidthF % QStringLiteral("\"/>"
--
2.43.0