PrepareMenu.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Layouts 1.1
  5. import QtQuick.Controls 2.3
  6. import UM 1.3 as UM
  7. import Cura 1.1 as Cura
  8. import QtGraphicalEffects 1.0 // For the dropshadow
  9. Item
  10. {
  11. id: prepareMenu
  12. // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it.
  13. signal showTooltip(Item item, point location, string text)
  14. signal hideTooltip()
  15. UM.I18nCatalog
  16. {
  17. id: catalog
  18. name: "cura"
  19. }
  20. // Item to ensure that all of the buttons are nicely centered.
  21. Item
  22. {
  23. anchors.horizontalCenter: parent.horizontalCenter
  24. width: openFileButton.width + itemRow.width + UM.Theme.getSize("default_margin").width
  25. height: parent.height
  26. RowLayout
  27. {
  28. id: itemRow
  29. anchors.left: openFileButton.right
  30. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  31. width: Math.round(0.9 * prepareMenu.width)
  32. height: parent.height
  33. spacing: 0
  34. Cura.MachineSelector
  35. {
  36. id: machineSelection
  37. z: openFileButton.z - 1 //Ensure that the tooltip of the open file button stays above the item row.
  38. headerCornerSide: Cura.RoundedRectangle.Direction.Left
  39. Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width
  40. Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width
  41. Layout.fillWidth: true
  42. Layout.fillHeight: true
  43. }
  44. // Separator line
  45. Rectangle
  46. {
  47. height: parent.height
  48. width: UM.Theme.getSize("default_lining").width
  49. color: UM.Theme.getColor("lining")
  50. }
  51. Cura.ConfigurationMenu
  52. {
  53. Layout.fillHeight: true
  54. Layout.fillWidth: true
  55. Layout.preferredWidth: itemRow.width - machineSelection.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width
  56. }
  57. // Separator line
  58. Rectangle
  59. {
  60. height: parent.height
  61. width: UM.Theme.getSize("default_lining").width
  62. color: UM.Theme.getColor("lining")
  63. }
  64. Item
  65. {
  66. id: printSetupSelectorItem
  67. // This is a work around to prevent the printSetupSelector from having to be re-loaded every time
  68. // a stage switch is done.
  69. children: [printSetupSelector]
  70. height: childrenRect.height
  71. width: childrenRect.width
  72. }
  73. }
  74. Button
  75. {
  76. id: openFileButton
  77. height: UM.Theme.getSize("stage_menu").height
  78. width: UM.Theme.getSize("stage_menu").height
  79. onClicked: Cura.Actions.open.trigger()
  80. hoverEnabled: true
  81. contentItem: Item
  82. {
  83. anchors.fill: parent
  84. UM.RecolorImage
  85. {
  86. id: buttonIcon
  87. anchors.centerIn: parent
  88. source: UM.Theme.getIcon("load")
  89. width: UM.Theme.getSize("button_icon").width
  90. height: UM.Theme.getSize("button_icon").height
  91. color: UM.Theme.getColor("toolbar_button_text")
  92. sourceSize.height: height
  93. }
  94. }
  95. background: Rectangle
  96. {
  97. id: background
  98. height: UM.Theme.getSize("stage_menu").height
  99. width: UM.Theme.getSize("stage_menu").height
  100. radius: UM.Theme.getSize("default_radius").width
  101. color: openFileButton.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
  102. }
  103. DropShadow
  104. {
  105. id: shadow
  106. // Don't blur the shadow
  107. radius: 0
  108. anchors.fill: background
  109. source: background
  110. verticalOffset: 2
  111. visible: true
  112. color: UM.Theme.getColor("action_button_shadow")
  113. // Should always be drawn behind the background.
  114. z: background.z - 1
  115. }
  116. }
  117. }
  118. }