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
commitacaab884d1941118302fc08b07b44c98229e8bb1 authorMichael Terry <michael.terry@canonical.com> dateMon 24 Nov 2014, 12:42 (12 years ago) parentc584e65
5 files changed+24−10
plugins/AccountsService/AccountsService.cpp+7−2 plugins/AccountsService/AccountsService.h+4 qml/Wizard/Pages/50-location.qml+1−6 tests/mocks/AccountsService/AccountsService.cpp+8−2 tests/mocks/AccountsService/AccountsService.h+4
plugins/AccountsService/AccountsService.cpp+7−2
@@ -33,7 +33,7 @@ AccountsService::AccountsService(QObject* parent)
3333 m_passwordDisplayHint(Keyboard),
3434 m_failedLogins(0),
3535 m_hereEnabled(false),
36− m_hereLicensePath(" ") // blank space means not set yet
36+ m_hereLicensePath() // null means not set yet
3737{
3838 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
3939 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
@@ -118,6 +118,11 @@ QString AccountsService::hereLicensePath() const
118118 return m_hereLicensePath;
119119}
120120
121+bool AccountsService::hereLicensePathValid() const
122+{
123+ return !m_hereLicensePath.isNull();
124+}
125+
121126void AccountsService::updateDemoEdges()
122127{
123128 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
@@ -194,7 +199,7 @@ void AccountsService::updateHereLicensePath()
194199{
195200 QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
196201
197− if (!hereLicensePath.isEmpty() && !QFile::exists(hereLicensePath))
202+ if (hereLicensePath.isEmpty() || !QFile::exists(hereLicensePath))
198203 hereLicensePath = "";
199204
200205 if (m_hereLicensePath != hereLicensePath) {
plugins/AccountsService/AccountsService.h+4
@@ -62,6 +62,9 @@ class AccountsService: public QObject
6262 Q_PROPERTY(QString hereLicensePath
6363 READ hereLicensePath
6464 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)
6568
6669public:
6770 enum PasswordDisplayHint {
@@ -85,6 +88,7 @@ public:
8588 bool hereEnabled() const;
8689 void setHereEnabled(bool enabled);
8790 QString hereLicensePath() const;
91+ bool hereLicensePathValid() const;
8892
8993Q_SIGNALS:
9094 void userChanged();
qml/Wizard/Pages/50-location.qml+1−6
@@ -25,7 +25,7 @@ LocalComponents.Page {
2525 title: i18n.tr("Location")
2626 forwardButtonSourceComponent: forwardButton
2727
28− property bool pathSet: AccountsService.hereLicensePath !== " " // single space means it's unassigned
28+ property bool pathSet: AccountsService.hereLicensePathValid
2929 property bool countSet: false
3030 skipValid: pathSet && (AccountsService.hereLicensePath === "" || countSet)
3131 skip: skipValid && (AccountsService.hereLicensePath === "" || termsModel.count === 0)
@@ -35,11 +35,6 @@ LocalComponents.Page {
3535 onCountChanged: if (pathSet) countSet = true
3636 }
3737
38− Connections {
39− target: AccountsService
40− onHereLicensePathChanged: console.log("MIKE path is", AccountsService.hereLicensePath)
41− }
42−
4338 FolderListModel {
4439 id: termsModel
4540 folder: AccountsService.hereLicensePath
tests/mocks/AccountsService/AccountsService.cpp+8−2
@@ -29,7 +29,7 @@ AccountsService::AccountsService(QObject* parent)
2929 m_failedLogins(0),
3030 m_demoEdges(false),
3131 m_hereEnabled(false),
32− m_hereLicensePath("")
32+ m_hereLicensePath()
3333{
3434}
3535
@@ -137,6 +137,12 @@ QString AccountsService::hereLicensePath() const
137137
138138void AccountsService::setHereLicensePath(const QString &path)
139139{
140− m_hereLicensePath = path;
140+ // Path should always be valid (this code is all synchronous)
141+ m_hereLicensePath = path.isNull() ? "" : path;
141142 hereLicensePathChanged();
142143}
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
6767 READ hereLicensePath
6868 WRITE setHereLicensePath // only available in mock
6969 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)
7073
7174public:
7275 enum PasswordDisplayHint {
@@ -95,6 +98,7 @@ public:
9598 void setHereEnabled(bool enabled);
9699 QString hereLicensePath() const;
97100 void setHereLicensePath(const QString &path);
101+ bool hereLicensePathValid() const;
98102
99103Q_SIGNALS:
100104 void userChanged();