LightGroup.qml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. signal channelClicked(int channelId)
  8. Column {
  9. width: root.width
  10. spacing: 5
  11. GradientButton {
  12. width: root.width
  13. height: 40
  14. visible: Boolean(root.title)
  15. radius: 5
  16. Label {
  17. anchors.centerIn: parent
  18. text: root.title
  19. }
  20. Image {
  21. anchors.left: parent.left
  22. anchors.top: parent.top
  23. anchors.bottom: parent.bottom
  24. anchors.margins: 5
  25. width: height
  26. source: "Off.png"
  27. }
  28. }
  29. Row {
  30. id: buttonsRow
  31. width: root.width
  32. height: childrenRect.height
  33. spacing: 5
  34. Repeater {
  35. model: root.lights
  36. width: root.width
  37. GradientButton {
  38. id: button
  39. width: (root.width - buttonsRow.spacing * (root.lights.count - 1)) / root.lights.count
  40. height: width / 2
  41. radius: 5
  42. Column {
  43. anchors.centerIn: parent
  44. Image {
  45. height: button.height * 0.5
  46. width: height
  47. anchors.horizontalCenter: parent.horizontalCenter
  48. source: "lamp.png"
  49. }
  50. Label {
  51. anchors.horizontalCenter: parent.horizontalCenter
  52. horizontalAlignment: Text.horizontalCenter
  53. text: name
  54. }
  55. }
  56. onClicked: {
  57. root.channelClicked(id)
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }