[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/utils/guidance-power-manager
From: Jonathan Riddell <jr () jriddell ! org>
Date: 2008-08-04 19:39:04
Message-ID: 1217878744.680823.19330.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 842137 by jriddell:
bump version, add global keyboard shortcuts (needs distros to set the keysyms though)
M +50 -25 guidance-power-manager.py
--- trunk/extragear/utils/guidance-power-manager/guidance-power-manager.py \
#842136:842137 @@ -26,7 +26,7 @@
import sys
from PyKDE4.kdecore import KAboutData, KCmdLineArgs, KConfig, i18n, i18nc, i18np, \
ki18n, ki18nc, KGlobal, KStandardDirs, KLocalizedString
-from PyKDE4.kdeui import KUniqueApplication, KApplication,KSystemTrayIcon, UserIcon, \
KDialog, SmallIcon, KAboutApplicationDialog, KPassivePopup, KMenu, KAction, BarIcon \
+from PyKDE4.kdeui import KUniqueApplication, KApplication,KSystemTrayIcon, UserIcon, \
KDialog, SmallIcon, KAboutApplicationDialog, KPassivePopup, KMenu, KAction, BarIcon, \
KShortcut, KXmlGuiWindow, KActionCollection
from PyQt4.QtGui import *
from PyQt4.QtCore import *
@@ -288,6 +288,29 @@
self.connect(hibernateAction, SIGNAL("triggered()"), self.hibernate)
menu.addAction(hibernateAction)
+ # In KDE 4 it seems we can't attach to X keysyms, only Qt keys.
+ # For no good reason whatsoever Qt turns XF86Launch4 into Qt::Key_Launch6, \
see qt4-x11-4.4.1/gui/kernel/qkeymapper_x11.cpp + # and does not map \
XF86LaunchE or XF86Sleep etc. + # In Kubuntu we map keys using a custom \
xmodmap file from the kubuntu-default-settings package which is loaded on starting X, \
+ # other distros will need to do something similar.
+ brightnessUpAction = \
self.systray.actionCollection().addAction("brightness_up") + \
brightnessUpAction.setText("Brightness Up") + \
brightnessUpAction.setShortcut(KShortcut(Qt.Key_Launch6)) + \
brightnessUpAction.setGlobalShortcut(KShortcut(Qt.Key_Launch6)) + \
self.connect(brightnessUpAction, SIGNAL("triggered(bool)"), self.setBrightnessUp) +
+ brightnessUpAction = \
self.systray.actionCollection().addAction("brightness_down") + \
brightnessUpAction.setText("Brightness Down") + \
brightnessUpAction.setShortcut(KShortcut(Qt.Key_Launch5)) + \
brightnessUpAction.setGlobalShortcut(KShortcut(Qt.Key_Launch5)) + \
self.connect(brightnessUpAction, SIGNAL("triggered(bool)"), self.setBrightnessDown) +
+ standbyAction = self.systray.actionCollection().addAction("standby")
+ standbyAction.setText("Standby")
+ standbyAction.setShortcut(KShortcut(Qt.Key_Standby))
+ standbyAction.setGlobalShortcut(KShortcut(Qt.Key_Standby))
+ self.connect(standbyAction, SIGNAL("triggered(bool)"), self.suspend)
+
# add list of cpu frequency governors
if self.powermanager.hasCpuFreqGovernors and len(self.cb_freq) > 0:
submenu = KMenu(menu)
@@ -318,6 +341,9 @@
self.radioButtonIndex = [self.laptopClosedNone, self.laptopClosedBlank, \
self.laptopClosedSuspend, self.laptopClosedHibernate, self.laptopClosedShutdown]
+ def setBrightness(self):
+ print "setbrightness"
+
def _initBattery(self):
""" Remove non-battery-related widgets if there's no battery bay. """
if not self.powermanager.hasBattery:
@@ -409,31 +435,30 @@
self.config.sync()
- #FIXME add global key bindings for these
- #def showBrightnessPopup(self):
- # if self.powermanager.onBattery():
- # value=self.BatteryBrightnessSlider.value()*100/self.BatteryBrightnessSlider.maxValue()
- # else:
- # value=self.PoweredBrightnessSlider.value()*100/self.PoweredBrightnessSlider.maxValue()
- # self.brightnessPopup = KPassivePopup.message('<b>Brightness:</b> \
'+str(value)+'%', self.systray)
- # """pop.setTimeout(3000)"""
- # self.brightnessPopup.show()
+ def showBrightnessPopup(self):
+ if self.powermanager.onBattery():
+ value=self.BatteryBrightnessSlider.value()*100/self.BatteryBrightnessSlider.maximum()
+ else:
+ value=self.PoweredBrightnessSlider.value()*100/self.PoweredBrightnessSlider.maximum()
+ self.brightnessPopup = KPassivePopup.message('<b>Brightness:</b> \
'+str(value)+'%', self.systray) + """pop.setTimeout(3000)"""
+ self.brightnessPopup.show()
- #def setBrightnessUp(self):
- # """Increments slider value by 10%"""
- # if self.powermanager.onBattery():
- # #self.BatteryBrightnessSlider.setValue(float(self.BatteryBrightnessSlider.value())+max(float(self.BatteryBrightnessSlider.maxValue())/float(10),1))
- # else:
- # self.PoweredBrightnessSlider.setValue(float(self.PoweredBrightnessSlider.value())+max(float(self.PoweredBrightnessSlider.maxValue())/float(10),1))
- # self.showBrightnessPopup()
+ def setBrightnessUp(self):
+ """Increments slider value by 5%"""
+ if self.powermanager.onBattery():
+ self.BatteryBrightnessSlider.setValue(float(self.BatteryBrightnessSlider.value())+max(float(self.BatteryBrightnessSlider.maximum())/float(10),1))
+ else:
+ self.PoweredBrightnessSlider.setValue(float(self.PoweredBrightnessSlider.value())+max(float(self.PoweredBrightnessSlider.maximum())/float(10),1))
+ self.showBrightnessPopup()
- #def setBrightnessDown(self):
- # """Decrements slider value by 10%"""
- # if self.powermanager.onBattery():
- # self.BatteryBrightnessSlider.setValue(float(self.BatteryBrightnessSlider.value())-max(float(self.BatteryBrightnessSlider.maxValue())/float(10),1))
- # else:
- # self.PoweredBrightnessSlider.setValue(float(self.PoweredBrightnessSlider.value())-max(float(self.PoweredBrightnessSlider.maxValue())/float(10),1))
- # self.showBrightnessPopup()
+ def setBrightnessDown(self):
+ """Decrements slider value by 5%"""
+ if self.powermanager.onBattery():
+ self.BatteryBrightnessSlider.setValue(float(self.BatteryBrightnessSlider.value())-max(float(self.BatteryBrightnessSlider.maximum())/float(10),1))
+ else:
+ self.PoweredBrightnessSlider.setValue(float(self.PoweredBrightnessSlider.value())-max(float(self.PoweredBrightnessSlider.maximum())/float(10),1))
+ self.showBrightnessPopup()
#def getBrightness(self):
# """Work with percentages - it's a bit nicer"""
@@ -1121,7 +1146,7 @@
appName = "guidance-power-manager"
catalog = ""
programName = ki18n("Guidance Power Manager")
- version = "4.1.0"
+ version = "4.1.1"
description = ki18n("Applet for battery info and setting brightness")
license = KAboutData.License_GPL
copyright = ki18n("Copyright 2006-2008 Sebastian Kügler, Canonical Ltd, Luka \
Renko")
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic