nosignal-shell/modules/dashboard/performance/HeroCard.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

148 lines
4.3 KiB
QML

import QtQuick
import QtQuick.Layouts
import M3Shapes
import Caelestia.Config
import qs.components
import qs.components.controls
import qs.services
StyledRect {
id: root
required property string icon
required property string label
required property string subLabel
required property color accent
required property real usage
required property real temperature
color: Colours.tPalette.m3surfaceContainer
radius: 0 // nosignal: square dashboard cards to match the redesign (F-D1)
implicitWidth: Tokens.sizes.dashboard.perfHeroCardWidth
implicitHeight: Math.max(tempProg.implicitHeight + detailsRow.implicitHeight + Tokens.spacing.large, usageShape.implicitHeight + usageLabel.implicitHeight) + Tokens.padding.large * 2
CircularProgress {
id: tempProg
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: Tokens.padding.large
fgColour: root.accent
spacing: Tokens.spacing.extraSmall
strokeWidth: Tokens.padding.extraSmall
implicitSize: Math.max(icon.implicitWidth, icon.implicitHeight) + Tokens.padding.medium * 2
value: root.usage
Behavior on clampedVal {
Anim {}
}
NsIcon {
id: icon
anchors.centerIn: parent
icon: root.icon
color: root.accent
fontStyle: Tokens.font.icon.medium
}
}
ColumnLayout {
anchors.left: tempProg.right
anchors.right: usageShape.left
anchors.verticalCenter: tempProg.verticalCenter
anchors.margins: Tokens.spacing.large
spacing: Tokens.spacing.extraSmall
StyledText {
text: root.label
font: Tokens.font.title.medium
color: root.accent
}
StyledText {
Layout.fillWidth: true
text: root.subLabel
font: Tokens.font.body.small
color: Colours.palette.m3onSurfaceVariant
elide: Text.ElideRight
}
}
ColumnLayout {
id: detailsRow
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: Tokens.padding.largeIncreased
spacing: Tokens.spacing.extraSmall
RowLayout {
Layout.leftMargin: -Tokens.padding.extraSmall
spacing: Tokens.spacing.extraSmall
NsIcon {
Layout.topMargin: Math.round(fontInfo.pointSize * 0.08)
icon: root.temperature > 90 ? "thermometer_alert" : "thermometer"
color: root.temperature > 90 ? Colours.palette.m3error : root.accent
fontStyle: Tokens.font.icon.medium
fill: 1
}
StyledText {
text: `${Math.ceil(GlobalConfig.services.useFahrenheitPerformance ? root.temperature * 1.8 + 32 : root.temperature)}°${GlobalConfig.services.useFahrenheitPerformance ? "F" : "C"}`
font: Tokens.font.body.builders.medium.build()
}
}
StyledProgressBar {
value: root.temperature / 100
implicitHeight: Tokens.padding.small
fgColour: root.accent
indeterminate: isNaN(root.usage) || isNaN(root.temperature)
}
}
MaterialShape {
id: usageShape
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: Tokens.padding.medium
implicitSize: Tokens.sizes.dashboard.perfUsageShapeSize
color: Colours.palette.m3secondaryContainer
shape: {
if (root.usage >= 0.8)
return MaterialShape.SoftBurst;
if (root.usage >= 0.4)
return MaterialShape.Sunny;
return MaterialShape.Cookie4Sided;
}
Behavior on color {
CAnim {}
}
StyledText {
id: usageLabel
anchors.bottom: parent.top
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Usage")
color: Colours.palette.m3onSurfaceVariant
font: Tokens.font.body.small
}
StyledText {
anchors.centerIn: parent
text: isNaN(root.usage) ? "...%" : Math.round(root.usage * 100) + "%"
color: root.accent
font: Tokens.font.headline.builders.small.width(50).build()
}
}
}