From ae4a3892ffe9abb2f3b0b1c5612282886b1e9c40 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 23 Aug 2023 13:17:05 +0900 Subject: Adjust brightness control to the corrected 'brightnessGet' DCOP call in tdepowersave Signed-off-by: Michele Calgaro --- kmilo/generic/generic_monitor.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp index 739b266..5751037 100644 --- a/kmilo/generic/generic_monitor.cpp +++ b/kmilo/generic/generic_monitor.cpp @@ -283,25 +283,28 @@ void GenericMonitor::brightnessChange(int direction, int step) DCOPReply reply = tdepowersave->call("brightnessGet"); if (reply.isValid()) { - int brightnessLevel = 100 + (int)reply; // reply value is a negative number between 0 and -100. - brightnessLevel += direction * step; // add requested brightness step - if (brightnessLevel > 100) + int brightnessLevel = (int)reply; + if (brightnessLevel >= 0) { - brightnessLevel = 100; + brightnessLevel += direction * step; // add requested brightness step + if (brightnessLevel > 100) + { + brightnessLevel = 100; + } + if (brightnessLevel < 0) + { + brightnessLevel = 0; + } + if (direction > 0) + { + tdepowersave->send("do_brightnessUp", step); + } + else if (direction < 0) + { + tdepowersave->send("do_brightnessDown", step); + } + _interface->displayProgress(i18n("Brightness"), brightnessLevel); } - if (brightnessLevel < 0) - { - brightnessLevel = 0; - } - if (direction > 0) - { - tdepowersave->send("do_brightnessUp", step); - } - else if (direction < 0) - { - tdepowersave->send("do_brightnessDown", step); - } - _interface->displayProgress(i18n("Brightness"), brightnessLevel); } } -- cgit v1.2.1