From 5846b06478994caa71b1fffe43574a27ef064563 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 22 May 2017 17:08:05 -0700 Subject: [PATCH] Reload Settings whenever the settings get saved in SettingsDialog --- onionshare_gui/onionshare_gui.py | 10 +++++++++- onionshare_gui/settings_dialog.py | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index ffcb1202..46356e2b 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -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): """ diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index f2a80272..71fc277a 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -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):