Files
harbour-aira/qml/cover/CoverPage.qml
T

97 lines
3.1 KiB
QML

import QtQuick 2.0
import Sailfish.Silica 1.0
// Copertina: legge api.summary (context property C++), quindi non dipende
// dallo scope delle property della pagina principale.
CoverBackground {
id: cover
function t(key) {
var v = api.summary[key]
return api.formatValue(v)
}
// Colore del pallino: gli stessi criteri della Home (vedi MainPage.qml).
// Un dato vecchio e' ambra come un modo attivo: un dato vecchio non e' un
// dato buono, e la copertina e' il posto dove si guarda di sfuggita.
function statusColor() {
if (!api.hasData || api.stale)
return "orange"
var livello = api.statusLevel()
if (livello === 2)
return Theme.errorColor
if (livello === 1)
return Theme.highlightColor
return "#4caf50"
}
Row {
id: intestazione
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: Theme.paddingLarge
spacing: Theme.paddingSmall
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: Theme.paddingSmall
height: width
radius: width / 2
color: cover.statusColor()
}
Label {
text: "Aira"
color: Theme.primaryColor
font.pixelSize: Theme.fontSizeLarge
}
}
Column {
anchors.centerIn: parent
width: parent.width - 2 * Theme.paddingLarge
spacing: Theme.paddingSmall
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
// Spenta quando i numeri sono vecchi: non deve sembrare fresca.
color: api.stale ? Theme.secondaryColor : Theme.primaryColor
text: cover.t("zone1_temperature") + " °C"
font.pixelSize: Theme.fontSizeHuge
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: qsTr("house · target %1 °C").arg(cover.t("zone1_setpoint"))
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
truncationMode: TruncationMode.Fade
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: qsTr("DHW %1 °C · target %2 °C").arg(cover.t("dhw_current")).arg(cover.t("dhw_target"))
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
truncationMode: TruncationMode.Fade
}
}
Label {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingMedium
// Qui c'e' posto per dire che i numeri non sono freschi.
text: api.stale
? qsTr("Not updated · last %1").arg(api.lastUpdate)
: qsTr("outside %1 °C").arg(cover.t("outdoor_temperature"))
color: api.stale ? "orange" : Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
truncationMode: TruncationMode.Fade
width: parent.width - 2 * Theme.paddingMedium
}
}