Commit e6145b72 authored by Dan Pascu's avatar Dan Pascu

Modernized code and improved PEP-8 compliance

parent 8c6e300f
# #
# Boring file regular expresions # Boring file regular expressions
# #
~$ ~$
......
__all__ = ['Blink']
__version__ = '1.4.2' __version__ = '1.4.2'
__date__ = 'December 4th 2015' __date__ = 'December 4th 2015'
import os import os
import sys import sys
import sip import sip
...@@ -42,6 +38,7 @@ try: ...@@ -42,6 +38,7 @@ try:
from blink import branding from blink import branding
except ImportError: except ImportError:
branding = Null branding = Null
from blink.chatwindow import ChatWindow from blink.chatwindow import ChatWindow
from blink.configuration.account import AccountExtension, BonjourAccountExtension from blink.configuration.account import AccountExtension, BonjourAccountExtension
from blink.configuration.addressbook import ContactExtension, GroupExtension from blink.configuration.addressbook import ContactExtension, GroupExtension
...@@ -56,6 +53,9 @@ from blink.update import UpdateManager ...@@ -56,6 +53,9 @@ from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread from blink.util import QSingleton, run_in_gui_thread
__all__ = ['Blink']
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
output = sys.stdout output = sys.stdout
makedirs(ApplicationData.get('logs')) makedirs(ApplicationData.get('logs'))
...@@ -293,7 +293,7 @@ class Blink(QApplication): ...@@ -293,7 +293,7 @@ class Blink(QApplication):
self.main_window.show() self.main_window.show()
settings = SIPSimpleSettings() settings = SIPSimpleSettings()
accounts = AccountManager().get_accounts() accounts = AccountManager().get_accounts()
if not accounts or (self.first_run and accounts==[BonjourAccount()]): if not accounts or (self.first_run and accounts == [BonjourAccount()]):
self.main_window.preferences_window.show_create_account_dialog() self.main_window.preferences_window.show_create_account_dialog()
if settings.google_contacts.authorization_token is InvalidToken: if settings.google_contacts.authorization_token is InvalidToken:
self.main_window.google_contacts_dialog.open_for_incorrect_password() self.main_window.google_contacts_dialog.open_for_incorrect_password()
......
__all__ = ['AboutPanel']
from PyQt4 import uic from PyQt4 import uic
from blink import __date__, __version__ from blink import __date__, __version__
...@@ -8,6 +6,9 @@ from blink.resources import Resources ...@@ -8,6 +6,9 @@ from blink.resources import Resources
from blink.util import QSingleton from blink.util import QSingleton
__all__ = ['AboutPanel']
credits_text = """ credits_text = """
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html> <html>
...@@ -32,6 +33,7 @@ credits_text = """ ...@@ -32,6 +33,7 @@ credits_text = """
ui_class, base_class = uic.loadUiType(Resources.get('about_panel.ui')) ui_class, base_class = uic.loadUiType(Resources.get('about_panel.ui'))
class AboutPanel(base_class, ui_class): class AboutPanel(base_class, ui_class):
__metaclass__ = QSingleton __metaclass__ = QSingleton
...@@ -43,7 +45,7 @@ class AboutPanel(base_class, ui_class): ...@@ -43,7 +45,7 @@ class AboutPanel(base_class, ui_class):
self.version.setText(u'Version %s\n%s' % (__version__, __date__)) self.version.setText(u'Version %s\n%s' % (__version__, __date__))
credits_width = self.credits_text.fontMetrics().width("NLNET Foundation" + "http://sipsimpleclient.org") + 40 credits_width = self.credits_text.fontMetrics().width("NLnet Foundation" + "http://sipsimpleclient.org") + 40
self.credits_text.setFixedWidth(credits_width) self.credits_text.setFixedWidth(credits_width)
self.credits_text.document().documentLayout().documentSizeChanged.connect(self._credits_size_changed) self.credits_text.document().documentLayout().documentSizeChanged.connect(self._credits_size_changed)
self.credits_text.setHtml(credits_text) self.credits_text.setHtml(credits_text)
......
__all__ = ['AccountModel', 'ActiveAccountModel', 'AccountSelector', 'AddAccountDialog', 'ServerToolsAccountModel', 'ServerToolsWindow']
import os import os
import re import re
import sys import sys
...@@ -31,17 +29,23 @@ from blink.widgets.labels import Status ...@@ -31,17 +29,23 @@ from blink.widgets.labels import Status
from blink.util import QSingleton, call_in_gui_thread, run_in_gui_thread from blink.util import QSingleton, call_in_gui_thread, run_in_gui_thread
__all__ = ['AccountModel', 'ActiveAccountModel', 'AccountSelector', 'AddAccountDialog', 'ServerToolsAccountModel', 'ServerToolsWindow']
class IconDescriptor(object): class IconDescriptor(object):
def __init__(self, filename): def __init__(self, filename):
self.filename = filename self.filename = filename
self.icon = None self.icon = None
def __get__(self, obj, objtype):
def __get__(self, instance, owner):
if self.icon is None: if self.icon is None:
self.icon = QIcon(self.filename) self.icon = QIcon(self.filename)
self.icon.filename = self.filename self.icon.filename = self.filename
return self.icon return self.icon
def __set__(self, obj, value): def __set__(self, obj, value):
raise AttributeError("attribute cannot be set") raise AttributeError("attribute cannot be set")
def __delete__(self, obj): def __delete__(self, obj):
raise AttributeError("attribute cannot be deleted") raise AttributeError("attribute cannot be deleted")
...@@ -222,6 +226,7 @@ class AccountSelector(QComboBox): ...@@ -222,6 +226,7 @@ class AccountSelector(QComboBox):
ui_class, base_class = uic.loadUiType(Resources.get('add_account.ui')) ui_class, base_class = uic.loadUiType(Resources.get('add_account.ui'))
class AddAccountDialog(base_class, ui_class): class AddAccountDialog(base_class, ui_class):
__metaclass__ = QSingleton __metaclass__ = QSingleton
...@@ -587,6 +592,7 @@ class ServerToolsWebView(QWebView): ...@@ -587,6 +592,7 @@ class ServerToolsWebView(QWebView):
ui_class, base_class = uic.loadUiType(Resources.get('server_tools.ui')) ui_class, base_class = uic.loadUiType(Resources.get('server_tools.ui'))
class ServerToolsWindow(base_class, ui_class): class ServerToolsWindow(base_class, ui_class):
__metaclass__ = QSingleton __metaclass__ = QSingleton
...@@ -629,7 +635,7 @@ class ServerToolsWindow(base_class, ui_class): ...@@ -629,7 +635,7 @@ class ServerToolsWindow(base_class, ui_class):
self.spinner_label.show() self.spinner_label.show()
self.spinner_movie.start() self.spinner_movie.start()
self.progress_bar.setValue(0) self.progress_bar.setValue(0)
#self.progress_bar.show() # self.progress_bar.show()
def _SH_WebViewLoadFinished(self, load_ok): def _SH_WebViewLoadFinished(self, load_ok):
self.spinner_movie.stop() self.spinner_movie.stop()
......
This diff is collapsed.
...@@ -176,7 +176,7 @@ class IconDescriptor(object): ...@@ -176,7 +176,7 @@ class IconDescriptor(object):
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, IconDescriptor): if isinstance(other, IconDescriptor):
return self.url==other.url and self.etag==other.etag return self.url == other.url and self.etag == other.etag
return NotImplemented return NotImplemented
def __ne__(self, other): def __ne__(self, other):
...@@ -208,7 +208,7 @@ class PresenceState(object): ...@@ -208,7 +208,7 @@ class PresenceState(object):
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, PresenceState): if isinstance(other, PresenceState):
return self.state==other.state and self.note==other.note return self.state == other.state and self.note == other.note
return NotImplemented return NotImplemented
def __ne__(self, other): def __ne__(self, other):
......
...@@ -83,7 +83,7 @@ class SIPSimpleSettingsExtension(SettingsObjectExtension): ...@@ -83,7 +83,7 @@ class SIPSimpleSettingsExtension(SettingsObjectExtension):
sounds = SoundSettings sounds = SoundSettings
tls = TLSSettingsExtension tls = TLSSettingsExtension
user_agent = Setting(type=str, default='Blink %s (%s)' % (__version__, platform.system() if sys.platform!='darwin' else 'MacOSX Qt')) user_agent = Setting(type=str, default='Blink %s (%s)' % (__version__, platform.system() if sys.platform != 'darwin' else 'MacOSX Qt'))
class SessionInfoSettings(SettingsGroup): class SessionInfoSettings(SettingsGroup):
......
This diff is collapsed.
__all__ = ['CallFunctionEvent']
from PyQt4.QtCore import QEvent from PyQt4.QtCore import QEvent
from application.python.descriptor import classproperty from application.python.descriptor import classproperty
__all__ = ['CallFunctionEvent']
class EventMeta(type(QEvent)): class EventMeta(type(QEvent)):
def __init__(cls, name, bases, dct): def __init__(cls, name, bases, dct):
super(EventMeta, cls).__init__(name, bases, dct) super(EventMeta, cls).__init__(name, bases, dct)
...@@ -35,4 +36,3 @@ class CallFunctionEvent(EventBase): ...@@ -35,4 +36,3 @@ class CallFunctionEvent(EventBase):
self.args = args self.args = args
self.kw = kw self.kw = kw
__all__ = ['FileTransferWindow']
import os import os
from PyQt4 import uic from PyQt4 import uic
...@@ -18,8 +16,12 @@ from blink.sessions import FileTransferDelegate, FileTransferModel ...@@ -18,8 +16,12 @@ from blink.sessions import FileTransferDelegate, FileTransferModel
from blink.widgets.util import ContextMenuActions from blink.widgets.util import ContextMenuActions
__all__ = ['FileTransferWindow']
ui_class, base_class = uic.loadUiType(Resources.get('filetransfer_window.ui')) ui_class, base_class = uic.loadUiType(Resources.get('filetransfer_window.ui'))
class FileTransferWindow(base_class, ui_class): class FileTransferWindow(base_class, ui_class):
implements(IObserver) implements(IObserver)
...@@ -63,7 +65,7 @@ class FileTransferWindow(base_class, ui_class): ...@@ -63,7 +65,7 @@ class FileTransferWindow(base_class, ui_class):
def update_status(self): def update_status(self):
total = len(self.model.items) total = len(self.model.items)
active = len([item for item in self.model.items if not item.ended]) active = len([item for item in self.model.items if not item.ended])
text = u'%d %s' % (total, 'transfer' if total==1 else 'transfers') text = u'%d %s' % (total, 'transfer' if total == 1 else 'transfers')
if active > 0: if active > 0:
text += u' (%d active)' % active text += u' (%d active)' % active
self.status_label.setText(text) self.status_label.setText(text)
......
__all__ = ['HistoryManager']
import bisect import bisect
import cPickle as pickle import cPickle as pickle
import re import re
...@@ -23,6 +21,9 @@ from blink.resources import ApplicationData, Resources ...@@ -23,6 +21,9 @@ from blink.resources import ApplicationData, Resources
from blink.util import run_in_gui_thread from blink.util import run_in_gui_thread
__all__ = ['HistoryManager']
class HistoryManager(object): class HistoryManager(object):
__metaclass__ = Singleton __metaclass__ = Singleton
implements(IObserver) implements(IObserver)
...@@ -86,13 +87,16 @@ class IconDescriptor(object): ...@@ -86,13 +87,16 @@ class IconDescriptor(object):
def __init__(self, filename): def __init__(self, filename):
self.filename = filename self.filename = filename
self.icon = None self.icon = None
def __get__(self, obj, objtype):
def __get__(self, instance, owner):
if self.icon is None: if self.icon is None:
self.icon = QIcon(self.filename) self.icon = QIcon(self.filename)
self.icon.filename = self.filename self.icon.filename = self.filename
return self.icon return self.icon
def __set__(self, obj, value): def __set__(self, obj, value):
raise AttributeError("attribute cannot be set") raise AttributeError("attribute cannot be set")
def __delete__(self, obj): def __delete__(self, obj):
raise AttributeError("attribute cannot be deleted") raise AttributeError("attribute cannot be deleted")
...@@ -116,7 +120,7 @@ class HistoryEntry(object): ...@@ -116,7 +120,7 @@ class HistoryEntry(object):
self.reason = reason self.reason = reason
def __reduce__(self): def __reduce__(self):
return (self.__class__, (self.direction, self.name, self.uri, self.account_id, self.call_time, self.duration, self.failed, self.reason)) return self.__class__, (self.direction, self.name, self.uri, self.account_id, self.call_time, self.duration, self.failed, self.reason)
def __eq__(self, other): def __eq__(self, other):
return self is other return self is other
...@@ -174,7 +178,7 @@ class HistoryEntry(object): ...@@ -174,7 +178,7 @@ class HistoryEntry(object):
@classmethod @classmethod
def from_session(cls, session): def from_session(cls, session):
if session.start_time is None and session.end_time is not None: if session.start_time is None and session.end_time is not None:
# Session may have anded before it fully started # Session may have ended before it fully started
session.start_time = session.end_time session.start_time = session.end_time
call_time = session.start_time or ISOTimestamp.now() call_time = session.start_time or ISOTimestamp.now()
if session.start_time and session.end_time: if session.start_time and session.end_time:
......
__all__ = ['LogManager']
import os import os
import sys import sys
...@@ -21,6 +19,9 @@ from sipsimple.configuration.settings import SIPSimpleSettings ...@@ -21,6 +19,9 @@ from sipsimple.configuration.settings import SIPSimpleSettings
from blink.resources import ApplicationData from blink.resources import ApplicationData
__all__ = ['LogManager']
class NotificationQueue(object): class NotificationQueue(object):
implements(IObserver) implements(IObserver)
...@@ -161,10 +162,10 @@ class LogManager(object): ...@@ -161,10 +162,10 @@ class LogManager(object):
direction = "RECEIVED" direction = "RECEIVED"
else: else:
direction = "SENDING" direction = "SENDING"
buf = ["%s: Packet %d, +%s" % (direction, self._siptrace_packet_count, (notification.datetime - self._siptrace_start_time))] buf = ["%s: Packet %d, +%s" % (direction, self._siptrace_packet_count, (notification.datetime - self._siptrace_start_time)),
buf.append("%(source_ip)s:%(source_port)d -(SIP over %(transport)s)-> %(destination_ip)s:%(destination_port)d" % notification.data.__dict__) "%(source_ip)s:%(source_port)d -(SIP over %(transport)s)-> %(destination_ip)s:%(destination_port)d" % notification.data.__dict__,
buf.append(notification.data.data) notification.data.data,
buf.append('--') '--']
message = '\n'.join(buf) message = '\n'.join(buf)
try: try:
self.siptrace_file.write('%s [%s %d]: %s\n' % (notification.datetime, self.name, self.pid, message)) self.siptrace_file.write('%s [%s %d]: %s\n' % (notification.datetime, self.name, self.pid, message))
...@@ -236,4 +237,3 @@ class LogManager(object): ...@@ -236,4 +237,3 @@ class LogManager(object):
except Exception: except Exception:
pass pass
__all__ = ['MainWindow']
import hashlib import hashlib
import os import os
...@@ -36,8 +34,12 @@ from blink.util import run_in_gui_thread ...@@ -36,8 +34,12 @@ from blink.util import run_in_gui_thread
from blink.widgets.buttons import AccountState, SwitchViewButton from blink.widgets.buttons import AccountState, SwitchViewButton
__all__ = ['MainWindow']
ui_class, base_class = uic.loadUiType(Resources.get('blink.ui')) ui_class, base_class = uic.loadUiType(Resources.get('blink.ui'))
class MainWindow(base_class, ui_class): class MainWindow(base_class, ui_class):
implements(IObserver) implements(IObserver)
...@@ -585,7 +587,7 @@ class MainWindow(base_class, ui_class): ...@@ -585,7 +587,7 @@ class MainWindow(base_class, ui_class):
def _SH_ContactListSelectionChanged(self, selected, deselected): def _SH_ContactListSelectionChanged(self, selected, deselected):
account_manager = AccountManager() account_manager = AccountManager()
selected_items = self.contact_list.selectionModel().selectedIndexes() selected_items = self.contact_list.selectionModel().selectedIndexes()
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and isinstance(selected_items[0].data(Qt.UserRole), Contact)) self.enable_call_buttons(account_manager.default_account is not None and len(selected_items) == 1 and isinstance(selected_items[0].data(Qt.UserRole), Contact))
def _SH_ContactModelAddedItems(self, items): def _SH_ContactModelAddedItems(self, items):
if not self.search_box.text(): if not self.search_box.text():
...@@ -663,7 +665,7 @@ class MainWindow(base_class, ui_class): ...@@ -663,7 +665,7 @@ class MainWindow(base_class, ui_class):
else: else:
self.contacts_view.setCurrentWidget(self.contact_list_panel) self.contacts_view.setCurrentWidget(self.contact_list_panel)
selected_items = self.contact_list.selectionModel().selectedIndexes() selected_items = self.contact_list.selectionModel().selectedIndexes()
self.enable_call_buttons(account_manager.default_account is not None and len(selected_items)==1 and type(selected_items[0].data(Qt.UserRole)) is Contact) self.enable_call_buttons(account_manager.default_account is not None and len(selected_items) == 1 and type(selected_items[0].data(Qt.UserRole)) is Contact)
self.search_list.detail_model.contact = None self.search_list.detail_model.contact = None
self.search_list.detail_view.hide() self.search_list.detail_view.hide()
...@@ -698,7 +700,7 @@ class MainWindow(base_class, ui_class): ...@@ -698,7 +700,7 @@ class MainWindow(base_class, ui_class):
def _SH_AudioSessionModelChangedStructure(self): def _SH_AudioSessionModelChangedStructure(self):
active_sessions = self.session_model.active_sessions active_sessions = self.session_model.active_sessions
self.active_sessions_label.setText(u'There is 1 active call' if len(active_sessions)==1 else u'There are %d active calls' % len(active_sessions)) self.active_sessions_label.setText(u'There is 1 active call' if len(active_sessions) == 1 else u'There are %d active calls' % len(active_sessions))
self.active_sessions_label.setVisible(any(active_sessions)) self.active_sessions_label.setVisible(any(active_sessions))
self.hangup_all_button.setEnabled(any(active_sessions)) self.hangup_all_button.setEnabled(any(active_sessions))
selected_indexes = self.session_list.selectionModel().selectedIndexes() selected_indexes = self.session_list.selectionModel().selectedIndexes()
...@@ -803,16 +805,16 @@ class MainWindow(base_class, ui_class): ...@@ -803,16 +805,16 @@ class MainWindow(base_class, ui_class):
self.silent_action.setChecked(settings.audio.silent) self.silent_action.setChecked(settings.audio.silent)
self.silent_button.setChecked(settings.audio.silent) self.silent_button.setChecked(settings.audio.silent)
if 'audio.output_device' in notification.data.modified: 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 = next(action for action in self.output_devices_group.actions() if action.data() == settings.audio.output_device)
action.setChecked(True) action.setChecked(True)
if 'audio.input_device' in notification.data.modified: 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 = next(action for action in self.input_devices_group.actions() if action.data() == settings.audio.input_device)
action.setChecked(True) action.setChecked(True)
if 'audio.alert_device' in notification.data.modified: 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 = next(action for action in self.alert_devices_group.actions() if action.data() == settings.audio.alert_device)
action.setChecked(True) action.setChecked(True)
if 'video.device' in notification.data.modified: 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 = next(action for action in self.video_devices_group.actions() if action.data() == settings.video.device)
action.setChecked(True) action.setChecked(True)
if 'answering_machine.enabled' in notification.data.modified: if 'answering_machine.enabled' in notification.data.modified:
self.answering_machine_action.setChecked(settings.answering_machine.enabled) self.answering_machine_action.setChecked(settings.answering_machine.enabled)
...@@ -841,12 +843,12 @@ class MainWindow(base_class, ui_class): ...@@ -841,12 +843,12 @@ class MainWindow(base_class, ui_class):
account_manager = AccountManager() account_manager = AccountManager()
account = notification.sender account = notification.sender
if 'enabled' in notification.data.modified: if 'enabled' in notification.data.modified:
action = (action for action in self.accounts_menu.actions() if action.data() is account).next() action = next(action for action in self.accounts_menu.actions() if action.data() is account)
action.setChecked(account.enabled) action.setChecked(account.enabled)
if 'display_name' in notification.data.modified and account is account_manager.default_account: if 'display_name' in notification.data.modified and account is account_manager.default_account:
self.display_name.setText(account.display_name or u'') self.display_name.setText(account.display_name or u'')
if set(['enabled', 'message_summary.enabled', 'message_summary.voicemail_uri']).intersection(notification.data.modified): if {'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 = next(action for action in self.voicemail_menu.actions() if action.data() is account)
action.setVisible(False if account is BonjourAccount() else account.enabled and account.message_summary.enabled) 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) action.setEnabled(False if account is BonjourAccount() else account.voicemail_uri is not None)
...@@ -868,9 +870,9 @@ class MainWindow(base_class, ui_class): ...@@ -868,9 +870,9 @@ class MainWindow(base_class, ui_class):
def _NH_SIPAccountManagerDidRemoveAccount(self, notification): def _NH_SIPAccountManagerDidRemoveAccount(self, notification):
account = notification.data.account account = notification.data.account
action = (action for action in self.accounts_menu.actions() if action.data() is account).next() action = next(action for action in self.accounts_menu.actions() if action.data() is account)
self.accounts_menu.removeAction(action) self.accounts_menu.removeAction(action)
action = (action for action in self.voicemail_menu.actions() if action.data() is account).next() action = next(action for action in self.voicemail_menu.actions() if action.data() is account)
self.voicemail_menu.removeAction(action) self.voicemail_menu.removeAction(action)
def _NH_SIPAccountManagerDidChangeDefaultAccount(self, notification): def _NH_SIPAccountManagerDidChangeDefaultAccount(self, notification):
...@@ -878,12 +880,12 @@ class MainWindow(base_class, ui_class): ...@@ -878,12 +880,12 @@ class MainWindow(base_class, ui_class):
self.enable_call_buttons(False) self.enable_call_buttons(False)
else: else:
selected_items = self.contact_list.selectionModel().selectedIndexes() selected_items = self.contact_list.selectionModel().selectedIndexes()
self.enable_call_buttons(len(selected_items)==1 and isinstance(selected_items[0].data(Qt.UserRole), Contact)) self.enable_call_buttons(len(selected_items) == 1 and isinstance(selected_items[0].data(Qt.UserRole), Contact))
def _NH_SIPAccountGotMessageSummary(self, notification): def _NH_SIPAccountGotMessageSummary(self, notification):
account = notification.sender account = notification.sender
summary = notification.data.message_summary summary = notification.data.message_summary
action = (action for action in self.voicemail_menu.actions() if action.data() is account).next() action = next(action for action in self.voicemail_menu.actions() if action.data() is account)
action.setEnabled(account.voicemail_uri is not None) action.setEnabled(account.voicemail_uri is not None)
if summary.messages_waiting: if summary.messages_waiting:
try: try:
...@@ -918,4 +920,3 @@ class MainWindow(base_class, ui_class): ...@@ -918,4 +920,3 @@ class MainWindow(base_class, ui_class):
del ui_class, base_class del ui_class, base_class
This diff is collapsed.
__all__ = ['PresenceManager', 'PendingWatcherDialog']
import base64 import base64
import hashlib import hashlib
import re import re
...@@ -36,6 +34,9 @@ from blink.resources import IconManager, Resources ...@@ -36,6 +34,9 @@ from blink.resources import IconManager, Resources
from blink.util import run_in_gui_thread from blink.util import run_in_gui_thread
__all__ = ['PresenceManager', 'PendingWatcherDialog']
epoch = datetime.fromtimestamp(0, tzutc()) epoch = datetime.fromtimestamp(0, tzutc())
...@@ -50,7 +51,7 @@ class BlinkPresenceState(object): ...@@ -50,7 +51,7 @@ class BlinkPresenceState(object):
state = blink_settings.presence.current_state.state state = blink_settings.presence.current_state.state
note = blink_settings.presence.current_state.note note = blink_settings.presence.current_state.note
state = 'offline' if state=='Invisible' else state.lower() state = 'offline' if state == 'Invisible' else state.lower()
if self.account is BonjourAccount(): if self.account is BonjourAccount():
return BonjourPresenceState(state, note) return BonjourPresenceState(state, note)
...@@ -182,10 +183,10 @@ class PresencePublicationHandler(object): ...@@ -182,10 +183,10 @@ class PresencePublicationHandler(object):
account.presence_state = BlinkPresenceState(account).online_state account.presence_state = BlinkPresenceState(account).online_state
else: else:
account = notification.sender account = notification.sender
if set(['xcap.enabled', 'xcap.xcap_root']).intersection(notification.data.modified): if {'xcap.enabled', 'xcap.xcap_root'}.intersection(notification.data.modified):
account.xcap.icon = None account.xcap.icon = None
account.save() account.save()
elif set(['presence.enabled', 'display_name', 'xcap.icon']).intersection(notification.data.modified) and account.presence.enabled: elif {'presence.enabled', 'display_name', 'xcap.icon'}.intersection(notification.data.modified) and account.presence.enabled:
account.presence_state = BlinkPresenceState(account).online_state account.presence_state = BlinkPresenceState(account).online_state
def _NH_SIPAccountWillActivate(self, notification): def _NH_SIPAccountWillActivate(self, notification):
...@@ -219,11 +220,11 @@ class PresencePublicationHandler(object): ...@@ -219,11 +220,11 @@ class PresencePublicationHandler(object):
blink_settings.presence.current_state = new_state blink_settings.presence.current_state = new_state
if new_state.note: if new_state.note:
try: try:
next(state for state in blink_settings.presence.state_history if state==new_state) next(state for state in blink_settings.presence.state_history if state == new_state)
except StopIteration: except StopIteration:
blink_settings.presence.state_history = [new_state] + blink_settings.presence.state_history blink_settings.presence.state_history = [new_state] + blink_settings.presence.state_history
else: else:
blink_settings.presence.state_history = [new_state] + [state for state in blink_settings.presence.state_history if state!=new_state] blink_settings.presence.state_history = [new_state] + [state for state in blink_settings.presence.state_history if state != new_state]
blink_settings.save() blink_settings.save()
def _NH_SIPAccountDidDiscoverXCAPSupport(self, notification): def _NH_SIPAccountDidDiscoverXCAPSupport(self, notification):
...@@ -334,11 +335,11 @@ class PresenceSubscriptionHandler(object): ...@@ -334,11 +335,11 @@ class PresenceSubscriptionHandler(object):
def service_sort_key(service): def service_sort_key(service):
timestamp = service.timestamp.value if service.timestamp else epoch timestamp = service.timestamp.value if service.timestamp else epoch
if service.status.extended is not None: if service.status.extended is not None:
return (100, timestamp) return 100, timestamp
elif service.status.basic == 'open': elif service.status.basic == 'open':
return (10, timestamp) return 10, timestamp
else: else:
return (0, timestamp) return 0, timestamp
current_pidf_map = {} current_pidf_map = {}
contact_pidf_map = {} contact_pidf_map = {}
...@@ -365,7 +366,7 @@ class PresenceSubscriptionHandler(object): ...@@ -365,7 +366,7 @@ class PresenceSubscriptionHandler(object):
if service.status.extended: if service.status.extended:
state = unicode(service.status.extended) state = unicode(service.status.extended)
else: else:
state = 'available' if service.status.basic=='open' else 'offline' state = 'available' if service.status.basic == 'open' else 'offline'
note = unicode(next(iter(service.notes))) if service.notes else None note = unicode(next(iter(service.notes))) if service.notes else None
icon_url = unicode(service.icon) if service.icon else None icon_url = unicode(service.icon) if service.icon else None
...@@ -406,7 +407,7 @@ class PresenceSubscriptionHandler(object): ...@@ -406,7 +407,7 @@ class PresenceSubscriptionHandler(object):
self._winfo_map.pop(old_id, None) self._winfo_map.pop(old_id, None)
self._process_presence_data() self._process_presence_data()
return return
if set(['enabled', 'presence.enabled']).intersection(notification.data.modified): if {'enabled', 'presence.enabled'}.intersection(notification.data.modified):
if not account.enabled or not account.presence.enabled: if not account.enabled or not account.presence.enabled:
self._pidf_map.pop(account.id, None) self._pidf_map.pop(account.id, None)
self._winfo_map.pop(account.id, None) self._winfo_map.pop(account.id, None)
......
"""Provide access to Blink's resources""" """Provide access to Blink's resources"""
__all__ = ['ApplicationData', 'Resources', 'IconManager']
import __main__ import __main__
import imghdr import imghdr
import os import os
...@@ -21,10 +19,14 @@ from sipsimple.configuration.datatypes import Path ...@@ -21,10 +19,14 @@ from sipsimple.configuration.datatypes import Path
from blink.util import run_in_gui_thread from blink.util import run_in_gui_thread
__all__ = ['ApplicationData', 'Resources', 'IconManager']
class DirectoryContextManager(unicode): class DirectoryContextManager(unicode):
def __enter__(self): def __enter__(self):
self.directory = os.getcwdu() self.directory = os.getcwdu()
os.chdir(self) os.chdir(self)
def __exit__(self, type, value, traceback): def __exit__(self, type, value, traceback):
os.chdir(self.directory) os.chdir(self.directory)
......
__all__ = ['ScreensharingWindow', 'VNCViewer', 'VNCClient', 'RFBSettings', 'ServerDefault', 'TrueColor', 'HighColor', 'LowColor']
from blink.screensharing.vncclient import VNCClient, RFBSettings, ServerDefault, TrueColor, HighColor, LowColor from blink.screensharing.vncclient import VNCClient, RFBSettings, ServerDefault, TrueColor, HighColor, LowColor
from blink.screensharing.vncviewer import ScreensharingWindow, VNCViewer from blink.screensharing.vncviewer import ScreensharingWindow, VNCViewer
__all__ = ['ScreensharingWindow', 'VNCViewer', 'VNCClient', 'RFBSettings', 'ServerDefault', 'TrueColor', 'HighColor', 'LowColor']
__all__ = ['RFBClient', 'RFBClientError']
from sip import voidptr from sip import voidptr
from PyQt4.QtCore import QThread from PyQt4.QtCore import QThread
from PyQt4.QtGui import QImage from PyQt4.QtGui import QImage
...@@ -12,6 +10,9 @@ from libc.stdlib cimport calloc, malloc, free ...@@ -12,6 +10,9 @@ from libc.stdlib cimport calloc, malloc, free
from libc.string cimport memcpy, strlen from libc.string cimport memcpy, strlen
__all__ = ['RFBClient', 'RFBClientError']
# external declarations # external declarations
# #
......
__all__ = ['VNCClient', 'RFBSettings', 'ServerDefault', 'TrueColor', 'HighColor', 'LowColor']
from PyQt4.QtCore import QObject, QSize, QSocketNotifier, QThread, pyqtSignal from PyQt4.QtCore import QObject, QSize, QSocketNotifier, QThread, pyqtSignal
from PyQt4.QtGui import QApplication from PyQt4.QtGui import QApplication
...@@ -13,6 +10,9 @@ from blink.event import EventBase ...@@ -13,6 +10,9 @@ from blink.event import EventBase
from blink.screensharing._rfb import RFBClient, RFBClientError from blink.screensharing._rfb import RFBClient, RFBClientError
__all__ = ['VNCClient', 'RFBSettings', 'ServerDefault', 'TrueColor', 'HighColor', 'LowColor']
class RFBSettings(object): class RFBSettings(object):
depth = WriteOnceAttribute() depth = WriteOnceAttribute()
quality = WriteOnceAttribute() quality = WriteOnceAttribute()
...@@ -101,6 +101,7 @@ class VNCClient(QObject): ...@@ -101,6 +101,7 @@ class VNCClient(QObject):
def _get_settings(self): def _get_settings(self):
return self.__dict__['settings'] return self.__dict__['settings']
def _set_settings(self, settings): def _set_settings(self, settings):
old_settings = self.__dict__.get('settings', None) old_settings = self.__dict__.get('settings', None)
if settings == old_settings: if settings == old_settings:
...@@ -108,6 +109,7 @@ class VNCClient(QObject): ...@@ -108,6 +109,7 @@ class VNCClient(QObject):
self.__dict__['settings'] = settings self.__dict__['settings'] = settings
if self.thread.isRunning(): if self.thread.isRunning():
QApplication.postEvent(self, RFBConfigureClientEvent()) QApplication.postEvent(self, RFBConfigureClientEvent())
settings = property(_get_settings, _set_settings) settings = property(_get_settings, _set_settings)
del _get_settings, _set_settings del _get_settings, _set_settings
......
from __future__ import division from __future__ import division
__all__ = ['ScreensharingWindow', 'VNCViewer']
import os import os
import platform import platform
...@@ -28,6 +24,9 @@ from blink.resources import Resources ...@@ -28,6 +24,9 @@ from blink.resources import Resources
from blink.screensharing.vncclient import ServerDefault, TrueColor, HighColor, LowColor from blink.screensharing.vncclient import ServerDefault, TrueColor, HighColor, LowColor
__all__ = ['ScreensharingWindow', 'VNCViewer']
class ButtonMaskMapper(dict): class ButtonMaskMapper(dict):
class qt: class qt:
NoButton = Qt.NoButton NoButton = Qt.NoButton
...@@ -47,7 +46,7 @@ class ButtonMaskMapper(dict): ...@@ -47,7 +46,7 @@ class ButtonMaskMapper(dict):
def __init__(self): def __init__(self):
mapping = {self.qt.NoButton: self.vnc.NoButton, self.qt.LeftButton: self.vnc.LeftButton, self.qt.MidButton: self.vnc.MidButton, self.qt.RightButton: self.vnc.RightButton} mapping = {self.qt.NoButton: self.vnc.NoButton, self.qt.LeftButton: self.vnc.LeftButton, self.qt.MidButton: self.vnc.MidButton, self.qt.RightButton: self.vnc.RightButton}
super(ButtonMaskMapper, self).__init__({int(b1|b2|b3): mapping[b1]|mapping[b2]|mapping[b3] for b1 in mapping for b2 in mapping for b3 in mapping}) super(ButtonMaskMapper, self).__init__({int(b1 | b2 | b3): mapping[b1] | mapping[b2] | mapping[b3] for b1 in mapping for b2 in mapping for b3 in mapping})
self._button_mask = int(self.qt.LeftButton|self.qt.MidButton|self.qt.RightButton) self._button_mask = int(self.qt.LeftButton|self.qt.MidButton|self.qt.RightButton)
def __getitem__(self, key): def __getitem__(self, key):
...@@ -172,14 +171,14 @@ class VNCViewer(QWidget): ...@@ -172,14 +171,14 @@ class VNCViewer(QWidget):
super(VNCViewer, self).__init__(parent) super(VNCViewer, self).__init__(parent)
self.setMouseTracking(True) self.setMouseTracking(True)
self.setFocusPolicy(Qt.WheelFocus) self.setFocusPolicy(Qt.WheelFocus)
#self.setCursor(Qt.BlankCursor) # self.setCursor(Qt.BlankCursor)
self.client = vncclient or parent.client self.client = vncclient or parent.client
self.client.started.connect(self._SH_ClientStarted) self.client.started.connect(self._SH_ClientStarted)
self.client.finished.connect(self._SH_ClientFinished) self.client.finished.connect(self._SH_ClientFinished)
self.client.imageSizeChanged.connect(self._SH_ImageSizeChanged) self.client.imageSizeChanged.connect(self._SH_ImageSizeChanged)
self.client.imageChanged.connect(self._SH_ImageUpdated) self.client.imageChanged.connect(self._SH_ImageUpdated)
self.client.passwordRequested.connect(self._SH_PasswordRequested, Qt.BlockingQueuedConnection) self.client.passwordRequested.connect(self._SH_PasswordRequested, Qt.BlockingQueuedConnection)
self.colors_8bit = [qRgb((i&0x07) << 5, (i&0x38) << 2, i&0xc0) for i in range(256)] self.colors_8bit = [qRgb((i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0) for i in range(256)]
self.scale = False self.scale = False
self.view_only = False self.view_only = False
self._client_active = False self._client_active = False
...@@ -188,6 +187,7 @@ class VNCViewer(QWidget): ...@@ -188,6 +187,7 @@ class VNCViewer(QWidget):
def _get_scale(self): def _get_scale(self):
return self.__dict__['scale'] return self.__dict__['scale']
def _set_scale(self, scale): def _set_scale(self, scale):
self.__dict__['scale'] = scale self.__dict__['scale'] = scale
if not scale: if not scale:
...@@ -197,11 +197,13 @@ class VNCViewer(QWidget): ...@@ -197,11 +197,13 @@ class VNCViewer(QWidget):
elif self.parent() is not None: elif self.parent() is not None:
self.resize(self.parent().size()) self.resize(self.parent().size())
self.update() self.update()
scale = property(_get_scale, _set_scale) scale = property(_get_scale, _set_scale)
del _get_scale, _set_scale del _get_scale, _set_scale
def _get_view_only(self): def _get_view_only(self):
return self.__dict__['view_only'] return self.__dict__['view_only']
def _set_view_only(self, view_only): def _set_view_only(self, view_only):
old_value = self.__dict__.get('view_only', None) old_value = self.__dict__.get('view_only', None)
new_value = self.__dict__['view_only'] = view_only new_value = self.__dict__['view_only'] = view_only
...@@ -211,6 +213,7 @@ class VNCViewer(QWidget): ...@@ -211,6 +213,7 @@ class VNCViewer(QWidget):
self.grabKeyboard() self.grabKeyboard()
else: else:
self.releaseKeyboard() self.releaseKeyboard()
view_only = property(_get_view_only, _set_view_only) view_only = property(_get_view_only, _set_view_only)
del _get_view_only, _set_view_only del _get_view_only, _set_view_only
...@@ -307,15 +310,15 @@ class VNCViewer(QWidget): ...@@ -307,15 +310,15 @@ class VNCViewer(QWidget):
button_mask = self.button_mask_map[event.buttons()] button_mask = self.button_mask_map[event.buttons()]
if event.type() == QEvent.Wheel: if event.type() == QEvent.Wheel:
if event.delta() > 0: if event.delta() > 0:
wheel_button_mask = self.button_mask_map.vnc.WheelUp if event.orientation()==Qt.Vertical else self.button_mask_map.vnc.WheelLeft wheel_button_mask = self.button_mask_map.vnc.WheelUp if event.orientation() == Qt.Vertical else self.button_mask_map.vnc.WheelLeft
else: else:
wheel_button_mask = self.button_mask_map.vnc.WheelDown if event.orientation()==Qt.Vertical else self.button_mask_map.vnc.WheelRight wheel_button_mask = self.button_mask_map.vnc.WheelDown if event.orientation() == Qt.Vertical else self.button_mask_map.vnc.WheelRight
self.client.mouse_event(x, y, button_mask | wheel_button_mask) self.client.mouse_event(x, y, button_mask | wheel_button_mask)
self.client.mouse_event(x, y, button_mask) self.client.mouse_event(x, y, button_mask)
def keyEvent(self, event): def keyEvent(self, event):
vnc_key = VNCKey.from_event(event) vnc_key = VNCKey.from_event(event)
key_down = event.type()==QEvent.KeyPress key_down = event.type() == QEvent.KeyPress
if vnc_key: if vnc_key:
expected_modifiers = self._active_keys.modifiers expected_modifiers = self._active_keys.modifiers
keyboard_modifiers = event.modifiers() keyboard_modifiers = event.modifiers()
...@@ -376,6 +379,7 @@ class VNCViewer(QWidget): ...@@ -376,6 +379,7 @@ class VNCViewer(QWidget):
ui_class, base_class = uic.loadUiType(Resources.get('screensharing_dialog.ui')) ui_class, base_class = uic.loadUiType(Resources.get('screensharing_dialog.ui'))
class ScreensharingDialog(base_class, ui_class): class ScreensharingDialog(base_class, ui_class):
def __init__(self, parent=None): def __init__(self, parent=None):
super(ScreensharingDialog, self).__init__(parent) super(ScreensharingDialog, self).__init__(parent)
...@@ -399,7 +403,7 @@ class ScreensharingDialog(base_class, ui_class): ...@@ -399,7 +403,7 @@ class ScreensharingDialog(base_class, ui_class):
self.setMinimumHeight(190) self.setMinimumHeight(190)
self.resize(self.minimumSize()) self.resize(self.minimumSize())
result = self.exec_() result = self.exec_()
return (self.username_editor.text(), self.password_editor.text()) if result==self.Accepted else (None, None) return (self.username_editor.text(), self.password_editor.text()) if result == self.Accepted else (None, None)
def get_password(self): def get_password(self):
self.message_label.setText(u'Screen sharing requires a password') self.message_label.setText(u'Screen sharing requires a password')
...@@ -411,13 +415,14 @@ class ScreensharingDialog(base_class, ui_class): ...@@ -411,13 +415,14 @@ class ScreensharingDialog(base_class, ui_class):
self.setMinimumHeight(165) self.setMinimumHeight(165)
self.resize(self.minimumSize()) self.resize(self.minimumSize())
result = self.exec_() result = self.exec_()
return self.password_editor.text() if result==self.Accepted else None return self.password_editor.text() if result == self.Accepted else None
del ui_class, base_class del ui_class, base_class
ui_class, base_class = uic.loadUiType(Resources.get('screensharing_toolbox.ui')) ui_class, base_class = uic.loadUiType(Resources.get('screensharing_toolbox.ui'))
class ScreensharingToolbox(base_class, ui_class): class ScreensharingToolbox(base_class, ui_class):
exposedPixels = 3 exposedPixels = 3
...@@ -530,6 +535,7 @@ del ui_class, base_class ...@@ -530,6 +535,7 @@ del ui_class, base_class
ui_class, base_class = uic.loadUiType(Resources.get('screensharing_window.ui')) ui_class, base_class = uic.loadUiType(Resources.get('screensharing_window.ui'))
class ScreensharingWindow(base_class, ui_class): class ScreensharingWindow(base_class, ui_class):
def __init__(self, vncclient, parent=None): def __init__(self, vncclient, parent=None):
super(ScreensharingWindow, self).__init__(parent) super(ScreensharingWindow, self).__init__(parent)
......
This diff is collapsed.
__all__ = ['IUpdateManager', 'UpdateManager']
import sys import sys
from application.python import Null from application.python import Null
from zope.interface import Interface from zope.interface import Interface
__all__ = ['IUpdateManager', 'UpdateManager']
class IUpdateManager(Interface): class IUpdateManager(Interface):
def initialize(self): def initialize(self):
pass pass
def shutdown(self): def shutdown(self):
pass pass
def check_for_updates(self): def check_for_updates(self):
pass pass
...@@ -23,4 +26,3 @@ if sys.platform == 'win32': ...@@ -23,4 +26,3 @@ if sys.platform == 'win32':
UpdateManager = Null UpdateManager = Null
else: else:
UpdateManager = Null UpdateManager = Null
...@@ -19,14 +19,13 @@ def library_locations(name): ...@@ -19,14 +19,13 @@ def library_locations(name):
for path in additional_paths: for path in additional_paths:
yield os.path.join(path, library_name) yield os.path.join(path, library_name)
def load_library(name): def load_library(name):
for library in library_locations(name): for library in library_locations(name):
try: try:
return CDLL(library) return CDLL(library)
except OSError: except OSError:
pass pass
else:
break
else: else:
raise RuntimeError('cannot find %s on this system' % name) raise RuntimeError('cannot find %s on this system' % name)
......
__all__ = ['QSingleton', 'call_in_gui_thread', 'call_later', 'run_in_gui_thread']
from PyQt4.QtCore import QObject, QThread, QTimer from PyQt4.QtCore import QObject, QThread, QTimer
from PyQt4.QtGui import QApplication from PyQt4.QtGui import QApplication
from application.python.decorator import decorator, preserve_signature from application.python.decorator import decorator, preserve_signature
...@@ -9,6 +7,9 @@ from application.python.types import Singleton ...@@ -9,6 +7,9 @@ from application.python.types import Singleton
from blink.event import CallFunctionEvent from blink.event import CallFunctionEvent
__all__ = ['QSingleton', 'call_in_gui_thread', 'call_later', 'run_in_gui_thread']
class QSingleton(Singleton, type(QObject)): class QSingleton(Singleton, type(QObject)):
"""A metaclass for making Qt objects singletons""" """A metaclass for making Qt objects singletons"""
......
__all__ = ['ToolButton', 'ConferenceButton', 'StreamButton', 'SegmentButton', 'SingleSegment', 'LeftSegment', 'MiddleSegment', 'RightSegment', 'RecordButton', 'SwitchViewButton',
'StateButton', 'AccountState']
from PyQt4.QtCore import Qt, QLineF, QPointF, QRectF, QSize, QTimer, pyqtSignal, pyqtSignature from PyQt4.QtCore import Qt, QLineF, QPointF, QRectF, QSize, QTimer, pyqtSignal, pyqtSignature
from PyQt4.QtGui import QAction, QBrush, QColor, QCommonStyle, QLinearGradient, QIcon, QMenu, QPainter, QPainterPath, QPalette, QPen, QPixmap from PyQt4.QtGui import QAction, QBrush, QColor, QCommonStyle, QLinearGradient, QIcon, QMenu, QPainter, QPainterPath, QPalette, QPen, QPixmap
from PyQt4.QtGui import QPolygonF, QPushButton, QStyle, QStyleOptionToolButton, QStylePainter, QToolButton from PyQt4.QtGui import QPolygonF, QPushButton, QStyle, QStyleOptionToolButton, QStylePainter, QToolButton
...@@ -10,8 +7,13 @@ from blink.resources import Resources ...@@ -10,8 +7,13 @@ from blink.resources import Resources
from blink.widgets.color import ColorScheme, ColorUtils, ColorHelperMixin from blink.widgets.color import ColorScheme, ColorUtils, ColorHelperMixin
__all__ = ['ToolButton', 'ConferenceButton', 'StreamButton', 'SegmentButton', 'SingleSegment', 'LeftSegment', 'MiddleSegment', 'RightSegment',
'RecordButton', 'SwitchViewButton', 'StateButton', 'AccountState']
class ToolButton(QToolButton): class ToolButton(QToolButton):
"""A custom QToolButton that doesn't show a menu indicator arrow""" """A custom QToolButton that doesn't show a menu indicator arrow"""
def paintEvent(self, event): def paintEvent(self, event):
painter = QStylePainter(self) painter = QStylePainter(self)
option = QStyleOptionToolButton() option = QStyleOptionToolButton()
...@@ -102,10 +104,12 @@ class SegmentTypeMeta(type): ...@@ -102,10 +104,12 @@ class SegmentTypeMeta(type):
def __repr__(cls): def __repr__(cls):
return cls.__name__ return cls.__name__
class SegmentType(object): class SegmentType(object):
__metaclass__ = SegmentTypeMeta __metaclass__ = SegmentTypeMeta
style_sheet = '' style_sheet = ''
class SingleSegment(SegmentType): class SingleSegment(SegmentType):
style_sheet = """ style_sheet = """
QToolButton { QToolButton {
...@@ -122,6 +126,7 @@ class SingleSegment(SegmentType): ...@@ -122,6 +126,7 @@ class SingleSegment(SegmentType):
} }
""" """
class LeftSegment(SegmentType): class LeftSegment(SegmentType):
style_sheet = """ style_sheet = """
QToolButton { QToolButton {
...@@ -139,6 +144,7 @@ class LeftSegment(SegmentType): ...@@ -139,6 +144,7 @@ class LeftSegment(SegmentType):
} }
""" """
class MiddleSegment(SegmentType): class MiddleSegment(SegmentType):
style_sheet = """ style_sheet = """
QToolButton { QToolButton {
...@@ -155,6 +161,7 @@ class MiddleSegment(SegmentType): ...@@ -155,6 +161,7 @@ class MiddleSegment(SegmentType):
} }
""" """
class RightSegment(SegmentType): class RightSegment(SegmentType):
style_sheet = """ style_sheet = """
QToolButton { QToolButton {
...@@ -387,7 +394,7 @@ class StateButtonStyle(QCommonStyle, ColorHelperMixin): ...@@ -387,7 +394,7 @@ class StateButtonStyle(QCommonStyle, ColorHelperMixin):
return super(StateButtonStyle, self).sizeFromContents(element, option, size, widget) return super(StateButtonStyle, self).sizeFromContents(element, option, size, widget)
def toolButtonSizeFromContents(self, option, size, widget): def toolButtonSizeFromContents(self, option, size, widget):
# Make width >= height to avoid super-skiny buttons # Make width >= height to avoid super-skinny buttons
margin = 2 * (self._pixel_metrics[QStyle.PM_DefaultFrameWidth] + self._pixel_metrics[QStyle.PM_ButtonMargin]) margin = 2 * (self._pixel_metrics[QStyle.PM_DefaultFrameWidth] + self._pixel_metrics[QStyle.PM_ButtonMargin])
if option.features & QStyleOptionToolButton.MenuButtonPopup: if option.features & QStyleOptionToolButton.MenuButtonPopup:
margin_size = QSize(margin+1, margin) margin_size = QSize(margin+1, margin)
...@@ -450,7 +457,7 @@ class StateButtonStyle(QCommonStyle, ColorHelperMixin): ...@@ -450,7 +457,7 @@ class StateButtonStyle(QCommonStyle, ColorHelperMixin):
else: else:
blend.setColorAt(0.0, Qt.transparent) # or @0.5 blend.setColorAt(0.0, Qt.transparent) # or @0.5
blend.setColorAt(0.9, self.color_with_alpha(shadow_color, 0x10)) blend.setColorAt(0.9, self.color_with_alpha(shadow_color, 0x10))
#blend.setColorAt(1-4.0/glow_rect.height(), self.color_with_alpha(shadow_color, 0x10)) # this is for exactly 4 pixels from bottom # blend.setColorAt(1-4.0/glow_rect.height(), self.color_with_alpha(shadow_color, 0x10)) # this is for exactly 4 pixels from bottom
blend.setColorAt(1.0, self.color_with_alpha(shadow_color, 0x30)) # 0x25, 0x30 or 0x35 blend.setColorAt(1.0, self.color_with_alpha(shadow_color, 0x30)) # 0x25, 0x30 or 0x35
painter.setBrush(blend) painter.setBrush(blend)
painter.drawRoundedRect(glow_rect, 5, 5) # 5 or 6 painter.drawRoundedRect(glow_rect, 5, 5) # 5 or 6
...@@ -685,6 +692,7 @@ class AccountState(StateButton): ...@@ -685,6 +692,7 @@ class AccountState(StateButton):
def _get_history(self): def _get_history(self):
return [(action.state.name, action.note) for action in self.menu().actions()[5:]] return [(action.state.name, action.note) for action in self.menu().actions()[5:]]
def _set_history(self, values): def _set_history(self, values):
menu = self.menu() menu = self.menu()
for action in menu.actions()[5:]: for action in menu.actions()[5:]:
...@@ -698,6 +706,7 @@ class AccountState(StateButton): ...@@ -698,6 +706,7 @@ class AccountState(StateButton):
action.state = state action.state = state
action.note = note action.note = note
menu.addAction(action) menu.addAction(action)
history = property(_get_history, _set_history) history = property(_get_history, _set_history)
del _get_history, _set_history del _get_history, _set_history
......
__all__ = ['ColorScheme', 'ColorUtils', 'ColorHelperMixin']
from PyQt4.QtCore import Qt from PyQt4.QtCore import Qt
from PyQt4.QtGui import QColor from PyQt4.QtGui import QColor
from application.python import limit from application.python import limit
...@@ -8,8 +6,11 @@ from application.python.decorator import decorator, preserve_signature ...@@ -8,8 +6,11 @@ from application.python.decorator import decorator, preserve_signature
from math import fmod, isnan from math import fmod, isnan
__all__ = ['ColorScheme', 'ColorUtils', 'ColorHelperMixin']
class HCYColor(object): class HCYColor(object):
"""Hue/chroma/luma colorspace""" """Hue/chroma/luma color space"""
luma_r = 0.2126 luma_r = 0.2126
luma_g = 0.7152 luma_g = 0.7152
...@@ -202,9 +203,11 @@ class ColorUtils(object): ...@@ -202,9 +203,11 @@ class ColorUtils(object):
def color_key(instance, color): def color_key(instance, color):
return color.rgba() return color.rgba()
def color_ratio_key(instance, color, ratio): def color_ratio_key(instance, color, ratio):
return color.rgba() << 32 | int(ratio*512) return color.rgba() << 32 | int(ratio*512)
def background_color_key(instance, background, color): def background_color_key(instance, background, color):
return background.rgba() << 32 | color.rgba() return background.rgba() << 32 | color.rgba()
......
__all__ = ['SlidingStackedWidget']
from PyQt4.QtCore import QEasingCurve, QParallelAnimationGroup, QPropertyAnimation, QPoint, pyqtSignal from PyQt4.QtCore import QEasingCurve, QParallelAnimationGroup, QPropertyAnimation, QPoint, pyqtSignal
from PyQt4.QtGui import QStackedWidget from PyQt4.QtGui import QStackedWidget
from blink.widgets.util import QtDynamicProperty from blink.widgets.util import QtDynamicProperty
__all__ = ['SlidingStackedWidget']
class SlidingStackedWidget(QStackedWidget): class SlidingStackedWidget(QStackedWidget):
animationEasingCurve = QtDynamicProperty('animationEasingCurve', int) animationEasingCurve = QtDynamicProperty('animationEasingCurve', int)
animationDuration = QtDynamicProperty('animationDuration', int) animationDuration = QtDynamicProperty('animationDuration', int)
...@@ -65,9 +66,9 @@ class SlidingStackedWidget(QStackedWidget): ...@@ -65,9 +66,9 @@ class SlidingStackedWidget(QStackedWidget):
next_widget.setGeometry(0, 0, width, height) next_widget.setGeometry(0, 0, width, height)
if direction in (self.TopToBottom, self.BottomToTop): if direction in (self.TopToBottom, self.BottomToTop):
offset = QPoint(0, height if direction==self.TopToBottom else -height) offset = QPoint(0, height if direction == self.TopToBottom else -height)
elif direction in (self.LeftToRight, self.RightToLeft): elif direction in (self.LeftToRight, self.RightToLeft):
offset = QPoint(width if direction==self.LeftToRight else -width, 0) offset = QPoint(width if direction == self.LeftToRight else -width, 0)
# re-position the next widget outside of the display area # re-position the next widget outside of the display area
prev_widget_position = prev_widget.pos() prev_widget_position = prev_widget.pos()
...@@ -101,7 +102,7 @@ class SlidingStackedWidget(QStackedWidget): ...@@ -101,7 +102,7 @@ class SlidingStackedWidget(QStackedWidget):
next_widget = next_widget_animation.targetObject() next_widget = next_widget_animation.targetObject()
self.setCurrentWidget(next_widget) self.setCurrentWidget(next_widget)
prev_widget.hide() # this may have been done already by QStackedWidget when changing the current widget above -Dan prev_widget.hide() # this may have been done already by QStackedWidget when changing the current widget above -Dan
prev_widget.move(prev_widget_animation.startValue()) # move the outshifted widget back to its original position prev_widget.move(prev_widget_animation.startValue()) # move the out-shifted widget back to its original position
self._animation_group.clear() self._animation_group.clear()
self._active = False self._active = False
self.animationFinished.emit() self.animationFinished.emit()
......
__all__ = ['BackgroundFrame']
from PyQt4.QtCore import Qt, QEvent, QPoint, QRect, QSize from PyQt4.QtCore import Qt, QEvent, QPoint, QRect, QSize
from PyQt4.QtGui import QColor, QFrame, QPainter, QPixmap from PyQt4.QtGui import QColor, QFrame, QPainter, QPixmap
...@@ -8,6 +6,9 @@ from blink.resources import Resources ...@@ -8,6 +6,9 @@ from blink.resources import Resources
from blink.widgets.util import QtDynamicProperty from blink.widgets.util import QtDynamicProperty
__all__ = ['BackgroundFrame']
class BackgroundFrame(QFrame): class BackgroundFrame(QFrame):
backgroundColor = QtDynamicProperty('backgroundColor', unicode) backgroundColor = QtDynamicProperty('backgroundColor', unicode)
backgroundImage = QtDynamicProperty('backgroundImage', unicode) backgroundImage = QtDynamicProperty('backgroundImage', unicode)
...@@ -70,4 +71,3 @@ class BackgroundFrame(QFrame): ...@@ -70,4 +71,3 @@ class BackgroundFrame(QFrame):
painter.drawPixmap(self.image_position, self.scaled_pixmap) painter.drawPixmap(self.image_position, self.scaled_pixmap)
painter.end() painter.end()
__all__ = ['Graph', 'GraphWidget', 'HeightScaler', 'LogarithmicScaler', 'MaxScaler', 'SoftScaler']
from PyQt4.QtCore import Qt, QLine, QPointF, QMetaObject, pyqtSignal from PyQt4.QtCore import Qt, QLine, QPointF, QMetaObject, pyqtSignal
from PyQt4.QtGui import QColor, QLinearGradient, QPainterPath, QPen, QPolygonF, QStyle, QStyleOption, QStylePainter, QWidget from PyQt4.QtGui import QColor, QLinearGradient, QPainterPath, QPen, QPolygonF, QStyle, QStyleOption, QStylePainter, QWidget
...@@ -14,6 +12,9 @@ from blink.widgets.color import ColorHelperMixin ...@@ -14,6 +12,9 @@ from blink.widgets.color import ColorHelperMixin
from blink.widgets.util import QtDynamicProperty from blink.widgets.util import QtDynamicProperty
__all__ = ['Graph', 'GraphWidget', 'HeightScaler', 'LogarithmicScaler', 'MaxScaler', 'SoftScaler']
class HeightScaler(object): class HeightScaler(object):
__metaclass__ = ABCMeta __metaclass__ = ABCMeta
...@@ -196,13 +197,13 @@ class GraphWidget(QWidget, ColorHelperMixin): ...@@ -196,13 +197,13 @@ class GraphWidget(QWidget, ColorHelperMixin):
cx_offset = self.horizontalPixelsPerUnit / 3.0 cx_offset = self.horizontalPixelsPerUnit / 3.0
smoothness = self.smoothFactor smoothness = self.smoothFactor
last_values = deque(3*[dataset.next() * height_scaling], maxlen=3) # last 3 values: 0 last, 1 previous, 2 previous previous last_values = deque(3*[next(dataset) * height_scaling], maxlen=3) # last 3 values: 0 last, 1 previous, 2 previous previous
envelope = QPainterPath() envelope = QPainterPath()
envelope.moveTo(0, last_values[0]) envelope.moveTo(0, last_values[0])
for x, y in enumerate(dataset, 1): for x, y in enumerate(dataset, 1):
x = x * self.horizontalPixelsPerUnit x *= self.horizontalPixelsPerUnit
y = y * height_scaling * (1 - smoothness) + last_values[0] * smoothness y *= height_scaling * (1 - smoothness) + last_values[0] * smoothness
last_values.appendleft(y) last_values.appendleft(y)
c1x = x - cx_offset * 2 c1x = x - cx_offset * 2
c2x = x - cx_offset c2x = x - cx_offset
...@@ -236,7 +237,7 @@ class GraphWidget(QWidget, ColorHelperMixin): ...@@ -236,7 +237,7 @@ class GraphWidget(QWidget, ColorHelperMixin):
painter.restore() painter.restore()
# queue the 'updated' signal to be emited after returning to the main loop # queue the 'updated' signal to be emitted after returning to the main loop
QMetaObject.invokeMethod(self, 'updated', Qt.QueuedConnection) QMetaObject.invokeMethod(self, 'updated', Qt.QueuedConnection)
def add_graph(self, graph): def add_graph(self, graph):
...@@ -254,4 +255,3 @@ class GraphWidget(QWidget, ColorHelperMixin): ...@@ -254,4 +255,3 @@ class GraphWidget(QWidget, ColorHelperMixin):
self.graphs = [] self.graphs = []
self.update() self.update()
__all__ = ['DurationLabel', 'IconSelector', 'LatencyLabel', 'PacketLossLabel', 'Status', 'StatusLabel', 'StreamInfoLabel', 'ElidedLabel', 'ContactState']
import os import os
from datetime import timedelta from datetime import timedelta
...@@ -16,6 +14,9 @@ from blink.widgets.color import ColorHelperMixin ...@@ -16,6 +14,9 @@ from blink.widgets.color import ColorHelperMixin
from blink.widgets.util import QtDynamicProperty, ContextMenuActions from blink.widgets.util import QtDynamicProperty, ContextMenuActions
__all__ = ['DurationLabel', 'IconSelector', 'LatencyLabel', 'PacketLossLabel', 'Status', 'StatusLabel', 'StreamInfoLabel', 'ElidedLabel', 'ContactState']
class IconSelector(QLabel): class IconSelector(QLabel):
default_icon = QtDynamicProperty('default_icon', QIcon) default_icon = QtDynamicProperty('default_icon', QIcon)
icon_size = QtDynamicProperty('icon_size', int) icon_size = QtDynamicProperty('icon_size', int)
...@@ -283,6 +284,7 @@ class StateColor(QColor): ...@@ -283,6 +284,7 @@ class StateColor(QColor):
def stroke(self): def stroke(self):
return self.darker(200) return self.darker(200)
class StateColorMapping(dict): class StateColorMapping(dict):
def __missing__(self, key): def __missing__(self, key):
if key == 'offline': if key == 'offline':
...@@ -294,7 +296,7 @@ class StateColorMapping(dict): ...@@ -294,7 +296,7 @@ class StateColorMapping(dict):
elif key == 'busy': elif key == 'busy':
return self.setdefault(key, StateColor('#ff0000')) return self.setdefault(key, StateColor('#ff0000'))
else: else:
return StateColor(Qt.transparent) #StateColor('#d0d0d0') return StateColor(Qt.transparent) # StateColor('#d0d0d0')
class ContactState(QLabel, ColorHelperMixin): class ContactState(QLabel, ColorHelperMixin):
...@@ -323,4 +325,3 @@ class ContactState(QLabel, ColorHelperMixin): ...@@ -323,4 +325,3 @@ class ContactState(QLabel, ColorHelperMixin):
painter.setPen(QPen(QBrush(gradient), 1)) painter.setPen(QPen(QBrush(gradient), 1))
painter.drawRoundedRect(-4, 0, self.width()+4, self.height(), 3.7, 3.7) painter.drawRoundedRect(-4, 0, self.width()+4, self.height(), 3.7, 3.7)
__all__ = ['LineEdit', 'ValidatingLineEdit', 'SearchBox', 'LocationBar']
import re import re
from PyQt4.QtCore import Qt, QEvent, pyqtSignal from PyQt4.QtCore import Qt, QEvent, pyqtSignal
...@@ -10,6 +8,9 @@ from blink.resources import Resources ...@@ -10,6 +8,9 @@ from blink.resources import Resources
from blink.widgets.util import QtDynamicProperty from blink.widgets.util import QtDynamicProperty
__all__ = ['LineEdit', 'ValidatingLineEdit', 'SearchBox', 'LocationBar']
class SideWidget(QWidget): class SideWidget(QWidget):
sizeHintChanged = pyqtSignal() sizeHintChanged = pyqtSignal()
...@@ -307,4 +308,3 @@ class LocationBar(LineEdit): ...@@ -307,4 +308,3 @@ class LocationBar(LineEdit):
def _SH_TextChanged(self, text): def _SH_TextChanged(self, text):
self.clear_button.setVisible(bool(text)) self.clear_button.setVisible(bool(text))
__all__ = ['QtDynamicProperty', 'ContextMenuActions']
from PyQt4.QtCore import QPyNullVariant from PyQt4.QtCore import QPyNullVariant
__all__ = ['QtDynamicProperty', 'ContextMenuActions']
class QtDynamicProperty(object): class QtDynamicProperty(object):
def __init__(self, name, type=unicode): def __init__(self, name, type=unicode):
self.name = name self.name = name
self.type = type self.type = type
def __get__(self, obj, objtype):
if obj is None: def __get__(self, instance, owner):
if instance is None:
return self return self
value = obj.property(self.name) value = instance.property(self.name)
if isinstance(value, QPyNullVariant): if isinstance(value, QPyNullVariant):
value = self.type() value = self.type()
return value return value
def __set__(self, obj, value): def __set__(self, obj, value):
if value is not None and not isinstance(value, self.type): if value is not None and not isinstance(value, self.type):
value = self.type(value) value = self.type(value)
obj.setProperty(self.name, value) obj.setProperty(self.name, value)
def __delete__(self, obj): def __delete__(self, obj):
raise AttributeError("attribute cannot be deleted") raise AttributeError("attribute cannot be deleted")
......
from __future__ import division from __future__ import division
__all__ = ['VideoSurface']
from PyQt4.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal from PyQt4.QtCore import Qt, QMetaObject, QPoint, QRect, QTimer, pyqtSignal
from PyQt4.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform, QWidget from PyQt4.QtGui import QColor, QCursor, QIcon, QImage, QPainter, QPixmap, QTransform, QWidget
...@@ -16,7 +12,11 @@ from sipsimple.core import FrameBufferVideoRenderer ...@@ -16,7 +12,11 @@ from sipsimple.core import FrameBufferVideoRenderer
from blink.resources import Resources from blink.resources import Resources
class Container(object): pass __all__ = ['VideoSurface']
class Container(object):
pass
class InteractionState(object): class InteractionState(object):
...@@ -197,13 +197,13 @@ class VideoSurface(QWidget): ...@@ -197,13 +197,13 @@ class VideoSurface(QWidget):
delta_x = -(self.width_for_height(geometry.height() - delta_y) - geometry.width()) delta_x = -(self.width_for_height(geometry.height() - delta_y) - geometry.width())
geometry.setTopLeft(geometry.topLeft() + QPoint(delta_x, delta_y)) geometry.setTopLeft(geometry.topLeft() + QPoint(delta_x, delta_y))
elif self._interaction.resize_corner is self.TopRightCorner: elif self._interaction.resize_corner is self.TopRightCorner:
delta_x = (self.width_for_height(geometry.height() - delta_y) - geometry.width()) delta_x = +(self.width_for_height(geometry.height() - delta_y) - geometry.width())
geometry.setTopRight(geometry.topRight() + QPoint(delta_x, delta_y)) geometry.setTopRight(geometry.topRight() + QPoint(delta_x, delta_y))
elif self._interaction.resize_corner is self.BottomLeftCorner: elif self._interaction.resize_corner is self.BottomLeftCorner:
delta_x = -(self.width_for_height(geometry.height() + delta_y) - geometry.width()) delta_x = -(self.width_for_height(geometry.height() + delta_y) - geometry.width())
geometry.setBottomLeft(geometry.bottomLeft() + QPoint(delta_x, delta_y)) geometry.setBottomLeft(geometry.bottomLeft() + QPoint(delta_x, delta_y))
else: else:
delta_x = (self.width_for_height(geometry.height() + delta_y) - geometry.width()) delta_x = +(self.width_for_height(geometry.height() + delta_y) - geometry.width())
geometry.setBottomRight(geometry.bottomRight() + QPoint(delta_x, delta_y)) geometry.setBottomRight(geometry.bottomRight() + QPoint(delta_x, delta_y))
if self.minimumHeight() <= geometry.height() <= self.maximumHeight() and (self.parent() is None or self.parent().rect().contains(geometry)): if self.minimumHeight() <= geometry.height() <= self.maximumHeight() and (self.parent() is None or self.parent().rect().contains(geometry)):
...@@ -224,4 +224,3 @@ class VideoSurface(QWidget): ...@@ -224,4 +224,3 @@ class VideoSurface(QWidget):
super(VideoSurface, self).closeEvent(event) super(VideoSurface, self).closeEvent(event)
self.stop() self.stop()
__all__ = ['ZRTPWidget']
from PyQt4 import uic from PyQt4 import uic
from PyQt4.QtCore import Qt, pyqtSignal from PyQt4.QtCore import Qt, pyqtSignal
from PyQt4.QtGui import QStyle, QStyleOption, QStylePainter from PyQt4.QtGui import QStyle, QStyleOption, QStylePainter
...@@ -9,8 +6,12 @@ from PyQt4.QtGui import QStyle, QStyleOption, QStylePainter ...@@ -9,8 +6,12 @@ from PyQt4.QtGui import QStyle, QStyleOption, QStylePainter
from blink.resources import Resources from blink.resources import Resources
__all__ = ['ZRTPWidget']
ui_class, base_class = uic.loadUiType(Resources.get('zrtp_widget.ui')) ui_class, base_class = uic.loadUiType(Resources.get('zrtp_widget.ui'))
class ZRTPWidget(base_class, ui_class): class ZRTPWidget(base_class, ui_class):
closed = pyqtSignal() closed = pyqtSignal()
nameChanged = pyqtSignal() nameChanged = pyqtSignal()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment