DropDownColumn.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * MIT License
  3. *
  4. * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
  5. *
  6. * This file is part of qtprotobuf project https://git.semlanik.org/semlanik/qtprotobuf
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy of this
  9. * software and associated documentation files (the "Software"), to deal in the Software
  10. * without restriction, including without limitation the rights to use, copy, modify,
  11. * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  12. * to permit persons to whom the Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in all copies
  16. * or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  19. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  20. * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  21. * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  22. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. */
  25. import QtQuick 2.9
  26. import QtQuick.Layouts 1.2
  27. Column {
  28. id: root
  29. property alias header: _headerText.text
  30. property alias value: _valueText.text
  31. default property alias content: _content.data
  32. anchors.left: parent.left
  33. anchors.right: parent.right
  34. state: "closed"
  35. states: [
  36. State {
  37. name: "opened"
  38. PropertyChanges {
  39. target: _content
  40. visible: true
  41. }
  42. PropertyChanges {
  43. target: _ddArrow
  44. rotation: 0
  45. }
  46. },
  47. State {
  48. name: "closed"
  49. PropertyChanges {
  50. target: _content
  51. visible: false
  52. }
  53. PropertyChanges {
  54. target: _ddArrow
  55. rotation: 180
  56. }
  57. }
  58. ]
  59. MouseArea {
  60. id: _header
  61. height: 70
  62. anchors.left: parent.left
  63. anchors.right: parent.right
  64. anchors.leftMargin: 10
  65. anchors.rightMargin: 10
  66. onClicked: {
  67. root.state = root.state == "closed" ? "opened" : "closed"
  68. }
  69. RowLayout {
  70. anchors.fill: parent
  71. PrimaryText {
  72. id: _headerText
  73. Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
  74. }
  75. PrimaryText {
  76. id: _valueText
  77. Layout.alignment: Qt.AlignRight | Qt.AlignBottom
  78. Layout.rightMargin: 20
  79. }
  80. Image {
  81. id: _ddArrow
  82. source: "qrc:/images/arrow.png"
  83. Layout.alignment: Qt.AlignRight | Qt.AlignBottom
  84. Behavior on rotation {
  85. NumberAnimation { duration: 200 }
  86. }
  87. }
  88. }
  89. Rectangle {
  90. visible: false
  91. anchors.fill: parent
  92. color: "#66ff0000"
  93. }
  94. }
  95. Column {
  96. id: _content
  97. anchors.left: parent.left
  98. anchors.right: parent.right
  99. anchors.leftMargin: 30
  100. }
  101. }