Bar SysMon: converted to Layout

This commit is contained in:
LemmyCook 2025-09-05 17:44:04 -04:00
parent f06d0f4e1e
commit 94293e4c63
2 changed files with 105 additions and 104 deletions

View file

@ -1,46 +1,44 @@
import QtQuick import QtQuick
import QtQuick.Layouts
import Quickshell import Quickshell
import qs.Commons import qs.Commons
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
Row { RowLayout {
id: root id: root
property ShellScreen screen property ShellScreen screen
property real scaling: 1.0 property real scaling: 1.0
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
Rectangle { Rectangle {
// Let the Rectangle size itself based on its content (the Row) Layout.preferredHeight: Math.round(Style.capsuleHeight * scaling)
width: row.width + Style.marginM * scaling * 2 Layout.preferredWidth: mainLayout.implicitWidth + Style.marginM * scaling * 2
Layout.alignment: Qt.AlignVCenter
height: Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling) radius: Math.round(Style.radiusM * scaling)
color: Color.mSurfaceVariant color: Color.mSurfaceVariant
anchors.verticalCenter: parent.verticalCenter RowLayout {
id: mainLayout
Item {
id: mainContainer
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: Style.marginS * scaling anchors.leftMargin: Style.marginS * scaling
anchors.rightMargin: Style.marginS * scaling anchors.rightMargin: Style.marginS * scaling
Row {
id: row
anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
Row {
// CPU Usage Component
RowLayout {
id: cpuUsageLayout id: cpuUsageLayout
spacing: Style.marginXS * scaling spacing: Style.marginXS * scaling
Layout.alignment: Qt.AlignVCenter
NIcon { NIcon {
id: cpuUsageIcon id: cpuUsageIcon
text: "speed" text: "speed"
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
} }
NText { NText {
@ -49,21 +47,22 @@ Row {
font.family: Settings.data.ui.fontFixed font.family: Settings.data.ui.fontFixed
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
font.weight: Style.fontWeightMedium font.weight: Style.fontWeightMedium
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: Color.mPrimary color: Color.mPrimary
} }
} }
// CPU Temperature Component // CPU Temperature Component
Row { RowLayout {
id: cpuTempLayout id: cpuTempLayout
// spacing is thin here to compensate for the vertical thermometer icon // spacing is thin here to compensate for the vertical thermometer icon
spacing: Style.marginXXS * scaling spacing: Style.marginXXS * scaling
Layout.alignment: Qt.AlignVCenter
NIcon { NIcon {
text: "thermometer" text: "thermometer"
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
} }
NText { NText {
@ -71,20 +70,21 @@ Row {
font.family: Settings.data.ui.fontFixed font.family: Settings.data.ui.fontFixed
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
font.weight: Style.fontWeightMedium font.weight: Style.fontWeightMedium
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: Color.mPrimary color: Color.mPrimary
} }
} }
// Memory Usage Component // Memory Usage Component
Row { RowLayout {
id: memoryUsageLayout id: memoryUsageLayout
spacing: Style.marginXS * scaling spacing: Style.marginXS * scaling
Layout.alignment: Qt.AlignVCenter
NIcon { NIcon {
text: "memory" text: "memory"
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
} }
NText { NText {
@ -92,21 +92,22 @@ Row {
font.family: Settings.data.ui.fontFixed font.family: Settings.data.ui.fontFixed
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
font.weight: Style.fontWeightMedium font.weight: Style.fontWeightMedium
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: Color.mPrimary color: Color.mPrimary
} }
} }
// Network Download Speed Component // Network Download Speed Component
Row { RowLayout {
id: networkDownloadLayout id: networkDownloadLayout
spacing: Style.marginXS * scaling spacing: Style.marginXS * scaling
Layout.alignment: Qt.AlignVCenter
visible: Settings.data.bar.showNetworkStats visible: Settings.data.bar.showNetworkStats
NIcon { NIcon {
text: "download" text: "download"
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
} }
NText { NText {
@ -114,21 +115,22 @@ Row {
font.family: Settings.data.ui.fontFixed font.family: Settings.data.ui.fontFixed
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
font.weight: Style.fontWeightMedium font.weight: Style.fontWeightMedium
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: Color.mPrimary color: Color.mPrimary
} }
} }
// Network Upload Speed Component // Network Upload Speed Component
Row { RowLayout {
id: networkUploadLayout id: networkUploadLayout
spacing: Style.marginXS * scaling spacing: Style.marginXS * scaling
Layout.alignment: Qt.AlignVCenter
visible: Settings.data.bar.showNetworkStats visible: Settings.data.bar.showNetworkStats
NIcon { NIcon {
text: "upload" text: "upload"
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
} }
NText { NText {
@ -136,12 +138,11 @@ Row {
font.family: Settings.data.ui.fontFixed font.family: Settings.data.ui.fontFixed
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
font.weight: Style.fontWeightMedium font.weight: Style.fontWeightMedium
anchors.verticalCenter: parent.verticalCenter Layout.alignment: Qt.AlignVCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: Color.mPrimary color: Color.mPrimary
} }
} }
} }
} }
}
} }

View file

@ -22,7 +22,7 @@ Singleton {
if (bytesPerSecond < 1024) { if (bytesPerSecond < 1024) {
return bytesPerSecond.toFixed(0) + "B/s" return bytesPerSecond.toFixed(0) + "B/s"
} else if (bytesPerSecond < 1024 * 1024) { } else if (bytesPerSecond < 1024 * 1024) {
return (bytesPerSecond / 1024).toFixed(1) + "KB/s" return (bytesPerSecond / 1024).toFixed(0) + "KB/s"
} else if (bytesPerSecond < 1024 * 1024 * 1024) { } else if (bytesPerSecond < 1024 * 1024 * 1024) {
return (bytesPerSecond / (1024 * 1024)).toFixed(1) + "MB/s" return (bytesPerSecond / (1024 * 1024)).toFixed(1) + "MB/s"
} else { } else {