Skip to content

Commit 1b428a5

Browse files
vsklencarwonder-sk
vsklencar
authored andcommitted
[QgsQuick] External widget changes
Simplified callbacks for onSaved/onCanceled form Some design fixes.
1 parent 0375ce4 commit 1b428a5

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

src/quickgui/plugin/editor/qgsquickexternalresource.qml

+22-21
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ Item {
3939
// Ment to be use with the save callback - stores image source
4040
property string sourceToDelete
4141

42-
Component.onCompleted: {
43-
callbackOnSave = function() {
44-
externalResourceHandler.onFormSave(fieldItem)
45-
}
46-
callbackOnCancel = function() {
47-
externalResourceHandler.onFormCanceled(fieldItem)
48-
}
42+
function callbackOnSave() {
43+
externalResourceHandler.onFormSave(fieldItem)
44+
}
45+
function callbackOnCancel() {
46+
externalResourceHandler.onFormCanceled(fieldItem)
4947
}
5048

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

130128
Button {
131129
id: deleteButton
132-
visible: !readOnly && fieldItem.state === "valid"
133-
width: fieldItem.iconSize
130+
visible: !readOnly && fieldItem.state !== "notSet"
131+
width: buttonsContainer.itemHeight
134132
height: width
135133
padding: 0
136134

137135
anchors.right: imageContainer.right
138136
anchors.bottom: imageContainer.bottom
137+
anchors.margins: buttonsContainer.itemHeight/4
139138

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

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

168167
anchors.horizontalCenter: parent.horizontalCenter
169168
anchors.verticalCenter: parent.verticalCenter
@@ -216,18 +215,20 @@ Item {
216215
}
217216
}
218217

219-
QgsQuick.IconTextItem {
220-
id: infoItem
221-
iconSize: fieldItem.iconSize/2
222-
fontColor: customStyle.fields.fontColor
223-
iconSource: fieldItem.brokenImageIcon
224-
labelText: qsTr("Image is not available: ") + image.currentValue
225-
218+
Text {
219+
id: text
220+
height: parent.height
221+
width: imageContainer.width - 2* fieldItem.textMargin
222+
wrapMode: Text.WordWrap
223+
minimumPixelSize: 50 * QgsQuick.Utils.dp
224+
text: qsTr("Image is not available: ") + image.currentValue
225+
font.pixelSize: buttonsContainer.itemHeight * 0.75
226+
color: customStyle.fields.fontColor
227+
anchors.leftMargin: buttonsContainer.itemHeight + fieldItem.textMargin
228+
horizontalAlignment: Text.AlignHCenter
229+
verticalAlignment: Text.AlignVCenter
230+
elide: Text.ElideRight
226231
visible: fieldItem.state === "notAvailable"
227-
height: fieldItem.iconSize/2
228-
anchors.bottom: parent.bottom
229-
anchors.bottomMargin: fieldItem.textMargin
230-
anchors.horizontalCenter: parent.horizontalCenter
231232
}
232233

233234
}

src/quickgui/plugin/qgsquickfeatureform.qml

+4-6
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,6 @@ Item {
376376
property var customStyle: form.style
377377
property var externalResourceHandler: form.externalResourceHandler
378378
property bool readOnly: form.state == "ReadOnly" || !AttributeEditable
379-
property var callbackOnSave: undefined
380-
property var callbackOnCancel: undefined
381379

382380
active: widget !== 'Hidden'
383381

@@ -395,8 +393,8 @@ Item {
395393
target: form
396394
ignoreUnknownSignals: true
397395
onSaved: {
398-
if (attributeEditorLoader.widget === "ExternalResource") {
399-
attributeEditorLoader.callbackOnSave()
396+
if (typeof attributeEditorLoader.item.callbackOnSave === "function") {
397+
attributeEditorLoader.item.callbackOnSave()
400398
}
401399
}
402400
}
@@ -405,8 +403,8 @@ Item {
405403
target: form
406404
ignoreUnknownSignals: true
407405
onCanceled: {
408-
if (attributeEditorLoader.widget === "ExternalResource") {
409-
attributeEditorLoader.callbackOnCancel()
406+
if (typeof attributeEditorLoader.item.callbackOnCancel === "function") {
407+
attributeEditorLoader.item.callbackOnCancel()
410408
}
411409
}
412410
}

0 commit comments

Comments
 (0)