From 18e5d76990536ae9d5e211cbdcbdbe0c32f219f2 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Thu, 16 Jan 2020 14:57:41 +0100 Subject: [PATCH] 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