fixes for messaging, contacts filtering etc
This commit is contained in:
parent
4ecf666b2f
commit
85ea9ab6e8
@ -134,12 +134,13 @@ class App:
|
||||
|
||||
def _load_login_screen_translations(self):
|
||||
current_language, supported_languages = self._get_languages()
|
||||
if current_language in supported_languages:
|
||||
lang_path = supported_languages[current_language]
|
||||
translator = QtCore.QTranslator()
|
||||
translator.load(util.get_translations_directory() + lang_path)
|
||||
self._app.installTranslator(translator)
|
||||
self._app.translator = translator
|
||||
if current_language not in supported_languages:
|
||||
return
|
||||
lang_path = supported_languages[current_language]
|
||||
translator = QtCore.QTranslator()
|
||||
translator.load(util.get_translations_directory() + lang_path)
|
||||
self._app.installTranslator(translator)
|
||||
self._app.translator = translator
|
||||
|
||||
def _load_icon(self):
|
||||
icon_file = os.path.join(util.get_images_directory(), 'icon.png')
|
||||
@ -237,11 +238,11 @@ class App:
|
||||
return ls.result
|
||||
|
||||
def _load_existing_profile(self, profile_path):
|
||||
self._settings = Settings(self._toxes, profile_path.replace('.tox', '.json'))
|
||||
self._profile_manager = ProfileManager(self._settings, self._toxes, profile_path)
|
||||
self._profile_manager = ProfileManager(self._toxes, profile_path)
|
||||
data = self._profile_manager.open_profile()
|
||||
if self._toxes.is_data_encrypted(data):
|
||||
data = self._enter_password(data)
|
||||
self._settings = Settings(self._toxes, profile_path.replace('.tox', '.json'))
|
||||
self._tox = self._create_tox(data)
|
||||
|
||||
def _create_new_profile(self, profile_name):
|
||||
@ -264,7 +265,7 @@ class App:
|
||||
if result.password:
|
||||
self._toxes.set_password(result.password)
|
||||
self._settings = Settings(self._toxes, self._path.replace('.tox', '.json'))
|
||||
self._profile_manager = ProfileManager(self._settings, self._toxes, profile_path)
|
||||
self._profile_manager = ProfileManager(self._toxes, profile_path)
|
||||
try:
|
||||
self._save_profile()
|
||||
except Exception as ex:
|
||||
|
@ -163,7 +163,7 @@ class ContactsManager(ToxSave):
|
||||
:param filter_str: show contacts which name contains this substring
|
||||
"""
|
||||
filter_str = filter_str.lower()
|
||||
contact = self.get_curr_contact()
|
||||
current_contact = self.get_curr_contact()
|
||||
|
||||
if sorting > 5 or sorting < 0:
|
||||
sorting = 0
|
||||
@ -189,7 +189,7 @@ class ContactsManager(ToxSave):
|
||||
else:
|
||||
self._contacts = sorted(self._contacts, key=lambda x: x.name.lower())
|
||||
|
||||
# change item widgets
|
||||
# change item widgets
|
||||
for index, contact in enumerate(self._contacts):
|
||||
list_item = self._screen.friends_list.item(index)
|
||||
item_widget = self._screen.friends_list.itemWidget(list_item)
|
||||
@ -203,13 +203,15 @@ class ContactsManager(ToxSave):
|
||||
item = self._screen.friends_list.item(index)
|
||||
item_widget = self._screen.friends_list.itemWidget(item)
|
||||
item.setSizeHint(QtCore.QSize(250, item_widget.height() if friend.visibility else 0))
|
||||
|
||||
# save soring results
|
||||
self._sorting, self._filter_string = sorting, filter_str
|
||||
self._settings['sorting'] = self._sorting
|
||||
self._settings.save()
|
||||
|
||||
# update active contact
|
||||
if contact is not None:
|
||||
index = self._contacts.index(contact)
|
||||
if current_contact is not None:
|
||||
index = self._contacts.index(current_contact)
|
||||
self.set_active(index)
|
||||
|
||||
def update_filtration(self):
|
||||
|
@ -34,6 +34,7 @@ class GroupsService(tox_save.ToxSave):
|
||||
self._add_new_group_by_number(group_number)
|
||||
group = self._get_group_by_number(group_number)
|
||||
group.status = constants.TOX_USER_STATUS['NONE']
|
||||
self._contacts_manager.update_filtration()
|
||||
|
||||
def join_gc_by_id(self, chat_id, password, nick, status):
|
||||
group_number = self._tox.group_join(chat_id, password, nick, status)
|
||||
|
@ -28,7 +28,10 @@ class MessageAuthor:
|
||||
def get_type(self):
|
||||
return self._type
|
||||
|
||||
type = property(get_type)
|
||||
def set_type(self, value):
|
||||
self._type = value
|
||||
|
||||
type = property(get_type, set_type)
|
||||
|
||||
|
||||
class Message:
|
||||
@ -74,7 +77,7 @@ class Message:
|
||||
self._widget = None
|
||||
|
||||
def mark_as_sent(self):
|
||||
self._author.author_type = MESSAGE_AUTHOR['ME']
|
||||
self._author.type = MESSAGE_AUTHOR['ME']
|
||||
if self._widget is not None:
|
||||
self._widget.mark_as_sent()
|
||||
|
||||
|
@ -654,7 +654,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
clipboard.setText(text)
|
||||
|
||||
def clear_history(self, num):
|
||||
self._contacts_manager.clear_history(num)
|
||||
self._history_loader.clear_history(num)
|
||||
|
||||
def auto_accept(self, num, value):
|
||||
tox_id = self._contacts_manager.friend_public_key(num)
|
||||
|
@ -241,7 +241,7 @@ class ProfileSettings(CenteredWidget):
|
||||
util_ui.tr('Use new path'))
|
||||
self._settings.export(directory)
|
||||
self._profile.export_db(directory)
|
||||
self._profile_manager.export_profile(directory, reply)
|
||||
self._profile_manager.export_profile(self._settings, directory, reply)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self._profile.set_name(self.nick.text())
|
||||
|
@ -7,8 +7,7 @@ class ProfileManager:
|
||||
"""
|
||||
Class with methods for search, load and save profiles
|
||||
"""
|
||||
def __init__(self, settings, toxes, path):
|
||||
self._settings = settings
|
||||
def __init__(self, toxes, path):
|
||||
self._toxes = toxes
|
||||
self._path = path
|
||||
self._directory = os.path.dirname(path)
|
||||
@ -38,7 +37,7 @@ class ProfileManager:
|
||||
fl.write(data)
|
||||
print('Profile saved successfully')
|
||||
|
||||
def export_profile(self, new_path, use_new_path):
|
||||
def export_profile(self, settings, new_path, use_new_path):
|
||||
path = new_path + os.path.basename(self._path)
|
||||
with open(self._path, 'rb') as fin:
|
||||
data = fin.read()
|
||||
@ -49,7 +48,7 @@ class ProfileManager:
|
||||
if use_new_path:
|
||||
self._path = new_path + os.path.basename(self._path)
|
||||
self._directory = new_path
|
||||
self._settings.update_path(new_path)
|
||||
settings.update_path(new_path)
|
||||
|
||||
@staticmethod
|
||||
def find_profiles():
|
||||
|
Loading…
Reference in New Issue
Block a user