Skip to content

Commit

Permalink
Merge pull request #2841 from MerginMaps/photo_desktop
Browse files Browse the repository at this point in the history
Fix image picker on desktops
  • Loading branch information
PeterPetrik authored Oct 11, 2023
2 parents 6feeb57 + e1f69f7 commit df71776
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 302 deletions.
1 change: 0 additions & 1 deletion app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ set(MM_QML
NumberSpin.qml
PanelItem.qml
PanelTabButton.qml
PhotoPanel.qml
ProjectIssuesPanel.qml
ProjectLimitDialog.qml
ProjectListPage.qml
Expand Down
18 changes: 11 additions & 7 deletions app/qml/ExternalResourceBundle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs

import "." // import InputStyle singleton

Item {
Expand All @@ -23,6 +22,9 @@ Item {
// Has to be set for actions with callbacks
property var itemWidget

// Whether we have camera available on this platform
property var hasCameraCapability:__androidUtils.isAndroid || __iosUtils.isIos

/**
* Called when clicked on the camera icon to capture an image.
* \param itemWidget editorWidget for modified field to send valueChanged signal.
Expand All @@ -41,7 +43,8 @@ Item {
} else if (__iosUtils.isIos) {
__iosUtils.callCamera(itemWidget.targetDir)
} else {
itemWidget.showDefaultPanel()
// This should never happen
console.log("Camera not implemented on this platform.")
}
}

Expand All @@ -63,7 +66,7 @@ Item {
} else if (__iosUtils.isIos) {
__iosUtils.callImagePicker(itemWidget.targetDir)
} else {
fileDialog.open()
desktopGalleryPicker.open()
}
}

Expand Down Expand Up @@ -228,15 +231,16 @@ Item {
}
}

// Gallery picker
FileDialog {
id: fileDialog
id: desktopGalleryPicker
title: qsTr( "Open Image" )
visible: false
nameFilters: [ qsTr( "Image files (*.gif *.png *.jpg)" ) ]
//width: window.width
//height: window.height
currentFolder: __inputUtils.imageGalleryLocation()
onAccepted: externalResourceHandler.imageSelected(fileDialog.fileUrl)
onAccepted: {
externalResourceHandler.imageSelected(selectedFile)
}
}

MessageDialog {
Expand Down
260 changes: 0 additions & 260 deletions app/qml/PhotoPanel.qml

This file was deleted.

37 changes: 3 additions & 34 deletions app/qml/editor/inputexternalresource.qml
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,6 @@ Item {
externalResourceHandler.onFormCanceled(fieldItem)
}

function showDefaultPanel() {
if (!photoCapturePanelLoader.item) {
// Load the photo capture panel if not loaded yet
photoCapturePanelLoader.setSource("qrc:/PhotoPanel.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
Expand All @@ -126,17 +110,6 @@ Item {
}
]

Loader {
id: photoCapturePanelLoader
}

Connections {
target: photoCapturePanelLoader.item
function onConfirmButtonClicked( path, filename ) {
externalResourceHandler.confirmImage(fieldItem, path, filename)
}
}

Rectangle {
id: imageContainer
width: parent.width
Expand Down Expand Up @@ -234,7 +207,7 @@ Item {
iconSource: fieldItem.cameraIcon
iconSize: buttonsContainer.itemHeight
labelText: qsTr("Take a photo")
visible: !readOnly && fieldItem.state !== " valid"
visible: !readOnly && fieldItem.state !== " valid" && externalResourceHandler.hasCameraCapability

Layout.preferredHeight: parent.height
Layout.fillWidth: true
Expand All @@ -243,18 +216,14 @@ Item {
MouseArea {
anchors.fill: parent
onClicked: {
if (externalResourceHandler.capturePhoto) {
externalResourceHandler.capturePhoto(fieldItem)
} else {
showDefaultPanel()
}
externalResourceHandler.capturePhoto(fieldItem)
}
}
}

Item {
id: lineContainer
visible: !readOnly && fieldItem.state !== " valid"
visible: photoButton.visible
Layout.fillWidth: true
Layout.preferredHeight: parent.height
Layout.preferredWidth: line.width * 2
Expand Down

0 comments on commit df71776

Please sign in to comment.