fix critici: PullDownMenu dentro lista/flickable (figli di Page non funzionano su questo kit); via setTimeout (non esiste in QML JS Qt 5.6) — ripara sea state e ricerca online
This commit is contained in:
+37
-39
@@ -55,6 +55,26 @@ Page {
|
||||
{ port: page.port })
|
||||
}
|
||||
|
||||
function setPreferred() {
|
||||
if (!port) return
|
||||
console.log("[tide] setPreferred:", port[0])
|
||||
appSettings.preferredPort = port[0]
|
||||
// se è un comune (custom) salva le coordinate per la cover
|
||||
if (custom) {
|
||||
appSettings.preferredLat = port[2]
|
||||
appSettings.preferredLon = port[3]
|
||||
} else {
|
||||
appSettings.preferredLat = -1
|
||||
appSettings.preferredLon = -1
|
||||
}
|
||||
pageStack.replace(Qt.resolvedUrl("MainPage.qml"))
|
||||
}
|
||||
|
||||
function openSettings() {
|
||||
console.log("[tide] openSettings")
|
||||
pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
if (!port) {
|
||||
console.log("[tide] refresh: port UNDEFINED")
|
||||
@@ -107,14 +127,6 @@ Page {
|
||||
if (!port) return
|
||||
console.log("[tide] seaState fetch:", port[0])
|
||||
var xhr = new XMLHttpRequest()
|
||||
var done = false
|
||||
var to = setTimeout(function() {
|
||||
if (!done) {
|
||||
done = true
|
||||
console.log("[tide] seaState timeout")
|
||||
seaFail()
|
||||
}
|
||||
}, 12000)
|
||||
xhr.open("GET",
|
||||
"https://marine-api.open-meteo.com/v1/marine?latitude=" + port[2]
|
||||
+ "&longitude=" + port[3]
|
||||
@@ -122,9 +134,6 @@ Page {
|
||||
true)
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (done) return
|
||||
done = true
|
||||
clearTimeout(to)
|
||||
console.log("[tide] seaState status:", xhr.status)
|
||||
if (xhr.status === 200) {
|
||||
try {
|
||||
@@ -378,6 +387,23 @@ Page {
|
||||
|
||||
Item { width: parent.width; height: Theme.paddingLarge }
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Set as preferred port")
|
||||
visible: page.port && page.port[0] !== appSettings.preferredPort
|
||||
onClicked: page.setPreferred()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("30-day calendar")
|
||||
visible: page.port !== undefined
|
||||
onClicked: page.openCalendar()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Settings")
|
||||
onClicked: page.openSettings()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// disegno della curva (stesso algoritmo del mockup)
|
||||
@@ -453,32 +479,4 @@ Page {
|
||||
}
|
||||
|
||||
Component.onCompleted: init()
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Set as preferred port")
|
||||
visible: page.port && page.port[0] !== appSettings.preferredPort
|
||||
onClicked: {
|
||||
appSettings.preferredPort = page.port[0]
|
||||
// se è un comune (custom) salva le coordinate per la cover
|
||||
if (page.custom) {
|
||||
appSettings.preferredLat = page.port[2]
|
||||
appSettings.preferredLon = page.port[3]
|
||||
} else {
|
||||
appSettings.preferredLat = -1
|
||||
appSettings.preferredLon = -1
|
||||
}
|
||||
pageStack.replace(Qt.resolvedUrl("MainPage.qml"))
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("30-day calendar")
|
||||
visible: page.port !== undefined
|
||||
onClicked: page.openCalendar()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Settings")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-18
@@ -6,13 +6,6 @@ import "../js/comuni.js" as Comuni
|
||||
Page {
|
||||
id: page
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Settings")
|
||||
onClicked: page.openSettings()
|
||||
}
|
||||
}
|
||||
|
||||
// Campi di ricerca FUORI dall'header della lista: gli id dichiarati nel
|
||||
// componente header hanno scope chiuso e le funzioni del Page non li
|
||||
// vedono (ReferenceError "filter is not defined").
|
||||
@@ -42,6 +35,13 @@ Page {
|
||||
anchors.bottom: parent.bottom
|
||||
model: ListModel { id: resultModel }
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Settings")
|
||||
onClicked: page.openSettings()
|
||||
}
|
||||
}
|
||||
|
||||
footer: Item {
|
||||
width: parent.width
|
||||
height: resultModel.count === 0 ? Theme.itemSizeSmall * 1.6 : 0
|
||||
@@ -208,21 +208,10 @@ Page {
|
||||
// e supporta il filtro osm_tag=place:city per le città vere.
|
||||
console.log("[tide] geoXhr:", query)
|
||||
var xhr = new XMLHttpRequest()
|
||||
var done = false
|
||||
var to = setTimeout(function() {
|
||||
if (!done) {
|
||||
done = true
|
||||
console.log("[tide] geoXhr timeout")
|
||||
cb(null)
|
||||
}
|
||||
}, 12000)
|
||||
xhr.open("GET", "https://photon.komoot.io/api/?limit=1&osm_tag=place:city&q="
|
||||
+ encodeURIComponent(query), true)
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (done) return
|
||||
done = true
|
||||
clearTimeout(to)
|
||||
console.log("[tide] geoXhr status:", xhr.status)
|
||||
if (xhr.status === 200) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user