Added machine action buttons dynamic visibility

Based on this change, users now will be able to manage the visibility of their machine action plugin implementations. For example, a machine action only visible when loggedIn.
This commit is contained in:
Julian 2022-09-07 16:29:55 +02:00
parent a8f0e330ad
commit ed14e3bd44
2 changed files with 13 additions and 0 deletions

View file

@ -114,3 +114,15 @@ class MachineAction(QObject, PluginObject):
@pyqtSlot(result = QObject)
def getDisplayItem(self) -> Optional["QObject"]:
return self._createViewFromQML()
@pyqtSlot(result = bool)
def isVisible(self) -> bool:
"""Whether this action button will be visible.
Example: Show only when isLoggedIn
:return: Defaults to true to be in line with the old behaviour.
"""
return True

View file

@ -67,6 +67,7 @@ UM.ManagementPage
{
width: Math.round(childrenRect.width + 2 * screenScaleFactor)
height: childrenRect.height
visible: machineActionRepeater.model[index].isVisible()
Cura.SecondaryButton
{
text: machineActionRepeater.model[index].label