mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 05:09:00 +08:00
Merge pull request #4088 from Ultimaker/CURA-5510_generic_materials_in_toolbox
Add generic material packages to materials page
This commit is contained in:
commit
29d1de03d1
@ -9,6 +9,9 @@ import UM 1.1 as UM
|
|||||||
|
|
||||||
Column
|
Column
|
||||||
{
|
{
|
||||||
|
property var heading: ""
|
||||||
|
property var model
|
||||||
|
id: gridArea
|
||||||
height: childrenRect.height + 2 * padding
|
height: childrenRect.height + 2 * padding
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: UM.Theme.getSize("default_margin").height
|
spacing: UM.Theme.getSize("default_margin").height
|
||||||
@ -16,7 +19,7 @@ Column
|
|||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: heading
|
id: heading
|
||||||
text: toolbox.viewCategory == "material" ? catalog.i18nc("@label", "Community contributions") : catalog.i18nc("@label", "Community plugins")
|
text: gridArea.heading
|
||||||
width: parent.width
|
width: parent.width
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
@ -24,14 +27,13 @@ Column
|
|||||||
GridLayout
|
GridLayout
|
||||||
{
|
{
|
||||||
id: grid
|
id: grid
|
||||||
property var model: toolbox.viewCategory == "material" ? toolbox.authorsModel : toolbox.packagesModel
|
|
||||||
width: parent.width - 2 * parent.padding
|
width: parent.width - 2 * parent.padding
|
||||||
columns: 2
|
columns: 2
|
||||||
columnSpacing: UM.Theme.getSize("default_margin").height
|
columnSpacing: UM.Theme.getSize("default_margin").height
|
||||||
rowSpacing: UM.Theme.getSize("default_margin").width
|
rowSpacing: UM.Theme.getSize("default_margin").width
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
model: grid.model
|
model: gridArea.model
|
||||||
delegate: ToolboxDownloadsGridTile
|
delegate: ToolboxDownloadsGridTile
|
||||||
{
|
{
|
||||||
Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns
|
Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns
|
||||||
|
@ -9,8 +9,8 @@ import UM 1.1 as UM
|
|||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
property int packageCount: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getTotalNumberOfPackagesByAuthor(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" && 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
|
||||||
Rectangle
|
Rectangle
|
||||||
@ -104,8 +104,18 @@ Item
|
|||||||
switch(toolbox.viewCategory)
|
switch(toolbox.viewCategory)
|
||||||
{
|
{
|
||||||
case "material":
|
case "material":
|
||||||
toolbox.viewPage = "author"
|
|
||||||
toolbox.filterModelByProp("packages", "author_id", model.id)
|
// If model has a type, it must be a package
|
||||||
|
if (model.type !== undefined)
|
||||||
|
{
|
||||||
|
toolbox.viewPage = "detail"
|
||||||
|
toolbox.filterModelByProp("packages", "id", model.id)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolbox.viewPage = "author"
|
||||||
|
toolbox.filterModelByProp("packages", "author_id", model.id)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
toolbox.viewPage = "detail"
|
toolbox.viewPage = "detail"
|
||||||
|
@ -29,6 +29,17 @@ ScrollView
|
|||||||
{
|
{
|
||||||
id: allPlugins
|
id: allPlugins
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
heading: toolbox.viewCategory == "material" ? catalog.i18nc("@label", "Community Contributions") : catalog.i18nc("@label", "Community Plugins")
|
||||||
|
model: toolbox.viewCategory == "material" ? toolbox.authorsModel : toolbox.packagesModel
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolboxDownloadsGrid
|
||||||
|
{
|
||||||
|
id: genericMaterials
|
||||||
|
visible: toolbox.viewCategory == "material"
|
||||||
|
width: parent.width
|
||||||
|
heading: catalog.i18nc("@label", "Generic Materials")
|
||||||
|
model: toolbox.materialsGenericModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class PackagesModel(ListModel):
|
|||||||
self.addRoleName(Qt.UserRole + 16, "has_configs")
|
self.addRoleName(Qt.UserRole + 16, "has_configs")
|
||||||
self.addRoleName(Qt.UserRole + 17, "supported_configs")
|
self.addRoleName(Qt.UserRole + 17, "supported_configs")
|
||||||
self.addRoleName(Qt.UserRole + 18, "download_count")
|
self.addRoleName(Qt.UserRole + 18, "download_count")
|
||||||
|
self.addRoleName(Qt.UserRole + 19, "tags")
|
||||||
|
|
||||||
# List of filters for queries. The result is the union of the each list of results.
|
# List of filters for queries. The result is the union of the each list of results.
|
||||||
self._filter = {} # type: Dict[str, str]
|
self._filter = {} # type: Dict[str, str]
|
||||||
@ -78,13 +79,15 @@ class PackagesModel(ListModel):
|
|||||||
"is_installed": package["is_installed"] if "is_installed" in package else False,
|
"is_installed": package["is_installed"] if "is_installed" in package else False,
|
||||||
"has_configs": has_configs,
|
"has_configs": has_configs,
|
||||||
"supported_configs": configs_model,
|
"supported_configs": configs_model,
|
||||||
"download_count": package["download_count"] if "download_count" in package else 0
|
"download_count": package["download_count"] if "download_count" in package else 0,
|
||||||
|
"tags": package["tags"] if "tags" in package else []
|
||||||
})
|
})
|
||||||
|
|
||||||
# Filter on all the key-word arguments.
|
# Filter on all the key-word arguments.
|
||||||
for key, value in self._filter.items():
|
for key, value in self._filter.items():
|
||||||
if "*" in value:
|
if key is "tags":
|
||||||
|
key_filter = lambda item, value = value: value in item["tags"]
|
||||||
|
elif "*" in value:
|
||||||
key_filter = lambda candidate, key = key, value = value: self._matchRegExp(candidate, key, value)
|
key_filter = lambda candidate, key = key, value = value: self._matchRegExp(candidate, key, value)
|
||||||
else:
|
else:
|
||||||
key_filter = lambda candidate, key = key, value = value: self._matchString(candidate, key, value)
|
key_filter = lambda candidate, key = key, value = value: self._matchString(candidate, key, value)
|
||||||
|
@ -71,7 +71,8 @@ class Toolbox(QObject, Extension):
|
|||||||
"plugins_installed": [],
|
"plugins_installed": [],
|
||||||
"materials_showcase": [],
|
"materials_showcase": [],
|
||||||
"materials_available": [],
|
"materials_available": [],
|
||||||
"materials_installed": []
|
"materials_installed": [],
|
||||||
|
"materials_generic": []
|
||||||
} # type: Dict[str, List[Any]]
|
} # type: Dict[str, List[Any]]
|
||||||
|
|
||||||
# Models:
|
# Models:
|
||||||
@ -83,7 +84,8 @@ class Toolbox(QObject, Extension):
|
|||||||
"plugins_installed": PackagesModel(self),
|
"plugins_installed": PackagesModel(self),
|
||||||
"materials_showcase": AuthorsModel(self),
|
"materials_showcase": AuthorsModel(self),
|
||||||
"materials_available": PackagesModel(self),
|
"materials_available": PackagesModel(self),
|
||||||
"materials_installed": PackagesModel(self)
|
"materials_installed": PackagesModel(self),
|
||||||
|
"materials_generic": PackagesModel(self)
|
||||||
} # type: Dict[str, ListModel]
|
} # type: Dict[str, ListModel]
|
||||||
|
|
||||||
# These properties are for keeping track of the UI state:
|
# These properties are for keeping track of the UI state:
|
||||||
@ -178,7 +180,8 @@ class Toolbox(QObject, Extension):
|
|||||||
"plugins_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
"plugins_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
||||||
"plugins_available": QUrl("{base_url}/packages?package_type=plugin".format(base_url=self._api_url)),
|
"plugins_available": QUrl("{base_url}/packages?package_type=plugin".format(base_url=self._api_url)),
|
||||||
"materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
"materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
||||||
"materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url))
|
"materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url)),
|
||||||
|
"materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url=self._api_url))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the API root for the packages API depending on Cura version settings.
|
# Get the API root for the packages API depending on Cura version settings.
|
||||||
@ -229,6 +232,7 @@ class Toolbox(QObject, Extension):
|
|||||||
self._makeRequestByType("plugins_showcase")
|
self._makeRequestByType("plugins_showcase")
|
||||||
self._makeRequestByType("materials_showcase")
|
self._makeRequestByType("materials_showcase")
|
||||||
self._makeRequestByType("materials_available")
|
self._makeRequestByType("materials_available")
|
||||||
|
self._makeRequestByType("materials_generic")
|
||||||
|
|
||||||
# Gather installed packages:
|
# Gather installed packages:
|
||||||
self._updateInstalledModels()
|
self._updateInstalledModels()
|
||||||
@ -640,6 +644,8 @@ class Toolbox(QObject, Extension):
|
|||||||
self._models[type].setFilter({"type": "plugin"})
|
self._models[type].setFilter({"type": "plugin"})
|
||||||
if type is "authors":
|
if type is "authors":
|
||||||
self._models[type].setFilter({"package_types": "material"})
|
self._models[type].setFilter({"package_types": "material"})
|
||||||
|
if type is "materials_generic":
|
||||||
|
self._models[type].setFilter({"tags": "generic"})
|
||||||
|
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
|
|
||||||
@ -761,6 +767,10 @@ class Toolbox(QObject, Extension):
|
|||||||
def materialsInstalledModel(self) -> PackagesModel:
|
def materialsInstalledModel(self) -> PackagesModel:
|
||||||
return cast(PackagesModel, self._models["materials_installed"])
|
return cast(PackagesModel, self._models["materials_installed"])
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify=metadataChanged)
|
||||||
|
def materialsGenericModel(self) -> PackagesModel:
|
||||||
|
return cast(PackagesModel, self._models["materials_generic"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Filter Models:
|
# Filter Models:
|
||||||
|
@ -713,6 +713,240 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"GenericABS": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericABS",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic ABS",
|
||||||
|
"description": "The generic ABS profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericBAM": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericBAM",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic BAM",
|
||||||
|
"description": "The generic BAM profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericCPE": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericCPE",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic CPE",
|
||||||
|
"description": "The generic CPE profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericCPEPlus": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericCPEPlus",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic CPE+",
|
||||||
|
"description": "The generic CPE+ profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericHIPS": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericHIPS",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic HIPS",
|
||||||
|
"description": "The generic HIPS profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericNylon": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericNylon",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic Nylon",
|
||||||
|
"description": "The generic Nylon profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericPC": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericPC",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic PC",
|
||||||
|
"description": "The generic PC profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericPETG": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericPETG",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic PETG",
|
||||||
|
"description": "The generic PETG profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericPLA": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericPLA",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic PLA",
|
||||||
|
"description": "The generic PLA profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericPP": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericPP",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic PP",
|
||||||
|
"description": "The generic PP profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericPVA": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericPVA",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic PVA",
|
||||||
|
"description": "The generic PVA profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericToughPLA": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericToughPLA",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic Tough PLA",
|
||||||
|
"description": "The generic Tough PLA profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"GenericTPU": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "GenericTPU",
|
||||||
|
"package_type": "material",
|
||||||
|
"display_name": "Generic TPU",
|
||||||
|
"description": "The generic TPU profile which other profiles can be based upon.",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": 6,
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"author": {
|
||||||
|
"author_id": "Generic",
|
||||||
|
"display_name": "Generic",
|
||||||
|
"email": "materials@ultimaker.com",
|
||||||
|
"website": "https://github.com/Ultimaker/fdm_materials",
|
||||||
|
"description": "Professional 3D printing made accessible."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"DagomaChromatikPLA": {
|
"DagomaChromatikPLA": {
|
||||||
"package_info": {
|
"package_info": {
|
||||||
"package_id": "DagomaChromatikPLA",
|
"package_id": "DagomaChromatikPLA",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user