Просмотр исходного кода

CURA-4870 Update the Sync Button accordingly to changes both in the
output device or in the current configuration, in order to check wether
a configuration matches or not.

Diego Prado Gesto 7 лет назад
Родитель
Сommit
987794c515

+ 32 - 1
resources/qml/Menus/ConfigurationMenu/SyncButton.qml

@@ -6,13 +6,30 @@ import QtQuick.Controls 1.4
 import QtQuick.Controls.Styles 1.4
 
 import UM 1.2 as UM
+import Cura 1.0 as Cura
 
 Button
 {
-    text: "No match"
+    id: base
+    property var outputDevice: Cura.MachineManager.printerOutputDevices[0] != null ? Cura.MachineManager.printerOutputDevices[0] : null
+    text: catalog.i18nc("@label:sync indicator", "No match")
     width: parent.width
     height: parent.height
 
+    function updateOnSync()
+    {
+        for (var index in outputDevice.uniqueConfigurations)
+        {
+            var configuration = outputDevice.uniqueConfigurations[index]
+            if (Cura.MachineManager.matchesConfiguration(configuration))
+            {
+                base.text = catalog.i18nc("@label:sync indicator", "Matched")
+                return
+            }
+        }
+        base.text = catalog.i18nc("@label:sync indicator", "No match")
+    }
+
     style: ButtonStyle
     {
         background: Rectangle
@@ -68,4 +85,18 @@ Button
     {
         panelVisible = !panelVisible
     }
+
+    Connections {
+        target: outputDevice
+        onUniqueConfigurationsChanged: {
+            updateOnSync()
+        }
+    }
+
+    Connections {
+        target: Cura.MachineManager
+        onCurrentConfigurationChanged: {
+            updateOnSync()
+        }
+    }
 }

+ 1 - 2
resources/qml/SidebarHeader.qml

@@ -63,8 +63,7 @@ Column
 
         ToolButton
         {
-            id: configurationSelection
-
+            id: printerTypeSelection
             text: catalog.i18nc("@label", "Printer type");
             height: UM.Theme.getSize("setting_control").height
             width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width