name && status bug fixes

This commit is contained in:
ingvar1995 2016-06-24 15:00:13 +03:00
parent 27a5735dc1
commit 5cfa484a67
2 changed files with 6 additions and 5 deletions

View File

@ -258,7 +258,7 @@ class ProfileSettings(CenteredWidget):
def closeEvent(self, event): def closeEvent(self, event):
profile = Profile.get_instance() profile = Profile.get_instance()
profile.set_name(self.nick.text().encode('utf-8')) profile.set_name(self.nick.text())
profile.set_status_message(self.status_message.text().encode('utf-8')) profile.set_status_message(self.status_message.text().encode('utf-8'))
profile.set_status(self.status.currentIndex()) profile.set_status(self.status.currentIndex())

View File

@ -74,18 +74,19 @@ class Profile(contact.Contact, Singleton):
self.set_status((self._status + 1) % 3) self.set_status((self._status + 1) % 3)
def set_status(self, status): def set_status(self, status):
if self._status is not None:
super(Profile, self).set_status(status) super(Profile, self).set_status(status)
if status is not None:
self._tox.self_set_status(status) self._tox.self_set_status(status)
def set_name(self, value): def set_name(self, value):
if self.name == value: if self.name == value:
return return
super(Profile, self).set_name(value) tmp = self.name
super(Profile, self).set_name(value.encode('utf-8'))
self._tox.self_set_name(self._name.encode('utf-8')) self._tox.self_set_name(self._name.encode('utf-8'))
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, value)
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: