Files
att_menu/components/BluetoothGlyph.qml
T
2026-07-26 21:16:55 +02:00

88 lines
2.4 KiB
QML

import QtQuick
import QtQuick.Shapes
import qs.config
// The bluetooth rune, drawn rather than themed: icon themes ship it only as a
// symbolic (black-on-transparent) SVG, which Qt renders as-is and which would
// be invisible on the dark panel. Drawing it also makes it recolourable to
// signal adapter state.
Item {
id: root
property color color: Theme.text
property int size: Theme.iconSize
// Struck through with a diagonal, for "off".
property bool struck: false
implicitWidth: root.size
implicitHeight: root.size
readonly property real glyphWidth: root.size * 0.44
readonly property real glyphHeight: root.size * 0.82
readonly property real stroke: Math.max(1.5, root.size * 0.09)
Shape {
anchors.centerIn: parent
width: root.glyphWidth
height: root.glyphHeight
preferredRendererType: Shape.CurveRenderer
// One continuous stroke: up the left diagonal, over the top apex, down
// the spine, out to the right and back down the other diagonal.
ShapePath {
strokeColor: root.color
strokeWidth: root.stroke
fillColor: "transparent"
capStyle: ShapePath.RoundCap
joinStyle: ShapePath.RoundJoin
startX: 0
startY: root.glyphHeight * 0.25
PathLine {
x: root.glyphWidth
y: root.glyphHeight * 0.75
}
PathLine {
x: root.glyphWidth * 0.5
y: root.glyphHeight
}
PathLine {
x: root.glyphWidth * 0.5
y: 0
}
PathLine {
x: root.glyphWidth
y: root.glyphHeight * 0.25
}
PathLine {
x: 0
y: root.glyphHeight * 0.75
}
}
}
Shape {
anchors.centerIn: parent
width: root.size
height: root.size
visible: root.struck
preferredRendererType: Shape.CurveRenderer
ShapePath {
strokeColor: root.color
strokeWidth: root.stroke
fillColor: "transparent"
capStyle: ShapePath.RoundCap
startX: root.size * 0.12
startY: root.size * 0.88
PathLine {
x: root.size * 0.88
y: root.size * 0.12
}
}
}
}