示例#1
0
QMLManager::QMLManager() : m_locationServiceEnabled(false),
	m_verboseEnabled(false),
	reply(0),
	deletedDive(0),
	deletedTrip(0),
	m_updateSelectedDive(-1),
	m_selectedDiveTimestamp(0),
	m_credentialStatus(UNKNOWN),
	m_lastDevicePixelRatio(1.0),
	alreadySaving(false)
{
	m_instance = this;
	connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
	appendTextToLog(getUserAgent());
	appendTextToLog(QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()));
	qDebug() << "Starting" << getUserAgent();
	qDebug() << QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion());
	setStartPageText(tr("Starting..."));
	setAccessingCloud(-1);
	setShowPin(false);
	// 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
	syncLoadFromCloud();
}
示例#2
0
QGeoPositionInfoSource *GpsLocation::getGpsSource()
{
	if (haveSource == NOGPS)
		return 0;

	if (!m_GpsSource) {
		m_GpsSource = QGeoPositionInfoSource::createDefaultSource(this);
		if (m_GpsSource != 0) {
#if defined(Q_OS_IOS)
			// at least Qt 5.6.0 isn't doing things right on iOS - it MUST check for permission before
			// accessing the position source
			// I have a hacked version of Qt 5.6.0 that I will build the iOS binaries with for now;
			// this test below righ after creating the source checks if the location service is disabled
			// and set's an error right when the position source is created to indicate this
			if (m_GpsSource->error() == QGeoPositionInfoSource::AccessError) {
				haveSource = NOGPS;
				emit haveSourceChanged();
				m_GpsSource = NULL;
				return NULL;
			}
#endif
			haveSource = (m_GpsSource->supportedPositioningMethods() & QGeoPositionInfoSource::SatellitePositioningMethods) ? HAVEGPS : NOGPS;
			emit haveSourceChanged();
#ifndef SUBSURFACE_MOBILE
			if (verbose)
#endif
				status(QString("Created position source %1").arg(m_GpsSource->sourceName()));
			connect(m_GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPosition(QGeoPositionInfo)));
			connect(m_GpsSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
			connect(m_GpsSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(positionSourceError(QGeoPositionInfoSource::Error)));
			setGpsTimeThreshold(prefs.time_threshold);
		} else {
#ifdef SUBSURFACE_MOBILE
			status("don't have GPS source");
#endif
			haveSource = NOGPS;
			emit haveSourceChanged();
		}
	}
	return m_GpsSource;
}
示例#3
0
void GpsLocation::positionSourceError(QGeoPositionInfoSource::Error)
{
	status("error receiving a GPS location");
	haveSource = NOGPS;
	emit haveSourceChanged();
}