harbour-maree 0.1.0: motore armonico 7 costituenti, 16 porti, ricerca libera (Nominatim+locale), grafico 24/48/72h, EN/IT, preferenze (lingua, porto, unità, intervallo), icone harbour
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/tides.js" as Tides
|
||||
|
||||
CoverBackground {
|
||||
id: cover
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.paddingSmall
|
||||
width: parent.width
|
||||
|
||||
Label {
|
||||
text: "🌊 Maree"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.primaryColor
|
||||
}
|
||||
Label {
|
||||
id: portLabel
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
color: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: qsTr("No port selected")
|
||||
}
|
||||
Label {
|
||||
id: nextLabel
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
color: Theme.highlightColor
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
wrapMode: Text.Wrap
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status === Cover.Active) refresh()
|
||||
}
|
||||
|
||||
Component.onCompleted: refresh()
|
||||
|
||||
function refresh() {
|
||||
var pref = appSettings.preferredPort
|
||||
if (pref === "") {
|
||||
portLabel.text = qsTr("No port selected")
|
||||
nextLabel.text = ""
|
||||
return
|
||||
}
|
||||
var p = null
|
||||
for (var i = 0; i < Tides.PORTS.length; i++) {
|
||||
if (Tides.PORTS[i][0] === pref) { p = Tides.PORTS[i]; break }
|
||||
}
|
||||
if (!p) { portLabel.text = qsTr("No port selected"); nextLabel.text = ""; return }
|
||||
portLabel.text = p[0]
|
||||
var ex = Tides.extrema(p, new Date(), 1)
|
||||
if (ex.length > 0) {
|
||||
var e = ex[0]
|
||||
var kind = e.kind === "high" ? qsTr("High") : qsTr("Low")
|
||||
nextLabel.text = kind + " " + Tides.fmtHM(e.t) + " · " + Tides.fmtH(e.h, appSettings.unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user