config: allow enable/disable osd brightness (#481)

* Added option to disable brightness slider

* Removed unwanted imports

* Renamed WrappedLoader.name to brightnessSlider

* fixes

---------

Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
Faiz Khan 2025-08-27 10:57:49 +05:30 committed by GitHub
parent 1a9c6785a1
commit cdfc260f39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 17 deletions

View file

@ -324,6 +324,8 @@ default, you must create it manually.
"expire": false
},
"osd": {
"enabled": true,
"enableBrightness": true,
"hideDelay": 2000
},
"paths": {

View file

@ -3,6 +3,7 @@ import Quickshell.Io
JsonObject {
property bool enabled: true
property int hideDelay: 2000
property bool enableBrightness: true
property Sizes sizes: Sizes {}
component Sizes: JsonObject {

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import qs.components.controls
import qs.services
import qs.config
@ -16,6 +18,7 @@ Column {
spacing: Appearance.spacing.normal
// Speaker volume
CustomMouseArea {
implicitWidth: Config.osd.sizes.sliderWidth
implicitHeight: Config.osd.sizes.sliderHeight
@ -36,26 +39,35 @@ Column {
}
}
CustomMouseArea {
implicitWidth: Config.osd.sizes.sliderWidth
implicitHeight: Config.osd.sizes.sliderHeight
// Brightness
WrappedLoader {
active: Config.osd.enableBrightness
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);
}
sourceComponent: CustomMouseArea {
implicitWidth: Config.osd.sizes.sliderWidth
implicitHeight: Config.osd.sizes.sliderHeight
FilledSlider {
anchors.fill: parent
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);
}
icon: `brightness_${(Math.round(value * 6) + 1)}`
value: root.monitor?.brightness ?? 0
onMoved: root.monitor?.setBrightness(value)
FilledSlider {
anchors.fill: parent
icon: `brightness_${(Math.round(value * 6) + 1)}`
value: root.monitor?.brightness ?? 0
onMoved: root.monitor?.setBrightness(value)
}
}
}
component WrappedLoader: Loader {
asynchronous: true
visible: active
}
}