feat: initial commit for pixel-snapping components and helpers
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import ZShell
|
||||
import ZShell.Components
|
||||
import ZShell.Services
|
||||
import ZShell.Config
|
||||
import qs.Components
|
||||
@@ -10,34 +12,39 @@ CustomRect {
|
||||
|
||||
readonly property color accent: Colors.palette.m3tertiary
|
||||
|
||||
required property real perc
|
||||
required property int used
|
||||
required property int total
|
||||
required property string label
|
||||
required property string icon
|
||||
|
||||
Layout.fillWidth: true
|
||||
color: Colors.tPalette.m3surfaceContainer
|
||||
implicitHeight: layout.implicitHeight + Tokens.padding.large * 2
|
||||
implicitWidth: layout.implicitWidth + Tokens.padding.extraLargeIncreased * 2
|
||||
radius: Tokens.rounding.largeIncreased
|
||||
|
||||
ServiceRef {
|
||||
service: Memory
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
SnapLayout {
|
||||
id: layout
|
||||
|
||||
anchors.centerIn: parent
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
orientation: Qt.Vertical
|
||||
spacing: Tokens.spacing.extraSmall
|
||||
|
||||
RowLayout {
|
||||
Layout.leftMargin: -Tokens.padding.extraSmall
|
||||
SnapLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
spacing: Tokens.spacing.small
|
||||
|
||||
MaterialIcon {
|
||||
color: root.accent
|
||||
fill: 1
|
||||
text: "memory_alt"
|
||||
text: root.icon
|
||||
}
|
||||
|
||||
CustomText {
|
||||
text: qsTr("Memory")
|
||||
text: root.label
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,17 +52,17 @@ CustomRect {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: Tokens.spacing.largeIncreased
|
||||
fgColor: root.accent
|
||||
implicitSize: usageColumn.implicitHeight + thickness + Tokens.padding.largeIncreased * 2
|
||||
implicitSize: ZUtils.snap(usageColumn.implicitHeight + thickness + Tokens.padding.largeIncreased * 2, root)
|
||||
startAngle: -225
|
||||
sweepAngle: 270
|
||||
value: Memory.percentage
|
||||
value: root.perc
|
||||
|
||||
Behavior on clampedVal {
|
||||
Anim {
|
||||
}
|
||||
Anim {}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
SnapLayout {
|
||||
orientation: Qt.Vertical
|
||||
id: usageColumn
|
||||
|
||||
anchors.centerIn: parent
|
||||
@@ -66,7 +73,7 @@ CustomRect {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
color: root.accent
|
||||
font: Tokens.font.body.large
|
||||
text: Math.round(Memory.percentage * 100) + "%"
|
||||
text: Math.round(root.perc * 100) + "%"
|
||||
}
|
||||
|
||||
CustomText {
|
||||
@@ -80,7 +87,7 @@ CustomRect {
|
||||
CustomText {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: {
|
||||
const fmt = UsageFmt.formatKib(Memory.used, Memory.total);
|
||||
const fmt = UsageFmt.formatKib(root.used, root.total);
|
||||
return `${fmt.value.toFixed(1)} / ${Math.floor(fmt.total)} ${fmt.unit}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user