mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-16 13:22:28 -04:00
Made clicking Exit in the TorConnectionDialog exit the app
This commit is contained in:
parent
d7c181e0b4
commit
cc0c8e043e
2 changed files with 20 additions and 13 deletions
|
@ -22,7 +22,7 @@ import os, sys, platform, argparse
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore, QtWidgets
|
||||||
|
|
||||||
from onionshare import strings, helpers, web
|
from onionshare import strings, helpers, web
|
||||||
from onionshare.onion import *
|
from onionshare.onion import Onion
|
||||||
from onionshare.onionshare import OnionShare
|
from onionshare.onionshare import OnionShare
|
||||||
from onionshare.settings import Settings
|
from onionshare.settings import Settings
|
||||||
|
|
||||||
|
@ -93,7 +93,15 @@ def main():
|
||||||
|
|
||||||
# Start the Onion
|
# Start the Onion
|
||||||
onion = Onion()
|
onion = Onion()
|
||||||
|
|
||||||
|
def exit_early():
|
||||||
|
# Wait for tor to exit
|
||||||
|
onion.cleanup()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
tor_con = TorConnectionDialog(settings, onion)
|
tor_con = TorConnectionDialog(settings, onion)
|
||||||
|
tor_con.canceled.connect(exit_early)
|
||||||
|
tor_con.start()
|
||||||
|
|
||||||
# Start the OnionShare app
|
# Start the OnionShare app
|
||||||
web.set_stay_open(stay_open)
|
web.set_stay_open(stay_open)
|
||||||
|
|
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from PyQt5 import QtCore, QtWidgets, QtGui
|
from PyQt5 import QtCore, QtWidgets, QtGui
|
||||||
|
|
||||||
from onionshare import strings, helpers
|
from onionshare import strings, helpers
|
||||||
|
from onionshare.onion import *
|
||||||
|
|
||||||
class TorConnectionDialog(QtWidgets.QProgressDialog):
|
class TorConnectionDialog(QtWidgets.QProgressDialog):
|
||||||
"""
|
"""
|
||||||
|
@ -28,6 +29,7 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
|
||||||
def __init__(self, settings, onion):
|
def __init__(self, settings, onion):
|
||||||
super(TorConnectionDialog, self).__init__(None)
|
super(TorConnectionDialog, self).__init__(None)
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
|
self.onion = onion
|
||||||
|
|
||||||
self.setWindowTitle("OnionShare")
|
self.setWindowTitle("OnionShare")
|
||||||
self.setWindowIcon(QtGui.QIcon(helpers.get_resource_path('images/logo.png')))
|
self.setWindowIcon(QtGui.QIcon(helpers.get_resource_path('images/logo.png')))
|
||||||
|
@ -39,11 +41,12 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
|
||||||
|
|
||||||
# Progress bar ticks from 0 to 100
|
# Progress bar ticks from 0 to 100
|
||||||
self.setRange(0, 100)
|
self.setRange(0, 100)
|
||||||
# Don't show if connection takes less than 200ms (for non-bundled tor)
|
# Don't show if connection takes less than 100ms (for non-bundled tor)
|
||||||
self.setMinimumDuration(200)
|
self.setMinimumDuration(100)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
# If bundled tor, prepare to display Tor connection status
|
# If bundled tor, prepare to display Tor connection status
|
||||||
if settings.get('connection_type') == 'bundled':
|
if self.settings.get('connection_type') == 'bundled':
|
||||||
tor_status_update = self.tor_status_update
|
tor_status_update = self.tor_status_update
|
||||||
else:
|
else:
|
||||||
tor_status_update = None
|
tor_status_update = None
|
||||||
|
@ -51,18 +54,14 @@ class TorConnectionDialog(QtWidgets.QProgressDialog):
|
||||||
# Connect to the Onion
|
# Connect to the Onion
|
||||||
self.setValue(0)
|
self.setValue(0)
|
||||||
try:
|
try:
|
||||||
onion.connect(self.settings, tor_status_update)
|
self.onion.connect(self.settings, tor_status_update)
|
||||||
except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported, BundledTorTimeout) as e:
|
except BundledTorCanceled as e:
|
||||||
|
self.close()
|
||||||
|
except Exception as e:
|
||||||
print(e.args[0])
|
print(e.args[0])
|
||||||
# TODO: Open settings to connect to Tor properly
|
# TODO: Open settings to connect to Tor properly
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
self.exec_()
|
|
||||||
|
|
||||||
def tor_status_update(self, progress, summary):
|
def tor_status_update(self, progress, summary):
|
||||||
if summary == 'Done':
|
self.setValue(int(progress))
|
||||||
# All done
|
|
||||||
self.close()
|
|
||||||
else:
|
|
||||||
self.setValue(int(progress))
|
|
||||||
self.setLabelText("<strong>{}</strong><br>{}".format(strings._('connecting_to_tor', True), summary))
|
self.setLabelText("<strong>{}</strong><br>{}".format(strings._('connecting_to_tor', True), summary))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue