From 5d8300df100c3a61038c4fffeb33c6abfb0890cb Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Mon, 20 Dec 2021 14:20:32 +1100 Subject: [PATCH] Add 'Try Again' button in AutoConnect bridge options. Update wording. Reset back to bridge/try again options if Tor Cancel clicked again --- desktop/src/onionshare/connection_tab.py | 38 +++++++++++++++++-- desktop/src/onionshare/gui_common.py | 5 +++ .../src/onionshare/resources/locale/en.json | 11 +++--- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/desktop/src/onionshare/connection_tab.py b/desktop/src/onionshare/connection_tab.py index cbb49f6b..fee4d428 100644 --- a/desktop/src/onionshare/connection_tab.py +++ b/desktop/src/onionshare/connection_tab.py @@ -95,6 +95,7 @@ class AutoConnectTab(QtWidgets.QWidget): # Use bridge widget self.use_bridge_widget = AutoConnectUseBridgeWidget(self.common) self.use_bridge_widget.connect_clicked.connect(self.use_bridge_connect_clicked) + self.use_bridge_widget.try_again_clicked.connect(self.first_launch_widget_connect_clicked) self.use_bridge_widget.open_tor_settings.connect(self.open_tor_settings) self.use_bridge_widget.hide() @@ -192,6 +193,8 @@ class AutoConnectTab(QtWidgets.QWidget): "Trying to automatically obtain bridges", ) self.use_bridge_widget.hide_buttons() + self.use_bridge_widget.progress.show() + self.use_bridge_widget.progress_label.show() if self.use_bridge_widget.detect_automatic_radio.isChecked(): country = False @@ -259,6 +262,8 @@ class AutoConnectTab(QtWidgets.QWidget): self.tor_con.hide() self.first_launch_widget.show_buttons() self.use_bridge_widget.show_buttons() + self.use_bridge_widget.progress.hide() + self.use_bridge_widget.progress_label.hide() if self.common.gui.onion.is_authenticated() and not self.tor_con.wasCanceled(): # Tell the tabs that Tor is connected @@ -279,6 +284,8 @@ class AutoConnectTab(QtWidgets.QWidget): self.first_launch_widget.show_buttons() self.first_launch_widget.hide() self.use_bridge_widget.show() + else: + self.use_bridge_widget.show_buttons() def reload_settings(self): self.curr_settings.load() @@ -374,6 +381,7 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): """ connect_clicked = QtCore.Signal() + try_again_clicked = QtCore.Signal() open_tor_settings = QtCore.Signal() def __init__(self, common): @@ -381,6 +389,13 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): self.common = common self.common.log("AutoConnectUseBridgeWidget", "__init__") + # Heading label when we fail to connect to Tor. + failed_to_connect_label = QtWidgets.QLabel( + strings._("gui_autoconnect_failed_to_connect_to_tor") + ) + failed_to_connect_label.setTextFormat(QtCore.Qt.RichText) + failed_to_connect_label.setStyleSheet(common.gui.css["autoconnect_failed_to_connect_label"]) + # Description description_label = QtWidgets.QLabel( strings._("gui_autoconnect_bridge_description") @@ -444,6 +459,13 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): self.connect_button.clicked.connect(self._connect_clicked) self.connect_button.setFixedWidth(150) self.connect_button.setStyleSheet(common.gui.css["autoconnect_start_button"]) + + self.try_again_button = QtWidgets.QPushButton( + strings._("gui_autoconnect_try_again_without_a_bridge") + ) + self.try_again_button.clicked.connect(self._try_again_clicked) + self.try_again_button.setStyleSheet(common.gui.css["autoconnect_start_button"]) + self.configure_button = QtWidgets.QPushButton( strings._("gui_autoconnect_configure") ) @@ -464,6 +486,7 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): cta_layout = QtWidgets.QHBoxLayout() cta_layout.addWidget(self.connect_button) + cta_layout.addWidget(self.try_again_button) cta_layout.addWidget(self.configure_button) cta_layout.addStretch() cta_widget = QtWidgets.QWidget() @@ -471,6 +494,7 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): # Layout layout = QtWidgets.QVBoxLayout() + layout.addWidget(failed_to_connect_label) layout.addWidget(description_label) layout.addLayout(detect_layout) layout.addWidget(self.country_combobox) @@ -486,15 +510,13 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): def hide_buttons(self): self.connect_button.hide() + self.try_again_button.hide() self.configure_button.hide() - self.progress.show() - self.progress_label.show() def show_buttons(self): self.connect_button.show() + self.try_again_button.show() self.configure_button.show() - self.progress.hide() - self.progress_label.hide() def _country_changed(self, index=None): self.country_code = str(self.country_combobox.currentData()).lower() @@ -528,5 +550,13 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): self.country_combobox.setEnabled(False) self.connect_clicked.emit() + def _try_again_clicked(self): + self.detect_automatic_radio.setEnabled(False) + self.detect_manual_radio.setEnabled(False) + + self.country_combobox.setEnabled(False) + self.hide_buttons() + self.try_again_clicked.emit() + def _open_tor_settings(self): self.open_tor_settings.emit() diff --git a/desktop/src/onionshare/gui_common.py b/desktop/src/onionshare/gui_common.py index 5bd10567..2253c56f 100644 --- a/desktop/src/onionshare/gui_common.py +++ b/desktop/src/onionshare/gui_common.py @@ -194,6 +194,11 @@ class GuiCommon: font-weight: bold; } """, + "autoconnect_failed_to_connect_label": """ + QLabel { + font-size: 18px; + font-weight: bold; + }""", # Common styles between modes and their child widgets "mode_settings_toggle_advanced": """ QPushButton { diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json index 656270fb..ea8e2df6 100644 --- a/desktop/src/onionshare/resources/locale/en.json +++ b/desktop/src/onionshare/resources/locale/en.json @@ -44,13 +44,14 @@ "gui_tor_settings_window_title": "Tor Settings", "gui_autoconnect_description": "OnionShare relies on the Tor Network, run by thousands of volunteers around the world.", "gui_enable_autoconnect_checkbox": "Connect to Tor automatically", - "gui_autoconnect_bridge_description": "Failed connecting to Tor. This could be because your internet is being censored.
You might be able to bypass this censorship by using a bridge.

