Skip to content
Permalink
Browse files

[QgsQuick] External widget changes

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 1b428a5e600dd3a0b5636fd31e806add6630256b
@@ -39,13 +39,11 @@ Item {
// Ment to be use with the save callback - stores image source
property string sourceToDelete

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

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

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

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

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

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

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

QgsQuick.IconTextItem {
id: infoItem
iconSize: fieldItem.iconSize/2
fontColor: customStyle.fields.fontColor
iconSource: fieldItem.brokenImageIcon
labelText: qsTr("Image is not available: ") + image.currentValue

Text {
id: text
height: parent.height
width: imageContainer.width - 2* fieldItem.textMargin
wrapMode: Text.WordWrap
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"
height: fieldItem.iconSize/2
anchors.bottom: parent.bottom
anchors.bottomMargin: fieldItem.textMargin
anchors.horizontalCenter: parent.horizontalCenter
}

}
@@ -376,8 +376,6 @@ Item {
property var customStyle: form.style
property var externalResourceHandler: form.externalResourceHandler
property bool readOnly: form.state == "ReadOnly" || !AttributeEditable
property var callbackOnSave: undefined
property var callbackOnCancel: undefined

active: widget !== 'Hidden'

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

0 comments on commit 1b428a5

Please sign in to comment.
You can’t perform that action at this time.