on xenial help sign in
reset views when switching between search and click
commit4d151b745cff3e36e515a08b99fbe9a43fbe53c1 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 15 Feb 2016, 21:49 (11 years ago) parent150205c
2 files changed+24−11
plugins/Wizard/timezonemodel.cpp+4 qml/Wizard/Pages/50-timezone.qml+20−11
plugins/Wizard/timezonemodel.cpp+4
@@ -518,6 +518,10 @@ QJsonArray TimeZoneLocationModel::timezoneAndOffsetAtMapPoint(int x, int y, cons
518518 const int red = qRed(rgb);
519519 const int green = qGreen(rgb);
520520 qDebug() << "Red:" << red << ", green:" << green;
521+ if (red == 0 && green == 0) {
522+ qWarning() << "Clicked the water!";
523+ return QJsonArray();
524+ }
521525 const int zoneIndex = ((red & 248) << 1) + ((green >> 4) & 15);
522526
523527 qDebug() << "Zone index:" << zoneIndex;
qml/Wizard/Pages/50-timezone.qml+20−11
@@ -65,6 +65,14 @@ LocalComponents.Page {
6565 return y;
6666 }
6767
68+ function resetViews() {
69+ selectedTimeZone = ""
70+ tzList.currentIndex = -1
71+ highlightImage.source = ""
72+ pinImage.x = 0;
73+ pinImage.y = 0;
74+ }
75+
6876 UbuntuTimeDatePanel {
6977 id: timeDatePanel
7078 }
@@ -171,12 +179,7 @@ LocalComponents.Page {
171179 anchors.rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
172180 placeholderText: i18n.tr("Enter your city")
173181 inputMethodHints: Qt.ImhNoPredictiveText
174− onTextChanged: {
175− // reset when switching between filter modes (text/country)
176− selectedTimeZone = ""
177− tzList.currentIndex = -1
178− highlightImage.source = ""
179− }
182+ onTextChanged: resetViews();
180183 }
181184
182185 Rectangle {
@@ -216,12 +219,15 @@ LocalComponents.Page {
216219 right: parent.right
217220 top: parent.top
218221 bottom: parent.bottom
222+ leftMargin: units.gu(2)
219223 }
220224
221225 Item {
222226 id: map
223− width: units.dp(800)
224− height: units.dp(410)
227+ //width: units.dp(800)
228+ //height: units.dp(410)
229+ width: column.width - tzList.width
230+ height: width / 1.95
225231 anchors {
226232 centerIn: parent
227233 }
@@ -229,13 +235,16 @@ LocalComponents.Page {
229235 MouseArea {
230236 anchors.fill: parent
231237 onClicked: {
232− print("Clicked at", mouse.x, mouse.y)
233− print("Map size:", map.width, map.height)
234238 var tzAndOffset = tzModel.timezoneAndOffsetAtMapPoint(mouse.x, mouse.y,
235239 Qt.size(map.width, map.height));
236240 var tzId = tzAndOffset[0];
237241 var offset = tzAndOffset[1];
238242 print("Timezone", tzId, ", offset", offset);
243+ if (tzId) {
244+ resetViews();
245+ selectedTimeZone = tzId;
246+ highlightTimezone(offset);
247+ }
239248 }
240249 }
241250
@@ -266,7 +275,7 @@ LocalComponents.Page {
266275 Image {
267276 id: pinImage
268277 source: "data/timezonemap/pin.png"
269− visible: selectedTimeZone != ""
278+ visible: x != 0 && y != 0
270279 width: units.dp(8)
271280 height: units.dp(16)
272281 z: map.z + 1