summaryrefslogtreecommitdiffstats
path: root/kmilo/generic/generic_monitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmilo/generic/generic_monitor.cpp')
-rw-r--r--kmilo/generic/generic_monitor.cpp90
1 files changed, 44 insertions, 46 deletions
diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp
index 739b266..2c15ad5 100644
--- a/kmilo/generic/generic_monitor.cpp
+++ b/kmilo/generic/generic_monitor.cpp
@@ -24,7 +24,7 @@
#include <kgenericfactory.h>
#include <kdebug.h>
-#include <kprocess.h>
+#include <tdeprocess.h>
#include <tdeconfig.h>
#include <sys/types.h>
@@ -35,6 +35,7 @@
#include <tqmessagebox.h>
#include <tqfile.h>
#include <tqdir.h>
+#include <tqtimer.h>
#define CONFIG_FILE "kmilodrc"
@@ -51,27 +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()) },
- { "BrightnessSlowUp", TDEShortcut("Ctrl+XF86MonBrightnessUp"), TQT_SLOT(brightnessSlowUp()) },
- { "BrightnessSlowDown", TDEShortcut("Ctrl+XF86MonBrightnessDown"), TQT_SLOT(brightnessSlowDown()) }
+ { "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)
@@ -146,7 +147,7 @@ bool GenericMonitor::retrieveVolume(int &volume)
// maybe the error occurred because kmix wasn't running. Try to start it
_interface->displayText(i18n("Starting KMix..."));
- if (kapp->startServiceByDesktopName("kmix") == 0)
+ if (tdeApp->startServiceByDesktopName("kmix") == 0)
{
// trying again
reply = kmixClient->call("volume");
@@ -214,7 +215,7 @@ bool GenericMonitor::retrieveMute(bool &muted)
// maybe the error occurred because kmix wasn't running. Try to start it
_interface->displayText(i18n("Starting KMix..."));
- if (kapp->startServiceByDesktopName("kmix") == 0)
+ if (tdeApp->startServiceByDesktopName("kmix") == 0)
{
// trying again
reply = kmixClient->call("mute");
@@ -275,33 +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, 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);
}
}
@@ -326,12 +324,12 @@ void GenericMonitor::launch(TQString configKey, TQString defaultApplication)
void GenericMonitor::launchMail()
{
kdDebug() << "launchMail" << endl;
- kapp->invokeMailer("", "", "", "", "", "", "", "");
+ tdeApp->invokeMailer("", "", "", "", "", "", "", "");
}
void GenericMonitor::launchBrowser()
{
- kapp->invokeBrowser("");
+ tdeApp->invokeBrowser("");
}
void GenericMonitor::launchSearch()