TestPage.qml 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585
  1. import QtQuick
  2. import Felgo
  3. import QtMultimedia
  4. import QtQuick.Controls
  5. import Qt.labs.settings 1.0 as QtLabs
  6. import QtQuick.Controls.Material 2.0
  7. import QtLocation 5.5
  8. import QtPositioning 5.5
  9. import Qt5Compat.GraphicalEffects
  10. import "../controls"
  11. import "../common"
  12. import Frames 0.1
  13. AppPage {
  14. //【必须有 id】上传进度弹层里用了 page.uploadPercent / page.uploadFailed 等绑定,
  15. //根元素原来没有 id,page 是未定义标识符 -> 绑定报 ReferenceError,
  16. //Popup 的 visible 永远算不出来,表现为"上传进度不显示"。
  17. id: page
  18. objectName: "autoFocus_Page"
  19. navigationBarHidden: true
  20. backgroundColor: app.theme_backgroundColor
  21. property var videoFormats
  22. // 定义电机状态
  23. property int currentAxis: 0 // 当前选择的轴 (0: X, 1: Y, 2: Z)
  24. property var axisPositions: [0, 0, 0] // 各轴当前位置
  25. property int speed: 50 // 当前速度 (0-100)
  26. property int stepDistance: 20 // 步进脉冲数量
  27. property string fExposureTime: "0"
  28. property bool motorUnlocked: false
  29. // ===== 上传进度水印(单张) =====
  30. // 业务上一次只上传一张图片(串行队列 FIFO,见 CurlFtpUploader::runLoop),
  31. // 所以不需要按序号铺 32 格进度网格,直接在画面上叠加一个整体进度水印即可。
  32. // uploading : 是否处于上传中(含进度回调已到达但 finished 尚未回来的窗口)
  33. // percent : 0~100,来自 CurlFtpUploader::progressChanged
  34. // fileName : 当前上传文件名(取末段),仅用于水印上显示是哪一张
  35. // failed : 本次上传是否失败(决定水印配色与文案)
  36. property bool uploading: false
  37. property double uploadPercent: 0
  38. property string uploadFileName: ""
  39. property bool uploadFailed: false
  40. // 进度圆可见性:仅在触发上传时为 true,收到 finished 后立即置 false 关闭展示
  41. property bool uploadWatermarkVisible: false
  42. function resetUploadWatermark() {
  43. uploading = false
  44. uploadPercent = 0
  45. uploadFileName = ""
  46. uploadFailed = false
  47. uploadWatermarkVisible = false
  48. uploadHideTimer.stop()
  49. }
  50. function autotake(sw){
  51. if(sw)
  52. {
  53. console.log("autotakestart")
  54. frames.camera_sw = true
  55. //frames.auto_clicked = true //开始对焦
  56. auto_timer.start() //启动对焦定时器
  57. console.log("相机已打开")
  58. photoTimer.interval=180*1000
  59. photoTimer.start()
  60. }else{
  61. frames.camera_sw = true
  62. console.log("打开相机单次拍照!")
  63. }
  64. }
  65. Frames {
  66. objectName: "Frames"
  67. id: frames
  68. videoSink: output.videoSink
  69. onCameraOpenFailed:function(err){
  70. console.log("onCameraOpenFailed",err)
  71. nativeUtils.displayMessageBox("相机打开失败!",err,1)
  72. focus_switch.checked = false
  73. focus_switch.enabled = true
  74. takephoto_switch.checked = false
  75. takephoto_switch.enabled = true
  76. }
  77. onVideoSinkChanged: {
  78. console.log("onVideoSinkChanged")
  79. photoTimer.start() //两秒后关闭相机,因为相机加载的慢,否则关不住
  80. }
  81. onQulityStringChanged: {
  82. loginpage.logintimeout = 600; //拍照刷新熄屏计时
  83. photoTimer.interval = 180*1000 //3分钟超时
  84. photoTimer.restart()
  85. }
  86. onRecordFileSaved: function(path){
  87. console.log("录制视频流已保存:", path)
  88. apptext_res.text = "录制已保存:" + path.split("/").pop()
  89. }
  90. onCameraStaChanged: function(sta_cam) {
  91. if(sta_cam){
  92. //camera.active = sta_cam
  93. //camera.start()
  94. //每次(重新)打开相机后清空上传进度水印(上一次采集的进度/结果不再保留)
  95. resetUploadWatermark()
  96. loginpage.logintimeout = 600; //拍照刷新熄屏计时
  97. output.visible = sta_cam
  98. photoTimer.interval = 180*1000 //3分钟超时
  99. photoTimer.start()
  100. //uvc_camera.visible = false
  101. }else{
  102. //camera.active = sta_cam
  103. //camera.stop()
  104. output.visible= sta_cam
  105. photoTimer.stop() //停止计时器
  106. focus_switch.checked = false
  107. focus_switch.enabled = true
  108. takephoto_switch.checked = false
  109. takephoto_switch.enabled = true
  110. //uvc_camera.visible = true
  111. }
  112. console.log("相机状态改变",sta_cam)
  113. }
  114. onStepCountChanged: function(step){
  115. console.log("坐标改变",step)
  116. step_apptextfield.text = step
  117. }
  118. onExposureTimeChanged: {
  119. fExposureTime = frames.cam_ExposureTime
  120. }
  121. }
  122. Timer {
  123. id: photoTimer
  124. interval: 2000 // 设置点击频率限制的时间间隔(以毫秒为单位)
  125. running: false // 初始状态下定时器停止
  126. repeat: false // 设置为false,以便只执行一次
  127. onTriggered: {
  128. // 定时器触发后,设置按钮可用
  129. // camera.active = false
  130. // camera.stop()
  131. output.visible = false
  132. frames.camera_sw = false
  133. }
  134. }
  135. Timer {
  136. id: auto_timer
  137. interval: 1000 // 设置点击频率限制的时间间隔(以毫秒为单位)
  138. running: false // 初始状态下定时器停止
  139. repeat: false // 设置为false,以便只执行一次
  140. onTriggered: {
  141. // 定时器触发后,开始对焦
  142. frames.auto_clicked = true
  143. }
  144. }
  145. Connections{
  146. target: mqtt
  147. function onMessagePub(message) {
  148. if(app.showPubData){
  149. var time = new Date().toLocaleTimeString()
  150. app.txDataLog = "[" + time + "] " + message + "\n" + app.txDataLog
  151. if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
  152. }
  153. }
  154. function onMessageSub(message) {
  155. if(app.showSubData){
  156. var time = new Date().toLocaleTimeString()
  157. app.rxDataLog = "[" + time + "] " + message + "\n" + app.rxDataLog
  158. if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
  159. }
  160. }
  161. function onSignal_set_camera_exposure(exposureTime) {
  162. console.log("收到远程相机曝光设置指令,曝光时间:" + exposureTime)
  163. frames.cam_ExposureTime = exposureTime.toString()
  164. }
  165. // 远程校准指令: {"cmd":"slide","ext":{"calibrate":"y","speed":"50"}} → 打开相机
  166. function onSignal_open_camera() {
  167. console.log("收到远程相机开启指令,打开相机!")
  168. frames.camera_sw = true
  169. }
  170. }
  171. // 图片上传进度 → 画面上的单张上传水印
  172. Connections {
  173. target: curl_picture
  174. function onProgressChanged(uploadedPercent, filePath){
  175. // 一次只有一张图在传,直接更新整体进度即可,无需按序号分发
  176. uploading = true
  177. uploadWatermarkVisible = true
  178. uploadPercent = Math.max(0, Math.min(100, uploadedPercent))
  179. uploadFailed = false
  180. if(filePath && filePath !== uploadFileName){
  181. // 只取路径末段做显示,避免水印被长路径撑开
  182. uploadFileName = String(filePath).split(/[\\/]/).pop()
  183. }
  184. uploadHideTimer.stop()
  185. }
  186. function onFinished(success, filePath, error){
  187. uploading = false
  188. if(success){
  189. uploadPercent = 100
  190. uploadFailed = false
  191. console.log("上传完成:", filePath)
  192. }else{
  193. uploadFailed = true
  194. console.log("上传失败:", filePath, error)
  195. }
  196. // 进度条改为弹出式后不再遮挡画面,给它留一点停留时间:
  197. // 成功 1.5s 收起,失败 5s(也可点击弹层立即关闭)
  198. uploadHideTimer.interval = success ? 1500 : 5000
  199. uploadHideTimer.restart()
  200. }
  201. }
  202. // 保留:仅用于手动复位时的清理,正常流程由 onFinished 延时关闭展示
  203. Timer {
  204. id: uploadHideTimer
  205. interval: 1500
  206. running: false
  207. repeat: false
  208. onTriggered: uploadWatermarkVisible = false
  209. }
  210. // ===== 图片上传进度条(弹出式) =====
  211. // 需求:取消画面上叠加的上传进度圆/状态文字,改成居中弹出的进度条;
  212. // 上传中显示文件名与百分比,成功/失败保留一小段时间后自动收起(点击也可立即收起)。
  213. Popup {
  214. id: uploadPopup
  215. parent: Overlay.overlay
  216. modal: false
  217. focus: false
  218. closePolicy: Popup.NoAutoClose
  219. visible: page.uploadWatermarkVisible
  220. width: Math.min((parent ? parent.width : dp(600)) * 0.7, dp(520))
  221. height: dp(104)
  222. x: parent ? (parent.width - width) / 2 : 0
  223. y: parent ? parent.height * 0.10 : 0
  224. padding: dp(14)
  225. background: Rectangle {
  226. color: "#e6212121"
  227. radius: dp(8)
  228. border.width: 1
  229. border.color: page.uploadFailed ? "#ff8a80" : "#4f8cff"
  230. }
  231. // 点击立即收起(失败时现场可以先看清错误,再手动关掉)
  232. MouseArea {
  233. anchors.fill: parent
  234. onClicked: page.uploadWatermarkVisible = false
  235. }
  236. Column {
  237. id: uploadColumn
  238. width: parent.width
  239. spacing: dp(8)
  240. AppText {
  241. width: parent.width
  242. text: (page.uploading
  243. ? "图片上传中 "
  244. : (page.uploadFailed ? "图片上传失败 " : "图片上传完成 "))
  245. + page.uploadFileName
  246. color: page.uploadFailed ? "#ff8a80" : "#ffffff"
  247. font.pixelSize: sp(12)
  248. elide: Text.ElideMiddle
  249. }
  250. ProgressBar {
  251. width: parent.width
  252. from: 0
  253. to: 100
  254. value: page.uploadPercent
  255. }
  256. AppText {
  257. width: parent.width
  258. text: Math.round(page.uploadPercent) + " %"
  259. color: "#cfd8dc"
  260. font.pixelSize: sp(11)
  261. horizontalAlignment: Text.AlignRight
  262. }
  263. }
  264. }
  265. Connections{
  266. target: serial
  267. onTakephotodone:{
  268. console.log("立即拍照完成!")
  269. apptext_res.text = "立即拍照完成!"
  270. focus_switch.enabled = true
  271. focus_switch.checked = false
  272. }
  273. onAutotestdone: {
  274. console.log("自动对焦完成!")
  275. apptext_res.text = "自动对焦完成!"
  276. autotest_switch.enabled = true
  277. autotest_switch.checked = false
  278. }
  279. onTranslatedone: {
  280. console.log("胶带传送完成!")
  281. apptext_res.text = "胶带传送完成!"
  282. jiaodai_switch.enabled = true
  283. jiaodai_switch.checked = false
  284. }
  285. onDataReceived:function(data) {
  286. if(app.showRxData){
  287. var time = new Date().toLocaleTimeString()
  288. app.rxDataLog = "[" + time + "] " + data + "\n" + app.rxDataLog
  289. if(app.rxDataLog.length > 5000) app.rxDataLog = app.rxDataLog.substring(0, 5000)
  290. }
  291. // 同步坐标值到输入框
  292. try {
  293. var jsonData = JSON.parse(data)
  294. if(jsonData.ext && !textInput_x.focus && jsonData.ext.x_init_dis !== undefined) {
  295. textInput_x.text = jsonData.ext.x_init_dis.toString()
  296. }
  297. if(jsonData.ext && !textInput_y.focus && jsonData.ext.y_init_dis !== undefined) {
  298. textInput_y.text = jsonData.ext.y_init_dis.toString()
  299. }
  300. } catch(e) {
  301. console.log("解析坐标数据失败:", e)
  302. }
  303. }
  304. onNetMessage:function(data) {
  305. if(app.showTxData){
  306. var time = new Date().toLocaleTimeString()
  307. app.txDataLog = "[" + time + "] " + data + "\n" + app.txDataLog
  308. if(app.txDataLog.length > 5000) app.txDataLog = app.txDataLog.substring(0, 5000)
  309. }
  310. }
  311. }
  312. SplitView{
  313. anchors.fill: parent
  314. orientation: Qt.Horizontal
  315. Rectangle {
  316. SplitView.preferredWidth: parent.width * 0.7
  317. height: parent.height
  318. color: app.cardColor
  319. radius: 5
  320. AppButton {
  321. id: normButton
  322. //anchors.horizontalCenter: parent.horizontalCenter
  323. anchors.centerIn: parent
  324. anchors.fill: parent
  325. //text: "打开相机"
  326. flat: true //边框是否可视
  327. onClicked: {
  328. console.log("相机状态:",frames.camera_sw)
  329. //if(camera.active){
  330. if(frames.camera_sw){
  331. text = "相机已关闭"
  332. output.visible = false
  333. frames.camera_sw = false
  334. //uvc_camera.visible = false
  335. }else{
  336. text = "打开相机"
  337. output.visible = true
  338. frames.camera_sw = true
  339. //uvc_camera.visible = true
  340. }
  341. }
  342. Timer {
  343. id: longPressTimer
  344. interval: 1000 // 长按时间1000ms
  345. running: false // 初始状态下定时器停止
  346. repeat: false // 设置为false,以便只执行一次
  347. onTriggered: {
  348. console.log("长按触发")
  349. }
  350. }
  351. onPressed: {
  352. console.log("按钮按下,开始计时")
  353. longPressTimer.start()
  354. }
  355. onReleased: {
  356. console.log("按钮释放,停止计时")
  357. longPressTimer.stop()
  358. }
  359. AppImage{
  360. id: image_picdis
  361. anchors.centerIn: parent
  362. source: "../../assets/photoico.svg"
  363. }
  364. }
  365. VideoOutput
  366. {
  367. id: output
  368. anchors.fill: parent
  369. visible: false
  370. fillMode: VideoOutput.PreserveAspectFit //根据视频的纵横比例等比例缩放
  371. //fillMode: VideoOutput.Stretch
  372. Component.onCompleted: {
  373. console.log("output onCompleted")
  374. }
  375. }
  376. // 画面左上角信息:帧率 / 清晰度 / 已录制帧数
  377. // 统一用 Column 纵向排列(显式宽度 + spacing):
  378. // 原来 fps 放在 Row 里(width: parent.width),Row 的宽度又来自子项,
  379. // 形成循环依赖,Row 的高度解算不稳定,导致清晰度、帧数与 fps 叠在一起。
  380. // Column 的宽度是显式绑定的,子项 width: parent.width 不再回退到自身,
  381. // 纵向位置也由 Column 统一分配,不会再挤成一团。
  382. Column {
  383. id: infoColumn
  384. anchors.top: parent.top
  385. anchors.left: parent.left
  386. anchors.topMargin: dp(6)
  387. anchors.leftMargin: dp(8)
  388. width: parent.width - dp(44)
  389. spacing: dp(4)
  390. AppText {
  391. id: photoclarity_text
  392. width: parent.width
  393. text: frames.fpsString
  394. color: "red"
  395. elide: Text.ElideRight
  396. }
  397. AppText {
  398. id: photoclarity2_text
  399. width: parent.width
  400. text: frames.qulityString
  401. color: "green"
  402. elide: Text.ElideRight
  403. }
  404. // 已录制帧数:步进扫描时每步应只 +1,用来现场核对"移动 N 步是否只录了 N 帧"
  405. // (之前出现过移动 100 步写出 200 帧,原因是重复 movy 被重复落盘)
  406. AppText {
  407. id: recordFrames_text
  408. width: parent.width
  409. text: "已录制帧数: " + frames.recordedFrames + (frames.recording ? " (录制中)" : "")
  410. color: "#ffd54f"
  411. font.pixelSize: sp(13)
  412. elide: Text.ElideRight
  413. // 未开始录制时不占位(Column 会跳过不可见子项)
  414. visible: frames.recording || frames.recordedFrames > 0
  415. }
  416. }
  417. // 抓图按钮:仅相机打开时显示,画面右下角透明背景,点击=模拟MCU拍照指令(按序号保存/锐化/上传)
  418. Rectangle {
  419. id: captureBtn
  420. visible: frames.camera_sw
  421. width: dp(56)
  422. height: dp(56)
  423. radius: width / 2
  424. color: "transparent"
  425. border.color: "#80ffffff"
  426. border.width: dp(2)
  427. anchors.right: parent.right
  428. anchors.bottom: parent.bottom
  429. anchors.rightMargin: dp(12)
  430. anchors.bottomMargin: dp(12)
  431. AppImage {
  432. anchors.centerIn: parent
  433. width: dp(34)
  434. height: dp(34)
  435. source: "../../assets/photoico.svg"
  436. }
  437. MouseArea {
  438. anchors.fill: parent
  439. onClicked: {
  440. console.log("抓图按钮点击!")
  441. frames.manualCapture()
  442. }
  443. }
  444. }
  445. // 录制按钮:仅相机打开时显示,画面右下角(抓图按钮左侧)
  446. // 点击开始录制原始(未压缩)视频流,再次点击停止并把视频流保存到相机打开时创建的文件夹
  447. Rectangle {
  448. id: recordBtn
  449. visible: frames.camera_sw
  450. width: dp(56)
  451. height: dp(56)
  452. radius: width / 2
  453. color: "transparent"
  454. border.color: frames.recording ? "#e74c3c" : "#80ffffff"
  455. border.width: dp(2)
  456. anchors.right: captureBtn.left
  457. anchors.bottom: parent.bottom
  458. anchors.rightMargin: dp(12)
  459. anchors.bottomMargin: dp(12)
  460. // 未录制:红色圆点(开始);录制中:红色方块(停止)
  461. Rectangle {
  462. anchors.centerIn: parent
  463. width: frames.recording ? dp(22) : dp(26)
  464. height: frames.recording ? dp(22) : dp(26)
  465. radius: frames.recording ? dp(3) : width / 2
  466. color: "#e74c3c"
  467. }
  468. MouseArea {
  469. anchors.fill: parent
  470. onClicked: {
  471. if(frames.recording){
  472. console.log("停止录制视频流")
  473. frames.stopRecord()
  474. }else{
  475. console.log("开始录制视频流")
  476. if(frames.startRecord()){
  477. apptext_res.text = "开始录制视频流"
  478. }else{
  479. nativeUtils.displayMessageBox("提示","录制失败,请先打开相机!",1)
  480. }
  481. }
  482. }
  483. }
  484. }
  485. // 分析/融合处理期间:挂起相机画面输出,用进度/过程替代画面
  486. Rectangle {
  487. id: processOverlay
  488. visible: frames.processing
  489. anchors.fill: parent
  490. color: "#E6000000"
  491. z: 20
  492. Column {
  493. anchors.centerIn: parent
  494. spacing: dp(12)
  495. BusyIndicator {
  496. anchors.horizontalCenter: parent.horizontalCenter
  497. running: frames.processing
  498. width: dp(56)
  499. height: dp(56)
  500. }
  501. AppText {
  502. anchors.horizontalCenter: parent.horizontalCenter
  503. text: frames.processMessage
  504. color: "white"
  505. fontSize: 16
  506. }
  507. AppText {
  508. anchors.horizontalCenter: parent.horizontalCenter
  509. text: "处理中 " + frames.processPercent + "%"
  510. color: "#28a779"
  511. fontSize: 15
  512. }
  513. // 进度条
  514. Rectangle {
  515. width: dp(280)
  516. height: dp(8)
  517. radius: dp(4)
  518. color: "#33ffffff"
  519. anchors.horizontalCenter: parent.horizontalCenter
  520. Rectangle {
  521. width: parent.width * frames.processPercent / 100
  522. height: parent.height
  523. radius: parent.radius
  524. color: "#28a779"
  525. }
  526. }
  527. }
  528. }
  529. }
  530. ScrollView
  531. {
  532. SplitView.preferredWidth: parent.width*0.29
  533. SplitView.minimumWidth: 200
  534. clip: true
  535. Column {
  536. spacing: dp(15)
  537. Row {
  538. spacing: 80
  539. AppText {
  540. id: text_title
  541. text: "测试调试"
  542. font.bold: true
  543. color: "#28a779"
  544. fontSize: 20
  545. }
  546. AppText {
  547. id: apptext_res
  548. text: "[测试结果]"
  549. fontSize:15
  550. color: "grey"
  551. anchors.verticalCenter: text_title.verticalCenter
  552. }
  553. }
  554. Row {
  555. spacing: dp(120)
  556. AppText{
  557. text: "一键测试"
  558. fontSize: 15
  559. color: app.fontColor
  560. anchors.verticalCenter: autotest_switch.verticalCenter
  561. }
  562. AppSwitch {
  563. id: autotest_switch
  564. onToggled: {
  565. if(autotest_switch.checked==true){
  566. autotest_switch.enabled = false
  567. serial.sendCmd("autotest",true,"","");
  568. t_autotest.start()
  569. }else{
  570. console.log("t_autotest 计数:",t_autotest.interval)
  571. }
  572. }
  573. }
  574. Timer {
  575. id: t_autotest
  576. interval: 1000*60
  577. running: false
  578. repeat: false
  579. onTriggered: {
  580. autotest_switch.enabled = true
  581. autotest_switch.checked = false
  582. }
  583. }
  584. }
  585. Row {
  586. spacing: dp(120)
  587. AppText{
  588. text: "风机测试"
  589. color: app.fontColor
  590. fontSize: 15
  591. anchors.verticalCenter: fantest_switch.verticalCenter
  592. }
  593. AppSwitch {
  594. id: fantest_switch
  595. onToggled: {
  596. if(fantest_switch.checked==true){
  597. serial.sendCmd("fan",true,"","");
  598. apptext_res.text = "打开风机"
  599. }else{
  600. serial.sendCmd("fan",false,"","");
  601. apptext_res.text = "关闭风机"
  602. }
  603. }
  604. }
  605. }
  606. Row {
  607. spacing: dp(120)
  608. AppText{
  609. text: "胶带测试"
  610. fontSize: 15
  611. color: app.fontColor
  612. //font.bold: true
  613. anchors.verticalCenter: jiaodai_switch.verticalCenter
  614. }
  615. AppSwitch {
  616. id: jiaodai_switch
  617. onToggled: {
  618. if(jiaodai_switch.checked==true){
  619. // 检查是否处于温度保护状态
  620. if(app.tempProtectionState === true){
  621. // 弹出提示对话框
  622. nativeUtils.displayMessageBox(
  623. "提示",
  624. "当前处于温控状态,请解除温控后再进行测试胶带传送",
  625. 1
  626. );
  627. // 恢复开关状态为未选中
  628. jiaodai_switch.checked = false;
  629. return;
  630. }
  631. // 正常执行胶带测试
  632. //jiaodai_switch.enabled = false
  633. apptext_res.text = "胶带测试开始"
  634. serial.sendCmd("jiaodai",true,"","");
  635. }
  636. }
  637. }
  638. }
  639. Row {
  640. spacing: dp(120)
  641. AppText {
  642. text: "补光测试"
  643. color: app.fontColor
  644. fontSize: 15
  645. anchors.verticalCenter: led_switch.verticalCenter
  646. }
  647. AppSwitch {
  648. id: led_switch
  649. onToggled: {
  650. if(led_switch.checked==true){
  651. serial.sendCmd("led",true,"","");
  652. apptext_res.text = "补光灯已打开"
  653. }else{
  654. serial.sendCmd("led",false,"","");
  655. apptext_res.text = "补光灯已关闭"
  656. }
  657. }
  658. }
  659. }
  660. Row {
  661. spacing: dp(120)
  662. AppText {
  663. text: "立即拍照"
  664. color: app.fontColor
  665. fontSize: 15
  666. anchors.verticalCenter: takephoto_switch.verticalCenter
  667. }
  668. AppSwitch {
  669. id: takephoto_switch
  670. onToggled: {
  671. if(takephoto_switch.checked==true){
  672. apptext_res.text = "立即拍照"
  673. frames.captureImage()
  674. }
  675. }
  676. }
  677. }
  678. Row {
  679. spacing: dp(120)
  680. AppText {
  681. text: "对焦拍照"
  682. color: app.fontColor
  683. fontSize: 15
  684. anchors.verticalCenter: focus_switch.verticalCenter
  685. }
  686. AppSwitch {
  687. id: focus_switch
  688. onToggled: {
  689. if(focus_switch.checked==true){
  690. apptext_res.text = "开始对焦"
  691. focus_switch.enabled = false
  692. serial.auto_takephoto(true)
  693. }
  694. }
  695. }
  696. }
  697. // 滤网更换测试按钮(始终可见)
  698. Row {
  699. spacing: dp(120)
  700. AppText {
  701. text: "滤网更换"
  702. color: app.fontColor
  703. fontSize: 15
  704. anchors.verticalCenter: selfclean_switch.verticalCenter
  705. }
  706. AppSwitch {
  707. id: selfclean_switch
  708. onToggled: {
  709. if(selfclean_switch.checked==true){
  710. apptext_res.text = "自清洁测试中..."
  711. serial.sendCmd("selfclean",true,"","");
  712. }
  713. }
  714. }
  715. }
  716. // 分割线
  717. Rectangle {
  718. visible: !motorUnlocked
  719. width: parent.width
  720. height: dp(1)
  721. color: "#e0e0e0"
  722. }
  723. // 分割线
  724. Rectangle {
  725. width: parent.width
  726. height: dp(2)
  727. color: "#28a779"
  728. }
  729. // 密码输入区域(未解锁时显示)
  730. Rectangle {
  731. visible: !motorUnlocked
  732. width: parent.width
  733. height: passwordColumn.height + dp(16)
  734. color: app.cardColor
  735. radius: dp(8)
  736. border.color: "#28a779"
  737. border.width: dp(1)
  738. Column {
  739. id: passwordColumn
  740. anchors.centerIn: parent
  741. spacing: dp(10)
  742. AppText {
  743. anchors.horizontalCenter: parent.horizontalCenter
  744. text: "请输入密码解锁电机控制"
  745. color: app.fontColor
  746. font.bold: true
  747. fontSize: 14
  748. }
  749. Row {
  750. anchors.horizontalCenter: parent.horizontalCenter
  751. spacing: dp(8)
  752. AppTextField {
  753. id: motorPasswordInput
  754. width: dp(130)
  755. height: dp(38)
  756. echoMode: TextInput.Password
  757. placeholderText: "密码"
  758. inputMethodHints: Qt.ImhDigitsOnly
  759. anchors.verticalCenter: parent.verticalCenter
  760. onAccepted: {
  761. if(text === "666888"){
  762. motorUnlocked = true
  763. text = ""
  764. }else{
  765. apptext_res.text = "密码错误"
  766. text = ""
  767. }
  768. }
  769. }
  770. AppButton {
  771. text: "确认"
  772. textColor: "white"
  773. flat: false
  774. backgroundColor: "#28a779"
  775. minimumHeight: dp(38)
  776. minimumWidth: dp(55)
  777. anchors.verticalCenter: parent.verticalCenter
  778. onClicked: {
  779. if(motorPasswordInput.text === "666888"){
  780. motorUnlocked = true
  781. motorPasswordInput.text = ""
  782. }else{
  783. apptext_res.text = "密码错误"
  784. motorPasswordInput.text = ""
  785. }
  786. }
  787. }
  788. }
  789. }
  790. }
  791. // 电机控制及以下所有控件(解锁后显示)
  792. Item {
  793. id: motorSection
  794. visible: motorUnlocked
  795. width: parent.width
  796. height: motorContent.height + dp(20)
  797. property alias content: motorContent
  798. Column {
  799. id: motorContent
  800. spacing: dp(12)
  801. width: parent.width
  802. // 锁定按钮
  803. Row {
  804. spacing: dp(5)
  805. width: parent.width
  806. AppText {
  807. text: "高级控制"
  808. font.bold: true
  809. color: "#28a779"
  810. fontSize: 20
  811. anchors.verticalCenter: parent.verticalCenter
  812. }
  813. AppButton {
  814. text: "锁定"
  815. textColor: "white"
  816. flat: false
  817. backgroundColor: "#d9534f"
  818. minimumHeight: dp(25)
  819. minimumWidth: dp(50)
  820. anchors.verticalCenter: parent.verticalCenter
  821. onClicked: motorUnlocked = false
  822. }
  823. }
  824. AppText {
  825. id: text_title2
  826. text: "三轴步进电机控制"
  827. font.bold: true
  828. color: "#28a779"
  829. fontSize: 20
  830. }
  831. // ===== 图像处理开关(与电机控制一起锁在密码后面)=====
  832. // 1) 景深融合:关掉后录制结束只保留最清晰帧,不做融合
  833. // 状态唯一来源是 frames.fusionEnabled(= param::fusion_enable,
  834. // MQTT fusion_sw 也会改它,所以用 Connections 双向同步,不做单向绑定)
  835. Row {
  836. spacing: dp(12)
  837. width: parent.width
  838. AppText {
  839. text: "景深融合"
  840. width: dp(140)
  841. color: app.fontColor
  842. fontSize: 15
  843. anchors.verticalCenter: fusion_switch.verticalCenter
  844. }
  845. AppSwitch {
  846. id: fusion_switch
  847. // 不用 checked: frames.fusionEnabled 绑定:用户点开关时控件内部会
  848. // 直接给 checked 赋值、绑定被打断,之后 MQTT 改状态就同步不过来了。
  849. // 这里改成显式赋值 + Connections 回灌,始终以 frames 的值为准。
  850. Component.onCompleted: checked = frames.fusionEnabled
  851. onToggled: {
  852. frames.fusionEnabled = checked
  853. console.log("景深融合:", checked ? "开" : "关")
  854. }
  855. }
  856. AppText {
  857. text: frames.fusionEnabled ? "开" : "关"
  858. color: frames.fusionEnabled ? "#28a779" : "#d9534f"
  859. anchors.verticalCenter: fusion_switch.verticalCenter
  860. }
  861. }
  862. // 2) 临时调试:保留录制文件(rawv),便于复盘;不写库,重启复位
  863. Row {
  864. spacing: dp(12)
  865. width: parent.width
  866. AppText {
  867. text: "保留录像(调试)"
  868. width: dp(140)
  869. color: app.fontColor
  870. fontSize: 15
  871. anchors.verticalCenter: keep_record_switch.verticalCenter
  872. }
  873. AppSwitch {
  874. id: keep_record_switch
  875. Component.onCompleted: checked = frames.debugKeepRecord
  876. onToggled: {
  877. frames.debugKeepRecord = checked
  878. console.log("调试保留录像:", checked ? "开" : "关")
  879. }
  880. }
  881. AppText {
  882. text: frames.debugKeepRecord ? "开" : "关"
  883. color: frames.debugKeepRecord ? "#ffd54f" : "#9e9e9e"
  884. anchors.verticalCenter: keep_record_switch.verticalCenter
  885. }
  886. }
  887. // 融合开关状态回灌:MQTT fusion_sw、启动读库、按钮点击都会走这里,
  888. // 保证界面开关显示与 param::fusion_enable 始终一致
  889. Connections {
  890. target: frames
  891. function onFusionEnabledChanged() {
  892. if(fusion_switch.checked !== frames.fusionEnabled)
  893. fusion_switch.checked = frames.fusionEnabled
  894. }
  895. function onDebugKeepRecordChanged() {
  896. if(keep_record_switch.checked !== frames.debugKeepRecord)
  897. keep_record_switch.checked = frames.debugKeepRecord
  898. }
  899. }
  900. // 轴选择
  901. Row {
  902. spacing: dp(8)
  903. width: parent.width
  904. AppText {
  905. text: "选择轴:"
  906. width: dp(60)
  907. color: app.fontColor
  908. anchors.verticalCenter: parent.verticalCenter
  909. }
  910. ComboBox {
  911. width: parent.width - dp(100)
  912. height: dp(40)
  913. model: ["X轴", "Y轴", "Z轴"]
  914. onCurrentIndexChanged: currentAxis = currentIndex
  915. }
  916. AppButton {
  917. text: "校准"
  918. textColor: "black"
  919. flat: false
  920. borderColor: "black"
  921. borderWidth: dp(1)
  922. backgroundColor: "white"
  923. minimumHeight: dp(30)
  924. minimumWidth: dp(50)
  925. onClicked:
  926. {
  927. autotake(false)
  928. if(currentAxis==0)
  929. {
  930. console.log("校准X")
  931. serial.sendCmd("calibrate",false,"x",speed.toString())
  932. }else if(currentAxis==1)
  933. {
  934. console.log("校准Y")
  935. serial.sendCmd("calibrate",false,"y",speed.toString())
  936. }else if(currentAxis==2)
  937. {
  938. console.log("校准Z")
  939. serial.sendCmd("calibrate",false,"z",speed.toString())
  940. }
  941. }
  942. }
  943. }
  944. // 速度调节
  945. Row {
  946. spacing: dp(10)
  947. width: parent.width
  948. AppText {
  949. text: "速度:"
  950. width: dp(40)
  951. color: app.fontColor
  952. anchors.verticalCenter: parent.verticalCenter
  953. }
  954. AppSlider {
  955. width: parent.width - dp(60)
  956. from: 0
  957. to: 100
  958. value: speed
  959. stepSize: 1
  960. onValueChanged: speed = value
  961. anchors.verticalCenter: parent.verticalCenter
  962. }
  963. AppText {
  964. text: speed
  965. width: dp(40)
  966. anchors.verticalCenter: parent.verticalCenter
  967. }
  968. }
  969. // 步进距离设置
  970. Row {
  971. spacing: dp(10)
  972. width: parent.width
  973. AppText {
  974. text: "步进脉冲次数:"
  975. width: dp(120)
  976. color: app.fontColor
  977. anchors.verticalCenter: parent.verticalCenter
  978. }
  979. AppTextField {
  980. id: step_apptextfield
  981. width: parent.width - dp(120)
  982. text: stepDistance
  983. validator: IntValidator { bottom: 0; top: 2000 }
  984. onTextChanged: stepDistance = parseInt(text)
  985. }
  986. }
  987. // 运动控制按钮
  988. Row {
  989. spacing: dp(10)
  990. width: parent.width
  991. AppButton {
  992. text: " 正转 "
  993. textColor: "black"
  994. flat: false
  995. borderColor: "black"
  996. borderWidth: dp(1)
  997. backgroundColor: "grey"
  998. minimumHeight: dp(30)
  999. minimumWidth: dp(50)
  1000. width: (parent.width - dp(30))/4
  1001. onClicked:
  1002. {
  1003. if(currentAxis==0)
  1004. {
  1005. console.log("X轴正转:",stepDistance)
  1006. serial.sendCmd("movx",false,"f"+stepDistance,speed.toString())
  1007. }else if(currentAxis==1)
  1008. {
  1009. console.log("Y轴正转:",stepDistance)
  1010. serial.sendCmd("movy",false,"f"+stepDistance,speed.toString())
  1011. }else if(currentAxis==2)
  1012. {
  1013. console.log("Z轴正转:",stepDistance)
  1014. serial.sendCmd("movz",false,"f"+stepDistance,speed.toString())
  1015. }
  1016. }
  1017. }
  1018. AppButton {
  1019. text: " 停止 "
  1020. textColor: "black"
  1021. flat: false
  1022. borderColor: "black"
  1023. borderWidth: dp(1)
  1024. backgroundColor: "red"
  1025. minimumHeight: dp(30)
  1026. minimumWidth: dp(50)
  1027. width: (parent.width - dp(30))/4
  1028. onClicked:
  1029. {
  1030. console.log("停止")
  1031. serial.sendCmd("movx",false,"f0","")
  1032. }
  1033. }
  1034. AppButton {
  1035. text: " 反转 "
  1036. textColor: "black"
  1037. flat: false
  1038. borderColor: "black"
  1039. borderWidth: dp(1)
  1040. backgroundColor: "grey"
  1041. minimumHeight: dp(30)
  1042. minimumWidth: dp(50)
  1043. width: (parent.width - dp(30))/4
  1044. onClicked:
  1045. {
  1046. if(currentAxis==0)
  1047. {
  1048. console.log("X轴反转:",stepDistance)
  1049. serial.sendCmd("movx",false,"b"+stepDistance,speed.toString())
  1050. }else if(currentAxis==1)
  1051. {
  1052. console.log("Y轴反转:",stepDistance)
  1053. serial.sendCmd("movy",false,"b"+stepDistance,speed.toString())
  1054. }else if(currentAxis==2)
  1055. {
  1056. console.log("Z轴反转:",stepDistance)
  1057. serial.sendCmd("movz",false,"b"+stepDistance,speed.toString())
  1058. }
  1059. }
  1060. }
  1061. AppButton {
  1062. text: " 复位 "
  1063. textColor: "black"
  1064. flat: false
  1065. borderColor: "black"
  1066. borderWidth: dp(1)
  1067. backgroundColor: "grey"
  1068. minimumHeight: dp(30)
  1069. minimumWidth: dp(50)
  1070. width: (parent.width - dp(30))/4
  1071. onClicked: {
  1072. if(currentAxis==0)
  1073. {
  1074. console.log("X轴复位!")
  1075. serial.sendCmd("movx",true,"",speed.toString())
  1076. }else if(currentAxis==1)
  1077. {
  1078. console.log("Y轴复位!")
  1079. serial.sendCmd("movy",true,"",speed.toString())
  1080. }else if(currentAxis==2)
  1081. {
  1082. console.log("Z轴复位!")
  1083. serial.sendCmd("movz",true,"",speed.toString())
  1084. }
  1085. }
  1086. }
  1087. }
  1088. // ===== 坐标参数 =====
  1089. AppText {
  1090. text: "坐标参数"
  1091. font.bold: true
  1092. color: "#28a779"
  1093. fontSize: 20
  1094. }
  1095. // X 坐标输入行
  1096. Row {
  1097. spacing: dp(5)
  1098. width: parent.width
  1099. AppText {
  1100. text: "X坐标:"
  1101. width: dp(50)
  1102. color: app.fontColor
  1103. fontSize: 15
  1104. anchors.verticalCenter: textInput_x.verticalCenter
  1105. }
  1106. AppTextField {
  1107. id: textInput_x
  1108. width: parent.width - dp(80)
  1109. height: dp(40)
  1110. placeholderText: "0"
  1111. text: "0"
  1112. font.family: "Arial"
  1113. font.pixelSize: 15
  1114. validator: DoubleValidator { decimals: 2 }
  1115. EnterKey.type: Qt.EnterKeyDone
  1116. inputMethodHints: Qt.ImhFormattedNumbersOnly
  1117. property real numericValue_x: Number(text) || 0
  1118. Keys.onReturnPressed: {
  1119. serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
  1120. Qt.inputMethod.hide()
  1121. }
  1122. onAccepted: {
  1123. serial.setHt_xy_dis(numericValue_x, textInput_y.numericValue_y)
  1124. }
  1125. }
  1126. }
  1127. // Y 坐标输入行
  1128. Row {
  1129. spacing: dp(5)
  1130. width: parent.width
  1131. AppText {
  1132. text: "Y坐标:"
  1133. width: dp(50)
  1134. color: app.fontColor
  1135. fontSize: 15
  1136. anchors.verticalCenter: textInput_y.verticalCenter
  1137. }
  1138. AppTextField {
  1139. id: textInput_y
  1140. width: parent.width - dp(80)
  1141. height: dp(40)
  1142. placeholderText: "0"
  1143. text: "0"
  1144. font.family: "Arial"
  1145. font.pixelSize: 15
  1146. validator: DoubleValidator { decimals: 2 }
  1147. EnterKey.type: Qt.EnterKeyDone
  1148. inputMethodHints: Qt.ImhFormattedNumbersOnly
  1149. property real numericValue_y: Number(text) || 0
  1150. Keys.onReturnPressed: {
  1151. serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
  1152. Qt.inputMethod.hide()
  1153. }
  1154. onAccepted: {
  1155. serial.setHt_xy_dis(textInput_x.numericValue_x, numericValue_y)
  1156. }
  1157. }
  1158. }
  1159. // 分割线
  1160. Rectangle {
  1161. width: parent.width
  1162. height: dp(2)
  1163. color: "#e0e0e0"
  1164. }
  1165. // ===== 相机参数 =====
  1166. AppText {
  1167. id: text_camera
  1168. text: "相机参数"
  1169. font.bold: true
  1170. color: "#28a779"
  1171. fontSize: 20
  1172. }
  1173. Row {
  1174. spacing: dp(10)
  1175. width: parent.width
  1176. AppText {
  1177. id: txt_fExposureTime
  1178. text: "曝光值:"
  1179. color: app.fontColor
  1180. }
  1181. AppTextField {
  1182. anchors.verticalCenter: txt_fExposureTime.verticalCenter
  1183. placeholderText: fExposureTime
  1184. text: fExposureTime
  1185. width: parent.width - dp(10)
  1186. EnterKey.type: Qt.EnterKeyDone
  1187. wrapMode: Text.NoWrap
  1188. inputMethodHints: Qt.ImhFormattedNumbersOnly |
  1189. Qt.ImhPreferDone |
  1190. Qt.ImhNoPredictiveText
  1191. validator: DoubleValidator {
  1192. bottom: 100.00
  1193. top: 500000.00
  1194. decimals: 0
  1195. }
  1196. // 关键:兜底(IME 再作妖也不怕)
  1197. Keys.onReturnPressed: {
  1198. frames.cam_ExposureTime = text
  1199. console.log("设置曝光时间:",text)
  1200. Qt.inputMethod.hide()
  1201. }
  1202. onAccepted: {
  1203. frames.cam_ExposureTime = text
  1204. console.log("设置曝光时间",text)
  1205. }
  1206. }
  1207. }
  1208. // 相机型号(海康工业相机,打开相机后自动读取展示)
  1209. Row {
  1210. spacing: dp(10)
  1211. width: parent.width
  1212. AppText {
  1213. id: txt_camModel
  1214. text: "相机型号:"
  1215. color: app.fontColor
  1216. fontSize: 15
  1217. anchors.verticalCenter: parent.verticalCenter
  1218. }
  1219. AppText {
  1220. text: frames.cam_ModelName
  1221. color: "#28a779"
  1222. font.bold: true
  1223. fontSize: 15
  1224. elide: Text.ElideRight
  1225. width: parent.width - txt_camModel.width - dp(10)
  1226. anchors.verticalCenter: parent.verticalCenter
  1227. }
  1228. }
  1229. // 亮度(自动曝光目标灰度0-255,设置后切换为自动曝光,手动曝光值失效)
  1230. Row {
  1231. spacing: dp(10)
  1232. width: parent.width
  1233. AppText {
  1234. id: txt_fBrightness
  1235. text: "亮度:"
  1236. color: app.fontColor
  1237. fontSize: 15
  1238. anchors.verticalCenter: parent.verticalCenter
  1239. }
  1240. AppTextField {
  1241. anchors.verticalCenter: txt_fBrightness.verticalCenter
  1242. placeholderText: frames.cam_Brightness
  1243. text: frames.cam_Brightness
  1244. width: parent.width - dp(10)
  1245. EnterKey.type: Qt.EnterKeyDone
  1246. wrapMode: Text.NoWrap
  1247. inputMethodHints: Qt.ImhDigitsOnly |
  1248. Qt.ImhPreferDone |
  1249. Qt.ImhNoPredictiveText
  1250. validator: IntValidator {
  1251. bottom: 0
  1252. top: 255
  1253. }
  1254. Keys.onReturnPressed: {
  1255. frames.cam_Brightness = text
  1256. console.log("设置亮度:", text)
  1257. Qt.inputMethod.hide()
  1258. }
  1259. onAccepted: {
  1260. frames.cam_Brightness = text
  1261. console.log("设置亮度:", text)
  1262. }
  1263. }
  1264. }
  1265. // 白平衡自动模式(关闭后可手动调下方红/蓝比例)
  1266. Row {
  1267. spacing: dp(10)
  1268. width: parent.width
  1269. AppText {
  1270. text: "白平衡:"
  1271. color: app.fontColor
  1272. fontSize: 15
  1273. anchors.verticalCenter: wbModeBox.verticalCenter
  1274. }
  1275. ComboBox {
  1276. id: wbModeBox
  1277. width: parent.width - dp(80)
  1278. height: dp(40)
  1279. model: ["关闭", "自动一次", "连续自动"]
  1280. currentIndex: frames.cam_WhiteBalanceMode
  1281. onActivated: {
  1282. frames.cam_WhiteBalanceMode = currentIndex
  1283. apptext_res.text = "白平衡模式:" + model[currentIndex]
  1284. console.log("设置白平衡模式:", model[currentIndex])
  1285. //用户选择会打断currentIndex的属性绑定,重新建立以保持相机参数回显同步
  1286. wbModeBox.currentIndex = Qt.binding(function(){ return frames.cam_WhiteBalanceMode })
  1287. }
  1288. }
  1289. }
  1290. // 白平衡红/蓝比例(手动模式下生效,写入时自动切为关闭模式)
  1291. Row {
  1292. spacing: dp(8)
  1293. width: parent.width
  1294. AppText {
  1295. text: "红/蓝比例:"
  1296. color: app.fontColor
  1297. fontSize: 13
  1298. anchors.verticalCenter: parent.verticalCenter
  1299. }
  1300. AppTextField {
  1301. id: wbRatioRField
  1302. width: (parent.width - dp(80)) / 2
  1303. placeholderText: "红 " + frames.cam_BalanceRatioR
  1304. text: frames.cam_BalanceRatioR
  1305. EnterKey.type: Qt.EnterKeyDone
  1306. wrapMode: Text.NoWrap
  1307. inputMethodHints: Qt.ImhDigitsOnly |
  1308. Qt.ImhPreferDone |
  1309. Qt.ImhNoPredictiveText
  1310. validator: IntValidator {
  1311. bottom: 0
  1312. top: 16383
  1313. }
  1314. Keys.onReturnPressed: {
  1315. frames.cam_BalanceRatioR = text
  1316. console.log("设置白平衡红比例:", text)
  1317. Qt.inputMethod.hide()
  1318. }
  1319. onAccepted: {
  1320. frames.cam_BalanceRatioR = text
  1321. console.log("设置白平衡红比例:", text)
  1322. }
  1323. }
  1324. AppTextField {
  1325. id: wbRatioBField
  1326. width: (parent.width - dp(80)) / 2
  1327. placeholderText: "蓝 " + frames.cam_BalanceRatioB
  1328. text: frames.cam_BalanceRatioB
  1329. EnterKey.type: Qt.EnterKeyDone
  1330. wrapMode: Text.NoWrap
  1331. inputMethodHints: Qt.ImhDigitsOnly |
  1332. Qt.ImhPreferDone |
  1333. Qt.ImhNoPredictiveText
  1334. validator: IntValidator {
  1335. bottom: 0
  1336. top: 16383
  1337. }
  1338. Keys.onReturnPressed: {
  1339. frames.cam_BalanceRatioB = text
  1340. console.log("设置白平衡蓝比例:", text)
  1341. Qt.inputMethod.hide()
  1342. }
  1343. onAccepted: {
  1344. frames.cam_BalanceRatioB = text
  1345. console.log("设置白平衡蓝比例:", text)
  1346. }
  1347. }
  1348. }
  1349. AppText {
  1350. id: text_debug
  1351. text: "通信调试"
  1352. font.bold: true
  1353. color: "#28a779"
  1354. fontSize: 20
  1355. }
  1356. Row {
  1357. spacing: dp(12)
  1358. AppText {
  1359. text: "显示Serial发送数据"
  1360. color: app.fontColor
  1361. fontSize: 15
  1362. anchors.verticalCenter: txSwitch.verticalCenter
  1363. }
  1364. AppSwitch {
  1365. id: txSwitch
  1366. onToggled: {
  1367. app.floatPanel = checked
  1368. app.showTxData = checked
  1369. app.floatPanel_title = "Serial发送数据"
  1370. }
  1371. }
  1372. }
  1373. Row {
  1374. spacing: dp(12)
  1375. AppText {
  1376. text: "显示Serial接收数据"
  1377. color: app.fontColor
  1378. fontSize: 15
  1379. anchors.verticalCenter: rxSwitch.verticalCenter
  1380. }
  1381. AppSwitch {
  1382. id: rxSwitch
  1383. onToggled: {
  1384. app.floatPanel = checked
  1385. app.showRxData = checked
  1386. app.floatPanel_title = "Serial接收数据"
  1387. }
  1388. }
  1389. }
  1390. Row {
  1391. spacing: dp(12)
  1392. AppText {
  1393. text: "显示MQTT发送数据"
  1394. color: app.fontColor
  1395. fontSize: 15
  1396. anchors.verticalCenter: pubSwitch.verticalCenter
  1397. }
  1398. AppSwitch {
  1399. id: pubSwitch
  1400. onToggled: {
  1401. app.floatPanel = checked
  1402. app.showPubData = checked
  1403. app.showSubData = false
  1404. app.floatPanel_title = "MQTT发送数据"
  1405. }
  1406. }
  1407. }
  1408. Row {
  1409. spacing: dp(12)
  1410. AppText {
  1411. text: "显示MQTT接收数据"
  1412. color: app.fontColor
  1413. fontSize: 15
  1414. anchors.verticalCenter: subSwitch.verticalCenter
  1415. }
  1416. AppSwitch {
  1417. id: subSwitch
  1418. onToggled: {
  1419. app.floatPanel = checked
  1420. app.showSubData = checked
  1421. app.showPubData = false
  1422. app.floatPanel_title = "MQTT接收数据"
  1423. }
  1424. }
  1425. }
  1426. } // motorContent
  1427. } // motorSection
  1428. }
  1429. }
  1430. }
  1431. }