nosignal-shell/modules/dashboard/dash/Calendar.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

214 lines
6.7 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import M3Shapes
import Caelestia.Config
import qs.components
import qs.components.controls
import qs.components.effects
import qs.services
CustomMouseArea {
id: root
required property DashboardState dashState
readonly property int currMonth: dashState.currentDate.getMonth()
readonly property int currYear: dashState.currentDate.getFullYear()
function onWheel(event: WheelEvent): void {
if (event.angleDelta.y > 0)
root.dashState.currentDate = new Date(root.currYear, root.currMonth - 1, 1);
else if (event.angleDelta.y < 0)
root.dashState.currentDate = new Date(root.currYear, root.currMonth + 1, 1);
}
anchors.left: parent.left
anchors.right: parent.right
implicitHeight: inner.implicitHeight + inner.anchors.margins * 2
acceptedButtons: Qt.MiddleButton
onClicked: root.dashState.currentDate = new Date()
ColumnLayout {
id: inner
anchors.fill: parent
anchors.margins: Tokens.padding.large
spacing: Tokens.spacing.extraSmall
RowLayout {
id: monthNavigationRow
Layout.fillWidth: true
spacing: Tokens.spacing.extraSmall
IconButton {
icon: "chevron_left"
type: IconButton.Text
font: Tokens.font.icon.builders.small.weight(Font.Bold).build()
padding: Tokens.padding.small
onClicked: root.dashState.currentDate = new Date(root.currYear, root.currMonth - 1, 1)
}
Item {
Layout.fillWidth: true
Layout.fillHeight: true
implicitWidth: monthYearDisplay.implicitWidth + Tokens.padding.large * 2
implicitHeight: monthYearDisplay.implicitHeight + Tokens.padding.extraSmall * 2
StateLayer {
color: Colours.palette.m3primary
radius: 0 // nosignal: square dashboard cards to match the redesign (F-D1)
disabled: {
const now = new Date();
return root.currMonth === now.getMonth() && root.currYear === now.getFullYear();
}
onClicked: root.dashState.currentDate = new Date()
Behavior on radius {
Anim {
type: Anim.DefaultEffects
}
}
}
StyledText {
id: monthYearDisplay
anchors.centerIn: parent
text: grid.title
color: Colours.palette.m3primary
font: Tokens.font.title.builders.small.capitalisation(Font.Capitalize).build()
}
}
IconButton {
icon: "chevron_right"
type: IconButton.Text
font: Tokens.font.icon.builders.small.weight(Font.Bold).build()
padding: Tokens.padding.small
onClicked: root.dashState.currentDate = new Date(root.currYear, root.currMonth + 1, 1)
}
}
DayOfWeekRow {
id: daysRow
Layout.fillWidth: true
locale: grid.locale
delegate: StyledText {
required property var model
horizontalAlignment: Text.AlignHCenter
text: model.shortName
font: Tokens.font.body.builders.small.weight(Font.Medium).build()
color: (model.day === 0 || model.day === 6) ? Colours.palette.m3tertiary : Colours.palette.m3onSurface
}
}
Item {
Layout.fillWidth: true
implicitHeight: grid.implicitHeight
MonthGrid {
id: grid
month: root.currMonth
year: root.currYear
anchors.fill: parent
spacing: 3
locale: Qt.locale()
delegate: Item {
id: dayItem
required property var model
implicitWidth: implicitHeight
implicitHeight: text.implicitHeight + Tokens.padding.small
StyledText {
id: text
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
text: grid.locale.toString(dayItem.model.day)
color: {
const dayOfWeek = dayItem.model.date.getDay();
if (dayOfWeek === 0 || dayOfWeek === 6)
return Colours.palette.m3tertiary;
return Colours.palette.m3onSurfaceVariant;
}
opacity: dayItem.model.today || dayItem.model.month === grid.month ? 1 : 0.4
font: Tokens.font.body.small
}
}
}
MaterialShape {
id: todayIndicator
readonly property Item todayItem: grid.contentItem.children.find(c => c.model.today) ?? null
property Item today
onTodayItemChanged: {
if (todayItem)
today = todayItem;
}
x: today ? today.x + (today.width - implicitWidth) / 2 : 0
y: today ? today.y - Tokens.padding.extraSmall - 1 : 0
implicitSize: today ? Math.max(today.implicitWidth, today.implicitHeight) + Tokens.padding.extraSmall * 2 : 0
shape: MaterialShape.Sunny
clip: true
color: Colours.palette.m3primary
opacity: todayItem ? 1 : 0
scale: todayItem ? 1 : 0.7
Colouriser {
x: -todayIndicator.x
y: -todayIndicator.y
implicitWidth: grid.width
implicitHeight: grid.height
source: grid
sourceColor: Colours.palette.m3onSurface
colorizationColor: Colours.palette.m3onPrimary
}
Behavior on opacity {
Anim {
type: Anim.DefaultEffects
}
}
Behavior on scale {
Anim {
type: Anim.FastSpatial
}
}
Behavior on x {
Anim {}
}
Behavior on y {
Anim {}
}
}
}
}
}