ii bar resources popup: use formatting func from ResourceUsage

This commit is contained in:
end-4
2026-03-12 11:22:26 +01:00
parent f9bd67699c
commit b59c3f5c30
@@ -7,11 +7,6 @@ import QtQuick.Layouts
StyledPopup { StyledPopup {
id: root id: root
// Helper function to format KB to GB
function formatKB(kb) {
return (kb / (1024 * 1024)).toFixed(1) + " GB";
}
Row { Row {
anchors.centerIn: parent anchors.centerIn: parent
spacing: 12 spacing: 12
@@ -29,17 +24,17 @@ StyledPopup {
StyledPopupValueRow { StyledPopupValueRow {
icon: "clock_loader_60" icon: "clock_loader_60"
label: Translation.tr("Used:") label: Translation.tr("Used:")
value: root.formatKB(ResourceUsage.memoryUsed) value: ResourceUsage.kbToGbString(ResourceUsage.memoryUsed)
} }
StyledPopupValueRow { StyledPopupValueRow {
icon: "check_circle" icon: "check_circle"
label: Translation.tr("Free:") label: Translation.tr("Free:")
value: root.formatKB(ResourceUsage.memoryFree) value: ResourceUsage.kbToGbString(ResourceUsage.memoryFree)
} }
StyledPopupValueRow { StyledPopupValueRow {
icon: "empty_dashboard" icon: "empty_dashboard"
label: Translation.tr("Total:") label: Translation.tr("Total:")
value: root.formatKB(ResourceUsage.memoryTotal) value: ResourceUsage.kbToGbString(ResourceUsage.memoryTotal)
} }
} }
} }
@@ -58,17 +53,17 @@ StyledPopup {
StyledPopupValueRow { StyledPopupValueRow {
icon: "clock_loader_60" icon: "clock_loader_60"
label: Translation.tr("Used:") label: Translation.tr("Used:")
value: root.formatKB(ResourceUsage.swapUsed) value: ResourceUsage.kbToGbString(ResourceUsage.swapUsed)
} }
StyledPopupValueRow { StyledPopupValueRow {
icon: "check_circle" icon: "check_circle"
label: Translation.tr("Free:") label: Translation.tr("Free:")
value: root.formatKB(ResourceUsage.swapFree) value: ResourceUsage.kbToGbString(ResourceUsage.swapFree)
} }
StyledPopupValueRow { StyledPopupValueRow {
icon: "empty_dashboard" icon: "empty_dashboard"
label: Translation.tr("Total:") label: Translation.tr("Total:")
value: root.formatKB(ResourceUsage.swapTotal) value: ResourceUsage.kbToGbString(ResourceUsage.swapTotal)
} }
} }
} }