From 51e49c01f1a32753efc3de74953ffcc0260d5b15 Mon Sep 17 00:00:00 2001 From: Saptak S Date: Fri, 3 Dec 2021 19:02:41 +0530 Subject: [PATCH] Adds autoconnect settings in tor settings tab --- desktop/src/onionshare/tor_settings_tab.py | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/desktop/src/onionshare/tor_settings_tab.py b/desktop/src/onionshare/tor_settings_tab.py index e28e5260..76957a8e 100644 --- a/desktop/src/onionshare/tor_settings_tab.py +++ b/desktop/src/onionshare/tor_settings_tab.py @@ -303,6 +303,24 @@ class TorSettingsTab(QtWidgets.QWidget): ) connection_type_radio_group.setLayout(connection_type_radio_group_layout) + # Quickstart settings + self.autoconnect_checkbox = QtWidgets.QCheckBox( + strings._("gui_enable_autoconnect_checkbox") + ) + self.autoconnect_checkbox.toggled.connect( + self.autoconnect_toggled + ) + left_column_settings = QtWidgets.QVBoxLayout() + connection_type_radio_group.setFixedHeight(300) + left_column_settings.addWidget(connection_type_radio_group) + left_column_settings.addSpacing(20) + left_column_settings.addWidget(self.autoconnect_checkbox) + left_column_settings.addStretch() + left_column_settings.setContentsMargins(0, 0, 0, 0) + left_column_setting_widget = QtWidgets.QWidget() + left_column_setting_widget.setLayout(left_column_settings) + + # The Bridges options are not exclusive (enabling Bridges offers obfs4 or custom bridges) connection_type_bridges_radio_group_layout = QtWidgets.QVBoxLayout() connection_type_bridges_radio_group_layout.addWidget(self.bridges) @@ -322,7 +340,7 @@ class TorSettingsTab(QtWidgets.QWidget): # Settings are in columns columns_layout = QtWidgets.QHBoxLayout() - columns_layout.addWidget(connection_type_radio_group) + columns_layout.addWidget(left_column_setting_widget) columns_layout.addSpacing(20) columns_layout.addLayout(connection_type_layout, stretch=1) columns_wrapper = QtWidgets.QWidget() @@ -477,6 +495,12 @@ class TorSettingsTab(QtWidgets.QWidget): self.bridge_use_checkbox.setCheckState(QtCore.Qt.Unchecked) self.bridge_settings.hide() + def autoconnect_toggled(self): + """ + Auto connect checkbox clicked + """ + self.common.log("TorSettingsTab", "autoconnect_checkbox_clicked") + def active_tabs_changed(self, are_tabs_active): if are_tabs_active: self.main_widget.hide() @@ -777,6 +801,9 @@ class TorSettingsTab(QtWidgets.QWidget): settings = Settings(self.common) settings.load() # To get the last update timestamp + # autoconnect + settings.set("auto_connect", self.autoconnect_checkbox.isChecked()) + # Tor connection if self.connection_type_bundled_radio.isChecked(): settings.set("connection_type", "bundled")