import Felgo import QtMultimedia import QtQuick import QtQuick.Controls import EasyModel 1.0 import com.example.database 1.0 import "../controls" import "../common" import "../model" AppPage { id: page_sys title: qsTr("系统设置") backgroundColor: app.theme_backgroundColor navigationBarHidden: true property var picinfo_list:[] signal logoutClicked signal themChange(string mode) // 参数重置二次确认挂起标志: // nativeUtils 是全局单例,其它页面/流程也会弹 messageBox, // 必须用标志位区分"本次参数重置弹窗"的确认/取消,避免其它弹窗误触发重置指令 property bool resetConfirmPending: false Connections { target: nativeUtils function onMessageBoxFinished(accepted) { if(!resetConfirmPending) return resetConfirmPending = false if(accepted){ console.log("参数重置已确认,发送JSONRPC恢复出厂设置指令!") serial.makeJsonRpc("factory_reset", "") }else{ console.log("参数重置已取消") } } } MediaPlayer{ id: audio audioOutput: AudioOutput{} source: Qt.resolvedUrl("../../assets/mp3/button.mp3") } Connections { target: mqtt } // 权限管理页:以 Component 形式定义,供"权限管理"按钮 push 进入 Component { id: permission_component PermissionPage { } } // 日志查看页:供"查看日志"按钮 push 进入 // 支持 App 运行日志列表、tail -f 实时刷新、打开历史文件、上传(FTP) Component { id: logviewer_component LogViewerPage { } } // 数据库管理页: 查看/修改 config.db、data.db 的表结构与数据 // 具体实现见 pages/SqlScreen.qml(数据页 + 表结构页 + 字段中文说明) Component { id: sqlite_component SqlScreen { } } Grid { anchors.fill: parent anchors.leftMargin: 5 anchors.topMargin:5 columns: 1 rows: 3 columnSpacing: 10 rowSpacing: 5 horizontalItemAlignment: Grid.AlignHCenter Rectangle { radius: 5 width: parent.width * 0.995 height: parent.height*0.18 color: app.cardColor Timer { interval: 1000 running: true repeat: true onTriggered: { picinfo_list = serial.pathinfo() text_info.text = "占用大小:" + picinfo_list[2] + "(Mb)" + "文件数量:" + picinfo_list[1] text_pathinfo.text = "图片存储目录:" + picinfo_list[0] } } AppImage { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left fillMode: Image.PreserveAspectFit source: "../../assets/floder.svg" } Column{ id: column_info anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 100 AppText{ id: text_info text: "存储占用:" + "" color: app.fontColor font.bold: true } AppText{ id: text_pathinfo text:"图片存储目录:" fontSize: 10 color: "gray" } } AppButton { id:btn_fresh anchors.verticalCenter: parent.verticalCenter anchors.left: column_info.right anchors.leftMargin: dp(50) text: "刷新" flat: false textColor: "black" backgroundColor: "#e9e9e9" borderColor: "white" onClicked: { serial.readPathinfo() } } AppButton { id:btn_clear anchors.verticalCenter: parent.verticalCenter anchors.left: btn_fresh.right text: "清理" flat: false textColor: "white" backgroundColor: "#0aa26b" borderColor: "white" onClicked: { serial.removepic() } } // 权限管理入口:定位/电话/文件与媒体/修改系统设置等权限的检测与开启 AppButton { id:btn_permission anchors.verticalCenter: parent.verticalCenter anchors.left: btn_clear.right anchors.leftMargin: dp(10) text: "权限管理" flat: false textColor: "white" backgroundColor: "#1a73e8" borderColor: "white" onClicked: { page_sys.navigationStack.push(permission_component) } } // 参数重置:二次弹窗确认后,串口发 JSONRPC 指令把 MCU 参数恢复出厂设置 AppButton { id:btn_param_reset anchors.verticalCenter: parent.verticalCenter anchors.left: btn_permission.right anchors.leftMargin: dp(10) text: "参数重置" flat: false textColor: "white" backgroundColor: "#d9534f" borderColor: "white" onClicked: { resetConfirmPending = true nativeUtils.displayMessageBox( "参数重置确认", "将把MCU参数恢复出厂设置,该操作不可撤销!\n是否继续?", 1 ) } } // 查看日志:进入日志页(LogViewerPage) // · App 运行日志 run_log*.txt (spdlog 轮转, 10MB×10) // 支持 tail -f 实时刷新、打开历史文件、选择文件上传(FTP) AppButton { id:btn_view_log anchors.verticalCenter: parent.verticalCenter anchors.left: btn_param_reset.right anchors.leftMargin: dp(10) text: "查看日志" flat: false textColor: "white" backgroundColor: "#5f6368" borderColor: "white" onClicked: { page_sys.navigationStack.push(logviewer_component) } } } Row{ width: parent.width height: parent.height*0.39 spacing:5 Rectangle { width: parent.width*0.245 height: parent.height color: app.cardColor radius: 5 Column{ anchors.fill: parent spacing: 5 AppImage { anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/ztl.svg" } AppText{ anchors.horizontalCenter: parent.horizontalCenter text: "状态栏开关" color: app.fontColor font.bold: true } Switch{ anchors.horizontalCenter: parent.horizontalCenter objectName: "openbar_btn" id: openbar_btn signal opernBar signal closeBar 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 Column{ anchors.fill: parent spacing: 5 AppImage { anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/dhl.svg" } AppText{ anchors.horizontalCenter: parent.horizontalCenter id: net_sta text: "导航栏开关" color: app.fontColor font.bold: true } Switch{ id: opennav_btn objectName: "opennav_btn" signal opernNav signal closeNav 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 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.fill: parent spacing: 5 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" } row_select.visible = false rec_theme.color = app.cardColor appimage_theme.visible = true apptext_title.visible = true apptext_select.visible = true } } 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" } row_select.visible = false rec_theme.color = app.cardColor appimage_theme.visible = true apptext_title.visible = true apptext_select.visible = true } } 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_select.visible = false rec_theme.color = app.cardColor appimage_theme.visible = true apptext_title.visible = true apptext_select.visible = true } } } Column { anchors.fill: parent spacing: 5 topPadding: 10 AppImage { id: appimage_theme anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/themset.svg" } AppText{ id: apptext_title anchors.horizontalCenter: parent.horizontalCenter text: "设置主题" color: app.fontColor font.bold: true } AppText { id: apptext_select anchors.horizontalCenter: parent.horizontalCenter 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 Column { anchors.fill: parent spacing: 5 topPadding: 10 AppButton { anchors.fill: parent onClicked: { logoutClicked() } } AppImage { id: image_exit anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/logout.svg" } AppText{ anchors.horizontalCenter: parent.horizontalCenter text: "退出登录" color: app.fontColor font.bold: true } } } } Row { width: parent.width height: parent.height*0.39 spacing: 5 Rectangle { radius: 5 width: parent.width*0.245 height: parent.height color: app.cardColor Column { anchors.fill: parent spacing: 5 topPadding: 10 AppImage { anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/updateboard.svg" } AppText { anchors.horizontalCenter: parent.horizontalCenter text: "升级主板" color: app.fontColor font.bold: true } AppText { anchors.horizontalCenter: parent.horizontalCenter text: "当前:" + app.boardversionText fontSize: 10 color: "gray" } MouseArea { anchors.horizontalCenter: parent.horizontalCenter width: parent.width * 0.7 height: dp(30) AppText { anchors.centerIn: parent text: "点击升级" color: "#0aa26b" font.pixelSize: sp(12) } onClicked: { var dialog = InputDialog.inputTextSingleLine(page_sys, "请输入密钥!", "Input here", function(ok, text){ if(ok){ if(text==="2024"){ mqtt.sendUpdatesBoard() }else{ nativeUtils.displayMessageBox("密钥校验错误!", "", 1) } } } ) } } } } Rectangle { radius: 5 width: parent.width*0.245 height: parent.height color: app.cardColor Column { anchors.fill: parent spacing: 5 topPadding: 10 AppImage { anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/updateapp.svg" } AppText { anchors.horizontalCenter: parent.horizontalCenter text: "升级App" color: app.fontColor font.bold: true } AppText { anchors.horizontalCenter: parent.horizontalCenter text: "当前:" + app.appversionText fontSize: 10 color: "gray" } MouseArea { anchors.horizontalCenter: parent.horizontalCenter width: parent.width * 0.7 height: dp(30) AppText { anchors.centerIn: parent text: "点击升级" color: "#0aa26b" font.pixelSize: sp(12) } onClicked: { var dialog = InputDialog.inputTextSingleLine(page_sys, "请输入密钥!", "Input here", function(ok, text){ if(ok){ if(text==="2024"){ mqtt.sendUpdateApp() }else{ nativeUtils.displayMessageBox("密钥校验错误!", "", 1) } } } ) } } } } Rectangle { id: rec_theme radius: 5 width: parent.width*0.245 height: parent.height color: app.cardColor Column { anchors.fill: parent anchors.topMargin: parent.height * 0.15 spacing: 10 AppImage { id: image_reboot anchors.horizontalCenter: parent.horizontalCenter fillMode: Image.PreserveAspectFit source: "../../assets/reboot.svg" } AppText{ id: text_reboot anchors.horizontalCenter: parent.horizontalCenter text: "系统重启" color: app.fontColor font.bold: true } MouseArea { anchors.horizontalCenter: parent.horizontalCenter width: parent.width * 0.7 height: dp(30) AppText { anchors.centerIn: parent text: "点击重启" color: "#0aa26b" font.pixelSize: sp(12) } onClicked: { var dialog = InputDialog.inputTextSingleLine(page_sys, "请输入密钥!", "Input here", function(ok, text){ if(ok){ if(text==="2024"){ serial.reboot() }else{ nativeUtils.displayMessageBox("密钥校验错误!", "", 1) } } } ) } } } } Rectangle { radius: 5 width: parent.width*0.245 height: parent.height color: app.cardColor Column { anchors.centerIn: parent anchors.horizontalCenter: parent.horizontalCenter spacing: 5 AppText { anchors.horizontalCenter: parent.horizontalCenter text: "参数调试" color: app.fontColor font.bold: true } MouseArea { anchors.horizontalCenter: parent.horizontalCenter width: parent.width * 0.7 height: dp(30) AppText { anchors.centerIn: parent text: "点击进入" color: "#0aa26b" font.pixelSize: sp(12) } onClicked: { var dialog = InputDialog.inputTextSingleLine(page_sys, "请输入密钥!", "Input here", function(ok, text){ if(ok){ if(text==="2024"){ page_sys.navigationStack.push(sqlite_component) }else{ nativeUtils.displayMessageBox("密钥校验错误!", "", 1) } } } ) } } } } } } }