MachineSelection.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. id: base
  12. property var isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
  13. property var printerStatus: Cura.MachineManager.printerOutputDevices.length != 0 ? "connected" : "disconnected"
  14. text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName
  15. tooltip: Cura.MachineManager.activeMachineName
  16. style: ButtonStyle {
  17. background: Rectangle {
  18. color: {
  19. if (control.pressed) {
  20. return UM.Theme.getColor("sidebar_header_active");
  21. }
  22. else if (control.hovered) {
  23. return UM.Theme.getColor("sidebar_header_hover");
  24. }
  25. else {
  26. return UM.Theme.getColor("sidebar_header_bar");
  27. }
  28. }
  29. Behavior on color { ColorAnimation { duration: 50; } }
  30. UM.RecolorImage {
  31. id: downArrow
  32. anchors.verticalCenter: parent.verticalCenter
  33. anchors.right: parent.right
  34. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  35. width: UM.Theme.getSize("standard_arrow").width
  36. height: UM.Theme.getSize("standard_arrow").height
  37. sourceSize.width: width
  38. sourceSize.height: width
  39. color: UM.Theme.getColor("text_emphasis")
  40. source: UM.Theme.getIcon("arrow_bottom")
  41. }
  42. PrinterStatusIcon {
  43. id: printerStatusIcon
  44. visible: isNetworkPrinter
  45. status: printerStatus
  46. anchors {
  47. verticalCenter: parent.verticalCenter
  48. left: parent.left
  49. leftMargin: UM.Theme.getSize("sidebar_margin").width
  50. }
  51. }
  52. Label {
  53. id: sidebarComboBoxLabel
  54. color: UM.Theme.getColor("sidebar_header_text_active")
  55. text: control.text;
  56. elide: Text.ElideRight;
  57. anchors.left: isNetworkPrinter ? printerStatusIcon.right : parent.left;
  58. anchors.leftMargin: isNetworkPrinter ? UM.Theme.getSize("sidebar_lining").width : UM.Theme.getSize("sidebar_margin").width
  59. anchors.right: downArrow.left;
  60. anchors.rightMargin: control.rightMargin;
  61. anchors.verticalCenter: parent.verticalCenter;
  62. font: UM.Theme.getFont("medium_bold")
  63. }
  64. }
  65. label: Label {}
  66. }
  67. menu: PrinterMenu { }
  68. // Make the toolbutton react when the outputdevice changes
  69. Connections
  70. {
  71. target: Cura.MachineManager
  72. onOutputDevicesChanged:
  73. {
  74. base.isNetworkPrinter = Cura.MachineManager.activeMachineNetworkKey != ""
  75. }
  76. }
  77. }