| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- import Felgo
- import QtMultimedia
- import QtQuick
- import QtQuick.Controls
- import "../controls"
- import "../common"
- import "../model"
- AppPage {
- id: page_sys
- title: qsTr("系统设置")
- backgroundColor: app.theme_backgroundColor
- navigationBarHidden: true
- signal logoutClicked
- signal themChange(string mode)
- MediaPlayer{
- id: audio
- audioOutput: AudioOutput{}
- source: Qt.resolvedUrl("../../assets/mp3/button.mp3")
- }
- Connections {
- target: mqtt
- }
- Grid {
- anchors.fill: parent
- anchors.leftMargin: 10
- anchors.topMargin:10
- //anchors.horizontalCenter: parent.horizontalCenter
- columns: 1
- rows: 3
- columnSpacing: 10
- rowSpacing: 5
- horizontalItemAlignment: Grid.AlignHCenter
- Row{
- //anchors.fill: parent
- width: parent.width
- height: parent.height*0.5
- spacing:5
- Rectangle {
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- radius: 5
- //anchors.leftMargin: 10
- AppImage {
- // 将元素的顶部锚定到父元素的顶部
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/ztl.svg"
- }
- Column{
- anchors.centerIn: parent
- AppText{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: -10
- text: "状态栏开关"
- color: app.fontColor
- font.bold: true
- }
- Switch{
- objectName: "openbar_btn"
- id: openbar_btn
- signal opernBar
- signal closeBar
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 40
- onClicked: {
- if(openbar_btn.checked==true){
- console.log("打开状态栏")
- opernBar()
- }else{
- console.log("关闭状态栏")
- closeBar()
- }
- }
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- AppImage {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/dhl.svg"
- }
- Column{
- anchors.centerIn: parent
- AppText{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: -10
- id: net_sta
- text: "导航栏开关"
- color: app.fontColor
- font.bold: true
- }
- Switch{
- id: opennav_btn
- objectName: "opennav_btn"
- signal opernNav
- signal closeNav
- anchors.top: net_sta.bottom
- anchors.topMargin: 20
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- onClicked: {
- if(opennav_btn.checked==true){
- console.log("打开导航栏")
- opernNav()
- }else{
- console.log("关闭导航栏")
- closeNav()
- }
- }
- }
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- AppButton {
- id: button_sleep
- anchors.fill: parent
- onClicked: {
- //退出登录,休眠计时改为0
- logoutClicked()
- loginpage.logintimeout = 59
- }
- }
- AppImage {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/screenoff.svg"
- }
- AppText{
- id: text_gps
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 150
- text: "关闭屏幕"
- color: app.fontColor
- font.bold: true
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- AppButton {
- id: button_reboot
- anchors.fill: parent
- onClicked:{
- serial.reboot()
- }
- }
- AppImage {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 30
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/reboot.svg"
- }
- AppText{
- id: text_reboot
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 150
- text: "重启主板"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- Row {
- width: parent.width
- height: parent.height*0.48
- spacing: 5
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- AppButton {
- anchors.fill: parent
- onClicked: {
- var dialog = InputDialog.inputTextSingleLine(page_sys,
- "请输入密钥!",
- "Input here",
- function(ok,text){
- if(ok){
- if(text==="2024"){
- mqtt.sendUpdatesBoard()
- }else{
- /*
- 0:普通消息框,只有一个“确定”按钮。
- 1:警告消息框,通常用于提醒用户注意。
- 2:确认消息框,包含“是”和“否”两个按钮。
- 3:询问消息框,包含“是”、“否”和“取消”三个按钮。
- 4:错误消息框,用于显示错误或异常情况。
- */
- nativeUtils.displayMessageBox("密钥校验错误!", "", 1)
- }
- }
- }
- )
- }
- }
- AppImage {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 50
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/updateboard.svg"
- }
- AppText{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 150
- text: "升级主板"
- color: app.fontColor
- font.bold: true
- }
- AppText{
- id: boardversion_text
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 200
- text: app.boardversionText
- fontSize: 10
- font.bold: false
- color: "gray"
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- AppImage {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 50
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/updateapp.svg"
- }
- AppButton {
- anchors.fill: parent
- onClicked: {
- var dialog = InputDialog.inputTextSingleLine(page_sys,
- "请输入密钥!",
- "Input here",
- function(ok,text){
- if(ok){
- if(text==="2024"){
- mqtt.sendUpdateApp()
- }else{
- nativeUtils.displayMessageBox("密钥校验错误!", "", 1)
- }
- }
- }
- )
- }
- }
- AppText{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 150
- text: "升级App"
- color: app.fontColor
- font.bold: true
- }
- AppText{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 200
- text: app.appversionText
- fontSize: 10
- font.bold: false
- color: "gray"
- }
- }
- Rectangle {
- id: rec_theme
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- MouseArea{
- anchors.fill: parent
- onClicked: {
- appimage_theme.visible = false
- apptext_title.visible = false
- apptext_select.visible = false
- row_select.visible = true
- }
- }
- Column {
- id: row_select
- visible: false
- anchors.top: parent.top
- anchors.topMargin: 10
- anchors.horizontalCenter: parent.horizontalCenter
- spacing:1
- Component.onCompleted: {
- app.theme_md = settings.getValue("theme_mode")
- if(app.theme_md==="auto"){
- auto_rdb.checked = true
- rec_auto_rdb.border.color = "#0aa26b"
- apptext_select.text = "当前:自动"
- }else if(theme_md==="day"){
- day_rdb.checked = true;
- rec_day_rdb.border.color = "#0aa26b"
- apptext_select.text = "当前:白天"
- }else if(theme_md==="night"){
- night_rdb.checked = true;
- rec_night_rdb.border.color = "#0aa26b"
- apptext_select.text = "当前:黑夜"
- }
- }
- AppText{
- id: apptext_title_mode
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- text: "设置模式"
- font.bold: true
- }
- CustomRadioButton {
- id: auto_rdb
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width*0.8
- checked: true
- text: "自动"
- Rectangle {
- id: rec_auto_rdb
- anchors.fill: parent
- color: "#f5f5f5"
- radius: 5
- border.color: "#f5f5f5"
- border.width: 2
- }
- onCheckedChanged: {
- if(auto_rdb.checked){
- rec_auto_rdb.border.color = "#0aa26b"
- settings.setValue("theme_mode","auto")
- themChange("auto")
- apptext_select.text = "当前:自动"
- }else{
- rec_auto_rdb.border.color = "#f5f5f5"
- }
- }
- }
- CustomRadioButton {
- id: night_rdb
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width*0.8
- text: "黑夜"
- Rectangle {
- id: rec_night_rdb
- anchors.fill: parent
- color: "#f5f5f5"
- radius: 5
- border.color: "#f5f5f5"
- border.width: 2
- }
- onCheckedChanged: {
- if(night_rdb.checked){
- settings.setValue("theme_mode","night")
- rec_night_rdb.border.color = "#0aa26b"
- themChange("night")
- apptext_select.text = "当前:黑夜"
- }else{
- rec_night_rdb.border.color = "#f5f5f5"
- }
- }
- }
- CustomRadioButton {
- id: day_rdb
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.width*0.8
- text: "白天"
- Rectangle {
- id: rec_day_rdb
- anchors.fill: parent
- color: "#f5f5f5"
- radius: 5
- border.color: "#f5f5f5"
- border.width: 2
- }
- onCheckedChanged: {
- if(day_rdb.checked){
- settings.setValue("theme_mode","day")
- rec_day_rdb.border.color = "#0aa26b"
- themChange("day")
- apptext_select.text = "当前:白天"
- }else{
- rec_day_rdb.border.color = "#f5f5f5"
- }
- }
- }
- Row {
- id: row_btn
- anchors.horizontalCenter: parent.horizontalCenter
- AppButton {
- minimumWidth: 40
- minimumHeight: 15
- text: "取消"
- flat: false
- backgroundColor: "#cdcdcd"
- textColor: "#555555"
- onClicked: {
- row_select.visible = false
- rec_theme.color = app.cardColor
- appimage_theme.visible = true
- apptext_title.visible = true
- apptext_select.visible = true
- }
- }
- AppButton {
- minimumWidth: 40
- minimumHeight: 15
- text: "保存"
- flat: false
- backgroundColor: "#0aa26b"
- textColor: "#e6f6f0"
- onClicked: {
- row_select.visible = false
- rec_theme.color = app.cardColor
- appimage_theme.visible = true
- apptext_title.visible = true
- apptext_select.visible = true
- }
- }
- }
- }
- AppImage {
- id: appimage_theme
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 50
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/themset.svg"
- }
- AppText{
- id: apptext_title
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 150
- text: "设置主题"
- color: app.fontColor
- font.bold: true
- }
- AppText {
- id: apptext_select
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 170
- text: "当前:" + settings.getValue("theme_mode")
- fontSize: 10
- font.bold: false
- color: "gray"
- }
- }
- Rectangle {
- radius: 5
- width: parent.width*0.245
- height: parent.height
- color: app.cardColor
- AppButton {
- anchors.fill: parent
- onClicked: {
- logoutClicked()
- }
- }
- AppImage {
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 50
- fillMode: Image.PreserveAspectFit // 保持纵横比适应
- source: "../../assets/logout.svg"
- }
- AppText{
- anchors.top: parent.top
- anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
- anchors.topMargin: 150
- text: "退出登录"
- color: app.fontColor
- font.bold: true
- }
- }
- }
- }
- }
|