qmlfmt with 120 chars width (rulers)

This commit is contained in:
quadbyte 2025-08-10 14:39:25 -04:00
parent def932c447
commit d3f66b1737
17 changed files with 77 additions and 126 deletions

View file

@ -20,8 +20,7 @@ PanelWindow {
function show() {
// Ensure only one panel is visible at a time using Settings as ephemeral store
try {
if (Settings.openPanel && Settings.openPanel !== outerPanel
&& Settings.openPanel.hide) {
if (Settings.openPanel && Settings.openPanel !== outerPanel && Settings.openPanel.hide) {
Settings.openPanel.hide()
}
Settings.openPanel = outerPanel

View file

@ -27,9 +27,7 @@ Item {
readonly property int iconSize: Style.baseWidgetSize * sizeMultiplier * scaling
readonly property int pillPaddingHorizontal: 14 * scaling
readonly property int pillOverlap: iconSize * 0.5
readonly property int maxPillWidth: Math.max(
1, textItem.implicitWidth
+ pillPaddingHorizontal * 2 + pillOverlap)
readonly property int maxPillWidth: Math.max(1, textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap)
// TBC, do we use those ?
signal shown

View file

@ -52,10 +52,8 @@ Slider {
height: knobDiameter + cutoutExtra
radius: width / 2
color: root.cutoutColor !== undefined ? root.cutoutColor : Colors.backgroundPrimary
x: Math.max(
0, Math.min(
parent.width - width,
root.visualPosition * (parent.width - root.knobDiameter) - cutoutExtra / 2))
x: Math.max(0, Math.min(parent.width - width,
root.visualPosition * (parent.width - root.knobDiameter) - cutoutExtra / 2))
y: (parent.height - height) / 2
}
}

View file

@ -24,26 +24,17 @@ Item {
command: ["sh", "-c", // Outputs: {"cpu":<int>,"memper":<int>,"cputemp":<int>}
"interval=" + intervalSeconds + "; " + "while true; do " + // First /proc/stat snapshot
"read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; "
+ "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); "
+ "sleep $interval; " + // Second /proc/stat snapshot
"read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; "
+ "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); "
+ "dt=$((t2 - t1)); di=$((i2 - i1)); " + "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); "
+ // Memory percent via /proc/meminfo (kB)
"mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); "
+ "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); "
+ "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); "
+ // Temperature: scan hwmon and thermal zones, choose max; convert m°C °C
"ct=0; "
+ "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do "
+ "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); " + "sleep $interval; " + // Second /proc/stat snapshot
"read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; " + "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); "
+ "dt=$((t2 - t1)); di=$((i2 - i1)); " + "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); " + // Memory percent via /proc/meminfo (kB)
"mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); " + "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); "
+ "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); " + // Temperature: scan hwmon and thermal zones, choose max; convert m°C °C
"ct=0; " + "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do "
+ "[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + "[ -z \"$v\" ] && continue; "
+ "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; "
+ "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; " + "done; "
+ // Disk usage percent for root filesystem
"dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); "
+ "[ -z \"$dp\" ] && dp=0; " + // Emit JSON line
"echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; "
+ "done"]
+ "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; " + "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; "
+ "done; " + // Disk usage percent for root filesystem
"dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); " + "[ -z \"$dp\" ] && dp=0; " + // Emit JSON line
"echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; " + "done"]
stdout: SplitParser {
onRead: function (line) {

View file

@ -37,12 +37,8 @@ Window {
function _showNow() {
// Compute new size everytime we show the tooltip
width = Math.max(
50 * scaling,
tooltipText.implicitWidth + Style.marginLarge * 2 * scaling)
height = Math.max(
50 * scaling,
tooltipText.implicitHeight + Style.marginSmall * 2 * scaling)
width = Math.max(50 * scaling, tooltipText.implicitWidth + Style.marginLarge * 2 * scaling)
height = Math.max(50 * scaling, tooltipText.implicitHeight + Style.marginSmall * 2 * scaling)
if (!target) {
return