slight changes
This commit is contained in:
+71
-54
@@ -4,7 +4,7 @@ import QtQuick.Shapes
|
||||
import qs.Components
|
||||
import qs.Config
|
||||
|
||||
Item {
|
||||
RowLayout {
|
||||
id: root
|
||||
|
||||
property color accentColor: warning ? DynamicColors.palette.m3error : mainColor
|
||||
@@ -20,12 +20,7 @@ Item {
|
||||
property int warningThreshold: 80
|
||||
|
||||
clip: true
|
||||
height: implicitHeight
|
||||
implicitHeight: 34
|
||||
implicitWidth: 34
|
||||
percentage: 0
|
||||
visible: width > 0 && height > 0
|
||||
width: implicitWidth
|
||||
|
||||
Behavior on animatedPercentage {
|
||||
Anim {
|
||||
@@ -36,58 +31,80 @@ Item {
|
||||
Component.onCompleted: animatedPercentage = percentage
|
||||
onPercentageChanged: animatedPercentage = percentage
|
||||
|
||||
Canvas {
|
||||
id: gaugeCanvas
|
||||
|
||||
anchors.centerIn: parent
|
||||
height: width
|
||||
width: Math.min(parent.width, parent.height)
|
||||
|
||||
Component.onCompleted: requestPaint()
|
||||
onPaint: {
|
||||
const ctx = getContext("2d");
|
||||
ctx.reset();
|
||||
const cx = width / 2;
|
||||
const cy = (height / 2) + 1;
|
||||
const radius = (Math.min(width, height) - 12) / 2;
|
||||
const lineWidth = 3;
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep);
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.lineCap = "round";
|
||||
ctx.strokeStyle = DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2);
|
||||
ctx.stroke();
|
||||
if (root.animatedPercentage > 0) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep * root.animatedPercentage);
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.lineCap = "round";
|
||||
ctx.strokeStyle = root.accentColor;
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onAnimatedPercentageChanged() {
|
||||
gaugeCanvas.requestPaint();
|
||||
}
|
||||
|
||||
target: root
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onPaletteChanged() {
|
||||
gaugeCanvas.requestPaint();
|
||||
}
|
||||
|
||||
target: DynamicColors
|
||||
}
|
||||
}
|
||||
// Canvas {
|
||||
// id: gaugeCanvas
|
||||
//
|
||||
// anchors.centerIn: parent
|
||||
// height: width
|
||||
// width: Math.min(parent.width, parent.height)
|
||||
//
|
||||
// Component.onCompleted: requestPaint()
|
||||
// onPaint: {
|
||||
// const ctx = getContext("2d");
|
||||
// ctx.reset();
|
||||
// const cx = width / 2;
|
||||
// const cy = (height / 2) + 1;
|
||||
// const radius = (Math.min(width, height) - 12) / 2;
|
||||
// const lineWidth = 3;
|
||||
// ctx.beginPath();
|
||||
// ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep);
|
||||
// ctx.lineWidth = lineWidth;
|
||||
// ctx.lineCap = "round";
|
||||
// ctx.strokeStyle = DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2);
|
||||
// ctx.stroke();
|
||||
// if (root.animatedPercentage > 0) {
|
||||
// ctx.beginPath();
|
||||
// ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep * root.animatedPercentage);
|
||||
// ctx.lineWidth = lineWidth;
|
||||
// ctx.lineCap = "round";
|
||||
// ctx.strokeStyle = root.accentColor;
|
||||
// ctx.stroke();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Connections {
|
||||
// function onAnimatedPercentageChanged() {
|
||||
// gaugeCanvas.requestPaint();
|
||||
// }
|
||||
//
|
||||
// target: root
|
||||
// }
|
||||
//
|
||||
// Connections {
|
||||
// function onPaletteChanged() {
|
||||
// gaugeCanvas.requestPaint();
|
||||
// }
|
||||
//
|
||||
// target: DynamicColors
|
||||
// }
|
||||
// }
|
||||
|
||||
MaterialIcon {
|
||||
anchors.centerIn: parent
|
||||
id: icon
|
||||
|
||||
color: DynamicColors.palette.m3onSurface
|
||||
font.pointSize: 12
|
||||
text: root.icon
|
||||
}
|
||||
|
||||
CustomClippingRect {
|
||||
Layout.preferredHeight: root.height
|
||||
Layout.preferredWidth: 5
|
||||
color: DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2)
|
||||
radius: Appearance.rounding.full
|
||||
|
||||
CustomRect {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
color: root.mainColor
|
||||
implicitHeight: root.percentage * parent.height
|
||||
radius: implicitHeight / 2
|
||||
|
||||
Behavior on implicitHeight {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user