mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-28 16:59:35 -05:00
Clicking Save in the settings dialog saves settings
This commit is contained in:
parent
c9607cf986
commit
9462b7d05f
@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import platform, os, json
|
||||
|
||||
from . import helpers
|
||||
from . import strings, helpers
|
||||
|
||||
class Settings(object):
|
||||
"""
|
||||
@ -77,8 +77,12 @@ class Settings(object):
|
||||
"""
|
||||
Save settings to file.
|
||||
"""
|
||||
os.mkdirs(os.path.dirname(self.filename))
|
||||
try:
|
||||
os.makedirs(os.path.dirname(self.filename))
|
||||
except:
|
||||
pass
|
||||
open(self.filename, 'w').write(json.dumps(self._settings))
|
||||
print(strings._('settings_saved').format(self.filename))
|
||||
|
||||
def get(self, key):
|
||||
return self._settings[key]
|
||||
|
@ -151,7 +151,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
if connection_type == 'automatic':
|
||||
self.connection_type_automatic_radio.setChecked(True)
|
||||
elif connection_type == 'control_port':
|
||||
self.connect_type_control_port_radio.setChecked(True)
|
||||
self.connection_type_control_port_radio.setChecked(True)
|
||||
elif connection_type == 'socket_file':
|
||||
self.connection_type_socket_file_radio.setChecked(True)
|
||||
self.connection_type_control_port_extras_address.setText(self.settings.get('control_port_address'))
|
||||
@ -238,7 +238,29 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
"""
|
||||
Save button clicked. Save current settings to disk.
|
||||
"""
|
||||
pass
|
||||
if self.connection_type_automatic_radio.isChecked():
|
||||
self.settings.set('connection_type', 'automatic')
|
||||
if self.connection_type_control_port_radio.isChecked():
|
||||
self.settings.set('connection_type', 'control_port')
|
||||
if self.connection_type_socket_file_radio.isChecked():
|
||||
self.settings.set('connection_type', 'socket_file')
|
||||
|
||||
self.settings.set('control_port_address', self.connection_type_control_port_extras_address.text())
|
||||
self.settings.set('control_port_port', self.connection_type_control_port_extras_port.text())
|
||||
self.settings.set('socket_file_path', self.connection_type_socket_file_extras_path.text())
|
||||
|
||||
if self.authenticate_no_auth_radio.isChecked():
|
||||
self.settings.set('auth_type', 'no_auth')
|
||||
if self.authenticate_password_radio.isChecked():
|
||||
self.settings.set('auth_type', 'password')
|
||||
if self.authenticate_cookie_radio.isChecked():
|
||||
self.settings.set('auth_type', 'cookie')
|
||||
|
||||
self.settings.set('auth_password', self.authenticate_password_extras_password.text())
|
||||
self.settings.set('auth_cookie_path', self.authenticate_cookie_extras_cookie_path.text())
|
||||
|
||||
self.settings.save()
|
||||
self.close()
|
||||
|
||||
def cancel_clicked(self):
|
||||
"""
|
||||
|
@ -77,5 +77,6 @@
|
||||
"gui_settings_cookie_label": "Cookie path",
|
||||
"gui_settings_button_test": "Test Settings",
|
||||
"gui_settings_button_save": "Save",
|
||||
"gui_settings_button_cancel": "Cancel"
|
||||
"gui_settings_button_cancel": "Cancel",
|
||||
"settings_saved": "Settings saved to {}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user