Addon Manager: Create NetworkManager class

To enable single-login authenticated proxy use, and simplified multi-threaded
network accesses, this commit adds a new wrapper around a QNetworkAccessManager
and includes a global instantiation of the class intended to exist for the
lifetime of the program. This instance can be used to enqueue any number of
network requests, which the manager will send out to the networking subsystem
in an appropriate manner.
This commit is contained in:
Chris Hennes
2022-01-14 11:52:31 -06:00
parent 4d87039635
commit 2b0a4dc643
8 changed files with 1055 additions and 660 deletions

View File

@@ -42,6 +42,8 @@ from package_list import PackageList, PackageListItemModel
from package_details import PackageDetails
from AddonManagerRepo import AddonManagerRepo
from NetworkManager import HAVE_QTNETWORK
__title__ = "FreeCAD Addon Manager Module"
__author__ = "Yorik van Havre", "Jonathan Wiedemann", "Kurt Kremitzki", "Chris Hennes"
__url__ = "http://www.freecad.org"
@@ -228,9 +230,16 @@ class CommandAddonManager:
# This must run on the main GUI thread
if hasattr(self, "connection_check_message") and self.connection_check_message:
self.connection_check_message.close()
QtWidgets.QMessageBox.critical(
None, translate("AddonsInstaller", "Connection failed"), message
)
if HAVE_QTNETWORK:
QtWidgets.QMessageBox.critical(
None, translate("AddonsInstaller", "Connection failed"), message
)
else:
QtWidgets.QMessageBox.critical(
None,
translate("AddonsInstaller", "Missing dependency"),
translate("AddonsInstaller", "Could not import QtNetwork -- see Report View for details. Addon Manager unavailable."),
)
def launch(self) -> None:
"""Shows the Addon Manager UI"""
@@ -821,7 +830,7 @@ class CommandAddonManager:
self.packageDetails.show_repo(selected_repo)
def show_information(self, message: str) -> None:
"""shows generic text in the information pane (which might be collapsed)"""
"""shows generic text in the information pane"""
self.dialog.labelStatusInfo.setText(message)
self.dialog.labelStatusInfo.repaint()