MachineSelection.qml 2.8 KB

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