MachineListButton.qml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import UM 1.5 as UM
  6. import Cura 1.0 as Cura
  7. Button
  8. {
  9. id: machineListButton
  10. width: parent.width
  11. height: UM.Theme.getSize("large_button").height
  12. leftPadding: UM.Theme.getSize("default_margin").width
  13. rightPadding: UM.Theme.getSize("default_margin").width
  14. checkable: true
  15. hoverEnabled: true
  16. contentItem: Item
  17. {
  18. width: machineListButton.width - machineListButton.leftPadding - machineListButton.rightPadding
  19. height: UM.Theme.getSize("action_button").height
  20. UM.ColorImage
  21. {
  22. id: printerIcon
  23. height: UM.Theme.getSize("medium_button").height
  24. width: UM.Theme.getSize("medium_button").width
  25. color: UM.Theme.getColor("machine_selector_printer_icon")
  26. visible: model.machineType == "abstract_machine" || !model.isOnline
  27. source: model.machineType == "abstract_machine" ? UM.Theme.getIcon("PrinterTriple", "medium") : UM.Theme.getIcon("Printer", "medium")
  28. anchors
  29. {
  30. left: parent.left
  31. verticalCenter: parent.verticalCenter
  32. }
  33. }
  34. UM.Label
  35. {
  36. id: buttonText
  37. anchors
  38. {
  39. left: printerIcon.right
  40. right: printerCount.left
  41. verticalCenter: parent.verticalCenter
  42. leftMargin: UM.Theme.getSize("default_margin").width
  43. }
  44. text: machineListButton.text
  45. font: model.machineType == "abstract_machine" ? UM.Theme.getFont("medium_bold") : UM.Theme.getFont("medium")
  46. visible: text != ""
  47. elide: Text.ElideRight
  48. }
  49. Rectangle
  50. {
  51. id: printerCount
  52. color: UM.Theme.getColor("background_2")
  53. radius: height
  54. width: height
  55. anchors
  56. {
  57. right: parent.right
  58. top: buttonText.top
  59. bottom: buttonText.bottom
  60. }
  61. visible: model.machineType == "abstract_machine"
  62. UM.Label
  63. {
  64. text: model.machineCount
  65. anchors.centerIn: parent
  66. font: UM.Theme.getFont("default_bold")
  67. }
  68. }
  69. }
  70. background: Rectangle
  71. {
  72. id: backgroundRect
  73. color: machineListButton.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent"
  74. }
  75. }