From 9258c9a7fc49b3bbe8b7c775c1b4377ca26fe4ef Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 31 Aug 2018 11:03:30 +0200 Subject: [PATCH 1/6] Added links to toolbox CURA-5676 --- .../resources/qml/ToolboxAuthorPage.qml | 31 ++++++++++- .../qml/ToolboxCompatibilityChart.qml | 47 ++++++++++++++++ plugins/Toolbox/src/PackagesModel.py | 54 ++++++++++++------- 3 files changed, 111 insertions(+), 21 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 04b055ed66..9666e65613 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -82,9 +82,16 @@ Item } spacing: Math.floor(UM.Theme.getSize("narrow_margin").height) width: childrenRect.width + Label { - text: catalog.i18nc("@label", "Contact") + ":" + text: catalog.i18nc("@label", "Website") + ":" + font: UM.Theme.getFont("very_small") + color: UM.Theme.getColor("text_medium") + } + Label + { + text: catalog.i18nc("@label", "Email") + ":" font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text_medium") } @@ -100,6 +107,26 @@ Item topMargin: UM.Theme.getSize("default_margin").height } spacing: Math.floor(UM.Theme.getSize("narrow_margin").height) + + Label + { + text: + { + if (details.website) + { + return "Link" + } + else + { + return "" + } + } + font: UM.Theme.getFont("very_small") + color: UM.Theme.getColor("text") + linkColor: UM.Theme.getColor("text_link") + onLinkActivated: Qt.openUrlExternally(link) + } + Label { text: @@ -110,7 +137,7 @@ Item } else { - return ""+details.name+"" + return "" } } font: UM.Theme.getFont("very_small") diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml index 1efcde2110..2ab8db007b 100644 --- a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml +++ b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml @@ -8,7 +8,31 @@ import UM 1.1 as UM Item { + id: base + property var packageData + property var technical_data_sheet_url + + function initiazeLinks() + { + var all_links = packageData.links + for(var index = 0; index < all_links.length; index++) + { + var temp_link = all_links[index] + var title = temp_link["title"] + + if(title === "Technical Data Sheet") + { + base.technical_data_sheet_url = temp_link["url"] + } + } + } + + Component.onCompleted: + { + initiazeLinks() + } + anchors.topMargin: UM.Theme.getSize("default_margin").height height: visible ? childrenRect.height : 0 visible: packageData.type == "material" && packageData.has_configs @@ -132,4 +156,27 @@ Item width: Math.floor(table.width * 0.1) } } + + + + Label + { + id: technical_data_sheet + anchors.top: table.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height / 2 + visible: base.technical_data_sheet_url !== undefined + text: + { + if (base.technical_data_sheet_url !== undefined) + { + return "%2".arg(base.technical_data_sheet_url).arg("Technical Data Sheet") + } + return "" + } + font: UM.Theme.getFont("very_small") + color: UM.Theme.getColor("text") + linkColor: UM.Theme.getColor("text_link") + onLinkActivated: Qt.openUrlExternally(link) + } + } diff --git a/plugins/Toolbox/src/PackagesModel.py b/plugins/Toolbox/src/PackagesModel.py index 8b9199b127..ddbd2d2665 100644 --- a/plugins/Toolbox/src/PackagesModel.py +++ b/plugins/Toolbox/src/PackagesModel.py @@ -7,6 +7,7 @@ from typing import Dict from PyQt5.QtCore import Qt, pyqtProperty from UM.Qt.ListModel import ListModel from .ConfigsModel import ConfigsModel +from UM.Logger import Logger ## Model that holds cura packages. By setting the filter property the instances held by this model can be changed. class PackagesModel(ListModel): @@ -34,6 +35,8 @@ class PackagesModel(ListModel): self.addRoleName(Qt.UserRole + 17, "supported_configs") self.addRoleName(Qt.UserRole + 18, "download_count") self.addRoleName(Qt.UserRole + 19, "tags") + self.addRoleName(Qt.UserRole + 20, "links") + self.addRoleName(Qt.UserRole + 21, "website") # List of filters for queries. The result is the union of the each list of results. self._filter = {} # type: Dict[str, str] @@ -45,10 +48,18 @@ class PackagesModel(ListModel): def _update(self): items = [] + #If a user has a slow internet connection then the metadata might be None + if self._metadata is None: + Logger.logException("w", "Failed to load packages for Toolbox") + self.setItems(items) + return + + for package in self._metadata: has_configs = False configs_model = None + data_links = [] if "data" in package: if "supported_configs" in package["data"]: if len(package["data"]["supported_configs"]) > 0: @@ -56,33 +67,38 @@ class PackagesModel(ListModel): configs_model = ConfigsModel() configs_model.setConfigs(package["data"]["supported_configs"]) + data_links = package['data']['links'] if 'links' in package['data'] else [] + if "author_id" not in package["author"] or "display_name" not in package["author"]: package["author"]["author_id"] = "" package["author"]["display_name"] = "" # raise Exception("Detected a package with malformed author data.") items.append({ - "id": package["package_id"], - "type": package["package_type"], - "name": package["display_name"], - "version": package["package_version"], - "author_id": package["author"]["author_id"], - "author_name": package["author"]["display_name"], - "author_email": package["author"]["email"] if "email" in package["author"] else None, - "description": package["description"] if "description" in package else None, - "icon_url": package["icon_url"] if "icon_url" in package else None, - "image_urls": package["image_urls"] if "image_urls" in package else None, - "download_url": package["download_url"] if "download_url" in package else None, - "last_updated": package["last_updated"] if "last_updated" in package else None, - "is_bundled": package["is_bundled"] if "is_bundled" in package else False, - "is_active": package["is_active"] if "is_active" in package else False, - "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, - "tags": package["tags"] if "tags" in package else [] + "id": package["package_id"], + "type": package["package_type"], + "name": package["display_name"], + "version": package["package_version"], + "author_id": package["author"]["author_id"], + "author_name": package["author"]["display_name"], + "author_email": package["author"]["email"] if "email" in package["author"] else None, + "description": package["description"] if "description" in package else None, + "icon_url": package["icon_url"] if "icon_url" in package else None, + "image_urls": package["image_urls"] if "image_urls" in package else None, + "download_url": package["download_url"] if "download_url" in package else None, + "last_updated": package["last_updated"] if "last_updated" in package else None, + "is_bundled": package["is_bundled"] if "is_bundled" in package else False, + "is_active": package["is_active"] if "is_active" in package else False, + "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, + "tags": package["tags"] if "tags" in package else [], + "links": data_links, + "website": package["website"] if "website" in package else None, }) + # Filter on all the key-word arguments. for key, value in self._filter.items(): if key is "tags": From b0b148f2d0d7ad880608880779f2b0d0fa3a7967 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 31 Aug 2018 11:06:25 +0200 Subject: [PATCH 2/6] Remove wrong setting CURA-5676 --- resources/definitions/fdmprinter.def.json | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 1b2d66810b..3eb7cb1c32 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -3875,19 +3875,6 @@ } } }, - "support_infill_angle": - { - "label": "Support Infill Line Direction", - "description": "Orientation of the infill pattern for supports. The support infill pattern is rotated in the horizontal plane.", - "unit": "°", - "type": "float", - "minimum_value": "-90", - "maximum_value": "90", - "default_value": 0, - "enabled": "support_enable", - "settable_per_mesh": false, - "settable_per_extruder": true - }, "support_z_distance": { "label": "Support Z Distance", From e17cf3dfbffd8c8d2c19ec97c059d7629f22ebb5 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 31 Aug 2018 13:20:40 +0200 Subject: [PATCH 3/6] Show company website full link as text CURA-5676 --- plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 9666e65613..7195f6d276 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -114,7 +114,7 @@ Item { if (details.website) { - return "Link" + return ""+details.website+"" } else { From 9433cf7c45df38b599c3272aa02a7c04e406ae6d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 31 Aug 2018 13:23:39 +0200 Subject: [PATCH 4/6] Change email field to show full email address CURA-5676 --- plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 7195f6d276..be6cd5e713 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -133,7 +133,7 @@ Item { if (details.email) { - return ""+details.name+"" + return ""+details.email+"" } else { From c4afbe7a673ceeac7bee277ef91c1e8efaa3bd41 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 31 Aug 2018 13:45:02 +0200 Subject: [PATCH 5/6] Convert links to a dict CURA-5676 Easier to process. --- .../qml/ToolboxCompatibilityChart.qml | 31 +++++-------------- plugins/Toolbox/src/PackagesModel.py | 27 +++++++++------- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml index 2ab8db007b..4a008f2a83 100644 --- a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml +++ b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml @@ -11,26 +11,13 @@ Item id: base property var packageData - property var technical_data_sheet_url - - function initiazeLinks() - { - var all_links = packageData.links - for(var index = 0; index < all_links.length; index++) + property var technicalDataSheetUrl: { + var link = undefined + if ("Technical Data Sheet" in packageData.links) { - var temp_link = all_links[index] - var title = temp_link["title"] - - if(title === "Technical Data Sheet") - { - base.technical_data_sheet_url = temp_link["url"] - } + link = packageData.links["Technical Data Sheet"] } - } - - Component.onCompleted: - { - initiazeLinks() + return link } anchors.topMargin: UM.Theme.getSize("default_margin").height @@ -157,19 +144,17 @@ Item } } - - Label { id: technical_data_sheet anchors.top: table.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height / 2 - visible: base.technical_data_sheet_url !== undefined + visible: base.technicalDataSheetUrl !== undefined text: { - if (base.technical_data_sheet_url !== undefined) + if (base.technicalDataSheetUrl !== undefined) { - return "%2".arg(base.technical_data_sheet_url).arg("Technical Data Sheet") + return "%2".arg(base.technicalDataSheetUrl).arg("Technical Data Sheet") } return "" } diff --git a/plugins/Toolbox/src/PackagesModel.py b/plugins/Toolbox/src/PackagesModel.py index ddbd2d2665..7892044d00 100644 --- a/plugins/Toolbox/src/PackagesModel.py +++ b/plugins/Toolbox/src/PackagesModel.py @@ -5,9 +5,12 @@ import re from typing import Dict from PyQt5.QtCore import Qt, pyqtProperty -from UM.Qt.ListModel import ListModel -from .ConfigsModel import ConfigsModel + from UM.Logger import Logger +from UM.Qt.ListModel import ListModel + +from .ConfigsModel import ConfigsModel + ## Model that holds cura packages. By setting the filter property the instances held by this model can be changed. class PackagesModel(ListModel): @@ -48,18 +51,16 @@ class PackagesModel(ListModel): def _update(self): items = [] - #If a user has a slow internet connection then the metadata might be None if self._metadata is None: Logger.logException("w", "Failed to load packages for Toolbox") self.setItems(items) return - for package in self._metadata: - has_configs = False configs_model = None - data_links = [] + + links_dict = {} if "data" in package: if "supported_configs" in package["data"]: if len(package["data"]["supported_configs"]) > 0: @@ -67,7 +68,10 @@ class PackagesModel(ListModel): configs_model = ConfigsModel() configs_model.setConfigs(package["data"]["supported_configs"]) - data_links = package['data']['links'] if 'links' in package['data'] else [] + # Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier + # to process. + link_list = package['data']['links'] if 'links' in package['data'] else [] + links_dict = {d["title"]: d["url"] for d in link_list} if "author_id" not in package["author"] or "display_name" not in package["author"]: package["author"]["author_id"] = "" @@ -94,19 +98,18 @@ class PackagesModel(ListModel): "supported_configs": configs_model, "download_count": package["download_count"] if "download_count" in package else 0, "tags": package["tags"] if "tags" in package else [], - "links": data_links, + "links": links_dict, "website": package["website"] if "website" in package else None, }) - # Filter on all the key-word arguments. for key, value in self._filter.items(): if key is "tags": - key_filter = lambda item, value = value: value in item["tags"] + key_filter = lambda item, v = value: v in item["tags"] elif "*" in value: - key_filter = lambda candidate, key = key, value = value: self._matchRegExp(candidate, key, value) + key_filter = lambda candidate, k = key, v = value: self._matchRegExp(candidate, k, v) else: - key_filter = lambda candidate, key = key, value = value: self._matchString(candidate, key, value) + key_filter = lambda candidate, k = key, v = value: self._matchString(candidate, k, v) items = filter(key_filter, items) # Execute all filters. From 98d8a3f3e3c83ffd4443ac2a8afae84d071e80eb Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 31 Aug 2018 13:49:08 +0200 Subject: [PATCH 6/6] Fix code style and small cleanup CURA-5676 --- .../Toolbox/resources/qml/ToolboxAuthorPage.qml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index be6cd5e713..90b92bd832 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -114,12 +114,9 @@ Item { if (details.website) { - return ""+details.website+"" - } - else - { - return "" + return "" + details.website + "" } + return "" } font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text") @@ -133,12 +130,9 @@ Item { if (details.email) { - return ""+details.email+"" - } - else - { - return "" + return "" + details.email + "" } + return "" } font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text")