Small cleanups: reuse Util.clamp in OSD; PanelSlider hover via _hot

OSD reimplemented clamp() inline when Util already has one.

PanelSlider's knob-scale binding read `mouseArea.containsMouse` directly
instead of going through a `_hot` like the other interactive controls
(TextField, NumberField, Dropdown). Mirror them so future style work
has a single property to override.
This commit is contained in:
David Heinemeier Hansson
2026-05-20 20:33:27 +02:00
parent 04e7820ebe
commit 8ed6e302b0
2 changed files with 3 additions and 4 deletions
+1 -3
View File
@@ -15,8 +15,6 @@ Item {
property bool hasProgress: true
property int duration: 1200
function clamp(v, min, max) { return Math.max(min, Math.min(max, v)) }
function iconFor(name, percent) {
var n = String(name || "").toLowerCase()
if (n === "volume-muted" || n === "volume-mute" || n === "muted" || n === "mute") return ""
@@ -41,7 +39,7 @@ Item {
maxValue = Math.max(1, parseInt(rawMax || "100", 10))
var parsed = parseInt(rawValue || "0", 10)
hasProgress = rawValue !== "" && !isNaN(parsed) && rawMessage === ""
value = hasProgress ? clamp(parsed, 0, maxValue) : 0
value = hasProgress ? Util.clamp(parsed, 0, maxValue) : 0
message = String(rawMessage || (hasProgress ? (rawProgressText || Math.round(value * 100 / maxValue) + "%") : ""))
icon = iconFor(iconName, hasProgress ? Math.round(value * 100 / maxValue) : -1)
var parsedDuration = parseInt(rawDuration || "1200", 10)