예제 #1
0
파일: labels.py 프로젝트: scudella/blink-qt
 def init_with_contact(self, contact):
     if contact is None:
         self.icon = self.contact_icon = None
     else:
         icon_manager = IconManager()
         self.contact_icon = icon_manager.get(contact.id)
         self.icon = icon_manager.get(contact.id + '_alt') or self.contact_icon
         if contact.alternate_icon is not None:
             self.last_icon_directory = os.path.dirname(contact.alternate_icon.url.path)
     self.filename = self.NotSelected
예제 #2
0
 def init_with_contact(self, contact):
     if contact is None:
         self.icon = self.contact_icon = None
     else:
         icon_manager = IconManager()
         self.contact_icon = icon_manager.get(contact.id)
         self.icon = icon_manager.get(contact.id + '_alt') or self.contact_icon
         if contact.alternate_icon is not None:
             self.last_icon_directory = os.path.dirname(contact.alternate_icon.url.path)
     self.filename = self.NotSelected
예제 #3
0
 def __init__(self, account, uri, display_name, parent=None):
     super(PendingWatcherDialog, self).__init__(parent)
     self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
     self.setAttribute(Qt.WA_DeleteOnClose)
     with Resources.directory:
         self.setupUi(self)
     default_font_size = self.uri_label.fontInfo().pointSizeF()
     name_font_size = limit(default_font_size + 3, max=14)
     font = self.name_label.font()
     font.setPointSizeF(name_font_size)
     self.name_label.setFont(font)
     addressbook_manager = addressbook.AddressbookManager()
     try:
         self.contact = next(
             contact for contact in addressbook_manager.get_contacts()
             if uri in (addr.uri for addr in contact.uris))
     except StopIteration:
         self.contact = None
     else:
         display_name = self.contact.name
         icon_manager = IconManager()
         icon = icon_manager.get(self.contact.id)
         if icon is not None:
             self.user_icon.setPixmap(icon.pixmap(48))
     self.description_label.setText(
         'Wants to subscribe to your availability information at {}'.format(
             account.id))
     self.name_label.setText(display_name or uri)
     self.uri_label.setText(uri)
     self.accept_button.released.connect(self._accept_watcher)
     self.block_button.released.connect(self._block_watcher)
     self.position = None
     self.timer = QTimer()
     self.timer.timeout.connect(self._SH_TimerFired)
     self.timer.start(60000)
예제 #4
0
 def __init__(self, account, uri, display_name, parent=None):
     super(PendingWatcherDialog, self).__init__(parent)
     self.setWindowFlags(Qt.WindowStaysOnTopHint)
     self.setAttribute(Qt.WA_DeleteOnClose)
     with Resources.directory:
         self.setupUi(self)
     addressbook_manager = addressbook.AddressbookManager()
     try:
         self.contact = next(contact for contact in addressbook_manager.get_contacts() if uri in (addr.uri for addr in contact.uris))
     except StopIteration:
         self.contact = None
     else:
         display_name = self.contact.name
         icon_manager = IconManager()
         icon = icon_manager.get(self.contact.id)
         if icon is not None:
             self.user_icon.setPixmap(icon.pixmap(32))
     self.account_label.setText(u'For account %s' % account.id)
     self.name_label.setText(display_name or uri)
     self.uri_label.setText(uri)
     font = self.name_label.font()
     font.setPointSizeF(self.uri_label.fontInfo().pointSizeF() + 3)
     font.setFamily("Sans Serif")
     self.name_label.setFont(font)
     self.accept_button.released.connect(self._accept_watcher)
     self.block_button.released.connect(self._block_watcher)
     self.position = None
     self.timer = QTimer()
     self.timer.timeout.connect(self._SH_TimerFired)
     self.timer.start(60000)
