mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Skip loading a reply if it's not later handled.
Contributes to CURA-5670.
This commit is contained in:
parent
988b9059b9
commit
bf1d3b964f
3 changed files with 18 additions and 16 deletions
|
@ -9,7 +9,7 @@ import UM 1.1 as UM
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
property int packageCount: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
property int packageCount: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getTotalNumberOfMaterialPackagesByAuthor(model.id) : 1
|
||||||
property int installedPackages: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
property int installedPackages: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||||
|
|
|
@ -9,7 +9,7 @@ import UM 1.1 as UM
|
||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfMaterialPackagesByAuthor(model.id) : 1
|
||||||
property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
||||||
id: tileBase
|
id: tileBase
|
||||||
width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width)
|
width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width)
|
||||||
|
|
|
@ -514,10 +514,11 @@ class Toolbox(QObject, Extension):
|
||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
# This slot is only used to get the number of material packages by author, not any other type of packages.
|
||||||
@pyqtSlot(str, result = int)
|
@pyqtSlot(str, result = int)
|
||||||
def getTotalNumberOfPackagesByAuthor(self, author_id: str) -> int:
|
def getTotalNumberOfMaterialPackagesByAuthor(self, author_id: str) -> int:
|
||||||
count = 0
|
count = 0
|
||||||
for package in self._metadata["packages"]:
|
for package in self._metadata["materials_available"]:
|
||||||
if package["author"]["author_id"] == author_id:
|
if package["author"]["author_id"] == author_id:
|
||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
@ -606,8 +607,21 @@ class Toolbox(QObject, Extension):
|
||||||
self.resetDownload()
|
self.resetDownload()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# HACK: These request are not handled independently at this moment, but together from the "packages" call
|
||||||
|
do_not_handle = [
|
||||||
|
"materials_available",
|
||||||
|
"materials_showcase",
|
||||||
|
"plugins_available",
|
||||||
|
"plugins_showcase",
|
||||||
|
]
|
||||||
|
|
||||||
if reply.operation() == QNetworkAccessManager.GetOperation:
|
if reply.operation() == QNetworkAccessManager.GetOperation:
|
||||||
for type, url in self._request_urls.items():
|
for type, url in self._request_urls.items():
|
||||||
|
|
||||||
|
# HACK: Do nothing because we'll handle these from the "packages" call
|
||||||
|
if type in do_not_handle:
|
||||||
|
return
|
||||||
|
|
||||||
if reply.url() == url:
|
if reply.url() == url:
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
|
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
|
||||||
try:
|
try:
|
||||||
|
@ -624,18 +638,6 @@ class Toolbox(QObject, Extension):
|
||||||
Logger.log("e", "Could not find the %s model.", type)
|
Logger.log("e", "Could not find the %s model.", type)
|
||||||
break
|
break
|
||||||
|
|
||||||
# HACK
|
|
||||||
do_not_handle = [
|
|
||||||
"materials_available",
|
|
||||||
"materials_showcase",
|
|
||||||
"plugins_available",
|
|
||||||
"plugins_showcase",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Do nothing because we'll handle these from the "packages" call
|
|
||||||
if type in do_not_handle:
|
|
||||||
return
|
|
||||||
|
|
||||||
self._metadata[type] = json_data["data"]
|
self._metadata[type] = json_data["data"]
|
||||||
self._models[type].setMetadata(self._metadata[type])
|
self._models[type].setMetadata(self._metadata[type])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue