From 97a604a4c86f795e29d6bcf6437c45de8ca105f3 Mon Sep 17 00:00:00 2001 From: Saptak S Date: Fri, 3 Dec 2021 19:30:20 +0530 Subject: [PATCH] Shows the Main window before starting to connect to Tor on autoconnect enabled --- desktop/src/onionshare/connection_tab.py | 5 +++++ desktop/src/onionshare/main_window.py | 3 +++ desktop/src/onionshare/tab_widget.py | 4 ++++ desktop/src/onionshare/tor_settings_tab.py | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/desktop/src/onionshare/connection_tab.py b/desktop/src/onionshare/connection_tab.py index 6cdba20d..bb5f72a3 100644 --- a/desktop/src/onionshare/connection_tab.py +++ b/desktop/src/onionshare/connection_tab.py @@ -132,6 +132,11 @@ class AutoConnectTab(QtWidgets.QWidget): self.setLayout(self.layout) + def check_autoconnect(self): + """ + After rendering, check if autoconnect was clicked, then start connecting + """ + self.common.log("AutoConnectTab", "autoconnect_checking") if self.auto_connect_enabled: self.enable_autoconnect_checkbox.setCheckState(QtCore.Qt.Checked) self.connect_clicked() diff --git a/desktop/src/onionshare/main_window.py b/desktop/src/onionshare/main_window.py index 8c38c38d..54fef40c 100644 --- a/desktop/src/onionshare/main_window.py +++ b/desktop/src/onionshare/main_window.py @@ -174,6 +174,9 @@ class MainWindow(QtWidgets.QMainWindow): ) self.close_dialog.setDefaultButton(self.close_dialog.reject_button) + # Check for autoconnect + self.tabs.check_autoconnect_tab() + def tor_connection_canceled(self): """ If the user cancels before Tor finishes connecting, ask if they want to diff --git a/desktop/src/onionshare/tab_widget.py b/desktop/src/onionshare/tab_widget.py index b5c18023..901a2ce0 100644 --- a/desktop/src/onionshare/tab_widget.py +++ b/desktop/src/onionshare/tab_widget.py @@ -168,6 +168,10 @@ class TabWidget(QtWidgets.QTabWidget): self.add_tab() else: self.open_connection_tab() + + def check_autoconnect_tab(self): + if type(self.tabs[0]) is AutoConnectTab: + self.tabs[0].check_autoconnect() def load_tab(self, mode_settings_id): # Load the tab's mode settings diff --git a/desktop/src/onionshare/tor_settings_tab.py b/desktop/src/onionshare/tor_settings_tab.py index 76957a8e..28778365 100644 --- a/desktop/src/onionshare/tor_settings_tab.py +++ b/desktop/src/onionshare/tor_settings_tab.py @@ -409,6 +409,10 @@ class TorSettingsTab(QtWidgets.QWidget): self.old_settings = Settings(self.common) self.old_settings.load() + # Check if autoconnect was enabled + if self.old_settings.get("auto_connect"): + self.autoconnect_checkbox.setCheckState(QtCore.Qt.Checked) + connection_type = self.old_settings.get("connection_type") if connection_type == "bundled": if self.connection_type_bundled_radio.isEnabled():