mirror of
https://github.com/onionshare/onionshare.git
synced 2025-03-30 09:28:06 -04:00
Make it possible to automatically start a persistent share when OnionShare starts
This commit is contained in:
parent
6e05ee4426
commit
9a5bd1f177
@ -40,7 +40,11 @@ class ModeSettings:
|
||||
"client_auth_priv_key": None,
|
||||
"client_auth_pub_key": None,
|
||||
},
|
||||
"persistent": {"mode": None, "enabled": False},
|
||||
"persistent": {
|
||||
"mode": None,
|
||||
"enabled": False,
|
||||
"autostart_on_launch": False
|
||||
},
|
||||
"general": {
|
||||
"title": None,
|
||||
"public": False,
|
||||
|
@ -214,7 +214,8 @@
|
||||
"mode_settings_advanced_toggle_show": "Show advanced settings",
|
||||
"mode_settings_advanced_toggle_hide": "Hide advanced settings",
|
||||
"mode_settings_title_label": "Custom title",
|
||||
"mode_settings_persistent_checkbox": "Always open this tab when OnionShare is started",
|
||||
"mode_settings_persistent_checkbox": "Always open this tab when OnionShare is started (the onion address will stay the same)",
|
||||
"mode_settings_persistent_autostart_on_launch_checkbox": "Automatically start this onion service when OnionShare starts",
|
||||
"mode_settings_public_checkbox": "This is a public OnionShare service (disables private key)",
|
||||
"mode_settings_autostart_timer_checkbox": "Start onion service at scheduled time",
|
||||
"mode_settings_autostop_timer_checkbox": "Stop onion service at scheduled time",
|
||||
|
@ -568,6 +568,8 @@ class Mode(QtWidgets.QWidget):
|
||||
self.primary_action.show()
|
||||
if not self.tab.timer.isActive():
|
||||
self.tab.timer.start(500)
|
||||
if self.settings.get("persistent", "enabled") and self.settings.get("persistent", "autostart_on_launch"):
|
||||
self.server_status.start_server()
|
||||
|
||||
def tor_connection_stopped(self):
|
||||
"""
|
||||
|
@ -39,14 +39,24 @@ class ModeSettingsWidget(QtWidgets.QScrollArea):
|
||||
# Downstream Mode need to fill in this layout with its settings
|
||||
self.mode_specific_layout = QtWidgets.QVBoxLayout()
|
||||
|
||||
self.persistent_autostart_on_launch_checkbox = QtWidgets.QCheckBox()
|
||||
self.persistent_autostart_on_launch_checkbox.clicked.connect(self.persistent_autostart_on_launch_checkbox_clicked)
|
||||
self.persistent_autostart_on_launch_checkbox.setText(strings._("mode_settings_persistent_autostart_on_launch_checkbox"))
|
||||
if self.settings.get("persistent", "autostart_on_launch"):
|
||||
self.persistent_autostart_on_launch_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||
else:
|
||||
self.persistent_autostart_on_launch_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||
|
||||
# Persistent
|
||||
self.persistent_checkbox = QtWidgets.QCheckBox()
|
||||
self.persistent_checkbox.clicked.connect(self.persistent_checkbox_clicked)
|
||||
self.persistent_checkbox.setText(strings._("mode_settings_persistent_checkbox"))
|
||||
if self.settings.get("persistent", "enabled"):
|
||||
self.persistent_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||
self.persistent_autostart_on_launch_checkbox.show()
|
||||
else:
|
||||
self.persistent_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||
self.persistent_autostart_on_launch_checkbox.hide()
|
||||
|
||||
# Public
|
||||
self.public_checkbox = QtWidgets.QCheckBox()
|
||||
@ -150,6 +160,7 @@ class ModeSettingsWidget(QtWidgets.QScrollArea):
|
||||
layout = QtWidgets.QVBoxLayout()
|
||||
layout.addLayout(self.mode_specific_layout)
|
||||
layout.addWidget(self.persistent_checkbox)
|
||||
layout.addWidget(self.persistent_autostart_on_launch_checkbox)
|
||||
layout.addWidget(self.public_checkbox)
|
||||
layout.addWidget(self.advanced_widget)
|
||||
layout.addWidget(self.toggle_advanced_button)
|
||||
@ -206,6 +217,7 @@ class ModeSettingsWidget(QtWidgets.QScrollArea):
|
||||
def persistent_checkbox_clicked(self):
|
||||
self.settings.set("persistent", "enabled", self.persistent_checkbox.isChecked())
|
||||
self.settings.set("persistent", "mode", self.tab.mode)
|
||||
self.settings.set("persistent", "autostart_on_launch", self.persistent_autostart_on_launch_checkbox.isChecked())
|
||||
self.change_persistent.emit(
|
||||
self.tab.tab_id, self.persistent_checkbox.isChecked()
|
||||
)
|
||||
@ -213,6 +225,12 @@ class ModeSettingsWidget(QtWidgets.QScrollArea):
|
||||
# If disabling persistence, delete the file from disk
|
||||
if not self.persistent_checkbox.isChecked():
|
||||
self.settings.delete()
|
||||
self.persistent_autostart_on_launch_checkbox.hide()
|
||||
else:
|
||||
self.persistent_autostart_on_launch_checkbox.show()
|
||||
|
||||
def persistent_autostart_on_launch_checkbox_clicked(self):
|
||||
self.settings.set("persistent", "autostart_on_launch", self.persistent_autostart_on_launch_checkbox.isChecked())
|
||||
|
||||
def public_checkbox_clicked(self):
|
||||
self.settings.set("general", "public", self.public_checkbox.isChecked())
|
||||
|
Loading…
x
Reference in New Issue
Block a user