mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
4ac6f34b16
commit
1819cc1ccc
2 changed files with 37 additions and 4 deletions
|
@ -72,11 +72,11 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
||||||
reply(0),
|
reply(0),
|
||||||
deletedDive(0),
|
deletedDive(0),
|
||||||
deletedTrip(0),
|
deletedTrip(0),
|
||||||
|
m_updateSelectedDive(-1),
|
||||||
|
m_selectedDiveTimestamp(0),
|
||||||
m_credentialStatus(UNKNOWN),
|
m_credentialStatus(UNKNOWN),
|
||||||
m_lastDevicePixelRatio(1.0),
|
m_lastDevicePixelRatio(1.0),
|
||||||
alreadySaving(false),
|
alreadySaving(false)
|
||||||
m_selectedDiveTimestamp(0),
|
|
||||||
m_updateSelectedDive(-1)
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
|
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
|
||||||
|
@ -88,6 +88,8 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
||||||
setAccessingCloud(-1);
|
setAccessingCloud(-1);
|
||||||
// create location manager service
|
// create location manager service
|
||||||
locationProvider = new GpsLocation(&appendTextToLogStandalone, this);
|
locationProvider = new GpsLocation(&appendTextToLogStandalone, this);
|
||||||
|
connect(locationProvider, SIGNAL(haveSourceChanged()), this, SLOT(hasLocationSourceChanged()));
|
||||||
|
setLocationServiceAvailable(locationProvider->hasLocationsSource());
|
||||||
set_git_update_cb(&gitProgressCB);
|
set_git_update_cb(&gitProgressCB);
|
||||||
|
|
||||||
// make sure we know if the current cloud repo has been successfully synced
|
// 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()
|
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();
|
return locationProvider->currentPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,7 +976,6 @@ void QMLManager::deleteGpsFix(quint64 when)
|
||||||
populateGpsData();
|
populateGpsData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString QMLManager::logText() const
|
QString QMLManager::logText() const
|
||||||
{
|
{
|
||||||
QString logText = m_logText + QString("\nNumer of GPS fixes: %1").arg(locationProvider->getGpsNum());
|
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);
|
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
|
bool QMLManager::verboseEnabled() const
|
||||||
{
|
{
|
||||||
return m_verboseEnabled;
|
return m_verboseEnabled;
|
||||||
|
|
|
@ -17,6 +17,7 @@ class QMLManager : public QObject {
|
||||||
Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged)
|
Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged)
|
||||||
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
|
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
|
||||||
Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
|
Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
|
||||||
|
Q_PROPERTY(bool locationServiceAvailable READ locationServiceAvailable WRITE setLocationServiceAvailable NOTIFY locationServiceAvailableChanged)
|
||||||
Q_PROPERTY(int distanceThreshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
|
Q_PROPERTY(int distanceThreshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
|
||||||
Q_PROPERTY(int timeThreshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
|
Q_PROPERTY(int timeThreshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
|
||||||
Q_PROPERTY(bool loadFromCloud READ loadFromCloud WRITE setLoadFromCloud NOTIFY loadFromCloudChanged)
|
Q_PROPERTY(bool loadFromCloud READ loadFromCloud WRITE setLoadFromCloud NOTIFY loadFromCloudChanged)
|
||||||
|
@ -52,6 +53,9 @@ public:
|
||||||
bool locationServiceEnabled() const;
|
bool locationServiceEnabled() const;
|
||||||
void setLocationServiceEnabled(bool locationServiceEnable);
|
void setLocationServiceEnabled(bool locationServiceEnable);
|
||||||
|
|
||||||
|
bool locationServiceAvailable() const;
|
||||||
|
void setLocationServiceAvailable(bool locationServiceAvailable);
|
||||||
|
|
||||||
bool verboseEnabled() const;
|
bool verboseEnabled() const;
|
||||||
void setVerboseEnabled(bool verboseMode);
|
void setVerboseEnabled(bool verboseMode);
|
||||||
|
|
||||||
|
@ -133,6 +137,7 @@ public slots:
|
||||||
qreal lastDevicePixelRatio();
|
qreal lastDevicePixelRatio();
|
||||||
void appendTextToLog(const QString &newText);
|
void appendTextToLog(const QString &newText);
|
||||||
void quit();
|
void quit();
|
||||||
|
void hasLocationSourceChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_cloudUserName;
|
QString m_cloudUserName;
|
||||||
|
@ -141,6 +146,7 @@ private:
|
||||||
QString m_startPageText;
|
QString m_startPageText;
|
||||||
QString m_logText;
|
QString m_logText;
|
||||||
bool m_locationServiceEnabled;
|
bool m_locationServiceEnabled;
|
||||||
|
bool m_locationServiceAvailable;
|
||||||
bool m_verboseEnabled;
|
bool m_verboseEnabled;
|
||||||
int m_distanceThreshold;
|
int m_distanceThreshold;
|
||||||
int m_timeThreshold;
|
int m_timeThreshold;
|
||||||
|
@ -169,6 +175,7 @@ signals:
|
||||||
void cloudUserNameChanged();
|
void cloudUserNameChanged();
|
||||||
void cloudPasswordChanged();
|
void cloudPasswordChanged();
|
||||||
void locationServiceEnabledChanged();
|
void locationServiceEnabledChanged();
|
||||||
|
void locationServiceAvailableChanged();
|
||||||
void verboseEnabledChanged();
|
void verboseEnabledChanged();
|
||||||
void logTextChanged();
|
void logTextChanged();
|
||||||
void timeThresholdChanged();
|
void timeThresholdChanged();
|
||||||
|
|
Loading…
Reference in a new issue