Browse Source

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.
Julian 2 years ago
parent
commit
ed14e3bd44
2 changed files with 13 additions and 0 deletions
  1. 12 0
      cura/MachineAction.py
  2. 1 0
      resources/qml/Preferences/MachinesPage.qml

+ 12 - 0
cura/MachineAction.py

@@ -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
+    

+ 1 - 0
resources/qml/Preferences/MachinesPage.qml

@@ -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