sea state sotto la tabella alte/basse e previsione 3 giorni; menu Webcam -> mappa Windy centrata sul porto

This commit is contained in:
2026-09-02 19:04:08 +02:00
parent f92240567a
commit 1e475cf30c
3 changed files with 44 additions and 20 deletions
+40 -20
View File
@@ -75,6 +75,15 @@ Page {
pageStack.push(Qt.resolvedUrl("SettingsPage.qml")) pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
} }
function openWebcams() {
if (!port) return
// Mappa webcam pubblica di Windy centrata sul porto (nessuna API key)
var url = "https://www.windy.com/-Webcams/webcams/"
+ port[2] + "/" + port[3]
console.log("[tide] openWebcams:", url)
Qt.openUrlExternally(url)
}
function refresh() { function refresh() {
if (!port) { if (!port) {
console.log("[tide] refresh: port UNDEFINED") console.log("[tide] refresh: port UNDEFINED")
@@ -139,20 +148,25 @@ Page {
try { try {
var j = JSON.parse(xhr.responseText) var j = JSON.parse(xhr.responseText)
var wh = j.daily.wave_height_max var wh = j.daily.wave_height_max
if (wh && wh.length > 0) { if (wh && wh.length >= 2) {
var today = wh[0] // riga 1: oggi
var i0 = Tides.douglas(today) var i0 = Tides.douglas(wh[0])
seaLabel.text = seaNames[i0] + " · " + Tides.fmtH(today, page.unit) seaLabel.text = qsTranslate("Sea", "Today") + ": " + seaNames[i0]
+ " · " + Tides.fmtH(wh[0], page.unit)
seaLabel.color = i0 >= 5 ? Theme.errorColor seaLabel.color = i0 >= 5 ? Theme.errorColor
: (i0 >= 4 ? Theme.secondaryColor : Theme.highlightColor) : (i0 >= 4 ? Theme.secondaryColor : Theme.highlightColor)
if (wh.length > 1) { // riga 2: domani e terzo giorno
var i1 = Tides.douglas(wh[1]) var s = qsTranslate("Sea", "Tomorrow") + ": " + seaNames[Tides.douglas(wh[1])]
seaSub.text = qsTranslate("Sea", "Tomorrow") + ": " + seaNames[i1] + " (" + Tides.fmtH(wh[1], page.unit) + ")"
+ " · " + Tides.fmtH(wh[1], page.unit) if (wh.length > 2) {
seaSub.color = Theme.secondaryColor var d2 = new Date()
} else { d2.setDate(d2.getDate() + 2)
seaSub.text = "" s += " · " + page.dayNames[d2.getDay()] + ": "
+ seaNames[Tides.douglas(wh[2])]
+ " (" + Tides.fmtH(wh[2], page.unit) + ")"
} }
seaSub.text = s
seaSub.color = Theme.secondaryColor
return return
} }
} catch (e) { } catch (e) {
@@ -239,15 +253,6 @@ Page {
} }
} }
// Stato del mare (scala Douglas, previsione onde Open-Meteo)
Item { width: parent.width; height: Theme.itemSizeSmall
Label { text: "🌊 " + qsTranslate("Sea", "Sea state"); color: Theme.secondaryColor; anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin; anchors.verticalCenter: parent.verticalCenter }
Label { id: seaLabel; text: "…"; anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin + 130; anchors.right: parent.right; anchors.rightMargin: Theme.horizontalPageMargin; anchors.verticalCenter: parent.verticalCenter; horizontalAlignment: Text.AlignRight; truncationMode: TruncationMode.Fade }
}
Item { width: parent.width; height: Theme.itemSizeSmall
Label { id: seaSub; anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin + 130; anchors.right: parent.right; anchors.rightMargin: Theme.horizontalPageMargin; anchors.verticalCenter: parent.verticalCenter; horizontalAlignment: Text.AlignRight; font.pixelSize: Theme.fontSizeSmall; truncationMode: TruncationMode.Fade }
}
// Intervallo (chips 24/48/72) // Intervallo (chips 24/48/72)
Row { Row {
spacing: Theme.paddingMedium spacing: Theme.paddingMedium
@@ -370,6 +375,16 @@ Page {
} }
} }
// Stato del mare (scala Douglas, previsione onde Open-Meteo,
// oggi + domani + terzo giorno) — sotto la tabella alte/basse
Item { width: parent.width; height: Theme.itemSizeSmall
Label { text: "🌊 " + qsTranslate("Sea", "Sea state"); color: Theme.secondaryColor; anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin; anchors.verticalCenter: parent.verticalCenter }
Label { id: seaLabel; text: "…"; anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin + 130; anchors.right: parent.right; anchors.rightMargin: Theme.horizontalPageMargin; anchors.verticalCenter: parent.verticalCenter; horizontalAlignment: Text.AlignRight; truncationMode: TruncationMode.Fade }
}
Item { width: parent.width; height: Theme.itemSizeSmall
Label { id: seaSub; anchors.left: parent.left; anchors.leftMargin: Theme.horizontalPageMargin; anchors.right: parent.right; anchors.rightMargin: Theme.horizontalPageMargin; anchors.verticalCenter: parent.verticalCenter; horizontalAlignment: Text.AlignRight; font.pixelSize: Theme.fontSizeSmall; truncationMode: TruncationMode.Fade }
}
SectionHeader { text: qsTr("Astro") } SectionHeader { text: qsTr("Astro") }
Item { width: parent.width; height: Theme.itemSizeSmall Item { width: parent.width; height: Theme.itemSizeSmall
@@ -399,6 +414,11 @@ Page {
visible: page.port !== undefined visible: page.port !== undefined
onClicked: page.openCalendar() onClicked: page.openCalendar()
} }
MenuItem {
text: qsTr("Webcams")
visible: page.port !== undefined
onClicked: page.openWebcams()
}
MenuItem { MenuItem {
text: qsTr("Settings") text: qsTr("Settings")
onClicked: page.openSettings() onClicked: page.openSettings()
+2
View File
@@ -22,6 +22,7 @@
</context> </context>
<context> <context>
<name>DetailPage</name> <name>DetailPage</name>
<message><source>Webcams</source><translation type="unfinished"></translation></message>
<message><source>30-day calendar</source><translation type="unfinished"></translation></message> <message><source>30-day calendar</source><translation type="unfinished"></translation></message>
<message><source>lat %1°</source><translation type="unfinished"></translation></message> <message><source>lat %1°</source><translation type="unfinished"></translation></message>
<message><source>📍 Nearest port: %1 — %2 · ±%3 m</source><translation type="unfinished"></translation></message> <message><source>📍 Nearest port: %1 — %2 · ±%3 m</source><translation type="unfinished"></translation></message>
@@ -97,6 +98,7 @@
<message><source>Very high</source><translation type="unfinished"></translation></message> <message><source>Very high</source><translation type="unfinished"></translation></message>
<message><source>Phenomenal</source><translation type="unfinished"></translation></message> <message><source>Phenomenal</source><translation type="unfinished"></translation></message>
<message><source>Sea state</source><translation type="unfinished"></translation></message> <message><source>Sea state</source><translation type="unfinished"></translation></message>
<message><source>Today</source><translation type="unfinished"></translation></message>
<message><source>Tomorrow</source><translation type="unfinished"></translation></message> <message><source>Tomorrow</source><translation type="unfinished"></translation></message>
<message><source>Unavailable (offline)</source><translation type="unfinished"></translation></message> <message><source>Unavailable (offline)</source><translation type="unfinished"></translation></message>
</context> </context>
+2
View File
@@ -22,6 +22,7 @@
</context> </context>
<context> <context>
<name>DetailPage</name> <name>DetailPage</name>
<message><source>Webcams</source><translation>Webcam</translation></message>
<message><source>30-day calendar</source><translation>Calendario 30 giorni</translation></message> <message><source>30-day calendar</source><translation>Calendario 30 giorni</translation></message>
<message><source>lat %1°</source><translation>lat %1°</translation></message> <message><source>lat %1°</source><translation>lat %1°</translation></message>
<message><source>📍 Nearest port: %1 — %2 · ±%3 m</source><translation>📍 Porto più vicino: %1 — %2 · ±%3 m</translation></message> <message><source>📍 Nearest port: %1 — %2 · ±%3 m</source><translation>📍 Porto più vicino: %1 — %2 · ±%3 m</translation></message>
@@ -97,6 +98,7 @@
<message><source>Very high</source><translation>Molto grosso</translation></message> <message><source>Very high</source><translation>Molto grosso</translation></message>
<message><source>Phenomenal</source><translation>Tempestoso</translation></message> <message><source>Phenomenal</source><translation>Tempestoso</translation></message>
<message><source>Sea state</source><translation>Stato del mare</translation></message> <message><source>Sea state</source><translation>Stato del mare</translation></message>
<message><source>Today</source><translation>Oggi</translation></message>
<message><source>Tomorrow</source><translation>Domani</translation></message> <message><source>Tomorrow</source><translation>Domani</translation></message>
<message><source>Unavailable (offline)</source><translation>Non disponibile (offline)</translation></message> <message><source>Unavailable (offline)</source><translation>Non disponibile (offline)</translation></message>
</context> </context>