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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user