mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Subsurface-mobile: don't create the GPS source until it is needed
This should accelerate the startup of the UI a little more. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f6ae8bf3ea
commit
2311bc2378
2 changed files with 24 additions and 10 deletions
|
@ -19,8 +19,19 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent)
|
||||||
// create a QSettings object that's separate from the main application settings
|
// create a QSettings object that's separate from the main application settings
|
||||||
geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope,
|
geoSettings = new QSettings(QSettings::NativeFormat, QSettings::UserScope,
|
||||||
QString("org.subsurfacedivelog"), QString("subsurfacelocation"), this);
|
QString("org.subsurfacedivelog"), QString("subsurfacelocation"), this);
|
||||||
gpsSource = QGeoPositionInfoSource::createDefaultSource(parent);
|
userAgent = getUserAgent();
|
||||||
|
}
|
||||||
|
|
||||||
|
QGeoPositionInfoSource *GpsLocation::getGpsSource()
|
||||||
|
{
|
||||||
|
static QGeoPositionInfoSource *gpsSource = NULL;
|
||||||
|
static bool initGpsSource = false;
|
||||||
|
|
||||||
|
if (!initGpsSource) {
|
||||||
|
gpsSource = QGeoPositionInfoSource::createDefaultSource(this);
|
||||||
|
initGpsSource = true;
|
||||||
if (gpsSource != 0) {
|
if (gpsSource != 0) {
|
||||||
|
status("created GPS source");
|
||||||
QString msg = QString("have position source %1").arg(gpsSource->sourceName());
|
QString msg = QString("have position source %1").arg(gpsSource->sourceName());
|
||||||
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
|
||||||
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
connect(gpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
|
||||||
|
@ -28,16 +39,19 @@ GpsLocation::GpsLocation(void (*showMsgCB)(const char *), QObject *parent)
|
||||||
} else {
|
} else {
|
||||||
status("don't have GPS source");
|
status("don't have GPS source");
|
||||||
}
|
}
|
||||||
userAgent = getUserAgent();
|
}
|
||||||
|
return gpsSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GpsLocation::hasLocationsSource()
|
bool GpsLocation::hasLocationsSource()
|
||||||
{
|
{
|
||||||
|
QGeoPositionInfoSource *gpsSource = getGpsSource();
|
||||||
return gpsSource != 0 && (gpsSource->supportedPositioningMethods() & QGeoPositionInfoSource::SatellitePositioningMethods);
|
return gpsSource != 0 && (gpsSource->supportedPositioningMethods() & QGeoPositionInfoSource::SatellitePositioningMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpsLocation::serviceEnable(bool toggle)
|
void GpsLocation::serviceEnable(bool toggle)
|
||||||
{
|
{
|
||||||
|
QGeoPositionInfoSource *gpsSource = getGpsSource();
|
||||||
if (!gpsSource) {
|
if (!gpsSource) {
|
||||||
if (toggle)
|
if (toggle)
|
||||||
status("Can't start location service, no location source available");
|
status("Can't start location service, no location source available");
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGeoPositionInfo lastPos;
|
QGeoPositionInfo lastPos;
|
||||||
QGeoPositionInfoSource *gpsSource;
|
QGeoPositionInfoSource *getGpsSource();
|
||||||
void status(QString msg);
|
void status(QString msg);
|
||||||
QSettings *geoSettings;
|
QSettings *geoSettings;
|
||||||
QNetworkReply *reply;
|
QNetworkReply *reply;
|
||||||
|
|
Loading…
Add table
Reference in a new issue