Skip to content

Commit

Permalink
[QgsQuick] Feature form improvements #2 (qgis#9388)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sklencar authored and wonder-sk committed Mar 6, 2019
1 parent 44847ca commit 288b5c1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/quickgui/plugin/editor/qgsquickcheckbox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import QgsQuick 0.1 as QgsQuick
Item {
signal valueChanged( var value, bool isNull )

id: fieldItem
enabled: !readOnly
height: childrenRect.height
anchors {
right: parent.right
left: parent.left
}
id: fieldItem

CheckBox {
property var currentValue: value
Expand Down
1 change: 1 addition & 0 deletions src/quickgui/plugin/editor/qgsquickdatetime.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Item {
signal valueChanged(var value, bool isNull)

id: fieldItem
enabled: !readOnly
height: childrenRect.height
anchors {
left: parent.left
Expand Down
19 changes: 11 additions & 8 deletions src/quickgui/plugin/editor/qgsquickexternalresource.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ import QgsQuick 0.1 as QgsQuick
* External Resource (Photo capture) for QGIS Attribute Form
* Requires various global properties set to function, see qgsquickfeatureform Loader section
* Do not use directly from Application QML
* The widget is interactive which allows interactions even in readOnly state (e.g showing preview), but no edit!
*/
Item {
signal valueChanged(var value, bool isNull)

property var image: image
property var brokenImageSource: QgsQuick.Utils.getThemeIcon("ic_broken_image_black")
property var notavailableImageSource: QgsQuick.Utils.getThemeIcon("ic_photo_notavailable_white")
property real iconSize: customStyle.height * 0.75

id: fieldItem
enabled: true // its interactive widget
height: image.hasValidSource? customStyle.height * 3 : customStyle.height
anchors {
left: parent.left
Expand All @@ -53,7 +56,7 @@ Item {

id: image
height: fieldItem.height
sourceSize.height: height
sourceSize.height: image.hasValidSource? customStyle.height * 3 : fieldItem.iconSize
autoTransform: true
fillMode: Image.PreserveAspectFit
visible: hasValidSource
Expand Down Expand Up @@ -93,8 +96,8 @@ Item {

Button {
id: deleteButton
visible: fieldItem.enabled && image.hasValidSource
width: customStyle.height
visible: !readOnly && image.hasValidSource
width: fieldItem.iconSize
height: width
padding: 0

Expand All @@ -117,14 +120,14 @@ Item {
ColorOverlay {
anchors.fill: deleteIcon
source: deleteIcon
color: customStyle.fontColor
color: customStyle.attentionColor
}
}

Button {
id: imageBrowserButton
visible: fieldItem.enabled
width: customStyle.height
visible: !readOnly
width: fieldItem.iconSize
height: width
padding: 0

Expand Down Expand Up @@ -153,8 +156,8 @@ Item {

Button {
id: button
visible: fieldItem.enabled
width: customStyle.height
visible: !readOnly
width: fieldItem.iconSize
height: width
padding: 0

Expand Down
6 changes: 3 additions & 3 deletions src/quickgui/plugin/editor/qgsquicktextedit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ Item {
signal valueChanged(var value, bool isNull)

id: fieldItem

enabled: !readOnly
height: childrenRect.height
anchors {
left: parent.left
right: parent.right
rightMargin: 10 * QgsQuick.Utils.dp
}

height: childrenRect.height

TextField {
id: textField
height: textArea.height == 0 ? customStyle.height : 0
Expand Down Expand Up @@ -92,6 +91,7 @@ Item {

background: Rectangle {
color: customStyle.backgroundColor
radius: customStyle.cornerRadius
}

onEditingFinished: {
Expand Down
6 changes: 3 additions & 3 deletions src/quickgui/plugin/editor/qgsquickvaluemap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import QgsQuick 0.1 as QgsQuick
*/
Item {
signal valueChanged(var value, bool isNull)
id: fieldItem

id: fieldItem
enabled: !readOnly
height: customStyle.height
anchors {
left: parent.left
right: parent.right
rightMargin: 10 * QgsQuick.Utils.dp
}

height: customStyle.height

ComboBox {
id: comboBox

Expand Down
5 changes: 2 additions & 3 deletions src/quickgui/plugin/qgsquickfeatureform.qml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Item {
left: parent.left
right: parent.right
}
height: tabRow.height
height: form.model.hasTabs ? tabRow.height : 0

flickableDirection: Flickable.HorizontalFlick
contentWidth: tabRow.width
Expand Down Expand Up @@ -339,8 +339,6 @@ Item {
height: childrenRect.height
anchors { left: parent.left; right: parent.right }

enabled: form.state !== "ReadOnly" && !!AttributeEditable

property var value: AttributeValue
property var config: EditorWidgetConfig
property var widget: EditorWidget
Expand All @@ -349,6 +347,7 @@ Item {
property var homePath: form.project ? form.project.homePath : ""
property var customStyle: form.style.fields
property var externalResourceHandler: form.externalResourceHandler
property bool readOnly: form.state == "ReadOnly" || !AttributeEditable

active: widget !== 'Hidden'

Expand Down
1 change: 1 addition & 0 deletions src/quickgui/plugin/qgsquickfeatureformstyling.qml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ QtObject {
property color backgroundColor: "lightGray"
property color backgroundColorInactive: "lightGray"
property color activeColor: "#1B5E20"
property color attentionColor: "red"
property color normalColor: "#4CAF50"
property real height: 48 * QgsQuick.Utils.dp
property real cornerRadius: 0 * QgsQuick.Utils.dp
Expand Down

0 comments on commit 288b5c1

Please sign in to comment.