Files
qbz/crates/qbz-qt/qml/QbzSlider.qml
T
vicrodh ea644f5e05 feat(qbz-qt): phase 19 — full Settings subnav, Appearance + Integrations, live theming
Theme system as data: qbz_theme registry (36 themes + auto/custom)
resolved from the shared ui_prefs slug into a themeJson document;
QbzTheme rebound to it so the whole app repaints live (OLED->Light
probe-verified). Full subnav (8 sections + Share logs footer);
Appearance 1:1 (theme dropdown with dark/light filter, ambient/titlebar
rows in their real home, typography, library visuals, window chrome,
tray via tray_settings.db, renderer); Integrations 1:1 (MusicBrainz,
Last.fm 2-step browser connect + authed state, ListenBrainz token
validate, Discord toggle -> live DiscordRpc.set_enabled). Offline/Local
Library/Blacklist/Developer render honest placeholders.

km
2026-07-28 06:13:04 -06:00

75 lines
2.4 KiB
QML

// QbzSlider (primitives/QbzSlider.slint) — extracted from SettingsView.qml
// in phase 19. 200x22, 4px r2 track, accent fill, 16px thumb; integer
// steps. Like the Slint original the thumb follows the pointer during a
// drag (local dragValue) and commits each step via changed(int).
import QtQuick
import com.blitzfc.qbz
Item {
property int minimum: 0
property int maximum: 10
property int value: 0
signal changed(int newValue)
QbzTheme { id: theme }
width: 200
height: 22
readonly property int thumbSize: 16
readonly property real travel: width - thumbSize
readonly property real fraction: maximum > minimum
? Math.max(0, Math.min(1, (value - minimum) / (maximum - minimum))) : 0
property bool dragging: false
property real dragFraction: fraction
readonly property real shownFraction: dragging ? dragFraction : fraction
onFractionChanged: if (!dragging) dragFraction = fraction
function commit(frac) {
const v = Math.round(minimum + Math.max(0, Math.min(1, frac)) * (maximum - minimum))
if (v !== value) changed(v)
}
Rectangle { // track
x: 0
y: Math.round((parent.height - height) / 2)
width: parent.width
height: 4
radius: 2
color: theme.surfaceElevated
}
Rectangle { // accent fill
x: 0
y: Math.round((parent.height - height) / 2)
width: parent.thumbSize / 2 + parent.shownFraction * parent.travel
height: 4
radius: 2
color: theme.accent
}
Rectangle { // thumb
width: parent.thumbSize
height: parent.thumbSize
radius: parent.thumbSize / 2
x: parent.shownFraction * parent.travel
anchors.verticalCenter: parent.verticalCenter
color: theme.textPrimary
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onPressed: {
parent.dragging = true
parent.dragFraction = Math.max(0, Math.min(1, (mouse.x - parent.thumbSize / 2) / parent.travel))
parent.commit(parent.dragFraction)
}
onPositionChanged: {
if (pressed) {
parent.dragFraction = Math.max(0, Math.min(1, (mouse.x - parent.thumbSize / 2) / parent.travel))
parent.commit(parent.dragFraction)
}
}
onReleased: parent.dragging = false
}
}