fixes for messaging, contacts filtering etc

This commit is contained in:
ingvar1995 2018-08-11 00:30:33 +03:00
parent 4ecf666b2f
commit 85ea9ab6e8
7 changed files with 27 additions and 21 deletions

View File

@ -134,7 +134,8 @@ class App:
def _load_login_screen_translations(self):
current_language, supported_languages = self._get_languages()
if current_language in supported_languages:
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)
@ -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:

View File

@ -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
@ -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):

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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())

View File

@ -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():