Or, you might just need to configure the Tor connection in Network Settings.", - "gui_autoconnect_bridge_detect_automatic": "Automatically determine my country from my IP address, to bypass country-specific censorship", - "gui_autoconnect_bridge_detect_manual": "Manually select my country instead", + "gui_autoconnect_failed_to_connect_to_tor": "Failed to connect to Tor.", + "gui_autoconnect_bridge_description": "Are you connected to the internet?

It's also possible your internet is being censored.

You might be able to bypass this using a bridge.", + "gui_autoconnect_bridge_detect_automatic": "Automatically determine my country from my IP address", + "gui_autoconnect_bridge_detect_manual": "Manually select my country", "gui_autoconnect_start": "Connect to Tor", "gui_autoconnect_configure": "Network Settings", "gui_autoconnect_bridge_start": "Use a Bridge", - "gui_autoconnect_bridge_back": "Back", + "gui_autoconnect_try_again_without_a_bridge": "Try again without a Bridge", "gui_autoconnect_circumventing_censorship": "Trying to resolve connectivity issues", "gui_autoconnect_circumventing_censorship_starting_circumvention": "Starting censorship circumvention process", "gui_autoconnect_circumventing_censorship_starting_meek": "Starting Meek for domain-fronting", @@ -247,4 +248,4 @@ "moat_captcha_error": "The solution is not correct. Please try again.", "moat_solution_empty_error": "You must enter the characters from the image", "mode_tor_not_connected_label": "OnionShare is not connected to the Tor network" -} \ No newline at end of file +}