CarPage.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import QtQuick
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. /*
  5. 自动驾驶车辆选择界面
  6. */
  7. Rectangle {
  8. id: carForm
  9. width: parent.width
  10. height: parent.height
  11. color: 'transparent'
  12. property StackView stack: null
  13. Component.onCompleted: {
  14. }
  15. //check
  16. function stateText(value)
  17. {
  18. if(value==0) return '(离线)';
  19. else if(value==1) return '(空闲中)';
  20. else return '(使用中)';
  21. }
  22. Rectangle {
  23. width: parent.width
  24. height: parent.height
  25. anchors.top: parent.top
  26. anchors.horizontalCenter: parent.horizontalCenter
  27. anchors.verticalCenter: parent.verticalCenter
  28. color: 'transparent'
  29. GridView {
  30. id: carGrid
  31. anchors.fill: parent
  32. cellWidth: 300
  33. cellHeight: 300
  34. focus: true
  35. anchors.leftMargin: 150//280+300
  36. anchors.rightMargin: 160
  37. anchors.topMargin: 180
  38. anchors.bottomMargin: 160
  39. x:100
  40. model: appModel.car
  41. /*
  42. Rectangle {
  43. width: 350
  44. height: 350
  45. radius: 5
  46. // border.color: mainAppColor
  47. color: 'transparent'
  48. }
  49. */
  50. //11-15
  51. delegate: Item {
  52. required property string name
  53. required property int uid
  54. required property string state
  55. property var uidToNameMap: {
  56. 1000000: "湛钢B 0533",
  57. 1000001: "湛钢B 0534",
  58. 1000002: "湛钢B 0535",
  59. 1000003: "湛钢B 0537",
  60. 1000004: "湛钢B 0538"
  61. }
  62. width: 300
  63. height: 300
  64. Image {
  65. id: myIcon
  66. width: 200
  67. height: 200
  68. anchors.horizontalCenter: parent.horizontalCenter
  69. anchors.verticalCenter: parent.verticalCenter
  70. fillMode: Image.PreserveAspectFit
  71. source: 'qrc:/images/car1.png'
  72. }
  73. Text {
  74. anchors {
  75. top: myIcon.bottom
  76. topMargin: 10
  77. horizontalCenter: parent.horizontalCenter
  78. }
  79. //11-15
  80. //text: parent.name + stateText(parent.state)
  81. //color: '#eaf4fc'
  82. //text: (uidToNameMap[parent.uid]+ stateText(parent.state)) || ""
  83. text: uidToNameMap[parent.uid] || ""
  84. color:'#29b6fb'
  85. font.family: alibaba.name
  86. font.pointSize: 20
  87. }
  88. Text {
  89. anchors {
  90. top: myIcon.bottom
  91. topMargin: 50
  92. horizontalCenter: parent.horizontalCenter
  93. }
  94. text: stateText(parent.state)
  95. color:parent.state==1 ? 'green':'red'
  96. font.family: alibaba.name
  97. font.pointSize: 20
  98. Timer{
  99. id: timerRefresh
  100. interval:1000
  101. onTriggered: {
  102. stateText(parent.state)
  103. }
  104. }
  105. }
  106. MouseArea {
  107. anchors.fill: parent
  108. enabled:parent.state==1 ? true:false
  109. onClicked: {
  110. if(appModel.idle(parent.uid))
  111. {
  112. parent.GridView.view.currentIndex = parent.uid
  113. console.log(parent.GridView.view.currentIndex)
  114. //carSelect(parent.GridView.view.currentIndex)
  115. page_detail.visible = true
  116. page_detail.stack = stack
  117. page_detail.refresh()
  118. stack.push(page_detail, {
  119. "name": parent.name,
  120. "uid": parent.uid
  121. })
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }