on xenial help sign in
reset views when switching between search and click
4d151b7Lukáš Tinkl
plugins/Wizard/timezonemodel.cpp+4
@@ -518,6 +518,10 @@ QJsonArray TimeZoneLocationModel::timezoneAndOffsetAtMapPoint(int x, int y, cons
518 const int red = qRed(rgb);
518 const int red = qRed(rgb);
519 const int green = qGreen(rgb);
519 const int green = qGreen(rgb);
520 qDebug() << "Red:" << red << ", green:" << green;
520 qDebug() << "Red:" << red << ", green:" << green;
521+ if (red == 0 && green == 0) {
522+ qWarning() << "Clicked the water!";
523+ return QJsonArray();
524+ }
521 const int zoneIndex = ((red & 248) << 1) + ((green >> 4) & 15);
525 const int zoneIndex = ((red & 248) << 1) + ((green >> 4) & 15);
522
526
523 qDebug() << "Zone index:" << zoneIndex;
527 qDebug() << "Zone index:" << zoneIndex;
qml/Wizard/Pages/50-timezone.qml+20−11
@@ -65,6 +65,14 @@ LocalComponents.Page {
65 return y;
65 return y;
66 }
66 }
67
67
68+ function resetViews() {
69+ selectedTimeZone = ""
70+ tzList.currentIndex = -1
71+ highlightImage.source = ""
72+ pinImage.x = 0;
73+ pinImage.y = 0;
74+ }
75+
68 UbuntuTimeDatePanel {
76 UbuntuTimeDatePanel {
69 id: timeDatePanel
77 id: timeDatePanel
70 }
78 }
@@ -171,12 +179,7 @@ LocalComponents.Page {
171 anchors.rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
179 anchors.rightMargin: column.anchors.rightMargin == 0 ? staticMargin : 0
172 placeholderText: i18n.tr("Enter your city")
180 placeholderText: i18n.tr("Enter your city")
173 inputMethodHints: Qt.ImhNoPredictiveText
181 inputMethodHints: Qt.ImhNoPredictiveText
174− onTextChanged: {
182+ onTextChanged: resetViews();
175− // reset when switching between filter modes (text/country)
176− selectedTimeZone = ""
177− tzList.currentIndex = -1
178− highlightImage.source = ""
179− }
180 }
183 }
181
184
182 Rectangle {
185 Rectangle {
@@ -216,12 +219,15 @@ LocalComponents.Page {
216 right: parent.right
219 right: parent.right
217 top: parent.top
220 top: parent.top
218 bottom: parent.bottom
221 bottom: parent.bottom
222+ leftMargin: units.gu(2)
219 }
223 }
220
224
221 Item {
225 Item {
222 id: map
226 id: map
223− width: units.dp(800)
227+ //width: units.dp(800)
224− height: units.dp(410)
228+ //height: units.dp(410)
229+ width: column.width - tzList.width
230+ height: width / 1.95
225 anchors {
231 anchors {
226 centerIn: parent
232 centerIn: parent
227 }
233 }
@@ -229,13 +235,16 @@ LocalComponents.Page {
229 MouseArea {
235 MouseArea {
230 anchors.fill: parent
236 anchors.fill: parent
231 onClicked: {
237 onClicked: {
232− print("Clicked at", mouse.x, mouse.y)
233− print("Map size:", map.width, map.height)
234 var tzAndOffset = tzModel.timezoneAndOffsetAtMapPoint(mouse.x, mouse.y,
238 var tzAndOffset = tzModel.timezoneAndOffsetAtMapPoint(mouse.x, mouse.y,
235 Qt.size(map.width, map.height));
239 Qt.size(map.width, map.height));
236 var tzId = tzAndOffset[0];
240 var tzId = tzAndOffset[0];
237 var offset = tzAndOffset[1];
241 var offset = tzAndOffset[1];
238 print("Timezone", tzId, ", offset", offset);
242 print("Timezone", tzId, ", offset", offset);
243+ if (tzId) {
244+ resetViews();
245+ selectedTimeZone = tzId;
246+ highlightTimezone(offset);
247+ }
239 }
248 }
240 }
249 }
241
250
@@ -266,7 +275,7 @@ LocalComponents.Page {
266 Image {
275 Image {
267 id: pinImage
276 id: pinImage
268 source: "data/timezonemap/pin.png"
277 source: "data/timezonemap/pin.png"
269− visible: selectedTimeZone != ""
278+ visible: x != 0 && y != 0
270 width: units.dp(8)
279 width: units.dp(8)
271 height: units.dp(16)
280 height: units.dp(16)
272 z: map.z + 1
281 z: map.z + 1