WorkspaceSection.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Copyright (c) 2022 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. Item
  7. {
  8. property alias title: sectionTitle.text
  9. property alias iconSource: sectionTitleIcon.source
  10. property Component content: Item { visible: false }
  11. property alias comboboxTitle: comboboxLabel.text
  12. property Component combobox: Item { visible: false }
  13. property string comboboxTooltipText: ""
  14. property bool comboboxVisible: false
  15. width: parent.width
  16. height: childrenRect.height
  17. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  18. Row
  19. {
  20. id: sectionTitleRow
  21. anchors.top: parent.top
  22. bottomPadding: UM.Theme.getSize("default_margin").height
  23. spacing: UM.Theme.getSize("default_margin").width
  24. UM.ColorImage
  25. {
  26. id: sectionTitleIcon
  27. anchors.verticalCenter: parent.verticalCenter
  28. source: ""
  29. height: UM.Theme.getSize("medium_button_icon").height
  30. width: height
  31. }
  32. UM.Label
  33. {
  34. id: sectionTitle
  35. text: ""
  36. anchors.verticalCenter: parent.verticalCenter
  37. font: UM.Theme.getFont("default_bold")
  38. }
  39. }
  40. Item
  41. {
  42. id: comboboxTooltip
  43. width: Math.round(parent.width / 2.5)
  44. height: visible ? UM.Theme.getSize("default_margin").height : 0
  45. anchors.top: parent.top
  46. anchors.right: parent.right
  47. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  48. visible: comboboxVisible
  49. UM.Label
  50. {
  51. id: comboboxLabel
  52. anchors.top: parent.top
  53. anchors.left: parent.left
  54. anchors.topMargin: UM.Theme.getSize("default_margin").height
  55. visible: comboboxVisible && text != ""
  56. text: ""
  57. font: UM.Theme.getFont("default_bold")
  58. }
  59. Loader
  60. {
  61. id: comboboxLoader
  62. width: parent.width
  63. height: UM.Theme.getSize("button").height
  64. anchors.top: comboboxLabel.bottom
  65. anchors.topMargin: UM.Theme.getSize("default_margin").height
  66. anchors.left: parent.left
  67. sourceComponent: combobox
  68. }
  69. MouseArea
  70. {
  71. id: helpIconMouseArea
  72. anchors.right: parent.right
  73. anchors.verticalCenter: comboboxLabel.verticalCenter
  74. width: childrenRect.width
  75. height: childrenRect.height
  76. hoverEnabled: true
  77. UM.ColorImage
  78. {
  79. width: UM.Theme.getSize("section_icon").width
  80. height: width
  81. visible: comboboxTooltipText != ""
  82. source: UM.Theme.getIcon("Help")
  83. UM.ToolTip
  84. {
  85. text: comboboxTooltipText
  86. visible: helpIconMouseArea.containsMouse
  87. targetPoint: Qt.point(parent.x + Math.round(parent.width / 2), parent.y)
  88. x: 0
  89. y: parent.y + parent.height + UM.Theme.getSize("default_margin").height
  90. width: UM.Theme.getSize("tooltip").width
  91. }
  92. }
  93. }
  94. }
  95. Loader
  96. {
  97. width: parent.width
  98. height: content.height
  99. anchors.top: sectionTitleRow.bottom
  100. sourceComponent: content
  101. }
  102. function reloadValues()
  103. {
  104. comboboxLoader.sourceComponent = null
  105. comboboxLoader.sourceComponent = combobox
  106. }
  107. }