ui fixes (long name and status)

This commit is contained in:
ingvar1995 2016-03-22 12:50:18 +03:00
parent 5fca5c183a
commit cd93d84dfd
4 changed files with 26 additions and 12 deletions

View file

@ -49,7 +49,7 @@ class MessageItem(QtGui.QListWidget):
font.setBold(True)
self.name.setFont(font)
self.name.setObjectName("name")
self.name.setText(user)
self.name.setText(user if len(user) <= 14 else user[:11] + '...')
self.time = QtGui.QLabel(self)
self.time.setGeometry(QtCore.QRect(parent.width() - 50, 0, 50, 25))

View file

@ -51,7 +51,7 @@ class LoginScreen(QtGui.QWidget):
self.load_profile.raise_()
self.new_name.raise_()
self.new_profile.raise_()
self.toxygen.setGeometry(QtCore.QRect(160, 10, 81, 21))
self.toxygen.setGeometry(QtCore.QRect(160, 10, 90, 21))
font = QtGui.QFont()
font.setFamily("Impact")
font.setPointSize(16)

View file

@ -106,11 +106,11 @@ class ProfileSettings(CenteredWidget):
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtGui.QLabel(self)
self.label_2.setGeometry(QtCore.QRect(50, 100, 91, 21))
self.label_2.setGeometry(QtCore.QRect(40, 100, 100, 21))
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.label_3 = QtGui.QLabel(self)
self.label_3.setGeometry(QtCore.QRect(50, 170, 91, 21))
self.label_3.setGeometry(QtCore.QRect(40, 170, 100, 21))
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.tox_id = QtGui.QLabel(self)
@ -121,11 +121,11 @@ class ProfileSettings(CenteredWidget):
s = profile.tox_id
self.tox_id.setText(s)
self.copyId = QtGui.QPushButton(self)
self.copyId.setGeometry(QtCore.QRect(40, 250, 100, 30))
self.copyId.setGeometry(QtCore.QRect(40, 250, 150, 30))
self.copyId.setObjectName("copyId")
self.copyId.clicked.connect(self.copy)
self.export = QtGui.QPushButton(self)
self.export.setGeometry(QtCore.QRect(150, 250, 100, 30))
self.export.setGeometry(QtCore.QRect(200, 250, 150, 30))
self.export.setObjectName("export")
self.export.clicked.connect(self.export_profile)
self.comboBox = QtGui.QComboBox(self)
@ -139,7 +139,7 @@ class ProfileSettings(CenteredWidget):
self.new_avatar = QtGui.QPushButton(self)
self.new_avatar.setGeometry(QtCore.QRect(400, 50, 200, 50))
self.delete_avatar = QtGui.QPushButton(self)
self.delete_avatar.setGeometry(QtCore.QRect(400, 100, 200, 50))
self.delete_avatar.setGeometry(QtCore.QRect(400, 120, 200, 50))
self.delete_avatar.clicked.connect(self.reset_avatar)
self.new_avatar.clicked.connect(self.set_avatar)
self.retranslateUi()

View file

@ -84,8 +84,15 @@ class Contact(object):
"""
self._name, self._status_message = name, status_message
self._status, self._widget = None, widget
widget.name.setText(name)
widget.status_message.setText(status_message)
if type(self) is Profile:
self._widget.name.setText(name if len(name) <= 14 else name[:11] + '...')
else:
self._widget.name.setText(name if len(name) <= 20 else name[:17] + '...')
if type(self) is Profile:
text = self._status_message if len(self._status_message) <= 20 else self._status_message[:17] + '...'
else:
text = self._status_message if len(self._status_message) <= 30 else self._status_message[:27] + '...'
self._widget.status_message.setText(text)
self._tox_id = tox_id
self.load_avatar()
@ -98,7 +105,10 @@ class Contact(object):
def set_name(self, value):
self._name = value.decode('utf-8')
self._widget.name.setText(self._name)
if type(self) is Profile:
self._widget.name.setText(self._name if len(self._name) <= 14 else self._name[:11] + '...')
else:
self._widget.name.setText(self._name if len(self._name) <= 20 else self._name[:17] + '...')
self._widget.name.repaint()
name = property(get_name, set_name)
@ -112,7 +122,11 @@ class Contact(object):
def set_status_message(self, value):
self._status_message = value.decode('utf-8')
self._widget.status_message.setText(self._status_message)
if type(self) is Profile:
text = self._status_message if len(self._status_message) <= 20 else self._status_message[:17] + '...'
else:
text = self._status_message if len(self._status_message) <= 30 else self._status_message[:27] + '...'
self._widget.status_message.setText(text)
self._widget.status_message.repaint()
status_message = property(get_status_message, set_status_message)
@ -590,7 +604,7 @@ class Profile(Contact, Singleton):
aliases.append((friend.tox_id, text))
friend.set_alias(text)
else: # use default name
friend.name = self._tox.friend_get_name(friend.number)
friend.name = self._tox.friend_get_name(friend.number).encode('utf-8')
friend.set_alias('')
try:
index = map(lambda x: x[0], aliases).index(friend.tox_id)