diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-04-17 22:54:53 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-17 22:59:19 -0700 |
commit | 1819cc1ccc45192359321a09bb734a4d6ca40b2d (patch) | |
tree | d8d79767a9cb83cceab35eedcfb7addfb6a28d6f /mobile-widgets/qmlmanager.cpp | |
parent | 4ac6f34b16aa404b8753d2ae1103da3605f33886 (diff) | |
download | subsurface-1819cc1ccc45192359321a09bb734a4d6ca40b2d.tar.gz |
QML UI: make the state of the GPS service available to QML
This exposes a locationServiceAvailable property to QML and keeps it in
sync with the corresponding state in the GpsLocation widget.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 3c2f8d311..4df82349c 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -72,11 +72,11 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), reply(0), deletedDive(0), deletedTrip(0), + m_updateSelectedDive(-1), + m_selectedDiveTimestamp(0), m_credentialStatus(UNKNOWN), m_lastDevicePixelRatio(1.0), - alreadySaving(false), - m_selectedDiveTimestamp(0), - m_updateSelectedDive(-1) + alreadySaving(false) { m_instance = this; connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged); @@ -88,6 +88,8 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), setAccessingCloud(-1); // create location manager service locationProvider = new GpsLocation(&appendTextToLogStandalone, this); + connect(locationProvider, SIGNAL(haveSourceChanged()), this, SLOT(hasLocationSourceChanged())); + setLocationServiceAvailable(locationProvider->hasLocationsSource()); set_git_update_cb(&gitProgressCB); // make sure we know if the current cloud repo has been successfully synced @@ -928,6 +930,14 @@ void QMLManager::addDiveAborted(int id) QString QMLManager::getCurrentPosition() { + static bool hasLocationSource = false; + if (locationProvider->hasLocationsSource() != hasLocationSource) { + hasLocationSource = !hasLocationSource; + setLocationServiceAvailable(hasLocationSource); + } + if (!hasLocationSource) + return tr("Unknown GPS location"); + return locationProvider->currentPosition(); } @@ -966,7 +976,6 @@ void QMLManager::deleteGpsFix(quint64 when) populateGpsData(); } - QString QMLManager::logText() const { QString logText = m_logText + QString("\nNumer of GPS fixes: %1").arg(locationProvider->getGpsNum()); @@ -996,6 +1005,23 @@ void QMLManager::setLocationServiceEnabled(bool locationServiceEnabled) locationProvider->serviceEnable(m_locationServiceEnabled); } +bool QMLManager::locationServiceAvailable() const +{ + return m_locationServiceAvailable; +} + +void QMLManager::setLocationServiceAvailable(bool locationServiceAvailable) +{ + qDebug() << "location service is" << (locationServiceAvailable ? "available" : "not available"); + m_locationServiceAvailable = locationServiceAvailable; + emit locationServiceAvailableChanged(); +} + +void QMLManager::hasLocationSourceChanged() +{ + setLocationServiceAvailable(locationProvider->hasLocationsSource()); +} + bool QMLManager::verboseEnabled() const { return m_verboseEnabled; |