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
71 changes: 40 additions & 31 deletions app/qml/map/MMMapController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,44 +97,53 @@ Item {
updatePosition()

switch ( state ) {
case "record": {
if ( __appSettings.autolockPosition ) { // center to GPS
if ( gpsStateGroup.state === "unavailable" ) {
__notificationModel.addError( "GPS currently unavailable." )
}
else {
root.centeredToGPS = true
Copy link
Contributor

Choose a reason for hiding this comment

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

if we moved this out of the GPS availability check, does it mean the map would re-center as soon as gps position is actually available? If yes, that could be useful, but I'm OK with merging it as it is now!

Copy link
Contributor Author

@VitorVieiraZ VitorVieiraZ Jun 19, 2024

Choose a reason for hiding this comment

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

In this scenario, it would center even if the user decides to uncheck "auto-lock" property in recording settings.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I mean like:

        if ( __appSettings.autolockPosition ) { // center to GPS
          root.centeredToGPS = true
          if ( gpsStateGroup.state === "unavailable" ) {
            __notificationModel.addError( "GPS currently unavailable." )
          }
          else {
            updatePosition()
          }
        }

updatePosition()
}
}

case "record": {
root.recordingStarted()
break
}
root.recordingStarted()
break
}

case "recordInLayer": {
root.recordInLayerFeatureStarted()
root.hideHighlight()
break
}
case "recordInLayer": {
root.recordInLayerFeatureStarted()
root.hideHighlight()
break
}

case "edit": {
root.editingGeometryStarted()
root.hideHighlight()
break
}
case "edit": {
root.editingGeometryStarted()
root.hideHighlight()
break
}

case "split": {
root.showInfoTextMessage( qsTr( "Create line to split the selected feature" ) )
root.splittingStarted()
break
}
case "split": {
root.showInfoTextMessage( qsTr( "Create line to split the selected feature" ) )
root.splittingStarted()
break
}

case "view": {
root.hideHighlight()
break
}
case "view": {
root.hideHighlight()
break
}

case "stakeout": {
root.hideHighlight()
root.stakeoutStarted( internal.stakeoutTarget )
break
}
case "stakeout": {
root.hideHighlight()
root.stakeoutStarted( internal.stakeoutTarget )
break
}

case "inactive": {
break
}
case "inactive": {
break
}
}
}

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