=== 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("Disable Airplane Mode?\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("Enable Airplane Mode?\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("Disable Airplane Mode?\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("Enable Airplane Mode?\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_()