Skip to content
Permalink
Browse files

[QgsQuick] Use generic function onImageCapture otherwise use default …

…PhotoPanel
  • Loading branch information
vsklencar authored and wonder-sk committed Jan 22, 2020
1 parent 1773270 commit 36e773f0eeec2c078858b1023a28a580ceb16373
@@ -118,6 +118,22 @@ Item {
return (prefix) ? prefix + "/" + pathFromValue : pathFromValue
}

function showDefaultPanel() {
if (!photoCapturePanelLoader.item) {
// Load the photo capture panel if not loaded yet
photoCapturePanelLoader.setSource("qgsquickphotopanel.qml")
photoCapturePanelLoader.item.height = window.height
photoCapturePanelLoader.item.width = window.width
photoCapturePanelLoader.item.edge = Qt.RightEdge
photoCapturePanelLoader.item.imageButtonSize = fieldItem.iconSize
photoCapturePanelLoader.item.backButtonSource = fieldItem.backIcon
}
photoCapturePanelLoader.item.visible = true
photoCapturePanelLoader.item.targetDir = targetDir
photoCapturePanelLoader.item.prefixToRelativePath = prefixToRelativePath
photoCapturePanelLoader.item.fieldItem = fieldItem
}

id: fieldItem
enabled: true // its interactive widget
height: customStyle.fields.height * 3
@@ -259,20 +275,11 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
var photoCapturePanel = photoCapturePanelLoader.item
if (!photoCapturePanelLoader.item) {
// Load the photo capture panel if not loaded yet
photoCapturePanelLoader.setSource("qgsquickphotopanel.qml")
photoCapturePanelLoader.item.height = window.height
photoCapturePanelLoader.item.width = window.width
photoCapturePanelLoader.item.edge = Qt.RightEdge
photoCapturePanelLoader.item.imageButtonSize = fieldItem.iconSize
photoCapturePanelLoader.item.backButtonSource = fieldItem.backIcon
if (externalResourceHandler.capturePhoto) {
externalResourceHandler.capturePhoto(fieldItem)
} else {
showDefaultPanel()
}
photoCapturePanelLoader.item.visible = true
photoCapturePanelLoader.item.targetDir = targetDir
photoCapturePanelLoader.item.prefixToRelativePath = prefixToRelativePath
photoCapturePanelLoader.item.fieldItem = fieldItem
}
}
}
@@ -41,6 +41,13 @@ Item {
*/
property var externalResourceHandler: QtObject {

/**
* Called when clicked on the camera icon to capture an image.
* \param itemWidget editorWidget for modified field to send valueChanged signal.
*/
property var capturePhoto: function captureImage(itemWidget) {
}

/**
* Called when clicked on the gallery icon to choose a file in a gallery.
* \param itemWidget editorWidget for modified field to send valueChanged signal.

0 comments on commit 36e773f

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