nosignal-shell/modules/dashboard/performance/BatteryTank.qml
28allday 53c5833de0 fix(nosignal): hardware-test feedback round 2 — weather, dashboard, tray
From the 2026-06-15 on-box hardware test (all 6 prior fixes confirmed; these
are the new findings, baked into the fork source rather than shipped as
pacman-hook patches, per the Phase-2 "we own the shell" approach):

- F-W1 (Weather.qml): fetch at startup. Stock only called reload() on a config
  CHANGE, so a saved location blanked after reboot and an empty/auto location
  never populated on a fresh boot. Add Component.onCompleted: reload() and
  switch the hourly Timer to reload() (re-detects auto/IP too).
- F-W3 (Weather.qml): 7-day forecast showed "undefined°" in °F mode — only
  maxTempC/minTempC were stored. Store rounded maxTempF/minTempF (and round °C).
- F-W2 (Weather.qml): empty/auto-IP location never populated — the in-shell
  ipinfo.io fetch didn't set loc (provider-specific; the city path works via
  the same Requests.get). Repair attempt: defensive JSON parse + error callback
  + fallback to geojs.io. Compiled Requests module not inspectable, so this is
  best-effort; a saved city still works regardless.
- F-D1a (modules/dashboard/*.qml): square the 25 card radii bound to the
  compiled Tokens.rounding.* Material defaults (which ignore shell.json
  rounding.scale=0) so the dashboard matches the square redesign.
- F-D1b (Glyphs.qml): remap the weather glyphs to the Material-weather family
  (every codepoint verified present in JetBrainsMono Nerd Font Mono); the old
  Font-Awesome codepoints were absent (rendered "?") and thunderstorm /
  snowing_heavy were unmapped.
- F-T1 (NsBar.qml): gate the system-tray pill on SystemTray.items count so it
  only shows when an app registers a tray icon (was opening an empty panel).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 21:04:28 +01:00

147 lines
4.4 KiB
QML

import QtQuick
import QtQuick.Layouts
import Quickshell.Services.UPower
import Caelestia.Config
import Caelestia.Services
import qs.components
import qs.services
StyledClippingRect {
id: root
property real animPerc: UPower.displayDevice.percentage
color: Colours.palette.m3secondaryContainer
radius: 0 // nosignal: square dashboard cards to match the redesign (F-D1)
implicitWidth: Config.dashboard.performance.showCpu || (Config.dashboard.performance.showGpu && Gpu.type !== Gpu.None) || Config.dashboard.performance.showStorage || Config.dashboard.performance.showMemory ? Tokens.sizes.dashboard.perfBattWidth : Tokens.sizes.dashboard.perfBattWidthSingle
implicitHeight: Tokens.sizes.dashboard.perfBattHeight
Behavior on animPerc {
Anim {}
}
Contents {
id: layout
anchors.fill: parent
anchors.margins: Tokens.padding.medium
accentColour: Colours.palette.m3primary
textColour: Colours.palette.m3onSurface
subTextColour: Colours.palette.m3onSurfaceVariant
}
StyledRect {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
implicitHeight: parent.height * root.animPerc
color: Colours.palette.m3secondary
radius: 0 // nosignal: square dashboard cards to match the redesign (F-D1)
clip: true
Contents {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: layout.anchors.margins
height: layout.height
accentColour: Colours.palette.m3primaryContainer
textColour: Colours.palette.m3onSecondary
subTextColour: Colours.palette.m3secondaryContainer
}
}
component Contents: ColumnLayout {
id: contents
required property color accentColour
required property color textColour
required property color subTextColour
readonly property bool charging: [UPowerDeviceState.Charging, UPowerDeviceState.FullyCharged, UPowerDeviceState.PendingCharge].includes(UPower.displayDevice.state)
spacing: 0
NsIcon {
Layout.leftMargin: -Tokens.padding.extraSmall
icon: "battery_full"
color: contents.accentColour
fontStyle: Tokens.font.icon.large
}
StyledText {
Layout.fillWidth: true
text: qsTr("Battery")
color: contents.textColour
font: Tokens.font.body.medium
}
Item {
Layout.fillHeight: true
}
StyledText {
Layout.alignment: Qt.AlignRight
text: {
if (UPower.displayDevice.state === UPowerDeviceState.FullyCharged)
return qsTr("Full");
if (contents.charging)
return qsTr("Charging");
const s = UPower.displayDevice.timeToEmpty;
if (s === 0)
return qsTr("...");
const hr = Math.floor(s / 3600);
const min = Math.floor((s % 3600) / 60);
if (hr > 0)
return `${hr}h ${min}m`;
return `${min}m`;
}
color: contents.subTextColour
font: Tokens.font.body.small
animate: true
}
RowLayout {
Layout.topMargin: -Tokens.padding.extraSmall
Layout.bottomMargin: -Tokens.padding.small
Layout.rightMargin: -Tokens.padding.extraSmall
Layout.alignment: Qt.AlignRight
spacing: Tokens.spacing.extraSmall
NsIcon {
icon: "bolt"
color: contents.accentColour
fontStyle: Tokens.font.icon.large
fill: 1
scale: contents.charging ? 1 : 0
opacity: contents.charging ? 1 : 0
Behavior on scale {
Anim {
type: Anim.FastSpatial
}
}
Behavior on opacity {
Anim {
type: Anim.FastEffects
}
}
}
StyledText {
text: `${Math.round(UPower.displayDevice.percentage * 100)}%`
color: contents.accentColour
font: Tokens.font.headline.medium
}
}
}
}