Commit 34db4734 authored by pvuorela's avatar pvuorela

[nemo-qml-plugin-systemsettings] Refactor location settings. Contributes to JB#47257

Adjusted for better maintainability.
- Api addition: pendingAgreements tells which location services
are missing acceptance on currently set location mode
- Some code moved around for grouping both deprecated parts and
location services together
- Yandex locator enabled setting removed, was copy-paste detail from
mls which has both offline and online variants.
- agps_providers on settings file didn't appear used by anything. Removed.
- Removed writing deprecated keys, only need to read them (if even that).
- Simplified lots of things
parent d469f881
This diff is collapsed.
......@@ -37,34 +37,38 @@
#include <QObject>
#include <QString>
#include <QStringList>
#define LOCATION_SETTINGS_LAST_DATA_SOURCE_BIT 31
// The settings component here expects two types of usage for modifications.
// Either locationMode to high level location types, after which pendingAgreements tells
// which location services need to be explicitly turned on to ensure the usage agreement is acknowledged.
// Or setting location mode to custom, and modifying specific details.
class LocationSettingsPrivate;
class SYSTEMSETTINGS_EXPORT LocationSettings : public QObject
{
Q_OBJECT
Q_PROPERTY(bool locationEnabled READ locationEnabled WRITE setLocationEnabled NOTIFY locationEnabledChanged)
Q_PROPERTY(LocationMode locationMode READ locationMode WRITE setLocationMode NOTIFY locationModeChanged)
Q_PROPERTY(QStringList pendingAgreements READ pendingAgreements NOTIFY pendingAgreementsChanged)
Q_PROPERTY(DataSources allowedDataSources READ allowedDataSources WRITE setAllowedDataSources NOTIFY allowedDataSourcesChanged)
Q_PROPERTY(bool gpsAvailable READ gpsAvailable CONSTANT)
Q_PROPERTY(bool gpsEnabled READ gpsEnabled WRITE setGpsEnabled NOTIFY gpsEnabledChanged)
Q_PROPERTY(bool gpsFlightMode READ gpsFlightMode WRITE setGpsFlightMode NOTIFY gpsFlightModeChanged)
Q_PROPERTY(bool gpsAvailable READ gpsAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState hereState READ hereState WRITE setHereState NOTIFY hereStateChanged)
Q_PROPERTY(bool hereAvailable READ hereAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState hereState READ hereState WRITE setHereState NOTIFY hereStateChanged)
Q_PROPERTY(bool mlsAvailable READ mlsAvailable CONSTANT)
Q_PROPERTY(bool mlsEnabled READ mlsEnabled WRITE setMlsEnabled NOTIFY mlsEnabledChanged)
Q_PROPERTY(OnlineAGpsState mlsOnlineState READ mlsOnlineState WRITE setMlsOnlineState NOTIFY mlsOnlineStateChanged)
Q_PROPERTY(bool mlsAvailable READ mlsAvailable CONSTANT)
Q_PROPERTY(bool yandexLocatorEnabled READ yandexLocatorEnabled WRITE setYandexLocatorEnabled NOTIFY yandexLocatorEnabledChanged)
Q_PROPERTY(OnlineAGpsState yandexLocatorOnlineState READ yandexLocatorOnlineState WRITE setYandexLocatorOnlineState NOTIFY yandexLocatorOnlineStateChanged)
Q_PROPERTY(bool yandexLocatorAvailable READ yandexLocatorAvailable CONSTANT)
Q_PROPERTY(LocationMode locationMode READ locationMode WRITE setLocationMode NOTIFY locationModeChanged)
Q_PROPERTY(DataSources allowedDataSources READ allowedDataSources WRITE setAllowedDataSources NOTIFY allowedDataSourcesChanged)
Q_PROPERTY(bool yandexAvailable READ yandexAvailable CONSTANT)
Q_PROPERTY(OnlineAGpsState yandexOnlineState READ yandexOnlineState WRITE setYandexOnlineState NOTIFY yandexOnlineStateChanged)
Q_ENUMS(OnlineAGpsState)
Q_ENUMS(LocationMode)
......@@ -75,41 +79,12 @@ public:
SynchronousMode
};
explicit LocationSettings(QObject *parent = 0);
explicit LocationSettings(Mode mode, QObject *parent = 0);
virtual ~LocationSettings();
bool locationEnabled() const;
void setLocationEnabled(bool enabled);
bool gpsEnabled() const;
void setGpsEnabled(bool enabled);
bool gpsFlightMode() const;
void setGpsFlightMode(bool flightMode);
bool gpsAvailable() const;
enum OnlineAGpsState {
OnlineAGpsAgreementNotAccepted,
OnlineAGpsDisabled,
OnlineAGpsEnabled
};
OnlineAGpsState hereState() const;
void setHereState(OnlineAGpsState state);
bool hereAvailable() const;
bool mlsEnabled() const;
void setMlsEnabled(bool enabled);
OnlineAGpsState mlsOnlineState() const;
void setMlsOnlineState(OnlineAGpsState state);
bool mlsAvailable() const;
bool yandexLocatorEnabled() const;
void setYandexLocatorEnabled(bool enabled);
OnlineAGpsState yandexLocatorOnlineState() const;
void setYandexLocatorOnlineState(OnlineAGpsState state);
bool yandexLocatorAvailable() const;
enum LocationMode {
HighAccuracyMode,
BatterySavingMode,
......@@ -117,9 +92,6 @@ public:
CustomMode
};
LocationMode locationMode() const;
void setLocationMode(LocationMode locationMode);
// Data sources are grouped roughly by type,
// with gaps left for future expansion.
enum DataSource {
......@@ -144,6 +116,37 @@ public:
Q_DECLARE_FLAGS(DataSources, DataSource)
Q_FLAG(DataSources)
explicit LocationSettings(QObject *parent = 0);
explicit LocationSettings(Mode mode, QObject *parent = 0);
virtual ~LocationSettings();
bool locationEnabled() const;
void setLocationEnabled(bool enabled);
bool gpsEnabled() const;
void setGpsEnabled(bool enabled);
bool gpsFlightMode() const;
void setGpsFlightMode(bool flightMode);
bool gpsAvailable() const;
OnlineAGpsState hereState() const;
void setHereState(OnlineAGpsState state);
bool hereAvailable() const;
bool mlsEnabled() const;
void setMlsEnabled(bool enabled);
OnlineAGpsState mlsOnlineState() const;
void setMlsOnlineState(OnlineAGpsState state);
bool mlsAvailable() const;
OnlineAGpsState yandexOnlineState() const;
void setYandexOnlineState(OnlineAGpsState state);
bool yandexAvailable() const;
LocationMode locationMode() const;
void setLocationMode(LocationMode locationMode);
QStringList pendingAgreements() const;
DataSources allowedDataSources() const;
void setAllowedDataSources(DataSources dataSources);
......@@ -154,9 +157,9 @@ signals:
void gpsFlightModeChanged();
void mlsEnabledChanged();
void mlsOnlineStateChanged();
void yandexLocatorEnabledChanged();
void yandexLocatorOnlineStateChanged();
void yandexOnlineStateChanged();
void locationModeChanged();
void pendingAgreementsChanged();
void allowedDataSourcesChanged();
private:
......
......@@ -38,6 +38,7 @@
#include <QDBusInterface>
#include <QVariant>
#include <QString>
#include <QStringList>
#include <sailfishkeyprovider_processmutex.h>
......@@ -60,22 +61,22 @@ public:
LocationSettings::LocationMode calculateLocationMode() const;
void writeSettings();
void removePendingAgreement(const QString &agreement);
bool mlsAvailable() const;
bool yandexLocatorAvailable() const;
bool hereAvailable() const;
int m_hereAvailable;
int m_mlsAvailable;
int m_yandexAvailable;
QFileSystemWatcher m_watcher;
bool m_locationEnabled;
bool m_gpsEnabled;
bool m_mlsEnabled;
bool m_yandexLocatorEnabled;
LocationSettings::OnlineAGpsState m_mlsOnlineState;
LocationSettings::OnlineAGpsState m_yandexLocatorOnlineState;
LocationSettings::OnlineAGpsState m_yandexOnlineState;
LocationSettings::OnlineAGpsState m_hereState;
LocationSettings::LocationMode m_locationMode;
bool m_settingLocationMode;
bool m_settingMultipleSettings;
QStringList m_pendingAgreements;
LocationSettings::DataSources m_allowedDataSources;
NetworkManager *m_connMan;
NetworkTechnology *m_gpsTech;
......@@ -85,7 +86,6 @@ private slots:
void readSettings();
void findGpsTech();
void gpsTechPropertyChanged(const QString &propertyName, const QVariant &value);
void recalculateLocationMode();
};
// TODO: replace this with DBus calls to a central settings service...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment