Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photo editor fixes #3459

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/qml/form/components/photo/MMPhotoAttachment.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideMiddle

visible: root.enabled
}
}

Expand Down Expand Up @@ -95,6 +97,8 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideMiddle

visible: root.enabled
}
}

Expand Down
23 changes: 11 additions & 12 deletions app/qml/form/editors/MMFormPhotoEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ MMFormPhotoViewer {
photoUrl: internal.absoluteImagePath
hasCameraCapability: __androidUtils.isAndroid || __iosUtils.isIos

on_FieldValueChanged: internal.calculateAbsoluteImagePath()
on_FieldValueChanged: internal.setAbsoluteImagePath()
on_FieldValueIsNullChanged: internal.setAbsoluteImagePath()

onCapturePhotoClicked: internal.capturePhoto()
onChooseFromGalleryClicked: internal.chooseFromGallery()
Expand Down Expand Up @@ -200,27 +201,25 @@ MMFormPhotoViewer {

property string imageSourceToDelete // used to postpone image deletion to when the form is saved

function calculateAbsoluteImagePath() {
//
// Sets path of the assigned photo to the absoluteImagePath.
// - absoluteImagePath is the actual path on the device and is used by QML Image to show the image
//
function setAbsoluteImagePath() {
let absolutePath = __inputUtils.getAbsolutePath( root._fieldValue, internal.prefixToRelativePath )

if ( root.photoComponent.status === Image.Error ) {
root.photoState = "notAvailable"
if ( !root._fieldValue || root._fieldValueIsNull ) {
root.photoState = "notSet"
absoluteImagePath = ""
return
}
else if ( root._fieldValue && __inputUtils.fileExists( absolutePath ) ) {
root.photoState = "valid"
absoluteImagePath = "file://" + absolutePath
return
}
else if ( !root._fieldValue || root._fieldValueIsNullfield ) {
root.photoState = "notSet"
else {
root.photoState = "notAvailable"
absoluteImagePath = ""
return
}

root.photoState = "notAvailable"
absoluteImagePath = "file://" + absolutePath
}

/**
Expand Down
Loading