on xenial help sign in
Use a separate property rather than a special one-space value to signal when we have a valid HERE path
acaab88Michael Terry
plugins/AccountsService/AccountsService.cpp+7−2
@@ -33,7 +33,7 @@ AccountsService::AccountsService(QObject* parent)
33 m_passwordDisplayHint(Keyboard),
33 m_passwordDisplayHint(Keyboard),
34 m_failedLogins(0),
34 m_failedLogins(0),
35 m_hereEnabled(false),
35 m_hereEnabled(false),
36− m_hereLicensePath(" ") // blank space means not set yet
36+ m_hereLicensePath() // null means not set yet
37{
37{
38 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
38 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
39 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
39 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
@@ -118,6 +118,11 @@ QString AccountsService::hereLicensePath() const
118 return m_hereLicensePath;
118 return m_hereLicensePath;
119}
119}
120
120
121+bool AccountsService::hereLicensePathValid() const
122+{
123+ return !m_hereLicensePath.isNull();
124+}
125+
121void AccountsService::updateDemoEdges()
126void AccountsService::updateDemoEdges()
122{
127{
123 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
128 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
@@ -194,7 +199,7 @@ void AccountsService::updateHereLicensePath()
194{
199{
195 QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
200 QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
196
201
197− if (!hereLicensePath.isEmpty() && !QFile::exists(hereLicensePath))
202+ if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
198 hereLicensePath = "";
203 hereLicensePath = "";
199
204
200 if (m_hereLicensePath != hereLicensePath) {
205 if (m_hereLicensePath != hereLicensePath) {
plugins/AccountsService/AccountsService.h+4
@@ -62,6 +62,9 @@ class AccountsService: public QObject
62 Q_PROPERTY(QString hereLicensePath
62 Q_PROPERTY(QString hereLicensePath
63 READ hereLicensePath
63 READ hereLicensePath
64 NOTIFY hereLicensePathChanged)
64 NOTIFY hereLicensePathChanged)
65+ Q_PROPERTY(bool hereLicensePathValid // qml sees a null string as "", so we use proxy setting for that
66+ READ hereLicensePathValid
67+ NOTIFY hereLicensePathChanged)
65
68
66public:
69public:
67 enum PasswordDisplayHint {
70 enum PasswordDisplayHint {
@@ -85,6 +88,7 @@ public:
85 bool hereEnabled() const;
88 bool hereEnabled() const;
86 void setHereEnabled(bool enabled);
89 void setHereEnabled(bool enabled);
87 QString hereLicensePath() const;
90 QString hereLicensePath() const;
91+ bool hereLicensePathValid() const;
88
92
89Q_SIGNALS:
93Q_SIGNALS:
90 void userChanged();
94 void userChanged();
qml/Wizard/Pages/50-location.qml+1−6
@@ -25,7 +25,7 @@ LocalComponents.Page {
25 title: i18n.tr("Location")
25 title: i18n.tr("Location")
26 forwardButtonSourceComponent: forwardButton
26 forwardButtonSourceComponent: forwardButton
27
27
28− property bool pathSet: AccountsService.hereLicensePath !== " " // single space means it's unassigned
28+ property bool pathSet: AccountsService.hereLicensePathValid
29 property bool countSet: false
29 property bool countSet: false
30 skipValid: pathSet && (AccountsService.hereLicensePath === "" || countSet)
30 skipValid: pathSet && (AccountsService.hereLicensePath === "" || countSet)
31 skip: skipValid && (AccountsService.hereLicensePath === "" || termsModel.count === 0)
31 skip: skipValid && (AccountsService.hereLicensePath === "" || termsModel.count === 0)
@@ -35,11 +35,6 @@ LocalComponents.Page {
35 onCountChanged: if (pathSet) countSet = true
35 onCountChanged: if (pathSet) countSet = true
36 }
36 }
37
37
38− Connections {
39− target: AccountsService
40− onHereLicensePathChanged: console.log("MIKE path is", AccountsService.hereLicensePath)
41− }
42−
43 FolderListModel {
38 FolderListModel {
44 id: termsModel
39 id: termsModel
45 folder: AccountsService.hereLicensePath
40 folder: AccountsService.hereLicensePath
tests/mocks/AccountsService/AccountsService.cpp+8−2
@@ -29,7 +29,7 @@ AccountsService::AccountsService(QObject* parent)
29 m_failedLogins(0),
29 m_failedLogins(0),
30 m_demoEdges(false),
30 m_demoEdges(false),
31 m_hereEnabled(false),
31 m_hereEnabled(false),
32− m_hereLicensePath("")
32+ m_hereLicensePath()
33{
33{
34}
34}
35
35
@@ -137,6 +137,12 @@ QString AccountsService::hereLicensePath() const
137
137
138void AccountsService::setHereLicensePath(const QString &path)
138void AccountsService::setHereLicensePath(const QString &path)
139{
139{
140+ // Path should always be valid (this code is all synchronous)
140− m_hereLicensePath = path;
141+ m_hereLicensePath = path.isNull() ? "" : path;
141 hereLicensePathChanged();
142 hereLicensePathChanged();
142}
143}
144+
145+bool AccountsService::hereLicensePathValid() const
146+{
147+ return !m_hereLicensePath.isNull();
148+}
tests/mocks/AccountsService/AccountsService.h+4
@@ -67,6 +67,9 @@ class AccountsService: public QObject
67 READ hereLicensePath
67 READ hereLicensePath
68 WRITE setHereLicensePath // only available in mock
68 WRITE setHereLicensePath // only available in mock
69 NOTIFY hereLicensePathChanged)
69 NOTIFY hereLicensePathChanged)
70+ Q_PROPERTY(bool hereLicensePathValid // qml sees a null string as "", so we use proxy setting for that
71+ READ hereLicensePathValid
72+ NOTIFY hereLicensePathChanged)
70
73
71public:
74public:
72 enum PasswordDisplayHint {
75 enum PasswordDisplayHint {
@@ -95,6 +98,7 @@ public:
95 void setHereEnabled(bool enabled);
98 void setHereEnabled(bool enabled);
96 QString hereLicensePath() const;
99 QString hereLicensePath() const;
97 void setHereLicensePath(const QString &path);
100 void setHereLicensePath(const QString &path);
101+ bool hereLicensePathValid() const;
98
102
99Q_SIGNALS:
103Q_SIGNALS:
100 void userChanged();
104 void userChanged();