| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829 |
- import QtQuick
- import Felgo
- import QtMultimedia
- import QtQuick.Controls
- import Qt.labs.settings 1.0 as QtLabs
- import QtQuick.Controls.Material 2.0
- import QtLocation 5.5
- import QtPositioning 5.5
- import Qt5Compat.GraphicalEffects
- import "../controls"
- import "../common"
- import Frames 0.1
- AppPage {
- //【必须有 id】上传进度弹层里用了 page.uploadPercent / page.uploadFailed 等绑定,
- //根元素原来没有 id,page 是未定义标识符 -> 绑定报 ReferenceError,
- //Popup 的 visible 永远算不出来,表现为"上传进度不显示"。
- id: page
- objectName: "autoFocus_Page"
- navigationBarHidden: true
- backgroundColor: app.theme_backgroundColor
- property var videoFormats
- // 定义电机状态
- property int currentAxis: 0 // 当前选择的轴 (0: X, 1: Y, 2: Z)
- property var axisPositions: [0, 0, 0] // 各轴当前位置
- property int speed: 50 // 当前速度 (0-100)
- property int stepDistance: 20 // 步进脉冲数量
- property string fExposureTime: "0"
- property bool motorUnlocked: false
- // ===== 上传进度水印(单张) =====
- // 业务上一次只上传一张图片(串行队列 FIFO,见 CurlFtpUploader::runLoop),
- // 所以不需要按序号铺 32 格进度网格,直接在画面上叠加一个整体进度水印即可。
- // uploading : 是否处于上传中(含进度回调已到达但 finished 尚未回来的窗口)
- // percent : 0~100,来自 CurlFtpUploader::progressChanged
- // fileName : 当前上传文件名(取末段),仅用于水印上显示是哪一张
- // failed : 本次上传是否失败(决定水印配色与文案)
- property bool uploading: false
- property double uploadPercent: 0
- property string uploadFileName: ""
- property bool uploadFailed: false
- // 进度圆可见性:仅在触发上传时为 true,收到 finished 后立即置 false 关闭展示
- property bool uploadWatermarkVisible: false
- function resetUploadWatermark() {
- uploading = false
- uploadPercent = 0
- uploadFileName = ""
- uploadFailed = false
- uploadWatermarkVisible = false
- uploadHideTimer.stop()
- }
- function autotake(sw){
- if(sw)
- {
- console.log("autotakestart")
- frames.camera_sw = true
- //frames.auto_clicked = true //开始对焦
- auto_timer.start() //启动对焦定时器
- console.log("相机已打开")
- photoTimer.interval=180*1000
- photoTimer.start()
- }else{
- frames.camera_sw = true
- console.log("打开相机单次拍照!")
- }
- }
- Frames {
- objectName: "Frames"
- id: frames
- videoSink: output.videoSink
- onCameraOpenFailed:function(err){
- console.log("onCameraOpenFailed",err)
- nativeUtils.displayMessageBox("相机打开失败!",err,1)
- focus_switch.checked = false
- focus_switch.enabled = true
- takephoto_switch.checked = false
- takephoto_switch.enabled = true
- }
- onVideoSinkChanged: {
- console.log("onVideoSinkChanged")
- photoTimer.start() //两秒后关闭相机,因为相机加载的慢,否则关不住
- }
- onQulityStringChanged: {
- loginpage.logintimeout = 600; //拍照刷新熄屏计时
- photoTimer.interval = 180*1000 //3分钟超时
- photoTimer.restart()
- }
- onRecordFileSaved: function(path){
- console.log("录制视频流已保存:", path)
- apptext_res.text = "录制已保存:" + path.split("/").pop()
- }
- onCameraStaChanged: function(sta_cam) {
- if(sta_cam){
- //camera.active = sta_cam
- //camera.start()
- //每次(重新)打开相机后清空上传进度水印(上一次采集的进度/结果不再保留)
- resetUploadWatermark()
- loginpage.logintimeout = 600; //拍照刷新熄屏计时
- output.visible = sta_cam
- photoTimer.interval = 180*1000 //3分钟超时
- photoTimer.start()
- //uvc_camera.visible = false
- }else{
- //camera.active = sta_cam
- //camera.stop()
- output.visible= sta_cam
- photoTimer.stop() //停止计时器
- focus_switch.checked = false
- focus_switch.enabled = true
- takephoto_switch.checked = false
- takephoto_switch.enabled = true
- //uvc_camera.visible = true
- }
- console.log("相机状态改变",sta_cam)
- }
- onStepCountChanged: function(step){
- console.log("坐标改变",step)
- step_apptextfield.text = step
- }
- onExposureTimeChanged: {
- fExposureTime = frames.cam_ExposureTime
- }
- }
- Timer {
- id: photoTimer
- interval: 2000 // 设置点击频率限制的时间间隔(以毫秒为单位)
- running: false // 初始状态下定时器停止
- repeat: false // 设置为false,以便只执行一次
- onTriggered: {
- // 定时器触发后,设置按钮可用
- // camera.active = false
- // camera.stop()
- output.visible = false
- frames.camera_sw = false
- }
- }
- Timer {
- id: auto_timer
- interval: 1000 // 设置点击频率限制的时间间隔(以毫秒为单位)
- running: false // 初始状态下定时器停止
- repeat: false // 设置为false,以便只执行一次
- onTriggered: {
- // 定时器触发后,开始对焦
- frames.auto_clicked = true
- }
- }
- Connections{
- target: mqtt
- function onMessagePub(message) {
- if(app.showPubData){
- var time = new Date().toLocaleTimeString()
- app.txDataLog = "[" + time + "] " + message + "\n" + app.txDataLog
- if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
- }
- }
- function onMessageSub(message) {
- if(app.showSubData){
- var time = new Date().toLocaleTimeString()
- app.rxDataLog = "[" + time + "] " + message + "\n" + app.rxDataLog
- if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
- }
- }
- function onSignal_set_camera_exposure(exposureTime) {
- console.log("收到远程相机曝光设置指令,曝光时间:" + exposureTime)
- frames.cam_ExposureTime = exposureTime.toString()
- }
- // 远程校准指令: {"cmd":"slide","ext":{"calibrate":"y","speed":"50"}} → 打开相机
- function onSignal_open_camera() {
- console.log("收到远程相机开启指令,打开相机!")
- frames.camera_sw = true
- }
- }
- // 图片上传进度 → 画面上的单张上传水印
- Connections {
- target: curl_picture
- function onProgressChanged(uploadedPercent, filePath){
- // 一次只有一张图在传,直接更新整体进度即可,无需按序号分发
- uploading = true
- uploadWatermarkVisible = true
- uploadPercent = Math.max(0, Math.min(100, uploadedPercent))
- uploadFailed = false
- if(filePath && filePath !== uploadFileName){
- // 只取路径末段做显示,避免水印被长路径撑开
- uploadFileName = String(filePath).split(/[\\/]/).pop()
- }
- uploadHideTimer.stop()
- }
- function onFinished(success, filePath, error){
- uploading = false
- if(success){
- uploadPercent = 100
- uploadFailed = false
- console.log("上传完成:", filePath)
- }else{
- uploadFailed = true
- console.log("上传失败:", filePath, error)
- }
- // 进度条改为弹出式后不再遮挡画面,给它留一点停留时间:
- // 成功 1.5s 收起,失败 5s(也可点击弹层立即关闭)
- uploadHideTimer.interval = success ? 1500 : 5000
- uploadHideTimer.restart()
- }
- }
- // 保留:仅用于手动复位时的清理,正常流程由 onFinished 延时关闭展示
- Timer {
- id: uploadHideTimer
- interval: 1500
- running: false
- repeat: false
- onTriggered: uploadWatermarkVisible = false
- }
- // ===== 图片上传进度条(弹出式) =====
- // 需求:取消画面上叠加的上传进度圆/状态文字,改成居中弹出的进度条;
- // 上传中显示文件名与百分比,成功/失败保留一小段时间后自动收起(点击也可立即收起)。
- Popup {
- id: uploadPopup
- parent: Overlay.overlay
- modal: false
- focus: false
- closePolicy: Popup.NoAutoClose
- visible: page.uploadWatermarkVisible
- width: Math.min((parent ? parent.width : dp(600)) * 0.7, dp(520))
- height: dp(104)
- x: parent ? (parent.width - width) / 2 : 0
- y: parent ? parent.height * 0.10 : 0
- padding: dp(14)
- background: Rectangle {
- color: "#e6212121"
- radius: dp(8)
- border.width: 1
- border.color: page.uploadFailed ? "#ff8a80" : "#4f8cff"
- }
- // 点击立即收起(失败时现场可以先看清错误,再手动关掉)
- MouseArea {
- anchors.fill: parent
- onClicked: page.uploadWatermarkVisible = false
- }
- Column {
- id: uploadColumn
- width: parent.width
- spacing: dp(8)
- AppText {
- width: parent.width
- text: (page.uploading
- ? "图片上传中 "
- : (page.uploadFailed ? "图片上传失败 " : "图片上传完成 "))
- + page.uploadFileName
- color: page.uploadFailed ? "#ff8a80" : "#ffffff"
- font.pixelSize: sp(12)
- elide: Text.ElideMiddle
- }
- ProgressBar {
- width: parent.width
- from: 0
- to: 100
- value: page.uploadPercent
- }
- AppText {
- width: parent.width
- text: Math.round(page.uploadPercent) + " %"
- color: "#cfd8dc"
- font.pixelSize: sp(11)
- horizontalAlignment: Text.AlignRight
- }
- }
- }
- Connections{
- target: serial
- onTakephotodone:{
- console.log("立即拍照完成!")
- apptext_res.text = "立即拍照完成!"
- focus_switch.enabled = true
- focus_switch.checked = false
- }
- onAutotestdone: {
- console.log("自动对焦完成!")
- apptext_res.text = "自动对焦完成!"
- autotest_switch.enabled = true
- autotest_switch.checked = false
- }
- onTranslatedone: {
- console.log("胶带传送完成!")
- apptext_res.text = "胶带传送完成!"
- jiaodai_switch.enabled = true
- jiaodai_switch.checked = false
- }
- onDataReceived:function(data) {
- if(app.showRxData){
- var time = new Date().toLocaleTimeString()
- app.rxDataLog = "[" + time + "] " + data + "\n" + app.rxDataLog
- if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
- }
- // 同步坐标值到输入框
- try {
- var jsonData = JSON.parse(data)
- if(jsonData.ext && !textInput_x.focus && jsonData.ext.x_init_dis !== undefined) {
- textInput_x.text = jsonData.ext.x_init_dis.toString()
- }
- if(jsonData.ext && !textInput_y.focus && jsonData.ext.y_init_dis !== undefined) {
- textInput_y.text = jsonData.ext.y_init_dis.toString()
- }
- } catch(e) {
- console.log("解析坐标数据失败:", e)
- }
- }
- onNetMessage:function(data) {
- if(app.showTxData){
- var time = new Date().toLocaleTimeString()
- app.txDataLog = "[" + time + "] " + data + "\n" + app.txDataLog
- if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
- }
- }
- }
- SplitView{
- anchors.fill: parent
- orientation: Qt.Horizontal
- Rectangle {
- SplitView.preferredWidth: parent.width * 0.7
- height: parent.height
- color: app.cardColor
- radius: 5
- AppButton {
- id: normButton
- //anchors.horizontalCenter: parent.horizontalCenter
- anchors.centerIn: parent
- anchors.fill: parent
- //text: "打开相机"
- flat: true //边框是否可视
- onClicked: {
- console.log("相机状态:",frames.camera_sw)
- //if(camera.active){
- if(frames.camera_sw){
- text = "相机已关闭"
- output.visible = false
- frames.camera_sw = false
- //uvc_camera.visible = false
- }else{
- text = "打开相机"
- output.visible = true
- frames.camera_sw = true
- //uvc_camera.visible = true
- }
- }
- Timer {
- id: longPressTimer
- interval: 1000 // 长按时间1000ms
- running: false // 初始状态下定时器停止
- repeat: false // 设置为false,以便只执行一次
- onTriggered: {
- console.log("长按触发")
- }
- }
- onPressed: {
- console.log("按钮按下,开始计时")
- longPressTimer.start()
- }
- onReleased: {
- console.log("按钮释放,停止计时")
- longPressTimer.stop()
- }
- AppImage{
- id: image_picdis
- anchors.centerIn: parent
- source: "../../assets/photoico.svg"
- }
- }
- VideoOutput
- {
- id: output
- anchors.fill: parent
- visible: false
- fillMode: VideoOutput.PreserveAspectFit //根据视频的纵横比例等比例缩放
- //fillMode: VideoOutput.Stretch
- Component.onCompleted: {
- console.log("output onCompleted")
- }
- }
- // 画面左上角信息:帧率 / 清晰度 / 已录制帧数
- // 统一用 Column 纵向排列(显式宽度 + spacing):
- // 原来 fps 放在 Row 里(width: parent.width),Row 的宽度又来自子项,
- // 形成循环依赖,Row 的高度解算不稳定,导致清晰度、帧数与 fps 叠在一起。
- // Column 的宽度是显式绑定的,子项 width: parent.width 不再回退到自身,
- // 纵向位置也由 Column 统一分配,不会再挤成一团。
- Column {
- id: infoColumn
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.topMargin: dp(6)
- anchors.leftMargin: dp(8)
- width: parent.width - dp(44)
- spacing: dp(4)
- AppText {
- id: photoclarity_text
- width: parent.width
- text: frames.fpsString
- color: "red"
- elide: Text.ElideRight
- }
- AppText {
- id: photoclarity2_text
- width: parent.width
- text: frames.qulityString
- color: "green"
- elide: Text.ElideRight
- }
- // 已录制帧数:步进扫描时每步应只 +1,用来现场核对"移动 N 步是否只录了 N 帧"
- // (之前出现过移动 100 步写出 200 帧,原因是重复 movy 被重复落盘)
- AppText {
- id: recordFrames_text
- width: parent.width
- text: "已录制帧数: " + frames.recordedFrames + (frames.recording ? " (录制中)" : "")
- color: "#ffd54f"
- font.pixelSize: sp(13)
- elide: Text.ElideRight
- // 未开始录制时不占位(Column 会跳过不可见子项)
- visible: frames.recording || frames.recordedFrames > 0
- }
- }
- // ================= 清晰度折线图 =================
- // 什么时候画:C++ 每算出一个清晰度(Tenengrad)就往 frames.qualitySeries 追加一个点;
- // 步进对焦扫描时就是"每个位置一个点",连起来即标准对焦曲线,峰值位置=最清晰焦面。
- // 放左下角:左上角是帧率/清晰度/已录制帧数文字,右下角是抓图/录制按钮。
- // 宽度随 parent 收窄,窄屏上不会压到右下角按钮。
- // 曲线清空时机由 C++ 控制:新一次 startRecord、或步号回退(主板重新计数)时自动清零。
- Rectangle {
- id: qualityChartBox
- anchors.left: parent.left
- anchors.bottom: parent.bottom
- anchors.leftMargin: dp(8)
- anchors.bottomMargin: dp(8)
- width: Math.min(dp(260), parent.width - dp(140))
- height: dp(100)
- radius: dp(6)
- color: "#a6000000"
- border.color: "#4caf50"
- border.width: dp(1)
- // 只有真正算过清晰度才出现,纯预览时不遮挡画面
- visible: qualityCanvas.pointCount > 0
- Canvas {
- id: qualityCanvas
- anchors.fill: parent
- anchors.margins: dp(5)
- // 绑定 C++ 属性:qualitySeriesChanged 发出后重新取值 -> onSeriesChanged -> 重绘
- property var series: frames.qualitySeries
- property int pointCount: series ? series.length : 0
- // 已录制帧数:曲线点与该计数一一对应,帧数变化也要重绘(标题里要显示)
- property int frameCount: frames.recordedFrames
- onSeriesChanged: requestPaint()
- onFrameCountChanged: requestPaint()
- onPaint: {
- var ctx = getContext("2d")
- ctx.reset()
- var n = pointCount
- if (n <= 0) return
- var w = width, h = height
- var padL = 2, padR = 2, padT = 15, padB = 2
- var plotW = w - padL - padR
- var plotH = h - padT - padB
- if (plotW <= 1 || plotH <= 1) return
- // 纵向归一化:按本段数据的最小/最大值铺满高度;max==min 时撑开 1 防止除零
- var vmin = series[0], vmax = series[0], peakIdx = 0
- for (var i = 1; i < n; ++i) {
- var v = series[i]
- if (v < vmin) vmin = v
- if (v > vmax) { vmax = v; peakIdx = i }
- }
- if (vmax - vmin < 0.0001) vmax = vmin + 1
- // 水平网格(3 条):便于判断峰谷相对高低
- ctx.strokeStyle = "rgba(255,255,255,0.12)"
- ctx.lineWidth = 1
- for (var g = 0; g <= 3; ++g) {
- var gy = padT + plotH * g / 3
- ctx.beginPath()
- ctx.moveTo(padL, gy)
- ctx.lineTo(padL + plotW, gy)
- ctx.stroke()
- }
- var xAt = function(idx) {
- return n === 1 ? (padL + plotW / 2)
- : (padL + plotW * idx / (n - 1))
- }
- var yAt = function(val) {
- return padT + plotH * (1 - (val - vmin) / (vmax - vmin))
- }
- // 折线:点数远多于像素列时按列抽稀,趋势/峰值不变,重绘不卡
- var stride = Math.max(1, Math.floor(n / Math.max(1, plotW)))
- ctx.beginPath()
- ctx.moveTo(xAt(0), yAt(series[0]))
- for (var k = stride; k < n; k += stride)
- ctx.lineTo(xAt(k), yAt(series[k]))
- if (n > 1)
- ctx.lineTo(xAt(n - 1), yAt(series[n - 1]))
- ctx.strokeStyle = "#4caf50"
- ctx.lineWidth = 1.8
- ctx.lineJoin = "round"
- ctx.stroke()
- // 曲线下方面积填充:值越低越暗,视觉上更容易看出"峰在哪"
- ctx.lineTo(xAt(n - 1), padT + plotH)
- ctx.lineTo(xAt(0), padT + plotH)
- ctx.closePath()
- ctx.fillStyle = "rgba(76,175,80,0.18)"
- ctx.fill()
- // 峰值标记:红点 + 顶部一行文字(点数 / 峰值)
- ctx.beginPath()
- ctx.arc(xAt(peakIdx), yAt(vmax), 3, 0, Math.PI * 2)
- ctx.fillStyle = "#ff5252"
- ctx.fill()
- var fs = Math.max(9, Math.round(h * 0.12))
- ctx.font = fs + "px sans-serif"
- ctx.textBaseline = "top"
- ctx.fillStyle = "#a5d6a7"
- // 点数与已录制帧数并列显示,一眼看出"每个已录帧一个点"
- var framesTxt = frames.recordedFrames > 0
- ? (" / 帧 " + frames.recordedFrames) : ""
- ctx.fillText("清晰度 " + n + " 点" + framesTxt
- + " 峰值 " + Number(vmax).toFixed(2),
- padL + 1, 1)
- }
- }
- }
- // 抓图按钮:仅相机打开时显示,画面右下角透明背景,点击=模拟MCU拍照指令(按序号保存/锐化/上传)
- Rectangle {
- id: captureBtn
- visible: frames.camera_sw
- width: dp(56)
- height: dp(56)
- radius: width / 2
- color: "transparent"
- border.color: "#80ffffff"
- border.width: dp(2)
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.rightMargin: dp(12)
- anchors.bottomMargin: dp(12)
- AppImage {
- anchors.centerIn: parent
- width: dp(34)
- height: dp(34)
- source: "../../assets/photoico.svg"
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- console.log("抓图按钮点击!")
- frames.manualCapture()
- }
- }
- }
- // 录制按钮:仅相机打开时显示,画面右下角(抓图按钮左侧)
- // 点击开始录制原始(未压缩)视频流,再次点击停止并把视频流保存到相机打开时创建的文件夹
- Rectangle {
- id: recordBtn
- visible: frames.camera_sw
- width: dp(56)
- height: dp(56)
- radius: width / 2
- color: "transparent"
- border.color: frames.recording ? "#e74c3c" : "#80ffffff"
- border.width: dp(2)
- anchors.right: captureBtn.left
- anchors.bottom: parent.bottom
- anchors.rightMargin: dp(12)
- anchors.bottomMargin: dp(12)
- // 未录制:红色圆点(开始);录制中:红色方块(停止)
- Rectangle {
- anchors.centerIn: parent
- width: frames.recording ? dp(22) : dp(26)
- height: frames.recording ? dp(22) : dp(26)
- radius: frames.recording ? dp(3) : width / 2
- color: "#e74c3c"
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if(frames.recording){
- console.log("停止录制视频流")
- frames.stopRecord()
- }else{
- console.log("开始录制视频流")
- if(frames.startRecord()){
- apptext_res.text = "开始录制视频流"
- }else{
- nativeUtils.displayMessageBox("提示","录制失败,请先打开相机!",1)
- }
- }
- }
- }
- }
- // 分析/融合处理期间:挂起相机画面输出,用进度/过程替代画面
- Rectangle {
- id: processOverlay
- visible: frames.processing
- anchors.fill: parent
- color: "#E6000000"
- z: 20
- Column {
- anchors.centerIn: parent
- spacing: dp(12)
- BusyIndicator {
- anchors.horizontalCenter: parent.horizontalCenter
- running: frames.processing
- width: dp(56)
- height: dp(56)
- }
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: frames.processMessage
- color: "white"
- fontSize: 16
- }
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "处理中 " + frames.processPercent + "%"
- color: "#28a779"
- fontSize: 15
- }
- // 进度条
- Rectangle {
- width: dp(280)
- height: dp(8)
- radius: dp(4)
- color: "#33ffffff"
- anchors.horizontalCenter: parent.horizontalCenter
- Rectangle {
- width: parent.width * frames.processPercent / 100
- height: parent.height
- radius: parent.radius
- color: "#28a779"
- }
- }
- }
- }
- }
- ScrollView
- {
- SplitView.preferredWidth: parent.width*0.29
- SplitView.minimumWidth: 200
- clip: true
- Column {
- spacing: dp(15)
- Row {
- spacing: 80
- AppText {
- id: text_title
- text: "测试调试"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- }
- AppText {
- id: apptext_res
- text: "[测试结果]"
- fontSize:15
- color: "grey"
- anchors.verticalCenter: text_title.verticalCenter
- }
- }
- Row {
- spacing: dp(120)
- AppText{
- text: "一键测试"
- fontSize: 15
- color: app.fontColor
- anchors.verticalCenter: autotest_switch.verticalCenter
- }
- AppSwitch {
- id: autotest_switch
- onToggled: {
- if(autotest_switch.checked==true){
- autotest_switch.enabled = false
- serial.sendCmd("autotest",true,"","");
- t_autotest.start()
- }else{
- console.log("t_autotest 计数:",t_autotest.interval)
- }
- }
- }
- Timer {
- id: t_autotest
- interval: 1000*60
- running: false
- repeat: false
- onTriggered: {
- autotest_switch.enabled = true
- autotest_switch.checked = false
- }
- }
- }
- Row {
- spacing: dp(120)
- AppText{
- text: "风机测试"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: fantest_switch.verticalCenter
- }
- AppSwitch {
- id: fantest_switch
- onToggled: {
- if(fantest_switch.checked==true){
- serial.sendCmd("fan",true,"","");
- apptext_res.text = "打开风机"
- }else{
- serial.sendCmd("fan",false,"","");
- apptext_res.text = "关闭风机"
- }
- }
- }
- }
- Row {
- spacing: dp(120)
- AppText{
- text: "胶带测试"
- fontSize: 15
- color: app.fontColor
- //font.bold: true
- anchors.verticalCenter: jiaodai_switch.verticalCenter
- }
- AppSwitch {
- id: jiaodai_switch
- onToggled: {
- if(jiaodai_switch.checked==true){
- // 检查是否处于温度保护状态
- if(app.tempProtectionState === true){
- // 弹出提示对话框
- nativeUtils.displayMessageBox(
- "提示",
- "当前处于温控状态,请解除温控后再进行测试胶带传送",
- 1
- );
- // 恢复开关状态为未选中
- jiaodai_switch.checked = false;
- return;
- }
- // 正常执行胶带测试
- //jiaodai_switch.enabled = false
- apptext_res.text = "胶带测试开始"
- serial.sendCmd("jiaodai",true,"","");
- }
- }
- }
- }
- Row {
- spacing: dp(120)
- AppText {
- text: "补光测试"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: led_switch.verticalCenter
- }
- AppSwitch {
- id: led_switch
- onToggled: {
- if(led_switch.checked==true){
- serial.sendCmd("led",true,"","");
- apptext_res.text = "补光灯已打开"
- }else{
- serial.sendCmd("led",false,"","");
- apptext_res.text = "补光灯已关闭"
- }
- }
- }
- }
- Row {
- spacing: dp(120)
- AppText {
- text: "立即拍照"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: takephoto_switch.verticalCenter
- }
- AppSwitch {
- id: takephoto_switch
- onToggled: {
- if(takephoto_switch.checked==true){
- apptext_res.text = "立即拍照"
- frames.captureImage()
- }
- }
- }
- }
- Row {
- spacing: dp(120)
- AppText {
- text: "对焦拍照"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: focus_switch.verticalCenter
- }
- AppSwitch {
- id: focus_switch
- onToggled: {
- if(focus_switch.checked==true){
- apptext_res.text = "开始对焦"
- focus_switch.enabled = false
- serial.auto_takephoto(true)
- }
- }
- }
- }
- //【已移除】滤网更换(selfclean 自清洁测试)按钮: 该机型不再使用滤网
- // 分割线
- Rectangle {
- visible: !motorUnlocked
- width: parent.width
- height: dp(1)
- color: "#e0e0e0"
- }
- // 分割线
- Rectangle {
- width: parent.width
- height: dp(2)
- color: "#28a779"
- }
- // 密码输入区域(未解锁时显示)
- Rectangle {
- visible: !motorUnlocked
- width: parent.width
- height: passwordColumn.height + dp(16)
- color: app.cardColor
- radius: dp(8)
- border.color: "#28a779"
- border.width: dp(1)
- Column {
- id: passwordColumn
- anchors.centerIn: parent
- spacing: dp(10)
- AppText {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "请输入密码解锁电机控制"
- color: app.fontColor
- font.bold: true
- fontSize: 14
- }
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: dp(8)
- AppTextField {
- id: motorPasswordInput
- width: dp(130)
- height: dp(38)
- echoMode: TextInput.Password
- placeholderText: "密码"
- inputMethodHints: Qt.ImhDigitsOnly
- anchors.verticalCenter: parent.verticalCenter
- onAccepted: {
- if(text === "666888"){
- motorUnlocked = true
- text = ""
- }else{
- apptext_res.text = "密码错误"
- text = ""
- }
- }
- }
- AppButton {
- text: "确认"
- textColor: "white"
- flat: false
- backgroundColor: "#28a779"
- minimumHeight: dp(38)
- minimumWidth: dp(55)
- anchors.verticalCenter: parent.verticalCenter
- onClicked: {
- if(motorPasswordInput.text === "666888"){
- motorUnlocked = true
- motorPasswordInput.text = ""
- }else{
- apptext_res.text = "密码错误"
- motorPasswordInput.text = ""
- }
- }
- }
- }
- }
- }
- // 电机控制及以下所有控件(解锁后显示)
- Item {
- id: motorSection
- visible: motorUnlocked
- width: parent.width
- height: motorContent.height + dp(20)
- property alias content: motorContent
- Column {
- id: motorContent
- spacing: dp(12)
- width: parent.width
- // 锁定按钮
- Row {
- spacing: dp(5)
- width: parent.width
- AppText {
- text: "高级控制"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- anchors.verticalCenter: parent.verticalCenter
- }
- AppButton {
- text: "锁定"
- textColor: "white"
- flat: false
- backgroundColor: "#d9534f"
- minimumHeight: dp(25)
- minimumWidth: dp(50)
- anchors.verticalCenter: parent.verticalCenter
- onClicked: motorUnlocked = false
- }
- }
- AppText {
- id: text_title2
- text: "三轴步进电机控制"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- }
- // ===== 图像处理开关(与电机控制一起锁在密码后面)=====
- // 1) 景深融合:关掉后录制结束只保留最清晰帧,不做融合
- // 状态唯一来源是 frames.fusionEnabled(= param::fusion_enable,
- // MQTT fusion_sw 也会改它,所以用 Connections 双向同步,不做单向绑定)
- Row {
- spacing: dp(12)
- width: parent.width
- AppText {
- text: "景深融合"
- width: dp(140)
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: fusion_switch.verticalCenter
- }
- AppSwitch {
- id: fusion_switch
- // 不用 checked: frames.fusionEnabled 绑定:用户点开关时控件内部会
- // 直接给 checked 赋值、绑定被打断,之后 MQTT 改状态就同步不过来了。
- // 这里改成显式赋值 + Connections 回灌,始终以 frames 的值为准。
- Component.onCompleted: checked = frames.fusionEnabled
- onToggled: {
- frames.fusionEnabled = checked
- console.log("景深融合:", checked ? "开" : "关")
- }
- }
- AppText {
- text: frames.fusionEnabled ? "开" : "关"
- color: frames.fusionEnabled ? "#28a779" : "#d9534f"
- anchors.verticalCenter: fusion_switch.verticalCenter
- }
- }
- // 2) 临时调试:保留录制文件(rawv),便于复盘;不写库,重启复位
- Row {
- spacing: dp(12)
- width: parent.width
- AppText {
- text: "保留录像(调试)"
- width: dp(140)
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: keep_record_switch.verticalCenter
- }
- AppSwitch {
- id: keep_record_switch
- Component.onCompleted: checked = frames.debugKeepRecord
- onToggled: {
- frames.debugKeepRecord = checked
- console.log("调试保留录像:", checked ? "开" : "关")
- }
- }
- AppText {
- text: frames.debugKeepRecord ? "开" : "关"
- color: frames.debugKeepRecord ? "#ffd54f" : "#9e9e9e"
- anchors.verticalCenter: keep_record_switch.verticalCenter
- }
- }
- // 融合开关状态回灌:MQTT fusion_sw、启动读库、按钮点击都会走这里,
- // 保证界面开关显示与 param::fusion_enable 始终一致
- Connections {
- target: frames
- function onFusionEnabledChanged() {
- if(fusion_switch.checked !== frames.fusionEnabled)
- fusion_switch.checked = frames.fusionEnabled
- }
- function onDebugKeepRecordChanged() {
- if(keep_record_switch.checked !== frames.debugKeepRecord)
- keep_record_switch.checked = frames.debugKeepRecord
- }
- }
- // 轴选择
- Row {
- spacing: dp(8)
- width: parent.width
- AppText {
- text: "选择轴:"
- width: dp(60)
- color: app.fontColor
- anchors.verticalCenter: parent.verticalCenter
- }
- ComboBox {
- width: parent.width - dp(100)
- height: dp(40)
- model: ["X轴", "Y轴", "Z轴"]
- onCurrentIndexChanged: currentAxis = currentIndex
- }
- AppButton {
- text: "校准"
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "white"
- minimumHeight: dp(30)
- minimumWidth: dp(50)
- onClicked:
- {
- autotake(false)
- if(currentAxis==0)
- {
- console.log("校准X")
- serial.sendCmd("calibrate",false,"x",speed.toString())
- }else if(currentAxis==1)
- {
- console.log("校准Y")
- serial.sendCmd("calibrate",false,"y",speed.toString())
- }else if(currentAxis==2)
- {
- console.log("校准Z")
- serial.sendCmd("calibrate",false,"z",speed.toString())
- }
- }
- }
- }
- // 速度调节
- Row {
- spacing: dp(10)
- width: parent.width
- AppText {
- text: "速度:"
- width: dp(40)
- color: app.fontColor
- anchors.verticalCenter: parent.verticalCenter
- }
- AppSlider {
- width: parent.width - dp(60)
- from: 0
- to: 100
- value: speed
- stepSize: 1
- onValueChanged: speed = value
- anchors.verticalCenter: parent.verticalCenter
- }
- AppText {
- text: speed
- width: dp(40)
- anchors.verticalCenter: parent.verticalCenter
- }
- }
- // 步进距离设置
- Row {
- spacing: dp(10)
- width: parent.width
- AppText {
- text: "步进脉冲次数:"
- width: dp(120)
- color: app.fontColor
- anchors.verticalCenter: parent.verticalCenter
- }
- AppTextField {
- id: step_apptextfield
- width: parent.width - dp(120)
- text: stepDistance
- validator: IntValidator { bottom: 0; top: 2000 }
- onTextChanged: stepDistance = parseInt(text)
- }
- }
- // 运动控制按钮
- Row {
- spacing: dp(10)
- width: parent.width
- AppButton {
- text: " 正转 "
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "grey"
- minimumHeight: dp(30)
- minimumWidth: dp(50)
- width: (parent.width - dp(30))/4
- onClicked:
- {
- if(currentAxis==0)
- {
- console.log("X轴正转:",stepDistance)
- serial.sendCmd("movx",false,"f"+stepDistance,speed.toString())
- }else if(currentAxis==1)
- {
- console.log("Y轴正转:",stepDistance)
- serial.sendCmd("movy",false,"f"+stepDistance,speed.toString())
- }else if(currentAxis==2)
- {
- console.log("Z轴正转:",stepDistance)
- serial.sendCmd("movz",false,"f"+stepDistance,speed.toString())
- }
- }
- }
- AppButton {
- text: " 停止 "
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "red"
- minimumHeight: dp(30)
- minimumWidth: dp(50)
- width: (parent.width - dp(30))/4
- onClicked:
- {
- console.log("停止")
- serial.sendCmd("movx",false,"f0","")
- }
- }
- AppButton {
- text: " 反转 "
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "grey"
- minimumHeight: dp(30)
- minimumWidth: dp(50)
- width: (parent.width - dp(30))/4
- onClicked:
- {
- if(currentAxis==0)
- {
- console.log("X轴反转:",stepDistance)
- serial.sendCmd("movx",false,"b"+stepDistance,speed.toString())
- }else if(currentAxis==1)
- {
- console.log("Y轴反转:",stepDistance)
- serial.sendCmd("movy",false,"b"+stepDistance,speed.toString())
- }else if(currentAxis==2)
- {
- console.log("Z轴反转:",stepDistance)
- serial.sendCmd("movz",false,"b"+stepDistance,speed.toString())
- }
- }
- }
- AppButton {
- text: " 复位 "
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "grey"
- minimumHeight: dp(30)
- minimumWidth: dp(50)
- width: (parent.width - dp(30))/4
- onClicked: {
- if(currentAxis==0)
- {
- console.log("X轴复位!")
- serial.sendCmd("movx",true,"",speed.toString())
- }else if(currentAxis==1)
- {
- console.log("Y轴复位!")
- serial.sendCmd("movy",true,"",speed.toString())
- }else if(currentAxis==2)
- {
- console.log("Z轴复位!")
- serial.sendCmd("movz",true,"",speed.toString())
- }
- }
- }
- }
- // ===== 坐标参数 =====
- AppText {
- text: "坐标参数"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- }
- // X 坐标输入行
- Row {
- spacing: dp(5)
- width: parent.width
- AppText {
- text: "X坐标:"
- width: dp(50)
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: textInput_x.verticalCenter
- }
- AppTextField {
- id: textInput_x
- width: parent.width - dp(80)
- height: dp(40)
- placeholderText: "0"
- text: "0"
- font.family: "Arial"
- font.pixelSize: 15
- validator: DoubleValidator { decimals: 2 }
- EnterKey.type: Qt.EnterKeyDone
- inputMethodHints: Qt.ImhFormattedNumbersOnly
- property real numericValue_x: Number(text) || 0
- Keys.onReturnPressed: {
- serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
- Qt.inputMethod.hide()
- }
- onAccepted: {
- serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
- }
- }
- }
- // Y 坐标输入行
- Row {
- spacing: dp(5)
- width: parent.width
- AppText {
- text: "Y坐标:"
- width: dp(50)
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: textInput_y.verticalCenter
- }
- AppTextField {
- id: textInput_y
- width: parent.width - dp(80)
- height: dp(40)
- placeholderText: "0"
- text: "0"
- font.family: "Arial"
- font.pixelSize: 15
- validator: DoubleValidator { decimals: 2 }
- EnterKey.type: Qt.EnterKeyDone
- inputMethodHints: Qt.ImhFormattedNumbersOnly
- property real numericValue_y: Number(text) || 0
- Keys.onReturnPressed: {
- serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
- Qt.inputMethod.hide()
- }
- onAccepted: {
- serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
- }
- }
- }
- // 分割线
- Rectangle {
- width: parent.width
- height: dp(2)
- color: "#e0e0e0"
- }
- // ===== 相机参数 =====
- AppText {
- id: text_camera
- text: "相机参数"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- }
- Row {
- spacing: dp(10)
- width: parent.width
- AppText {
- id: txt_fExposureTime
- text: "曝光值:"
- color: app.fontColor
- }
- AppTextField {
- anchors.verticalCenter: txt_fExposureTime.verticalCenter
- placeholderText: fExposureTime
- text: fExposureTime
- width: parent.width - dp(10)
- EnterKey.type: Qt.EnterKeyDone
- wrapMode: Text.NoWrap
- inputMethodHints: Qt.ImhFormattedNumbersOnly |
- Qt.ImhPreferDone |
- Qt.ImhNoPredictiveText
- validator: DoubleValidator {
- bottom: 100.00
- top: 500000.00
- decimals: 0
- }
- // 关键:兜底(IME 再作妖也不怕)
- Keys.onReturnPressed: {
- frames.cam_ExposureTime = text
- console.log("设置曝光时间:",text)
- Qt.inputMethod.hide()
- }
- onAccepted: {
- frames.cam_ExposureTime = text
- console.log("设置曝光时间",text)
- }
- }
- }
- // 相机型号(海康工业相机,打开相机后自动读取展示)
- Row {
- spacing: dp(10)
- width: parent.width
- AppText {
- id: txt_camModel
- text: "相机型号:"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- AppText {
- text: frames.cam_ModelName
- color: "#28a779"
- font.bold: true
- fontSize: 15
- elide: Text.ElideRight
- width: parent.width - txt_camModel.width - dp(10)
- anchors.verticalCenter: parent.verticalCenter
- }
- }
- // 亮度(自动曝光目标灰度0-255,设置后切换为自动曝光,手动曝光值失效)
- Row {
- spacing: dp(10)
- width: parent.width
- AppText {
- id: txt_fBrightness
- text: "亮度:"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- AppTextField {
- anchors.verticalCenter: txt_fBrightness.verticalCenter
- placeholderText: frames.cam_Brightness
- text: frames.cam_Brightness
- width: parent.width - dp(10)
- EnterKey.type: Qt.EnterKeyDone
- wrapMode: Text.NoWrap
- inputMethodHints: Qt.ImhDigitsOnly |
- Qt.ImhPreferDone |
- Qt.ImhNoPredictiveText
- validator: IntValidator {
- bottom: 0
- top: 255
- }
- Keys.onReturnPressed: {
- frames.cam_Brightness = text
- console.log("设置亮度:", text)
- Qt.inputMethod.hide()
- }
- onAccepted: {
- frames.cam_Brightness = text
- console.log("设置亮度:", text)
- }
- }
- }
- // 白平衡自动模式(关闭后可手动调下方红/蓝比例)
- Row {
- spacing: dp(10)
- width: parent.width
- AppText {
- text: "白平衡:"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: wbModeBox.verticalCenter
- }
- ComboBox {
- id: wbModeBox
- width: parent.width - dp(80)
- height: dp(40)
- model: ["关闭", "自动一次", "连续自动"]
- currentIndex: frames.cam_WhiteBalanceMode
- onActivated: {
- frames.cam_WhiteBalanceMode = currentIndex
- apptext_res.text = "白平衡模式:" + model[currentIndex]
- console.log("设置白平衡模式:", model[currentIndex])
- //用户选择会打断currentIndex的属性绑定,重新建立以保持相机参数回显同步
- wbModeBox.currentIndex = Qt.binding(function(){ return frames.cam_WhiteBalanceMode })
- }
- }
- }
- // 白平衡红/蓝比例(手动模式下生效,写入时自动切为关闭模式)
- Row {
- spacing: dp(8)
- width: parent.width
- AppText {
- text: "红/蓝比例:"
- color: app.fontColor
- fontSize: 13
- anchors.verticalCenter: parent.verticalCenter
- }
- AppTextField {
- id: wbRatioRField
- width: (parent.width - dp(80)) / 2
- placeholderText: "红 " + frames.cam_BalanceRatioR
- text: frames.cam_BalanceRatioR
- EnterKey.type: Qt.EnterKeyDone
- wrapMode: Text.NoWrap
- inputMethodHints: Qt.ImhDigitsOnly |
- Qt.ImhPreferDone |
- Qt.ImhNoPredictiveText
- validator: IntValidator {
- bottom: 0
- top: 16383
- }
- Keys.onReturnPressed: {
- frames.cam_BalanceRatioR = text
- console.log("设置白平衡红比例:", text)
- Qt.inputMethod.hide()
- }
- onAccepted: {
- frames.cam_BalanceRatioR = text
- console.log("设置白平衡红比例:", text)
- }
- }
- AppTextField {
- id: wbRatioBField
- width: (parent.width - dp(80)) / 2
- placeholderText: "蓝 " + frames.cam_BalanceRatioB
- text: frames.cam_BalanceRatioB
- EnterKey.type: Qt.EnterKeyDone
- wrapMode: Text.NoWrap
- inputMethodHints: Qt.ImhDigitsOnly |
- Qt.ImhPreferDone |
- Qt.ImhNoPredictiveText
- validator: IntValidator {
- bottom: 0
- top: 16383
- }
- Keys.onReturnPressed: {
- frames.cam_BalanceRatioB = text
- console.log("设置白平衡蓝比例:", text)
- Qt.inputMethod.hide()
- }
- onAccepted: {
- frames.cam_BalanceRatioB = text
- console.log("设置白平衡蓝比例:", text)
- }
- }
- }
- AppText {
- id: text_debug
- text: "通信调试"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- }
- Row {
- spacing: dp(12)
- AppText {
- text: "显示Serial发送数据"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: txSwitch.verticalCenter
- }
- AppSwitch {
- id: txSwitch
- onToggled: {
- app.floatPanel = checked
- app.showTxData = checked
- app.floatPanel_title = "Serial发送数据"
- }
- }
- }
- Row {
- spacing: dp(12)
- AppText {
- text: "显示Serial接收数据"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: rxSwitch.verticalCenter
- }
- AppSwitch {
- id: rxSwitch
- onToggled: {
- app.floatPanel = checked
- app.showRxData = checked
- app.floatPanel_title = "Serial接收数据"
- }
- }
- }
- Row {
- spacing: dp(12)
- AppText {
- text: "显示MQTT发送数据"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: pubSwitch.verticalCenter
- }
- AppSwitch {
- id: pubSwitch
- onToggled: {
- app.floatPanel = checked
- app.showPubData = checked
- app.showSubData = false
- app.floatPanel_title = "MQTT发送数据"
- }
- }
- }
- Row {
- spacing: dp(12)
- AppText {
- text: "显示MQTT接收数据"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: subSwitch.verticalCenter
- }
- AppSwitch {
- id: subSwitch
- onToggled: {
- app.floatPanel = checked
- app.showSubData = checked
- app.showPubData = false
- app.floatPanel_title = "MQTT接收数据"
- }
- }
- }
- // ===== 运维App(com.rd.client) 运行状态 / 下载安装 =====
- // 后台每 10 分钟巡检 FTP 取最高版本自动下载安装,
- // 这里只做展示 + 手动触发,流程全部在 oaApp(C++) 里完成。
- AppText {
- id: text_oa_app
- text: "运维App"
- font.bold: true
- color: "#28a779"
- fontSize: 20
- }
- // 竖向排列:屏幕宽度不够时横向排列会被截断
- Column {
- spacing: dp(6)
- width: parent.width
- Row {
- spacing: dp(6)
- AppText {
- text: "运行状态:"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- AppText {
- id: oa_state_text
- text: oaApp.stateText
- color: oaApp.running ? "#28a779" : "#d9534f"
- font.bold: true
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- }
- Row {
- spacing: dp(6)
- AppText {
- text: "已装版本:"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- AppText {
- text: oaApp.installedVersion.length > 0 ? oaApp.installedVersion : "--"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- }
- Row {
- spacing: dp(6)
- AppText {
- text: "FTP最高版本:"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- AppText {
- text: oaApp.remoteVersion.length > 0 ? oaApp.remoteVersion : "--"
- color: app.fontColor
- fontSize: 15
- anchors.verticalCenter: parent.verticalCenter
- }
- }
- }
- // 下载进度:仅在下载中显示
- Rectangle {
- visible: oaApp.downloading
- width: parent.width
- height: dp(10)
- radius: dp(5)
- color: "#33000000"
- Rectangle {
- width: parent.width * oaApp.progress / 100
- height: parent.height
- radius: parent.radius
- color: "#28a779"
- }
- }
- // 按钮同样竖排,避免三个按钮挤在一行被截断
- Column {
- spacing: dp(8)
- // 下载/更新:立即巡检 FTP,有更高版本则下载并自动安装
- AppButton {
- id: oa_download_btn
- text: oaApp.downloading ? "下载中 " + oaApp.progress + "%"
- : (oaApp.installed ? "下载并更新" : "下载安装")
- textColor: "white"
- flat: false
- backgroundColor: oaApp.downloading ? "grey" : "#28a779"
- minimumHeight: dp(38)
- minimumWidth: dp(140)
- enabled: !oaApp.downloading
- onClicked: {
- oaApp.checkNow()
- }
- }
- // 立即启动:不检查版本,直接把运维App拉起来
- AppButton {
- text: "立即启动"
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "white"
- minimumHeight: dp(38)
- minimumWidth: dp(140)
- onClicked: {
- oaApp.startApp()
- }
- }
- // 刷新状态:立即查询已装版本/是否运行
- AppButton {
- text: "刷新状态"
- textColor: "black"
- flat: false
- borderColor: "black"
- borderWidth: dp(1)
- backgroundColor: "white"
- minimumHeight: dp(38)
- minimumWidth: dp(140)
- onClicked: {
- oaApp.refreshStatus()
- }
- }
- }
- AppText {
- id: oa_msg_text
- // 无结果提示时显示"等待巡检 下次 mm:ss",剩余时间每秒刷新
- text: (oaApp.message.length > 0 ? oaApp.message : "等待巡检")
- + (oaApp.nextCheckText.length > 0 ? " 下次巡检 " + oaApp.nextCheckText : "")
- + (oaApp.lastCheckTime.length > 0 ? " (" + oaApp.lastCheckTime + ")" : "")
- color: app.fontColor
- fontSize: 13
- }
- } // motorContent
- } // motorSection
- }
- }
- }
- }
|