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,96 @@
|
||||
import QtQuick 2.2
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/i18n.js" as I18N
|
||||
|
||||
// Impostazioni: razze disponibili, mio pollaio, clienti, backup, lingua,
|
||||
// introduzione, informazioni. Le voci dell'app Flutter erano tre schede piu'
|
||||
// il selettore di lingua nella barra: qui diventano una lista di voci.
|
||||
Page {
|
||||
id: page
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string lang: "en"
|
||||
// Avvisa la Home che i dati sono cambiati (usato dal ripristino).
|
||||
property var onChanged: null
|
||||
property bool ready: false
|
||||
|
||||
function tr(key, arg) { return I18N.t(key, arg, page.lang) }
|
||||
|
||||
ListModel { id: entries }
|
||||
|
||||
function reload() {
|
||||
page.lang = I18N.langFor(appSettings.language, Qt.locale().name)
|
||||
entries.clear()
|
||||
entries.append({ "label": page.tr("available_breeds") })
|
||||
entries.append({ "label": page.tr("my_coop") })
|
||||
entries.append({ "label": page.tr("customers_list") })
|
||||
entries.append({ "label": page.tr("backup_restore") })
|
||||
entries.append({ "label": page.tr("language") })
|
||||
entries.append({ "label": page.tr("show_intro") })
|
||||
entries.append({ "label": page.tr("about") })
|
||||
}
|
||||
|
||||
function openEntry(index) {
|
||||
if (index === 0) {
|
||||
pageStack.push(Qt.resolvedUrl("BreedsPage.qml"))
|
||||
} else if (index === 1) {
|
||||
pageStack.push(Qt.resolvedUrl("CoopPage.qml"))
|
||||
} else if (index === 2) {
|
||||
pageStack.push(Qt.resolvedUrl("CustomersPage.qml"))
|
||||
} else if (index === 3) {
|
||||
pageStack.push(Qt.resolvedUrl("BackupPage.qml"),
|
||||
{ "onChanged": page.forwardChanged })
|
||||
} else if (index === 4) {
|
||||
pageStack.push(Qt.resolvedUrl("LanguagePage.qml"))
|
||||
} else if (index === 5) {
|
||||
pageStack.push(Qt.resolvedUrl("IntroPage.qml"), { "firstRun": false })
|
||||
} else if (index === 6) {
|
||||
pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
|
||||
}
|
||||
}
|
||||
|
||||
function forwardChanged() {
|
||||
if (page.onChanged)
|
||||
page.onChanged()
|
||||
}
|
||||
|
||||
Component.onCompleted: page.reload()
|
||||
|
||||
// al ritorno da una sottopagina i dati possono essere cambiati
|
||||
onStatusChanged: {
|
||||
if (status !== PageStatus.Active)
|
||||
return
|
||||
if (page.ready)
|
||||
page.reload()
|
||||
page.ready = true
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
|
||||
header: PageHeader { title: page.tr("settings") }
|
||||
model: entries
|
||||
|
||||
delegate: ListItem {
|
||||
id: entry
|
||||
|
||||
Label {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
right: parent.right
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: model.label
|
||||
color: entry.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
|
||||
onClicked: page.openEntry(index)
|
||||
}
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user