tweaked Volume.qml to support typing the number instead of using the slider or the buttons

This commit is contained in:
SomeElse
2026-05-20 01:55:33 +00:00
parent 01619f4af4
commit b80615e21d
2 changed files with 45 additions and 6 deletions

View File

@@ -148,6 +148,7 @@ ModuleChip {
cardColor: t.volPopupBg
cardBorderColor: t.volPopupBorder
cardHeight: popupCol.implicitHeight + 34
hasKeyboardFocus: true
ColumnLayout {
id: popupCol
@@ -227,6 +228,7 @@ ModuleChip {
borderColor: root.t.volPopupBorder
onDecrement: root.outputMaxVolume = Math.max(10, root.outputMaxVolume - 10)
onIncrement: root.outputMaxVolume = Math.min(300, root.outputMaxVolume + 10)
onValueSet: root.outputMaxVolume = Math.max(10, Math.min(300, val))
}
LimitRow {
Layout.fillWidth: true
@@ -241,6 +243,7 @@ ModuleChip {
borderColor: root.t.volPopupBorder
onDecrement: root.inputMaxVolume = Math.max(10, root.inputMaxVolume - 10)
onIncrement: root.inputMaxVolume = Math.min(300, root.inputMaxVolume + 10)
onValueSet: root.inputMaxVolume = Math.max(10, Math.min(300, val))
}
}
Item { height: 2 }
@@ -291,14 +294,31 @@ ModuleChip {
Layout.fillWidth: true
renderType: Text.NativeRendering
}
Text {
TextInput {
text: vs.muted ? "muted" : vs.volume + "%"
color: vs.muted ? vs.dimColor : vs.textColor
font.pixelSize: 12
font.bold: !vs.muted
horizontalAlignment: Text.AlignHCenter
horizontalAlignment: TextInput.AlignHCenter
verticalAlignment: TextInput.AlignVCenter
Layout.preferredWidth: 44
renderType: Text.NativeRendering
readOnly: vs.muted
selectByMouse: true
activeFocusOnPress: true
onAccepted: {
if (!vs.muted) {
let val = parseInt(text.replace("%", "").trim(), 10)
if (!isNaN(val)) vs.sliderMoved(Math.max(0, Math.min(vs.maxVolume, val)))
text = vs.volume + "%"
}
}
onActiveFocusChanged: {
if (activeFocus && !vs.muted) {
text = vs.volume.toString()
selectAll()
}
}
}
Rectangle {
@@ -465,6 +485,7 @@ ModuleChip {
signal decrement()
signal increment()
signal valueSet(int val)
Text { text: lr.icon; color: lr.iconColor; font.pixelSize: 13; font.bold: true; renderType: Text.NativeRendering }
Text {
@@ -491,13 +512,31 @@ ModuleChip {
HoverHandler { id: decHover; cursorShape: Qt.PointingHandCursor }
TapHandler { onTapped: { if (lr.value > lr.minValue) lr.decrement() } }
}
Text {
TextInput {
text: lr.value + "%"
color: lr.textColor
font.pixelSize: 12; font.bold: true
horizontalAlignment: Text.AlignHCenter
horizontalAlignment: TextInput.AlignHCenter
verticalAlignment: TextInput.AlignVCenter
Layout.preferredWidth: 44
renderType: Text.NativeRendering
selectByMouse: true
activeFocusOnPress: true
onAccepted: {
let val = parseInt(text.replace("%", "").trim(), 10)
if (!isNaN(val)) lr.valueSet(Math.max(lr.minValue, Math.min(lr.maxValue, val)))
text = lr.value + "%"
}
onActiveFocusChanged: {
if (activeFocus) {
text = lr.value.toString()
selectAll()
} else {
let val = parseInt(text.replace("%", "").trim(), 10)
if (!isNaN(val)) lr.valueSet(Math.max(lr.minValue, Math.min(lr.maxValue, val)))
text = lr.value + "%"
}
}
}
Rectangle {

View File

@@ -50,7 +50,7 @@ QtObject {
// ── Timezone (IANA name, e.g. "America/New_York", "Europe/London") ──────────
// Leave empty to use the system timezone.
property string timezone: "America/New_York"
property string timezone: ""
// Date format used in the clock popup and background date widget.
// "MDY" → month/day/year (e.g. May 14, 2026)
@@ -77,7 +77,7 @@ QtObject {
property int volumeSliderHeight: 2
property int volumeHandleSize: 20
property int volumePopupWidth: 280
property int volumeOutputMax: 190
property int volumeOutputMax: 100
property int volumeInputMax: 200