DetailPage.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. import QtQuick
  2. import QtQuick.Controls 2.5
  3. import QtQuick.Layouts 1.3
  4. import "backend.js" as Backend
  5. /*
  6. 车辆连接和1/5摄像头显示
  7. */
  8. Rectangle {
  9. id: detailForm
  10. width: parent.width
  11. height: parent.height
  12. color: 'transparent'
  13. property StackView stack: null
  14. property string name: ""
  15. property string uid: ""
  16. property int ifConnect:0
  17. property var uidToNameMap: {
  18. 1000000: "湛钢B 0533",
  19. 1000001: "湛钢B 0534",
  20. 1000002: "湛钢B 0535",
  21. 1000003: "湛钢B 0537",
  22. 1000004: "湛钢B 0538"
  23. }
  24. // property int statue: 0
  25. property int loadingCount: 0
  26. function refresh()
  27. {
  28. //connectButton.text="连接"
  29. if (!appModel.ready)
  30. connectButton.text="连接"
  31. else
  32. connectButton.text="断开"
  33. }
  34. function disconnect()
  35. {
  36. disconn.start()
  37. console.log("321312")
  38. }
  39. //抓爪增加等待视频的动画效果
  40. Rectangle {
  41. id: loginWaitRectangle
  42. z:90
  43. visible: false
  44. //modal: true
  45. x: (parent.width - width) / 2
  46. y: (parent.height - height) / 2
  47. //closePolicy: Popup.NoAutoClose
  48. implicitWidth: 570
  49. implicitHeight: 321
  50. color: Qt.rgba(1, 1, 1, 0)
  51. Image {
  52. anchors.horizontalCenter: parent.horizontalCenter
  53. anchors.verticalCenter: parent.verticalCenter
  54. source: 'qrc:/images/waitConnect.png'
  55. }
  56. Text {
  57. text: ifConnect===0 ? "正在连接中···":"连接成功"
  58. font.pointSize: 24
  59. font.family: alibaba.name
  60. color: mainAppColor
  61. anchors.horizontalCenter: parent.horizontalCenter
  62. y: 200
  63. }
  64. ProgressBar {
  65. id:progressBar
  66. anchors.top:parent.top
  67. anchors.topMargin: 100
  68. anchors.horizontalCenter: parent.horizontalCenter
  69. value: 0.0
  70. padding: 1
  71. background: Rectangle {
  72. implicitWidth: 200
  73. implicitHeight: 20
  74. //color:"blue"
  75. color: "#e6e6e6"
  76. radius: 10
  77. border.color: "#888888"
  78. border.width: 2
  79. }
  80. contentItem: Item {
  81. implicitWidth: 200
  82. implicitHeight: 20
  83. visible:true
  84. Rectangle {
  85. width: progressBar.value * parent.width
  86. height: parent.height
  87. radius: 10
  88. //color:"red"
  89. color: "#17a81a"
  90. opacity: progressBar.value
  91. clip: true
  92. }
  93. }
  94. }
  95. SequentialAnimation {
  96. id: progressBarAnimation
  97. NumberAnimation {
  98. target: progressBar
  99. property: "value"
  100. from: 0.0
  101. to: 1.0
  102. duration: 30000 //进度动画设置为30秒
  103. }
  104. onRunningChanged: {
  105. if (!running) {
  106. //progressBar.value = 0.0; // 重置进度条的值
  107. ifConnect=1
  108. delay.start()
  109. }
  110. }
  111. }
  112. Timer {
  113. id:delay
  114. interval: 1000
  115. repeat: false
  116. onTriggered: {
  117. loginWaitRectangle.visible=false
  118. }
  119. }
  120. Timer {
  121. id:barStart
  122. interval: 0
  123. //running: true
  124. repeat: false
  125. onTriggered: {
  126. progressBarAnimation.start(); // 开始动画
  127. }
  128. }
  129. }
  130. Rectangle{
  131. id:disconnectFlagImage
  132. width:400
  133. height:150
  134. z:97
  135. visible:false
  136. color:'#000066'
  137. border.color:'#CCCC66'
  138. border.width:1
  139. radius:10
  140. Text{
  141. anchors.centerIn:parent
  142. text:"重连请等待7秒..."
  143. }
  144. anchors {
  145. centerIn:parent
  146. /*
  147. top: detailForm.top
  148. topMargin: 550
  149. left:detailForm.left
  150. leftMargin:850
  151. horizontalCenter: parent.horizontalCenter
  152. */
  153. }
  154. }
  155. Rectangle {
  156. width: 1440
  157. height: 820
  158. anchors.horizontalCenter: parent.horizontalCenter
  159. anchors.verticalCenter: parent.verticalCenter
  160. color: 'transparent'
  161. //border.color: mainAppColor
  162. //border.width: 1
  163. radius: 5
  164. // Image {
  165. // id: myIcon
  166. // width: 200
  167. // height: 200
  168. // anchors.horizontalCenter: parent.horizontalCenter
  169. // anchors.verticalCenter: parent.verticalCenter
  170. // fillMode: Image.PreserveAspectFit
  171. // source: 'qrc:/images/car1.png'
  172. // }
  173. Rectangle {
  174. id:panelID
  175. width: 1000
  176. height: 800
  177. color: 'transparent'
  178. anchors.top: parent.top
  179. anchors.topMargin: 50
  180. anchors.horizontalCenter: parent.horizontalCenter
  181. // anchors.verticalCenter: parent.verticalCenter
  182. // CAM Panel
  183. Image {
  184. id: panelImg
  185. //visible: false
  186. width: 1000
  187. height: 800
  188. fillMode: Image.Stretch//拉伸模式
  189. //fillMode: Image.PreserveAspectFit//保持宽高比例适应模式
  190. //fillMode: Image.PreserveAspectCrop //保持宽高比裁剪模式
  191. //fillMode: Image.Tile//平铺模式
  192. //source:'qrc:/images/PanelImage.png'
  193. }
  194. Connections {
  195. target: LeftAnchor
  196. onCallQmlRefeshLeftAnchor: {
  197. //aaa
  198. panelImg.source = ""
  199. //panelImg.source = "image://PanelImage/"+Math.random()
  200. panelImg.source = "image://LeftAnchor" //从名为LeftAnchor的图像资源中获取数据
  201. }
  202. }
  203. Image {
  204. id: panelImg_camera1
  205. anchors.topMargin: 140
  206. width: parent.width
  207. height: parent.height
  208. fillMode: Image.Stretch
  209. visible: true
  210. source: 'qrc:/images/middle_camera1.png'
  211. z: 98
  212. }
  213. Image {
  214. anchors.top:panelImg_camera1.top
  215. anchors.topMargin: -30
  216. anchors.left:panelImg_camera1.left
  217. anchors.leftMargin:-25
  218. height: parent.height+25
  219. fillMode: Image.Stretch
  220. //左后视镜边框
  221. source: 'qrc:/images/sideV_left.png'
  222. z: 99
  223. }
  224. Image {
  225. anchors.top:panelImg_camera1.top
  226. anchors.topMargin: -30
  227. anchors.left:panelImg_camera1.right
  228. anchors.leftMargin:-125
  229. height: parent.height+25
  230. fillMode: Image.Stretch
  231. //左后视镜边框
  232. source: 'qrc:/images/sideV_left1.png'
  233. z: 99
  234. }
  235. }
  236. Text {
  237. id: carName
  238. anchors {
  239. top: myIcon.bottom
  240. topMargin: 10
  241. horizontalCenter: parent.horizontalCenter
  242. }
  243. //text: name
  244. //text: uidToNameMap[uid] || ""
  245. //text:"湛钢B 0533"
  246. text: uidToNameMap[uid]
  247. //color: '#eaf4fc'
  248. color:'#29b6fb'
  249. font.family: alibaba.name
  250. //anchors.topMargin: 5
  251. font.pointSize: 20
  252. }
  253. /*
  254. CButton {
  255. id: carButton
  256. x:10
  257. y:200
  258. textHeight: 50
  259. fontHeight: 0.4
  260. width: 50
  261. height: 200
  262. color: pressed ? textClickedColor : mainAppColor
  263. Text{
  264. text: "\n 场\n 地\n 管\n 理"
  265. wrapMode: Text.WordWrap
  266. font.pointSize: 20
  267. color:"white"
  268. // anchors.horizontalCenter: parent.horizontalCenter
  269. // horizontalAlignment: Text.AlignHCenter
  270. verticalAlignment: Text.AlignVCenter
  271. }
  272. onClicked:workManage();
  273. }
  274. */
  275. /*
  276. Text {
  277. id: carName
  278. anchors {
  279. top: myIcon.bottom
  280. topMargin: 10
  281. horizontalCenter: parent.horizontalCenter
  282. }
  283. text: name
  284. color: '#eaf4fc'
  285. font.family: alibaba.name
  286. font.pointSize: 20
  287. }
  288. Text {
  289. id: carConnState
  290. anchors {
  291. top: carName.bottom
  292. topMargin: 10
  293. horizontalCenter: parent.horizontalCenter
  294. }
  295. text: !appModel.ready ? "未连接" : "已连接"
  296. color: '#eaf4fc'
  297. font.family: alibaba.name
  298. font.pointSize: 20
  299. }*/
  300. /* Image {
  301. id: model
  302. x:appModel.ModelX
  303. y:appModel.modelY
  304. width: 30
  305. height: 30
  306. fillMode: Image.Stretch
  307. source:'qrc:/images/PanelImage.png'
  308. }
  309. */
  310. Row {
  311. anchors.top: parent.bottom
  312. anchors.topMargin: 50
  313. anchors.horizontalCenter: parent.horizontalCenter
  314. //height: parent.height
  315. // anchors.top:parent.top
  316. // y:250
  317. // x:100
  318. //spacing: 40
  319. CButton {
  320. id: connectButton
  321. //anchors.topMargin: 50
  322. //y:10
  323. textHeight: 50
  324. fontHeight: 0.4
  325. width: 180
  326. height: 50
  327. color: pressed ? textClickedColor : mainAppColor
  328. text: appModel.ready ? "断开" : "连接"
  329. onClicked: {
  330. if (!appModel.ready) {
  331. //当没有功能时按钮失效
  332. //engineSpeedPlaySound.stop()
  333. connectButton.visible = false
  334. loading.start()
  335. carSelect(uid)
  336. backButton.visible = false
  337. appModel.ready = true
  338. connectButton.text="断开"
  339. loginWaitRectangle.visible=true
  340. ifConnect=0
  341. barStart.start()
  342. } else {
  343. //engineSpeedPlaySound.stop()
  344. connectButton.visible = false
  345. disconn.start()
  346. appModel.leaveCar(uid)
  347. appModel.ready = false
  348. connectButton.text="连接"
  349. statusLeftLogin.visible=false //点击断开后车辆数据信息UI界面不显示
  350. //stack.pop()
  351. }
  352. }
  353. }
  354. Timer {
  355. id: loading
  356. interval: 30000
  357. onTriggered: {
  358. connectButton.visible = true
  359. statusLeftLogin.visible=true
  360. //connectButton.text="连接"
  361. //backButton.visible=true
  362. // loadingCount++
  363. // carConnState.text = "连接中" + Backend.dot(loadingCount)
  364. // if (loadingCount === 4)
  365. // loadingCount = 0
  366. }
  367. }
  368. Timer {
  369. id: disconn
  370. interval: 2000
  371. onTriggered: {
  372. connectButton.visible = true
  373. //connectButton.text="断开"
  374. backButton.visible = true
  375. }
  376. }
  377. spacing: 50
  378. CButton {
  379. id: backButton
  380. //anchors.top: connectButton.bottom
  381. //anchors.topMargin: 30
  382. //anchors.horizontalCenter: parent.horizontalCenter
  383. textHeight: 50
  384. fontHeight: 0.4
  385. width: 180
  386. height: 50
  387. //y:10
  388. visible:appModel.ready?false:true
  389. //visible: true
  390. color: pressed ? textClickedColor : mainAppColor
  391. text: "返回"
  392. onClicked: {
  393. connectButton.enabled = true
  394. // carConnState.text = ""
  395. stack.pop()
  396. }
  397. }
  398. }
  399. /*Component.onCompleted: {
  400. loading.start() //在组件完成初始化并准备好显示时,loading定时器开始启动
  401. }*/
  402. }
  403. }