- CommandsPage: 4 interruttori (TextSwitch) al posto di 8 pulsanti in coppie accendi/spegni, piu' 3 pulsanti per le azioni senza stato. Gli interruttori seguono il dato vero (automaticCheck: false), non anticipano l'impianto, e la sezione 'Stato attuale' non serve piu'. - La pagina si chiama 'Comandi impianto'. - PlantPage: frase estesa dello stato, diagnostica (verifica impianto) e le letture che non avevano posto (pompa, modi consentiti, manuale, sbrinamento, luci di firma). - SettingsPage: 'Salva' e 'Prova connessione' diventano 'Salva e prova'. - ApiClient: dopo un comando riuscito lo stato si rilegge da solo (prima non si aggiornava nulla: l'aggiornamento automatico non esisteva). - NoticeBar anche su Dati, Impianto e Comandi; via i messaggi dentro il contenuto che scorre.
150 lines
5.3 KiB
QML
150 lines
5.3 KiB
QML
import QtQuick 2.2
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Indirizzo e token del bridge. Si salvano all'uscita dalla pagina, alla
|
|
// pressione di Invio e col pulsante Salva: NON a ogni tasto (QSettings.sync()
|
|
// su ogni carattere consuma scritture senza motivo).
|
|
Page {
|
|
id: page
|
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
property string urlText: appSettings.baseUrl
|
|
property string tokenText: appSettings.token
|
|
property string testResult: ""
|
|
property bool testOk: false
|
|
|
|
function save() {
|
|
appSettings.baseUrl = urlText.trim()
|
|
appSettings.token = tokenText.trim()
|
|
}
|
|
|
|
function testAndReport() {
|
|
save()
|
|
page.testResult = qsTr("checking…")
|
|
api.testConnection()
|
|
}
|
|
|
|
onStatusChanged: {
|
|
if (status === PageStatus.Inactive)
|
|
save()
|
|
}
|
|
|
|
Connections {
|
|
target: api
|
|
onConnectionTested: {
|
|
page.testOk = ok
|
|
page.testResult = message
|
|
}
|
|
}
|
|
|
|
SilicaFlickable {
|
|
anchors.fill: parent
|
|
contentHeight: col.height + Theme.paddingLarge
|
|
|
|
Column {
|
|
id: col
|
|
width: parent.width
|
|
spacing: Theme.paddingMedium
|
|
|
|
PageHeader { title: qsTr("Settings") }
|
|
|
|
// ---- lingua ---------------------------------------------------- //
|
|
SectionHeader { text: qsTr("Language") }
|
|
|
|
// Le voci si scelgono dal menu: il valore mostrato segue la scelta
|
|
// salvata (translator.language), non l'ultimo tocco.
|
|
ComboBox {
|
|
id: langBox
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
label: qsTr("Language")
|
|
value: translator.language === "it" ? "Italiano"
|
|
: translator.language === "en" ? "English"
|
|
: qsTr("System")
|
|
menu: ContextMenu {
|
|
MenuItem {
|
|
text: qsTr("System")
|
|
onClicked: translator.language = ""
|
|
}
|
|
// I nomi delle lingue restano nella lingua che nominano.
|
|
MenuItem {
|
|
text: "English"
|
|
onClicked: translator.language = "en"
|
|
}
|
|
MenuItem {
|
|
text: "Italiano"
|
|
onClicked: translator.language = "it"
|
|
}
|
|
}
|
|
}
|
|
|
|
Label {
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
text: qsTr("Changing the language reloads the app.")
|
|
color: Theme.secondaryColor
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
// ---- bridge ---------------------------------------------------- //
|
|
SectionHeader { text: qsTr("Bridge") }
|
|
|
|
TextField {
|
|
id: urlField
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
label: qsTr("Bridge address")
|
|
placeholderText: "192.168.2.50:8790"
|
|
text: page.urlText
|
|
onTextChanged: if (text !== page.urlText) page.urlText = text
|
|
EnterKey.enabled: true
|
|
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
|
|
EnterKey.onClicked: page.save()
|
|
}
|
|
|
|
// PasswordField: mette l'icona nativa mostra/nascondi, niente
|
|
// TextField con echoMode gestito a mano.
|
|
PasswordField {
|
|
id: tokenField
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
label: qsTr("Bridge token")
|
|
showEchoModeToggle: true
|
|
text: page.tokenText
|
|
onTextChanged: if (text !== page.tokenText) page.tokenText = text
|
|
EnterKey.enabled: true
|
|
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
|
|
EnterKey.onClicked: page.save()
|
|
}
|
|
|
|
Label {
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
text: qsTr("Address and token live on the server: the token is in aira_bridge.json next to the bridge. Without a scheme, http:// is used.")
|
|
color: Theme.secondaryColor
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
wrapMode: Text.Wrap
|
|
}
|
|
|
|
// Un pulsante solo: salvare e provare erano due gesti per la stessa
|
|
// cosa (il secondo salvava comunque).
|
|
Button {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("Save and test")
|
|
onClicked: page.testAndReport()
|
|
}
|
|
|
|
Label {
|
|
visible: page.testResult.length > 0
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
text: page.testResult
|
|
color: page.testOk ? Theme.highlightColor : Theme.errorColor
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
wrapMode: Text.Wrap
|
|
}
|
|
}
|
|
}
|
|
} |