From 03d3983d83f3553b1207daed2c940f8a805d61b2 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Mon, 14 Mar 2016 22:30:51 +0300 Subject: [PATCH] some network menu updates --- src/main.py | 8 ++++---- src/menu.py | 17 ++++++++++++++--- src/profile.py | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/main.py b/src/main.py index 0d8d80f..20e50ef 100644 --- a/src/main.py +++ b/src/main.py @@ -9,7 +9,7 @@ from bootstrap import node_generator from util import curr_directory, get_style -class login(object): +class Login(object): def __init__(self, arr): self.arr = arr @@ -33,7 +33,7 @@ class login(object): def main(): """ - main function of app. loads loginscreen if needed and starts mainscreen + main function of app. loads login screen if needed and starts main screen """ app = QtGui.QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(curr_directory() + '/images/icon.png')) @@ -44,7 +44,7 @@ def main(): ls.setWindowIconText("Toxygen") profiles = ProfileHelper.find_profiles() ls.update_select(map(lambda x: x[1], profiles)) - _login = login(profiles) + _login = Login(profiles) ls.update_on_close(_login.login_screen_close) ls.show() app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), app, QtCore.SLOT("quit()")) @@ -120,5 +120,5 @@ class ToxIterateThread(QtCore.QThread): if __name__ == '__main__': - # TODO: add command line options (example: portable, multiprofile) + # TODO: add command line options main() diff --git a/src/menu.py b/src/menu.py index 87dcc73..e864d0a 100644 --- a/src/menu.py +++ b/src/menu.py @@ -238,9 +238,20 @@ class NetworkSettings(CenteredWidget): def closeEvent(self, *args, **kwargs): settings = Settings.get_instance() - old_data = str(settings['ipv6_enabled']) + str(settings['udp_enabled']) + str(settings['proxy_type']) - - # check if proxy data changed and recreate tox instance + old_data = str(settings['ipv6_enabled']) + str(settings['udp_enabled']) + str(bool(settings['proxy_type'])) + new_data = str(self.ipv.isChecked()) + str(self.udp.isChecked()) + str(self.proxy.isChecked()) + changed = old_data != new_data + if self.proxy.isChecked() and (self.proxyip.text() != settings['proxy_host'] or self.proxyport.text() != settings['proxy_port']): + changed = True + if changed: + settings['ipv6_enabled'] = self.ipv.isChecked() + settings['udp_enabled'] = self.udp.isChecked() + settings['proxy_type'] = int(self.proxy.isChecked()) + settings['proxy_host'] = self.proxyip.text() + settings['proxy_port'] = self.proxyport.text() + settings.save() + # recreate tox instance + Profile.get_instance().reset() class PrivacySettings(CenteredWidget): diff --git a/src/profile.py b/src/profile.py index b0e8bc6..94470cd 100644 --- a/src/profile.py +++ b/src/profile.py @@ -449,6 +449,7 @@ class Profile(Contact, Singleton): if friend_num == self.get_active_number(): # add message to list user_name = Profile.get_instance().get_active_name() self.create_message_item(message.decode('utf-8'), curr_time(), user_name, message_type) + self._messages.scrollToBottom() self._friends[self._active_friend].append_message((message, MESSAGE_OWNER['FRIEND'], time.time(), @@ -477,6 +478,7 @@ class Profile(Contact, Singleton): self.tox.friend_send_message(friend.number, message_type, text.encode('utf-8')) self.create_message_item(text, curr_time(), self._name, message_type) self.screen.messageEdit.clear() + self._messages.scrollToBottom() friend.append_message((text, MESSAGE_OWNER['ME'], int(time.time()), @@ -631,6 +633,19 @@ class Profile(Contact, Singleton): except Exception as ex: # something is wrong log('Accept friend request failed! ' + str(ex)) + # ----------------------------------------------------------------------------------------------------------------- + # Reset + # ----------------------------------------------------------------------------------------------------------------- + + def reset(self): + """ + Recreate tox instance + """ + print 'In reset' + data = self.tox.get_savedata() + ProfileHelper.save_profile(data) + # TODO: recreate tox + def tox_factory(data=None, settings=None): """