Prima versione di ThinQ: stato e comandi della lavasciuga via cloud LG

- elenco delle macchine e stato in lettura, fasi tradotte in italiano
- avvio, stop, spegnimento, ripresa e stop ritardato da 3 a 19 ore
- chiave di accesso custodita solo sul telefono, nel file privato dell'app
- 44 verifiche automatiche sul nucleo (scripts/test-core.sh)
- interfaccia italiana o inglese secondo la lingua del telefono
This commit is contained in:
kaneda committed 2026-10-12 12:03:23 +02:00
commit b5f6e79146
32 files changed
+2859

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "../js/status.js" as Status
CoverBackground {
Column {
anchors.centerIn: parent
width: parent.width - 2 * Theme.paddingMedium
spacing: Theme.paddingSmall
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: Theme.itemSizeSmall / 2.2
height: width
radius: width / 2
color: Status.statusColor(api.statusLevel)
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
color: Theme.primaryColor
font.pixelSize: Theme.fontSizeSmall
text: api.hasState ? api.phaseText : qsTr("No data")
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
visible: api.remainText.length > 0
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: api.remainText
}
}
CoverActionList {
CoverAction {
iconSource: "image://theme/icon-cover-refresh"
onTriggered: api.refresh()
}
}
}
+11
View File
@@ -0,0 +1,11 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "pages"
import "cover"
ApplicationWindow
{
initialPage: Component { MainPage { } }
cover: Component { CoverPage { } }
allowedOrientations: Orientation.All
}
+23
View File
@@ -0,0 +1,23 @@
// Livello di stato e colore corrispondente, in UN posto solo: la Home e la
// copertina devono raccontare la stessa cosa (due mappe = incoerenza).
// Livelli: -1 nessun dato, 0 spenta, 1 in corso, 2 in pausa, 3 finita, 4 errore.
//
// Colori letterali e non Theme.*: questo file e' importato sia dalle pagine sia
// dalla copertina e non deve dipendere da un .import di modulo.
function statusColor(level) {
if (level === 4)
return "#d32f2f"; // errore
if (level === 3)
return "#1f7ae0"; // finita
if (level === 2)
return "#ffb300"; // in pausa
if (level === 1)
return "#4caf50"; // in corso
return "#8c8c8c"; // spenta o nessun dato
}
// L'indicatore di attivita' pulsa solo quando c'e' qualcosa in corso.
function isActive(level) {
return level === 1;
}
+54
View File
@@ -0,0 +1,54 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
// Stop ritardato: 3-19 ore, gli unici valori che questa macchina accetta.
Dialog {
id: dialog
property int hours: api.delayHours
canAccept: true
onAccepted: {
api.setDelayHours(hours)
api.sendDelay()
}
Column {
width: parent.width
spacing: Theme.paddingMedium
DialogHeader {
title: qsTr("Delayed stop")
acceptText: qsTr("Set")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
wrapMode: Text.WordWrap
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
text: qsTr("The machine will stop on its own after the chosen time, then resume its programme.")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
horizontalAlignment: Text.AlignHCenter
text: dialog.hours + " h"
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeLarge
}
Slider {
width: parent.width
minimumValue: 3
maximumValue: 19
stepSize: 1
value: dialog.hours
valueText: value + " h"
onValueChanged: dialog.hours = Math.round(value)
}
}
}
+220
View File
@@ -0,0 +1,220 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "../js/status.js" as Status
Page {
id: page
allowedOrientations: Orientation.All
// La macchina si aggiorna solo mentre la schermata e' in primo piano:
// e' quello che l'utente ha scelto (niente ponte, niente servizio).
onStatusChanged: {
if (status === PageStatus.Active)
api.startPolling()
else
api.stopPolling()
}
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height + Theme.paddingLarge
PullDownMenu {
MenuItem {
text: qsTr("Refresh")
onClicked: api.refresh()
}
MenuItem {
text: qsTr("Delayed stop…")
onClicked: pageStack.push(Qt.resolvedUrl("DelayDialog.qml"))
}
MenuItem {
text: qsTr("Switch off")
enabled: api.canCommand
onClicked: api.powerOff()
}
MenuItem {
text: qsTr("Wake the display up")
enabled: api.canCommand
onClicked: api.wakeUp()
}
MenuItem {
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
}
}
Column {
id: column
width: parent.width
spacing: Theme.paddingMedium
PageHeader {
title: api.alias
description: api.configured
? (api.stale ? qsTr("Not up to date") : api.updatedText)
: qsTr("Not configured")
}
// Prima di tutto: se manca qualcosa per parlare con la macchina,
// dirlo qui invece di mostrare una schermata vuota.
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
visible: !api.configured
wrapMode: Text.WordWrap
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
text: qsTr("Enter the LG access token in Settings and pick your machine.")
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
visible: !api.configured
text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
}
// --- stato ---
Item {
width: parent.width
height: Theme.itemSizeLarge
visible: api.configured
Rectangle {
id: lamp
x: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
width: Theme.itemSizeSmall / 2.2
height: width
radius: width / 2
color: Status.statusColor(api.statusLevel)
SequentialAnimation on opacity {
running: Status.isActive(api.statusLevel)
loops: Animation.Infinite
PropertyAnimation { to: 0.35; duration: 900 }
PropertyAnimation { to: 1.0; duration: 900 }
}
}
Label {
anchors.left: lamp.right
anchors.leftMargin: Theme.paddingLarge
anchors.right: parent.right
anchors.rightMargin: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter
truncationMode: TruncationMode.Fade
text: api.phaseText
color: Theme.primaryColor
font.pixelSize: Theme.fontSizeLarge
}
}
// --- tempo rimanente ---
Column {
width: parent.width
visible: api.configured
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
horizontalAlignment: Text.AlignHCenter
text: api.remainText.length > 0 ? api.remainText : "--"
color: api.stale ? "orange" : Theme.primaryColor
font.pixelSize: Theme.fontSizeHuge
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
horizontalAlignment: Text.AlignHCenter
visible: api.totalText.length > 0
text: qsTr("of %1").arg(api.totalText)
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
}
}
// --- righe informative ---
Column {
width: parent.width
visible: api.configured
spacing: Theme.paddingSmall
DetailItem {
label: qsTr("Cycle")
value: api.cycleCount > 0 ? String(api.cycleCount) : "--"
}
DetailItem {
label: qsTr("Remote start")
value: api.remoteEnabled ? qsTr("on") : qsTr("off")
}
}
// Se il comando a distanza e' spento, dirlo con le parole necessarie
// invece di lasciare un tasto che non funziona.
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
visible: api.configured && api.hasState && !api.remoteEnabled
wrapMode: Text.WordWrap
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: qsTr("To send commands, switch remote start on from the machine panel.")
}
// --- UN comando, che cambia secondo lo stato ---
Button {
id: primaryButton
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 2 * Theme.horizontalPageMargin
height: Theme.itemSizeLarge
visible: api.configured
enabled: api.canCommand && !api.busy
text: api.primaryLabel
onClicked: api.runPrimary()
}
BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
size: BusyIndicatorSize.Small
running: api.busy
}
Item { width: 1; height: Theme.paddingLarge }
}
VerticalScrollDecorator { }
}
// Banner dei messaggi: ancorato al bordo e di altezza fissa, cosi' non
// sposta ne' copre il contenuto.
Rectangle {
id: noticeBar
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: api.notice.length > 0 ? Theme.itemSizeSmall : 0
color: api.noticeIsError ? "#b3261e" : "#2e5d3a"
visible: height > 0
Label {
anchors.fill: parent
anchors.leftMargin: Theme.horizontalPageMargin
anchors.rightMargin: Theme.horizontalPageMargin
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
color: "white"
font.pixelSize: Theme.fontSizeExtraSmall
text: api.notice
}
MouseArea {
anchors.fill: parent
onClicked: api.clearNotice()
}
}
}
+142
View File
@@ -0,0 +1,142 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
Page {
id: page
property string tokenDraft: appSettings.token
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height + Theme.paddingLarge
Column {
id: column
width: parent.width
spacing: Theme.paddingMedium
PageHeader {
title: qsTr("Settings")
}
SectionHeader {
text: qsTr("LG account")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
wrapMode: Text.WordWrap
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: qsTr("The access token comes from connect-pat.lgthinq.com and stays on this phone only. If LG starts refusing it, paste a new one here.")
}
TextField {
id: tokenField
anchors.left: parent.left
anchors.right: parent.right
label: qsTr("Access token")
placeholderText: qsTr("paste the token")
echoMode: TextInput.Password
text: page.tokenDraft
onTextChanged: page.tokenDraft = text
}
TextField {
id: countryField
anchors.left: parent.left
anchors.right: parent.right
label: qsTr("Country code")
placeholderText: "IT"
// Il valore si carica una volta: legarlo alla property farebbe
// riscrivere il campo sotto le dita (il codice paese viene
// normalizzato in maiuscolo).
onTextChanged: appSettings.country = text
Component.onCompleted: text = appSettings.country
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Save the token")
onClicked: {
appSettings.token = page.tokenDraft
api.reloadCredentials()
api.discover()
}
}
SectionHeader {
text: qsTr("Machine")
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Find my machines")
onClicked: api.discover()
}
ComboBox {
anchors.left: parent.left
anchors.right: parent.right
label: qsTr("Machine")
visible: api.deviceCount > 0
currentIndex: api.selectedDevice
menu: ContextMenu {
Repeater {
model: api.deviceCount
MenuItem {
text: api.deviceLabels[index]
}
}
}
onCurrentIndexChanged: {
if (currentIndex >= 0 && currentIndex !== api.selectedDevice)
api.chooseDevice(currentIndex)
}
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
visible: appSettings.deviceAlias.length > 0
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: qsTr("Selected: %1").arg(appSettings.deviceAlias)
}
SectionHeader {
text: qsTr("Language")
}
ComboBox {
anchors.left: parent.left
anchors.right: parent.right
label: qsTr("Language")
currentIndex: translator.language === "it" ? 2 : (translator.language === "en" ? 1 : 0)
menu: ContextMenu {
MenuItem { text: qsTr("System") }
MenuItem { text: "English" }
MenuItem { text: "Italiano" }
}
onCurrentIndexChanged: {
translator.language = currentIndex === 2 ? "it"
: (currentIndex === 1 ? "en" : "system")
}
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
horizontalAlignment: Text.AlignHCenter
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: qsTr("Version %1").arg(appVersion)
}
Item { width: 1; height: Theme.paddingLarge }
}
VerticalScrollDecorator { }
}
}