MachineSelector.qml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. import "Menus"
  10. ToolButton
  11. {
  12. id: base
  13. property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
  14. property bool printerConnected: Cura.MachineManager.printerConnected
  15. property var printerStatus: Cura.MachineManager.printerConnected ? "connected" : "disconnected"
  16. text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName
  17. tooltip: Cura.MachineManager.activeMachineName
  18. width: 240
  19. style: ButtonStyle
  20. {
  21. background: Rectangle
  22. {
  23. color:
  24. {
  25. if (control.pressed) {
  26. return UM.Theme.getColor("machine_selector_active");
  27. }
  28. else if (control.hovered) {
  29. return UM.Theme.getColor("machine_selector_hover");
  30. }
  31. else {
  32. return UM.Theme.getColor("machine_selector_bar");
  33. }
  34. }
  35. Behavior on color { ColorAnimation { duration: 50; } }
  36. UM.RecolorImage
  37. {
  38. id: downArrow
  39. anchors.verticalCenter: parent.verticalCenter
  40. anchors.right: parent.right
  41. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  42. width: UM.Theme.getSize("standard_arrow").width
  43. height: UM.Theme.getSize("standard_arrow").height
  44. sourceSize.width: width
  45. sourceSize.height: width
  46. color: UM.Theme.getColor("text_emphasis")
  47. source: UM.Theme.getIcon("arrow_bottom")
  48. }
  49. PrinterStatusIcon
  50. {
  51. id: printerStatusIcon
  52. visible: printerConnected || isNetworkPrinter
  53. status: printerStatus
  54. anchors
  55. {
  56. verticalCenter: parent.verticalCenter
  57. left: parent.left
  58. leftMargin: UM.Theme.getSize("thick_margin").width
  59. }
  60. }
  61. Label
  62. {
  63. id: sidebarComboBoxLabel
  64. color: UM.Theme.getColor("machine_selector_text_active")
  65. text: control.text;
  66. elide: Text.ElideRight;
  67. anchors.left: printerStatusIcon.visible ? printerStatusIcon.right : parent.left;
  68. anchors.leftMargin: printerStatusIcon.visible ? UM.Theme.getSize("narrow_margin").width : UM.Theme.getSize("thick_margin").width
  69. anchors.right: downArrow.left;
  70. anchors.rightMargin: control.rightMargin;
  71. anchors.verticalCenter: parent.verticalCenter;
  72. font: UM.Theme.getFont("medium_bold")
  73. }
  74. }
  75. label: Label {}
  76. }
  77. menu: PrinterMenu { }
  78. }