ControlsPage.qml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import Qt.labs.settings 1.0 as QtLabs
  5. import QtQuick.Controls.Material 2.0
  6. import QtLocation 5.5
  7. import QtPositioning 5.5
  8. import QtMultimedia
  9. import Qt5Compat.GraphicalEffects
  10. import Felgo 4.0
  11. import "../controls"
  12. import "../common"
  13. //import MqttClient 1.0
  14. AppPage {
  15. id: controlsPage
  16. property string originalString: ""
  17. property string collectString: ""
  18. property string gps_state: "正在定位..."
  19. property string board_version: ""
  20. property bool connect_board: false
  21. property var tt
  22. property bool isonline: false
  23. property var net_list:[]
  24. property var picinfo_list:[]
  25. Material.accent: Theme.tintColor
  26. rightBarItem: IconButtonBarItem {
  27. iconType: IconType.paintbrush
  28. onClicked: {
  29. themeModal.open()
  30. }
  31. }
  32. Component.onCompleted: {
  33. originalString = myClass.deviceid
  34. }
  35. // 接收并显示日志消息
  36. Connections {
  37. target: mqtt
  38. onConnected: {
  39. console.log("mqtt connect")
  40. mqtt_sta.detailText="MQTT已连接"
  41. }
  42. onDisconnected: {
  43. console.log("mqtt disconnect")
  44. mqtt_sta.detailText="MQTT已断开"
  45. }
  46. }
  47. Connections{
  48. target: myClass
  49. }
  50. //串口
  51. Connections{
  52. target: serial
  53. onDataReceived:{
  54. var jsonData = JSON.parse(data)
  55. console.debug("接收到主板数据:",data.toString())
  56. if(jsonData.ext.work_sta==="0"){
  57. if(jsonData.ext.ds==="0"){
  58. work_header.text =qsTr("<b>设备开关:</b> 关机") + "-" + qsTr("<b>工作状态:</b> 待机")
  59. }else{
  60. work_header.text =qsTr("<b>设备开关:</b> 开机") + "-" + qsTr("<b>工作状态:</b> 待机")
  61. }
  62. }else if(jsonData.ext.work_sta==="1"){
  63. if(jsonData.ext.ds==="0"){
  64. work_header.text = qsTr("<b>设备开关:</b> 关机") + "-" + qsTr("<b>工作状态:</b> 采集")
  65. }else{
  66. work_header.text = qsTr("<b>设备开关:</b> 开机") + "-" + qsTr("<b>工作状态:</b> 采集")
  67. }
  68. }
  69. if(jsonData.ext.gps==="1"){
  70. gps_state = "成功"
  71. }
  72. if(jsonData.ext.coll_time){
  73. collectString = " [" +jsonData.ext.coll_time[0] + "," + jsonData.ext.coll_time[1] + "," + jsonData.ext.coll_time[2] + "]";
  74. }
  75. if(jsonData.ext.dat_f){
  76. serial.update_dat_f_main(jsonData.ext.dat_f);
  77. }
  78. board_version = jsonData.ext.dver
  79. work_header.detailText = "电压:" + jsonData.ext.vbat + " 电流:" + jsonData.ext.current + " 温度:" + jsonData.ext.at + " 湿度:" + jsonData.ext.ah ;
  80. }
  81. onDisconnect_485:{
  82. work_header.text =qsTr("485未连接,读取数据失败");
  83. }
  84. }
  85. MediaPlayer{
  86. id: audio
  87. audioOutput: AudioOutput{}
  88. source: Qt.resolvedUrl("../../assets/mp3/button.mp3")
  89. }
  90. AppFlickable {
  91. id: scroll
  92. anchors.fill: parent
  93. contentHeight: content.height
  94. // remove focus from controls if clicked outside
  95. MouseArea {
  96. anchors.fill: parent
  97. onClicked: {
  98. scroll.forceActiveFocus()
  99. }
  100. }
  101. Column {
  102. id: content
  103. width: parent.width
  104. Timer {
  105. interval: 500
  106. running: true
  107. repeat: true
  108. onTriggered: {
  109. menutab.title = Date().toString() + " 设备ID:" + originalString.toLowerCase() + " GPS状态:" + gps_state
  110. if(mqtt.checkLink()){
  111. mqtt_sta.detailText="MQTT已连接"
  112. }else{
  113. mqtt_sta.detailText="MQTT已断开"
  114. }
  115. net_list = mqtt.netMessage()
  116. if(net_list){
  117. if(net_list[0]==="1"){isonline = true}else{isonline = false}
  118. mqtt_sta.text = qsTr("<b>联网状态:</b> %1 (网卡名称:%2) (描述:%3)").arg(isonline? "已联网" : "未联网").arg(net_list[1]).arg(net_list[2])
  119. net_mes.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3]) + qsTr("<b>[IPV4] </b> %1").arg(net_list[4])
  120. mqtt_sta.detailText += "<服务器地址:>" + net_list[5]
  121. mqtt_sta.detailText += "<数据上传间隔:>" + net_list[6] + "(" +net_list[7] + ")" + "分钟";
  122. }
  123. }
  124. }
  125. Section {
  126. id: menutab
  127. title: Date().toString()
  128. //SectionItem {
  129. //title: "运行状态"
  130. //anchors.horizontalCenter: parent.horizontalCenter
  131. AppCard {
  132. id: card
  133. width: parent.width
  134. // property real resetX: 0
  135. // x: resetX
  136. margin: dp(5)
  137. paper.radius: dp(5)
  138. header: SimpleRow {
  139. id: work_header
  140. //imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
  141. text: qsTr("<b>设备开关:</b> 开机") + qsTr("<b>工作状态:</b> 待机")
  142. detailText: "电压:" + jsonData.ext.vbat + " 电流:" + jsonData.ext.current + " 温度:" + jsonData.ext.at + " 湿度:" + jsonData.ext.ah ;
  143. badgeColor: "green"
  144. image.radius: image.width / 2
  145. image.fillMode: Image.PreserveAspectCrop
  146. style: StyleSimpleRow {
  147. showDisclosure: false
  148. backgroundColor: "transparent"
  149. }
  150. }
  151. media: AppImage {
  152. width: card.width
  153. fillMode: Image.PreserveAspectFit
  154. source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
  155. }
  156. content: AppText{
  157. id: work_apptext
  158. width: card.width
  159. padding: dp(15)
  160. text: "设定采集时间:" + collectString;
  161. }
  162. }
  163. AppCard {
  164. id: card_net
  165. width: parent.width
  166. property real resetX: 0
  167. x: resetX
  168. margin: dp(5)
  169. paper.radius: dp(5)
  170. header: SimpleRow {
  171. id: mqtt_sta
  172. //imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
  173. text: qsTr("<b>联网状态:</b> %1 (%2)").arg(app.isOnline ? "已联网" : "未联网").arg(nativeUtils.connectionType)
  174. detailText: "AppCard detailed text"
  175. image.radius: image.width / 2
  176. image.fillMode: Image.PreserveAspectCrop
  177. style: StyleSimpleRow {
  178. showDisclosure: false
  179. backgroundColor: "transparent"
  180. }
  181. }
  182. media: AppImage {
  183. width: parent.width
  184. fillMode: Image.PreserveAspectFit
  185. source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
  186. }
  187. content: AppText{
  188. id: net_mes
  189. width: parent.width
  190. padding: dp(15)
  191. text: "Mac" + "ipv4:";
  192. }
  193. }
  194. // ============ 有线网卡 (eth) 状态与配置 ============
  195. // 通过 EnjoySDK 走系统 EthernetService 配置,无需 root。
  196. // 关键:mode=STATIC 必须与 IP 参数**一次性下发** ——
  197. // setEthernetConfig 会校验整个配置,静态模式下 IP/掩码不合法会被拒(-101),
  198. // 所以不能"先只切模式、再填 IP"分两步提交(见 EthernetBridge.setStaticIp)。
  199. AppCard {
  200. id: card_eth
  201. width: parent.width
  202. margin: dp(5)
  203. paper.radius: dp(5)
  204. // ---- 状态 ----
  205. property string ethIface: "eth1" // 目标网卡,可切换 eth0/eth1
  206. property int ethLinkState: -1 // 0未连接 1连接中 2已连接 3断开中 4未知
  207. property int ethMode: 0 // 1=DHCP 2=静态 3=PPPOE 4=未知
  208. property bool ethEnabled: false
  209. property string ethMac: ""
  210. property string ethIp: ""
  211. property string ethMask: ""
  212. property string ethGateway: ""
  213. property string ethDns: ""
  214. // ---- 配置输入 ----
  215. // 默认值:与 GigE 相机同网段的 192.168.100.101 + Jumbo 帧 MTU 9000。
  216. // 若网卡已有配置,refresh() 会用实际值覆盖这两项。
  217. property bool useDhcp: true // true=DHCP false=静态
  218. property string ipInput: "192.168.100.101"
  219. property string maskInput: "255.255.255.0"
  220. property string gatewayInput: ""
  221. property string dnsInput: ""
  222. property string mtuInput: "9000"
  223. property string ethMessage: ""
  224. property bool ethBusy: false
  225. // 链路状态文字
  226. readonly property string linkText: {
  227. switch (ethLinkState) {
  228. case 0: return "未连接"
  229. case 1: return "连接中"
  230. case 2: return "已连接"
  231. case 3: return "断开中"
  232. default: return "未知"
  233. }
  234. }
  235. readonly property string linkColor: {
  236. switch (ethLinkState) {
  237. case 2: return "#28a779" // 已连接=绿
  238. case 1:
  239. case 3: return "#e8a33d" // 连接中/断开中=黄
  240. case 0: return "#e74c3c" // 未连接=红
  241. default: return "#999999"
  242. }
  243. }
  244. readonly property string modeText: {
  245. switch (ethMode) {
  246. case 1: return "DHCP"
  247. case 2: return "静态"
  248. case 3: return "PPPOE"
  249. default: return "未知"
  250. }
  251. }
  252. // 读取指定网卡状态
  253. // keepMode: 为 true 时不覆盖 useDhcp —— 设置模式下发的瞬间系统返回值
  254. // 可能还没刷新,若此时用 r.mode 回写会把用户刚选的模式弹回去。
  255. function refresh(iface, keepMode) {
  256. if (iface !== undefined && iface !== "")
  257. card_eth.ethIface = iface
  258. var r = ethernet.status(card_eth.ethIface)
  259. if (!r || r.ok !== true) {
  260. card_eth.ethMessage = "读取失败: " + (r && r.msg ? r.msg : ethernet.lastError())
  261. card_eth.ethLinkState = -1
  262. return
  263. }
  264. card_eth.ethLinkState = r.linkState !== undefined ? r.linkState : -1
  265. card_eth.ethMode = r.mode !== undefined ? r.mode : 0
  266. card_eth.ethEnabled = (r.enabled === true)
  267. card_eth.ethMac = r.mac || ""
  268. card_eth.ethIp = r.ip || ""
  269. card_eth.ethMask = r.subnetMask || ""
  270. card_eth.ethGateway = r.gateway || ""
  271. card_eth.ethDns = r.dns || ""
  272. // 用当前实际配置回填输入框
  273. if (r.ip && r.ip !== "0.0.0.0") {
  274. card_eth.ipInput = r.ip
  275. card_eth.maskInput = r.subnetMask || "255.255.255.0"
  276. card_eth.gatewayInput = r.gateway || ""
  277. card_eth.dnsInput = r.dns || ""
  278. }
  279. if (keepMode !== true) {
  280. card_eth.useDhcp = (r.mode === 1)
  281. }
  282. card_eth.ethMessage = ""
  283. }
  284. // 切换为 DHCP 模式。
  285. // 注意:静态模式**不能**在这里单独下发 —— setEthernetConfig 会校验整个配置,
  286. // 静态模式下 IP/掩码必须合法,只改 mode 会被拒(-101)。
  287. // 所以切静态只改界面状态,等用户填好 IP 后由 applyStaticIp() 一次性下发。
  288. function applyDhcp() {
  289. card_eth.ethBusy = true
  290. var r = ethernet.setDhcp(card_eth.ethIface, true) // true = DHCP
  291. card_eth.ethBusy = false
  292. if (r && r.ok === true) {
  293. card_eth.ethMessage = "已切换为 DHCP 模式"
  294. card_eth.refresh(undefined, true)
  295. } else {
  296. card_eth.ethMessage = "切换失败: " + (r && r.msg ? r.msg : ethernet.lastError())
  297. }
  298. }
  299. // 应用静态配置:先 MTU,再静态 IP
  300. // 【顺序很重要】setMtu 内部会 ifconfig down/up,会重置网卡;
  301. // 若先下发 IP 再改 MTU,刚设好的 IP 可能被 down/up 冲掉。
  302. function applyStaticIp() {
  303. if (!card_eth.ipInput) {
  304. card_eth.ethMessage = "请输入 IP 地址"
  305. return
  306. }
  307. card_eth.ethBusy = true
  308. // 步骤 1:设置 MTU(Jumbo 帧)。
  309. // EnjoySDK 没有 MTU 接口,只能走 ifconfig + su,需要 root;
  310. // 失败不影响后续 IP 下发,单独在提示里说明。
  311. var mtuMsg = ""
  312. var mtu = parseInt(card_eth.mtuInput)
  313. if (!isNaN(mtu) && mtu > 0) {
  314. var m = ethernet.setMtu(card_eth.ethIface, mtu)
  315. if (m && m.ok === true) {
  316. mtuMsg = ",MTU=" + mtu
  317. } else {
  318. var why = ethernet.lastError()
  319. mtuMsg = ",MTU 未生效" + (why ? "(" + why + ")" : "")
  320. }
  321. }
  322. // 步骤 2:一次性下发 mode=STATIC + IP
  323. // (setStaticIp 内部把 mode 与 IP 字段一起提交;
  324. // 若只切模式再设 IP,静态模式下配置校验不过会被拒 -101)
  325. var r = ethernet.setStaticIp(card_eth.ethIface,
  326. card_eth.ipInput,
  327. card_eth.maskInput,
  328. card_eth.gatewayInput,
  329. card_eth.dnsInput)
  330. card_eth.ethBusy = false
  331. if (!r || r.ok !== true) {
  332. card_eth.ethMessage = "设置失败: " + (r && r.msg ? r.msg : ethernet.lastError())
  333. return
  334. }
  335. card_eth.useDhcp = false
  336. card_eth.ethMessage = "静态 IP 已应用: " + card_eth.ipInput + mtuMsg
  337. card_eth.refresh(undefined, true)
  338. }
  339. header: SimpleRow {
  340. id: eth_sta
  341. text: qsTr("<b>有线网卡:</b> %1 (%2)").arg(card_eth.ethIface).arg(card_eth.linkText)
  342. detailText: qsTr("模式: %1 IP: %2").arg(card_eth.modeText)
  343. .arg(card_eth.ethIp === "" ? "未分配" : card_eth.ethIp)
  344. image.radius: image.width / 2
  345. image.fillMode: Image.PreserveAspectCrop
  346. style: StyleSimpleRow {
  347. showDisclosure: false
  348. backgroundColor: "transparent"
  349. }
  350. }
  351. media: Rectangle {
  352. width: parent.width
  353. height: dp(4)
  354. color: card_eth.linkColor
  355. }
  356. content: ColumnLayout {
  357. id: eth_content
  358. width: card_eth.width
  359. spacing: dp(10)
  360. // ---- 网卡选择 ----
  361. RowLayout {
  362. Layout.fillWidth: true
  363. spacing: dp(10)
  364. AppText {
  365. text: "网卡"
  366. color: Theme.textColor
  367. }
  368. // 目标网卡:默认 eth1,可切换
  369. RowLayout {
  370. spacing: dp(6)
  371. Repeater {
  372. model: ["eth0", "eth1"]
  373. delegate: AppButton {
  374. // 用 var 而非 string:与下面对象数组的 delegate 保持一致,
  375. // 避免 Qt 版本对 modelData 类型推断的差异
  376. required property var modelData
  377. text: modelData
  378. flat: true
  379. // 用 opacity 而非 visible 表达选中态,避免切换时按钮宽度跳变
  380. opacity: card_eth.ethIface === modelData ? 1 : 0.5
  381. onClicked: {
  382. card_eth.ethIface = modelData
  383. card_eth.refresh()
  384. }
  385. }
  386. }
  387. }
  388. Item { Layout.fillWidth: true }
  389. AppButton {
  390. text: "刷新"
  391. onClicked: card_eth.refresh()
  392. }
  393. }
  394. // ---- 当前状态明细 ----
  395. AppText {
  396. Layout.fillWidth: true
  397. text: "MAC: " + (card_eth.ethMac === "" ? "-" : card_eth.ethMac)
  398. color: Theme.textColor
  399. font.pixelSize: sp(12)
  400. elide: Text.ElideMiddle
  401. }
  402. AppText {
  403. Layout.fillWidth: true
  404. text: "模式: " + card_eth.modeText
  405. + " 子网掩码: " + (card_eth.ethMask === "" ? "-" : card_eth.ethMask)
  406. + " 网关: " + (card_eth.ethGateway === "" ? "-" : card_eth.ethGateway)
  407. color: Theme.textColor
  408. font.pixelSize: sp(12)
  409. elide: Text.ElideMiddle
  410. }
  411. // ---- DHCP / 静态 切换 ----
  412. RowLayout {
  413. Layout.fillWidth: true
  414. spacing: dp(10)
  415. AppText {
  416. text: "IP 模式"
  417. color: Theme.textColor
  418. }
  419. RowLayout {
  420. spacing: dp(6)
  421. Repeater {
  422. model: [{ label: "DHCP", value: true },
  423. { label: "静态IP", value: false }]
  424. delegate: AppButton {
  425. required property var modelData
  426. text: modelData.label
  427. flat: true
  428. opacity: card_eth.useDhcp === modelData.value ? 1 : 0.5
  429. onClicked: {
  430. if (card_eth.useDhcp === modelData.value)
  431. return
  432. card_eth.useDhcp = modelData.value
  433. if (modelData.value === true) {
  434. // 切 DHCP:直接下发(DHCP 不需要调用方提供 IP)
  435. card_eth.applyDhcp()
  436. } else {
  437. // 切静态:只展开参数表单,**暂不下发**。
  438. // 静态模式要求 IP/掩码齐全,单独改 mode 会被系统拒(-101);
  439. // 等用户填好后点「应用静态IP」时 mode+IP 一次性提交。
  440. card_eth.ethMessage = "请填写静态 IP 参数,然后点「应用静态IP」"
  441. }
  442. }
  443. }
  444. }
  445. }
  446. Item { Layout.fillWidth: true }
  447. // 网卡开关
  448. AppButton {
  449. text: card_eth.ethEnabled ? "关闭网卡" : "启用网卡"
  450. enabled: !card_eth.ethBusy
  451. onClicked: {
  452. var r = ethernet.setEnabled(card_eth.ethIface, !card_eth.ethEnabled)
  453. if (r && r.ok === true) {
  454. card_eth.refresh()
  455. } else {
  456. card_eth.ethMessage = "操作失败: " + (r && r.msg ? r.msg : ethernet.lastError())
  457. }
  458. }
  459. }
  460. }
  461. // ---- 静态 IP 参数(仅静态模式下可编辑)----
  462. // 这里用 visible(而非 opacity)是有意的:DHCP 模式下要让整块参数
  463. // 真正收起、不占布局空间;用 opacity 隐藏的话输入框仍会占位。
  464. // 下方"模式"按钮与网卡开关是固定行,不受这里影响。
  465. ColumnLayout {
  466. Layout.fillWidth: true
  467. spacing: dp(6)
  468. visible: !card_eth.useDhcp
  469. enabled: !card_eth.useDhcp && !card_eth.ethBusy
  470. AppText {
  471. text: "静态 IP 参数"
  472. color: Theme.textColor
  473. font.pixelSize: sp(12)
  474. }
  475. GridLayout {
  476. Layout.fillWidth: true
  477. columns: 2
  478. columnSpacing: dp(10)
  479. rowSpacing: dp(8)
  480. AppText { text: "IP 地址"; color: Theme.textColor }
  481. AppTextField {
  482. Layout.fillWidth: true
  483. text: card_eth.ipInput
  484. placeholderText: "如 192.168.100.101"
  485. onTextChanged: card_eth.ipInput = text
  486. }
  487. AppText { text: "子网掩码"; color: Theme.textColor }
  488. AppTextField {
  489. Layout.fillWidth: true
  490. text: card_eth.maskInput
  491. placeholderText: "255.255.255.0"
  492. onTextChanged: card_eth.maskInput = text
  493. }
  494. AppText { text: "网关"; color: Theme.textColor }
  495. AppTextField {
  496. Layout.fillWidth: true
  497. text: card_eth.gatewayInput
  498. placeholderText: "可留空"
  499. onTextChanged: card_eth.gatewayInput = text
  500. }
  501. AppText { text: "DNS"; color: Theme.textColor }
  502. AppTextField {
  503. Layout.fillWidth: true
  504. text: card_eth.dnsInput
  505. placeholderText: "可留空"
  506. onTextChanged: card_eth.dnsInput = text
  507. }
  508. AppText { text: "MTU"; color: Theme.textColor }
  509. AppTextField {
  510. Layout.fillWidth: true
  511. text: card_eth.mtuInput
  512. placeholderText: "如 9000 (Jumbo 帧)"
  513. inputMethodHints: Qt.ImhDigitsOnly
  514. onTextChanged: card_eth.mtuInput = text
  515. }
  516. }
  517. // MTU 说明:EnjoySDK 没有 MTU 接口,只能走 ifconfig + su,
  518. // 需要设备已 root;失败不影响上面已下发的 IP 配置。
  519. AppText {
  520. Layout.fillWidth: true
  521. text: "MTU(9000) 用于 GigE 大帧,需设备已 root;失败不影响 IP 配置"
  522. color: "#999999"
  523. font.pixelSize: sp(11)
  524. wrapMode: Text.Wrap
  525. }
  526. RowLayout {
  527. Layout.fillWidth: true
  528. spacing: dp(10)
  529. Item { Layout.fillWidth: true }
  530. AppButton {
  531. text: card_eth.ethBusy ? "应用中..." : "应用静态IP"
  532. enabled: !card_eth.ethBusy
  533. onClicked: card_eth.applyStaticIp()
  534. }
  535. }
  536. }
  537. // ---- 结果提示 ----
  538. AppText {
  539. Layout.fillWidth: true
  540. text: card_eth.ethMessage
  541. color: card_eth.ethMessage === "" ? Theme.textColor : "#e8a33d"
  542. font.pixelSize: sp(12)
  543. wrapMode: Text.Wrap
  544. }
  545. }
  546. Component.onCompleted: {
  547. // 默认展示 eth1 状态(eth0 用于 GigE 相机,由程序启动时自动配置)
  548. card_eth.ethIface = "eth1"
  549. card_eth.refresh()
  550. }
  551. }
  552. // AppCard {
  553. // id: card_cfg
  554. // width: parent.width
  555. // height: width*1.5
  556. // property real resetX: 0
  557. // x: resetX
  558. // margin: dp(5)
  559. // paper.radius: dp(5)
  560. // header: SimpleRow {
  561. // imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
  562. // text: "参数"
  563. // detailText: "AppCard detailed text"
  564. // image.radius: image.width / 2
  565. // image.fillMode: Image.PreserveAspectCrop
  566. // style: StyleSimpleRow {
  567. // showDisclosure: false
  568. // backgroundColor: "transparent"
  569. // }
  570. // }
  571. // media: AppImage {
  572. // width: card_cfg.width
  573. // fillMode: Image.PreserveAspectFit
  574. // source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
  575. // }
  576. // content: AppText{
  577. // width: card_cfg.width
  578. // padding: dp(15)
  579. // text: "此界面显示参数等信息,运行时间等"
  580. // }
  581. // cardSwipeArea.onSwipeOutCompleted: {
  582. // card_cfg.x = card_cfg.resetX
  583. // card_cfg.rotation = 0
  584. // }
  585. // }
  586. //} // AppCard section
  587. } // convenience controls section
  588. Timer {
  589. interval: 1000
  590. running: true
  591. repeat: true
  592. onTriggered: {
  593. picinfo_list = serial.pathinfo()
  594. pic_path.text = "图片存储目录:" + picinfo_list[0]
  595. pic_count.text = "文件数量:" + picinfo_list[1]
  596. pic_total.text = "占用大小:" + picinfo_list[2] + "(Mb)"
  597. }
  598. }
  599. Section {
  600. title: "存储信息"
  601. bottomPadding: dp(Theme.navigationBar.defaultBarItemPadding)
  602. Grid {
  603. anchors.horizontalCenter: parent.horizontalCenter
  604. columns: 2
  605. rows: 4
  606. //horizontalItemAlignment: Grid.AlignHCenter
  607. Column{
  608. AppButton {
  609. text: "查询"
  610. flat: false
  611. onClicked: {
  612. serial.readPathinfo()
  613. }
  614. }
  615. AppButton {
  616. text: "清理"
  617. flat: false
  618. onClicked: {
  619. serial.removepic()
  620. }
  621. }
  622. }
  623. Column{
  624. AppText {
  625. id: pic_path
  626. text: "图片存储目录:" + picinfo_list[0]
  627. }
  628. AppText{
  629. id: pic_count
  630. text: "文件数量:" + picinfo_list[1]
  631. }
  632. AppText{
  633. id: pic_total
  634. text: "占用大小:" + picinfo_list[2]
  635. }
  636. }
  637. }
  638. } // native utils section }
  639. Section {
  640. title: "Device Info"
  641. bottomPadding: dp(15)
  642. Row {
  643. width: parent.width - dp(30)
  644. anchors.horizontalCenter: parent.horizontalCenter
  645. spacing: dp(5)
  646. Column {
  647. id: firstInfoColumn
  648. spacing: dp(5)
  649. width: (parent.width - parent.spacing) * 0.5
  650. AppText {
  651. text: "<b>OS Type:</b> " + system.osType
  652. font.pixelSize: sp(11)
  653. visible: system.osType !== "undefined"
  654. }
  655. AppText {
  656. text: "<b>OS Version:</b> " + system.osVersion
  657. font.pixelSize: sp(11)
  658. visible: system.osVersion !== "undefined"
  659. }
  660. AppText {
  661. text: "<b>Device Model:</b> " + nativeUtils.deviceModel()
  662. font.pixelSize: sp(11)
  663. visible: nativeUtils.deviceModel() !== "undefined"
  664. }
  665. AppText {
  666. text: qsTr("<b>Device Online:</b> %1 (%2)").arg(app.isOnline ? "Yes" : "No").arg(nativeUtils.connectionType)
  667. font.pixelSize: sp(11)
  668. }
  669. AppText {
  670. text: "<b>MAC Address:</b> " + system.macAddress
  671. font.pixelSize: sp(11)
  672. width: parent.width
  673. wrapMode: Text.WrapAtWordBoundaryOrAnywhere
  674. visible: system.macAddress !== "undefined"
  675. }
  676. AppText {
  677. text: "<b>Unique Device Id:</b> " + system.UDID
  678. font.pixelSize: sp(11)
  679. width: parent.width
  680. wrapMode: Text.WrapAtWordBoundaryOrAnywhere
  681. visible: system.UDID !== "undefined"
  682. }
  683. }
  684. Column {
  685. id: secondInfoColumn
  686. spacing: dp(5)
  687. width: firstInfoColumn.width
  688. AppText {
  689. text: "<b>Orientation:</b> " + (Theme.isPortrait ? "portrait" : "landscape")
  690. font.pixelSize: sp(11)
  691. }
  692. AppText {
  693. text: "<b>Statusbar Height:</b> " + Theme.statusBarHeight
  694. font.pixelSize: sp(11)
  695. }
  696. AppText {
  697. text: "<b>App Identifier:</b> " + system.appIdentifier
  698. font.pixelSize: sp(11)
  699. width: parent.width
  700. wrapMode: Text.WrapAtWordBoundaryOrAnywhere
  701. visible: system.appIdentifier !== "undefined"
  702. }
  703. AppText {
  704. text: "<b>App Version:</b> " + system.appVersionCode
  705. font.pixelSize: sp(11)
  706. }
  707. AppText {
  708. text: "<b>Qt Version:</b> " + system.qtVersion
  709. font.pixelSize: sp(11)
  710. }
  711. AppText {
  712. text: "<b>Felgo Version:</b> " + system.felgoVersion + " (" + system.felgoVersionRef + ")"
  713. font.pixelSize: sp(11)
  714. }
  715. }
  716. }
  717. } // device info section
  718. } // content column
  719. } // flickable
  720. ThemeModal {
  721. id: themeModal
  722. pushBackContent: navigationStack
  723. } // theme modal
  724. } // page