WorkspaceSection.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. color: UM.Theme.getColor("text")
  31. width: height
  32. }
  33. UM.Label
  34. {
  35. id: sectionTitle
  36. text: ""
  37. anchors.verticalCenter: parent.verticalCenter
  38. font: UM.Theme.getFont("default_bold")
  39. }
  40. }
  41. Item
  42. {
  43. id: comboboxTooltip
  44. width: Math.round(parent.width / 2.5)
  45. height: visible ? UM.Theme.getSize("default_margin").height : 0
  46. anchors.top: parent.top
  47. anchors.right: parent.right
  48. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  49. visible: comboboxVisible
  50. UM.Label
  51. {
  52. id: comboboxLabel
  53. anchors.top: parent.top
  54. anchors.left: parent.left
  55. anchors.topMargin: UM.Theme.getSize("default_margin").height
  56. visible: comboboxVisible && text != ""
  57. text: ""
  58. font: UM.Theme.getFont("default_bold")
  59. }
  60. Loader
  61. {
  62. id: comboboxLoader
  63. width: parent.width
  64. height: UM.Theme.getSize("button").height
  65. anchors.top: comboboxLabel.bottom
  66. anchors.topMargin: UM.Theme.getSize("default_margin").height
  67. anchors.left: parent.left
  68. sourceComponent: combobox
  69. }
  70. MouseArea
  71. {
  72. id: helpIconMouseArea
  73. anchors.right: parent.right
  74. anchors.verticalCenter: comboboxLabel.verticalCenter
  75. width: childrenRect.width
  76. height: childrenRect.height
  77. hoverEnabled: true
  78. UM.ColorImage
  79. {
  80. width: UM.Theme.getSize("section_icon").width
  81. height: width
  82. visible: comboboxTooltipText != ""
  83. source: UM.Theme.getIcon("Help")
  84. color: UM.Theme.getColor("text")
  85. UM.ToolTip
  86. {
  87. text: comboboxTooltipText
  88. visible: helpIconMouseArea.containsMouse
  89. targetPoint: Qt.point(parent.x + Math.round(parent.width / 2), parent.y)
  90. x: 0
  91. y: parent.y + parent.height + UM.Theme.getSize("default_margin").height
  92. width: UM.Theme.getSize("tooltip").width
  93. }
  94. }
  95. }
  96. }
  97. Loader
  98. {
  99. width: parent.width
  100. height: content.height
  101. anchors.top: sectionTitleRow.bottom
  102. sourceComponent: content
  103. }
  104. function reloadValues()
  105. {
  106. comboboxLoader.sourceComponent = null
  107. comboboxLoader.sourceComponent = combobox
  108. }
  109. }