mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-11 02:45:03 -04:00
When any setting is changed, update the tab settings dict
This commit is contained in:
parent
bfcb28a327
commit
bfd8c4aae6
5 changed files with 57 additions and 3 deletions
|
@ -24,7 +24,7 @@ from onionshare import strings
|
||||||
|
|
||||||
class ModeSettings(QtWidgets.QWidget):
|
class ModeSettings(QtWidgets.QWidget):
|
||||||
"""
|
"""
|
||||||
A settings widget
|
All of the common settings for each mode are in this widget
|
||||||
"""
|
"""
|
||||||
|
|
||||||
change_persistent = QtCore.pyqtSignal(int, bool)
|
change_persistent = QtCore.pyqtSignal(int, bool)
|
||||||
|
@ -45,11 +45,15 @@ class ModeSettings(QtWidgets.QWidget):
|
||||||
|
|
||||||
# Public
|
# Public
|
||||||
self.public_checkbox = QtWidgets.QCheckBox()
|
self.public_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.public_checkbox.clicked.connect(self.public_checkbox_clicked)
|
||||||
self.public_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.public_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.public_checkbox.setText(strings._("mode_settings_public_checkbox"))
|
self.public_checkbox.setText(strings._("mode_settings_public_checkbox"))
|
||||||
|
|
||||||
# Whether or not to use an auto-start timer
|
# Whether or not to use an auto-start timer
|
||||||
self.autostart_timer_checkbox = QtWidgets.QCheckBox()
|
self.autostart_timer_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.autostart_timer_checkbox.clicked.connect(
|
||||||
|
self.autostart_timer_checkbox_clicked
|
||||||
|
)
|
||||||
self.autostart_timer_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.autostart_timer_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.autostart_timer_checkbox.setText(
|
self.autostart_timer_checkbox.setText(
|
||||||
strings._("mode_settings_autostart_timer_checkbox")
|
strings._("mode_settings_autostart_timer_checkbox")
|
||||||
|
@ -57,6 +61,9 @@ class ModeSettings(QtWidgets.QWidget):
|
||||||
|
|
||||||
# Whether or not to use an auto-stop timer
|
# Whether or not to use an auto-stop timer
|
||||||
self.autostop_timer_checkbox = QtWidgets.QCheckBox()
|
self.autostop_timer_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.autostop_timer_checkbox.clicked.connect(
|
||||||
|
self.autostop_timer_checkbox_clicked
|
||||||
|
)
|
||||||
self.autostop_timer_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.autostop_timer_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.autostop_timer_checkbox.setText(
|
self.autostop_timer_checkbox.setText(
|
||||||
strings._("mode_settings_autostop_timer_checkbox")
|
strings._("mode_settings_autostop_timer_checkbox")
|
||||||
|
@ -64,12 +71,14 @@ class ModeSettings(QtWidgets.QWidget):
|
||||||
|
|
||||||
# Legacy address
|
# Legacy address
|
||||||
self.legacy_checkbox = QtWidgets.QCheckBox()
|
self.legacy_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.legacy_checkbox.clicked.connect(self.legacy_checkbox_clicked)
|
||||||
self.legacy_checkbox.clicked.connect(self.update_ui)
|
self.legacy_checkbox.clicked.connect(self.update_ui)
|
||||||
self.legacy_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.legacy_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.legacy_checkbox.setText(strings._("mode_settings_legacy_checkbox"))
|
self.legacy_checkbox.setText(strings._("mode_settings_legacy_checkbox"))
|
||||||
|
|
||||||
# Client auth
|
# Client auth
|
||||||
self.client_auth_checkbox = QtWidgets.QCheckBox()
|
self.client_auth_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.client_auth_checkbox.clicked.connect(self.client_auth_checkbox_clicked)
|
||||||
self.client_auth_checkbox.clicked.connect(self.update_ui)
|
self.client_auth_checkbox.clicked.connect(self.update_ui)
|
||||||
self.client_auth_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.client_auth_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.client_auth_checkbox.setText(
|
self.client_auth_checkbox.setText(
|
||||||
|
@ -136,6 +145,27 @@ class ModeSettings(QtWidgets.QWidget):
|
||||||
self.tab.tab_id, self.persistent_checkbox.isChecked()
|
self.tab.tab_id, self.persistent_checkbox.isChecked()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def public_checkbox_clicked(self):
|
||||||
|
self.tab.tab_settings["general"]["public"] = self.public_checkbox.isChecked()
|
||||||
|
|
||||||
|
def autostart_timer_checkbox_clicked(self):
|
||||||
|
self.tab.tab_settings["general"][
|
||||||
|
"autostart_timer"
|
||||||
|
] = self.autostart_timer_checkbox.isChecked()
|
||||||
|
|
||||||
|
def autostop_timer_checkbox_clicked(self):
|
||||||
|
self.tab.tab_settings["general"][
|
||||||
|
"autostop_timer"
|
||||||
|
] = self.autostop_timer_checkbox.isChecked()
|
||||||
|
|
||||||
|
def legacy_checkbox_clicked(self):
|
||||||
|
self.tab.tab_settings["general"]["legacy"] = self.legacy_checkbox.isChecked()
|
||||||
|
|
||||||
|
def client_auth_checkbox_clicked(self):
|
||||||
|
self.tab.tab_settings["general"][
|
||||||
|
"client_auth"
|
||||||
|
] = self.client_auth_checkbox.isChecked()
|
||||||
|
|
||||||
def toggle_advanced_clicked(self):
|
def toggle_advanced_clicked(self):
|
||||||
if self.advanced_widget.isVisible():
|
if self.advanced_widget.isVisible():
|
||||||
self.advanced_widget.hide()
|
self.advanced_widget.hide()
|
||||||
|
|
|
@ -41,6 +41,7 @@ class ReceiveMode(Mode):
|
||||||
# Header
|
# Header
|
||||||
self.header_label.setText(strings._("gui_new_tab_receive_button"))
|
self.header_label.setText(strings._("gui_new_tab_receive_button"))
|
||||||
|
|
||||||
|
# Settings
|
||||||
data_dir_label = QtWidgets.QLabel(
|
data_dir_label = QtWidgets.QLabel(
|
||||||
strings._("mode_settings_receive_data_dir_label")
|
strings._("mode_settings_receive_data_dir_label")
|
||||||
)
|
)
|
||||||
|
@ -125,7 +126,7 @@ class ReceiveMode(Mode):
|
||||||
|
|
||||||
def data_dir_button_clicked(self):
|
def data_dir_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
Browse for a new OnionShare data directory
|
Browse for a new OnionShare data directory, and save to tab settings
|
||||||
"""
|
"""
|
||||||
data_dir = self.data_dir_lineedit.text()
|
data_dir = self.data_dir_lineedit.text()
|
||||||
selected_dir = QtWidgets.QFileDialog.getExistingDirectory(
|
selected_dir = QtWidgets.QFileDialog.getExistingDirectory(
|
||||||
|
@ -139,6 +140,7 @@ class ReceiveMode(Mode):
|
||||||
f"selected dir: {selected_dir}",
|
f"selected dir: {selected_dir}",
|
||||||
)
|
)
|
||||||
self.data_dir_lineedit.setText(selected_dir)
|
self.data_dir_lineedit.setText(selected_dir)
|
||||||
|
self.tab.tab_settings["receive"]["data_dir"] = data_dir
|
||||||
|
|
||||||
def get_stop_server_autostop_timer_text(self):
|
def get_stop_server_autostop_timer_text(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -50,7 +50,11 @@ class ShareMode(Mode):
|
||||||
# Header
|
# Header
|
||||||
self.header_label.setText(strings._("gui_new_tab_share_button"))
|
self.header_label.setText(strings._("gui_new_tab_share_button"))
|
||||||
|
|
||||||
|
# Settings
|
||||||
self.autostop_sharing_checkbox = QtWidgets.QCheckBox()
|
self.autostop_sharing_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.autostop_sharing_checkbox.clicked.connect(
|
||||||
|
self.autostop_sharing_checkbox_clicked
|
||||||
|
)
|
||||||
self.autostop_sharing_checkbox.setCheckState(QtCore.Qt.Checked)
|
self.autostop_sharing_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||||
self.autostop_sharing_checkbox.setText(
|
self.autostop_sharing_checkbox.setText(
|
||||||
strings._("mode_settings_share_autostop_sharing_checkbox")
|
strings._("mode_settings_share_autostop_sharing_checkbox")
|
||||||
|
@ -149,6 +153,14 @@ class ShareMode(Mode):
|
||||||
# Always start with focus on file selection
|
# Always start with focus on file selection
|
||||||
self.file_selection.setFocus()
|
self.file_selection.setFocus()
|
||||||
|
|
||||||
|
def autostop_sharing_checkbox_clicked(self):
|
||||||
|
"""
|
||||||
|
Save autostop sharing setting to the tab settings
|
||||||
|
"""
|
||||||
|
self.tab.tab_settings["share"][
|
||||||
|
"autostop_sharing"
|
||||||
|
] = self.autostop_sharing_checkbox.isChecked()
|
||||||
|
|
||||||
def get_stop_server_autostop_timer_text(self):
|
def get_stop_server_autostop_timer_text(self):
|
||||||
"""
|
"""
|
||||||
Return the string to put on the stop server button, if there's an auto-stop timer
|
Return the string to put on the stop server button, if there's an auto-stop timer
|
||||||
|
|
|
@ -52,7 +52,9 @@ class WebsiteMode(Mode):
|
||||||
# Header
|
# Header
|
||||||
self.header_label.setText(strings._("gui_new_tab_website_button"))
|
self.header_label.setText(strings._("gui_new_tab_website_button"))
|
||||||
|
|
||||||
|
# Settings
|
||||||
self.disable_csp_checkbox = QtWidgets.QCheckBox()
|
self.disable_csp_checkbox = QtWidgets.QCheckBox()
|
||||||
|
self.disable_csp_checkbox.clicked.connect(self.disable_csp_checkbox_clicked)
|
||||||
self.disable_csp_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.disable_csp_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.disable_csp_checkbox.setText(
|
self.disable_csp_checkbox.setText(
|
||||||
strings._("mode_settings_website_disable_csp_checkbox")
|
strings._("mode_settings_website_disable_csp_checkbox")
|
||||||
|
@ -149,6 +151,14 @@ class WebsiteMode(Mode):
|
||||||
# Always start with focus on file selection
|
# Always start with focus on file selection
|
||||||
self.file_selection.setFocus()
|
self.file_selection.setFocus()
|
||||||
|
|
||||||
|
def disable_csp_checkbox_clicked(self):
|
||||||
|
"""
|
||||||
|
Save disable CSP setting to the tab settings
|
||||||
|
"""
|
||||||
|
self.tab.tab_settings["website"][
|
||||||
|
"disable_csp"
|
||||||
|
] = self.disable_csp_checkbox.isChecked()
|
||||||
|
|
||||||
def get_stop_server_autostop_timer_text(self):
|
def get_stop_server_autostop_timer_text(self):
|
||||||
"""
|
"""
|
||||||
Return the string to put on the stop server button, if there's an auto-stop timer
|
Return the string to put on the stop server button, if there's an auto-stop timer
|
||||||
|
|
|
@ -130,7 +130,7 @@ class Tab(QtWidgets.QWidget):
|
||||||
"public": False,
|
"public": False,
|
||||||
"autostart_timer": False,
|
"autostart_timer": False,
|
||||||
"autostop_timer": False,
|
"autostop_timer": False,
|
||||||
"legacy_addresses": False,
|
"legacy": False,
|
||||||
"client_auth": False,
|
"client_auth": False,
|
||||||
},
|
},
|
||||||
"share": {"autostop_sharing": True},
|
"share": {"autostop_sharing": True},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue