diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-12-02 23:42:46 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-12-02 23:50:26 +0900 |
commit | 7589d48a4101244c3c7a27931293ee7924f78119 (patch) | |
tree | aed6f02a47eb138bb6d25ba3115a381e34d0c75a /kmilo | |
parent | 99f7cd1932291ac8fe822b13cd1077da6433f279 (diff) | |
download | tdeutils-7589d48a4101244c3c7a27931293ee7924f78119.tar.gz tdeutils-7589d48a4101244c3c7a27931293ee7924f78119.zip |
kmilo: after changing the screen brightness, allows a small delay before popping up the OSD feedback. This allows the underlying hardware to report the correct value. This resolves issue #68.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kmilo')
-rw-r--r-- | kmilo/generic/generic_monitor.cpp | 52 | ||||
-rw-r--r-- | kmilo/generic/generic_monitor.h | 3 |
2 files changed, 21 insertions, 34 deletions
diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp index 435b6df..b1f00c1 100644 --- a/kmilo/generic/generic_monitor.cpp +++ b/kmilo/generic/generic_monitor.cpp @@ -35,6 +35,7 @@ #include <tqmessagebox.h> #include <tqfile.h> #include <tqdir.h> +#include <tqtimer.h> #define CONFIG_FILE "kmilodrc" @@ -275,47 +276,30 @@ void GenericMonitor::brightnessSlowDown() void GenericMonitor::brightnessChange(int direction, int step) { - if (!tdepowersave) + if (!tdepowersave || direction == 0) { return; } + if (direction > 0) + { + tdepowersave->call("do_brightnessUp", step); + } + else + { + tdepowersave->call("do_brightnessDown", step); + } + TQTimer::singleShot(250, this, TQT_SLOT(brightnessValueUpdate())); +} + +void GenericMonitor::brightnessValueUpdate() +{ DCOPReply reply = tdepowersave->call("brightnessGet"); if (reply.isValid()) { - int brightnessLevel = (int)reply; - if (brightnessLevel >= 0) - { - 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); - } - - DCOPReply reply = tdepowersave->call("brightnessGet"); - if (reply.isValid()) - { - // Display real brightness value. This may differ from the set value - // on machines with few brightness steps. - _interface->displayProgress(i18n("Brightness"), (int)reply); - } - else - { - _interface->displayProgress(i18n("Brightness"), brightnessLevel); - } - } + // Display real brightness value. This may differ from the set value + // on machines with few brightness steps. + _interface->displayProgress(i18n("Brightness"), (int)reply); } } diff --git a/kmilo/generic/generic_monitor.h b/kmilo/generic/generic_monitor.h index 9ec3184..851277d 100644 --- a/kmilo/generic/generic_monitor.h +++ b/kmilo/generic/generic_monitor.h @@ -71,6 +71,9 @@ public slots: void lightBulb(); void pmBattery(); +private slots: + void brightnessValueUpdate(); + private: void volumeChange(int direction, int percentage); bool retrieveMute(bool &muted); |