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.cpp51
1 files changed, 41 insertions, 10 deletions
diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp
index 28138ec..502f37e 100644
--- a/kmilo/generic/generic_monitor.cpp
+++ b/kmilo/generic/generic_monitor.cpp
@@ -31,6 +31,8 @@
#include <sys/types.h>
#include <unistd.h>
+#include <algorithm>
+
#include "generic_monitor.h"
#include "kmilointerface.h"
#include <tqmessagebox.h>
@@ -43,7 +45,7 @@
using namespace KMilo;
GenericMonitor::GenericMonitor(TQObject *parent, const char *name, const TQStringList& args)
-: Monitor(parent, name, args)
+: Monitor(parent, name, args), tPowerSave(NULL)
{
_poll = false;
m_displayType = Monitor::None;
@@ -69,11 +71,11 @@ GenericMonitor::~GenericMonitor()
bool GenericMonitor::init()
{
- TDEConfig config(CONFIG_FILE);
- reconfigure(&config);
+ config = new TDEConfig(CONFIG_FILE);
+ //TDEConfig config(CONFIG_FILE);
+ reconfigure(config);
- //config = new TDEConfig("kmilodrc");
- config.setGroup("kubuntu");
+ //config.setGroup("kubuntu");
if(!m_enabled)
return false; // exit early if we are not supposed to run
@@ -95,9 +97,12 @@ bool GenericMonitor::init()
{ "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(mute()) }
+ { "Mute", TDEShortcut("XF86AudioMute"), TQT_SLOT(mute()) },
+ { "BrightnessUp", TDEShortcut("XF86MonBrightnessUp"), TQT_SLOT(brightnessUp()) },
+ { "BrightnessDown", TDEShortcut("XF86MonBrightnessDown"), TQT_SLOT(brightnessDown()) }
};
+
ga = new TDEGlobalAccel(this, "miloGenericAccel");
ShortcutInfo si;
@@ -114,9 +119,11 @@ bool GenericMonitor::init()
ga->readSettings();
ga->updateConnections();
- kmixClient = new DCOPRef("kmix", "Mixer0");
+ kmixClient = new DCOPRef("kmix", "MixerMaster");
kmixWindow = new DCOPRef("kmix", "kmix-mainwindow#1");
+ tPowerSave = new DCOPRef("tdepowersave", "tdepowersaveIface");
+
return true;
}
@@ -151,7 +158,7 @@ bool GenericMonitor::retrieveKmixDevices()
if (!reply.isValid())
{
- kdDebug() << "KMilo: GenericMonitor could not access kmix/Mixer0 via dcop"
+ kdDebug() << "KMilo: GenericMonitor could not access kmix/MixerMaster via dcop"
<< endl;
_interface->displayText(i18n("It seems that KMix is not running."));
@@ -196,7 +203,7 @@ bool GenericMonitor::retrieveVolume()
if (kmix_error)
{
- kdDebug() << "KMilo: GenericMonitor could not access kmix/Mixer0 via dcop"
+ kdDebug() << "KMilo: GenericMonitor could not access kmix/MixerMaster via dcop"
<< endl;
_interface->displayText(i18n("It seems that KMix is not running."));
@@ -294,7 +301,7 @@ bool GenericMonitor::retrieveMute()
if (kmix_error)
{
- kdDebug() << "KMilo: GenericMonitor could not access kmix/Mixer0 via dcop"
+ kdDebug() << "KMilo: GenericMonitor could not access kmix/MixerMaster via dcop"
<< endl;
_interface->displayText(i18n("It seems that KMix is not running."));
@@ -325,6 +332,30 @@ void GenericMonitor::mute()
_interface->displayText(muteText);
}
+void GenericMonitor::brightnessUp()
+{
+ if(!tPowerSave) return;
+
+ DCOPReply reply = tPowerSave->call("brightnessGet");
+ if(reply.isValid()) {
+ int lev = 100+(int)reply;
+ _interface->displayProgress(i18n("Brightness"), std::min(100,lev+5));
+ tPowerSave->send("do_brightnessUp", std::min(5,100-lev));
+ }
+}
+
+void GenericMonitor::brightnessDown()
+{
+ if(!tPowerSave) return;
+
+ DCOPReply reply = tPowerSave->call("brightnessGet");
+ if(reply.isValid()) {
+ int lev = 100+(int)reply;
+ _interface->displayProgress(i18n("Brightness"), std::max(5,lev-5));
+ if((lev=std::min(5,lev-5)) > 0) tPowerSave->send("do_brightnessDown", lev);
+ }
+}
+
int GenericMonitor::progress() const
{
return m_progress;