initial commit
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import QtQuick
|
||||
import QtQuick.Shapes
|
||||
import qs.config
|
||||
|
||||
// The wifi fan, drawn for the same reason as the bluetooth rune: themes ship it
|
||||
// symbolic-only, which Qt renders black-on-transparent. Drawing it also lets
|
||||
// each arc be lit separately, which is how signal strength is shown.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property color color: Theme.text
|
||||
// Unlit arcs stay drawn, faintly, so the glyph keeps one silhouette at
|
||||
// every strength instead of changing shape as the signal moves.
|
||||
property color dimColor: Theme.textDim
|
||||
property int size: Theme.iconSize
|
||||
// Lit arcs, 0-3.
|
||||
property int level: 3
|
||||
// Struck through with a diagonal, for "off".
|
||||
property bool struck: false
|
||||
|
||||
implicitWidth: root.size
|
||||
implicitHeight: root.size
|
||||
|
||||
readonly property real cx: root.size / 2
|
||||
readonly property real cy: root.size * 0.74
|
||||
readonly property real stroke: Math.max(1.5, root.size * 0.085)
|
||||
|
||||
Rectangle {
|
||||
x: root.cx - width / 2
|
||||
y: root.cy - height / 2
|
||||
width: Math.max(2, root.size * 0.14)
|
||||
height: width
|
||||
radius: width / 2
|
||||
color: root.level > 0 ? root.color : root.dimColor
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: 3
|
||||
|
||||
Shape {
|
||||
id: arc
|
||||
|
||||
required property int index
|
||||
|
||||
anchors.fill: parent
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
|
||||
ShapePath {
|
||||
strokeColor: root.level > arc.index ? root.color : root.dimColor
|
||||
strokeWidth: root.stroke
|
||||
fillColor: "transparent"
|
||||
capStyle: ShapePath.RoundCap
|
||||
|
||||
// Centred on the dot, opening upwards: 225° to 315°, measured
|
||||
// clockwise from three o'clock.
|
||||
PathAngleArc {
|
||||
centerX: root.cx
|
||||
centerY: root.cy
|
||||
radiusX: root.size * (0.2 + arc.index * 0.115)
|
||||
radiusY: root.size * (0.2 + arc.index * 0.115)
|
||||
startAngle: 225
|
||||
sweepAngle: 90
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Shape {
|
||||
anchors.fill: parent
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user