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

80 lines
2.1 KiB
QML

import QtQuick 2.2
import Sailfish.Silica 1.0
import "../js/henflow.js" as HF
import "../js/i18n.js" as I18N
import "../js/catalog.js" as Catalog
// Cover: produzione stimata del giorno e ordini ancora da consegnare.
CoverBackground {
id: cover
property string lang: "en"
property real production: 0
property int pending: 0
function tr(key, arg) { return I18N.t(key, arg, cover.lang) }
function refresh() {
cover.lang = I18N.langFor(appSettings.language, Qt.locale().name)
cover.production = HF.totalDailyProduction(appData.breedSettings(), Catalog.HF_BREEDS)
var list = appData.reservations()
var n = 0
for (var i = 0; i < list.length; i++) {
if (!list[i].isDelivered)
n++
}
cover.pending = n
}
Component.onCompleted: refresh()
// i dati cambiano quando si salvano ordini o galline
Connections {
target: appData
onChanged: cover.refresh()
}
Label {
id: title
anchors {
top: parent.top
topMargin: Theme.paddingLarge
horizontalCenter: parent.horizontalCenter
}
text: cover.tr("app_title")
color: Theme.primaryColor
}
Column {
anchors.centerIn: parent
width: parent.width - 2 * Theme.paddingLarge
spacing: Theme.paddingSmall
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: cover.production.toFixed(1)
font.pixelSize: Theme.fontSizeHuge
color: Theme.highlightColor
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: cover.tr("eggs_per_day")
font.pixelSize: Theme.fontSizeSmall
color: Theme.secondaryColor
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: cover.tr("reservations") + ": " + cover.pending
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
}
}
}