Skip to content

Commit

Permalink
[QgsQuick] External widget changes
Browse files Browse the repository at this point in the history
Simplified callbacks for onSaved/onCanceled form
Some design fixes.
  • Loading branch information
vsklencar authored and wonder-sk committed Apr 24, 2019
1 parent 0375ce4 commit 1b428a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
43 changes: 22 additions & 21 deletions src/quickgui/plugin/editor/qgsquickexternalresource.qml
Expand Up @@ -39,13 +39,11 @@ Item {
// Ment to be use with the save callback - stores image source // Ment to be use with the save callback - stores image source
property string sourceToDelete property string sourceToDelete


Component.onCompleted: { function callbackOnSave() {
callbackOnSave = function() { externalResourceHandler.onFormSave(fieldItem)
externalResourceHandler.onFormSave(fieldItem) }
} function callbackOnCancel() {
callbackOnCancel = function() { externalResourceHandler.onFormCanceled(fieldItem)
externalResourceHandler.onFormCanceled(fieldItem)
}
} }


id: fieldItem id: fieldItem
Expand Down Expand Up @@ -129,13 +127,14 @@ Item {


Button { Button {
id: deleteButton id: deleteButton
visible: !readOnly && fieldItem.state === "valid" visible: !readOnly && fieldItem.state !== "notSet"
width: fieldItem.iconSize width: buttonsContainer.itemHeight
height: width height: width
padding: 0 padding: 0


anchors.right: imageContainer.right anchors.right: imageContainer.right
anchors.bottom: imageContainer.bottom anchors.bottom: imageContainer.bottom
anchors.margins: buttonsContainer.itemHeight/4


onClicked: externalResourceHandler.removeImage(fieldItem, homePath + "/" + image.currentValue) onClicked: externalResourceHandler.removeImage(fieldItem, homePath + "/" + image.currentValue)


Expand Down Expand Up @@ -163,7 +162,7 @@ Item {
anchors.centerIn: imageContainer anchors.centerIn: imageContainer
anchors.fill: imageContainer anchors.fill: imageContainer
anchors.margins: fieldItem.textMargin anchors.margins: fieldItem.textMargin
visible: fieldItem.state !== "valid" visible: fieldItem.state === "notSet"


anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Expand Down Expand Up @@ -216,18 +215,20 @@ Item {
} }
} }


QgsQuick.IconTextItem { Text {
id: infoItem id: text
iconSize: fieldItem.iconSize/2 height: parent.height
fontColor: customStyle.fields.fontColor width: imageContainer.width - 2* fieldItem.textMargin
iconSource: fieldItem.brokenImageIcon wrapMode: Text.WordWrap
labelText: qsTr("Image is not available: ") + image.currentValue minimumPixelSize: 50 * QgsQuick.Utils.dp

text: qsTr("Image is not available: ") + image.currentValue
font.pixelSize: buttonsContainer.itemHeight * 0.75
color: customStyle.fields.fontColor
anchors.leftMargin: buttonsContainer.itemHeight + fieldItem.textMargin
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
visible: fieldItem.state === "notAvailable" visible: fieldItem.state === "notAvailable"
height: fieldItem.iconSize/2
anchors.bottom: parent.bottom
anchors.bottomMargin: fieldItem.textMargin
anchors.horizontalCenter: parent.horizontalCenter
} }


} }
10 changes: 4 additions & 6 deletions src/quickgui/plugin/qgsquickfeatureform.qml
Expand Up @@ -376,8 +376,6 @@ Item {
property var customStyle: form.style property var customStyle: form.style
property var externalResourceHandler: form.externalResourceHandler property var externalResourceHandler: form.externalResourceHandler
property bool readOnly: form.state == "ReadOnly" || !AttributeEditable property bool readOnly: form.state == "ReadOnly" || !AttributeEditable
property var callbackOnSave: undefined
property var callbackOnCancel: undefined


active: widget !== 'Hidden' active: widget !== 'Hidden'


Expand All @@ -395,8 +393,8 @@ Item {
target: form target: form
ignoreUnknownSignals: true ignoreUnknownSignals: true
onSaved: { onSaved: {
if (attributeEditorLoader.widget === "ExternalResource") { if (typeof attributeEditorLoader.item.callbackOnSave === "function") {
attributeEditorLoader.callbackOnSave() attributeEditorLoader.item.callbackOnSave()
} }
} }
} }
Expand All @@ -405,8 +403,8 @@ Item {
target: form target: form
ignoreUnknownSignals: true ignoreUnknownSignals: true
onCanceled: { onCanceled: {
if (attributeEditorLoader.widget === "ExternalResource") { if (typeof attributeEditorLoader.item.callbackOnCancel === "function") {
attributeEditorLoader.callbackOnCancel() attributeEditorLoader.item.callbackOnCancel()
} }
} }
} }
Expand Down

0 comments on commit 1b428a5

Please sign in to comment.