From 1c7eba2b104b7627bdd90545830d3a02e191d643 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Mon, 20 Dec 2021 15:17:40 +1100 Subject: [PATCH] Show/hide widgets more aggressively. Different error message on CensorshipCircumventionError. --- desktop/src/onionshare/connection_tab.py | 43 ++++++++++++------- .../src/onionshare/resources/locale/en.json | 2 + 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/desktop/src/onionshare/connection_tab.py b/desktop/src/onionshare/connection_tab.py index 4aaf52c8..e67ca483 100644 --- a/desktop/src/onionshare/connection_tab.py +++ b/desktop/src/onionshare/connection_tab.py @@ -192,9 +192,13 @@ class AutoConnectTab(QtWidgets.QWidget): """ Display an error if there simply seems no network connection. """ + self.use_bridge_widget.connection_status_label.setText( + strings._("gui_autoconnect_failed_to_connect_to_tor") + ) self.use_bridge_widget.progress.hide() self.use_bridge_widget.progress_label.hide() self.use_bridge_widget.error_label.show() + self.use_bridge_widget.country_combobox.setEnabled(True) self.use_bridge_widget.show_buttons() self.use_bridge_widget.show() @@ -416,20 +420,20 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): self.common.log("AutoConnectUseBridgeWidget", "__init__") # Heading label when we fail to connect to Tor. - failed_to_connect_label = QtWidgets.QLabel( + self.connection_status_label = QtWidgets.QLabel( strings._("gui_autoconnect_failed_to_connect_to_tor") ) - failed_to_connect_label.setTextFormat(QtCore.Qt.RichText) - failed_to_connect_label.setStyleSheet( + self.connection_status_label.setTextFormat(QtCore.Qt.RichText) + self.connection_status_label.setStyleSheet( common.gui.css["autoconnect_failed_to_connect_label"] ) # Description - description_label = QtWidgets.QLabel( + self.description_label = QtWidgets.QLabel( strings._("gui_autoconnect_bridge_description") ) - description_label.setTextFormat(QtCore.Qt.RichText) - description_label.setWordWrap(True) + self.description_label.setTextFormat(QtCore.Qt.RichText) + self.description_label.setWordWrap(True) # Detection preference self.detect_automatic_radio = QtWidgets.QRadioButton( @@ -504,7 +508,9 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): ) # Error label - self.error_label = QtWidgets.QLabel(strings._("gui_tor_connection_canceled")) + self.error_label = QtWidgets.QLabel( + strings._("gui_autoconnect_could_not_connect_to_tor_api") + ) self.error_label.setStyleSheet(self.common.gui.css["tor_settings_error"]) self.error_label.setWordWrap(True) self.error_label.hide() @@ -528,8 +534,8 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): # Layout layout = QtWidgets.QVBoxLayout() - layout.addWidget(failed_to_connect_label) - layout.addWidget(description_label) + layout.addWidget(self.connection_status_label) + layout.addWidget(self.description_label) layout.addLayout(detect_layout) layout.addWidget(self.country_combobox) layout.addWidget(self.country_image) @@ -547,12 +553,18 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): self.connect_button.hide() self.try_again_button.hide() self.configure_button.hide() + self.description_label.hide() self.error_label.hide() + self.detect_automatic_radio.hide() + self.detect_manual_radio.hide() def show_buttons(self): self.connect_button.show() self.try_again_button.show() + self.description_label.show() self.configure_button.show() + self.detect_automatic_radio.show() + self.detect_manual_radio.show() def _country_changed(self, index=None): self.country_code = str(self.country_combobox.currentData()).lower() @@ -580,16 +592,17 @@ class AutoConnectUseBridgeWidget(QtWidgets.QWidget): self.country_image.show() def _connect_clicked(self): - self.detect_automatic_radio.setEnabled(False) - self.detect_manual_radio.setEnabled(False) - self.country_combobox.setEnabled(False) + self.hide_buttons() + self.connection_status_label.setText( + strings._("gui_autoconnect_trying_to_connect_to_tor") + ) self.connect_clicked.emit() def _try_again_clicked(self): - self.detect_automatic_radio.setEnabled(False) - self.detect_manual_radio.setEnabled(False) - + self.connection_status_label.setText( + strings._("gui_autoconnect_trying_to_connect_to_tor") + ) self.country_combobox.setEnabled(False) self.hide_buttons() self.try_again_clicked.emit() diff --git a/desktop/src/onionshare/resources/locale/en.json b/desktop/src/onionshare/resources/locale/en.json index ea8e2df6..8936b218 100644 --- a/desktop/src/onionshare/resources/locale/en.json +++ b/desktop/src/onionshare/resources/locale/en.json @@ -45,6 +45,7 @@ "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_failed_to_connect_to_tor": "Failed to connect to Tor.", + "gui_autoconnect_trying_to_connect_to_tor": "Trying 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", @@ -57,6 +58,7 @@ "gui_autoconnect_circumventing_censorship_starting_meek": "Starting Meek for domain-fronting", "gui_autoconnect_circumventing_censorship_requesting_bridges": "Requesting bridges from the Tor Censorship Circumvention API", "gui_autoconnect_circumventing_censorship_got_bridges": "Got bridges! Trying to reconnect to Tor", + "gui_autoconnect_could_not_connect_to_tor_api": "Could not connect to the Tor API. Make sure you are connected to the internet before trying again.", "gui_settings_window_title": "Settings", "gui_settings_autoupdate_label": "Check for new version", "gui_settings_autoupdate_option": "Notify me when a new version is available",