From 1d95cc4cbfb229c55580b46512c9df1c5016247e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 14 Apr 2018 11:12:07 -0700 Subject: 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 --- mobile-widgets/qml/DiveDetailsEdit.qml | 6 ++++++ mobile-widgets/qmlmanager.cpp | 7 ++++++- mobile-widgets/qmlmanager.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2