From dbab3c6e8b0b6d3617c6d1a9cad801dcc655d44b Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Wed, 15 Jan 2020 11:50:59 +0100 Subject: [PATCH 1/4] Add more materials from Marketplace menu button This commit adds a button "Add more materials from Marketplace" in the menu that pops up in the material list while configuring the materials into custom ones. The button redirects the user to the Marketplace materials page (https://marketplace.ultimaker.com/app/cura/materials) CURA-7027 --- resources/qml/Actions.qml | 9 +++++++++ resources/qml/Menus/MaterialMenu.qml | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index e5b39c6ba5..3c978df115 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -54,6 +54,7 @@ Item property alias manageProfiles: manageProfilesAction; property alias manageMaterials: manageMaterialsAction; + property alias marketplaceMaterials: marketplaceMaterialsAction; property alias preferences: preferencesAction; @@ -188,6 +189,14 @@ Item shortcut: "Ctrl+K" } + Action + { + id: marketplaceMaterialsAction + onTriggered: Qt.openUrlExternally("https://marketplace.ultimaker.com/app/cura/materials") + iconName: "configure" + text: catalog.i18nc("@action:inmenu", "Add more materials from Marketplace") + } + Action { id: updateProfileAction; diff --git a/resources/qml/Menus/MaterialMenu.qml b/resources/qml/Menus/MaterialMenu.qml index c101f56da5..b733ead40b 100644 --- a/resources/qml/Menus/MaterialMenu.qml +++ b/resources/qml/Menus/MaterialMenu.qml @@ -157,4 +157,11 @@ Menu { action: Cura.Actions.manageMaterials } + + MenuSeparator {} + + MenuItem + { + action: Cura.Actions.marketplaceMaterials + } } From 18e5d76990536ae9d5e211cbdcbdbe0c32f219f2 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Thu, 16 Jan 2020 14:57:41 +0100 Subject: [PATCH 2/4] Fix button to open in-Cura Marketplace materials The button was opening the online Marketplace, which was wrong. This fix changes the behavior to open the in-Cura Marketplace at the materials tab. In order to achieve that, the button calls an action called materialsMarketplace, which in turn is connected through a Connection in the ApplicationMenu. When the action is triggered, it first launched the Toolbox and then it sets its category to the materials tab. Since the callExtensionMethod does not allow us to provide input arguments to the called method, a new method had to be created in the toolbox that changes the view to the materials tab, instead of immediately calling the setViewCategory("material"). CURA-7027 --- plugins/Toolbox/src/Toolbox.py | 3 +++ resources/qml/Actions.qml | 1 - resources/qml/MainWindow/ApplicationMenu.qml | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index dd01458a32..0436befdb9 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -779,6 +779,9 @@ class Toolbox(QObject, Extension): self._view_category = category self.viewChanged.emit() + def setViewCategoryToMaterials(self) -> None: + self.setViewCategory("material") + @pyqtProperty(str, fset = setViewCategory, notify = viewChanged) def viewCategory(self) -> str: return self._view_category diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 3c978df115..8a1b2092fa 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -192,7 +192,6 @@ Item Action { id: marketplaceMaterialsAction - onTriggered: Qt.openUrlExternally("https://marketplace.ultimaker.com/app/cura/materials") iconName: "configure" text: catalog.i18nc("@action:inmenu", "Add more materials from Marketplace") } diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 30e44d7d3b..9ee9e75ad3 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -163,4 +163,15 @@ Item curaExtensions.callExtensionMethod("Toolbox", "launch") } } + + // Show the Marketplace dialog at the materials tab + Connections + { + target: Cura.Actions.marketplaceMaterials + onTriggered: + { + curaExtensions.callExtensionMethod("Toolbox", "launch") + curaExtensions.callExtensionMethod("Toolbox", "setViewCategoryToMaterials") + } + } } \ No newline at end of file From 50fbe02c58ffe0d76d74715d05253829f5f78836 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Thu, 16 Jan 2020 15:19:51 +0100 Subject: [PATCH 3/4] Add comment CURA-7027 --- plugins/Toolbox/src/Toolbox.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 0436befdb9..85bfaeafb2 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -779,6 +779,8 @@ class Toolbox(QObject, Extension): self._view_category = category self.viewChanged.emit() + ## Function explicitly defined so that it can be called through the callExtensionsMethod + # which cannot receive arguments. def setViewCategoryToMaterials(self) -> None: self.setViewCategory("material") From 4b60da6802b7eab64ec26fcb4c76f5dd4ae12315 Mon Sep 17 00:00:00 2001 From: ninovanhooff Date: Thu, 16 Jan 2020 16:26:15 +0100 Subject: [PATCH 4/4] Update resources/qml/Actions.qml Remove redundant icon from marketplaceMaterialsAction --- resources/qml/Actions.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 8a1b2092fa..c62b0cb89a 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -192,7 +192,6 @@ Item Action { id: marketplaceMaterialsAction - iconName: "configure" text: catalog.i18nc("@action:inmenu", "Add more materials from Marketplace") }