LightGroup.qml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import QtQuick 2.0
  2. import QtQuick.Controls 2.2
  3. Item {
  4. id: root
  5. property string title: ""
  6. property QtObject lights: undefined
  7. Column {
  8. width: root.width
  9. spacing: 5
  10. GradientButton {
  11. width: root.width
  12. height: 40
  13. visible: Boolean(root.title)
  14. radius: 5
  15. Label {
  16. anchors.centerIn: parent
  17. text: root.title
  18. }
  19. Image {
  20. anchors.left: parent.left
  21. anchors.top: parent.top
  22. anchors.bottom: parent.bottom
  23. anchors.margins: 5
  24. width: height
  25. source: "Off.png"
  26. }
  27. }
  28. Row {
  29. id: buttonsRow
  30. width: root.width
  31. height: childrenRect.height
  32. spacing: 5
  33. Repeater {
  34. model: root.lights
  35. width: root.width
  36. GradientButton {
  37. id: button
  38. width: (root.width - buttonsRow.spacing * (root.lights.count - 1)) / root.lights.count
  39. height: width / 2
  40. radius: 5
  41. Column {
  42. anchors.centerIn: parent
  43. Image {
  44. height: button.height * 0.5
  45. width: height
  46. anchors.horizontalCenter: parent.horizontalCenter
  47. source: "lamp.png"
  48. }
  49. Label {
  50. anchors.horizontalCenter: parent.horizontalCenter
  51. horizontalAlignment: Text.horizontalCenter
  52. text: name
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }