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
This commit is contained in:
Kostas Karmas 2020-01-16 14:57:41 +01:00
parent 4cb074c5cd
commit 18e5d76990
3 changed files with 14 additions and 1 deletions

View file

@ -779,6 +779,9 @@ class Toolbox(QObject, Extension):
self._view_category = category self._view_category = category
self.viewChanged.emit() self.viewChanged.emit()
def setViewCategoryToMaterials(self) -> None:
self.setViewCategory("material")
@pyqtProperty(str, fset = setViewCategory, notify = viewChanged) @pyqtProperty(str, fset = setViewCategory, notify = viewChanged)
def viewCategory(self) -> str: def viewCategory(self) -> str:
return self._view_category return self._view_category

View file

@ -192,7 +192,6 @@ Item
Action Action
{ {
id: marketplaceMaterialsAction id: marketplaceMaterialsAction
onTriggered: Qt.openUrlExternally("https://marketplace.ultimaker.com/app/cura/materials")
iconName: "configure" iconName: "configure"
text: catalog.i18nc("@action:inmenu", "Add more materials from Marketplace") text: catalog.i18nc("@action:inmenu", "Add more materials from Marketplace")
} }

View file

@ -163,4 +163,15 @@ Item
curaExtensions.callExtensionMethod("Toolbox", "launch") 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")
}
}
} }