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

Add QField camera UI to toggle geotagging #4685

Merged
merged 1 commit into from
Oct 24, 2023
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
33 changes: 31 additions & 2 deletions src/qml/imports/QFieldControls/+Qt5/QFieldCamera.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Window 2.14
import QtMultimedia 5.14
import Qt.labs.settings 1.0

import org.qfield 1.0

Expand Down Expand Up @@ -40,6 +41,11 @@ Popup {
}
}

Settings {
id: settings
property bool geoTagging: true
}

Page {
width: parent.width
height: parent.height
Expand Down Expand Up @@ -253,7 +259,9 @@ Popup {
}
} else if (cameraItem.state == "PhotoPreview" || cameraItem.state == "VideoPreview") {
if (cameraItem.state == "PhotoPreview") {
FileUtils.addImageMetadata(currentPath, positionSource.positionInformation)
if (settings.geoTagging && positionSource.active) {
FileUtils.addImageMetadata(currentPath, positionSource.positionInformation)
}
}
cameraItem.finished(currentPath)
}
Expand Down Expand Up @@ -361,7 +369,7 @@ Popup {

iconSource: Theme.getThemeIcon("ic_chevron_left_white_24dp")
iconColor: "white"
bgcolor: Qt.hsla(Theme.darkGray.hslHue, Theme.darkGray.hslSaturation, Theme.darkGray.hslLightness, 0.5)
bgcolor: Theme.darkGraySemiOpaque
round: true

onClicked: {
Expand All @@ -376,5 +384,26 @@ Popup {
}
}
}

QfToolButton {
id: geotagButton

anchors.left: parent.left
anchors.leftMargin: 4
anchors.top: backButton.bottom
anchors.topMargin: 4

iconSource: positionSource.active ? Theme.getThemeIcon("ic_geotag_24dp") : Theme.getThemeIcon("ic_geotag_missing_24dp")
iconColor: positionSource.active && settings.geoTagging ? Theme.mainColor : "white"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
iconColor: positionSource.active && settings.geoTagging ? Theme.mainColor : "white"
iconColor: positionSource.active && settings.geoTagging ? Theme.mainColor : Theme.lightColor

Isn't it better to avoid mixing themed and hardcoded colors?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, not really. I mean, we could have Theme.white, but I feel like it's not gaining much.

This specific color doesn't change across our light/dark theme either.

If we want to say have something like Theme.defaultToolButttonColor (being white) I suggest we do that in a separate PR as it'll touch a dozen QML files or so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the idea is that if we decide to add another color theme in the future, we are not sure if the white will remain white. Probably your suggestion to have Theme.defaultToolButttonColor is even better. Lets merge like this for now.

bgcolor: Theme.darkGraySemiOpaque
round: true

onClicked: {
if (positionSource.active) {
settings.geoTagging = !settings.geoTagging
displayToast(settings.geoTagging ? qsTr("Geotagging enabled") : qsTr("Geotagging disabled"))
}
}
}
}
}
31 changes: 30 additions & 1 deletion src/qml/imports/QFieldControls/+Qt6/QFieldCamera.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Window
import QtMultimedia
import Qt.labs.settings

import Theme 1.0

Expand Down Expand Up @@ -38,6 +39,11 @@ Popup {
}
}

Settings {
id: settings
property bool geoTagging: true
}

Page {
width: parent.width
height: parent.height
Expand Down Expand Up @@ -217,7 +223,9 @@ Popup {
}
} else if (cameraItem.state == "PhotoPreview" || cameraItem.state == "VideoPreview") {
if (cameraItem.state == "PhotoPreview") {
FileUtils.addImageMetadata(currentPath, positionSource.positionInformation)
if (settings.geoTagging && positionSource.active) {
FileUtils.addImageMetadata(currentPath, positionSource.positionInformation)
}
}
cameraItem.finished(currentPath)
}
Expand Down Expand Up @@ -339,5 +347,26 @@ Popup {
}
}
}

QfToolButton {
id: geotagButton

anchors.left: parent.left
anchors.leftMargin: 4
anchors.top: backButton.bottom
anchors.topMargin: 4

iconSource: positionSource.active ? Theme.getThemeIcon("ic_geotag_24dp") : Theme.getThemeIcon("ic_geotag_missing_24dp")
iconColor: positionSource.active && settings.geoTagging ? Theme.mainColor : "white"
nirvn marked this conversation as resolved.
Show resolved Hide resolved
bgcolor: Theme.darkGraySemiOpaque
round: true

onClicked: {
if (positionSource.active) {
settings.geoTagging = !settings.geoTagging
displayToast(settings.geoTagging ? qsTr("Geotagging enabled") : qsTr("Geotagging disabled"))
}
}
}
}
}
Loading