schermate di configurazione complete: razze disponibili, mio pollaio, registro galline, clienti, backup/ripristino nel formato dell'app Android, lingua a runtime, introduzione e informazioni
- datastore: export/import JSON con le chiavi camelCase dell'app Android (breedSettings/reservations/customers), scorte e ultimo aggiornamento preservati al ripristino - settings: flag 'introduzione vista' - desktop: permesso Documents (dove finisce il backup) - nuovi controlli: tools/check_qml.py (chiavi di traduzione, simboli JS, pagine, componenti) e qmllint nella suite - versione 0.2.0
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
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
|
||||
|
||||
// "Mio pollaio" (seconda scheda dell'originale): produzione del giorno e
|
||||
// razze allevate, con conteggi e stima per razza. Il tocco apre il registro
|
||||
// delle galline di quella razza.
|
||||
Page {
|
||||
id: page
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string lang: "en"
|
||||
property bool ready: false
|
||||
property var settings: []
|
||||
property real totalProduction: 0
|
||||
|
||||
function tr(key, arg) { return I18N.t(key, arg, page.lang) }
|
||||
|
||||
ListModel { id: breedModel }
|
||||
|
||||
function reload() {
|
||||
page.lang = I18N.langFor(appSettings.language, Qt.locale().name)
|
||||
page.settings = appData.breedSettings()
|
||||
page.totalProduction = HF.totalDailyProduction(page.settings, Catalog.HF_BREEDS)
|
||||
|
||||
breedModel.clear()
|
||||
for (var i = 0; i < page.settings.length; i++) {
|
||||
var s = page.settings[i]
|
||||
var breed = Catalog.breedFromId(s.breedId)
|
||||
var laying = HF.activeHens(s)
|
||||
var daily = laying * HF.eggsPerHenPerDay(Catalog.HF_BREEDS, s.breedId)
|
||||
breedModel.append({
|
||||
"n": i,
|
||||
"name": breed ? page.tr(breed.name) : s.breedId,
|
||||
"registered": page.tr("reg_hens") + ": " + (s.hens ? s.hens.length : 0),
|
||||
"laying": page.tr("laying_6_months") + ": " + laying,
|
||||
"production": page.tr("est_prod") + ": " + daily.toFixed(1) + " " + page.tr("eggs_per_day")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: page.reload()
|
||||
|
||||
onStatusChanged: {
|
||||
if (status !== PageStatus.Active)
|
||||
return
|
||||
if (page.ready)
|
||||
page.reload()
|
||||
page.ready = true
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
|
||||
header: Column {
|
||||
width: listView.width
|
||||
|
||||
PageHeader { title: page.tr("my_coop") }
|
||||
|
||||
Rectangle {
|
||||
x: Theme.horizontalPageMargin
|
||||
width: listView.width - 2 * Theme.horizontalPageMargin
|
||||
height: coopColumn.height + 2 * Theme.paddingMedium
|
||||
radius: Theme.paddingSmall
|
||||
color: Theme.rgba(Theme.highlightBackgroundColor, 0.12)
|
||||
|
||||
Column {
|
||||
id: coopColumn
|
||||
x: Theme.paddingMedium
|
||||
y: Theme.paddingMedium
|
||||
width: parent.width - 2 * Theme.paddingMedium
|
||||
spacing: Theme.paddingSmall
|
||||
|
||||
Label {
|
||||
text: page.tr("daily_prod_est")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
|
||||
Label {
|
||||
text: page.totalProduction.toFixed(1) + " " + page.tr("eggs_per_day")
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item { width: parent.width; height: Theme.paddingMedium }
|
||||
|
||||
SectionHeader { text: page.tr("available_breeds") }
|
||||
}
|
||||
|
||||
model: breedModel
|
||||
|
||||
delegate: ListItem {
|
||||
id: coopItem
|
||||
contentHeight: coopText.height + Theme.paddingMedium
|
||||
|
||||
Column {
|
||||
id: coopText
|
||||
x: Theme.horizontalPageMargin
|
||||
y: Theme.paddingMedium
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
spacing: Theme.paddingTiny
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.name
|
||||
color: coopItem.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.registered + " · " + model.laying
|
||||
color: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.production
|
||||
color: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("BreedDetailPage.qml"),
|
||||
{ "breedId": page.settings[index].breedId })
|
||||
}
|
||||
|
||||
ViewPlaceholder {
|
||||
enabled: breedModel.count === 0
|
||||
text: page.tr("no_breeds")
|
||||
hintText: page.tr("config_breed_first")
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: page.tr("available_breeds")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("BreedsPage.qml"))
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user