plasma-applet-tiledmenu icon indicating copy to clipboard operation
plasma-applet-tiledmenu copied to clipboard

Svg Icons (TilesOnly / Alphabetical / Category) under Breeze Twlight have DarkText on DarkBG

Open Zren opened this issue 9 months ago • 1 comments

Eg:

%Y-%M-%D___%H-%m-%S-3

This is because KSvg.Svg {} uses of KColorScheme's global color palette instead of the locally inherited colors. We can change the "colorSet" but we can't use the palette

  • https://api.kde.org/frameworks/ksvg/html/classKSvg_1_1Svg.html
  • https://invent.kde.org/frameworks/ksvg.git/-/blame/master/src/declarativeimports/svgitem.cpp#L46
m_kirigamiTheme = qobject_cast<Kirigami::Platform::PlatformTheme *>(qmlAttachedPropertiesObject<Kirigami::Platform::PlatformTheme>(this, true));
m_svg->setColor(Svg::Text, m_kirigamiTheme->textColor());

However the KIconTheme uses the current palette for the icon colors.

  • https://invent.kde.org/frameworks/kiconthemes.git/-/blame/master/src/kiconcolors.cpp#L105
d->text = palette.windowText().color();

My solution is to embed the svg paths with a QML Shape ShapePath PathSvg.

  • https://doc.qt.io/qt-6/qml-qtquick-shapes-shape.html
  • https://doc.qt.io/qt-6/qml-qtquick-shapes-shapepath.html
  • https://doc.qt.io/qt-6/qml-qtquick-pathsvg.html
// SidebarViewButton.qml
SidebarItem {
	...
	// From FlatButton.qml, modifed so icon is also 16px
	property int iconSize: Kirigami.Units.iconSizes.roundedIconSize(config.flatButtonIconSize)

	default property alias shapePathChildren: shapePath.pathElements
	property int viewBoxSize: 16
	readonly property real viewBoxScale: control.iconSize / control.viewBoxSize
	Shape {
		ShapePath {
			id: shapePath
			scale: Qt.size(control.viewBoxScale, control.viewBoxScale)
			fillColor: control.checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor
			fillRule: ShapePath.WindingFill
			strokeWidth: -1

			PathSvg { path: "m 1,3 v 4 h 9 V 3 Z M 2,4 H 9 V 6 H 2 Z" }
			PathSvg { path: "m 11,3 v 4 h 4 V 3 Z m 1,1 h 2 v 2 h -2 z" }
			PathSvg { path: "M 1,8 1,12 H 5 l 0,-4 z m 1,1 h 2 l 0,2 H 2 Z" }
			PathSvg { path: "M 6,8 V 12 h 9 V 8 Z m 1,1 h 7 V 11 H 7 Z" }
		}
		preferredRendererType: Shape.CurveRenderer // Aliasing

		width: control.iconSize
		height: control.iconSize
		anchors.centerIn: parent

		// From FlatButton.qml
		scale: control.zoomOnPush && control.pressed ? (control.height-5) / control.height : 1
		Behavior on scale { NumberAnimation { duration: 200 } }
	}
	...
}

Zren avatar May 01 '24 04:05 Zren

There might be some way of making the SVG inherit the colors, but I haven't skimmed through Plasma6 enough to see it yet.

Zren avatar May 01 '24 05:05 Zren

in my experience making icons for plasma since the ability to inherit the colorschemes with the style tag and it's id: current-colorscheme, is that anything one wants to be effected by that seems to need to be it's final form as paths. So i always make sure to convert all the shapes... including text to raw paths. I assume that it's a good idea as well to save the .svg off as plain and not for inkscape. It would be nice if Inkscape would stop nagging about it every time i open or try to save a plain svg, but I digress

addendum: UI myself am very interested in seeing custom icons working for this widget. I have a LOT of experience with svgs and making and extending icon themes many with external styles like the use of current-colorscheme. If I can be helpful in this effortt to get that feature nailed down let me know.

lucifer-morningstar avatar Jun 07 '24 18:06 lucifer-morningstar

Blarg this is easier than I thought, for monocolor symbolic icons at least.

https://api.kde.org/frameworks/kirigami/html/classIcon.html#a3d2456bbe8dd3ff3b43b4637591b6ed5

Kirigami.Icon {
	isMask: true // Force color
	color: button.checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor
}

Anything with multiple ColorScheme classes, like say a NegativeText red slash for mute is still difficult to deal with but this should work for our purposes.

Zren avatar Jun 18 '24 00:06 Zren

Hmm, looks like upstream plasma also noticed this issue with Breeze Twilight. There's a few PRs that were merged that always use the color scheme. I'll need to test after updating tomorrow.

  • https://bugs.kde.org/show_bug.cgi?id=485801
  • https://bugs.kde.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=RESOLVED&bug_status=NEEDSINFO&bug_status=VERIFIED&bug_status=CLOSED&classification=Plasma&f0=OP&f1=OP&f2=product&f3=component&f4=alias&f5=short_desc&f7=content&f8=CP&f9=CP&j1=OR&o2=substring&o3=substring&o4=substring&o5=substring&o6=substring&o7=matches&product=plasmashell&query_format=advanced&short_desc=twilight&short_desc_type=allwordssubstr&v2=twilight&v3=twilight&v4=twilight&v5=twilight&v6=twilight&v7=%22twilight%22

Zren avatar Jun 18 '24 00:06 Zren