mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-28 00:39:37 -05:00
Now when you cancel connecting to Tor, it prompts you if you want to quit or open settings
This commit is contained in:
parent
ad2c5e94b4
commit
58f70b1d9b
@ -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_()
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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()
|
||||
|
@ -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."
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user