From 27a5735dc12bc5b9c89a8bfe11c6e3c2d46ef822 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 23 Jun 2016 22:50:17 +0300 Subject: [PATCH] bug fixes --- src/profile.py | 20 ++++++++++---------- src/widgets.py | 9 ++++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/profile.py b/src/profile.py index cdce446..d1aa7a2 100644 --- a/src/profile.py +++ b/src/profile.py @@ -79,18 +79,18 @@ class Profile(contact.Contact, Singleton): self._tox.self_set_status(status) def set_name(self, value): - tmp = self.name + if self.name == value: + return super(Profile, self).set_name(value) self._tox.self_set_name(self._name.encode('utf-8')) - if tmp != value: - message = QtGui.QApplication.translate("MainWindow", 'User {} is now known as {}', None, - QtGui.QApplication.UnicodeUTF8) - message = message.format(tmp, str(value, 'utf-8')) - for friend in self._friends: - friend.append_message(InfoMessage(message, time.time())) - if self._active_friend + 1: - self.create_message_item(message, curr_time(), '', MESSAGE_TYPE['INFO_MESSAGE']) - self._messages.scrollToBottom() + message = QtGui.QApplication.translate("MainWindow", 'User {} is now known as {}', None, + QtGui.QApplication.UnicodeUTF8) + message = message.format(tmp, str(value, 'utf-8')) + for friend in self._friends: + friend.append_message(InfoMessage(message, time.time())) + if self._active_friend + 1: + self.create_message_item(message, curr_time(), '', MESSAGE_TYPE['INFO_MESSAGE']) + self._messages.scrollToBottom() def set_status_message(self, value): super(Profile, self).set_status_message(value) diff --git a/src/widgets.py b/src/widgets.py index 30482c6..1e5cfe8 100644 --- a/src/widgets.py +++ b/src/widgets.py @@ -8,12 +8,11 @@ class DataLabel(QtGui.QLabel): """ Label with elided text """ - - def paintEvent(self, event): - painter = QtGui.QPainter(self) + def setText(self, text): + text = ''.join(c if c <= '\u10FFFF' else '\u25AF' for c in text) metrics = QtGui.QFontMetrics(self.font()) - text = metrics.elidedText(self.text(), QtCore.Qt.ElideRight, self.width()) - painter.drawText(self.rect(), self.alignment(), text) + text = metrics.elidedText(text, QtCore.Qt.ElideRight, self.width()) + super().setText(text) class CenteredWidget(QtGui.QWidget):