mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-03 15:14:35 +00:00
117 lines
No EOL
3.8 KiB
Text
117 lines
No EOL
3.8 KiB
Text
/* LICENSE BEGIN
|
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
|
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
|
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
|
|
|
SPDX-License-Identifier: GPL-3.0-only
|
|
This file is also available under commercial licensing terms.
|
|
Please contact info@sixtyfps.io for more information.
|
|
LICENSE END */
|
|
|
|
import { TabWidget, StandardButton, GridBox, ListView } from "sixtyfps_widgets.60";
|
|
|
|
|
|
SysInfo := Dialog {
|
|
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 <[{dev: string, mnt: string, total: int, used: int}]> partitions;
|
|
title: "System information";
|
|
|
|
callback human-unit(int) -> string;
|
|
human-unit(unit) => {
|
|
if (unit > 900 * 1000 * 1000) {
|
|
return "\{round(unit / 1000 / 1000 / 10) / 100} GB";
|
|
} else if (unit > 900 * 1000) {
|
|
return "\{round(unit / 1000 / 10) / 100} MB";
|
|
} else if (unit > 900) {
|
|
return "\{round(unit / 10) / 100} kB";
|
|
}
|
|
return "\{unit} bytes";
|
|
}
|
|
|
|
StandardButton { kind: ok; }
|
|
preferred-width: 300px;
|
|
TabWidget {
|
|
Tab {
|
|
title: "General";
|
|
GridBox {
|
|
Row {
|
|
Text {
|
|
text: "Operationg System:";
|
|
max-width: min-width;
|
|
}
|
|
os-name := Text {
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "CPU Model:";
|
|
max-width: min-width;
|
|
}
|
|
cpu-model := Text {
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "CPU Vendor:";
|
|
max-width: min-width;
|
|
}
|
|
cpu-vendor := Text {
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "Number of logical cores:";
|
|
max-width: min-width;
|
|
}
|
|
cpu-count := Text {
|
|
}
|
|
}
|
|
Row {
|
|
Text {
|
|
text: "Memory Size:";
|
|
max-width: min-width;
|
|
}
|
|
Text {
|
|
text: "\{floor(mem_size_kb / (1000*1000))} GB";
|
|
}
|
|
}
|
|
Row {
|
|
Text{
|
|
text: "Uptime:";
|
|
max-width: min-width;
|
|
}
|
|
uptime := Text {
|
|
}
|
|
}
|
|
Rectangle {}
|
|
}
|
|
}
|
|
Tab {
|
|
title: "Partitions";
|
|
ListView {
|
|
for disk in partitions : HorizontalLayout {
|
|
padding: 5px;
|
|
spacing: 5px;
|
|
Text { text: disk.dev + " → " + disk.mnt; }
|
|
Rectangle {
|
|
min-width: t.min-width + 10px;
|
|
background: lightblue;
|
|
Rectangle {
|
|
background: lightgray;
|
|
width: (disk.used / disk.total) * parent.width;
|
|
}
|
|
t := Text {
|
|
x: 5px;
|
|
text: "\{human-unit(disk.used)} of \{human-unit(disk.total)} (\{round(100 * (disk.used / disk.total))} %)";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |