bug fixes

This commit is contained in:
ingvar1995 2016-06-23 22:50:17 +03:00
parent a714c1045d
commit 27a5735dc1
2 changed files with 14 additions and 15 deletions

View file

@ -79,18 +79,18 @@ class Profile(contact.Contact, Singleton):
self._tox.self_set_status(status) self._tox.self_set_status(status)
def set_name(self, value): def set_name(self, value):
tmp = self.name if self.name == value:
return
super(Profile, self).set_name(value) super(Profile, self).set_name(value)
self._tox.self_set_name(self._name.encode('utf-8')) self._tox.self_set_name(self._name.encode('utf-8'))
if tmp != value: message = QtGui.QApplication.translate("MainWindow", 'User {} is now known as {}', None,
message = QtGui.QApplication.translate("MainWindow", 'User {} is now known as {}', None, QtGui.QApplication.UnicodeUTF8)
QtGui.QApplication.UnicodeUTF8) message = message.format(tmp, str(value, 'utf-8'))
message = message.format(tmp, str(value, 'utf-8')) for friend in self._friends:
for friend in self._friends: friend.append_message(InfoMessage(message, time.time()))
friend.append_message(InfoMessage(message, time.time())) if self._active_friend + 1:
if self._active_friend + 1: self.create_message_item(message, curr_time(), '', MESSAGE_TYPE['INFO_MESSAGE'])
self.create_message_item(message, curr_time(), '', MESSAGE_TYPE['INFO_MESSAGE']) self._messages.scrollToBottom()
self._messages.scrollToBottom()
def set_status_message(self, value): def set_status_message(self, value):
super(Profile, self).set_status_message(value) super(Profile, self).set_status_message(value)

View file

@ -8,12 +8,11 @@ class DataLabel(QtGui.QLabel):
""" """
Label with elided text Label with elided text
""" """
def setText(self, text):
def paintEvent(self, event): text = ''.join(c if c <= '\u10FFFF' else '\u25AF' for c in text)
painter = QtGui.QPainter(self)
metrics = QtGui.QFontMetrics(self.font()) metrics = QtGui.QFontMetrics(self.font())
text = metrics.elidedText(self.text(), QtCore.Qt.ElideRight, self.width()) text = metrics.elidedText(text, QtCore.Qt.ElideRight, self.width())
painter.drawText(self.rect(), self.alignment(), text) super().setText(text)
class CenteredWidget(QtGui.QWidget): class CenteredWidget(QtGui.QWidget):