Addon Manager: Correct macro display

If the "download macros" preference is off, the macro will not yet have
a URL to load the data from. Make sure to load the macro before
attempting to display it. Also resolves the issue with macros being
unable to be installed under similar circumstances.
This commit is contained in:
Chris Hennes
2022-02-17 17:28:52 -06:00
parent c5dfa7fa01
commit 524992b8db

View File

@@ -454,18 +454,23 @@ class PackageDetails(QWidget):
def show_macro(self, repo: AddonManagerRepo) -> None:
"""loads information of a given macro"""
if HAS_QTWEBENGINE:
self.ui.webView.load(QUrl(repo.macro.url))
self.ui.urlBar.setText(repo.macro.url)
if not repo.macro.url:
# We need to populate the macro information... may as well do it while the user reads the wiki page
self.worker = GetMacroDetailsWorker(repo)
self.worker.readme_updated.connect(self.macro_readme_updated)
self.worker.start()
else:
readme_data = NetworkManager.AM_NETWORK_MANAGER.blocking_get(repo.macro.url)
self.macro_readme_updated()
def macro_readme_updated(self):
if HAS_QTWEBENGINE:
self.ui.webView.load(QUrl(self.repo.macro.url))
self.ui.urlBar.setText(self.repo.macro.url)
else:
readme_data = NetworkManager.AM_NETWORK_MANAGER.blocking_get(self.repo.macro.url)
text = readme_data.data().decode("utf8")
self.ui.textBrowserReadMe.setHtml(text)
# We need to populate the macro information... may as well do it while the user reads the wiki page
self.worker = GetMacroDetailsWorker(repo)
self.worker.start()
def run_javascript(self):
"""Modify the page for a README to optimize for viewing in a smaller window"""