diff options
| author | PFiS <pfis1737@gmail.com> | 2025-08-02 14:19:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-02 16:19:59 +1000 |
| commit | a89a401087455c520c84f346e61055b668b50654 (patch) | |
| tree | c1fdb44e4f4b524950a9957aed86018d4b7c1d25 | |
| parent | bar: add bluetooth connected icon state (#311) (diff) | |
| download | caelestia-shell-a89a401087455c520c84f346e61055b668b50654.tar.gz caelestia-shell-a89a401087455c520c84f346e61055b668b50654.tar.bz2 caelestia-shell-a89a401087455c520c84f346e61055b668b50654.zip | |
osd: animate scrolling (#316)
* refactor: make the animation smooth when scrolling the mouse wheel
* fix: can't drag
* format
* fix cursor
---------
Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
| -rw-r--r-- | modules/osd/Content.qml | 61 | ||||
| -rw-r--r-- | widgets/VerticalSlider.qml | 4 |
2 files changed, 44 insertions, 21 deletions
diff --git a/modules/osd/Content.qml b/modules/osd/Content.qml index 8f78894..a707fb4 100644 --- a/modules/osd/Content.qml +++ b/modules/osd/Content.qml @@ -15,29 +15,54 @@ Column { spacing: Appearance.spacing.normal - VerticalSlider { - icon: { - if (Audio.muted) - return "no_sound"; - if (value >= 0.5) - return "volume_up"; - if (value > 0) - return "volume_down"; - return "volume_mute"; - } - value: Audio.volume - onMoved: Audio.setVolume(value) - + CustomMouseArea { implicitWidth: Config.osd.sizes.sliderWidth implicitHeight: Config.osd.sizes.sliderHeight - } - VerticalSlider { - icon: `brightness_${(Math.round(value * 6) + 1)}` - value: root.monitor?.brightness ?? 0 - onMoved: root.monitor?.setBrightness(value) + onWheel: event => { + if (event.angleDelta.y > 0) + Audio.setVolume(Audio.volume + 0.1); + else if (event.angleDelta.y < 0) + Audio.setVolume(Audio.volume - 0.1); + } + VerticalSlider { + anchors.fill: parent + + icon: { + if (Audio.muted) + return "no_sound"; + if (value >= 0.5) + return "volume_up"; + if (value > 0) + return "volume_down"; + return "volume_mute"; + } + value: Audio.volume + onMoved: Audio.setVolume(value) + } + } + + CustomMouseArea { implicitWidth: Config.osd.sizes.sliderWidth implicitHeight: Config.osd.sizes.sliderHeight + + onWheel: event => { + const monitor = root.monitor; + if (!monitor) + return; + if (event.angleDelta.y > 0) + monitor.setBrightness(monitor.brightness + 0.1); + else if (event.angleDelta.y < 0) + monitor.setBrightness(monitor.brightness - 0.1); + } + + VerticalSlider { + anchors.fill: parent + + icon: `brightness_${(Math.round(value * 6) + 1)}` + value: root.monitor?.brightness ?? 0 + onMoved: root.monitor?.setBrightness(value) + } } } diff --git a/widgets/VerticalSlider.qml b/widgets/VerticalSlider.qml index 2c064c4..21bdc7a 100644 --- a/widgets/VerticalSlider.qml +++ b/widgets/VerticalSlider.qml @@ -11,8 +11,6 @@ Slider { required property string icon property real oldValue - wheelEnabled: true - orientation: Qt.Vertical background: StyledRect { @@ -59,7 +57,7 @@ Slider { MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor - onPressed: event => event.accepted = false + acceptedButtons: Qt.NoButton } MaterialIcon { |