SubWindow.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. import QtQuick
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. import "backend.js" as Backend
  5. Item {
  6. width: 1920
  7. height: 1080
  8. FontLoader {
  9. id: alibaba
  10. source: "qrc:/components/font/Alibaba-PuHuiTi-Bold.ttf"
  11. }
  12. FontLoader {
  13. id: fontawesome
  14. source: "qrc:/components/font/fontawesome-webfont.ttf"
  15. }
  16. signal loginSuccess(var userName, var password)
  17. // signal carSeleted(var id)
  18. function loginUser(uname, pword) {
  19. var ret = Backend.validateUserCredentials(uname, pword)
  20. var message = ""
  21. if (ret) {
  22. message = "用户名或密码输入错误"
  23. subPopup.popMessage = message
  24. subPopup.open()
  25. return
  26. }
  27. // loginSuccess(uname, pword)
  28. appModel.userLogin(uname, pword)
  29. page_car.visible = true
  30. page_car.stack = stack
  31. stack.push(page_car)
  32. }
  33. function carSelect(id) {
  34. appModel.connectCar(id)
  35. }
  36. Popup {
  37. id: subPopup
  38. property alias popMessage: message.text
  39. background: Rectangle {
  40. id: subPopupBg
  41. implicitWidth: 1920
  42. implicitHeight: 60
  43. color: popupBgColorErr
  44. }
  45. y: (parent.height - 60)
  46. modal: true
  47. focus: true
  48. closePolicy: Popup.CloseOnPressOutside
  49. Text {
  50. id: message
  51. anchors.centerIn: parent
  52. font.pointSize: 12
  53. color: popupTextColor
  54. font.family: alibaba.name
  55. }
  56. onOpened: subPopupClose.start()
  57. }
  58. Timer {
  59. id: subPopupClose
  60. interval: 3000
  61. onTriggered: subPopup.close()
  62. }
  63. Rectangle {
  64. anchors.fill: parent
  65. Image {
  66. fillMode: Image.PreserveAspectFit
  67. source: 'qrc:/images/bg.png'
  68. }
  69. color: 'transparent'
  70. }
  71. Rectangle {
  72. width: parent.width
  73. height: 80
  74. color: 'transparent'
  75. z: 99
  76. Image {
  77. anchors.horizontalCenter: parent.horizontalCenter
  78. fillMode: Image.PreserveAspectFit
  79. source: 'qrc:/images/banner.png'
  80. }
  81. Text {
  82. anchors.horizontalCenter: parent.horizontalCenter
  83. anchors.verticalCenter: parent.verticalCenter
  84. text: '大冶渣包车智能驾驶系统'
  85. font.family: alibaba.name
  86. font.pointSize: 24
  87. color: mainTextColor
  88. }
  89. }
  90. StackView {
  91. id: stack
  92. initialItem: page_login
  93. anchors.fill: parent
  94. }
  95. LoginPage {
  96. id: page_login
  97. visible: false
  98. }
  99. CarPage {
  100. id: page_car
  101. visible: false
  102. }
  103. DetailPage {
  104. id: page_detail
  105. visible: false
  106. }
  107. }