예제 #5
0
 def __init__(self, account, uri, display_name, parent=None):
     super(PendingWatcherDialog, self).__init__(parent)
     self.setWindowFlags(Qt.WindowStaysOnTopHint)
     self.setAttribute(Qt.WA_DeleteOnClose)
     with Resources.directory:
         self.setupUi(self)
     addressbook_manager = addressbook.AddressbookManager()
     try:
         self.contact = next(
             contact for contact in addressbook_manager.get_contacts()
             if uri in (addr.uri for addr in contact.uris))
     except StopIteration:
         self.contact = None
     else:
         display_name = self.contact.name
         icon_manager = IconManager()
         icon = icon_manager.get(self.contact.id)
         if icon is not None:
             self.user_icon.setPixmap(icon.pixmap(32))
     self.account_label.setText(u'For account %s' % account.id)
     self.name_label.setText(display_name or uri)
     self.uri_label.setText(uri)
     font = self.name_label.font()
     font.setPointSizeF(self.uri_label.fontInfo().pointSizeF() + 3)
     font.setFamily("Sans Serif")
     self.name_label.setFont(font)
     self.accept_button.released.connect(self._accept_watcher)
     self.block_button.released.connect(self._block_watcher)
     self.position = None
     self.timer = QTimer()
     self.timer.timeout.connect(self._SH_TimerFired)
     self.timer.start(60000)
예제 #6
0
 def __init__(self, account, uri, display_name, parent=None):
     super(PendingWatcherDialog, self).__init__(parent)
     self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
     self.setAttribute(Qt.WA_DeleteOnClose)
     with Resources.directory:
         self.setupUi(self)
     default_font_size = self.uri_label.fontInfo().pointSizeF()
     name_font_size = limit(default_font_size + 3, max=14)
     font = self.name_label.font()
     font.setPointSizeF(name_font_size)
     self.name_label.setFont(font)
     addressbook_manager = addressbook.AddressbookManager()
     try:
         self.contact = next(contact for contact in addressbook_manager.get_contacts() if uri in (addr.uri for addr in contact.uris))
     except StopIteration:
         self.contact = None
     else:
         display_name = self.contact.name
         icon_manager = IconManager()
         icon = icon_manager.get(self.contact.id)
         if icon is not None:
             self.user_icon.setPixmap(icon.pixmap(48))
     self.description_label.setText(u'Wants to subscribe to your availability information at {}'.format(account.id))
     self.name_label.setText(display_name or uri)
     self.uri_label.setText(uri)
     self.accept_button.released.connect(self._accept_watcher)
     self.block_button.released.connect(self._block_watcher)
     self.position = None
     self.timer = QTimer()
     self.timer.timeout.connect(self._SH_TimerFired)
     self.timer.start(60000)
예제 #7
0
 def _NH_CFGSettingsObjectDidChange(self, notification):
     settings = SIPSimpleSettings()
     blink_settings = BlinkSettings()
     icon_manager = IconManager()
     if notification.sender is settings:
         if 'audio.muted' in notification.data.modified:
             self.mute_action.setChecked(settings.audio.muted)
             self.mute_button.setChecked(settings.audio.muted)
         if 'audio.silent' in notification.data.modified:
             self.silent_action.setChecked(settings.audio.silent)
             self.silent_button.setChecked(settings.audio.silent)
         if 'audio.output_device' in notification.data.modified:
             action = (action for action in self.output_devices_group.actions() if action.data() == settings.audio.output_device).next()
             action.setChecked(True)
         if 'audio.input_device' in notification.data.modified:
             action = (action for action in self.input_devices_group.actions() if action.data() == settings.audio.input_device).next()
             action.setChecked(True)
         if 'audio.alert_device' in notification.data.modified:
             action = (action for action in self.alert_devices_group.actions() if action.data() == settings.audio.alert_device).next()
             action.setChecked(True)
         if 'video.device' in notification.data.modified:
             action = (action for action in self.video_devices_group.actions() if action.data() == settings.video.device).next()
             action.setChecked(True)
         if 'answering_machine.enabled' in notification.data.modified:
             self.answering_machine_action.setChecked(settings.answering_machine.enabled)
         if 'chat.auto_accept' in notification.data.modified:
             self.auto_accept_chat_action.setChecked(settings.chat.auto_accept)
         if 'sounds.play_message_alerts' in notification.data.modified:
             self.received_messages_sound_action.setChecked(settings.sounds.play_message_alerts)
         if 'google_contacts.authorization_token' in notification.data.modified:
             authorization_token = notification.sender.google_contacts.authorization_token
             if authorization_token is None:
                 self.google_contacts_action.setText(u'Enable &Google Contacts...')
             else:
                 self.google_contacts_action.setText(u'Disable &Google Contacts')
             if authorization_token is InvalidToken:
                 self.google_contacts_dialog.open_for_incorrect_password()
     elif notification.sender is blink_settings:
         if 'presence.current_state' in notification.data.modified:
             state = getattr(AccountState, blink_settings.presence.current_state.state, AccountState.Available)
             self.account_state.setState(state, blink_settings.presence.current_state.note)
         if 'presence.icon' in notification.data.modified:
             self.set_user_icon(icon_manager.get('avatar'))
         if 'presence.offline_note' in notification.data.modified:
             # TODO: set offline note -Saul
             pass
     elif isinstance(notification.sender, (Account, BonjourAccount)):
         account_manager = AccountManager()
         account = notification.sender
         if 'enabled' in notification.data.modified:
             action = (action for action in self.accounts_menu.actions() if action.data() is account).next()
             action.setChecked(account.enabled)
         if 'display_name' in notification.data.modified and account is account_manager.default_account:
             self.display_name.setText(account.display_name or u'')
         if set(['enabled', 'message_summary.enabled', 'message_summary.voicemail_uri']).intersection(notification.data.modified):
             action = (action for action in self.voicemail_menu.actions() if action.data() is account).next()
             action.setVisible(False if account is BonjourAccount() else account.enabled and account.message_summary.enabled)
             action.setEnabled(False if account is BonjourAccount() else account.voicemail_uri is not None)
예제 #8
0
 def _NH_CFGSettingsObjectDidChange(self, notification):
     settings = SIPSimpleSettings()
     blink_settings = BlinkSettings()
     icon_manager = IconManager()
     if notification.sender is settings:
         if 'audio.muted' in notification.data.modified:
             self.mute_action.setChecked(settings.audio.muted)
             self.mute_button.setChecked(settings.audio.muted)
         if 'audio.silent' in notification.data.modified:
             self.silent_action.setChecked(settings.audio.silent)
             self.silent_button.setChecked(settings.audio.silent)
         if 'audio.output_device' in notification.data.modified:
             action = (action for action in self.output_devices_group.actions() if action.data() == settings.audio.output_device).next()
             action.setChecked(True)
         if 'audio.input_device' in notification.data.modified:
             action = (action for action in self.input_devices_group.actions() if action.data() == settings.audio.input_device).next()
             action.setChecked(True)
         if 'audio.alert_device' in notification.data.modified:
             action = (action for action in self.alert_devices_group.actions() if action.data() == settings.audio.alert_device).next()
             action.setChecked(True)
         if 'video.device' in notification.data.modified:
             action = (action for action in self.video_devices_group.actions() if action.data() == settings.video.device).next()
             action.setChecked(True)
         if 'answering_machine.enabled' in notification.data.modified:
             self.answering_machine_action.setChecked(settings.answering_machine.enabled)
         if 'chat.auto_accept' in notification.data.modified:
             self.auto_accept_chat_action.setChecked(settings.chat.auto_accept)
         if 'sounds.play_message_alerts' in notification.data.modified:
             self.received_messages_sound_action.setChecked(settings.sounds.play_message_alerts)
         if 'google_contacts.authorization_token' in notification.data.modified:
             authorization_token = notification.sender.google_contacts.authorization_token
             if authorization_token is None:
                 self.google_contacts_action.setText(u'Enable &Google Contacts...')
             else:
                 self.google_contacts_action.setText(u'Disable &Google Contacts')
             if authorization_token is InvalidToken:
                 self.google_contacts_dialog.open_for_incorrect_password()
     elif notification.sender is blink_settings:
         if 'presence.current_state' in notification.data.modified:
             state = getattr(AccountState, blink_settings.presence.current_state.state, AccountState.Available)
             self.account_state.setState(state, blink_settings.presence.current_state.note)
         if 'presence.icon' in notification.data.modified:
             self.set_user_icon(icon_manager.get('avatar'))
         if 'presence.offline_note' in notification.data.modified:
             # TODO: set offline note -Saul
             pass
     elif isinstance(notification.sender, (Account, BonjourAccount)):
         account_manager = AccountManager()
         account = notification.sender
         if 'enabled' in notification.data.modified:
             action = (action for action in self.accounts_menu.actions() if action.data() is account).next()
             action.setChecked(account.enabled)
         if 'display_name' in notification.data.modified and account is account_manager.default_account:
             self.display_name.setText(account.display_name or u'')
         if set(['enabled', 'message_summary.enabled', 'message_summary.voicemail_uri']).intersection(notification.data.modified):
             action = (action for action in self.voicemail_menu.actions() if action.data() is account).next()
             action.setVisible(False if account is BonjourAccount() else account.enabled and account.message_summary.enabled)
             action.setEnabled(False if account is BonjourAccount() else account.voicemail_uri is not None)
