SyncButton.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. Button
  9. {
  10. id: base
  11. property var outputDevice: null
  12. property var matched: updateOnSync()
  13. text: matched == true ? catalog.i18nc("@label:extruder label", "Yes") : catalog.i18nc("@label:extruder label", "No")
  14. width: parent.width
  15. height: parent.height
  16. function updateOnSync()
  17. {
  18. if (outputDevice != undefined)
  19. {
  20. for (var index in outputDevice.uniqueConfigurations)
  21. {
  22. var configuration = outputDevice.uniqueConfigurations[index]
  23. if (Cura.MachineManager.matchesConfiguration(configuration))
  24. {
  25. base.matched = true;
  26. return;
  27. }
  28. }
  29. }
  30. base.matched = false;
  31. }
  32. style: ButtonStyle
  33. {
  34. background: Rectangle
  35. {
  36. color:
  37. {
  38. if(control.pressed)
  39. {
  40. return UM.Theme.getColor("sidebar_header_active");
  41. }
  42. else if(control.hovered)
  43. {
  44. return UM.Theme.getColor("sidebar_header_hover");
  45. }
  46. else
  47. {
  48. return UM.Theme.getColor("sidebar_header_bar");
  49. }
  50. }
  51. Behavior on color { ColorAnimation { duration: 50; } }
  52. UM.RecolorImage
  53. {
  54. id: downArrow
  55. anchors.verticalCenter: parent.verticalCenter
  56. anchors.right: parent.right
  57. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  58. width: UM.Theme.getSize("standard_arrow").width
  59. height: UM.Theme.getSize("standard_arrow").height
  60. sourceSize.width: width
  61. sourceSize.height: height
  62. color: UM.Theme.getColor("text_emphasis")
  63. source: UM.Theme.getIcon("arrow_bottom")
  64. }
  65. UM.RecolorImage
  66. {
  67. id: sidebarComboBoxLabel
  68. anchors.left: parent.left
  69. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  70. anchors.verticalCenter: parent.verticalCenter;
  71. width: UM.Theme.getSize("printer_sync_icon").width
  72. height: UM.Theme.getSize("printer_sync_icon").height
  73. color: control.matched ? UM.Theme.getColor("printer_config_matched") : UM.Theme.getColor("printer_config_mismatch")
  74. source: UM.Theme.getIcon("tab_status_connected")
  75. sourceSize.width: width
  76. sourceSize.height: height
  77. }
  78. }
  79. label: Label {}
  80. }
  81. Connections
  82. {
  83. target: outputDevice
  84. onUniqueConfigurationsChanged: updateOnSync()
  85. }
  86. Connections
  87. {
  88. target: Cura.MachineManager
  89. onCurrentConfigurationChanged: updateOnSync()
  90. onOutputDevicesChanged: updateOnSync()
  91. }
  92. }