identicons fixes. sending messages button fixed
This commit is contained in:
parent
d09609a5e5
commit
7aac248bf9
@ -148,6 +148,11 @@ class BaseContact:
|
||||
|
||||
return util.join_path(directory, '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]))
|
||||
|
||||
def has_avatar(self):
|
||||
path = self.get_contact_avatar_path()
|
||||
|
||||
return util.file_exists(path)
|
||||
|
||||
def get_avatar_changed_event(self):
|
||||
return self._avatar_changed_event
|
||||
|
||||
|
@ -296,11 +296,7 @@ class ContactsManager(ToxSave):
|
||||
Adds friend to list
|
||||
"""
|
||||
self._tox.friend_add_norequest(tox_id)
|
||||
self._history.add_friend_to_db(tox_id)
|
||||
friend = self._contact_provider.get_friend_by_public_key(tox_id)
|
||||
self._contacts.append(friend)
|
||||
friend.reset_avatar(self._settings['identicons'])
|
||||
self._save_profile()
|
||||
self._add_friend(tox_id)
|
||||
|
||||
def block_user(self, tox_id):
|
||||
"""
|
||||
@ -375,8 +371,7 @@ class ContactsManager(ToxSave):
|
||||
else:
|
||||
self._tox.friend_add(tox_id, message.encode('utf-8'))
|
||||
tox_id = tox_id[:TOX_PUBLIC_KEY_SIZE * 2]
|
||||
friend = self._contact_provider.get_friend_by_public_key(tox_id)
|
||||
self._contacts.append(friend)
|
||||
self._add_friend(tox_id)
|
||||
self.save_profile()
|
||||
return True
|
||||
except Exception as ex: # wrong data
|
||||
@ -430,6 +425,8 @@ class ContactsManager(ToxSave):
|
||||
self._load_groups()
|
||||
if len(self._contacts):
|
||||
self.set_active(0)
|
||||
for contact in filter(lambda c: not c.has_avatar(), self._contacts):
|
||||
contact.reset_avatar(self._settings['identicons'])
|
||||
self.update_filtration()
|
||||
|
||||
def _load_friends(self):
|
||||
@ -477,6 +474,14 @@ class ContactsManager(ToxSave):
|
||||
self._screen.account_avatar.setPixmap(pixmap.scaled(width, width,
|
||||
QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation))
|
||||
|
||||
def _add_friend(self, tox_id):
|
||||
self._history.add_friend_to_db(tox_id)
|
||||
friend = self._contact_provider.get_friend_by_public_key(tox_id)
|
||||
self._contacts.append(friend)
|
||||
if not friend.has_avatar():
|
||||
friend.reset_avatar(self._settings['identicons'])
|
||||
self._save_profile()
|
||||
|
||||
def _save_profile(self):
|
||||
data = self._tox.get_savedata()
|
||||
self._profile_manager.save_profile(data)
|
||||
|
@ -17,7 +17,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self._plugins_loader = None
|
||||
self.setAcceptDrops(True)
|
||||
self._saved = False
|
||||
self._profile = self._toxes = None
|
||||
self._profile = self._toxes = self._messenger = None
|
||||
self._file_transfer_handler = self._history_loader = self._groups_service = self._calls_manager = None
|
||||
self._should_show_group_peers_list = False
|
||||
self.initUI()
|
||||
@ -34,6 +34,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self._calls_manager = calls_manager
|
||||
self._groups_service = groups_service
|
||||
self._toxes = toxes
|
||||
self._messenger = messenger
|
||||
self._contacts_manager.active_contact_changed.add_callback(self._new_contact_selected)
|
||||
self.messageEdit.set_messenger(messenger)
|
||||
|
||||
|
@ -102,6 +102,10 @@ def join_path(a, b):
|
||||
return os.path.join(a, b)
|
||||
|
||||
|
||||
def file_exists(file_path):
|
||||
return os.path.exists(file_path)
|
||||
|
||||
|
||||
def copy(src, dest):
|
||||
if not os.path.exists(dest):
|
||||
os.makedirs(dest)
|
||||
|
Loading…
Reference in New Issue
Block a user