mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 13:49:02 +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
|
||||
{
|
||||
property var heading: ""
|
||||
property var model
|
||||
id: gridArea
|
||||
height: childrenRect.height + 2 * padding
|
||||
width: parent.width
|
||||
spacing: UM.Theme.getSize("default_margin").height
|
||||
@ -16,7 +19,7 @@ Column
|
||||
Label
|
||||
{
|
||||
id: heading
|
||||
text: toolbox.viewCategory == "material" ? catalog.i18nc("@label", "Community contributions") : catalog.i18nc("@label", "Community plugins")
|
||||
text: gridArea.heading
|
||||
width: parent.width
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
font: UM.Theme.getFont("medium")
|
||||
@ -24,14 +27,13 @@ Column
|
||||
GridLayout
|
||||
{
|
||||
id: grid
|
||||
property var model: toolbox.viewCategory == "material" ? toolbox.authorsModel : toolbox.packagesModel
|
||||
width: parent.width - 2 * parent.padding
|
||||
columns: 2
|
||||
columnSpacing: UM.Theme.getSize("default_margin").height
|
||||
rowSpacing: UM.Theme.getSize("default_margin").width
|
||||
Repeater
|
||||
{
|
||||
model: grid.model
|
||||
model: gridArea.model
|
||||
delegate: ToolboxDownloadsGridTile
|
||||
{
|
||||
Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns
|
||||
|
@ -9,8 +9,8 @@ import UM 1.1 as UM
|
||||
|
||||
Item
|
||||
{
|
||||
property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
||||
property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
||||
property int packageCount: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
||||
property int installedPackages: (toolbox.viewCategory == "material" && model.type === undefined) ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
||||
height: childrenRect.height
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||
Rectangle
|
||||
@ -104,8 +104,18 @@ Item
|
||||
switch(toolbox.viewCategory)
|
||||
{
|
||||
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
|
||||
default:
|
||||
toolbox.viewPage = "detail"
|
||||
|
@ -29,6 +29,17 @@ ScrollView
|
||||
{
|
||||
id: allPlugins
|
||||
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 + 17, "supported_configs")
|
||||
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.
|
||||
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,
|
||||
"has_configs": has_configs,
|
||||
"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.
|
||||
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)
|
||||
else:
|
||||
key_filter = lambda candidate, key = key, value = value: self._matchString(candidate, key, value)
|
||||
|
@ -71,7 +71,8 @@ class Toolbox(QObject, Extension):
|
||||
"plugins_installed": [],
|
||||
"materials_showcase": [],
|
||||
"materials_available": [],
|
||||
"materials_installed": []
|
||||
"materials_installed": [],
|
||||
"materials_generic": []
|
||||
} # type: Dict[str, List[Any]]
|
||||
|
||||
# Models:
|
||||
@ -83,7 +84,8 @@ class Toolbox(QObject, Extension):
|
||||
"plugins_installed": PackagesModel(self),
|
||||
"materials_showcase": AuthorsModel(self),
|
||||
"materials_available": PackagesModel(self),
|
||||
"materials_installed": PackagesModel(self)
|
||||
"materials_installed": PackagesModel(self),
|
||||
"materials_generic": PackagesModel(self)
|
||||
} # type: Dict[str, ListModel]
|
||||
|
||||
# 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_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_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.
|
||||
@ -229,6 +232,7 @@ class Toolbox(QObject, Extension):
|
||||
self._makeRequestByType("plugins_showcase")
|
||||
self._makeRequestByType("materials_showcase")
|
||||
self._makeRequestByType("materials_available")
|
||||
self._makeRequestByType("materials_generic")
|
||||
|
||||
# Gather installed packages:
|
||||
self._updateInstalledModels()
|
||||
@ -640,6 +644,8 @@ class Toolbox(QObject, Extension):
|
||||
self._models[type].setFilter({"type": "plugin"})
|
||||
if type is "authors":
|
||||
self._models[type].setFilter({"package_types": "material"})
|
||||
if type is "materials_generic":
|
||||
self._models[type].setFilter({"tags": "generic"})
|
||||
|
||||
self.metadataChanged.emit()
|
||||
|
||||
@ -761,6 +767,10 @@ class Toolbox(QObject, Extension):
|
||||
def materialsInstalledModel(self) -> PackagesModel:
|
||||
return cast(PackagesModel, self._models["materials_installed"])
|
||||
|
||||
@pyqtProperty(QObject, notify=metadataChanged)
|
||||
def materialsGenericModel(self) -> PackagesModel:
|
||||
return cast(PackagesModel, self._models["materials_generic"])
|
||||
|
||||
|
||||
|
||||
# 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": {
|
||||
"package_info": {
|
||||
"package_id": "DagomaChromatikPLA",
|
||||
|
Loading…
x
Reference in New Issue
Block a user