Files
qbz/crates/qbz-qt/qml/controls/CardOverlayButton.qml
T
vicrodh 81c43a114e fix(qt): glyph colours follow the theme, on light palettes and on accent fills
Two defects with one cause: a tint name that means a frozen hex.

"primary" is the legacy alias of literal #ffffff, not Theme.text-primary,
so every control passing it drew a white glyph. On the eleven light
themes that is white-on-light -- the header back/forward chevrons, the
sidebar toggle and the carousel arrows the owner marked. They now pass
the theme-following names, which icon_tint_qt bakes at runtime.

The stale `hslLightness > 0.5 ? "primary" : "black"` workarounds that
predate the runtime tinter collapse into those names, and the qrc floor
underneath them becomes polarity-aware: dir_for() returns "" whenever
the cache dir is unavailable, a bake fails or the theme document has not
been published, and that path used to resolve textPrimary straight back
to the white bake -- reproducing the bug it was fixing, app-wide, in the
degraded state.

On accent fills the fix is a deviation from Slint, approved by the owner
after measurement. A fixed white glyph on Theme.accent falls under 2.6:1
on 16 of the 35 shipped palettes, including high-contrast at 1.70:1 and
wcag-dark at 1.82:1 -- the two themes whose reason to exist is contrast.
Slint hardcodes #ffffff there (CircleAction.slint:72 and three others),
so the bug is upstream. accentText alone is not the answer either: it is
picked for the theme's text ramp and gives 2.56:1 on Rose Pine Dawn,
worse than the black it replaces. So QbzTheme picks the best-contrast
tint by real sRGB luminance against the live accent, and the labels
beside those glyphs use its colour twin -- BrowseGenreButton and
LibraryView were drawing a white glyph next to an accentText label
inside the same pill.

Rounds out the two parity items the same files owe: QbzNavButton gains
the ambient arm from Carousel.slint (wired at the six carousel sites,
not left dead), and QbzCircleAction rounds its glyph to whole pixels the
way CircleAction.slint does.

cc
2026-07-29 10:30:43 -06:00

48 lines
1.8 KiB
QML

// CardOverlayButton — the shared card hover-overlay button (the Slint
// per-card OverlayButton copies, homologated in the POC at
// LibraryView.LibOverlayBtn and promoted to shared in phase 21):
// primary = 44px white disc (black icon), ghost = 36px translucent disc
// (1.5px border); `active` tints the icon accent (follow/heart state).
import QtQuick
import com.blitzfc.qbz
import "../theme"
Rectangle {
property string name: ""
property bool primary: false
property bool active: false
// Forwards the MouseArea event. Three cards write
// `onClicked: function (mouse) { menu.openAtCursor(btn, mouse.x, mouse.y) }`
// against this signal; while it took no argument, `mouse` was undefined and
// those context menus threw a TypeError instead of opening.
signal clicked(var mouse)
width: primary ? 44 : 36
height: primary ? 44 : 36
radius: width / 2
color: primary ? (obArea.containsMouse ? "#d6ffffff" : "#ffffff")
: (obArea.containsMouse ? "#3dffffff" : "#24ffffff")
border.width: primary ? 0 : 1.5
border.color: "#ccffffff"
QbzIcon {
name: parent.name
width: primary ? 18 : 16
height: primary ? 18 : 16
anchors.centerIn: parent
// Both non-accent arms are theme-INDEPENDENT by design: this button
// only ever sits on artwork. `primary` is a solid #ffffff disc (black
// glyph), the ghost arm is #24ffffff over the artwork itself (white
// glyph). "white" is the explicit spelling of what "primary" baked.
tintName: parent.active ? "accent" : (parent.primary ? "black" : "white")
}
property alias hovered: obArea.containsMouse
MouseArea {
id: obArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: function (m) { parent.clicked(m) }
}
}