Files
harbour-aira/qml/pages/CommandsPage.qml
T
Carlo f4bee218bb 0.7.6: via il banner del remorse dai tasti rapidi
Alla pressione Silica ri-parenta il RemorseItem dentro la fila dei tre tasti e
ci disegna sopra il banner (messaggio + conto alla rovescia) a margini fissi:
il suo riquadro non ha la larghezza del tasto, quindi copre i tasti vicini.
Il messaggio lo mostra gia' la NoticeBar, che ora ha altezza fissa a una riga e
una banda riservata sotto il contenuto in tutte e cinque le pagine.
2026-10-11 17:26:13 +02:00

174 lines
6.2 KiB
QML

import QtQuick 2.2
import Sailfish.Silica 1.0
import "../components"
// Comandi impianto: i comandi che non stanno nella Home.
//
// Prima erano 12 pulsanti in quattro sezioni, otto dei quali in coppie
// accendi/spegni, con lo stato da leggere in sei righe piu' in alto. Ora ogni
// cosa che ha uno stato e' un interruttore: lo stato si vede e si cambia in un
// tocco solo (docs/UX-STUDIO.md).
//
// Gli interruttori NON anticipano l'impianto: `checked` segue l'ultimo dato
// vero (automaticCheck: false) e al tocco parte il comando. Se il comando non
// riesce, l'interruttore non si muove; se riesce, lo stato arriva da solo
// (ApiClient rilegge il riassunto due secondi dopo).
Page {
id: page
allowedOrientations: Orientation.All
function raw(key) {
return api.summary[key]
}
// La funzione riscaldamento e' abilitata quando i modi configurati della
// pompa la comprendono ("PUMP_MODE_STATE_HEATING").
function heatingEnabled() {
return String(page.raw("configured_modes") || "").indexOf("HEATING") >= 0
}
Component.onCompleted: {
if (api.configured)
api.refresh()
}
// Fuori dai pulsanti/interruttori: dentro finirebbero nel loro contentItem.
RemorseItem { id: remorse }
SilicaFlickable {
anchors.fill: parent
// Banda riservata al messaggio in fondo: cosi' non copre il contenuto.
anchors.bottomMargin: notice.banda
contentHeight: col.height + Theme.paddingLarge
PullDownMenu {
MenuItem {
text: qsTr("Refresh")
onClicked: api.refresh()
}
MenuItem {
text: qsTr("Data")
onClicked: pageStack.push(Qt.resolvedUrl("DataPage.qml"))
}
MenuItem {
text: qsTr("Plant")
onClicked: pageStack.push(Qt.resolvedUrl("PlantPage.qml"))
}
MenuItem {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
}
}
Column {
id: col
width: parent.width
spacing: Theme.paddingSmall
PageHeader { title: qsTr("Plant commands") }
// ---- modalita' -------------------------------------------------- //
SectionHeader { text: qsTr("Modes") }
TextSwitch {
id: awaySwitch
text: qsTr("Away mode")
description: qsTr("Lowers the house and stops the hot water")
automaticCheck: false
checked: page.raw("away_mode") === true
onClicked: {
if (checked)
api.sendCommand("away_mode_off")
else
api.sendCommand("away_mode_on")
}
}
TextSwitch {
text: qsTr("Forced heating")
description: qsTr("Heats at full power until you stop it")
automaticCheck: false
checked: page.raw("force_heating") === true
onClicked: {
if (checked)
api.sendCommand("force_heating_off")
else
api.sendCommand("force_heating_on")
}
}
TextSwitch {
id: heatingSwitch
text: qsTr("Heating")
description: qsTr("The heating can turn on")
automaticCheck: false
checked: page.heatingEnabled()
onClicked: {
// Spegnere il riscaldamento ha conseguenze: si conferma.
if (checked)
remorse.execute(heatingSwitch, qsTr("Heating will be disabled"),
function() { api.sendCommand("heating_off") })
else
api.sendCommand("heating_on")
}
}
// ---- acqua calda ------------------------------------------------ //
SectionHeader { text: qsTr("Domestic hot water") }
TextSwitch {
id: waterSwitch
text: qsTr("Hot water active")
description: qsTr("The heat pump keeps the water in temperature")
automaticCheck: false
checked: page.raw("hot_water_heating") === true
onClicked: {
if (checked)
remorse.execute(waterSwitch,
qsTr("Domestic hot water will stop being heated"),
function() { api.sendCommand("hot_water_heating_off") })
else
api.sendCommand("hot_water_heating_on")
}
}
ActionButton {
text: qsTr("Legionella cycle")
confirmText: qsTr("Starting the legionella cycle: it takes a while")
onTriggered: api.sendCommand("legionella_cycle")
}
// ---- rumore ----------------------------------------------------- //
SectionHeader { text: qsTr("Noise") }
ActionButton {
text: qsTr("Night mode for one hour")
onTriggered: api.sendCommand("night_mode_1h")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: qsTr("The switches show the current state of the plant: the Status section is not needed any more.")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.Wrap
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: qsTr("Commands go through the bridge and may take a few seconds. The status refreshes by itself afterwards.")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.Wrap
}
Item { width: 1; height: Theme.paddingMedium }
}
}
NoticeBar { id: notice }
}