Zren / plasma-applet-tiledmenu

https://store.kde.org/p/2142716/
137 stars 34 forks source link

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

Open Zren opened 2 weeks ago

Zren commented 2 weeks ago

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

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.

d->text = palette.windowText().color();

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

// 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 commented 2 weeks ago

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