diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-04-14 11:12:07 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-04-14 13:37:44 -0700 |
commit | 1d95cc4cbfb229c55580b46512c9df1c5016247e (patch) | |
tree | d517960d69d62c706578894d26785d3d1102012d | |
parent | ca3be8f376784cedbcf9c2bf8b11d2764f82036e (diff) | |
download | subsurface-1d95cc4cbfb229c55580b46512c9df1c5016247e.tar.gz |
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>
-rw-r--r-- | mobile-widgets/qml/DiveDetailsEdit.qml | 6 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 7 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 1 |
3 files changed, 13 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml index 25c33b939..ef5d304d3 100644 --- a/mobile-widgets/qml/DiveDetailsEdit.qml +++ b/mobile-widgets/qml/DiveDetailsEdit.qml @@ -177,6 +177,12 @@ Item { gpsText = manager.getCurrentPosition() } } + Connections { + target: manager + onWaitingForPositionChanged: { + gpsText = manager.getCurrentPosition() + } + } Controls.Label { Layout.alignment: Qt.AlignRight diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index c2b2b66fd..a9c855eab 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -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() diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index dd3d48dff..b158e43ee 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -280,6 +280,7 @@ signals: void buddyListChanged(); void divemasterListChanged(); void locationListChanged(); + void waitingForPositionChanged(); }; #endif |