formatter
This commit is contained in:
+93
-87
@@ -5,106 +5,112 @@ import qs.Components
|
||||
import qs.Config
|
||||
|
||||
Item {
|
||||
id: root
|
||||
required property double percentage
|
||||
property int warningThreshold: 100
|
||||
property bool shown: true
|
||||
clip: true
|
||||
visible: width > 0 && height > 0
|
||||
implicitWidth: resourceRowLayout.x < 0 ? 0 : resourceRowLayout.implicitWidth
|
||||
implicitHeight: 22
|
||||
property bool warning: percentage * 100 >= warningThreshold
|
||||
id: root
|
||||
|
||||
property color borderColor: warning ? DynamicColors.palette.m3onError : mainColor
|
||||
required property color mainColor
|
||||
property color usageColor: warning ? DynamicColors.palette.m3error : mainColor
|
||||
property color borderColor: warning ? DynamicColors.palette.m3onError : mainColor
|
||||
required property double percentage
|
||||
property bool shown: true
|
||||
property color usageColor: warning ? DynamicColors.palette.m3error : mainColor
|
||||
property bool warning: percentage * 100 >= warningThreshold
|
||||
property int warningThreshold: 100
|
||||
|
||||
Behavior on percentage {
|
||||
NumberAnimation {
|
||||
duration: 300
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
clip: true
|
||||
implicitHeight: 22
|
||||
implicitWidth: resourceRowLayout.x < 0 ? 0 : resourceRowLayout.implicitWidth
|
||||
visible: width > 0 && height > 0
|
||||
|
||||
RowLayout {
|
||||
id: resourceRowLayout
|
||||
spacing: 2
|
||||
x: shown ? 0 : -resourceRowLayout.width
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
Behavior on percentage {
|
||||
NumberAnimation {
|
||||
duration: 300
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
implicitWidth: 14
|
||||
implicitHeight: root.implicitHeight
|
||||
RowLayout {
|
||||
id: resourceRowLayout
|
||||
|
||||
Rectangle {
|
||||
id: backgroundCircle
|
||||
anchors.centerIn: parent
|
||||
width: 14
|
||||
height: 14
|
||||
radius: height / 2
|
||||
color: "#40000000"
|
||||
border.color: "#404040"
|
||||
border.width: 1
|
||||
}
|
||||
spacing: 2
|
||||
x: shown ? 0 : -resourceRowLayout.width
|
||||
|
||||
Shape {
|
||||
anchors.fill: backgroundCircle
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
smooth: true
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
Item {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
implicitHeight: root.implicitHeight
|
||||
implicitWidth: 14
|
||||
|
||||
ShapePath {
|
||||
strokeWidth: 0
|
||||
fillColor: root.usageColor
|
||||
startX: backgroundCircle.width / 2
|
||||
startY: backgroundCircle.height / 2
|
||||
Rectangle {
|
||||
id: backgroundCircle
|
||||
|
||||
Behavior on fillColor {
|
||||
CAnim {}
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
border.color: "#404040"
|
||||
border.width: 1
|
||||
color: "#40000000"
|
||||
height: 14
|
||||
radius: height / 2
|
||||
width: 14
|
||||
}
|
||||
|
||||
PathLine {
|
||||
x: backgroundCircle.width / 2
|
||||
y: 0 + ( 1 / 2 )
|
||||
}
|
||||
Shape {
|
||||
anchors.fill: backgroundCircle
|
||||
preferredRendererType: Shape.CurveRenderer
|
||||
smooth: true
|
||||
|
||||
PathAngleArc {
|
||||
centerX: backgroundCircle.width / 2
|
||||
centerY: backgroundCircle.height / 2
|
||||
radiusX: backgroundCircle.width / 2 - ( 1 / 2 )
|
||||
radiusY: backgroundCircle.height / 2 - ( 1 / 2 )
|
||||
startAngle: -90
|
||||
sweepAngle: 360 * root.percentage
|
||||
}
|
||||
ShapePath {
|
||||
fillColor: root.usageColor
|
||||
startX: backgroundCircle.width / 2
|
||||
startY: backgroundCircle.height / 2
|
||||
strokeWidth: 0
|
||||
|
||||
PathLine {
|
||||
x: backgroundCircle.width / 2
|
||||
y: backgroundCircle.height / 2
|
||||
}
|
||||
}
|
||||
Behavior on fillColor {
|
||||
CAnim {
|
||||
}
|
||||
}
|
||||
|
||||
ShapePath {
|
||||
strokeWidth: 1
|
||||
strokeColor: root.borderColor
|
||||
fillColor: "transparent"
|
||||
capStyle: ShapePath.FlatCap
|
||||
PathLine {
|
||||
x: backgroundCircle.width / 2
|
||||
y: 0 + (1 / 2)
|
||||
}
|
||||
|
||||
Behavior on strokeColor {
|
||||
CAnim {}
|
||||
}
|
||||
PathAngleArc {
|
||||
centerX: backgroundCircle.width / 2
|
||||
centerY: backgroundCircle.height / 2
|
||||
radiusX: backgroundCircle.width / 2 - (1 / 2)
|
||||
radiusY: backgroundCircle.height / 2 - (1 / 2)
|
||||
startAngle: -90
|
||||
sweepAngle: 360 * root.percentage
|
||||
}
|
||||
|
||||
PathAngleArc {
|
||||
centerX: backgroundCircle.width / 2
|
||||
centerY: backgroundCircle.height / 2
|
||||
radiusX: backgroundCircle.width / 2 - ( 1 / 2 )
|
||||
radiusY: backgroundCircle.height / 2 - ( 1 / 2 )
|
||||
startAngle: -90
|
||||
sweepAngle: 360 * root.percentage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PathLine {
|
||||
x: backgroundCircle.width / 2
|
||||
y: backgroundCircle.height / 2
|
||||
}
|
||||
}
|
||||
|
||||
ShapePath {
|
||||
capStyle: ShapePath.FlatCap
|
||||
fillColor: "transparent"
|
||||
strokeColor: root.borderColor
|
||||
strokeWidth: 1
|
||||
|
||||
Behavior on strokeColor {
|
||||
CAnim {
|
||||
}
|
||||
}
|
||||
|
||||
PathAngleArc {
|
||||
centerX: backgroundCircle.width / 2
|
||||
centerY: backgroundCircle.height / 2
|
||||
radiusX: backgroundCircle.width / 2 - (1 / 2)
|
||||
radiusY: backgroundCircle.height / 2 - (1 / 2)
|
||||
startAngle: -90
|
||||
sweepAngle: 360 * root.percentage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user