CarPage.qml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import QtQuick
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. Rectangle {
  5. id: carForm
  6. width: parent.width
  7. height: parent.height
  8. color: 'transparent'
  9. property StackView stack: null
  10. Component.onCompleted: {
  11. }
  12. function stateText(value)
  13. {
  14. if(value==0) return '(离线)';
  15. else if(value==1) return '(等待)';
  16. else return '(使用中)';
  17. }
  18. Rectangle {
  19. width: parent.width
  20. height: parent.height
  21. anchors.top: parent.top
  22. anchors.horizontalCenter: parent.horizontalCenter
  23. anchors.verticalCenter: parent.verticalCenter
  24. color: 'transparent'
  25. GridView {
  26. id: carGrid
  27. anchors.fill: parent
  28. cellWidth: 300
  29. cellHeight: 300
  30. focus: true
  31. anchors.leftMargin: 160
  32. anchors.rightMargin: 160
  33. anchors.topMargin: 160
  34. anchors.bottomMargin: 160
  35. x:100
  36. model: appModel.car
  37. /*
  38. Rectangle {
  39. width: 350
  40. height: 350
  41. radius: 5
  42. // border.color: mainAppColor
  43. color: 'transparent'
  44. }
  45. */
  46. delegate: Item {
  47. required property string name
  48. required property int uid
  49. required property string state
  50. width: 300
  51. height: 300
  52. Image {
  53. id: myIcon
  54. width: 200
  55. height: 200
  56. anchors.horizontalCenter: parent.horizontalCenter
  57. anchors.verticalCenter: parent.verticalCenter
  58. fillMode: Image.PreserveAspectFit
  59. source: 'qrc:/images/car1.png'
  60. }
  61. Text {
  62. anchors {
  63. top: myIcon.bottom
  64. topMargin: 10
  65. horizontalCenter: parent.horizontalCenter
  66. }
  67. text: parent.name + stateText(parent.state)
  68. color: '#eaf4fc'
  69. font.family: alibaba.name
  70. font.pointSize: 20
  71. Timer{
  72. id: timerRefresh
  73. interval:1000
  74. onTriggered: {
  75. stateText(parent.state)
  76. }
  77. }
  78. }
  79. MouseArea {
  80. anchors.fill: parent
  81. onClicked: {
  82. if(appModel.idle(parent.uid))
  83. {
  84. parent.GridView.view.currentIndex = parent.uid
  85. console.log(parent.GridView.view.currentIndex)
  86. //carSelect(parent.GridView.view.currentIndex)
  87. page_detail.visible = true
  88. page_detail.stack = stack
  89. page_detail.refresh()
  90. stack.push(page_detail, {
  91. "name": parent.name,
  92. "uid": parent.uid
  93. })
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }