From e7396a47d993879d4213b9e5416a1c6a7d3b4124 Mon Sep 17 00:00:00 2001 From: uclaros Date: Fri, 19 Apr 2024 08:31:32 +0300 Subject: [PATCH] rework MMFormScannerEditor --- app/qml/form/editors/MMFormScannerEditor.qml | 45 +++++--------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/app/qml/form/editors/MMFormScannerEditor.qml b/app/qml/form/editors/MMFormScannerEditor.qml index cfa4d227d7..8c2ed53fab 100644 --- a/app/qml/form/editors/MMFormScannerEditor.qml +++ b/app/qml/form/editors/MMFormScannerEditor.qml @@ -10,8 +10,8 @@ import QtQuick import QtQuick.Controls import QtQuick.Controls.Basic -import "../../components" -import "../../inputs" +import "../../components" as MMComponents +import "../../components/private" as MMPrivateComponents /* * QR/Barcode scanner editor for QGIS Attribute Form @@ -21,7 +21,7 @@ import "../../inputs" * Should be used only within feature form. */ -MMBaseInput { +MMPrivateComponents.MMBaseSingleLineInput { id: root property var _fieldValue: parent.fieldValue @@ -38,9 +38,6 @@ MMBaseInput { property bool _fieldRememberValueSupported: parent.fieldRememberValueSupported property bool _fieldRememberValueState: parent.fieldRememberValueState - property alias placeholderText: textField.placeholderText - property alias text: textField.text - signal editorValueChanged( var newValue, bool isNull ) signal rememberValueBoxClicked( bool state ) @@ -49,8 +46,7 @@ MMBaseInput { warningMsg: _fieldWarningMessage errorMsg: _fieldErrorMessage - hasFocus: textField.activeFocus - enabled: !_fieldIsReadOnly + readOnly: _fieldIsReadOnly hasCheckbox: _fieldRememberValueSupported checkboxChecked: _fieldRememberValueState @@ -59,39 +55,20 @@ MMBaseInput { root.rememberValueBoxClicked( checkboxChecked ) } - content: TextField { - id: textField - - anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter - - readOnly: !root.enabled - - text: root._fieldValue === undefined || root._fieldValueIsNull ? '' : root._fieldValue - - color: __style.nightColor - placeholderTextColor: __style.darkGreyColor + text: root._fieldValue === undefined || root._fieldValueIsNull ? '' : root._fieldValue - font: __style.p5 - hoverEnabled: true + onTextEdited: root.editorValueChanged( root.text, root.text === "" ) - background: Rectangle { color: __style.transparentColor } - - onTextEdited: root.editorValueChanged( textField.text, textField.text === "" ) - } - - rightAction: MMIcon { + rightContent: MMComponents.MMIcon { property bool pressed: false - anchors.verticalCenter: parent.verticalCenter - size: __style.icon24 source: __style.qrCodeIcon - color: root.enabled ? __style.forestColor : __style.mediumGreenColor + color: root.state === "enabled" ? __style.forestColor : __style.mediumGreenColor } - onRightActionClicked: { - if ( !root.enabled ) + onRightContentClicked: { + if ( root.state !== "enabled" ) return if (!__inputUtils.acquireCameraPermission()) @@ -112,7 +89,7 @@ MMBaseInput { Component { id: readerComponent - MMCodeScanner { + MMComponents.MMCodeScanner { focus: true onClosed: codeScannerLoader.active = false