Seconds per clock, and type that scales with the bar height

Seconds move from one bar-wide switch to a per-clock setting. A clock's own
`showSeconds` wins, the top-level one is the default for clocks with no
opinion, and the centre clock gets `local.showSeconds` since it has no entry in
`clocks[]`. An explicit false on a clock beats a true default, so the check is
for the property's presence rather than its truthiness.

The tick rate follows what is actually displayed: `anyShowsSeconds()` decides
between a per-second and a per-minute SystemClock, so a bar showing no seconds
does not wake the shell sixty times as often to redraw an identical minute.

`barSize` is now editable from the popup, and everything drawn on the bar is
sized against the theme's own bar height rather than pinned to the theme's
12px type. A taller bar carries proportionally larger text, gaps and rule; at
the theme's own height the scale is exactly 1, so nothing moves. Heights are
clamped to 12-120 rather than rejected, so a value the editor can produce can
never be one the config layer silently discards.

Fixes a latent bug this surfaced: updateRow() rebuilt a draft row from a fixed
pair of fields, so editing a clock's label would have thrown away its own
seconds setting. It now copies every key the row had.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhxtL7WzL5XmuTd8GHbcTY
This commit is contained in:
Harvey
2026-09-04 18:02:36 +02:00
co-authored by Claude Opus 5
parent b5f4569233
commit 8364fe2141
6 changed files with 249 additions and 29 deletions
+17 -2
View File
@@ -38,7 +38,10 @@ QtObject {
],
workingHours: { start: 8, end: 18, workdays: [1, 2, 3, 4, 5] },
dimOutsideWorkingHours: true,
// The bar-wide default for seconds. Any clock, and the centre clock via
// `local`, may override it.
showSeconds: false,
local: { showSeconds: false },
barSize: 0
}
}
@@ -58,7 +61,12 @@ QtObject {
var tz = String(entry.timezone || "").replace(/^\s+|\s+$/g, "")
if (!tz) continue
var label = String(entry.label === undefined || entry.label === null ? "" : entry.label).replace(/^\s+|\s+$/g, "")
clocks.push({ label: label || tz, timezone: tz })
var clock = { label: label || tz, timezone: tz }
// Carried through only when the clock actually sets it, so a clock
// with no opinion keeps inheriting the bar-wide default rather than
// being frozen to whatever it happened to be when this was written.
if (typeof entry.showSeconds === "boolean") clock.showSeconds = entry.showSeconds
clocks.push(clock)
}
out.clocks = clocks
}
@@ -81,8 +89,15 @@ QtObject {
if (typeof raw.dimOutsideWorkingHours === "boolean") out.dimOutsideWorkingHours = raw.dimOutsideWorkingHours
if (typeof raw.showSeconds === "boolean") out.showSeconds = raw.showSeconds
if (raw.local && typeof raw.local === "object" && typeof raw.local.showSeconds === "boolean")
out.local.showSeconds = raw.local.showSeconds
// 0 means "follow the theme". The ceiling is a guard against a typo
// turning the bar into a full-screen panel with no way back to the
// editor that would undo it.
var size = Number(raw.barSize)
if (isFinite(size) && size >= 0 && size <= 200) out.barSize = size
if (isFinite(size) && size > 0) out.barSize = Math.min(120, Math.max(12, Math.round(size)))
else if (isFinite(size)) out.barSize = 0
return out
}