From b80615e21d25ca3e334a3c2d5b6cf2218ba472d3 Mon Sep 17 00:00:00 2001 From: SomeElse Date: Wed, 20 May 2026 01:55:33 +0000 Subject: [PATCH] tweaked Volume.qml to support typing the number instead of using the slider or the buttons --- bar/modules/Volume.qml | 47 ++++++++++++++++++++++++++++++++++++++---- config/config.qml | 4 ++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/bar/modules/Volume.qml b/bar/modules/Volume.qml index 5214b34..af96889 100644 --- a/bar/modules/Volume.qml +++ b/bar/modules/Volume.qml @@ -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 { diff --git a/config/config.qml b/config/config.qml index d398770..b1932e7 100644 --- a/config/config.qml +++ b/config/config.qml @@ -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