Commit 67291fd4 authored by Dan Pascu's avatar Dan Pascu

Added default user icon descriptor on ChatWidget

parent e4b32d23
...@@ -453,9 +453,26 @@ class ChatTextInput(QTextEdit): ...@@ -453,9 +453,26 @@ class ChatTextInput(QTextEdit):
self.setTextCursor(cursor) self.setTextCursor(cursor)
class IconDescriptor(object):
def __init__(self, filename):
self.filename = filename
self.icon = None
def __get__(self, obj, objtype):
if self.icon is None:
self.icon = QIcon(self.filename)
self.icon.filename = self.filename
return self.icon
def __set__(self, obj, value):
raise AttributeError("attribute cannot be set")
def __delete__(self, obj):
raise AttributeError("attribute cannot be deleted")
ui_class, base_class = uic.loadUiType(Resources.get('chat_widget.ui')) ui_class, base_class = uic.loadUiType(Resources.get('chat_widget.ui'))
class ChatWidget(base_class, ui_class): class ChatWidget(base_class, ui_class):
default_user_icon = IconDescriptor(Resources.get('icons/default-avatar.png'))
def __init__(self, session, parent=None): def __init__(self, session, parent=None):
super(ChatWidget, self).__init__(parent) super(ChatWidget, self).__init__(parent)
with Resources.directory: with Resources.directory:
...@@ -585,7 +602,7 @@ class ChatWidget(base_class, ui_class): ...@@ -585,7 +602,7 @@ class ChatWidget(base_class, ui_class):
account = chat_stream.blink_session.account account = chat_stream.blink_session.account
display_name = account.display_name display_name = account.display_name
uri = account.id uri = account.id
icon = IconManager().get('avatar') or self.session.default_user_icon icon = IconManager().get('avatar') or self.default_user_icon
sender = ChatSender(display_name, uri, icon.filename) sender = ChatSender(display_name, uri, icon.filename)
self.add_message(ChatMessage(text, sender, 'outgoing')) self.add_message(ChatMessage(text, sender, 'outgoing'))
......
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