Adds autoconnect settings in tor settings tab

This commit is contained in:
Saptak S 2021-12-03 19:02:41 +05:30
parent bbdfea218e
commit 51e49c01f1
No known key found for this signature in database
GPG Key ID: 7B7F1772C0C6FCBF

View File

@ -303,6 +303,24 @@ class TorSettingsTab(QtWidgets.QWidget):
) )
connection_type_radio_group.setLayout(connection_type_radio_group_layout) 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) # 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 = QtWidgets.QVBoxLayout()
connection_type_bridges_radio_group_layout.addWidget(self.bridges) connection_type_bridges_radio_group_layout.addWidget(self.bridges)
@ -322,7 +340,7 @@ class TorSettingsTab(QtWidgets.QWidget):
# Settings are in columns # Settings are in columns
columns_layout = QtWidgets.QHBoxLayout() columns_layout = QtWidgets.QHBoxLayout()
columns_layout.addWidget(connection_type_radio_group) columns_layout.addWidget(left_column_setting_widget)
columns_layout.addSpacing(20) columns_layout.addSpacing(20)
columns_layout.addLayout(connection_type_layout, stretch=1) columns_layout.addLayout(connection_type_layout, stretch=1)
columns_wrapper = QtWidgets.QWidget() columns_wrapper = QtWidgets.QWidget()
@ -477,6 +495,12 @@ class TorSettingsTab(QtWidgets.QWidget):
self.bridge_use_checkbox.setCheckState(QtCore.Qt.Unchecked) self.bridge_use_checkbox.setCheckState(QtCore.Qt.Unchecked)
self.bridge_settings.hide() 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): def active_tabs_changed(self, are_tabs_active):
if are_tabs_active: if are_tabs_active:
self.main_widget.hide() self.main_widget.hide()
@ -777,6 +801,9 @@ class TorSettingsTab(QtWidgets.QWidget):
settings = Settings(self.common) settings = Settings(self.common)
settings.load() # To get the last update timestamp settings.load() # To get the last update timestamp
# autoconnect
settings.set("auto_connect", self.autoconnect_checkbox.isChecked())
# Tor connection # Tor connection
if self.connection_type_bundled_radio.isChecked(): if self.connection_type_bundled_radio.isChecked():
settings.set("connection_type", "bundled") settings.set("connection_type", "bundled")