Esempio n. 1
0
    def __init__(self, app):
        self.app = app
        self.configManager = app.configManager

        self.icon = KSystemTrayIcon(ConfigManager.SETTINGS[NOTIFICATION_ICON])
        self.icon.connect(
            self.icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
            self.on_activate)

        self.build_menu()
        self.update_tool_tip()

        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            self.icon.show()
Esempio n. 2
0
    def __init__(self, app):
        self.app = app
        self.configManager = app.configManager
        
        self.icon = KSystemTrayIcon(ConfigManager.SETTINGS[NOTIFICATION_ICON])
        self.icon.connect(self.icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.on_activate)

        self.build_menu()
        self.update_tool_tip()

        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            self.icon.show()
Esempio n. 3
0
class Notifier:
    def __init__(self, app):
        self.app = app
        self.configManager = app.configManager

        self.icon = KSystemTrayIcon(ConfigManager.SETTINGS[NOTIFICATION_ICON])
        self.icon.connect(
            self.icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
            self.on_activate)

        self.build_menu()
        self.update_tool_tip()

        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            self.icon.show()

    def update_tool_tip(self):
        if ConfigManager.SETTINGS[SERVICE_RUNNING]:
            self.icon.setToolTip(TOOLTIP_RUNNING.toString())
            self.toggleAction.setChecked(True)
        else:
            self.icon.setToolTip(TOOLTIP_PAUSED.toString())
            self.toggleAction.setChecked(False)

    def build_menu(self):
        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            # Get phrase folders to add to main menu
            folders = []
            items = []

            for folder in self.configManager.allFolders:
                if folder.showInTrayMenu:
                    folders.append(folder)

            for item in self.configManager.allItems:
                if item.showInTrayMenu:
                    items.append(item)

            # Construct main menu
            menu = popupmenu.PopupMenu(self.app.service, folders, items, False,
                                       "AutoKey")
            if len(items) > 0:
                menu.addSeparator()

            self.toggleAction = KToggleAction(i18n("&Enable Monitoring"), menu)
            self.toggleAction.connect(self.toggleAction, SIGNAL("triggered()"),
                                      self.on_enable_toggled)
            self.toggleAction.setChecked(self.app.service.is_running())
            self.toggleAction.setEnabled(not self.app.serviceDisabled)

            menu.addAction(self.toggleAction)
            menu.addAction(KIcon("edit-clear"), i18n("&Hide Icon"),
                           self.on_hide_icon)
            menu.addAction(KIcon("configure"), i18n("&Show Main Window"),
                           self.on_configure)
            menu.addAction(KStandardAction.quit(self.on_quit, menu))
            self.icon.setContextMenu(menu)

    def update_visible_status(self):
        self.icon.setVisible(ConfigManager.SETTINGS[SHOW_TRAY_ICON])
        self.build_menu()

    def hide_icon(self):
        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            self.icon.hide()

    def notify_error(self, message):
        pass

    # ---- Signal handlers ----

    def on_show_error(self):
        self.app.exec_in_main(self.app.show_script_error)

    def on_quit(self):
        self.app.shutdown()

    def on_activate(self, reason):
        if reason == QSystemTrayIcon.ActivationReason(QSystemTrayIcon.Trigger):
            self.on_configure()

    def on_configure(self):
        self.app.show_configure()

    def on_enable_toggled(self):
        if self.toggleAction.isChecked():
            self.app.unpause_service()
        else:
            self.app.pause_service()

    def on_hide_icon(self):
        self.icon.hide()
        ConfigManager.SETTINGS[SHOW_TRAY_ICON] = False
Esempio n. 4
0
        else:
            mw.hide()


menu = QtGui.QMenu()

exitAction = QtGui.QAction(QtGui.QIcon(":/icons/icons/exit.png"), (u"Exit"), None)
connectAction = QtGui.QAction(QtGui.QIcon(":/icons/icons/ok.png"), (u"Connect"), None)
disconnectAction = QtGui.QAction(QtGui.QIcon(":/icons/icons/disconnet.png"), (u"Disconnect"), None)

QtCore.QObject.connect(exitAction, QtCore.SIGNAL("triggered(bool)"), app.exit)
QtCore.QObject.connect(connectAction, QtCore.SIGNAL("triggered(bool)"), mw.connect)
QtCore.QObject.connect(disconnectAction, QtCore.SIGNAL("triggered(bool)"), mw.disconnect)

menu.addAction(connectAction)
menu.addAction(disconnectAction)
menu.addSeparator()
menu.addAction(exitAction)


tray = KSystemTrayIcon(QtGui.QIcon(":/icons/icons/manager.png"))

QtCore.QObject.connect(tray, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), showw)
tray.setContextMenu(menu)

tray.show()
import pumaicons_rc

app.exec_()

Esempio n. 5
0
class Notifier:
    
    def __init__(self, app):
        self.app = app
        self.configManager = app.configManager
        
        self.icon = KSystemTrayIcon(ConfigManager.SETTINGS[NOTIFICATION_ICON])
        self.icon.connect(self.icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.on_activate)

        self.build_menu()
        self.update_tool_tip()

        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            self.icon.show()
                        
    def update_tool_tip(self):
        if ConfigManager.SETTINGS[SERVICE_RUNNING]:
            self.icon.setToolTip(TOOLTIP_RUNNING.toString())
            self.toggleAction.setChecked(True)
        else:
            self.icon.setToolTip(TOOLTIP_PAUSED.toString())
            self.toggleAction.setChecked(False)
            
    def build_menu(self):
        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            # Get phrase folders to add to main menu
            folders = []
            items = []

            for folder in self.configManager.allFolders:
                if folder.showInTrayMenu:
                    folders.append(folder)
            
            for item in self.configManager.allItems:
                if item.showInTrayMenu:
                    items.append(item)
                    
            # Construct main menu
            menu = popupmenu.PopupMenu(self.app.service, folders, items, False, "AutoKey")
            if len(items) > 0:
                menu.addSeparator()
            
            self.toggleAction = KToggleAction(i18n("&Enable Monitoring"), menu)
            self.toggleAction.connect(self.toggleAction, SIGNAL("triggered()"), self.on_enable_toggled)
            self.toggleAction.setChecked(self.app.service.is_running())
            self.toggleAction.setEnabled(not self.app.serviceDisabled)           
            
            menu.addAction(self.toggleAction)
            menu.addAction(KIcon("edit-clear"), i18n("&Hide Icon"), self.on_hide_icon)
            menu.addAction(KIcon("configure"), i18n("&Show Main Window"), self.on_configure)
            menu.addAction(KStandardAction.quit(self.on_quit, menu))
            self.icon.setContextMenu(menu)

    def update_visible_status(self):
        self.icon.setVisible(ConfigManager.SETTINGS[SHOW_TRAY_ICON])
        self.build_menu()

    def hide_icon(self):
        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
            self.icon.hide()

    def notify_error(self, message):
        pass
        
    # ---- Signal handlers ----

    def on_show_error(self):
        self.app.exec_in_main(self.app.show_script_error)

    def on_quit(self):
        self.app.shutdown()

    def on_activate(self, reason):
        if reason == QSystemTrayIcon.ActivationReason(QSystemTrayIcon.Trigger):
            self.on_configure()

    def on_configure(self):
        self.app.show_configure()
        
    def on_enable_toggled(self):
        if self.toggleAction.isChecked():
            self.app.unpause_service()
        else:
            self.app.pause_service()
            
    def on_hide_icon(self):
        self.icon.hide()
        ConfigManager.SETTINGS[SHOW_TRAY_ICON] = False
Esempio n. 6
0
menu = QtGui.QMenu()

exitAction = QtGui.QAction(QtGui.QIcon(":/icons/icons/exit.png"), (u"Exit"),
                           None)
connectAction = QtGui.QAction(QtGui.QIcon(":/icons/icons/ok.png"),
                              (u"Connect"), None)
disconnectAction = QtGui.QAction(QtGui.QIcon(":/icons/icons/disconnet.png"),
                                 (u"Disconnect"), None)

QtCore.QObject.connect(exitAction, QtCore.SIGNAL("triggered(bool)"), app.exit)
QtCore.QObject.connect(connectAction, QtCore.SIGNAL("triggered(bool)"),
                       mw.connect)
QtCore.QObject.connect(disconnectAction, QtCore.SIGNAL("triggered(bool)"),
                       mw.disconnect)

menu.addAction(connectAction)
menu.addAction(disconnectAction)
menu.addSeparator()
menu.addAction(exitAction)

tray = KSystemTrayIcon(QtGui.QIcon(":/icons/icons/manager.png"))

QtCore.QObject.connect(
    tray, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), showw)
tray.setContextMenu(menu)

tray.show()
import pumaicons_rc

app.exec_()
Esempio n. 7
0
 def __init__(self, parent, iface):
     KSystemTrayIcon.__init__(self, parent)
     self.appWindow = parent
     self.setAssociatedWidget(parent)
     PTray.__init__(self, iface)
Esempio n. 8
0
 def __init__(self, parent, iface):
     KSystemTrayIcon.__init__(self, parent)
     self.appWindow = parent
     PTray.__init__(self, iface)
Esempio n. 9
0
 def __init__(self, parent, iface):
     KSystemTrayIcon.__init__(self, parent)
     self.appWindow = parent
     self.setAssociatedWidget(parent)
     PTray.__init__(self, iface)