PanelWindow.qml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. import QtQuick
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. import "backend.js" as Backend
  5. Item {
  6. property string back_content: "ask content";
  7. property string move_content: "";
  8. property int uid: 0
  9. property string strArea:""
  10. property string strNo:""
  11. width: 1920
  12. height: 1080
  13. visible: true
  14. FontLoader {
  15. id: alibaba
  16. source: "qrc:/components/font/Alibaba-PuHuiTi-Bold.ttf"
  17. }
  18. FontLoader {
  19. id: fontawesome
  20. source: "qrc:/components/font/fontawesome-webfont.ttf"
  21. }
  22. signal loginSuccess(var userName, var password)
  23. function loginUser(uname, pword) {
  24. var ret = Backend.validateUserCredentials(uname, pword)
  25. var message = ""
  26. if (ret) {
  27. message = "用户名或密码输入错误"
  28. subPopup.popMessage = message
  29. subPopup.open()
  30. return
  31. }
  32. // loginSuccess(uname, pword)
  33. appModel.userLogin(uname, pword);
  34. page_car.visible = true
  35. page_car.stack = stack
  36. stack.push(page_car)
  37. }
  38. function moveBegin(area,no)
  39. {
  40. appModel.moveBegin(area,no)
  41. back_content="\t 自动驾驶即将启动 \n\t 是否还需要保持远程监控";
  42. trackDialog.visible=true;
  43. /*
  44. if(appModel.autoClose())
  45. {
  46. page_detail.disconnect()
  47. appModel.leaveCar()
  48. stack.pop()
  49. stack.pop()
  50. }
  51. */
  52. }
  53. function carManage(){
  54. stack.pop()
  55. }
  56. function workManage(){
  57. page_work.visible=true;
  58. page_work.stack=stack;
  59. stack.push(page_work)
  60. }
  61. objectName: "tst"
  62. function popDialog(str,area,no, vid)
  63. {
  64. strArea=String.fromCharCode(0x41+area)+""
  65. no= no+1
  66. strNo=(no<3?"新"+strArea+(no+1).toString()+"罐":strArea+(no-2).toString()+"罐")
  67. back_content=str+"已经到达"+strNo+"区域 \n\t 请求远程操控";
  68. uid=vid;
  69. backDialog.visible=true;
  70. }
  71. function moveErrorDialog(desc)
  72. {
  73. strDesc="不能执行自动驾驶"
  74. if(desc===1)
  75. {
  76. back_content=strDesc+"(未能获取编码器数据)";
  77. }
  78. else
  79. {
  80. back_content=strDesc+"(未知错误)";
  81. }
  82. moveErrorDlg.visible=true;
  83. }
  84. function carSelect(id) {
  85. appModel.connectCar(id)
  86. }
  87. function track()
  88. {
  89. // appModel.track()
  90. }
  91. function unTrack()
  92. {
  93. console.log('1111111');
  94. appModel.leaveCar()
  95. appModel.ready = false
  96. stack.pop()
  97. page_detail.update()
  98. stack.pop()
  99. }
  100. Popup {
  101. id: subPopup
  102. property alias popMessage: message.text
  103. background: Rectangle {
  104. id: subPopupBg
  105. implicitWidth: 1920
  106. implicitHeight: 60
  107. color: popupBgColorErr
  108. }
  109. y: (parent.height - 60)
  110. modal: true
  111. focus: true
  112. closePolicy: Popup.CloseOnPressOutside
  113. Text {
  114. id: message
  115. anchors.centerIn: parent
  116. font.pointSize: 12
  117. color: popupTextColor
  118. font.family: alibaba.name
  119. }
  120. onOpened: subPopupClose.start()
  121. }
  122. Timer {
  123. id: subPopupClose
  124. interval: 3000
  125. onTriggered: subPopup.close()
  126. }
  127. Rectangle {
  128. anchors.fill: parent
  129. Image {
  130. fillMode: Image.PreserveAspectFit
  131. source: 'qrc:/images/bg.png'
  132. }
  133. color: 'transparent'
  134. }
  135. Rectangle {
  136. width: parent.width
  137. height: 80
  138. color: 'transparent'
  139. z: 99
  140. Image {
  141. anchors.horizontalCenter: parent.horizontalCenter
  142. fillMode: Image.PreserveAspectFit
  143. source: 'qrc:/images/banner.png'
  144. }
  145. Text {
  146. anchors.horizontalCenter: parent.horizontalCenter
  147. anchors.verticalCenter: parent.verticalCenter
  148. text: textTitle
  149. font.family: alibaba.name
  150. font.pointSize: 24
  151. color: mainTextColor
  152. }
  153. }
  154. StackView {
  155. id: stack
  156. initialItem: page_login
  157. anchors.fill: parent
  158. }
  159. LoginPage {
  160. id: page_login
  161. visible: false
  162. }
  163. CarPage {
  164. id: page_car
  165. visible: false
  166. }
  167. WorkPage
  168. {
  169. id: page_work
  170. visible:false
  171. }
  172. DetailPage {
  173. id: page_detail
  174. visible: false
  175. }
  176. Dialog {
  177. id: backDialog
  178. visible: false
  179. modal: true
  180. x: (parent.width - width) / 2
  181. y: (parent.height - height) / 2
  182. closePolicy: Popup.NoAutoClose
  183. implicitWidth: 600
  184. implicitHeight: 300
  185. Text {
  186. text: back_content
  187. font.pointSize: 24
  188. font.family: alibaba.name
  189. color: '#000000'
  190. anchors.horizontalCenter: parent.horizontalCenter
  191. y: 100
  192. }
  193. Row {
  194. height: parent.height
  195. anchors.horizontalCenter: parent.horizontalCenter
  196. y: 200
  197. CButton {
  198. id: quitButton
  199. textHeight: 50
  200. fontHeight: 0.4
  201. width: 150
  202. height: 50
  203. color: pressed ? textClickedColor : mainAppColor
  204. text: "确定"
  205. onClicked: {
  206. appModel.controlCar(uid);
  207. backDialog.visible = false;
  208. // videoWindow.close()
  209. // rootItem.qmlSignalQuit()
  210. }
  211. }
  212. spacing: 50
  213. CButton {
  214. id: cancelBtn
  215. textHeight: 50
  216. fontHeight: 0.4
  217. width: 150
  218. height: 50
  219. color: pressed ? textClickedColor : mainAppColor
  220. text: "取消"
  221. onClicked: {
  222. appModel.cancelControl()
  223. backDialog.visible = false
  224. }
  225. }
  226. }
  227. }
  228. Dialog {
  229. id: trackDialog
  230. visible: false
  231. modal: true
  232. x: (parent.width - width) / 2
  233. y: (parent.height - height) / 2
  234. closePolicy: Popup.NoAutoClose
  235. implicitWidth: 600
  236. implicitHeight: 300
  237. Text {
  238. text: back_content
  239. font.pointSize: 24
  240. font.family: alibaba.name
  241. color: '#000000'
  242. anchors.horizontalCenter: parent.horizontalCenter
  243. y: 100
  244. }
  245. Row {
  246. height: parent.height
  247. anchors.horizontalCenter: parent.horizontalCenter
  248. y: 200
  249. CButton {
  250. id: yesBtn
  251. textHeight: 50
  252. fontHeight: 0.4
  253. width: 150
  254. height: 50
  255. color: pressed ? textClickedColor : mainAppColor
  256. text: "是"
  257. onClicked: {
  258. track();
  259. trackDialog.visible = false;
  260. // videoWindow.close()
  261. // rootItem.qmlSignalQuit()
  262. }
  263. }
  264. spacing: 50
  265. CButton {
  266. id: noBtn
  267. textHeight: 50
  268. fontHeight: 0.4
  269. width: 150
  270. height: 50
  271. color: pressed ? textClickedColor : mainAppColor
  272. text: "否"
  273. onClicked: {
  274. unTrack();
  275. trackDialog.visible = false
  276. }
  277. }
  278. }
  279. }
  280. Dialog {
  281. id: moveErrorDlg
  282. visible: false
  283. modal: true
  284. x: (parent.width - width) / 2
  285. y: (parent.height - height) / 2
  286. closePolicy: Popup.NoAutoClose
  287. implicitWidth: 600
  288. implicitHeight: 300
  289. Text {
  290. text: move_content
  291. font.pointSize: 24
  292. font.family: alibaba.name
  293. color: '#000000'
  294. anchors.horizontalCenter: parent.horizontalCenter
  295. y: 100
  296. }
  297. Row {
  298. height: parent.height
  299. anchors.horizontalCenter: parent.horizontalCenter
  300. y: 200
  301. CButton {
  302. id: exbutton
  303. textHeight: 50
  304. fontHeight: 0.4
  305. width: 150
  306. height: 50
  307. color: pressed ? textClickedColor : mainAppColor
  308. text: "确定"
  309. onClicked: {
  310. appModel.controlCar(uid);
  311. backDialog.visible = false;
  312. // videoWindow.close()
  313. // rootItem.qmlSignalQuit()
  314. }
  315. }
  316. }
  317. }
  318. }