示例#1
0
文件: app.py 项目: rajansg/qsh
    def __init__(self, *args, **kwargs):
        super(QSH, self).__init__(*args, **kwargs)
        self.setQuitOnLastWindowClosed(False)

        # signals
        self.aboutToQuit.connect(self.beforeQuit)

        # dialogs
        self.screenViewDialog = ScreenViewDialog(self)

        # networking
        self.connector = Connector()

        # tray
        self.trayIcon = MainTrayIcon(self,
                                     callbacks={
                                         "quit": self.quit,
                                         "configuration":
                                         self.showConfigurationDialog,
                                         "incoming": self.showScreenViewDialog
                                     })
        self.trayIcon.middle_click_callback = self.trayIconMiddleClick

        # networking callbacks
        self.connector.known_hosts_updated_callback = self.trayIcon.updateMenu
        self.connector.got_image_callback = self.processReceivedImage
        self.connector.receiving_start_callback = self.trayIcon.setIconLoading
        self.connector.sending_end_callback = self.trayIcon.setIconDefault

        # hi there!
        self.connector.updateKnownHosts()

        # periodically check whether hosts alive
        self.helloAllTimer = QtCore.QTimer(self)
        self.connect(self.helloAllTimer, QtCore.SIGNAL("timeout()"),
                     self.connector.updateKnownHosts)
        self.helloAllTimer.start(AppConfig.get_heartbeat_interval())