Bar SysMon: converted to Layout
This commit is contained in:
parent
f06d0f4e1e
commit
94293e4c63
2 changed files with 105 additions and 104 deletions
|
|
@ -1,145 +1,146 @@
|
||||||
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
|
||||||
|
spacing: Style.marginS * scaling
|
||||||
|
|
||||||
Row {
|
// CPU Usage Component
|
||||||
id: row
|
RowLayout {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
id: cpuUsageLayout
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginXS * scaling
|
||||||
Row {
|
Layout.alignment: Qt.AlignVCenter
|
||||||
id: cpuUsageLayout
|
|
||||||
spacing: Style.marginXS * scaling
|
|
||||||
|
|
||||||
NIcon {
|
NIcon {
|
||||||
id: cpuUsageIcon
|
id: cpuUsageIcon
|
||||||
text: "speed"
|
text: "speed"
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
|
||||||
|
|
||||||
NText {
|
|
||||||
id: cpuUsageText
|
|
||||||
text: `${SystemStatService.cpuUsage}%`
|
|
||||||
font.family: Settings.data.ui.fontFixed
|
|
||||||
font.pointSize: Style.fontSizeS * scaling
|
|
||||||
font.weight: Style.fontWeightMedium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
color: Color.mPrimary
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPU Temperature Component
|
NText {
|
||||||
Row {
|
id: cpuUsageText
|
||||||
id: cpuTempLayout
|
text: `${SystemStatService.cpuUsage}%`
|
||||||
// spacing is thin here to compensate for the vertical thermometer icon
|
font.family: Settings.data.ui.fontFixed
|
||||||
spacing: Style.marginXXS * scaling
|
font.pointSize: Style.fontSizeS * scaling
|
||||||
|
font.weight: Style.fontWeightMedium
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: Color.mPrimary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NIcon {
|
// CPU Temperature Component
|
||||||
text: "thermometer"
|
RowLayout {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
id: cpuTempLayout
|
||||||
}
|
// spacing is thin here to compensate for the vertical thermometer icon
|
||||||
|
spacing: Style.marginXXS * scaling
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
NText {
|
NIcon {
|
||||||
text: `${SystemStatService.cpuTemp}°C`
|
text: "thermometer"
|
||||||
font.family: Settings.data.ui.fontFixed
|
Layout.alignment: Qt.AlignVCenter
|
||||||
font.pointSize: Style.fontSizeS * scaling
|
|
||||||
font.weight: Style.fontWeightMedium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
color: Color.mPrimary
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memory Usage Component
|
NText {
|
||||||
Row {
|
text: `${SystemStatService.cpuTemp}°C`
|
||||||
id: memoryUsageLayout
|
font.family: Settings.data.ui.fontFixed
|
||||||
spacing: Style.marginXS * scaling
|
font.pointSize: Style.fontSizeS * scaling
|
||||||
|
font.weight: Style.fontWeightMedium
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: Color.mPrimary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NIcon {
|
// Memory Usage Component
|
||||||
text: "memory"
|
RowLayout {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
id: memoryUsageLayout
|
||||||
}
|
spacing: Style.marginXS * scaling
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
NText {
|
NIcon {
|
||||||
text: `${SystemStatService.memoryUsageGb}G`
|
text: "memory"
|
||||||
font.family: Settings.data.ui.fontFixed
|
Layout.alignment: Qt.AlignVCenter
|
||||||
font.pointSize: Style.fontSizeS * scaling
|
|
||||||
font.weight: Style.fontWeightMedium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
color: Color.mPrimary
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network Download Speed Component
|
NText {
|
||||||
Row {
|
text: `${SystemStatService.memoryUsageGb}G`
|
||||||
id: networkDownloadLayout
|
font.family: Settings.data.ui.fontFixed
|
||||||
spacing: Style.marginXS * scaling
|
font.pointSize: Style.fontSizeS * scaling
|
||||||
visible: Settings.data.bar.showNetworkStats
|
font.weight: Style.fontWeightMedium
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: Color.mPrimary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NIcon {
|
// Network Download Speed Component
|
||||||
text: "download"
|
RowLayout {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
id: networkDownloadLayout
|
||||||
}
|
spacing: Style.marginXS * scaling
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
visible: Settings.data.bar.showNetworkStats
|
||||||
|
|
||||||
NText {
|
NIcon {
|
||||||
text: SystemStatService.formatSpeed(SystemStatService.rxSpeed)
|
text: "download"
|
||||||
font.family: Settings.data.ui.fontFixed
|
Layout.alignment: Qt.AlignVCenter
|
||||||
font.pointSize: Style.fontSizeS * scaling
|
|
||||||
font.weight: Style.fontWeightMedium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
color: Color.mPrimary
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network Upload Speed Component
|
NText {
|
||||||
Row {
|
text: SystemStatService.formatSpeed(SystemStatService.rxSpeed)
|
||||||
id: networkUploadLayout
|
font.family: Settings.data.ui.fontFixed
|
||||||
spacing: Style.marginXS * scaling
|
font.pointSize: Style.fontSizeS * scaling
|
||||||
visible: Settings.data.bar.showNetworkStats
|
font.weight: Style.fontWeightMedium
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: Color.mPrimary
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NIcon {
|
// Network Upload Speed Component
|
||||||
text: "upload"
|
RowLayout {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
id: networkUploadLayout
|
||||||
}
|
spacing: Style.marginXS * scaling
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
visible: Settings.data.bar.showNetworkStats
|
||||||
|
|
||||||
NText {
|
NIcon {
|
||||||
text: SystemStatService.formatSpeed(SystemStatService.txSpeed)
|
text: "upload"
|
||||||
font.family: Settings.data.ui.fontFixed
|
Layout.alignment: Qt.AlignVCenter
|
||||||
font.pointSize: Style.fontSizeS * scaling
|
}
|
||||||
font.weight: Style.fontWeightMedium
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
NText {
|
||||||
verticalAlignment: Text.AlignVCenter
|
text: SystemStatService.formatSpeed(SystemStatService.txSpeed)
|
||||||
color: Color.mPrimary
|
font.family: Settings.data.ui.fontFixed
|
||||||
}
|
font.pointSize: Style.fontSizeS * scaling
|
||||||
|
font.weight: Style.fontWeightMedium
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: Color.mPrimary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue