diff options
Diffstat (limited to 'kmilo/generic/generic_monitor.cpp')
-rw-r--r-- | kmilo/generic/generic_monitor.cpp | 89 |
1 files changed, 49 insertions, 40 deletions
diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp index 44d540c..b46425c 100644 --- a/kmilo/generic/generic_monitor.cpp +++ b/kmilo/generic/generic_monitor.cpp @@ -1,4 +1,3 @@ -// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*- /* This file is part of the KDE project @@ -36,6 +35,7 @@ #include <tqmessagebox.h> #include <tqfile.h> #include <tqdir.h> +#include <tqtimer.h> #define CONFIG_FILE "kmilodrc" @@ -52,25 +52,27 @@ struct ShortcutInfo static const ShortcutInfo shortcuts[] = { - { "Search", TDEShortcut("XF86Search"), TQT_SLOT(launchSearch()) }, - { "Home Folder", TDEShortcut("XF86MyComputer"), TQT_SLOT(launchHomeFolder()) }, - { "Mail", TDEShortcut("XF86Mail"), TQT_SLOT(launchMail()) }, - { "Audio Media", TDEShortcut("XF86AudioMedia"), TQT_SLOT(launchMusic()) }, - { "Music", TDEShortcut("XF86Music"), TQT_SLOT(launchMusic()) }, - { "Browser", TDEShortcut("XF86WWW"), TQT_SLOT(launchBrowser()) }, - { "Calculator", TDEShortcut("XF86Calculator"), TQT_SLOT(launchCalculator()) }, - { "Terminal", TDEShortcut("XF86Terminal"), TQT_SLOT(launchTerminal()) }, - { "Eject", TDEShortcut("XF86Eject"), TQT_SLOT(eject()) }, - { "Help", TDEShortcut("XF86Launch0"), TQT_SLOT(launchHelp()) }, - { "Light Bulb", TDEShortcut("XF86LightBulb"), TQT_SLOT(lightBulb()) }, - { "Battery", TDEShortcut("XF86LaunchB"), TQT_SLOT(pmBattery()) }, - { "FastVolumeUp", TQt::Key_VolumeUp, TQT_SLOT(fastVolumeUp()) }, - { "FastVolumeDown", TQt::Key_VolumeDown, TQT_SLOT(fastVolumeDown()) }, - { "SlowVolumeUp", TQt::CTRL+TQt::Key_VolumeUp, TQT_SLOT(slowVolumeUp()) }, - { "SlowVolumeDown", TQt::CTRL+TQt::Key_VolumeDown, TQT_SLOT(slowVolumeDown()) }, - { "Mute", TDEShortcut("XF86AudioMute"), TQT_SLOT(toggleMute()) }, - { "BrightnessUp", TDEShortcut("XF86MonBrightnessUp"), TQT_SLOT(brightnessUp()) }, - { "BrightnessDown", TDEShortcut("XF86MonBrightnessDown"), TQT_SLOT(brightnessDown()) } + { "Search", TDEShortcut("XF86Search"), TQ_SLOT(launchSearch()) }, + { "Home Folder", TDEShortcut("XF86MyComputer"), TQ_SLOT(launchHomeFolder()) }, + { "Mail", TDEShortcut("XF86Mail"), TQ_SLOT(launchMail()) }, + { "Audio Media", TDEShortcut("XF86AudioMedia"), TQ_SLOT(launchMusic()) }, + { "Music", TDEShortcut("XF86Music"), TQ_SLOT(launchMusic()) }, + { "Browser", TDEShortcut("XF86WWW"), TQ_SLOT(launchBrowser()) }, + { "Calculator", TDEShortcut("XF86Calculator"), TQ_SLOT(launchCalculator()) }, + { "Terminal", TDEShortcut("XF86Terminal"), TQ_SLOT(launchTerminal()) }, + { "Eject", TDEShortcut("XF86Eject"), TQ_SLOT(eject()) }, + { "Help", TDEShortcut("XF86Launch0"), TQ_SLOT(launchHelp()) }, + { "Light Bulb", TDEShortcut("XF86LightBulb"), TQ_SLOT(lightBulb()) }, + { "Battery", TDEShortcut("XF86LaunchB"), TQ_SLOT(pmBattery()) }, + { "FastVolumeUp", TQt::Key_VolumeUp, TQ_SLOT(fastVolumeUp()) }, + { "FastVolumeDown", TQt::Key_VolumeDown, TQ_SLOT(fastVolumeDown()) }, + { "SlowVolumeUp", TQt::CTRL+TQt::Key_VolumeUp, TQ_SLOT(slowVolumeUp()) }, + { "SlowVolumeDown", TQt::CTRL+TQt::Key_VolumeDown, TQ_SLOT(slowVolumeDown()) }, + { "Mute", TDEShortcut("XF86AudioMute"), TQ_SLOT(toggleMute()) }, + { "BrightnessUp", TDEShortcut("XF86MonBrightnessUp"), TQ_SLOT(brightnessUp()) }, + { "BrightnessDown", TDEShortcut("XF86MonBrightnessDown"), TQ_SLOT(brightnessDown()) }, + { "BrightnessSlowUp", TDEShortcut("Ctrl+XF86MonBrightnessUp"), TQ_SLOT(brightnessSlowUp()) }, + { "BrightnessSlowDown", TDEShortcut("Ctrl+XF86MonBrightnessDown"), TQ_SLOT(brightnessSlowDown()) } }; GenericMonitor::GenericMonitor(TQObject *parent, const char *name, const TQStringList& args) @@ -262,35 +264,42 @@ void GenericMonitor::brightnessDown() brightnessChange(-1, 10); } +void GenericMonitor::brightnessSlowUp() +{ + brightnessChange(1, 1); +} + +void GenericMonitor::brightnessSlowDown() +{ + brightnessChange(-1, 1); +} + 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, TQ_SLOT(brightnessValueUpdate())); +} + +void GenericMonitor::brightnessValueUpdate() +{ 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) - { - 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); + // Display real brightness value. This may differ from the set value + // on machines with few brightness steps. + _interface->displayProgress(i18n("Brightness"), (int)reply); } } |