forked from Shinonome/dots-hyprland
bar: make circular progresses of filled style
This commit is contained in:
@@ -48,24 +48,28 @@ Item {
|
|||||||
spacing: 4
|
spacing: 4
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
CircularProgress {
|
ClippedFilledCircularProgress {
|
||||||
|
id: mediaCircProg
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.leftMargin: rowLayout.spacing
|
lineWidth: Appearance.rounding.unsharpen
|
||||||
lineWidth: 2
|
value: percentage
|
||||||
value: activePlayer?.position / activePlayer?.length
|
implicitSize: 22
|
||||||
implicitSize: 26
|
colPrimary: Appearance.colors.colOnSecondaryContainer
|
||||||
colSecondary: Appearance.colors.colSecondaryContainer
|
|
||||||
colPrimary: Appearance.m3colors.m3onSecondaryContainer
|
|
||||||
enableAnimation: false
|
enableAnimation: false
|
||||||
|
|
||||||
MaterialSymbol {
|
Item {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
fill: 1
|
width: mediaCircProg.implicitSize
|
||||||
text: activePlayer?.isPlaying ? "pause" : "music_note"
|
height: mediaCircProg.implicitSize
|
||||||
iconSize: Appearance.font.pixelSize.normal
|
|
||||||
color: Appearance.m3colors.m3onSecondaryContainer
|
MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
fill: 1
|
||||||
|
text: activePlayer?.isPlaying ? "pause" : "music_note"
|
||||||
|
iconSize: Appearance.font.pixelSize.normal
|
||||||
|
color: Appearance.m3colors.m3onSecondaryContainer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
|||||||
@@ -35,21 +35,27 @@ Item {
|
|||||||
spacing: 2
|
spacing: 2
|
||||||
x: shown ? 0 : -resourceRowLayout.width
|
x: shown ? 0 : -resourceRowLayout.width
|
||||||
|
|
||||||
CircularProgress {
|
ClippedFilledCircularProgress {
|
||||||
|
id: resourceCircProg
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
lineWidth: 2
|
lineWidth: Appearance.rounding.unsharpen
|
||||||
value: percentage
|
value: percentage
|
||||||
implicitSize: 26
|
implicitSize: 22
|
||||||
colSecondary: Appearance.colors.colSecondaryContainer
|
colPrimary: Appearance.colors.colOnSecondaryContainer
|
||||||
colPrimary: Appearance.m3colors.m3onSecondaryContainer
|
|
||||||
enableAnimation: false
|
enableAnimation: false
|
||||||
|
|
||||||
MaterialSymbol {
|
Item {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
fill: 1
|
width: resourceCircProg.implicitSize
|
||||||
text: iconName
|
height: resourceCircProg.implicitSize
|
||||||
iconSize: Appearance.font.pixelSize.large
|
|
||||||
color: Appearance.m3colors.m3onSecondaryContainer
|
MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
fill: 1
|
||||||
|
text: iconName
|
||||||
|
iconSize: Appearance.font.pixelSize.normal
|
||||||
|
color: Appearance.m3colors.m3onSecondaryContainer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +67,14 @@ Item {
|
|||||||
TextMetrics {
|
TextMetrics {
|
||||||
id: fullPercentageTextMetrics
|
id: fullPercentageTextMetrics
|
||||||
text: "100"
|
text: "100"
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.small
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: percentageText
|
id: percentageText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: Appearance.colors.colOnLayer1
|
color: Appearance.colors.colOnLayer1
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.small
|
||||||
text: `${Math.round(percentage * 100).toString()}`
|
text: `${Math.round(percentage * 100).toString()}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import qs.modules.common
|
||||||
|
import qs.modules.common.functions
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Shapes
|
||||||
|
import Qt5Compat.GraphicalEffects
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property int implicitSize: 18
|
||||||
|
property int lineWidth: 2
|
||||||
|
property real value: 0
|
||||||
|
property color colPrimary: Appearance?.colors.colOnSecondaryContainer ?? "#685496"
|
||||||
|
property color colSecondary: ColorUtils.transparentize(colPrimary, 0.4) ?? "#F1D3F9"
|
||||||
|
property real gapAngle: 360 / 18
|
||||||
|
property bool fill: true
|
||||||
|
property int fillOverflow: 2
|
||||||
|
property bool enableAnimation: true
|
||||||
|
property int animationDuration: 800
|
||||||
|
property var easingType: Easing.OutCubic
|
||||||
|
default property Item textMask: Item {
|
||||||
|
width: implicitSize
|
||||||
|
height: implicitSize
|
||||||
|
StyledText {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: Math.round(root.value * 100)
|
||||||
|
font.pixelSize: 12
|
||||||
|
font.weight: Font.Medium
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: implicitSize
|
||||||
|
implicitHeight: implicitSize
|
||||||
|
|
||||||
|
// property real degree: value * 360
|
||||||
|
property real degree: 0.65 * 360
|
||||||
|
property real centerX: root.width / 2
|
||||||
|
property real centerY: root.height / 2
|
||||||
|
property real arcRadius: root.implicitSize / 2 - root.lineWidth
|
||||||
|
property real startAngle: -90
|
||||||
|
|
||||||
|
Behavior on degree {
|
||||||
|
enabled: root.enableAnimation
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.animationDuration
|
||||||
|
easing.type: root.easingType
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: contentItem
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: implicitSize / 2
|
||||||
|
color: root.colSecondary
|
||||||
|
visible: false
|
||||||
|
layer.enabled: true
|
||||||
|
layer.smooth: true
|
||||||
|
|
||||||
|
Shape {
|
||||||
|
anchors.fill: parent
|
||||||
|
preferredRendererType: Shape.CurveRenderer
|
||||||
|
|
||||||
|
ShapePath {
|
||||||
|
id: primaryPath
|
||||||
|
pathHints: ShapePath.PathSolid & ShapePath.PathNonIntersecting
|
||||||
|
strokeColor: root.colPrimary
|
||||||
|
strokeWidth: root.lineWidth
|
||||||
|
capStyle: ShapePath.RoundCap
|
||||||
|
fillColor: root.colPrimary
|
||||||
|
|
||||||
|
startX: root.centerX
|
||||||
|
startY: root.centerY
|
||||||
|
|
||||||
|
PathAngleArc {
|
||||||
|
moveToStart: false
|
||||||
|
centerX: root.centerX
|
||||||
|
centerY: root.centerY
|
||||||
|
radiusX: root.arcRadius
|
||||||
|
radiusY: root.arcRadius
|
||||||
|
startAngle: root.startAngle
|
||||||
|
sweepAngle: root.degree
|
||||||
|
}
|
||||||
|
PathLine {
|
||||||
|
x: primaryPath.startX
|
||||||
|
y: primaryPath.startY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpacityMask {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: contentItem
|
||||||
|
invert: true
|
||||||
|
maskSource: root.textMask
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,9 @@ Item {
|
|||||||
ShapePath {
|
ShapePath {
|
||||||
id: shapePath
|
id: shapePath
|
||||||
strokeWidth: 0
|
strokeWidth: 0
|
||||||
|
|
||||||
fillColor: root.color
|
fillColor: root.color
|
||||||
|
pathHints: ShapePath.PathSolid & ShapePath.PathNonIntersecting
|
||||||
|
|
||||||
startX: switch (root.corner) {
|
startX: switch (root.corner) {
|
||||||
case RoundCorner.CornerEnum.TopLeft: return 0;
|
case RoundCorner.CornerEnum.TopLeft: return 0;
|
||||||
case RoundCorner.CornerEnum.TopRight: return root.implicitSize;
|
case RoundCorner.CornerEnum.TopRight: return root.implicitSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user