avatars handler fix

This commit is contained in:
ingvar1995 2016-12-24 14:36:49 +03:00
parent 9e7e9b9012
commit 9d939e7439
2 changed files with 4 additions and 5 deletions

View File

@ -84,11 +84,10 @@ class BaseContact:
""" """
Tries to load avatar of contact or uses default avatar Tries to load avatar of contact or uses default avatar
""" """
avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]) prefix = ProfileHelper.get_path() + 'avatars/'
os.chdir(ProfileHelper.get_path() + 'avatars/') avatar_path = prefix + '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2])
if not os.path.isfile(avatar_path) or not os.path.getsize(avatar_path): # load default image if not os.path.isfile(avatar_path) or not os.path.getsize(avatar_path): # load default image
avatar_path = 'avatar.png' avatar_path = curr_directory() + '/images/avatar.png'
os.chdir(curr_directory() + '/images/')
width = self._widget.avatar_label.width() width = self._widget.avatar_label.width()
pixmap = QtGui.QPixmap(avatar_path) pixmap = QtGui.QPixmap(avatar_path)
self._widget.avatar_label.setPixmap(pixmap.scaled(width, width, QtCore.Qt.KeepAspectRatio, self._widget.avatar_label.setPixmap(pixmap.scaled(width, width, QtCore.Qt.KeepAspectRatio,

View File

@ -1151,7 +1151,6 @@ class Profile(basecontact.BaseContact, Singleton):
if not os.path.isfile(avatar_path): # reset image if not os.path.isfile(avatar_path): # reset image
avatar_path = None avatar_path = None
sa = SendAvatar(avatar_path, self._tox, friend_number) sa = SendAvatar(avatar_path, self._tox, friend_number)
sa.set_transfer_finished_handler(self.transfer_finished)
self._file_transfers[(friend_number, sa.get_file_number())] = sa self._file_transfers[(friend_number, sa.get_file_number())] = sa
def incoming_avatar(self, friend_number, file_number, size): def incoming_avatar(self, friend_number, file_number, size):
@ -1164,6 +1163,7 @@ class Profile(basecontact.BaseContact, Singleton):
ra = ReceiveAvatar(self._tox, friend_number, size, file_number) ra = ReceiveAvatar(self._tox, friend_number, size, file_number)
if ra.state != TOX_FILE_TRANSFER_STATE['CANCELLED']: if ra.state != TOX_FILE_TRANSFER_STATE['CANCELLED']:
self._file_transfers[(friend_number, file_number)] = ra self._file_transfers[(friend_number, file_number)] = ra
ra.set_transfer_finished_handler(self.transfer_finished)
else: else:
self.get_friend_by_number(friend_number).load_avatar() self.get_friend_by_number(friend_number).load_avatar()
if self.get_active_number() == friend_number: if self.get_active_number() == friend_number: