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) MediaPlayer{ id: audio audioOutput: AudioOutput{} source: Qt.resolvedUrl("../../assets/mp3/button.mp3") } Connections { target: mqtt } Component { id: sqlite_component AppPage { id: sqlite_page implicitHeight: 800 implicitWidth: 1280 rightBarItem: IconButtonBarItem { iconType: IconType.paintbrush onClicked: { console.log("database") sqliteModal.open() } } property int verHeaderHeight: 30 property int verHeaderWidth: 150 property int horHeaderHeight: 30 property color scrollBarColor: "cyan" property int scrollBarWidth: 6 property variant columnWidthArr: [30,100,100,100,100,100,200,100,100,100,100,100,100] property variant table_mqtt_Value: ["id","dtype","ip","port","imei","uid","pwd","clientid","qos","keepalive","sub","pub","offline"] property variant table_ftp_Value: ["id","ip","port","dir","uid","pwd","mode"] property variant table_location_Value: ["id","lbs_lat","lbs_lng","gps_lat","gps_lng","gps_elevation"] property variant table_camera_Value: ["camera_type","mode","stitch_photonum","photo_width","photo_height","auto_focus"] property variant table_json_Value: ["id","datetime","json_data","json_data"] property int datacount: 1 DatabaseInterface { id: db_cfg } EasyTableModel{ id: table_model horHeader: table_mqtt_Value } TableView{ id: table_view height: sqlite_page.implicitHeight anchors{ left: parent.left right: parent.right top: parent.top leftMargin: 30 topMargin: sqlite_page.horHeaderHeight } clip: true boundsBehavior: Flickable.StopAtBounds columnSpacing: 1 rowSpacing: 1 rowHeightProvider: function (row) { return sqlite_page.verHeaderHeight; } columnWidthProvider: function (column) { return sqlite_page.columnWidthArr[column]; } ScrollBar.vertical: ScrollBar { id: scroll_vertical anchors.right: parent.right anchors.rightMargin: 2 contentItem: Rectangle{ visible: (scroll_vertical.size<1.0) implicitWidth: sqlite_page.scrollBarWidth color: sqlite_page.scrollBarColor } } ScrollBar.horizontal: ScrollBar { id: scroll_horizontal anchors.bottom: parent.bottom anchors.bottomMargin: 2 contentItem: Rectangle{ visible: (scroll_horizontal.size<1.0) implicitHeight: sqlite_page.scrollBarWidth color: sqlite_page.scrollBarColor } } model: table_model delegate: Rectangle { color: (model.row%2)?"orange":Qt.darker("orange") AppText{ id : value_text anchors.centerIn: parent verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: model.value AppButton { onClicked: { var dialog = InputDialog.inputTextSingleLine(app, "请输入要修改内容", value_text.text, function(ok,text){ if(ok){ value_text.text = text model.edit=text; console.log("edit",model.value) if(sqlite_switch.checked) { if(table_combox.displayText===table_combox.model[0]||table_combox.displayText===table_combox.model[1]) { columnWidthArr = [30,100,100,100,100,100,200,100,100,100,100,100,100] db_cfg.updateData(table_combox.displayText,table_mqtt_Value[index],model.value) } if(table_combox.displayText===table_combox.model[2]||table_combox.displayText===table_combox.model[3]) { db_cfg.updateData(table_combox.displayText,table_ftp_Value[index],model.value) } if(table_combox.displayText===table_combox.model[4]) { db_cfg.updateData(table_combox.displayText,table_location_Value[index],model.value) } if(table_combox.displayText===table_combox.model[5]){ db_cfg.updateData(table_combox.displayText,table_camera_Value[index],model.value) } } } }) dialog.negativeAction = false dialog.outsideTouchable = true } } } } } Item{ id: header_horizontal anchors{ left: parent.left right: parent.right leftMargin: 30 } height: sqlite_page.horHeaderHeight z: 2 property int posXTemp: 0 MouseArea{ anchors.fill: parent onPressed: { header_horizontal.posXTemp=mouseX; } onPositionChanged: { if(table_view.contentX+(header_horizontal.posXTemp-mouseX)>0){ table_view.contentX+=(header_horizontal.posXTemp-mouseX); }else{ table_view.contentX=0; } header_horizontal.posXTemp=mouseX; } } Row { id: header_horizontal_row anchors.fill: parent leftPadding: -table_view.contentX clip: true spacing: 0 Repeater { model: table_view.columns > 0 ? table_view.columns : 0 Rectangle { id: header_horizontal_item width: table_view.columnWidthProvider(index)+table_view.columnSpacing height: sqlite_page.horHeaderHeight color: "purple" AppText { anchors.centerIn: parent text: table_model.headerData(index, Qt.Horizontal) } Rectangle{ width: 1 height: parent.height anchors.right: parent.right color: "black" opacity: 0.5 } MouseArea{ width: 3 height: parent.height anchors.right: parent.right cursorShape: Qt.SplitHCursor onPressed: header_horizontal.posXTemp=mouseX; onPositionChanged: { if((header_horizontal_item.width-(header_horizontal.posXTemp-mouseX))>10){ header_horizontal_item.width-=(header_horizontal.posXTemp-mouseX); }else{ header_horizontal_item.width=10; } header_horizontal.posXTemp=mouseX; sqlite_page.columnWidthArr[index]=(header_horizontal_item.width-table_view.columnSpacing); table_view.forceLayout(); } } } } } } Column { id: header_verical height: sqlite_page.implicitHeight anchors{ left: parent.left top: parent.top topMargin: sqlite_page.horHeaderHeight } topPadding: -table_view.contentY z: 2 clip: true spacing: 1 Repeater { model: table_view.rows > 0 ? table_view.rows : 0 Rectangle { width: 30 height: table_view.rowHeightProvider(index) color: "green" Text { anchors.centerIn: parent text: table_model.headerData(index, Qt.Vertical) } } } } AppModal { id: sqliteModal fullscreen: false modalHeight: dp(380) + nativeUtils.safeAreaInsets.bottom NavigationStack { AppPage { title: "配置信息管理" rightBarItem: TextButtonBarItem { text: "关闭" textItem.font.pixelSize: sp(16) onClicked: sqliteModal.close() } Column { id: sqliteColumn width: parent.width Section { title: "数据库" ComboBox { id: sqlite_combox height: dp(40) width: parent.width/2 model: ["config.db", "data.db"] } } Section { title: "数据表" ComboBox { id: table_combox height: dp(40) width: parent.width/2 model: ["mqtt", "mqtt_other","ftp","ftp_other","location","camera","data"] onActivated: { console.log(displayText) table_model.table_name = displayText if(displayText===model[0]||displayText===model[1]) { columnWidthArr = [30,100,100,100,100,100,200,100,100,100,100,100,100] table_model.horHeader = table_mqtt_Value } else if(displayText===model[2]||displayText===model[3]) { table_model.horHeader = table_ftp_Value } else if(displayText===model[4]) { table_model.horHeader = table_location_Value }else if(displayText===model[5]){ columnWidthArr = [100,100,150,100,100,100] table_model.horHeader = table_camera_Value } else if(displayText===model[6]) { table_model.horHeader = table_json_Value } table_model.initData=db_cfg.queryData(displayText,datacount) } } } AppText { id: sqlite_text text: "开关:" } AppSwitch { id: sqlite_switch anchors.left: sqlite_text.light anchors.leftMargin: 10 onToggled: { if(sqlite_switch.checked){ var dbs = db_cfg.openDatabase(sqlite_combox.displayText) if(dbs){ console.log("打开数据库成功"); sqlite_combox.enabled = false table_combox.enabled = true if(sqlite_combox.displayText==="data.db") { table_combox.displayText=table_combox.model[6]; } table_model.table_name = table_combox.displayText table_model.initData=db_cfg.queryData(table_combox.displayText,datacount) }else{ sqlite_switch.checked = false sqlite_combox.enabled = true; console.log("打开数据库失败"); } }else{ sqlite_combox.enabled = true; db_cfg.closeDatabase() console.log("关闭数据库"); } } } } } } } } } 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() } } } 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) } } } ) } } } } } } }