SubWindow.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. FontLoader {
  17. id: digtalFont
  18. source: "qrc:/components/font/fontawesome-webfont.ttf"
  19. }
  20. signal loginSuccess(var userName, var password)
  21. // signal carSeleted(var id)
  22. function loginUser(uname, pword) {
  23. var ret = Backend.validateUserCredentials(uname, pword)
  24. var message = ""
  25. if (ret) {
  26. message = "用户名或密码输入错误"
  27. subPopup.popMessage = message
  28. subPopup.open()
  29. return
  30. }
  31. // loginSuccess(uname, pword)
  32. appModel.userLogin(uname, pword)
  33. page_car.visible = true
  34. page_car.stack = stack
  35. stack.push(page_car)
  36. }
  37. function carSelect(id) {
  38. appModel.connectCar(id)
  39. }
  40. Popup {
  41. id: subPopup
  42. property alias popMessage: message.text
  43. background: Rectangle {
  44. id: subPopupBg
  45. implicitWidth: 1920
  46. implicitHeight: 60
  47. color: popupBgColorErr
  48. }
  49. y: (parent.height - 60)
  50. modal: true
  51. focus: true
  52. closePolicy: Popup.CloseOnPressOutside
  53. Text {
  54. id: message
  55. anchors.centerIn: parent
  56. font.pointSize: 12
  57. color: popupTextColor
  58. font.family: alibaba.name
  59. }
  60. onOpened: subPopupClose.start()
  61. }
  62. Timer {
  63. id: subPopupClose
  64. interval: 3000
  65. onTriggered: subPopup.close()
  66. }
  67. Rectangle {
  68. anchors.fill: parent
  69. Image {
  70. fillMode: Image.PreserveAspectFit
  71. source: 'qrc:/images/bg.png'
  72. }
  73. color: 'transparent'
  74. }
  75. Rectangle {
  76. width: parent.width
  77. height: 80
  78. color: 'transparent'
  79. z: 99
  80. Image {
  81. anchors.horizontalCenter: parent.horizontalCenter
  82. fillMode: Image.PreserveAspectFit
  83. source: 'qrc:/images/banner.png'
  84. }
  85. Text {
  86. anchors.horizontalCenter: parent.horizontalCenter
  87. anchors.verticalCenter: parent.verticalCenter
  88. text: '中冶非视距远程操控系统'
  89. font.family: alibaba.name
  90. font.pointSize: 24
  91. color: mainTextColor
  92. }
  93. }
  94. StackView {
  95. id: stack
  96. initialItem: page_login
  97. anchors.fill: parent
  98. }
  99. LoginPage {
  100. id: page_login
  101. visible: false
  102. }
  103. CarPage {
  104. id: page_car
  105. visible: false
  106. }
  107. DetailPage {
  108. id: page_detail
  109. visible: false
  110. }
  111. }