ProfilePage.qml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. import Felgo
  2. import QtMultimedia
  3. import QtQuick
  4. import QtQuick.Controls
  5. import "../controls"
  6. import "../common"
  7. import "../model"
  8. AppPage {
  9. id: page_sys
  10. title: qsTr("系统设置")
  11. backgroundColor: app.theme_backgroundColor
  12. navigationBarHidden: true
  13. signal logoutClicked
  14. signal themChange(string mode)
  15. MediaPlayer{
  16. id: audio
  17. audioOutput: AudioOutput{}
  18. source: Qt.resolvedUrl("../../assets/mp3/button.mp3")
  19. }
  20. Connections {
  21. target: mqtt
  22. }
  23. Grid {
  24. anchors.fill: parent
  25. anchors.leftMargin: 10
  26. anchors.topMargin:10
  27. //anchors.horizontalCenter: parent.horizontalCenter
  28. columns: 1
  29. rows: 3
  30. columnSpacing: 10
  31. rowSpacing: 5
  32. horizontalItemAlignment: Grid.AlignHCenter
  33. Row{
  34. //anchors.fill: parent
  35. width: parent.width
  36. height: parent.height*0.5
  37. spacing:5
  38. Rectangle {
  39. width: parent.width*0.245
  40. height: parent.height
  41. color: app.cardColor
  42. radius: 5
  43. //anchors.leftMargin: 10
  44. AppImage {
  45. // 将元素的顶部锚定到父元素的顶部
  46. anchors.top: parent.top
  47. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  48. anchors.topMargin: 30
  49. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  50. source: "../../assets/ztl.svg"
  51. }
  52. Column{
  53. anchors.centerIn: parent
  54. AppText{
  55. anchors.top: parent.top
  56. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  57. anchors.topMargin: -10
  58. text: "状态栏开关"
  59. color: app.fontColor
  60. font.bold: true
  61. }
  62. Switch{
  63. objectName: "openbar_btn"
  64. id: openbar_btn
  65. signal opernBar
  66. signal closeBar
  67. anchors.top: parent.top
  68. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  69. anchors.topMargin: 40
  70. onClicked: {
  71. if(openbar_btn.checked==true){
  72. console.log("打开状态栏")
  73. opernBar()
  74. }else{
  75. console.log("关闭状态栏")
  76. closeBar()
  77. }
  78. }
  79. }
  80. }
  81. }
  82. Rectangle {
  83. radius: 5
  84. width: parent.width*0.245
  85. height: parent.height
  86. color: app.cardColor
  87. AppImage {
  88. anchors.top: parent.top
  89. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  90. anchors.topMargin: 30
  91. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  92. source: "../../assets/dhl.svg"
  93. }
  94. Column{
  95. anchors.centerIn: parent
  96. AppText{
  97. anchors.top: parent.top
  98. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  99. anchors.topMargin: -10
  100. id: net_sta
  101. text: "导航栏开关"
  102. color: app.fontColor
  103. font.bold: true
  104. }
  105. Switch{
  106. id: opennav_btn
  107. objectName: "opennav_btn"
  108. signal opernNav
  109. signal closeNav
  110. anchors.top: net_sta.bottom
  111. anchors.topMargin: 20
  112. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  113. onClicked: {
  114. if(opennav_btn.checked==true){
  115. console.log("打开导航栏")
  116. opernNav()
  117. }else{
  118. console.log("关闭导航栏")
  119. closeNav()
  120. }
  121. }
  122. }
  123. }
  124. }
  125. Rectangle {
  126. radius: 5
  127. width: parent.width*0.245
  128. height: parent.height
  129. color: app.cardColor
  130. AppButton {
  131. id: button_sleep
  132. anchors.fill: parent
  133. onClicked: {
  134. //退出登录,休眠计时改为0
  135. logoutClicked()
  136. loginpage.logintimeout = 59
  137. }
  138. }
  139. AppImage {
  140. anchors.top: parent.top
  141. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  142. anchors.topMargin: 30
  143. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  144. source: "../../assets/screenoff.svg"
  145. }
  146. AppText{
  147. id: text_gps
  148. anchors.top: parent.top
  149. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  150. anchors.topMargin: 150
  151. text: "关闭屏幕"
  152. color: app.fontColor
  153. font.bold: true
  154. }
  155. }
  156. Rectangle {
  157. radius: 5
  158. width: parent.width*0.245
  159. height: parent.height
  160. color: app.cardColor
  161. AppButton {
  162. id: button_reboot
  163. anchors.fill: parent
  164. onClicked:{
  165. serial.reboot()
  166. }
  167. }
  168. AppImage {
  169. anchors.top: parent.top
  170. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  171. anchors.topMargin: 30
  172. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  173. source: "../../assets/reboot.svg"
  174. }
  175. AppText{
  176. id: text_reboot
  177. anchors.top: parent.top
  178. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  179. anchors.topMargin: 150
  180. text: "重启主板"
  181. color: app.fontColor
  182. font.bold: true
  183. }
  184. }
  185. }
  186. Row {
  187. width: parent.width
  188. height: parent.height*0.48
  189. spacing: 5
  190. Rectangle {
  191. radius: 5
  192. width: parent.width*0.245
  193. height: parent.height
  194. color: app.cardColor
  195. AppButton {
  196. anchors.fill: parent
  197. onClicked: {
  198. var dialog = InputDialog.inputTextSingleLine(page_sys,
  199. "请输入密钥!",
  200. "Input here",
  201. function(ok,text){
  202. if(ok){
  203. if(text==="2024"){
  204. mqtt.sendUpdatesBoard()
  205. }else{
  206. /*
  207. 0:普通消息框,只有一个“确定”按钮。
  208. 1:警告消息框,通常用于提醒用户注意。
  209. 2:确认消息框,包含“是”和“否”两个按钮。
  210. 3:询问消息框,包含“是”、“否”和“取消”三个按钮。
  211. 4:错误消息框,用于显示错误或异常情况。
  212. */
  213. nativeUtils.displayMessageBox("密钥校验错误!", "", 1)
  214. }
  215. }
  216. }
  217. )
  218. }
  219. }
  220. AppImage {
  221. anchors.top: parent.top
  222. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  223. anchors.topMargin: 50
  224. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  225. source: "../../assets/updateboard.svg"
  226. }
  227. AppText{
  228. anchors.top: parent.top
  229. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  230. anchors.topMargin: 150
  231. text: "升级主板"
  232. color: app.fontColor
  233. font.bold: true
  234. }
  235. AppText{
  236. id: boardversion_text
  237. anchors.top: parent.top
  238. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  239. anchors.topMargin: 200
  240. text: app.boardversionText
  241. fontSize: 10
  242. font.bold: false
  243. color: "gray"
  244. }
  245. }
  246. Rectangle {
  247. radius: 5
  248. width: parent.width*0.245
  249. height: parent.height
  250. color: app.cardColor
  251. AppImage {
  252. anchors.top: parent.top
  253. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  254. anchors.topMargin: 50
  255. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  256. source: "../../assets/updateapp.svg"
  257. }
  258. AppButton {
  259. anchors.fill: parent
  260. onClicked: {
  261. var dialog = InputDialog.inputTextSingleLine(page_sys,
  262. "请输入密钥!",
  263. "Input here",
  264. function(ok,text){
  265. if(ok){
  266. if(text==="2024"){
  267. mqtt.sendUpdateApp()
  268. }else{
  269. nativeUtils.displayMessageBox("密钥校验错误!", "", 1)
  270. }
  271. }
  272. }
  273. )
  274. }
  275. }
  276. AppText{
  277. anchors.top: parent.top
  278. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  279. anchors.topMargin: 150
  280. text: "升级App"
  281. color: app.fontColor
  282. font.bold: true
  283. }
  284. AppText{
  285. anchors.top: parent.top
  286. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  287. anchors.topMargin: 200
  288. text: app.appversionText
  289. fontSize: 10
  290. font.bold: false
  291. color: "gray"
  292. }
  293. }
  294. Rectangle {
  295. id: rec_theme
  296. radius: 5
  297. width: parent.width*0.245
  298. height: parent.height
  299. color: app.cardColor
  300. MouseArea{
  301. anchors.fill: parent
  302. onClicked: {
  303. appimage_theme.visible = false
  304. apptext_title.visible = false
  305. apptext_select.visible = false
  306. row_select.visible = true
  307. }
  308. }
  309. Column {
  310. id: row_select
  311. visible: false
  312. anchors.top: parent.top
  313. anchors.topMargin: 10
  314. anchors.horizontalCenter: parent.horizontalCenter
  315. spacing:1
  316. Component.onCompleted: {
  317. app.theme_md = settings.getValue("theme_mode")
  318. if(app.theme_md==="auto"){
  319. auto_rdb.checked = true
  320. rec_auto_rdb.border.color = "#0aa26b"
  321. apptext_select.text = "当前:自动"
  322. }else if(theme_md==="day"){
  323. day_rdb.checked = true;
  324. rec_day_rdb.border.color = "#0aa26b"
  325. apptext_select.text = "当前:白天"
  326. }else if(theme_md==="night"){
  327. night_rdb.checked = true;
  328. rec_night_rdb.border.color = "#0aa26b"
  329. apptext_select.text = "当前:黑夜"
  330. }
  331. }
  332. AppText{
  333. id: apptext_title_mode
  334. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  335. text: "设置模式"
  336. font.bold: true
  337. }
  338. CustomRadioButton {
  339. id: auto_rdb
  340. anchors.horizontalCenter: parent.horizontalCenter
  341. width: parent.width*0.8
  342. checked: true
  343. text: "自动"
  344. Rectangle {
  345. id: rec_auto_rdb
  346. anchors.fill: parent
  347. color: "#f5f5f5"
  348. radius: 5
  349. border.color: "#f5f5f5"
  350. border.width: 2
  351. }
  352. onCheckedChanged: {
  353. if(auto_rdb.checked){
  354. rec_auto_rdb.border.color = "#0aa26b"
  355. settings.setValue("theme_mode","auto")
  356. themChange("auto")
  357. apptext_select.text = "当前:自动"
  358. }else{
  359. rec_auto_rdb.border.color = "#f5f5f5"
  360. }
  361. }
  362. }
  363. CustomRadioButton {
  364. id: night_rdb
  365. anchors.horizontalCenter: parent.horizontalCenter
  366. width: parent.width*0.8
  367. text: "黑夜"
  368. Rectangle {
  369. id: rec_night_rdb
  370. anchors.fill: parent
  371. color: "#f5f5f5"
  372. radius: 5
  373. border.color: "#f5f5f5"
  374. border.width: 2
  375. }
  376. onCheckedChanged: {
  377. if(night_rdb.checked){
  378. settings.setValue("theme_mode","night")
  379. rec_night_rdb.border.color = "#0aa26b"
  380. themChange("night")
  381. apptext_select.text = "当前:黑夜"
  382. }else{
  383. rec_night_rdb.border.color = "#f5f5f5"
  384. }
  385. }
  386. }
  387. CustomRadioButton {
  388. id: day_rdb
  389. anchors.horizontalCenter: parent.horizontalCenter
  390. width: parent.width*0.8
  391. text: "白天"
  392. Rectangle {
  393. id: rec_day_rdb
  394. anchors.fill: parent
  395. color: "#f5f5f5"
  396. radius: 5
  397. border.color: "#f5f5f5"
  398. border.width: 2
  399. }
  400. onCheckedChanged: {
  401. if(day_rdb.checked){
  402. settings.setValue("theme_mode","day")
  403. rec_day_rdb.border.color = "#0aa26b"
  404. themChange("day")
  405. apptext_select.text = "当前:白天"
  406. }else{
  407. rec_day_rdb.border.color = "#f5f5f5"
  408. }
  409. }
  410. }
  411. Row {
  412. id: row_btn
  413. anchors.horizontalCenter: parent.horizontalCenter
  414. AppButton {
  415. minimumWidth: 40
  416. minimumHeight: 15
  417. text: "取消"
  418. flat: false
  419. backgroundColor: "#cdcdcd"
  420. textColor: "#555555"
  421. onClicked: {
  422. row_select.visible = false
  423. rec_theme.color = app.cardColor
  424. appimage_theme.visible = true
  425. apptext_title.visible = true
  426. apptext_select.visible = true
  427. }
  428. }
  429. AppButton {
  430. minimumWidth: 40
  431. minimumHeight: 15
  432. text: "保存"
  433. flat: false
  434. backgroundColor: "#0aa26b"
  435. textColor: "#e6f6f0"
  436. onClicked: {
  437. row_select.visible = false
  438. rec_theme.color = app.cardColor
  439. appimage_theme.visible = true
  440. apptext_title.visible = true
  441. apptext_select.visible = true
  442. }
  443. }
  444. }
  445. }
  446. AppImage {
  447. id: appimage_theme
  448. anchors.top: parent.top
  449. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  450. anchors.topMargin: 50
  451. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  452. source: "../../assets/themset.svg"
  453. }
  454. AppText{
  455. id: apptext_title
  456. anchors.top: parent.top
  457. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  458. anchors.topMargin: 150
  459. text: "设置主题"
  460. color: app.fontColor
  461. font.bold: true
  462. }
  463. AppText {
  464. id: apptext_select
  465. anchors.top: parent.top
  466. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  467. anchors.topMargin: 170
  468. text: "当前:" + settings.getValue("theme_mode")
  469. fontSize: 10
  470. font.bold: false
  471. color: "gray"
  472. }
  473. }
  474. Rectangle {
  475. radius: 5
  476. width: parent.width*0.245
  477. height: parent.height
  478. color: app.cardColor
  479. AppButton {
  480. anchors.fill: parent
  481. onClicked: {
  482. logoutClicked()
  483. }
  484. }
  485. AppImage {
  486. anchors.top: parent.top
  487. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  488. anchors.topMargin: 50
  489. fillMode: Image.PreserveAspectFit // 保持纵横比适应
  490. source: "../../assets/logout.svg"
  491. }
  492. AppText{
  493. anchors.top: parent.top
  494. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  495. anchors.topMargin: 150
  496. text: "退出登录"
  497. color: app.fontColor
  498. font.bold: true
  499. }
  500. }
  501. }
  502. }
  503. }