on xenial help sign in
merge geonames support (lp:~mterry/unity8/oobe-timezone)
869caa8Lukáš Tinkl
CMakeLists.txt+1
@@ -58,6 +58,7 @@ find_package(Qt5Concurrent 5.4 REQUIRED)
58find_package(Qt5Sql 5.4 REQUIRED)
58find_package(Qt5Sql 5.4 REQUIRED)
59
59
60pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=13)
60pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=13)
61+pkg_check_modules(GEONAMES REQUIRED geonames)
61pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
62pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
62pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
63pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
63pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
64pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
debian/control+1−1
@@ -15,6 +15,7 @@ Build-Depends: cmake,
15 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
15 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
16 libconnectivity-qt1-dev,
16 libconnectivity-qt1-dev,
17 libevdev-dev,
17 libevdev-dev,
18+ libgeonames-dev (>= 0.2),
18 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
19 libgl1-mesa-dev[!armhf] | libgl-dev[!armhf],
19 libgl1-mesa-dri,
20 libgl1-mesa-dri,
20 libgles2-mesa-dev[armhf],
21 libgles2-mesa-dev[armhf],
@@ -28,7 +29,6 @@ Build-Depends: cmake,
28 libqt5svg5-dev,
29 libqt5svg5-dev,
29 libqt5xmlpatterns5-dev,
30 libqt5xmlpatterns5-dev,
30 libsystemsettings-dev,
31 libsystemsettings-dev,
31− libtimezonemap1-dev,
32 libudev-dev,
32 libudev-dev,
33 libunity-api-dev (>= 7.106),
33 libunity-api-dev (>= 7.106),
34 libusermetricsoutput1-dev,
34 libusermetricsoutput1-dev,
plugins/Wizard/CMakeLists.txt+2−4
@@ -1,6 +1,4 @@
1−pkg_search_module(TIMEZONEMAP REQUIRED timezonemap)
2−
3−include_directories(${GLIB_INCLUDE_DIRS} ${TIMEZONEMAP_INCLUDE_DIRS})
1+include_directories(${GLIB_INCLUDE_DIRS} ${GEONAMES_INCLUDE_DIRS})
4
2
5add_library(Wizard-qml MODULE
3add_library(Wizard-qml MODULE
6 plugin.cpp
4 plugin.cpp
@@ -12,7 +10,7 @@ add_library(Wizard-qml MODULE
12)
10)
13
11
14qt5_use_modules(Wizard-qml DBus Qml Concurrent)
12qt5_use_modules(Wizard-qml DBus Qml Concurrent)
15−target_link_libraries(Wizard-qml ${GLIB_LDFLAGS} ${TIMEZONEMAP_LDFLAGS})
13+target_link_libraries(Wizard-qml ${GLIB_LDFLAGS} ${GEONAMES_LDFLAGS})
16add_unity8_plugin(Wizard 0.1 Wizard TARGETS Wizard-qml)
14add_unity8_plugin(Wizard 0.1 Wizard TARGETS Wizard-qml)
17
15
18set(POLKIT_LIB_DIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/polkit-1")
16set(POLKIT_LIB_DIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/polkit-1")
plugins/Wizard/plugin.cpp−1
@@ -30,6 +30,5 @@ void WizardPlugin::registerTypes(const char *uri)
30 qmlRegisterSingletonType<System>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new System; });
30 qmlRegisterSingletonType<System>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new System; });
31 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
31 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
32 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
32 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
33− qmlRegisterType<TimeZoneFilterModel>(uri, 0, 1, "TimeZoneFilterModel");
34 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
33 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
35}
34}
plugins/Wizard/timezonemodel.cpp+135−124
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2015 Canonical Ltd.
2+ * Copyright (C) 2016 Canonical Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
5 * under the terms of the GNU General Public License version 3, as published
@@ -18,17 +18,15 @@
18
18
19#include <glib.h>
19#include <glib.h>
20#include <glib-object.h>
20#include <glib-object.h>
21−#include <timezonemap/tz.h>
22
21
23#include "LocalePlugin.h"
22#include "LocalePlugin.h"
24#include "timezonemodel.h"
23#include "timezonemodel.h"
25
24
26TimeZoneLocationModel::TimeZoneLocationModel(QObject *parent):
25TimeZoneLocationModel::TimeZoneLocationModel(QObject *parent):
27 QAbstractListModel(parent),
26 QAbstractListModel(parent),
28− m_workerThread(new TimeZonePopulateWorker())
27+ m_listUpdating(false),
28+ m_cancellable(nullptr)
29{
29{
30− qRegisterMetaType<TzLocationWizard>();
31−
32 m_roleNames[Qt::DisplayRole] = "displayName";
30 m_roleNames[Qt::DisplayRole] = "displayName";
33 m_roleNames[TimeZoneRole] = "timeZone";
31 m_roleNames[TimeZoneRole] = "timeZone";
34 m_roleNames[CityRole] = "city";
32 m_roleNames[CityRole] = "city";
@@ -36,78 +34,52 @@ TimeZoneLocationModel::TimeZoneLocationModel(QObject *parent):
36 m_roleNames[OffsetRole] = "offset";
34 m_roleNames[OffsetRole] = "offset";
37 m_roleNames[LatitudeRole] = "latitude";
35 m_roleNames[LatitudeRole] = "latitude";
38 m_roleNames[LongitudeRole] = "longitude";
36 m_roleNames[LongitudeRole] = "longitude";
39−
40− QObject::connect(m_workerThread,
41− &TimeZonePopulateWorker::resultReady,
42− this,
43− &TimeZoneLocationModel::processModelResult);
44− QObject::connect(m_workerThread,
45− &TimeZonePopulateWorker::finished,
46− this,
47− &TimeZoneLocationModel::store);
48− QObject::connect(m_workerThread,
49− &TimeZonePopulateWorker::finished,
50− m_workerThread,
51− &QObject::deleteLater);
52−
53− init();
54−}
55−
56−void TimeZoneLocationModel::init()
57−{
58− beginResetModel();
59− m_workerThread->start();
60−}
61−
62−void TimeZoneLocationModel::store()
63−{
64− m_workerThread = nullptr;
65− endResetModel();
66−}
67−
68−void TimeZoneLocationModel::processModelResult(const TzLocationWizard &location)
69−{
70− m_locations.append(location);
71}
37}
72
38
73int TimeZoneLocationModel::rowCount(const QModelIndex &parent) const
39int TimeZoneLocationModel::rowCount(const QModelIndex &parent) const
74{
40{
75− if (parent.isValid())
41+ if (parent.isValid()) {
76 return 0;
42 return 0;
43+ } else if (m_filter.isEmpty()) {
44+ return m_countryLocations.count();
45+ } else {
77− return m_locations.count();
46+ return m_locations.count();
47+ }
78}
48}
79
49
80QVariant TimeZoneLocationModel::data(const QModelIndex &index, int role) const
50QVariant TimeZoneLocationModel::data(const QModelIndex &index, int role) const
81{
51{
52+ GeonamesCity *city;
53+ if (m_filter.isEmpty()) {
54+ city = m_countryLocations.value(index.row());
55+ } else {
82− if (index.row() >= m_locations.count() || index.row() < 0)
56+ city = m_locations.value(index.row());
57+ }
58+ if (!city)
83 return QVariant();
59 return QVariant();
84
60
85− const TzLocationWizard tz = m_locations.at(index.row());
86−
87− const QString country(tz.full_country.isEmpty() ? tz.country : tz.full_country);
88−
89 switch (role) {
61 switch (role) {
90 case Qt::DisplayRole:
62 case Qt::DisplayRole:
91− if (!tz.state.isEmpty())
92− return QStringLiteral("%1, %2, %3").arg(tz.city).arg(tz.state).arg(country);
63+ return QStringLiteral("%1, %2, %3").arg(geonames_city_get_name(city))
93− else
64+ .arg(geonames_city_get_state(city))
94− return QStringLiteral("%1, %2").arg(tz.city).arg(country);
65+ .arg(geonames_city_get_country(city));
95 case SimpleRole:
66 case SimpleRole:
96− return QStringLiteral("%1, %2").arg(tz.city).arg(country);
67+ return QStringLiteral("%1, %2").arg(geonames_city_get_name(city))
68+ .arg(geonames_city_get_country(city));
97 case TimeZoneRole:
69 case TimeZoneRole:
98− return tz.timezone;
70+ return geonames_city_get_timezone(city);
99 case CountryRole:
71 case CountryRole:
100− return tz.country;
72+ return geonames_city_get_country(city);
101 case CityRole:
73 case CityRole:
102− return tz.city;
74+ return geonames_city_get_name(city);
103 case OffsetRole: {
75 case OffsetRole: {
104− QTimeZone tmp(tz.timezone.toLatin1());
76+ QTimeZone tmp(geonames_city_get_timezone(city));
105 return static_cast<double>(tmp.standardTimeOffset(QDateTime::currentDateTime())) / 3600;
77 return static_cast<double>(tmp.standardTimeOffset(QDateTime::currentDateTime())) / 3600;
106 }
78 }
107 case LatitudeRole:
79 case LatitudeRole:
108− return tz.latitude;
80+ return geonames_city_get_latitude(city);
109 case LongitudeRole:
81 case LongitudeRole:
110− return tz.longitude;
82+ return geonames_city_get_longitude(city);
111 default:
83 default:
112 qWarning() << Q_FUNC_INFO << "Unknown role";
84 qWarning() << Q_FUNC_INFO << "Unknown role";
113 return QVariant();
85 return QVariant();
@@ -119,110 +91,149 @@ QHash<int, QByteArray> TimeZoneLocationModel::roleNames() const
119 return m_roleNames;
91 return m_roleNames;
120}
92}
121
93
122−void TimeZonePopulateWorker::run()
94+void TimeZoneLocationModel::setModel(const QList<GeonamesCity *> &locations)
123{
95{
124− buildCityMap();
96+ beginResetModel();
97+
98+ Q_FOREACH(GeonamesCity *city, m_locations) {
99+ geonames_city_free(city);
100+ }
101+
102+ m_locations = locations;
103+ endResetModel();
125}
104}
126
105
127−void TimeZonePopulateWorker::buildCityMap()
106+void TimeZoneLocationModel::filterFinished(GObject *source_object,
107+ GAsyncResult *res,
108+ gpointer user_data)
128{
109{
129− TzDB *tzdb = tz_load_db();
110+ Q_UNUSED(source_object);
130− GPtrArray *tz_locations = tz_get_locations(tzdb);
111+
131−
112+ g_autofree gint *cities = nullptr;
132− TimeZoneLocationModel::TzLocationWizard tmpTz;
113+ guint cities_len = 0;
133−
114+ g_autoptr(GError) error = nullptr;
134− for (guint i = 0; i < tz_locations->len; ++i) {
115+
135− auto tmp = static_cast<CcTimezoneLocation *>(g_ptr_array_index(tz_locations, i));
116+ cities = geonames_query_cities_finish(res, &cities_len, &error);
136− gchar *en_name, *country, *zone, *state, *full_country;
117+ if (error) {
137− gdouble latitude;
118+ if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
138− gdouble longitude;
119+ TimeZoneLocationModel *model = static_cast<TimeZoneLocationModel *>(user_data);
139− g_object_get (tmp, "en_name", &en_name,
120+ g_clear_object(&model->m_cancellable);
140− "country", &country,
121+ model->setListUpdating(false);
141− "zone", &zone,
122+ qWarning() << "Could not filter timezones:" << error->message;
142− "state", &state,
143− "full_country", &full_country,
144− "latitude", &latitude,
145− "longitude", &longitude,
146− nullptr);
147− // There are empty entries in the DB
148− if (g_strcmp0(en_name, "") != 0) {
149− tmpTz.city = en_name;
150− tmpTz.country = country;
151− tmpTz.timezone = zone;
152− tmpTz.state = state;
153− tmpTz.full_country = full_country;
154− tmpTz.latitude = latitude;
155− tmpTz.longitude = longitude;
156−
157− Q_EMIT (resultReady(tmpTz));
158 }
123 }
159− g_free (en_name);
124+ return;
160− g_free (country);
161− g_free (zone);
162− g_free (state);
163− g_free (full_country);
164 }
125 }
165
126
166− g_ptr_array_free (tz_locations, TRUE);
127+ QList<GeonamesCity *> locations;
167− tz_db_free(tzdb);
168−}
169
128
129+ for (guint i = 0; i < cities_len; ++i) {
130+ GeonamesCity *city = geonames_get_city(cities[i]);
131+ if (city) {
132+ locations.append(city);
133+ }
134+ }
170
135
171−TimeZoneFilterModel::TimeZoneFilterModel(QObject *parent)
136+ TimeZoneLocationModel *model = static_cast<TimeZoneLocationModel *>(user_data);
172− : QSortFilterProxyModel(parent)
137+
173−{
138+ g_clear_object(&model->m_cancellable);
174− setDynamicSortFilter(false);
139+
175− setSortLocaleAware(true);
140+ model->setModel(locations);
176− setSortRole(TimeZoneLocationModel::CityRole);
141+ model->setListUpdating(false);
177− m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive);
178− sort(0);
179}
142}
180
143
181−bool TimeZoneFilterModel::filterAcceptsRow(int row, const QModelIndex &parentIndex) const
144+bool TimeZoneLocationModel::listUpdating() const
182{
145{
183− if (!sourceModel()) {
184− return true;
146+ return m_listUpdating;
185− }
147+}
186−
187− if (!m_filter.isEmpty()) { // filtering by freeform text input, cf setFilter(QString)
188− const QString city = sourceModel()->index(row, 0, parentIndex).data(TimeZoneLocationModel::CityRole).toString();
189
148
190− if (m_stringMatcher.indexIn(city) == 0) { // match at the beginning of the city name
149+void TimeZoneLocationModel::setListUpdating(bool listUpdating)
191− return true;
150+{
192− }
151+ if (m_listUpdating != listUpdating) {
193− } else if (!m_country.isEmpty()) { // filter by country code
152+ m_listUpdating = listUpdating;
194− const QString countryCode = sourceModel()->index(row, 0, parentIndex).data(TimeZoneLocationModel::CountryRole).toString();
153+ Q_EMIT listUpdatingChanged();
195− return m_country.compare(countryCode, Qt::CaseInsensitive) == 0;
196 }
154 }
197−
198− return false;
199}
155}
200
156
201−QString TimeZoneFilterModel::filter() const
157+QString TimeZoneLocationModel::filter() const
202{
158{
203 return m_filter;
159 return m_filter;
204}
160}
205
161
206−void TimeZoneFilterModel::setFilter(const QString &filter)
162+void TimeZoneLocationModel::setFilter(const QString &filter)
207{
163{
208 if (filter != m_filter) {
164 if (filter != m_filter) {
209 m_filter = filter;
165 m_filter = filter;
210− m_stringMatcher.setPattern(m_filter);
211 Q_EMIT filterChanged();
166 Q_EMIT filterChanged();
212− invalidate();
213 }
167 }
168+
169+ setListUpdating(true);
170+
171+ if (m_cancellable) {
172+ g_cancellable_cancel(m_cancellable);
173+ g_clear_object(&m_cancellable);
174+ }
175+
176+ setModel(QList<GeonamesCity *>());
177+
178+ if (filter.isEmpty()) {
179+ setListUpdating(false);
180+ return;
181+ }
182+
183+ m_cancellable = g_cancellable_new();
184+ geonames_query_cities(filter.toUtf8().data(),
185+ GEONAMES_QUERY_DEFAULT,
186+ m_cancellable,
187+ filterFinished,
188+ this);
214}
189}
215
190
216−QString TimeZoneFilterModel::country() const
191+QString TimeZoneLocationModel::country() const
217{
192{
218 return m_country;
193 return m_country;
219}
194}
220
195
196+static bool citycmp(GeonamesCity *a, GeonamesCity *b)
197+{
198+ return geonames_city_get_population(b) < geonames_city_get_population(a);
199+}
200+
221−void TimeZoneFilterModel::setCountry(const QString &country)
201+void TimeZoneLocationModel::setCountry(const QString &country)
222{
202{
223 if (m_country == country)
203 if (m_country == country)
224 return;
204 return;
225
205
226 m_country = country;
206 m_country = country;
207+
208+ Q_FOREACH(GeonamesCity *city, m_countryLocations) {
209+ geonames_city_free(city);
210+ }
211+
212+ gint num_cities = geonames_get_n_cities();
213+ for (gint i = 0; i < num_cities; i++) {
214+ GeonamesCity *city = geonames_get_city(i);
215+ if (city && m_country == geonames_city_get_country_code(city)) {
216+ m_countryLocations.append(city);
217+ }
218+ }
219+
220+ std::sort(m_countryLocations.begin(), m_countryLocations.end(), citycmp);
221+
227 Q_EMIT countryChanged(country);
222 Q_EMIT countryChanged(country);
228}
223}
224+
225+TimeZoneLocationModel::~TimeZoneLocationModel()
226+{
227+ if (m_cancellable) {
228+ g_cancellable_cancel(m_cancellable);
229+ g_clear_object(&m_cancellable);
230+ }
231+
232+ Q_FOREACH(GeonamesCity *city, m_countryLocations) {
233+ geonames_city_free(city);
234+ }
235+
236+ Q_FOREACH(GeonamesCity *city, m_locations) {
237+ geonames_city_free(city);
238+ }
239+}
plugins/Wizard/timezonemodel.h+22−55
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2015 Canonical Ltd.
2+ * Copyright (C) 2016 Canonical Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
5 * under the terms of the GNU General Public License version 3, as published
@@ -17,21 +17,21 @@
17#ifndef TIMEZONEMODEL_H
17#ifndef TIMEZONEMODEL_H
18#define TIMEZONEMODEL_H
18#define TIMEZONEMODEL_H
19
19
20+#include <geonames.h>
21+#include <glib.h>
20#include <QAbstractListModel>
22#include <QAbstractListModel>
21−#include <QSortFilterProxyModel>
22−#include <QThread>
23−#include <QtConcurrent>
24−#include <QtGui/QImage>
25−
26−class TimeZonePopulateWorker;
27
23
28class TimeZoneLocationModel: public QAbstractListModel
24class TimeZoneLocationModel: public QAbstractListModel
29{
25{
30 Q_OBJECT
26 Q_OBJECT
27+ Q_PROPERTY(bool listUpdating READ listUpdating NOTIFY listUpdatingChanged)
28+ Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
29+ Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
31 Q_ENUMS(Roles)
30 Q_ENUMS(Roles)
31+
32public:
32public:
33 explicit TimeZoneLocationModel(QObject *parent = nullptr);
33 explicit TimeZoneLocationModel(QObject *parent = nullptr);
34− ~TimeZoneLocationModel() = default;
34+ ~TimeZoneLocationModel();
35
35
36 enum Roles {
36 enum Roles {
37 TimeZoneRole = Qt::UserRole + 1,
37 TimeZoneRole = Qt::UserRole + 1,
@@ -43,56 +43,11 @@ public:
43 LongitudeRole
43 LongitudeRole
44 };
44 };
45
45
46− struct TzLocationWizard {
47− QString city;
48− QString country;
49− QString timezone;
50− QString state;
51− QString full_country;
52− double latitude;
53− double longitude;
54− };
55−
56 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
46 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
57 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
47 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
58 QHash<int, QByteArray> roleNames() const override;
48 QHash<int, QByteArray> roleNames() const override;
59
49
60−private Q_SLOTS:
50+ bool listUpdating() const;
61− void processModelResult(const TzLocationWizard &location);
62− void store();
63−
64−private:
65− void init();
66− QHash<int, QByteArray> m_roleNames;
67− QList<TzLocationWizard> m_locations;
68− TimeZonePopulateWorker *m_workerThread;
69−};
70−
71−Q_DECLARE_METATYPE (TimeZoneLocationModel::TzLocationWizard)
72−
73−class TimeZonePopulateWorker: public QThread
74−{
75− Q_OBJECT
76−public:
77− void run() override;
78−
79−Q_SIGNALS:
80− void resultReady(const TimeZoneLocationModel::TzLocationWizard &tz);
81−
82−private:
83− void buildCityMap();
84−};
85−
86−class TimeZoneFilterModel: public QSortFilterProxyModel
87−{
88− Q_OBJECT
89− Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
90− Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY countryChanged)
91−
92−public:
93− explicit TimeZoneFilterModel(QObject *parent = nullptr);
94− ~TimeZoneFilterModel() = default;
95− bool filterAcceptsRow(int row, const QModelIndex &parentIndex) const override;
96
51
97 QString filter() const;
52 QString filter() const;
98 void setFilter(const QString &filter);
53 void setFilter(const QString &filter);
@@ -101,13 +56,25 @@ public:
101 void setCountry(const QString &country);
56 void setCountry(const QString &country);
102
57
103Q_SIGNALS:
58Q_SIGNALS:
59+ void listUpdatingChanged();
104 void filterChanged();
60 void filterChanged();
105 void countryChanged(const QString &country);
61 void countryChanged(const QString &country);
106
62
107private:
63private:
64+ void setModel(const QList<GeonamesCity *> &locations);
65+ void setListUpdating(bool listUpdating);
66+ static void filterFinished(GObject *source_object,
67+ GAsyncResult *res,
68+ gpointer user_data);
69+
70+
71+ bool m_listUpdating;
108 QString m_filter;
72 QString m_filter;
109− QStringMatcher m_stringMatcher;
110 QString m_country;
73 QString m_country;
74+ GCancellable *m_cancellable;
75+ QHash<int, QByteArray> m_roleNames;
76+ QList<GeonamesCity *> m_locations;
77+ QList<GeonamesCity *> m_countryLocations;
111};
78};
112
79
113#endif
80#endif
qml/Wizard/Pages.qml−11
@@ -34,23 +34,12 @@ Item {
34 property int passwordMethod: UbuntuSecurityPrivacyPanel.Passphrase
34 property int passwordMethod: UbuntuSecurityPrivacyPanel.Passphrase
35 property string password: ""
35 property string password: ""
36
36
37− property string countryCode: "US" // default country (for the timezone page)
38 property bool seenSIMPage: false // we want to see the SIM page at most once
37 property bool seenSIMPage: false // we want to see the SIM page at most once
39
38
40 property alias modemManager: modemManager
39 property alias modemManager: modemManager
41 property alias simManager0: simManager0
40 property alias simManager0: simManager0
42 property alias simManager1: simManager1
41 property alias simManager1: simManager1
43
42
44− TimeZoneModel { // preload the heavy models
45− id: tzModel
46− }
47−
48− TimeZoneFilterModel {
49− id: tzFilterModel
50− sourceModel: tzModel
51− country: countryCode
52− }
53−
54 UbuntuSecurityPrivacyPanel {
43 UbuntuSecurityPrivacyPanel {
55 id: securityPrivacy
44 id: securityPrivacy
56 objectName: "securityPrivacy"
45 objectName: "securityPrivacy"
qml/Wizard/Pages/10-welcome.qml−1
@@ -155,7 +155,6 @@ LocalComponents.Page {
155 System.updateSessionLocale(plugin.languageCodes[plugin.currentLanguage]);
155 System.updateSessionLocale(plugin.languageCodes[plugin.currentLanguage]);
156 }
156 }
157 i18n.language = plugin.languageCodes[plugin.currentLanguage]; // re-notify of change after above call (for qlocale change)
157 i18n.language = plugin.languageCodes[plugin.currentLanguage]; // re-notify of change after above call (for qlocale change)
158− root.countryCode = plugin.languageCodes[plugin.currentLanguage].split('_')[1].split('.')[0]; // extract the country code, save it for the timezone page
159
158
160 if (!root.modemManager.available || !root.modemManager.ready || root.modemManager.modems.length === 0 ||
159 if (!root.modemManager.available || !root.modemManager.ready || root.modemManager.modems.length === 0 ||
161 (root.simManager0.present && root.simManager0.ready) || (root.simManager1.present && root.simManager1.ready) ||
160 (root.simManager0.present && root.simManager0.ready) || (root.simManager1.present && root.simManager1.ready) ||
qml/Wizard/Pages/50-timezone.qml+13−3
@@ -87,8 +87,6 @@ LocalComponents.Page {
87 }
87 }
88
88
89 resetViews();
89 resetViews();
90− tzFilterModel.filter = Qt.binding(function() { return searchField.text; });
91− tzFilterModel.invalidate();
92 theme.palette.normal.backgroundText = "#cdcdcd";
90 theme.palette.normal.backgroundText = "#cdcdcd";
93 searchField.forceActiveFocus();
91 searchField.forceActiveFocus();
94 }
92 }
@@ -192,9 +190,21 @@ LocalComponents.Page {
192 objectName: "tzList"
190 objectName: "tzList"
193 clip: true
191 clip: true
194 currentIndex: -1
192 currentIndex: -1
195− model: tzFilterModel
193+ model: TimeZoneModel {
194+ id: timeZoneModel
195+ filter: searchField.text
196+ country: i18n.language.split('_')[1].split('.')[0]
197+ }
196 delegate: tzComponent
198 delegate: tzComponent
197 }
199 }
200+
201+ ActivityIndicator {
202+ anchors.centerIn: tzList
203+ running: tzList.count == 0 &&
204+ searchField.length > 0 &&
205+ timeZoneModel.listUpdating
206+ visible: running
207+ }
198 }
208 }
199
209
200 Item {
210 Item {
qml/Wizard/Pages/passcode-confirm.qml+1−2
@@ -37,8 +37,7 @@ LocalComponents.Page {
37 UnityComponents.Lockscreen {
37 UnityComponents.Lockscreen {
38 id: lockscreen
38 id: lockscreen
39 anchors {
39 anchors {
40− fill: parent
40+ fill: content
41− topMargin: customMargin
42 }
41 }
43
42
44 infoText: i18n.tr("Confirm passcode")
43 infoText: i18n.tr("Confirm passcode")
qml/Wizard/Pages/passcode-set.qml+1−2
@@ -48,8 +48,7 @@ LocalComponents.Page {
48 UnityComponents.Lockscreen {
48 UnityComponents.Lockscreen {
49 id: lockscreen
49 id: lockscreen
50 anchors {
50 anchors {
51− fill: parent
51+ fill: content
52− topMargin: customMargin
53 }
52 }
54
53
55 infoText: i18n.tr("Choose passcode")
54 infoText: i18n.tr("Choose passcode")
tests/mocks/Wizard/CMakeLists.txt+2−4
@@ -1,7 +1,5 @@
1−pkg_search_module(TIMEZONEMAP REQUIRED timezonemap)
2−
3include_directories(
1include_directories(
4− ${GLIB_INCLUDE_DIRS} ${TIMEZONEMAP_INCLUDE_DIRS}
2+ ${GLIB_INCLUDE_DIRS} ${GEONAMES_INCLUDE_DIRS}
5 ${CMAKE_SOURCE_DIR}/plugins/Wizard
3 ${CMAKE_SOURCE_DIR}/plugins/Wizard
6)
4)
7
5
@@ -15,5 +13,5 @@ add_library(MockWizard-qml MODULE
15)
13)
16
14
17qt5_use_modules(MockWizard-qml DBus Qml Concurrent)
15qt5_use_modules(MockWizard-qml DBus Qml Concurrent)
18−target_link_libraries(MockWizard-qml ${GLIB_LDFLAGS} ${TIMEZONEMAP_LDFLAGS})
16+target_link_libraries(MockWizard-qml ${GLIB_LDFLAGS} ${GEONAMES_LDFLAGS})
19add_unity8_mock(Wizard 0.1 Wizard TARGETS MockWizard-qml)
17add_unity8_mock(Wizard 0.1 Wizard TARGETS MockWizard-qml)
tests/mocks/Wizard/mockplugin.cpp−1
@@ -30,6 +30,5 @@ void MockWizardPlugin::registerTypes(const char *uri)
30 qmlRegisterSingletonType<MockSystem>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new MockSystem; });
30 qmlRegisterSingletonType<MockSystem>(uri, 0, 1, "System", [](QQmlEngine*, QJSEngine*) -> QObject* { return new MockSystem; });
31 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
31 qmlRegisterSingletonType<Status>(uri, 0, 1, "Status", [](QQmlEngine*, QJSEngine*) -> QObject* { return new Status; });
32 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
32 qmlRegisterType<TimeZoneLocationModel>(uri, 0, 1, "TimeZoneModel");
33− qmlRegisterType<TimeZoneFilterModel>(uri, 0, 1, "TimeZoneFilterModel");
34 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
33 qmlRegisterType<LocalePlugin>(uri, 0, 1, "LocalePlugin");
35}
34}