mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-26 07:49:48 -05:00
Get/set tab settings using a getter and setter function
This commit is contained in:
parent
f2d4bddc23
commit
2984577f28
@ -137,34 +137,34 @@ class ModeSettings(QtWidgets.QWidget):
|
||||
self.client_auth_checkbox.hide()
|
||||
|
||||
def persistent_checkbox_clicked(self):
|
||||
self.tab.tab_settings["persistent"][
|
||||
"enabled"
|
||||
] = self.persistent_checkbox.isChecked()
|
||||
self.tab.set_tab_setting(
|
||||
"persistent", "enabled", self.persistent_checkbox.isChecked()
|
||||
)
|
||||
|
||||
self.change_persistent.emit(
|
||||
self.tab.tab_id, self.persistent_checkbox.isChecked()
|
||||
)
|
||||
|
||||
def public_checkbox_clicked(self):
|
||||
self.tab.tab_settings["general"]["public"] = self.public_checkbox.isChecked()
|
||||
self.tab.set_tab_setting("general", "public", self.public_checkbox.isChecked())
|
||||
|
||||
def autostart_timer_checkbox_clicked(self):
|
||||
self.tab.tab_settings["general"][
|
||||
"autostart_timer"
|
||||
] = self.autostart_timer_checkbox.isChecked()
|
||||
self.tab.set_tab_setting(
|
||||
"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()
|
||||
self.tab.set_tab_setting(
|
||||
"general", "autostop_timer", self.autostop_timer_checkbox.isChecked()
|
||||
)
|
||||
|
||||
def legacy_checkbox_clicked(self):
|
||||
self.tab.tab_settings["general"]["legacy"] = self.legacy_checkbox.isChecked()
|
||||
self.tab.set_tab_setting("general", "legacy", self.legacy_checkbox.isChecked())
|
||||
|
||||
def client_auth_checkbox_clicked(self):
|
||||
self.tab.tab_settings["general"][
|
||||
"client_auth"
|
||||
] = self.client_auth_checkbox.isChecked()
|
||||
self.tab.set_tab_setting(
|
||||
"general", "client_auth", self.client_auth_checkbox.isChecked()
|
||||
)
|
||||
|
||||
def toggle_advanced_clicked(self):
|
||||
if self.advanced_widget.isVisible():
|
||||
|
@ -140,7 +140,7 @@ class ReceiveMode(Mode):
|
||||
f"selected dir: {selected_dir}",
|
||||
)
|
||||
self.data_dir_lineedit.setText(selected_dir)
|
||||
self.tab.tab_settings["receive"]["data_dir"] = data_dir
|
||||
self.tab.set_tab_setting("receive", "data_dir", data_dir)
|
||||
|
||||
def get_stop_server_autostop_timer_text(self):
|
||||
"""
|
||||
|
@ -157,9 +157,9 @@ class ShareMode(Mode):
|
||||
"""
|
||||
Save autostop sharing setting to the tab settings
|
||||
"""
|
||||
self.tab.tab_settings["share"][
|
||||
"autostop_sharing"
|
||||
] = self.autostop_sharing_checkbox.isChecked()
|
||||
self.tab.set_tab_setting(
|
||||
"share", "autostop_sharing", self.autostop_sharing_checkbox.isChecked()
|
||||
)
|
||||
|
||||
def get_stop_server_autostop_timer_text(self):
|
||||
"""
|
||||
@ -309,7 +309,7 @@ class ShareMode(Mode):
|
||||
self.history.update_in_progress()
|
||||
|
||||
# Close on finish?
|
||||
if self.common.settings.get("close_after_first_download"):
|
||||
if self.tab.tab_settings["share"]["autostop_sharing"]:
|
||||
self.server_status.stop_server()
|
||||
self.status_bar.clearMessage()
|
||||
self.server_status_label.setText(strings._("closing_automatically"))
|
||||
|
@ -155,9 +155,9 @@ class WebsiteMode(Mode):
|
||||
"""
|
||||
Save disable CSP setting to the tab settings
|
||||
"""
|
||||
self.tab.tab_settings["website"][
|
||||
"disable_csp"
|
||||
] = self.disable_csp_checkbox.isChecked()
|
||||
self.tab.set_tab_setting(
|
||||
"website", "disable_csp", self.disable_csp_checkbox.isChecked()
|
||||
)
|
||||
|
||||
def get_stop_server_autostop_timer_text(self):
|
||||
"""
|
||||
|
@ -118,6 +118,17 @@ class Tab(QtWidgets.QWidget):
|
||||
self.timer = QtCore.QTimer()
|
||||
self.timer.timeout.connect(self.timer_callback)
|
||||
|
||||
# Persistent image
|
||||
self.persistent_image_label = QtWidgets.QLabel()
|
||||
self.persistent_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(
|
||||
QtGui.QImage(
|
||||
self.common.get_resource_path("images/persistent_enabled.png")
|
||||
)
|
||||
)
|
||||
)
|
||||
self.persistent_image_label.setFixedSize(30, 30)
|
||||
|
||||
# Settings for this tab
|
||||
self.tab_settings = {
|
||||
"persistent": {
|
||||
@ -138,16 +149,11 @@ class Tab(QtWidgets.QWidget):
|
||||
"website": {"disable_csp": False},
|
||||
}
|
||||
|
||||
# Persistent image
|
||||
self.persistent_image_label = QtWidgets.QLabel()
|
||||
self.persistent_image_label.setPixmap(
|
||||
QtGui.QPixmap.fromImage(
|
||||
QtGui.QImage(
|
||||
self.common.get_resource_path("images/persistent_enabled.png")
|
||||
)
|
||||
)
|
||||
)
|
||||
self.persistent_image_label.setFixedSize(30, 30)
|
||||
def get_tab_setting(self, group, key):
|
||||
return self.tab_settings[group][key]
|
||||
|
||||
def set_tab_setting(self, group, key, val):
|
||||
self.tab_settings[group][key] = val
|
||||
|
||||
def share_mode_clicked(self):
|
||||
self.common.log("Tab", "share_mode_clicked")
|
||||
|
Loading…
Reference in New Issue
Block a user