Reload Settings whenever the settings get saved in SettingsDialog

This commit is contained in:
Micah Lee 2017-05-22 17:08:05 -07:00
parent e626a410f3
commit 5846b06478
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 13 additions and 4 deletions

View File

@ -206,7 +206,15 @@ class OnionShareGui(QtWidgets.QMainWindow):
"""
Open the SettingsDialog.
"""
SettingsDialog(self.onion, self.qtapp)
common.log('OnionShareGui', 'open_settings')
def reload_settings():
common.log('OnionShareGui', 'open_settings', 'settings have changed, reloading')
self.settings.load()
d = SettingsDialog(self.onion, self.qtapp)
d.settings_saved.connect(reload_settings)
d.exec_()
def start_server(self):
"""

View File

@ -32,6 +32,8 @@ class SettingsDialog(QtWidgets.QDialog):
"""
Settings dialog.
"""
settings_saved = QtCore.pyqtSignal()
def __init__(self, onion, qtapp):
super(SettingsDialog, self).__init__()
common.log('SettingsDialog', '__init__')
@ -312,9 +314,6 @@ class SettingsDialog(QtWidgets.QDialog):
self.authenticate_password_radio.setChecked(True)
self.authenticate_password_extras_password.setText(self.old_settings.get('auth_password'))
# Show the dialog
self.exec_()
def connection_type_bundled_toggled(self, checked):
"""
Connection type bundled was toggled. If checked, hide authentication fields.
@ -493,9 +492,11 @@ class SettingsDialog(QtWidgets.QDialog):
common.log('SettingsDialog', 'save_clicked', 'Onion done rebooting, connected to Tor: {}'.format(self.onion.connected_to_tor))
if self.onion.connected_to_tor and not tor_con.wasCanceled():
self.settings_saved.emit()
self.close()
else:
self.settings_saved.emit()
self.close()
def cancel_clicked(self):