예제 #9
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.saved_account_state = None

        notification_center = NotificationCenter()
        notification_center.add_observer(self, name='SIPApplicationWillStart')
        notification_center.add_observer(self, name='SIPApplicationDidStart')
        notification_center.add_observer(self, name='SIPAccountGotMessageSummary')
        notification_center.add_observer(self, name='SIPAccountGotPendingWatcher')
        notification_center.add_observer(self, name='BlinkSessionNewOutgoing')
        notification_center.add_observer(self, name='BlinkSessionDidReinitializeForOutgoing')
        notification_center.add_observer(self, name='FileTransferNewIncoming')
        notification_center.add_observer(self, name='FileTransferNewOutgoing')
        notification_center.add_observer(self, sender=AccountManager())

        icon_manager = IconManager()

        self.pending_watcher_dialogs = []

        self.mwi_icons = [QIcon(Resources.get('icons/mwi-%d.png' % i)) for i in xrange(0, 11)]
        self.mwi_icons.append(QIcon(Resources.get('icons/mwi-many.png')))

        with Resources.directory:
            self.setupUi()

        self.setWindowTitle('Blink')
        self.setWindowIconText('Blink')

        geometry = QSettings().value("main_window/geometry")
        if geometry:
            self.restoreGeometry(geometry)

        self.default_icon_path = Resources.get('icons/default-avatar.png')
        self.default_icon = QIcon(self.default_icon_path)
        self.last_icon_directory = Path('~').normalized
        self.set_user_icon(icon_manager.get('avatar'))

        self.active_sessions_label.hide()
        self.enable_call_buttons(False)
        self.conference_button.setEnabled(False)
        self.hangup_all_button.setEnabled(False)
        self.sip_server_settings_action.setEnabled(False)
        self.search_for_people_action.setEnabled(False)
        self.history_on_server_action.setEnabled(False)
        self.main_view.setCurrentWidget(self.contacts_panel)
        self.contacts_view.setCurrentWidget(self.contact_list_panel)
        self.search_view.setCurrentWidget(self.search_list_panel)

        # System tray
        if QSystemTrayIcon.isSystemTrayAvailable() and not os.getenv('XDG_CURRENT_DESKTOP', '').lower().startswith('unity'):
            self.system_tray_icon = QSystemTrayIcon(QIcon(Resources.get('icons/blink.png')), self)
            self.system_tray_icon.activated.connect(self._SH_SystemTrayIconActivated)
            menu = QMenu(self)
            menu.addAction(QAction("Show", self, triggered=self._AH_SystemTrayShowWindow))
            menu.addAction(QAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self, triggered=self._AH_QuitActionTriggered))
            self.system_tray_icon.setContextMenu(menu)
            self.system_tray_icon.show()
        else:
            self.system_tray_icon = None

        # Accounts
        self.account_model = AccountModel(self)
        self.enabled_account_model = ActiveAccountModel(self.account_model, self)
        self.server_tools_account_model = ServerToolsAccountModel(self.account_model, self)
        self.identity.setModel(self.enabled_account_model)

        # Contacts
        self.contact_model = ContactModel(self)
        self.contact_search_model = ContactSearchModel(self.contact_model, self)
        self.contact_list.setModel(self.contact_model)
        self.search_list.setModel(self.contact_search_model)

        # Sessions (audio)
        self.session_model = AudioSessionModel(self)
        self.session_list.setModel(self.session_model)
        self.session_list.selectionModel().selectionChanged.connect(self._SH_SessionListSelectionChanged)

        # History
        self.history_manager = HistoryManager()

        # Windows, dialogs and panels
        self.about_panel = AboutPanel(self)
        self.conference_dialog = ConferenceDialog(self)
        self.contact_editor_dialog = ContactEditorDialog(self)
        self.google_contacts_dialog = GoogleContactsDialog(self)
        self.filetransfer_window = FileTransferWindow()
        self.preferences_window = PreferencesWindow(self.account_model, None)
        self.server_tools_window = ServerToolsWindow(self.server_tools_account_model, None)

        # Signals
        self.account_state.stateChanged.connect(self._SH_AccountStateChanged)
        self.account_state.clicked.connect(self._SH_AccountStateClicked)
        self.activity_note.editingFinished.connect(self._SH_ActivityNoteEditingFinished)
        self.add_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.add_search_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.audio_call_button.clicked.connect(self._SH_AudioCallButtonClicked)
        self.video_call_button.clicked.connect(self._SH_VideoCallButtonClicked)
        self.chat_session_button.clicked.connect(self._SH_ChatSessionButtonClicked)
        self.back_to_contacts_button.clicked.connect(self.search_box.clear) # this can be set in designer -Dan
        self.conference_button.makeConference.connect(self._SH_MakeConference)
        self.conference_button.breakConference.connect(self._SH_BreakConference)

        self.contact_list.selectionModel().selectionChanged.connect(self._SH_ContactListSelectionChanged)
        self.contact_model.itemsAdded.connect(self._SH_ContactModelAddedItems)
        self.contact_model.itemsRemoved.connect(self._SH_ContactModelRemovedItems)

        self.display_name.editingFinished.connect(self._SH_DisplayNameEditingFinished)
        self.hangup_all_button.clicked.connect(self._SH_HangupAllButtonClicked)

        self.identity.activated[int].connect(self._SH_IdentityChanged)
        self.identity.currentIndexChanged[int].connect(self._SH_IdentityCurrentIndexChanged)

        self.mute_button.clicked.connect(self._SH_MuteButtonClicked)

        self.search_box.textChanged.connect(self._SH_SearchBoxTextChanged)
        self.search_box.returnPressed.connect(self._SH_SearchBoxReturnPressed)
        self.search_box.shortcut.activated.connect(self.search_box.setFocus)

        self.search_list.selectionModel().selectionChanged.connect(self._SH_SearchListSelectionChanged)

        self.server_tools_account_model.rowsInserted.connect(self._SH_ServerToolsAccountModelChanged)
        self.server_tools_account_model.rowsRemoved.connect(self._SH_ServerToolsAccountModelChanged)

        self.session_model.sessionAdded.connect(self._SH_AudioSessionModelAddedSession)
        self.session_model.sessionRemoved.connect(self._SH_AudioSessionModelRemovedSession)
        self.session_model.structureChanged.connect(self._SH_AudioSessionModelChangedStructure)

        self.silent_button.clicked.connect(self._SH_SilentButtonClicked)
        self.switch_view_button.viewChanged.connect(self._SH_SwitchViewButtonChangedView)

        # Blink menu actions
        self.about_action.triggered.connect(self.about_panel.show)
        self.add_account_action.triggered.connect(self.preferences_window.show_add_account_dialog)
        self.manage_accounts_action.triggered.connect(self.preferences_window.show_for_accounts)
        self.help_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl(u'http://icanblink.com/help-qt.phtml')))
        self.preferences_action.triggered.connect(self.preferences_window.show)
        self.auto_accept_chat_action.triggered.connect(self._AH_AutoAcceptChatActionTriggered)
        self.received_messages_sound_action.triggered.connect(self._AH_ReceivedMessagesSoundActionTriggered)
        self.answering_machine_action.triggered.connect(self._AH_EnableAnsweringMachineActionTriggered)
        self.release_notes_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl(u'http://icanblink.com/changelog-qt.phtml')))
        self.quit_action.triggered.connect(self._AH_QuitActionTriggered)

        # Call menu actions
        self.redial_action.triggered.connect(self._AH_RedialActionTriggered)
        self.join_conference_action.triggered.connect(self.conference_dialog.show)
        self.history_menu.aboutToShow.connect(self._SH_HistoryMenuAboutToShow)
        self.history_menu.triggered.connect(self._AH_HistoryMenuTriggered)
        self.output_devices_group.triggered.connect(self._AH_AudioOutputDeviceChanged)
        self.input_devices_group.triggered.connect(self._AH_AudioInputDeviceChanged)
        self.alert_devices_group.triggered.connect(self._AH_AudioAlertDeviceChanged)
        self.video_devices_group.triggered.connect(self._AH_VideoDeviceChanged)
        self.mute_action.triggered.connect(self._SH_MuteButtonClicked)
        self.silent_action.triggered.connect(self._SH_SilentButtonClicked)

        # Tools menu actions
        self.sip_server_settings_action.triggered.connect(self._AH_SIPServerSettings)
        self.search_for_people_action.triggered.connect(self._AH_SearchForPeople)
        self.history_on_server_action.triggered.connect(self._AH_HistoryOnServer)

        # Window menu actions
        self.chat_window_action.triggered.connect(self._AH_ChatWindowActionTriggered)
        self.transfers_window_action.triggered.connect(self._AH_TransfersWindowActionTriggered)
        self.logs_window_action.triggered.connect(self._AH_LogsWindowActionTriggered)
        self.received_files_window_action.triggered.connect(self._AH_ReceivedFilesWindowActionTriggered)
        self.screenshots_window_action.triggered.connect(self._AH_ScreenshotsWindowActionTriggered)
