From 52954460a3f1a6601d725829e19e60d4508aaf1b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 30 Jun 2017 15:30:22 +0200 Subject: [PATCH] Added refresh option for plugin list. This fixes the issue that if you don't have internet connection on first start of the browser, you'd need a reboot of cura to get the list. CURA-3856 --- plugins/PluginBrowser/PluginBrowser.py | 8 +++++++- plugins/PluginBrowser/PluginBrowser.qml | 24 +++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/plugins/PluginBrowser/PluginBrowser.py b/plugins/PluginBrowser/PluginBrowser.py index 5ef3e6e335..3957fcb9a4 100644 --- a/plugins/PluginBrowser/PluginBrowser.py +++ b/plugins/PluginBrowser/PluginBrowser.py @@ -66,7 +66,9 @@ class PluginBrowser(QObject, Extension): self._createDialog() self._dialog.show() + @pyqtSlot() def requestPluginList(self): + Logger.log("i", "Requesting plugin list") url = QUrl(self._api_url + "plugins") self._plugin_list_request = QNetworkRequest(url) self._plugin_list_request.setRawHeader(*self._request_header) @@ -181,7 +183,6 @@ class PluginBrowser(QObject, Extension): def _onRequestFinished(self, reply): reply_url = reply.url().toString() - if reply.error() == QNetworkReply.TimeoutError: Logger.log("w", "Got a timeout.") # Reset everything. @@ -191,6 +192,11 @@ class PluginBrowser(QObject, Extension): self._download_plugin_reply.downloadProgress.disconnect(self._onDownloadPluginProgress) self._download_plugin_reply.abort() self._download_plugin_reply = None + return + elif reply.error() == QNetworkReply.HostNotFoundError: + Logger.log("w", "Unable to reach server.") + return + if reply.operation() == QNetworkAccessManager.GetOperation: if reply_url == self._api_url + "plugins": try: diff --git a/plugins/PluginBrowser/PluginBrowser.qml b/plugins/PluginBrowser/PluginBrowser.qml index 841a1828a2..a9596b0abd 100644 --- a/plugins/PluginBrowser/PluginBrowser.qml +++ b/plugins/PluginBrowser/PluginBrowser.qml @@ -14,17 +14,31 @@ UM.Dialog Item { anchors.fill: parent - Label + Item { - id: introText - text: catalog.i18nc("@label", "Here you can find a list of Third Party plugins.") + id: topBar + height: childrenRect.height; width: parent.width - height: 30 + Label + { + id: introText + text: catalog.i18nc("@label", "Here you can find a list of Third Party plugins.") + width: parent.width + height: 30 + } + + Button + { + id: refresh + text: catalog.i18nc("@action:button", "Refresh") + onClicked: manager.requestPluginList() + anchors.right: parent.right + } } ScrollView { width: parent.width - anchors.top: introText.bottom + anchors.top: topBar.bottom anchors.bottom: progressbar.top anchors.bottomMargin: UM.Theme.getSize("default_margin").height frameVisible: true