minor bug fixes

This commit is contained in:
ingvar1995 2018-09-23 13:04:27 +03:00
parent ad3bbb5e45
commit ae4eae92ae
4 changed files with 13 additions and 10 deletions

View File

@ -105,12 +105,12 @@ class App:
def _stop_app(self): def _stop_app(self):
self._plugin_loader.stop() self._plugin_loader.stop()
self._stop_threads() self._stop_threads()
self._file_transfer_handler.stop()
self._tray.hide() self._tray.hide()
self._save_profile() self._save_profile()
self._settings.close() self._settings.close()
self._kill_toxav() self._kill_toxav()
self._kill_tox() self._kill_tox()
del self._tox
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# App loading # App loading
@ -323,7 +323,6 @@ class App:
self._save_profile(data) self._save_profile(data)
self._kill_toxav() self._kill_toxav()
self._kill_tox() self._kill_tox()
del self._tox
# create new tox instance # create new tox instance
self._tox = self._create_tox(data) self._tox = self._create_tox(data)
self._start_threads(False) self._start_threads(False)
@ -398,7 +397,8 @@ class App:
if updating: if updating:
self._save_profile() self._save_profile()
self._settings.close() self._settings.close()
del self._tox self._kill_toxav()
self._kill_tox()
return updating return updating
def _create_tox(self, data): def _create_tox(self, data):

View File

@ -126,7 +126,7 @@ class BaseContact:
if os.path.isfile(avatar_path) and not avatar_path == self._get_default_avatar_path(): if os.path.isfile(avatar_path) and not avatar_path == self._get_default_avatar_path():
os.remove(avatar_path) os.remove(avatar_path)
if generate_new: if generate_new:
self.set_avatar(common.generate_avatar(self.tox_id)) self.set_avatar(common.generate_avatar(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]))
else: else:
self.load_avatar() self.load_avatar()

View File

@ -20,7 +20,7 @@ class FileTransfersHandler(ToxSave):
profile.avatar_changed_event.add_callback(self._send_avatar_to_contacts) profile.avatar_changed_event.add_callback(self._send_avatar_to_contacts)
def __del__(self): def stop(self):
self._settings['paused_file_transfers'] = self._paused_file_transfers if self._settings['resend_files'] else {} self._settings['paused_file_transfers'] = self._paused_file_transfers if self._settings['resend_files'] else {}
self._settings.save() self._settings.save()
@ -259,13 +259,16 @@ class FileTransfersHandler(ToxSave):
def _send_avatar_to_contacts(self, _): def _send_avatar_to_contacts(self, _):
friends = self._get_all_friends() friends = self._get_all_friends()
for friend in friends: for friend in filter(self._is_friend_online, friends):
self.send_avatar(friend.number) self.send_avatar(friend.number)
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Private methods # Private methods
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
def _is_friend_online(self, friend_number):
return self._get_friend_by_number(friend_number).status is not None
def _get_friend_by_number(self, friend_number): def _get_friend_by_number(self, friend_number):
return self._contact_provider.get_friend_by_number(friend_number) return self._contact_provider.get_friend_by_number(friend_number)

View File

@ -181,7 +181,7 @@ def tox_file_recv(window, tray, profile, file_transfer_handler, contacts_manager
invoke_in_main_thread(tray_notification, file_from + ' ' + friend.name, file_name, tray, window) invoke_in_main_thread(tray_notification, file_from + ' ' + friend.name, file_name, tray, window)
if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']: if settings['sound_notifications'] and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['FILE_TRANSFER']) sound_notification(SOUND_NOTIFICATION['FILE_TRANSFER'])
icon = os.path.join(util.get_images_directory(), 'icon_new_messages.png') icon = util.join_path(util.get_images_directory(), 'icon_new_messages.png')
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon)) invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon))
else: # AVATAR else: # AVATAR
print('Avatar') print('Avatar')
@ -371,7 +371,7 @@ def group_message(window, tray, tox, messenger, settings, profile):
invoke_in_main_thread(tray_notification, name, message, tray, window) invoke_in_main_thread(tray_notification, name, message, tray, window)
if settings['sound_notifications'] and bl and profile.status != TOX_USER_STATUS['BUSY']: if settings['sound_notifications'] and bl and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['MESSAGE']) sound_notification(SOUND_NOTIFICATION['MESSAGE'])
icon = os.path.join(util.get_images_directory(), 'icon_new_messages.png') icon = util.join_path(util.get_images_directory(), 'icon_new_messages.png')
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon)) invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon))
return wrapped return wrapped
@ -392,7 +392,7 @@ def group_private_message(window, tray, tox, messenger, settings, profile):
invoke_in_main_thread(tray_notification, name, message, tray, window) invoke_in_main_thread(tray_notification, name, message, tray, window)
if settings['sound_notifications'] and bl and profile.status != TOX_USER_STATUS['BUSY']: if settings['sound_notifications'] and bl and profile.status != TOX_USER_STATUS['BUSY']:
sound_notification(SOUND_NOTIFICATION['MESSAGE']) sound_notification(SOUND_NOTIFICATION['MESSAGE'])
icon = os.path.join(util.get_images_directory(), 'icon_new_messages.png') icon = util.join_path(util.get_images_directory(), 'icon_new_messages.png')
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon)) invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon))
return wrapped return wrapped
@ -411,7 +411,7 @@ def group_invite(window, settings, tray, profile, groups_service, contacts_provi
title = util_ui.tr('New invite to group chat') title = util_ui.tr('New invite to group chat')
text = util_ui.tr('{} invites you to group "{}"').format(friend.name, group_name) text = util_ui.tr('{} invites you to group "{}"').format(friend.name, group_name)
invoke_in_main_thread(tray_notification, title, text, tray, window) invoke_in_main_thread(tray_notification, title, text, tray, window)
icon = os.path.join(util.get_images_directory(), 'icon_new_messages.png') icon = util.join_path(util.get_images_directory(), 'icon_new_messages.png')
invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon)) invoke_in_main_thread(tray.setIcon, QtGui.QIcon(icon))
return wrapped return wrapped