utf-8 everywhere, fixed bug with name and status, saving added.

This commit is contained in:
ingvar1995 2016-03-01 00:23:03 +03:00
parent ff7aa1794c
commit 5576f0423c
4 changed files with 15 additions and 12 deletions

View File

@ -84,6 +84,8 @@ def main():
app.exec_() app.exec_()
mainloop.stop = True mainloop.stop = True
mainloop.wait() mainloop.wait()
data = tox.get_savedata()
ProfileHelper.save_profile(data)
del tox del tox

View File

@ -138,8 +138,8 @@ class ProfileSettings(QtGui.QWidget):
def closeEvent(self, event): def closeEvent(self, event):
profile = Profile.get_instance() profile = Profile.get_instance()
profile.name = self.nick.text() profile.set_name(self.nick.text().encode('utf-8'))
profile.status_message = self.status.text() profile.set_status_message(self.status.text().encode('utf-8'))
class NetworkSettings(QtGui.QWidget): class NetworkSettings(QtGui.QWidget):

View File

@ -57,7 +57,7 @@ class Contact(object):
""" """
def __init__(self, name, status_message, widget): def __init__(self, name, status_message, widget):
self._name, self._status_message= name, status_message self._name, self._status_message = name, status_message
self._status, self._widget = None, widget self._status, self._widget = None, widget
widget.name.setText(name) widget.name.setText(name)
widget.status_message.setText(status_message) widget.status_message.setText(status_message)
@ -66,8 +66,8 @@ class Contact(object):
return self._name return self._name
def set_name(self, value): def set_name(self, value):
self._name = value self._name = value.decode('utf-8')
self._widget.name.setText(value) self._widget.name.setText(self._name)
self._widget.name.repaint() self._widget.name.repaint()
name = property(get_name, set_name) name = property(get_name, set_name)
@ -76,8 +76,8 @@ class Contact(object):
return self._status_message return self._status_message
def set_status_message(self, value): def set_status_message(self, value):
self._status_message = value self._status_message = value.decode('utf-8')
self._widget.status_message.setText(value) self._widget.status_message.setText(self._status_message)
self._widget.status_message.repaint() self._widget.status_message.repaint()
status_message = property(get_status_message, set_status_message) status_message = property(get_status_message, set_status_message)
@ -149,8 +149,8 @@ class Profile(Contact):
self._friends.append(Friend(i, name, status_message, widgets[num])) self._friends.append(Friend(i, name, status_message, widgets[num]))
num += 1 num += 1
Profile._instance = self Profile._instance = self
self.set_name(tox.self_get_name()) self.set_name(tox.self_get_name().encode('utf-8'))
self.set_status_message(tox.self_get_status_message()) self.set_status_message(tox.self_get_status_message().encode('utf-8'))
@staticmethod @staticmethod
def get_instance(): def get_instance():
@ -164,11 +164,11 @@ class Profile(Contact):
def set_name(self, value): def set_name(self, value):
super(self.__class__, self).set_name(value) super(self.__class__, self).set_name(value)
self.tox.self_set_name(value) self.tox.self_set_name(self._name.encode('utf-8'))
def set_status_message(self, value): def set_status_message(self, value):
super(self.__class__, self).set_status_message(value) super(self.__class__, self).set_status_message(value)
self.tox.self_set_status_message(value) self.tox.self_set_status_message(self._status_message.encode('utf-8'))
def filtration(self, show_online=True, filter_str=''): def filtration(self, show_online=True, filter_str=''):
for friend in self._friends: for friend in self._friends:
@ -202,6 +202,7 @@ class Profile(Contact):
return friend.name, friend.status_message return friend.name, friend.status_message
else: else:
log('Something is wrong in get_active_friend_data') log('Something is wrong in get_active_friend_data')
return '', ''
def get_active_number(self): def get_active_number(self):
return self._friends[self._active_friend].number return self._friends[self._active_friend].number

View File

@ -6,7 +6,7 @@ program_version = '0.0.1 (alpha)'
def log(data): def log(data):
with open('logs.log', 'a') as fl: with open('logs.log', 'a') as fl:
fl.write(str(data)) fl.write(str(data) + '\n')
def curr_directory(): def curr_directory():