diff --git a/onionshare_gui/alert.py b/onionshare_gui/alert.py index 5dee4d3f..2af7daf0 100644 --- a/onionshare_gui/alert.py +++ b/onionshare_gui/alert.py @@ -25,10 +25,13 @@ class Alert(QtWidgets.QMessageBox): """ An alert box dialog. """ - def __init__(self, message, icon=QtWidgets.QMessageBox.NoIcon): + def __init__(self, message, icon=QtWidgets.QMessageBox.NoIcon, buttons=QtWidgets.QMessageBox.Ok, autostart=True): super(Alert, self).__init__(None) self.setWindowTitle("OnionShare") self.setWindowIcon(QtGui.QIcon(helpers.get_resource_path('images/logo.png'))) self.setText(message) self.setIcon(icon) - self.exec_() + self.setStandardButtons(buttons) + + if autostart: + self.exec_() diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 00c0aeec..dc5bdc71 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -143,13 +143,25 @@ class OnionShareGui(QtWidgets.QMainWindow): def _tor_connection_canceled(self): """ - If the user cancels before Tor finishes connecting, quit. + If the user cancels before Tor finishes connecting, ask if they want to + quit, or open settings. """ - def quit(): - self.qtapp.quit() + def quit_settings_dialog(): + a = Alert("Would you like to open OnionShare settings to troubleshoot connecting to Tor?", QtWidgets.QMessageBox.Question, buttons=QtWidgets.QMessageBox.NoButton, autostart=False) + settings_button = QtWidgets.QPushButton("Open Settings") + quit_button = QtWidgets.QPushButton("Quit") + a.addButton(settings_button, QtWidgets.QMessageBox.AcceptRole) + a.addButton(quit_button, QtWidgets.QMessageBox.RejectRole) + a.setDefaultButton(settings_button) + a.exec_() + + if a.clickedButton() == settings_button: + SettingsDialog(self.qtapp) + else: + self.qtapp.quit() # Wait 1ms for the event loop to finish closing the TorConnectionDialog - QtCore.QTimer.singleShot(1, quit) + QtCore.QTimer.singleShot(1, quit_settings_dialog) def _tor_connection_open_settings(self): """ diff --git a/onionshare_gui/tor_connection_dialog.py b/onionshare_gui/tor_connection_dialog.py index 96bb2f60..ee1a9b28 100644 --- a/onionshare_gui/tor_connection_dialog.py +++ b/onionshare_gui/tor_connection_dialog.py @@ -42,7 +42,6 @@ class TorConnectionDialog(QtWidgets.QProgressDialog): # Label self.setLabelText(strings._('connecting_to_tor', True)) - self.setCancelButtonText(strings._('gui_tor_connection_exit', True)) # Progress bar ticks from 0 to 100 self.setRange(0, 100) @@ -72,7 +71,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog): self.cancel() # Display the exception in an alert box - Alert("{}\n\nTry adjusting how OnionShare connects to the Tor network in Settings.".format(e.args[0]), QtWidgets.QMessageBox.Warning) + Alert("{}\n\n{}".format(e.args[0], strings._('gui_tor_connection_error_settings', True)), QtWidgets.QMessageBox.Warning) # Open settings self.open_settings.emit() diff --git a/share/locale/en.json b/share/locale/en.json index acb4f73d..96085451 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -101,5 +101,5 @@ "update_error_sockshttp": "Error checking for updates: Connected to Tor, but can't load the update HTTP request.", "update_error_invalid_latest_version": "Error checking for updates: The OnionShare website responded saying the latest version is '{}', but that doesn't appear to be a valid version string.", "update_not_available": "You are running the latest version of OnionShare.", - "gui_tor_connection_exit": "Exit" + "gui_tor_connection_error_settings": "Try adjusting how OnionShare connects to the Tor network in Settings." }