mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-04 01:20:37 +00:00
184 lines
No EOL
6.1 KiB
Text
184 lines
No EOL
6.1 KiB
Text
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
|
|
|
import { TabWidget, StandardButton, GridBox, VerticalBox, ListView } from "std-widgets.slint";
|
|
|
|
|
|
SysInfo := Dialog {
|
|
title: "System information";
|
|
preferred-width: 600px;
|
|
preferred-height: 400px;
|
|
|
|
TabWidget {
|
|
|
|
Tab {
|
|
title: "General";
|
|
GridBox {
|
|
Row {
|
|
Image {
|
|
rowspan: 6;
|
|
source: @image-url("laptop.svg");
|
|
min-width: 128px;
|
|
}
|
|
Text {
|
|
col: 1;
|
|
text: "Operating System:";
|
|
max-width: min-width;
|
|
}
|
|
os-name := Text {}
|
|
}
|
|
Row {
|
|
Text {
|
|
col: 1;
|
|
text: "CPU Model:";
|
|
max-width: min-width;
|
|
}
|
|
cpu-model := Text {}
|
|
}
|
|
Row {
|
|
Text {
|
|
col: 1;
|
|
text: "CPU Vendor:";
|
|
max-width: min-width;
|
|
}
|
|
cpu-vendor := Text {}
|
|
}
|
|
Row {
|
|
Text {
|
|
col: 1;
|
|
text: "Number of logical cores:";
|
|
max-width: min-width;
|
|
}
|
|
cpu-count := Text {}
|
|
}
|
|
Row {
|
|
Text{
|
|
col: 1;
|
|
text: "Uptime:";
|
|
max-width: min-width;
|
|
}
|
|
uptime := Text {}
|
|
}
|
|
Rectangle {}
|
|
}
|
|
}
|
|
|
|
Tab {
|
|
title: "Memory";
|
|
GridBox {
|
|
Row {
|
|
Text {
|
|
text: "Installed Memory:";
|
|
max-width: min-width;
|
|
}
|
|
Text {
|
|
text: "\{floor(mem_size_kb / (1024*1024))} GiB";
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "Buffer/Cache Memory:";
|
|
max-width: min-width;
|
|
}
|
|
Text {
|
|
text: "\{floor(buffer_mem_size_kb / (1024*1024))} GiB";
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "Swap Total:";
|
|
max-width: min-width;
|
|
}
|
|
Text {
|
|
text: "\{floor(swap_total_kb / (1024*1024))} GiB";
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "Swap Used:";
|
|
max-width: min-width;
|
|
}
|
|
Text {
|
|
text: "\{floor(swap_used_kb / (1024*1024))} GiB";
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "Swap Free:";
|
|
max-width: min-width;
|
|
}
|
|
Text {
|
|
text: "\{floor(swap_free_kb / (1024*1024))} GiB";
|
|
}
|
|
}
|
|
Row {
|
|
Rectangle {}
|
|
}
|
|
}
|
|
}
|
|
|
|
Tab {
|
|
title: "Partitions";
|
|
VerticalBox {
|
|
padding: 5px;
|
|
|
|
HorizontalLayout {
|
|
padding: 5px; spacing: 5px;
|
|
t1 := Text { width: 25%; overflow: elide; text: "Device"; }
|
|
t2 := Text { width: 25%; overflow: elide; text: "Mount Point"; }
|
|
t3 := Text { width: preferred-width * 2; text: "Total"; }
|
|
t4 := Text { width: t3.width; text: "Free"; }
|
|
t5 := Text { horizontal-stretch: 1; text: "Usage"; }
|
|
}
|
|
ListView {
|
|
for disk in partitions : HorizontalLayout {
|
|
padding: 5px;
|
|
spacing: 5px;
|
|
Text { width: t1.width; overflow: elide; text: disk.dev; }
|
|
Text { width: t2.width; overflow: elide; text: disk.mnt; }
|
|
Text { width: t3.width; text: human-unit(disk.total); }
|
|
Text { width: t4.width; text: human-unit(disk.free); }
|
|
Rectangle {
|
|
min-width: t.min-width + 10px;
|
|
background: lightblue;
|
|
Rectangle {
|
|
background: lightgray;
|
|
width: (1 - (disk.free / disk.total)) * parent.width;
|
|
}
|
|
t := Text {
|
|
x: 5px;
|
|
text: round(100 - 100 * (disk.free / disk.total)) + "%";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
StandardButton { kind: close; }
|
|
|
|
property os_name <=> os-name.text;
|
|
property uptime <=> uptime.text;
|
|
property cpu_count <=> cpu-count.text;
|
|
property cpu_model <=> cpu-model.text;
|
|
property cpu_vendor <=> cpu-vendor.text;
|
|
property<int> mem_size_kb;
|
|
property<int> buffer_mem_size_kb;
|
|
property<int> swap_total_kb;
|
|
property<int> swap_used_kb;
|
|
property<int> swap_free_kb;
|
|
property <[{dev: string, mnt: string, total: int, free: int}]> partitions;
|
|
|
|
callback human-unit(int) -> string;
|
|
human-unit(unit) => {
|
|
if (unit > 900 * 1000 * 1000) {
|
|
return "\{round(unit / 1000 / 1000 / 100) / 10} GB";
|
|
} else if (unit > 900 * 1000) {
|
|
return "\{round(unit / 1000 / 100) / 10} MB";
|
|
} else if (unit > 900) {
|
|
return "\{round(unit / 100) / 10} kB";
|
|
}
|
|
return "\{unit} B";
|
|
}
|
|
} |