summaryrefslogtreecommitdiffstats
path: root/kmilo
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-05-05 21:57:03 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-05-10 18:43:07 +0900
commit3c70b34ae35cd22d6b7424e4f8523a2c6a1a62e5 (patch)
treeef50fcfe5a65d7b11fa16c2b0ace195894c7fb51 /kmilo
parenteabfd64e7420dad4f3ef847ed6a5e5833dfb789c (diff)
downloadtdeutils-3c70b34ae35cd22d6b7424e4f8523a2c6a1a62e5.tar.gz
tdeutils-3c70b34ae35cd22d6b7424e4f8523a2c6a1a62e5.zip
KMilo: added keyboard support for screen brightness up/down.
This is inspired and partially include code from Roman Savochenko proposed in bug 2783 and tdeutils #8. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'kmilo')
-rw-r--r--kmilo/generic/generic_monitor.cpp56
-rw-r--r--kmilo/generic/generic_monitor.h5
2 files changed, 53 insertions, 8 deletions
diff --git a/kmilo/generic/generic_monitor.cpp b/kmilo/generic/generic_monitor.cpp
index 28138ec..9017f70 100644
--- a/kmilo/generic/generic_monitor.cpp
+++ b/kmilo/generic/generic_monitor.cpp
@@ -43,7 +43,7 @@
using namespace KMilo;
GenericMonitor::GenericMonitor(TQObject *parent, const char *name, const TQStringList& args)
-: Monitor(parent, name, args)
+: Monitor(parent, name, args), kmixClient(NULL), kmixWindow(NULL), tdepowersave(NULL)
{
_poll = false;
m_displayType = Monitor::None;
@@ -69,11 +69,8 @@ GenericMonitor::~GenericMonitor()
bool GenericMonitor::init()
{
- TDEConfig config(CONFIG_FILE);
- reconfigure(&config);
-
- //config = new TDEConfig("kmilodrc");
- config.setGroup("kubuntu");
+ config = new TDEConfig(CONFIG_FILE);
+ reconfigure(config);
if(!m_enabled)
return false; // exit early if we are not supposed to run
@@ -95,7 +92,9 @@ 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");
@@ -116,6 +115,7 @@ bool GenericMonitor::init()
kmixClient = new DCOPRef("kmix", "Mixer0");
kmixWindow = new DCOPRef("kmix", "kmix-mainwindow#1");
+ tdepowersave = new DCOPRef("tdepowersave", "tdepowersaveIface");
return true;
}
@@ -325,6 +325,48 @@ void GenericMonitor::mute()
_interface->displayText(muteText);
}
+void GenericMonitor::brightnessUp()
+{
+ brightnessChange(1, 10);
+}
+
+void GenericMonitor::brightnessDown()
+{
+ brightnessChange(-1, 10);
+}
+
+void GenericMonitor::brightnessChange(int direction, int step)
+{
+ if (!tdepowersave)
+ {
+ return;
+ }
+
+ 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);
+ }
+}
+
int GenericMonitor::progress() const
{
return m_progress;
diff --git a/kmilo/generic/generic_monitor.h b/kmilo/generic/generic_monitor.h
index 44ff970..9305ac3 100644
--- a/kmilo/generic/generic_monitor.h
+++ b/kmilo/generic/generic_monitor.h
@@ -65,6 +65,8 @@ public slots:
void fastVolumeUp();
void fastVolumeDown();
void mute();
+ void brightnessUp();
+ void brightnessDown();
void launchMail();
void launchBrowser();
void launchSearch();
@@ -83,12 +85,13 @@ private:
bool retrieveMute();
bool retrieveVolume();
void displayVolume();
+ void brightnessChange(int direction, int step);
void launch(TQString configKey, TQString defaultApplication);
TDEGlobalAccel *ga;
TDEConfig* config;
- DCOPRef *kmixClient, *kmixWindow;
+ DCOPRef *kmixClient, *kmixWindow, *tdepowersave;
int m_progress;
long m_volume;