ui updates: messages #3, friend's avatars and aliases
This commit is contained in:
parent
f4ba65b79d
commit
fca6a926b4
@ -29,7 +29,8 @@ class MessageEdit(QtGui.QPlainTextEdit):
|
||||
print 'lines ', lines
|
||||
if self.document().blockCount() == 1:
|
||||
lines += 1
|
||||
self.setFixedHeight(max(lines * 15, 30))
|
||||
size = (lines - 1) * 18 + 12
|
||||
self.setFixedHeight(max(size, 30))
|
||||
self.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse | QtCore.Qt.LinksAccessibleByMouse)
|
||||
|
||||
|
||||
@ -40,18 +41,18 @@ class MessageItem(QtGui.QListWidget):
|
||||
def __init__(self, text, time, user='', message_type=TOX_MESSAGE_TYPE['NORMAL'], parent=None):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
self.name = QtGui.QLabel(self)
|
||||
self.name.setGeometry(QtCore.QRect(0, 0, 50, 25))
|
||||
self.name.setGeometry(QtCore.QRect(5, 0, 95, 30))
|
||||
self.name.setTextFormat(QtCore.Qt.PlainText)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(12)
|
||||
font.setPointSize(10)
|
||||
font.setBold(True)
|
||||
self.name.setFont(font)
|
||||
self.name.setObjectName("name")
|
||||
self.name.setText(user)
|
||||
|
||||
self.time = QtGui.QLabel(self)
|
||||
self.time.setGeometry(QtCore.QRect(450, 0, 50, 25))
|
||||
self.time.setGeometry(QtCore.QRect(parent.width() - 50, 0, 50, 25))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
@ -60,9 +61,10 @@ class MessageItem(QtGui.QListWidget):
|
||||
self.time.setObjectName("time")
|
||||
self.time.setText(time)
|
||||
|
||||
self.message = MessageEdit(text, parent.width() - 100, self)
|
||||
self.message.setGeometry(QtCore.QRect(50, 0, parent.width() - 100, self.message.height()))
|
||||
self.message = MessageEdit(text, parent.width() - 150, self)
|
||||
self.message.setGeometry(QtCore.QRect(100, 0, parent.width() - 150, self.message.height()))
|
||||
self.h = self.message.height()
|
||||
print 'self.h ', self.h
|
||||
self.setFixedHeight(self.getHeight())
|
||||
|
||||
self.message.setFrameShape(QtGui.QFrame.NoFrame)
|
||||
@ -89,11 +91,12 @@ class ContactItem(QtGui.QListWidget):
|
||||
"""
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
# self.setMinimumSize(QtCore.QSize(250, 50))
|
||||
# self.setMaximumSize(QtCore.QSize(250, 50))
|
||||
self.setBaseSize(QtCore.QSize(250, 50))
|
||||
self.setBaseSize(QtCore.QSize(250, 70))
|
||||
self.avatar_label = QtGui.QLabel(self)
|
||||
self.avatar_label.setGeometry(QtCore.QRect(3, 3, 64, 64))
|
||||
self.avatar_label.setScaledContents(True)
|
||||
self.name = QtGui.QLabel(self)
|
||||
self.name.setGeometry(QtCore.QRect(80, 10, 191, 25))
|
||||
self.name.setGeometry(QtCore.QRect(70, 10, 170, 25))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(12)
|
||||
@ -101,18 +104,16 @@ class ContactItem(QtGui.QListWidget):
|
||||
self.name.setFont(font)
|
||||
self.name.setObjectName("name")
|
||||
self.status_message = QtGui.QLabel(self)
|
||||
self.status_message.setGeometry(QtCore.QRect(80, 30, 191, 17))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
self.status_message.setGeometry(QtCore.QRect(70, 30, 180, 20))
|
||||
font.setPointSize(10)
|
||||
font.setBold(False)
|
||||
self.status_message.setFont(font)
|
||||
self.status_message.setObjectName("status_message")
|
||||
self.connection_status = StatusCircle(self)
|
||||
self.connection_status.setGeometry(QtCore.QRect(200, 5, 16, 16))
|
||||
self.connection_status.setMinimumSize(QtCore.QSize(32, 32))
|
||||
self.connection_status.setMaximumSize(QtCore.QSize(32, 32))
|
||||
self.connection_status.setBaseSize(QtCore.QSize(32, 32))
|
||||
self.connection_status.setGeometry(QtCore.QRect(218, 5, 32, 32))
|
||||
# self.connection_status.setMinimumSize(QtCore.QSize(32, 32))
|
||||
# self.connection_status.setMaximumSize(QtCore.QSize(32, 32))
|
||||
# self.connection_status.setBaseSize(QtCore.QSize(32, 32))
|
||||
self.connection_status.setObjectName("connection_status")
|
||||
|
||||
|
||||
@ -136,11 +137,11 @@ class StatusCircle(QtGui.QWidget):
|
||||
color = QtCore.Qt.transparent
|
||||
else:
|
||||
if self.data == TOX_USER_STATUS['NONE']:
|
||||
color = QtCore.Qt.darkGreen
|
||||
color = QtGui.QColor(50, 205, 50)
|
||||
elif self.data == TOX_USER_STATUS['AWAY']:
|
||||
color = QtCore.Qt.yellow
|
||||
color = QtGui.QColor(255, 200, 50)
|
||||
else: # self.data == TOX_USER_STATUS['BUSY']:
|
||||
color = QtCore.Qt.darkRed
|
||||
color = QtGui.QColor(255, 50, 0)
|
||||
|
||||
paint.setPen(color)
|
||||
center = QtCore.QPoint(k, k)
|
||||
@ -151,5 +152,5 @@ class StatusCircle(QtGui.QWidget):
|
||||
color = QtCore.Qt.darkRed
|
||||
paint.setBrush(QtCore.Qt.transparent)
|
||||
paint.setPen(color)
|
||||
paint.drawEllipse(center, rad_x + 5, rad_y + 5)
|
||||
paint.drawEllipse(center, rad_x + 3, rad_y + 3)
|
||||
paint.end()
|
||||
|
@ -140,7 +140,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
Form.name.setFont(font)
|
||||
Form.name.setObjectName("name")
|
||||
self.status_message = Form.status_message = QtGui.QLabel(Form)
|
||||
Form.status_message.setGeometry(QtCore.QRect(80, 60, 191, 17))
|
||||
Form.status_message.setGeometry(QtCore.QRect(80, 60, 190, 20))
|
||||
font.setPointSize(12)
|
||||
font.setBold(False)
|
||||
Form.status_message.setFont(font)
|
||||
@ -154,12 +154,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def setup_right_top(self, Form):
|
||||
Form.setObjectName("Form")
|
||||
Form.resize(495, 111)
|
||||
Form.resize(650, 300)
|
||||
self.account_avatar = QtGui.QLabel(Form)
|
||||
self.account_avatar.setGeometry(QtCore.QRect(10, 20, 64, 64))
|
||||
self.account_avatar.setScaledContents(True)
|
||||
self.account_name = QtGui.QLabel(Form)
|
||||
self.account_name.setGeometry(QtCore.QRect(100, 30, 300, 25))
|
||||
self.account_name.setGeometry(QtCore.QRect(100, 30, 400, 25))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
@ -167,13 +167,13 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.account_name.setFont(font)
|
||||
self.account_name.setObjectName("account_name")
|
||||
self.account_status = QtGui.QLabel(Form)
|
||||
self.account_status.setGeometry(QtCore.QRect(100, 50, 300, 25))
|
||||
self.account_status.setGeometry(QtCore.QRect(100, 50, 400, 25))
|
||||
font.setPointSize(12)
|
||||
font.setBold(False)
|
||||
self.account_status.setFont(font)
|
||||
self.account_status.setObjectName("account_status")
|
||||
self.callButton = QtGui.QPushButton(Form)
|
||||
self.callButton.setGeometry(QtCore.QRect(400, 30, 100, 30))
|
||||
self.callButton.setGeometry(QtCore.QRect(550, 30, 75, 30))
|
||||
self.callButton.setObjectName("callButton")
|
||||
self.callButton.setText(QtGui.QApplication.translate("Form", "Start call", None, QtGui.QApplication.UnicodeUTF8))
|
||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||
@ -187,7 +187,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
item = ContactItem()
|
||||
elem = QtGui.QListWidgetItem(self.friends_list)
|
||||
print item.sizeHint()
|
||||
elem.setSizeHint(QtCore.QSize(250, 50))
|
||||
elem.setSizeHint(QtCore.QSize(250, 70))
|
||||
self.friends_list.addItem(elem)
|
||||
self.friends_list.setItemWidget(elem, item)
|
||||
widgets.append(item)
|
||||
@ -196,12 +196,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def setup_right_center(self, widget):
|
||||
self.messages = QtGui.QListWidget(widget)
|
||||
self.messages.setGeometry(0, 0, 500, 250)
|
||||
self.messages.setGeometry(0, 0, 600, 250)
|
||||
|
||||
def initUI(self):
|
||||
self.setMinimumSize(800, 550)
|
||||
self.setMaximumSize(800, 550)
|
||||
self.setGeometry(400, 400, 800, 550)
|
||||
self.setMinimumSize(900, 550)
|
||||
self.setMaximumSize(900, 550)
|
||||
self.setGeometry(400, 400, 900, 550)
|
||||
self.setWindowTitle('Toxygen')
|
||||
main = QtGui.QWidget()
|
||||
grid = QtGui.QGridLayout()
|
||||
|
@ -62,7 +62,7 @@ class Contact(object):
|
||||
widget.name.setText(name)
|
||||
widget.status_message.setText(status_message)
|
||||
self._tox_id = tox_id
|
||||
# self.load_avatar()
|
||||
self.load_avatar()
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# name - current name or alias of user
|
||||
@ -139,11 +139,23 @@ class Friend(Contact):
|
||||
self._number = number
|
||||
self._new_messages = False
|
||||
self._visible = True
|
||||
self._alias = False
|
||||
|
||||
def __del__(self):
|
||||
self.set_visibility(False)
|
||||
del self._widget
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Alias support
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
def set_name(self, value):
|
||||
if not self._alias:
|
||||
super(self.__class__, self).set_name(value)
|
||||
|
||||
def set_alias(self, alias):
|
||||
self._alias = bool(alias)
|
||||
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
# Visibility in friends' list
|
||||
# -----------------------------------------------------------------------------------------------------------------
|
||||
@ -200,14 +212,22 @@ class Profile(Contact, Singleton):
|
||||
self._name = tox.self_get_name()
|
||||
self._status_message = tox.self_get_status_message()
|
||||
self._status = None
|
||||
settings = Settings.get_instance()
|
||||
self.show_online = Settings.get_instance()['show_online_friends']
|
||||
aliases = settings['friends_aliases']
|
||||
data = tox.self_get_friend_list()
|
||||
self._friends, num, self._active_friend = [], 0, -1
|
||||
for i in data:
|
||||
tox_id = tox.friend_get_public_key(i)
|
||||
name = tox.friend_get_name(i) or tox_id
|
||||
try:
|
||||
alias = filter(lambda x: x[0] == tox_id, aliases)[0][1]
|
||||
except:
|
||||
alias = ''
|
||||
name = alias or tox.friend_get_name(i) or tox_id
|
||||
status_message = tox.friend_get_status_message(i)
|
||||
self._friends.append(Friend(i, name, status_message, widgets[num], tox_id))
|
||||
friend = Friend(i, name, status_message, widgets[num], tox_id)
|
||||
friend.set_alias(alias)
|
||||
self._friends.append(friend)
|
||||
num += 1
|
||||
self.set_name(tox.self_get_name().encode('utf-8'))
|
||||
self.set_status_message(tox.self_get_status_message().encode('utf-8'))
|
||||
|
Loading…
Reference in New Issue
Block a user