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>
pull/69/head
Michele Calgaro 11 months ago
parent 99f7cd1932
commit 7589d48a41
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -35,6 +35,7 @@
#include <tqmessagebox.h> #include <tqmessagebox.h>
#include <tqfile.h> #include <tqfile.h>
#include <tqdir.h> #include <tqdir.h>
#include <tqtimer.h>
#define CONFIG_FILE "kmilodrc" #define CONFIG_FILE "kmilodrc"
@ -275,47 +276,30 @@ void GenericMonitor::brightnessSlowDown()
void GenericMonitor::brightnessChange(int direction, int step) void GenericMonitor::brightnessChange(int direction, int step)
{ {
if (!tdepowersave) if (!tdepowersave || direction == 0)
{ {
return; 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"); DCOPReply reply = tdepowersave->call("brightnessGet");
if (reply.isValid()) if (reply.isValid())
{ {
int brightnessLevel = (int)reply; // Display real brightness value. This may differ from the set value
if (brightnessLevel >= 0) // on machines with few brightness steps.
{ _interface->displayProgress(i18n("Brightness"), (int)reply);
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);
}
}
} }
} }

@ -71,6 +71,9 @@ public slots:
void lightBulb(); void lightBulb();
void pmBattery(); void pmBattery();
private slots:
void brightnessValueUpdate();
private: private:
void volumeChange(int direction, int percentage); void volumeChange(int direction, int percentage);
bool retrieveMute(bool &muted); bool retrieveMute(bool &muted);

Loading…
Cancel
Save