move stuff into components
This commit is contained in:
parent
6370732e4e
commit
14292e6683
17 changed files with 81 additions and 149 deletions
|
|
@ -1,15 +1,14 @@
|
|||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import QtQuick.Controls
|
||||
import "." as M
|
||||
|
||||
Row {
|
||||
M.BarSection {
|
||||
id: root
|
||||
spacing: 2
|
||||
tooltip: "CPU: " + root.usage + "%\n" + root.freqGhz.toFixed(2) + " GHz"
|
||||
|
||||
property int usage: 0
|
||||
property real freqGhz: 0
|
||||
|
||||
property var _prev: null
|
||||
|
||||
FileView {
|
||||
|
|
@ -26,10 +25,7 @@ Row {
|
|||
if (dTotal > 0)
|
||||
root.usage = Math.round((1 - dIdle / dTotal) * 100);
|
||||
}
|
||||
root._prev = {
|
||||
idle,
|
||||
total
|
||||
};
|
||||
root._prev = { idle, total };
|
||||
}
|
||||
}
|
||||
FileView {
|
||||
|
|
@ -37,8 +33,7 @@ Row {
|
|||
path: "/proc/cpuinfo"
|
||||
onLoaded: {
|
||||
const lines = text().split("\n").filter(l => l.startsWith("cpu MHz"));
|
||||
if (lines.length === 0)
|
||||
return;
|
||||
if (lines.length === 0) return;
|
||||
const sum = lines.reduce((a, l) => a + parseFloat(l.split(":")[1]), 0);
|
||||
root.freqGhz = sum / lines.length / 1000;
|
||||
}
|
||||
|
|
@ -47,10 +42,7 @@ Row {
|
|||
interval: 1000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
stat.reload();
|
||||
cpuinfo.reload();
|
||||
}
|
||||
onTriggered: { stat.reload(); cpuinfo.reload(); }
|
||||
}
|
||||
|
||||
M.BarIcon {
|
||||
|
|
@ -64,9 +56,4 @@ Row {
|
|||
font.family: M.Theme.fontFamily
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
HoverHandler { id: hover }
|
||||
ToolTip {
|
||||
visible: hover.hovered
|
||||
text: "CPU: " + root.usage + "%\n" + root.freqGhz.toFixed(2) + " GHz"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue