WorkspaceSection.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.8 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. UM.HelpIcon
  71. {
  72. anchors.right: parent.right
  73. anchors.verticalCenter: comboboxLabel.verticalCenter
  74. color: UM.Theme.getColor("small_button_text")
  75. icon: UM.Theme.getIcon("Information")
  76. text: comboboxTooltipText
  77. visible: comboboxTooltipText != ""
  78. }
  79. }
  80. Loader
  81. {
  82. width: parent.width
  83. height: content.height
  84. anchors.top: sectionTitleRow.bottom
  85. sourceComponent: content
  86. }
  87. function reloadValues()
  88. {
  89. comboboxLoader.sourceComponent = null
  90. comboboxLoader.sourceComponent = combobox
  91. }
  92. }