From 0bde1487e71074db168b8530dbb422529c284c64 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 16 Jul 2018 16:13:43 +0200 Subject: [PATCH 1/3] Add generic material packages to materials page Contributes to CURA-5510 --- .../resources/qml/ToolboxDownloadsGrid.qml | 8 +++++--- .../resources/qml/ToolboxDownloadsGridTile.qml | 14 ++++++++++++-- .../resources/qml/ToolboxDownloadsPage.qml | 11 +++++++++++ plugins/Toolbox/src/PackagesModel.py | 9 ++++++--- plugins/Toolbox/src/Toolbox.py | 16 +++++++++++++--- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml index 823a85cf09..c586828969 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml @@ -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 diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml index dbaa2c83dc..17a41f2e83 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml @@ -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) + { + 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" diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml index 9dd64aacfe..1089fcc51e 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml @@ -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 } } } diff --git a/plugins/Toolbox/src/PackagesModel.py b/plugins/Toolbox/src/PackagesModel.py index 8694619fde..23aa639bde 100644 --- a/plugins/Toolbox/src/PackagesModel.py +++ b/plugins/Toolbox/src/PackagesModel.py @@ -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) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index e0c73cd7fc..a9d0bb03d1 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -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: From f1379135e0fd847b456c409060894a1a097e2dfc Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 17 Jul 2018 13:49:17 +0200 Subject: [PATCH 2/3] CURA-5510 Add the Generic materials to the list of the bundled packages so that they show up as installed. Show the installed icon on those packages as well. --- .../qml/ToolboxDownloadsGridTile.qml | 6 +- resources/bundled_packages.json | 216 ++++++++++++++++++ 2 files changed, 219 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml index 17a41f2e83..392b867071 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml @@ -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 @@ -106,7 +106,7 @@ Item case "material": // If model has a type, it must be a package - if (model.type) + if (model.type !== undefined) { toolbox.viewPage = "detail" toolbox.filterModelByProp("packages", "id", model.id) diff --git a/resources/bundled_packages.json b/resources/bundled_packages.json index 7f3ba2a92e..428b9e3dc9 100644 --- a/resources/bundled_packages.json +++ b/resources/bundled_packages.json @@ -713,6 +713,222 @@ } } }, + "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." + } + } + }, + "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", From f90409452df8dc47cd21c54292372edabb98f6a9 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 17 Jul 2018 14:01:44 +0200 Subject: [PATCH 3/3] Add generic CPE+ as a bundled package. Contributes to CURA-5510. --- resources/bundled_packages.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/resources/bundled_packages.json b/resources/bundled_packages.json index 428b9e3dc9..6d9b9d1a95 100644 --- a/resources/bundled_packages.json +++ b/resources/bundled_packages.json @@ -767,6 +767,24 @@ } } }, + "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",