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

Reintroduction of centering to GPS when starting to record new feature #3509

Merged
merged 9 commits into from
Jun 19, 2024
17 changes: 17 additions & 0 deletions app/appsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ AppSettings::AppSettings( QObject *parent ): QObject( parent )
bool autosync = settings.value( QStringLiteral( "autosyncAllowed" ), false ).toBool();
double gpsHeight = settings.value( "gpsHeight", 0 ).toDouble();
QString ignoreMigrateVersion = settings.value( QStringLiteral( "ignoreMigrateVersion" ) ).toString();
bool autolockPosition = settings.value( QStringLiteral( "autolockPosition" ), true ).toBool();

settings.endGroup();

Expand All @@ -46,6 +47,7 @@ AppSettings::AppSettings( QObject *parent ): QObject( parent )
setAutosyncAllowed( autosync );
setGpsAntennaHeight( gpsHeight );
setIgnoreMigrateVersion( ignoreMigrateVersion );
setAutolockPosition( autolockPosition );
}

QString AppSettings::defaultLayer() const
Expand Down Expand Up @@ -279,6 +281,21 @@ void AppSettings::setAutosyncAllowed( bool newAutosyncAllowed )
emit autosyncAllowedChanged( mAutosyncAllowed );
}

bool AppSettings::autolockPosition() const
{
return mAutolockPosition;
}

void AppSettings::setAutolockPosition( bool autolockPosition )
{
if ( mAutolockPosition == autolockPosition )
return;

mAutolockPosition = autolockPosition;
setValue( QStringLiteral( "autolockPosition" ), autolockPosition );
emit autolockPositionChanged( mAutolockPosition );
}

double AppSettings::gpsAntennaHeight() const
{
return mGpsAntennaHeight;
Expand Down
6 changes: 6 additions & 0 deletions app/appsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class AppSettings: public QObject
Q_PROPERTY( bool autosyncAllowed READ autosyncAllowed WRITE setAutosyncAllowed NOTIFY autosyncAllowedChanged )
Q_PROPERTY( double gpsAntennaHeight READ gpsAntennaHeight WRITE setGpsAntennaHeight NOTIFY gpsAntennaHeightChanged )
Q_PROPERTY( QString ignoreMigrateVersion READ ignoreMigrateVersion WRITE setIgnoreMigrateVersion NOTIFY ignoreMigrateVersionChanged )
Q_PROPERTY( bool autolockPosition READ autolockPosition WRITE setAutolockPosition NOTIFY autolockPositionChanged )

public:
explicit AppSettings( QObject *parent = nullptr );
Expand Down Expand Up @@ -82,6 +83,9 @@ class AppSettings: public QObject

static const QString POSITION_PROVIDERS_GROUP;

bool autolockPosition() const;
void setAutolockPosition( bool autolockPosition );

public slots:
void setReuseLastEnteredValues( bool reuseLastEnteredValues );

Expand All @@ -99,6 +103,7 @@ class AppSettings: public QObject
void activePositionProviderIdChanged( const QString & );

void autosyncAllowedChanged( bool autosyncAllowed );
void autolockPositionChanged( bool autolockPosition );

void ignoreMigrateVersionChanged();

Expand Down Expand Up @@ -132,6 +137,7 @@ class AppSettings: public QObject
QVariant value( const QString &key, const QVariant &defaultValue = QVariant() );
QString mActivePositionProviderId;
bool mAutosyncAllowed = false;
bool mAutolockPosition = true;
double mGpsAntennaHeight = 0;
QString mIgnoreMigrateVersion;
};
Expand Down
1 change: 1 addition & 0 deletions app/qml/map/MMMapController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ Item {
map: mapCanvas
positionMarkerComponent: positionMarker
recordingMapTool.centeredToGPS: root.centeredToGPS
centerToGPSOnStartup: __appSettings.autolockPosition
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved

activeFeature: root.state === "edit" ? internal.featurePairToEdit.feature : __inputUtils.emptyFeature()

Expand Down
14 changes: 14 additions & 0 deletions app/qml/map/MMRecordingTools.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Item {
required property MMPositionMarker positionMarkerComponent

property alias recordingMapTool: mapTool
property bool centerToGPSOnStartup: __appSettings.autolockPosition

property var activeFeature

Expand Down Expand Up @@ -314,6 +315,19 @@ Item {
}
}

Component.onCompleted: {
if ( root.centerToGPSOnStartup ) {
// center to GPS
if ( gpsStateGroup.state === "unavailable" ) {
__notificationModel.addError( "GPS currently unavailable." );
return;
}

root.map.mapSettings.centeredToGPS = true;
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved
root.map.mapSettings.setCenter( mapPositionSource.mapPosition );
}
}

function discardChanges() {
mapTool.discardChanges()
root.canceled()
Expand Down
11 changes: 11 additions & 0 deletions app/qml/settings/MMSettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ MMPage {
onClicked: __appSettings.autosyncAllowed = !checked
}

MMLine {}

MMSettingsComponents.MMSettingsSwitch {
width: parent.width
title: qsTr("Auto-lock position")
description: qsTr("Each time you start recording, the app centers to GPS")
checked: __appSettings.autolockPosition

onClicked: __appSettings.autolockPosition = !checked
}

Item { width: 1; height: 1 }

Text {
Expand Down
Loading