From e88090ff17545c4f014e01bdaa5359d5af1cfa41 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 16 Apr 2016 11:54:29 +0300 Subject: [PATCH] force reconnection button and bug fixes --- src/mainscreen.py | 1 + src/menu.py | 11 ++++++++++- src/settings.py | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mainscreen.py b/src/mainscreen.py index 2e76342..ce2cab4 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -269,6 +269,7 @@ class MainWindow(QtGui.QMainWindow): def closeEvent(self, *args, **kwargs): self.profile.save_history() + QtGui.QApplication.closeAllWindows() # ----------------------------------------------------------------------------------------------------------------- # Functions which called when user click in menu diff --git a/src/menu.py b/src/menu.py index 20174f6..344cfad 100644 --- a/src/menu.py +++ b/src/menu.py @@ -184,6 +184,7 @@ class NetworkSettings(CenteredWidget): def __init__(self, reset): super(NetworkSettings, self).__init__() self.reset = reset + self.reconnect = False self.initUI() def initUI(self): @@ -213,6 +214,9 @@ class NetworkSettings(CenteredWidget): self.label_2 = QtGui.QLabel(self) self.label_2.setGeometry(QtCore.QRect(40, 190, 66, 17)) self.label_2.setObjectName("label_2") + self.reconnect = QtGui.QPushButton(self) + self.reconnect.setGeometry(QtCore.QRect(40, 260, 200, 30)) + self.reconnect.clicked.connect(self.restart_core) settings = Settings.get_instance() self.ipv.setChecked(settings['ipv6_enabled']) self.udp.setChecked(settings['udp_enabled']) @@ -229,6 +233,7 @@ class NetworkSettings(CenteredWidget): self.proxy.setText(QtGui.QApplication.translate("Form", "Proxy", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("Form", "IP:", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("Form", "Port:", None, QtGui.QApplication.UnicodeUTF8)) + self.reconnect.setText(QtGui.QApplication.translate("NetworkSettings", "Restart TOX core", None, QtGui.QApplication.UnicodeUTF8)) def closeEvent(self, *args, **kwargs): settings = Settings.get_instance() @@ -237,7 +242,7 @@ class NetworkSettings(CenteredWidget): changed = old_data != new_data if self.proxy.isChecked() and (self.proxyip.text() != settings['proxy_host'] or self.proxyport.text() != unicode(settings['proxy_port'])): changed = True - if changed: + if changed or self.reconnect: settings['ipv6_enabled'] = self.ipv.isChecked() settings['udp_enabled'] = self.udp.isChecked() settings['proxy_type'] = int(self.proxy.isChecked()) @@ -247,6 +252,10 @@ class NetworkSettings(CenteredWidget): # recreate tox instance Profile.get_instance().reset(self.reset) + def restart_core(self): + self.reconnect = True + self.close() + class PrivacySettings(CenteredWidget): """Privacy settings form: history, typing notifications""" diff --git a/src/settings.py b/src/settings.py index 6a1f333..151b521 100644 --- a/src/settings.py +++ b/src/settings.py @@ -80,7 +80,10 @@ class Settings(Singleton, dict): with open(path) as fl: data = fl.read() app_settings = json.loads(data) - app_settings['active_profile'].remove(unicode(ProfileHelper.get_path() + self.name + '.tox')) + try: + app_settings['active_profile'].remove(unicode(ProfileHelper.get_path() + self.name + '.tox')) + except: + pass data = json.dumps(app_settings) with open(path, 'w') as fl: fl.write(data)