QML UI: if we don't have a current position, update it later

Once we get a new fix we asynchronously update the text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-04-14 11:12:07 -07:00
parent ca3be8f376
commit 1d95cc4cbf
3 changed files with 13 additions and 1 deletions

View file

@ -177,6 +177,12 @@ Item {
gpsText = manager.getCurrentPosition()
}
}
Connections {
target: manager
onWaitingForPositionChanged: {
gpsText = manager.getCurrentPosition()
}
}
Controls.Label {
Layout.alignment: Qt.AlignRight

View file

@ -1297,7 +1297,12 @@ QString QMLManager::getCurrentPosition()
if (!hasLocationSource)
return tr("Unknown GPS location");
return locationProvider->currentPosition();
QString positionResponse = locationProvider->currentPosition();
if (positionResponse == GPS_CURRENT_POS)
connect(locationProvider, &GpsLocation::acquiredPosition, this, &QMLManager::waitingForPositionChanged, Qt::UniqueConnection);
else
disconnect(locationProvider, &GpsLocation::acquiredPosition, this, &QMLManager::waitingForPositionChanged);
return positionResponse;
}
void QMLManager::applyGpsData()

View file

@ -280,6 +280,7 @@ signals:
void buddyListChanged();
void divemasterListChanged();
void locationListChanged();
void waitingForPositionChanged();
};
#endif