예제 #10
0
파일: labels.py 프로젝트: scudella/blink-qt
 def update_from_contact(self, contact):
     icon_manager = IconManager()
     if self.icon is self.contact_icon:
         self.icon = self.contact_icon = icon_manager.get(contact.id)
     else:
         self.contact_icon = icon_manager.get(contact.id)
예제 #11
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.saved_account_state = None

        notification_center = NotificationCenter()
        notification_center.add_observer(self, name='SIPApplicationWillStart')
        notification_center.add_observer(self, name='SIPApplicationDidStart')
        notification_center.add_observer(self, name='SIPAccountGotMessageSummary')
        notification_center.add_observer(self, name='SIPAccountGotPendingWatcher')
        notification_center.add_observer(self, name='BlinkSessionNewOutgoing')
        notification_center.add_observer(self, name='BlinkSessionDidReinitializeForOutgoing')
        notification_center.add_observer(self, name='BlinkSessionTransferNewOutgoing')
        notification_center.add_observer(self, name='BlinkFileTransferNewIncoming')
        notification_center.add_observer(self, name='BlinkFileTransferNewOutgoing')
        notification_center.add_observer(self, sender=AccountManager())

        icon_manager = IconManager()

        self.pending_watcher_dialogs = []

        self.mwi_icons = [QIcon(Resources.get('icons/mwi-%d.png' % i)) for i in range(0, 11)]
        self.mwi_icons.append(QIcon(Resources.get('icons/mwi-many.png')))

        with Resources.directory:
            self.setupUi()

        self.setWindowTitle('Blink')

        geometry = QSettings().value("main_window/geometry")
        if geometry:
            self.restoreGeometry(geometry)

        self.default_icon_path = Resources.get('icons/default-avatar.png')
        self.default_icon = QIcon(self.default_icon_path)
        self.last_icon_directory = Path('~').normalized
        self.set_user_icon(icon_manager.get('avatar'))

        self.active_sessions_label.hide()
        self.enable_call_buttons(False)
        self.conference_button.setEnabled(False)
        self.hangup_all_button.setEnabled(False)
        self.sip_server_settings_action.setEnabled(False)
        self.search_for_people_action.setEnabled(False)
        self.history_on_server_action.setEnabled(False)
        self.main_view.setCurrentWidget(self.contacts_panel)
        self.contacts_view.setCurrentWidget(self.contact_list_panel)
        self.search_view.setCurrentWidget(self.search_list_panel)

        # System tray
        if QSystemTrayIcon.isSystemTrayAvailable():
            self.system_tray_icon = QSystemTrayIcon(QIcon(Resources.get('icons/blink.png')), self)
            self.system_tray_icon.activated.connect(self._SH_SystemTrayIconActivated)
            menu = QMenu(self)
            menu.addAction("Show", self._AH_SystemTrayShowWindow)
            menu.addAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self._AH_QuitActionTriggered)
            self.system_tray_icon.setContextMenu(menu)
            self.system_tray_icon.show()
        else:
            self.system_tray_icon = None

        # Accounts
        self.account_model = AccountModel(self)
        self.enabled_account_model = ActiveAccountModel(self.account_model, self)
        self.server_tools_account_model = ServerToolsAccountModel(self.account_model, self)
        self.identity.setModel(self.enabled_account_model)

        # Contacts
        self.contact_model = ContactModel(self)
        self.contact_search_model = ContactSearchModel(self.contact_model, self)
        self.contact_list.setModel(self.contact_model)
        self.search_list.setModel(self.contact_search_model)

        # Sessions (audio)
        self.session_model = AudioSessionModel(self)
        self.session_list.setModel(self.session_model)
        self.session_list.selectionModel().selectionChanged.connect(self._SH_SessionListSelectionChanged)

        # History
        self.history_manager = HistoryManager()

        # Windows, dialogs and panels
        self.about_panel = AboutPanel(self)
        self.conference_dialog = ConferenceDialog(self)
        self.contact_editor_dialog = ContactEditorDialog(self)
        self.filetransfer_window = FileTransferWindow()
        self.preferences_window = PreferencesWindow(self.account_model, None)
        self.server_tools_window = ServerToolsWindow(self.server_tools_account_model, None)

        # Signals
        self.account_state.stateChanged.connect(self._SH_AccountStateChanged)
        self.account_state.clicked.connect(self._SH_AccountStateClicked)
        self.activity_note.editingFinished.connect(self._SH_ActivityNoteEditingFinished)
        self.add_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.add_search_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.audio_call_button.clicked.connect(self._SH_AudioCallButtonClicked)
        self.video_call_button.clicked.connect(self._SH_VideoCallButtonClicked)
        self.chat_session_button.clicked.connect(self._SH_ChatSessionButtonClicked)
        self.back_to_contacts_button.clicked.connect(self.search_box.clear)  # this can be set in designer -Dan
        self.conference_button.makeConference.connect(self._SH_MakeConference)
        self.conference_button.breakConference.connect(self._SH_BreakConference)

        self.contact_list.selectionModel().selectionChanged.connect(self._SH_ContactListSelectionChanged)
        self.contact_model.itemsAdded.connect(self._SH_ContactModelAddedItems)
        self.contact_model.itemsRemoved.connect(self._SH_ContactModelRemovedItems)

        self.display_name.editingFinished.connect(self._SH_DisplayNameEditingFinished)
        self.hangup_all_button.clicked.connect(self._SH_HangupAllButtonClicked)

        self.identity.activated[int].connect(self._SH_IdentityChanged)
        self.identity.currentIndexChanged[int].connect(self._SH_IdentityCurrentIndexChanged)

        self.mute_button.clicked.connect(self._SH_MuteButtonClicked)

        self.search_box.textChanged.connect(self._SH_SearchBoxTextChanged)
        self.search_box.returnPressed.connect(self._SH_SearchBoxReturnPressed)
        self.search_box.shortcut.activated.connect(self.search_box.setFocus)

        self.search_list.selectionModel().selectionChanged.connect(self._SH_SearchListSelectionChanged)

        self.server_tools_account_model.rowsInserted.connect(self._SH_ServerToolsAccountModelChanged)
        self.server_tools_account_model.rowsRemoved.connect(self._SH_ServerToolsAccountModelChanged)

        self.session_model.sessionAdded.connect(self._SH_AudioSessionModelAddedSession)
        self.session_model.sessionRemoved.connect(self._SH_AudioSessionModelRemovedSession)
        self.session_model.structureChanged.connect(self._SH_AudioSessionModelChangedStructure)

        self.silent_button.clicked.connect(self._SH_SilentButtonClicked)
        self.switch_view_button.viewChanged.connect(self._SH_SwitchViewButtonChangedView)

        # Blink menu actions
        self.about_action.triggered.connect(self.about_panel.show)
        self.add_account_action.triggered.connect(self.preferences_window.show_add_account_dialog)
        self.manage_accounts_action.triggered.connect(self.preferences_window.show_for_accounts)
        self.help_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl('http://icanblink.com/help/')))
        self.preferences_action.triggered.connect(self.preferences_window.show)
        self.auto_accept_chat_action.triggered.connect(self._AH_AutoAcceptChatActionTriggered)
        self.received_messages_sound_action.triggered.connect(self._AH_ReceivedMessagesSoundActionTriggered)
        self.answering_machine_action.triggered.connect(self._AH_EnableAnsweringMachineActionTriggered)
        self.release_notes_action.triggered.connect(partial(QDesktopServices.openUrl, QUrl('http://icanblink.com/changelog/')))
        self.quit_action.triggered.connect(self._AH_QuitActionTriggered)

        # Call menu actions
        self.redial_action.triggered.connect(self._AH_RedialActionTriggered)
        self.join_conference_action.triggered.connect(self.conference_dialog.show)
        self.history_menu.aboutToShow.connect(self._SH_HistoryMenuAboutToShow)
        self.history_menu.triggered.connect(self._AH_HistoryMenuTriggered)
        self.output_devices_group.triggered.connect(self._AH_AudioOutputDeviceChanged)
        self.input_devices_group.triggered.connect(self._AH_AudioInputDeviceChanged)
        self.alert_devices_group.triggered.connect(self._AH_AudioAlertDeviceChanged)
        self.video_devices_group.triggered.connect(self._AH_VideoDeviceChanged)
        self.mute_action.triggered.connect(self._SH_MuteButtonClicked)
        self.silent_action.triggered.connect(self._SH_SilentButtonClicked)

        # Tools menu actions
        self.sip_server_settings_action.triggered.connect(self._AH_SIPServerSettings)
        self.search_for_people_action.triggered.connect(self._AH_SearchForPeople)
        self.history_on_server_action.triggered.connect(self._AH_HistoryOnServer)
        self.google_contacts_action.triggered.connect(self._AH_GoogleContactsActionTriggered)

        # Window menu actions
        self.chat_window_action.triggered.connect(self._AH_ChatWindowActionTriggered)
        self.transfers_window_action.triggered.connect(self._AH_TransfersWindowActionTriggered)
        self.logs_window_action.triggered.connect(self._AH_LogsWindowActionTriggered)
        self.received_files_window_action.triggered.connect(self._AH_ReceivedFilesWindowActionTriggered)
        self.screenshots_window_action.triggered.connect(self._AH_ScreenshotsWindowActionTriggered)
예제 #12
0
 def update_from_contact(self, contact):
     icon_manager = IconManager()
     if self.icon is self.contact_icon:
         self.icon = self.contact_icon = icon_manager.get(contact.id)
     else:
         self.contact_icon = icon_manager.get(contact.id)