MachineSelection.qml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright (c) 2017 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. style: ButtonStyle
  19. {
  20. background: Rectangle
  21. {
  22. color:
  23. {
  24. if (control.pressed) {
  25. return UM.Theme.getColor("sidebar_header_active");
  26. }
  27. else if (control.hovered) {
  28. return UM.Theme.getColor("sidebar_header_hover");
  29. }
  30. else {
  31. return UM.Theme.getColor("sidebar_header_bar");
  32. }
  33. }
  34. Behavior on color { ColorAnimation { duration: 50; } }
  35. UM.RecolorImage
  36. {
  37. id: downArrow
  38. anchors.verticalCenter: parent.verticalCenter
  39. anchors.right: parent.right
  40. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  41. width: UM.Theme.getSize("standard_arrow").width
  42. height: UM.Theme.getSize("standard_arrow").height
  43. sourceSize.width: width
  44. sourceSize.height: width
  45. color: UM.Theme.getColor("text_emphasis")
  46. source: UM.Theme.getIcon("arrow_bottom")
  47. }
  48. PrinterStatusIcon
  49. {
  50. id: printerStatusIcon
  51. visible: printerConnected || isNetworkPrinter
  52. status: printerStatus
  53. anchors
  54. {
  55. verticalCenter: parent.verticalCenter
  56. left: parent.left
  57. leftMargin: UM.Theme.getSize("sidebar_margin").width
  58. }
  59. }
  60. Label
  61. {
  62. id: sidebarComboBoxLabel
  63. color: UM.Theme.getColor("sidebar_header_text_active")
  64. text: control.text;
  65. elide: Text.ElideRight;
  66. anchors.left: printerStatusIcon.visible ? printerStatusIcon.right : parent.left;
  67. anchors.leftMargin: printerStatusIcon.visible ? UM.Theme.getSize("sidebar_lining").width : UM.Theme.getSize("sidebar_margin").width
  68. anchors.right: downArrow.left;
  69. anchors.rightMargin: control.rightMargin;
  70. anchors.verticalCenter: parent.verticalCenter;
  71. font: UM.Theme.getFont("medium_bold")
  72. }
  73. }
  74. label: Label {}
  75. }
  76. menu: PrinterMenu { }
  77. }