From 78a270452ad101dd2c266a6ecab5167134055d40 Mon Sep 17 00:00:00 2001 From: "viktor.sklencar@lutraconsulting.co.uk" Date: Fri, 5 Jan 2018 13:58:53 +0100 Subject: [PATCH] Bug fixing of photopanel - related to qgis-mobile #19 #20 issues. --- .../editor/qgsquickexternalresource.qml | 33 +++++++++---------- src/quickgui/plugin/qgsquickphotopanel.qml | 5 +++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/quickgui/plugin/editor/qgsquickexternalresource.qml b/src/quickgui/plugin/editor/qgsquickexternalresource.qml index 754c69b161d5..e4e3479357f8 100644 --- a/src/quickgui/plugin/editor/qgsquickexternalresource.qml +++ b/src/quickgui/plugin/editor/qgsquickexternalresource.qml @@ -6,6 +6,9 @@ import QgisQuick 1.0 as QgsQuick Item { signal valueChanged(var value, bool isNull) + property var image: image + + id: fieldItem anchors.left: parent.left anchors.right: parent.right @@ -19,14 +22,17 @@ Item { autoTransform: true fillMode: Image.PreserveAspectFit - source: { - if (image.status === Image.Error) - QgsQuick.Utils.getThemeIcon("ic_broken_image_black_24dp") - else if (image.currentValue && QgsQuick.Utils.fileExists(homePath + "/" + image.currentValue)) { - homePath + "/" + image.currentValue - } - else - QgsQuick.Utils.getThemeIcon("ic_photo_notavailable_white_48dp") + Component.onCompleted: image.source = getSource() + + function getSource() { + if (image.status === Image.Error) + return QgsQuick.Utils.getThemeIcon("ic_broken_image_black_24dp") + else if (image.currentValue && QgsQuick.Utils.fileExists(homePath + "/" + image.currentValue)) { + return homePath + "/" + image.currentValue + } + else { + return QgsQuick.Utils.getThemeIcon("ic_photo_notavailable_white_48dp") + } } } @@ -41,6 +47,7 @@ Item { onClicked: { photoCapturePanel.visible = true photoCapturePanel.targetDir = homePath + photoCapturePanel.fieldItem = fieldItem } background: Image { @@ -49,14 +56,4 @@ Item { height: button.height } } - - Connections { - target: photoCapturePanel - onVisibleChanged : { - if (!photoCapturePanel.visible && photoCapturePanel.lastPhotoName !== "") { - image.source = homePath + "/" + photoCapturePanel.lastPhotoName - valueChanged(photoCapturePanel.lastPhotoName, photoCapturePanel.lastPhotoName === "" || photoCapturePanel.lastPhotoName === null) - } - } - } } diff --git a/src/quickgui/plugin/qgsquickphotopanel.qml b/src/quickgui/plugin/qgsquickphotopanel.qml index c614165e75a0..2e6d8ae38953 100644 --- a/src/quickgui/plugin/qgsquickphotopanel.qml +++ b/src/quickgui/plugin/qgsquickphotopanel.qml @@ -25,6 +25,7 @@ Drawer { property var targetDir property var lastPhotoName property int iconSize: photoPanel.width/30 + property var fieldItem id: photoPanel visible: false @@ -199,6 +200,10 @@ Drawer { captureItem.saveImage = true photoPanel.visible = false photoPanel.lastPhotoName = QgsQuick.Utils.getFileName(camera.imageCapture.capturedImagePath) + if (photoPanel.lastPhotoName !== "") { + fieldItem.image.source = photoPanel.targetDir + "/" + photoPanel.lastPhotoName + fieldItem.valueChanged(photoPanel.lastPhotoName, photoPanel.lastPhotoName === "" || photoPanel.lastPhotoName === null) + } } } }