Refactor UpdateChecker into a class that's a QObject, and make it use signals and slots to communicate

This commit is contained in:
Micah Lee 2017-04-15 18:55:41 -07:00
parent ca16600d29
commit 47c1488512
2 changed files with 74 additions and 57 deletions

View file

@ -381,9 +381,17 @@ class SettingsDialog(QtWidgets.QDialog):
bundled_tor_func = None
# Check for updates
def update_available(update_url, installed_version, latest_version):
Alert(strings._("update_available", True).format(update_url, installed_version, latest_version))
def update_not_available():
Alert(strings._('update_not_available', True))
u = UpdateChecker()
u.update_available.connect(update_available)
u.update_not_available.connect(update_not_available)
try:
if not check_for_updates(force=True, bundled_tor_func=bundled_tor_func):
Alert(strings._('update_not_available', True))
u.check(force=True, bundled_tor_func=bundled_tor_func)
except UpdateCheckerTorError:
Alert(strings._('update_error_tor', True), QtWidgets.QMessageBox.Warning)
except UpdateCheckerSOCKSHTTPError: