=== modified file 'kairmode.py' --- kairmode.py 2009-08-25 04:53:27 +0000 +++ kairmode.py 2009-08-25 19:42:35 +0000 @@ -33,9 +33,7 @@ class App(QObject): def __init__(self): QObject.__init__(self) - self.init()
- def init(self): # Wireless devices self.wifi_device = self.getWiFiDeviceInfo() self.wifi_power = self.getWiFiDevicePowerStatus() @@ -52,7 +50,7 @@ self.setTrayToolTip() self.setMenu() self.connect(self.tray_icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.activated) - self.tray_icon.setVisible(True) + self.tray_icon.show()
#################### ## UI CODE @@ -60,19 +58,22 @@ #---- Tray Icon Clicked ----# def activated(self, activationReason): if activationReason == QSystemTrayIcon.Trigger: - if self.airplane_mode: - msg = i18n("<b>Disable Airplane Mode?</b>\n\n" - "Disabling Airplane Mode will turn the power for\n" - "all wireless devices on, therefore putting your\n" - "system in a non-safe condition during flight.") - else: - msg = i18n("<b>Enable Airplane Mode?</b>\n\n" - "Enabling Airplane Mode will turn the power for\n" - "all wireless devices off, therefore putting your\n" - "system in a safe condition during flight.") - confirm = KMessageBox.questionYesNo(None, msg, i18n("KDE Airplane Mode")) - if confirm == KMessageBox.Yes: - self.toggleAirplaneMode() + if self.airplane_mode: + msg = i18n("<b>Disable Airplane Mode?</b>\n\n" + "Disabling Airplane Mode will turn the power for\n" + "all wireless devices on, therefore putting your\n" + "system in a non-safe condition during flight.") + btn = i18n("Disable Airplane Mode") + else: + msg = i18n("<b>Enable Airplane Mode?</b>\n\n" + "Enabling Airplane Mode will turn the power for\n" + "all wireless devices off, therefore putting your\n" + "system in a safe condition during flight.") + btn = i18n("Enable Airplane Mode") + yesButton = KGuiItem(btn) + confirm = KMessageBox.questionYesNo(None, msg, i18n("KDE Airplane Mode"), yesButton, KStandardGuiItem.cancel()) + if confirm == KMessageBox.Yes: + self.toggleAirplaneMode()
#---- Notifications ----# def notifyUser(self, event, message): @@ -128,7 +129,7 @@
#---- Toggle Quit ----# def toggleQuit(self): - app.quit() + sys.exit(app.quit())
#################### ## COMMANDS @@ -278,6 +279,7 @@ pass
#---- Toggle Airplane Mode ----# + @pyqtSignature("toggleAirplaneMode()") def toggleAirplaneMode(self): if not self.airplane_mode: if self.wifi_device and self.wifi_power == "on": self.toggleWiFi() @@ -342,7 +344,7 @@ KCmdLineArgs.init(sys.argv, aboutData)
app = KApplication() + app.setQuitOnLastWindowClosed(False) applet = App() - sys.exit(app.exec_()) - + app.exec_()
=== modified file 'kairmode.py'
QObject. __init_ _(self)
--- kairmode.py 2009-08-25 04:53:27 +0000
+++ kairmode.py 2009-08-25 19:42:35 +0000
@@ -33,9 +33,7 @@
class App(QObject):
def __init__(self):
- self.init()
- def init(self):
self. wifi_device = self.getWiFiDev iceInfo( )
self. wifi_power = self.getWiFiDev icePowerStatus( )
self. setTrayToolTip( )
self. setMenu( )
self. connect( self.tray_ icon, SIGNAL( "activated( QSystemTrayIcon ::ActivationRea son)"), self.activated) icon.setVisible (True) icon.show( )
# Wireless devices
@@ -52,7 +50,7 @@
- self.tray_
+ self.tray_
## ####### ####### #### .Trigger: questionYesNo( None, msg, i18n("KDE Airplane Mode")) laneMode( ) questionYesNo( None, msg, i18n("KDE Airplane Mode"), yesButton, KStandardGuiIte m.cancel( )) laneMode( )
## UI CODE
@@ -60,19 +58,22 @@
#---- Tray Icon Clicked ----#
def activated(self, activationReason):
if activationReason == QSystemTrayIcon
- if self.airplane_mode:
- msg = i18n("<b>Disable Airplane Mode?</b>\n\n"
- "Disabling Airplane Mode will turn the power for\n"
- "all wireless devices on, therefore putting your\n"
- "system in a non-safe condition during flight.")
- else:
- msg = i18n("<b>Enable Airplane Mode?</b>\n\n"
- "Enabling Airplane Mode will turn the power for\n"
- "all wireless devices off, therefore putting your\n"
- "system in a safe condition during flight.")
- confirm = KMessageBox.
- if confirm == KMessageBox.Yes:
- self.toggleAirp
+ if self.airplane_mode:
+ msg = i18n("<b>Disable Airplane Mode?</b>\n\n"
+ "Disabling Airplane Mode will turn the power for\n"
+ "all wireless devices on, therefore putting your\n"
+ "system in a non-safe condition during flight.")
+ btn = i18n("Disable Airplane Mode")
+ else:
+ msg = i18n("<b>Enable Airplane Mode?</b>\n\n"
+ "Enabling Airplane Mode will turn the power for\n"
+ "all wireless devices off, therefore putting your\n"
+ "system in a safe condition during flight.")
+ btn = i18n("Enable Airplane Mode")
+ yesButton = KGuiItem(btn)
+ confirm = KMessageBox.
+ if confirm == KMessageBox.Yes:
+ self.toggleAirp
#---- Notifications ----#
def notifyUser(self, event, message):
@@ -128,7 +129,7 @@
#---- Toggle Quit ----# app.quit( ))
def toggleQuit(self):
- app.quit()
+ sys.exit(
## ####### ####### ####
## COMMANDS
@@ -278,6 +279,7 @@
pass
#---- Toggle Airplane Mode ----# "toggleAirplane Mode()" ) ode(self) : gs.init( sys.argv, aboutData)
+ @pyqtSignature(
def toggleAirplaneM
if not self.airplane_mode:
if self.wifi_device and self.wifi_power == "on": self.toggleWiFi()
@@ -342,7 +344,7 @@
KCmdLineAr
app = KApplication() stWindowClosed( False) app.exec_ ())
+ app.setQuitOnLa
applet = App()
- sys.exit(
-
+ app.exec_()