Skip to content

Commit 288b5c1

Browse files
sklencarwonder-sk
authored andcommitted
[QgsQuick] Feature form improvements #2 (#9388)
TextEdit * added radius property QgsQuickFeatureFormStyling and ExternalResource widget - added optional color for trash icon ExternalResource * smaller icons * preview available in read-only mode FeatureForm * fix of empty space for tabs which exists even if there are no tabs Enabling widgets for interactions even in readOnly mode, still not edits! Changes due to introduction of a preview for externalResources widget, which should be available also in readOnly mode. Therefore the widget is always enabled. NOTE: changed order of properties for widgets to keep the same order.
1 parent 44847ca commit 288b5c1

File tree

7 files changed

+23
-18
lines changed

7 files changed

+23
-18
lines changed

src/quickgui/plugin/editor/qgsquickcheckbox.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import QgsQuick 0.1 as QgsQuick
2525
Item {
2626
signal valueChanged( var value, bool isNull )
2727

28+
id: fieldItem
29+
enabled: !readOnly
2830
height: childrenRect.height
2931
anchors {
3032
right: parent.right
3133
left: parent.left
3234
}
33-
id: fieldItem
3435

3536
CheckBox {
3637
property var currentValue: value

src/quickgui/plugin/editor/qgsquickdatetime.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Item {
2828
signal valueChanged(var value, bool isNull)
2929

3030
id: fieldItem
31+
enabled: !readOnly
3132
height: childrenRect.height
3233
anchors {
3334
left: parent.left

src/quickgui/plugin/editor/qgsquickexternalresource.qml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ import QgsQuick 0.1 as QgsQuick
2222
* External Resource (Photo capture) for QGIS Attribute Form
2323
* Requires various global properties set to function, see qgsquickfeatureform Loader section
2424
* Do not use directly from Application QML
25+
* The widget is interactive which allows interactions even in readOnly state (e.g showing preview), but no edit!
2526
*/
2627
Item {
2728
signal valueChanged(var value, bool isNull)
2829

2930
property var image: image
3031
property var brokenImageSource: QgsQuick.Utils.getThemeIcon("ic_broken_image_black")
3132
property var notavailableImageSource: QgsQuick.Utils.getThemeIcon("ic_photo_notavailable_white")
33+
property real iconSize: customStyle.height * 0.75
3234

3335
id: fieldItem
36+
enabled: true // its interactive widget
3437
height: image.hasValidSource? customStyle.height * 3 : customStyle.height
3538
anchors {
3639
left: parent.left
@@ -53,7 +56,7 @@ Item {
5356

5457
id: image
5558
height: fieldItem.height
56-
sourceSize.height: height
59+
sourceSize.height: image.hasValidSource? customStyle.height * 3 : fieldItem.iconSize
5760
autoTransform: true
5861
fillMode: Image.PreserveAspectFit
5962
visible: hasValidSource
@@ -93,8 +96,8 @@ Item {
9396

9497
Button {
9598
id: deleteButton
96-
visible: fieldItem.enabled && image.hasValidSource
97-
width: customStyle.height
99+
visible: !readOnly && image.hasValidSource
100+
width: fieldItem.iconSize
98101
height: width
99102
padding: 0
100103

@@ -117,14 +120,14 @@ Item {
117120
ColorOverlay {
118121
anchors.fill: deleteIcon
119122
source: deleteIcon
120-
color: customStyle.fontColor
123+
color: customStyle.attentionColor
121124
}
122125
}
123126

124127
Button {
125128
id: imageBrowserButton
126-
visible: fieldItem.enabled
127-
width: customStyle.height
129+
visible: !readOnly
130+
width: fieldItem.iconSize
128131
height: width
129132
padding: 0
130133

@@ -153,8 +156,8 @@ Item {
153156

154157
Button {
155158
id: button
156-
visible: fieldItem.enabled
157-
width: customStyle.height
159+
visible: !readOnly
160+
width: fieldItem.iconSize
158161
height: width
159162
padding: 0
160163

src/quickgui/plugin/editor/qgsquicktextedit.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ Item {
2828
signal valueChanged(var value, bool isNull)
2929

3030
id: fieldItem
31-
31+
enabled: !readOnly
32+
height: childrenRect.height
3233
anchors {
3334
left: parent.left
3435
right: parent.right
3536
rightMargin: 10 * QgsQuick.Utils.dp
3637
}
3738

38-
height: childrenRect.height
39-
4039
TextField {
4140
id: textField
4241
height: textArea.height == 0 ? customStyle.height : 0
@@ -92,6 +91,7 @@ Item {
9291

9392
background: Rectangle {
9493
color: customStyle.backgroundColor
94+
radius: customStyle.cornerRadius
9595
}
9696

9797
onEditingFinished: {

src/quickgui/plugin/editor/qgsquickvaluemap.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ import QgsQuick 0.1 as QgsQuick
2525
*/
2626
Item {
2727
signal valueChanged(var value, bool isNull)
28-
id: fieldItem
2928

29+
id: fieldItem
30+
enabled: !readOnly
31+
height: customStyle.height
3032
anchors {
3133
left: parent.left
3234
right: parent.right
3335
rightMargin: 10 * QgsQuick.Utils.dp
3436
}
3537

36-
height: customStyle.height
37-
3838
ComboBox {
3939
id: comboBox
4040

src/quickgui/plugin/qgsquickfeatureform.qml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Item {
170170
left: parent.left
171171
right: parent.right
172172
}
173-
height: tabRow.height
173+
height: form.model.hasTabs ? tabRow.height : 0
174174

175175
flickableDirection: Flickable.HorizontalFlick
176176
contentWidth: tabRow.width
@@ -339,8 +339,6 @@ Item {
339339
height: childrenRect.height
340340
anchors { left: parent.left; right: parent.right }
341341

342-
enabled: form.state !== "ReadOnly" && !!AttributeEditable
343-
344342
property var value: AttributeValue
345343
property var config: EditorWidgetConfig
346344
property var widget: EditorWidget
@@ -349,6 +347,7 @@ Item {
349347
property var homePath: form.project ? form.project.homePath : ""
350348
property var customStyle: form.style.fields
351349
property var externalResourceHandler: form.externalResourceHandler
350+
property bool readOnly: form.state == "ReadOnly" || !AttributeEditable
352351

353352
active: widget !== 'Hidden'
354353

src/quickgui/plugin/qgsquickfeatureformstyling.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ QtObject {
5050
property color backgroundColor: "lightGray"
5151
property color backgroundColorInactive: "lightGray"
5252
property color activeColor: "#1B5E20"
53+
property color attentionColor: "red"
5354
property color normalColor: "#4CAF50"
5455
property real height: 48 * QgsQuick.Utils.dp
5556
property real cornerRadius: 0 * QgsQuick.Utils.dp

0 commit comments

Comments
 (0)