Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. import QtQuick 2.10
  2. import QtQuick.Controls 2.3
  3. import QtQuick.Layouts 1.3
  4.  
  5. ColumnLayout {
  6. id: root
  7. anchors.margins: 3
  8. spacing: 3
  9.  
  10. signal startTest(string testName)
  11.  
  12. property var testListModel: [
  13. {
  14. "title": "Video tests",
  15. "tests": [
  16. {
  17. "name" : "Video Test 1920x1200",
  18. "passed" : false
  19. },
  20. {
  21. "name" : "Video Test 1280x800",
  22. "passed" : true
  23. },
  24. {
  25. "name" : "Video Test 800x480",
  26. "passed" : false
  27. }
  28.  
  29. /*
  30. qsTr("Video Test 1920x1200"),
  31. qsTr("Video Test 1280x800"),
  32. qsTr("Video Test 800x480")*/
  33. ]
  34. }
  35. /*,
  36. {
  37. "title": "Audio tests",
  38. "tests": [
  39. qsTr("Microphone"),
  40. qsTr("Speaker")
  41. ]
  42. },
  43. {
  44. "title": "Misc",
  45. "tests": [
  46. qsTr("Ethernet"),
  47. qsTr("USB"),
  48. qsTr("SD Card"),
  49. qsTr("LED Test"),
  50.  
  51. ]
  52. }*/
  53. ]
  54.  
  55. Frame {
  56.  
  57. ListView {
  58.  
  59. implicitWidth: 600
  60. implicitHeight: 500
  61.  
  62. clip: true
  63. anchors.fill: parent
  64.  
  65. model: testListModel
  66.  
  67. delegate: Column {
  68. property bool showList: false
  69. anchors.left: parent.left
  70. anchors.right: parent.right
  71. Button {
  72. anchors.left: parent.left
  73. anchors.right: parent.right
  74. text: modelData.title
  75. onClicked: paneTestList.shown = !paneTestList.shown
  76. }
  77.  
  78. Pane {
  79. id: paneTestList
  80. property bool shown: false
  81. visible: height > 0
  82. height: shown ? implicitHeight: 0
  83. Behavior on height {
  84. NumberAnimation {
  85. easing.type: Easing.InOutQuad
  86. }
  87. }
  88.  
  89. clip: true
  90. anchors.left: parent.left
  91. anchors.right: parent.right
  92.  
  93. Column {
  94. anchors.left: parent.left
  95. anchors.right: parent.right
  96. spacing: 3
  97.  
  98. Repeater {
  99. id: testList
  100. model: modelData.tests
  101. anchors.fill: parent
  102.  
  103. delegate: RowLayout {
  104. anchors.left: parent.left
  105. anchors.right: parent.right
  106. spacing: 10
  107.  
  108. Rectangle {
  109. implicitHeight: 40
  110. implicitWidth: 40
  111. Image {
  112. source: "start.png"
  113. fillMode: Image.PreserveAspectFit
  114.  
  115. anchors.centerIn: parent
  116. anchors.fill: parent
  117.  
  118. height: sourceSize.height
  119.  
  120. }
  121. MouseArea {
  122. anchors.fill: parent
  123. onClicked: {
  124. console.log("Button pressed!!!" + modelData.name)
  125. modelData.passed = true
  126. //testListModelChanged()
  127. modelDataChanged()
  128. console.log("Data has been changed: " + modelData.passed)
  129.  
  130. modelData.name = "PassedBlahBlah"
  131. console.log("New name = " + modelData.name)
  132. }
  133. }
  134. }
  135.  
  136. Label {
  137. text: modelData.name
  138. Layout.fillWidth: true
  139. }
  140.  
  141. Rectangle {
  142. implicitHeight: 40
  143. implicitWidth: 40
  144. Image {
  145. source: {
  146. modelData.passed ? "passed.png" : "failed.png"
  147. }
  148. fillMode: Image.PreserveAspectFit
  149.  
  150. anchors.centerIn: parent
  151. anchors.fill: parent
  152. //sourceSize.height: button.background.height - 6
  153. //height: sourceSize.height
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160.  
  161.  
  162.  
  163. /*
  164. RowLayout {
  165. width: parent.width
  166. CheckBox {
  167. checked: true
  168. }
  169. Label {
  170. text: "Some text"
  171. }
  172. Button {
  173. text: "Test"
  174. }
  175. }*/
  176. }
  177.  
  178. }
  179. }
  180. /*
  181. Button {
  182. text: "Start the test"
  183. onPressed: {
  184. startTest("myTest")
  185. }
  186. }
  187. */
  188.  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement