Skip to content

Commit

Permalink
rework MMFormScannerEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros committed Apr 19, 2024
1 parent f40b7a5 commit 4d3df5e
Showing 1 changed file with 12 additions and 36 deletions.
48 changes: 12 additions & 36 deletions app/qml/form/editors/MMFormScannerEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
***************************************************************************/

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
Expand All @@ -21,7 +20,7 @@ import "../../inputs"
* Should be used only within feature form.
*/

MMBaseInput {
MMPrivateComponents.MMBaseSingleLineInput {
id: root

property var _fieldValue: parent.fieldValue
Expand All @@ -38,9 +37,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 )

Expand All @@ -49,8 +45,7 @@ MMBaseInput {
warningMsg: _fieldWarningMessage
errorMsg: _fieldErrorMessage

hasFocus: textField.activeFocus
enabled: !_fieldIsReadOnly
readOnly: _fieldIsReadOnly

hasCheckbox: _fieldRememberValueSupported
checkboxChecked: _fieldRememberValueState
Expand All @@ -59,39 +54,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
text: root._fieldValue === undefined || root._fieldValueIsNull ? '' : root._fieldValue

color: __style.nightColor
placeholderTextColor: __style.darkGreyColor
onTextEdited: root.editorValueChanged( root.text, root.text === "" )

font: __style.p5
hoverEnabled: true

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.editState === "enabled" ? __style.forestColor : __style.mediumGreenColor
}

onRightActionClicked: {
if ( !root.enabled )
onRightContentClicked: {
if ( root.editState !== "enabled" )
return

if (!__inputUtils.acquireCameraPermission())
Expand All @@ -112,7 +88,7 @@ MMBaseInput {
Component {
id: readerComponent

MMCodeScanner {
MMComponents.MMCodeScanner {
focus: true

onClosed: codeScannerLoader.active = false
Expand Down

0 comments on commit 4d3df5e

Please sign in to comment.