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.
This commit is contained in:
Diego Prado Gesto 2018-03-06 16:59:51 +01:00
parent 5280d21c26
commit 987794c515
2 changed files with 33 additions and 3 deletions

View file

@ -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()
}
}
}