mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Download buttons are now disabled when another plugin is being downloaded
CURA-3856
This commit is contained in:
parent
051ce5e9f4
commit
a4e353c830
2 changed files with 18 additions and 4 deletions
|
@ -41,8 +41,16 @@ class PluginBrowser(QObject, Extension):
|
||||||
self._dialog = None
|
self._dialog = None
|
||||||
self._download_progress = 0
|
self._download_progress = 0
|
||||||
|
|
||||||
|
self._is_downloading = False
|
||||||
|
|
||||||
|
|
||||||
pluginsMetadataChanged = pyqtSignal()
|
pluginsMetadataChanged = pyqtSignal()
|
||||||
onDownloadProgressChanged = pyqtSignal()
|
onDownloadProgressChanged = pyqtSignal()
|
||||||
|
onIsDownloadingChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = onIsDownloadingChanged)
|
||||||
|
def isDownloading(self):
|
||||||
|
return self._is_downloading
|
||||||
|
|
||||||
def browsePlugins(self):
|
def browsePlugins(self):
|
||||||
self._createNetworkManager()
|
self._createNetworkManager()
|
||||||
|
@ -71,6 +79,11 @@ class PluginBrowser(QObject, Extension):
|
||||||
Logger.log("e", "QQmlComponent status %s", self._qml_component.status())
|
Logger.log("e", "QQmlComponent status %s", self._qml_component.status())
|
||||||
Logger.log("e", "QQmlComponent errorString %s", self._qml_component.errorString())
|
Logger.log("e", "QQmlComponent errorString %s", self._qml_component.errorString())
|
||||||
|
|
||||||
|
def setIsDownloading(self, is_downloading):
|
||||||
|
if self._is_downloading != is_downloading:
|
||||||
|
self._is_downloading = is_downloading
|
||||||
|
self.onIsDownloadingChanged.emit()
|
||||||
|
|
||||||
def _onDownloadPluginProgress(self, bytes_sent, bytes_total):
|
def _onDownloadPluginProgress(self, bytes_sent, bytes_total):
|
||||||
if bytes_total > 0:
|
if bytes_total > 0:
|
||||||
new_progress = bytes_sent / bytes_total * 100
|
new_progress = bytes_sent / bytes_total * 100
|
||||||
|
@ -79,6 +92,7 @@ class PluginBrowser(QObject, Extension):
|
||||||
self.onDownloadProgressChanged.emit()
|
self.onDownloadProgressChanged.emit()
|
||||||
self._download_progress = new_progress
|
self._download_progress = new_progress
|
||||||
if new_progress == 100.0:
|
if new_progress == 100.0:
|
||||||
|
self.setIsDownloading(False)
|
||||||
self._download_plugin_reply.downloadProgress.disconnect(self._onDownloadPluginProgress)
|
self._download_plugin_reply.downloadProgress.disconnect(self._onDownloadPluginProgress)
|
||||||
self._temp_plugin_file = tempfile.NamedTemporaryFile(suffix = ".curaplugin")
|
self._temp_plugin_file = tempfile.NamedTemporaryFile(suffix = ".curaplugin")
|
||||||
self._temp_plugin_file.write(self._download_plugin_reply.readAll())
|
self._temp_plugin_file.write(self._download_plugin_reply.readAll())
|
||||||
|
@ -96,6 +110,7 @@ class PluginBrowser(QObject, Extension):
|
||||||
self._download_plugin_request = QNetworkRequest(url)
|
self._download_plugin_request = QNetworkRequest(url)
|
||||||
self._download_plugin_reply = self._network_manager.get(self._download_plugin_request)
|
self._download_plugin_reply = self._network_manager.get(self._download_plugin_request)
|
||||||
self._download_progress = 0
|
self._download_progress = 0
|
||||||
|
self.setIsDownloading(True)
|
||||||
self.onDownloadProgressChanged.emit()
|
self.onDownloadProgressChanged.emit()
|
||||||
self._download_plugin_reply.downloadProgress.connect(self._onDownloadPluginProgress)
|
self._download_plugin_reply.downloadProgress.connect(self._onDownloadPluginProgress)
|
||||||
|
|
||||||
|
@ -134,7 +149,6 @@ class PluginBrowser(QObject, Extension):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _onRequestFinished(self, reply):
|
def _onRequestFinished(self, reply):
|
||||||
reply_url = reply.url().toString()
|
reply_url = reply.url().toString()
|
||||||
if reply.operation() == QNetworkAccessManager.GetOperation:
|
if reply.operation() == QNetworkAccessManager.GetOperation:
|
||||||
|
|
|
@ -8,7 +8,7 @@ UM.Dialog
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
|
|
||||||
title: "YAY"
|
title: "Find & Update plugins"
|
||||||
width: 450
|
width: 450
|
||||||
height: 150
|
height: 150
|
||||||
ScrollView
|
ScrollView
|
||||||
|
@ -63,10 +63,10 @@ UM.Dialog
|
||||||
}
|
}
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
text: enabled ? "Download" : "Already Installed"
|
text: !model.already_installed ? "Download" : "Already Installed"
|
||||||
onClicked: manager.downloadAndInstallPlugin(model.file_location)
|
onClicked: manager.downloadAndInstallPlugin(model.file_location)
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
enabled: !model.already_installed
|
enabled: !model.already_installed && !manager.isDownloading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue