force reconnection button and bug fixes

This commit is contained in:
ingvar1995 2016-04-16 11:54:29 +03:00
parent 43a49ca570
commit e88090ff17
3 changed files with 15 additions and 2 deletions

View File

@ -269,6 +269,7 @@ class MainWindow(QtGui.QMainWindow):
def closeEvent(self, *args, **kwargs): def closeEvent(self, *args, **kwargs):
self.profile.save_history() self.profile.save_history()
QtGui.QApplication.closeAllWindows()
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
# Functions which called when user click in menu # Functions which called when user click in menu

View File

@ -184,6 +184,7 @@ class NetworkSettings(CenteredWidget):
def __init__(self, reset): def __init__(self, reset):
super(NetworkSettings, self).__init__() super(NetworkSettings, self).__init__()
self.reset = reset self.reset = reset
self.reconnect = False
self.initUI() self.initUI()
def initUI(self): def initUI(self):
@ -213,6 +214,9 @@ class NetworkSettings(CenteredWidget):
self.label_2 = QtGui.QLabel(self) self.label_2 = QtGui.QLabel(self)
self.label_2.setGeometry(QtCore.QRect(40, 190, 66, 17)) self.label_2.setGeometry(QtCore.QRect(40, 190, 66, 17))
self.label_2.setObjectName("label_2") 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() settings = Settings.get_instance()
self.ipv.setChecked(settings['ipv6_enabled']) self.ipv.setChecked(settings['ipv6_enabled'])
self.udp.setChecked(settings['udp_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.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.setText(QtGui.QApplication.translate("Form", "IP:", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("Form", "Port:", 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): def closeEvent(self, *args, **kwargs):
settings = Settings.get_instance() settings = Settings.get_instance()
@ -237,7 +242,7 @@ class NetworkSettings(CenteredWidget):
changed = old_data != new_data changed = old_data != new_data
if self.proxy.isChecked() and (self.proxyip.text() != settings['proxy_host'] or self.proxyport.text() != unicode(settings['proxy_port'])): if self.proxy.isChecked() and (self.proxyip.text() != settings['proxy_host'] or self.proxyport.text() != unicode(settings['proxy_port'])):
changed = True changed = True
if changed: if changed or self.reconnect:
settings['ipv6_enabled'] = self.ipv.isChecked() settings['ipv6_enabled'] = self.ipv.isChecked()
settings['udp_enabled'] = self.udp.isChecked() settings['udp_enabled'] = self.udp.isChecked()
settings['proxy_type'] = int(self.proxy.isChecked()) settings['proxy_type'] = int(self.proxy.isChecked())
@ -247,6 +252,10 @@ class NetworkSettings(CenteredWidget):
# recreate tox instance # recreate tox instance
Profile.get_instance().reset(self.reset) Profile.get_instance().reset(self.reset)
def restart_core(self):
self.reconnect = True
self.close()
class PrivacySettings(CenteredWidget): class PrivacySettings(CenteredWidget):
"""Privacy settings form: history, typing notifications""" """Privacy settings form: history, typing notifications"""

View File

@ -80,7 +80,10 @@ class Settings(Singleton, dict):
with open(path) as fl: with open(path) as fl:
data = fl.read() data = fl.read()
app_settings = json.loads(data) app_settings = json.loads(data)
try:
app_settings['active_profile'].remove(unicode(ProfileHelper.get_path() + self.name + '.tox')) app_settings['active_profile'].remove(unicode(ProfileHelper.get_path() + self.name + '.tox'))
except:
pass
data = json.dumps(app_settings) data = json.dumps(app_settings)
with open(path, 'w') as fl: with open(path, 'w') as fl:
fl.write(data) fl.write(data)