bug fixes

This commit is contained in:
ingvar1995 2016-03-16 23:12:51 +03:00
parent 1a996522f1
commit 257271cf93
2 changed files with 8 additions and 2 deletions

View file

@ -165,7 +165,7 @@ class ProfileSettings(CenteredWidget):
Profile.get_instance().reset_avatar() Profile.get_instance().reset_avatar()
def set_avatar(self): def set_avatar(self):
name = QtGui.QFileDialog.getOpenFileName(self, 'Open file', None, 'Image Files (*.png *.jpg *.bmp)') name = QtGui.QFileDialog.getOpenFileName(self, 'Open file', None, 'Image Files (*.png)')
print name print name
if name[0]: if name[0]:
with open(name[0], 'rb') as f: with open(name[0], 'rb') as f:

View file

@ -170,7 +170,7 @@ class Contact(object):
def get_avatar_hash(self): def get_avatar_hash(self):
avatar_path = (Settings.get_default_path() + 'avatars/{}.png').format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]) avatar_path = (Settings.get_default_path() + 'avatars/{}.png').format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2])
if not os.path.isfile(avatar_path): # load default image if not os.path.isfile(avatar_path): # load default image
avatar_path = curr_directory() + '/images/avatar.png' return 0
with open(avatar_path, 'rb') as fl: with open(avatar_path, 'rb') as fl:
data = fl.read() data = fl.read()
return Tox.hash(data) return Tox.hash(data)
@ -705,6 +705,12 @@ class Profile(Contact, Singleton):
pass pass
def incoming_avatar(self, friend_number, file_number, size): def incoming_avatar(self, friend_number, file_number, size):
"""
Friend changed avatar
:param friend_number: friend number
:param file_number: file number
:param size: size of avatar or 0 (default avatar)
"""
friend = self.get_friend_by_number(friend_number) friend = self.get_friend_by_number(friend_number)
if not size: if not size:
friend.reset_avatar() friend.reset_avatar()