Schermata principale con tutte le macchine, avviso di fine lavaggio, IT/EN

- la chiave si chiede una volta sola: poi la schermata principale mostra
  ogni macchina dell'account col suo stato e il suo comando
- avviso di sistema a fine lavaggio, anche se il ciclo e' finito mentre
  l'app era chiusa (si annota il numero di ciclo gia' avvisato)
- comandi per singola macchina: avvio/stop, spegnimento, risveglio,
  stop ritardato (nel menu della macchina, tocco prolungato sul nome)
- le macchine non raggiungibili vengono segnate come non collegate,
  senza riempire la barra dei messaggi ad ogni aggiornamento
- multilingua italiano/inglese, catalogo verificato dal banco di prova
  (52 controlli)
This commit is contained in:
kaneda committed 2026-10-12 12:38:10 +02:00
1 parent fe961b438c
commit e2c6f28613
14 files changed
+1015 -541

No files matched your search

+10 -4
View File
@@ -2,7 +2,11 @@ import QtQuick 2.2
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import "../js/status.js" as Status import "../js/status.js" as Status
// Copertina: la macchina che sta lavorando (se ce n'e' una), altrimenti la
// prima. Stesse funzioni della schermata principale: una sola verita'.
CoverBackground { CoverBackground {
property int shown: api.activeIndex()
Column { Column {
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width - 2 * Theme.paddingMedium width: parent.width - 2 * Theme.paddingMedium
@@ -13,7 +17,7 @@ CoverBackground {
width: Theme.itemSizeSmall / 2.2 width: Theme.itemSizeSmall / 2.2
height: width height: width
radius: width / 2 radius: width / 2
color: Status.statusColor(api.statusLevel) color: Status.statusColor(api.statusLevelAt(shown))
} }
Label { Label {
@@ -22,16 +26,18 @@ CoverBackground {
elide: Text.ElideRight elide: Text.ElideRight
color: Theme.primaryColor color: Theme.primaryColor
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
text: api.hasState ? api.phaseText : qsTr("No data") text: api.validIndex(shown) && api.hasStateAt(shown)
? api.phaseTextAt(shown)
: qsTr("No data")
} }
Label { Label {
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
visible: api.remainText.length > 0 visible: api.validIndex(shown) && api.remainTextAt(shown).length > 0
color: Theme.secondaryColor color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall font.pixelSize: Theme.fontSizeExtraSmall
text: api.remainText text: api.validIndex(shown) ? api.remainTextAt(shown) : ""
} }
} }
+22
View File
@@ -1,5 +1,6 @@
import QtQuick 2.2 import QtQuick 2.2
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import Nemo.Notifications 1.0
import "pages" import "pages"
import "cover" import "cover"
@@ -8,4 +9,25 @@ ApplicationWindow
initialPage: Component { MainPage { } } initialPage: Component { MainPage { } }
cover: Component { CoverPage { } } cover: Component { CoverPage { } }
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
// Avviso di fine lavaggio. La macchina lo racconta al cloud, l'app lo
// chiede al cloud: nessun server di mezzo. Arriva quando l'app e' viva e
// ha appena visto il ciclo finire; se nel frattempo era chiusa, arriva
// alla prima riapertura.
Notification {
id: cycleNotice
appName: "ThinQ"
appIcon: "harbour-thinq"
urgency: Notification.Normal
expireTimeout: 10000
}
Connections {
target: api
onCycleFinished: {
cycleNotice.summary = qsTr("Washing finished")
cycleNotice.body = label
cycleNotice.publish()
}
}
} }
+8 -4
View File
@@ -1,17 +1,20 @@
import QtQuick 2.2 import QtQuick 2.2
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
// Stop ritardato: 3-19 ore, gli unici valori che questa macchina accetta. // Stop ritardato: 3-19 ore, gli unici valori che queste macchine accettano.
// Si apre dal menu di UNA macchina: senza l'indice il comando andrebbe a
// quella sbagliata.
Dialog { Dialog {
id: dialog id: dialog
property int deviceIndex: -1
property int hours: api.delayHours property int hours: api.delayHours
canAccept: true canAccept: api.canCommandAt(deviceIndex)
onAccepted: { onAccepted: {
api.setDelayHours(hours) api.setDelayHours(hours)
api.sendDelay() api.sendDelayAt(deviceIndex)
} }
Column { Column {
@@ -19,7 +22,8 @@ Dialog {
spacing: Theme.paddingMedium spacing: Theme.paddingMedium
DialogHeader { DialogHeader {
title: qsTr("Delayed stop") title: api.validIndex(deviceIndex) ? api.labelAt(deviceIndex)
: qsTr("Delayed stop")
acceptText: qsTr("Set") acceptText: qsTr("Set")
} }
+199 -122
View File
@@ -2,13 +2,17 @@ import QtQuick 2.2
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import "../js/status.js" as Status import "../js/status.js" as Status
// Prima schermata. Due volti:
// * senza chiave di accesso -> si chiede una volta sola (qui, non nelle
// impostazioni) e poi non se ne parla piu';
// * con la chiave -> l'elenco delle macchine, ognuna col suo stato.
Page { Page {
id: page id: page
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
// La macchina si aggiorna solo mentre la schermata e' in primo piano: // La macchina si aggiorna solo mentre la schermata e' in primo piano:
// e' quello che l'utente ha scelto (niente ponte, niente servizio). // niente ponte, niente servizio che gira di nascosto.
onStatusChanged: { onStatusChanged: {
if (status === PageStatus.Active) if (status === PageStatus.Active)
api.startPolling() api.startPolling()
@@ -23,22 +27,9 @@ Page {
PullDownMenu { PullDownMenu {
MenuItem { MenuItem {
text: qsTr("Refresh") text: qsTr("Refresh")
enabled: api.configured
onClicked: api.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 { MenuItem {
text: qsTr("Settings") text: qsTr("Settings")
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml")) onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
@@ -51,131 +42,217 @@ Page {
spacing: Theme.paddingMedium spacing: Theme.paddingMedium
PageHeader { PageHeader {
title: api.alias title: qsTr("My machines")
description: api.configured description: api.configured
? (api.stale ? qsTr("Not up to date") : api.updatedText) ? (api.busy ? qsTr("Updating…") : qsTr("%1 found").arg(api.deviceCount))
: qsTr("Not configured") : qsTr("First setup")
} }
// Prima di tutto: se manca qualcosa per parlare con la macchina, // ---------------------------------------------------------------
// dirlo qui invece di mostrare una schermata vuota. // Primo avvio: le credenziali si chiedono qui, una volta sola.
Label { // ---------------------------------------------------------------
x: Theme.horizontalPageMargin Column {
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 width: parent.width
height: Theme.itemSizeLarge visible: !api.configured
visible: api.configured spacing: Theme.paddingMedium
Rectangle { Label {
id: lamp
x: Theme.horizontalPageMargin x: Theme.horizontalPageMargin
anchors.verticalCenter: parent.verticalCenter width: parent.width - 2 * Theme.horizontalPageMargin
width: Theme.itemSizeSmall / 2.2 wrapMode: Text.WordWrap
height: width color: Theme.secondaryColor
radius: width / 2 font.pixelSize: Theme.fontSizeExtraSmall
color: Status.statusColor(api.statusLevel) 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.")
}
SequentialAnimation on opacity { TextField {
running: Status.isActive(api.statusLevel) id: setupToken
loops: Animation.Infinite anchors.left: parent.left
PropertyAnimation { to: 0.35; duration: 900 } anchors.right: parent.right
PropertyAnimation { to: 1.0; duration: 900 } label: qsTr("Access token")
placeholderText: qsTr("paste the token")
echoMode: TextInput.Password
}
TextField {
id: setupCountry
anchors.left: parent.left
anchors.right: parent.right
label: qsTr("Country code")
placeholderText: "IT"
onTextChanged: appSettings.country = text
Component.onCompleted: text = appSettings.country
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 2 * Theme.horizontalPageMargin
height: Theme.itemSizeMedium
enabled: setupToken.text.length > 0 && !api.busy
text: qsTr("Connect")
onClicked: {
appSettings.token = setupToken.text
api.reloadCredentials()
api.discover()
} }
} }
}
Label { // ---------------------------------------------------------------
anchors.left: lamp.right // Ogni macchina dell'account, col suo stato e il suo comando.
anchors.leftMargin: Theme.paddingLarge // ---------------------------------------------------------------
anchors.right: parent.right Repeater {
anchors.rightMargin: Theme.horizontalPageMargin model: api.configured ? api.deviceCount : 0
anchors.verticalCenter: parent.verticalCenter
truncationMode: TruncationMode.Fade delegate: Column {
text: api.phaseText id: machine
color: Theme.primaryColor width: column.width
font.pixelSize: Theme.fontSizeLarge spacing: Theme.paddingSmall
// Nome e fase: il tocco prolungato apre le azioni della
// macchina (stop ritardato, spegni, risveglia).
Item {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
height: Math.max(lamp.height, nameBox.height)
Rectangle {
id: lamp
anchors.verticalCenter: parent.verticalCenter
width: Theme.itemSizeSmall / 2.2
height: width
radius: width / 2
color: Status.statusColor(api.statusLevelAt(index))
SequentialAnimation on opacity {
running: Status.isActive(api.statusLevelAt(index))
loops: Animation.Infinite
PropertyAnimation { to: 0.35; duration: 900 }
PropertyAnimation { to: 1.0; duration: 900 }
}
}
Column {
id: nameBox
anchors.left: lamp.right
anchors.leftMargin: Theme.paddingLarge
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.paddingTiny
Label {
width: parent.width
truncationMode: TruncationMode.Fade
text: api.labelAt(index)
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeMedium
}
Label {
width: parent.width
truncationMode: TruncationMode.Fade
text: api.offlineAt(index)
? qsTr("Not connected")
: api.phaseTextAt(index)
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
}
}
MouseArea {
anchors.fill: parent
onPressAndHold: machineMenu.open(this)
}
}
Label {
anchors.horizontalCenter: parent.horizontalCenter
visible: api.hasStateAt(index)
text: api.remainTextAt(index).length > 0 ? api.remainTextAt(index) : "--"
color: api.staleAt(index) ? "orange" : Theme.primaryColor
font.pixelSize: Theme.fontSizeHuge
}
Label {
anchors.horizontalCenter: parent.horizontalCenter
visible: api.totalLineAt(index).length > 0
text: api.totalLineAt(index)
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
}
// Se la macchina non risponde o ha l'avvio a distanza
// spento, dirlo con le parole necessarie invece di lasciare
// un tasto che non funziona.
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
wrapMode: Text.WordWrap
visible: api.hasStateAt(index) && !api.remoteEnabledAt(index)
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: qsTr("To send commands, switch remote start on from the machine panel.")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
wrapMode: Text.WordWrap
visible: api.offlineAt(index)
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
text: qsTr("The washing machine is not connected (switched off or offline)")
}
// UN comando per macchina, che cambia secondo il suo stato.
Button {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 2 * Theme.horizontalPageMargin
height: Theme.itemSizeMedium
visible: api.hasStateAt(index)
enabled: api.canCommandAt(index) && !api.busy
text: api.primaryLabelAt(index)
onClicked: api.runPrimaryAt(index)
}
ContextMenu {
id: machineMenu
MenuItem {
text: qsTr("Delayed stop…")
enabled: api.canCommandAt(index)
onClicked: pageStack.push(Qt.resolvedUrl("DelayDialog.qml"),
{ "deviceIndex": index })
}
MenuItem {
text: qsTr("Switch off")
enabled: api.canCommandAt(index)
onClicked: api.powerOffAt(index)
}
MenuItem {
text: qsTr("Wake the display up")
enabled: api.canCommandAt(index)
onClicked: api.wakeUpAt(index)
}
}
Separator {
width: parent.width
color: Theme.secondaryHighlightColor
}
} }
} }
// --- tempo rimanente --- // Chiave presente ma nessuna macchina: dirlo qui, non con una
Column { // schermata vuota.
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 { Label {
x: Theme.horizontalPageMargin x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin width: parent.width - 2 * Theme.horizontalPageMargin
visible: api.configured && api.hasState && !api.remoteEnabled
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
visible: api.configured && api.deviceCount === 0 && !api.busy
color: Theme.secondaryColor color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall font.pixelSize: Theme.fontSizeSmall
text: qsTr("To send commands, switch remote start on from the machine panel.") text: qsTr("No machine found yet. Pull down to search again.")
}
// --- 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 { BusyIndicator {
+12 -30
View File
@@ -1,6 +1,8 @@
import QtQuick 2.2 import QtQuick 2.2
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
// Impostazioni: la chiave, il paese, la lingua. Le macchine non si scelgono
// piu' qui: la schermata principale le mostra tutte.
Page { Page {
id: page id: page
@@ -67,7 +69,16 @@ Page {
} }
SectionHeader { SectionHeader {
text: qsTr("Machine") text: qsTr("Machines")
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
wrapMode: Text.WordWrap
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
text: qsTr("%1 found").arg(api.deviceCount)
} }
Button { Button {
@@ -76,35 +87,6 @@ Page {
onClicked: api.discover() 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 { SectionHeader {
text: qsTr("Language") text: qsTr("Language")
} }
+9 -1
View File
@@ -1,6 +1,6 @@
Name: harbour-thinq Name: harbour-thinq
Summary: Control an LG ThinQ washing machine Summary: Control an LG ThinQ washing machine
Version: 0.1.2 Version: 0.2.0
Release: 1 Release: 1
Group: Qt/Qt Group: Qt/Qt
License: MIT License: MIT
@@ -26,6 +26,14 @@ ThinQ Connect cloud from the phone: no server in between. The access token
is stored only on the device, in the app private configuration file. is stored only on the device, in the app private configuration file.
%changelog %changelog
* Mon Oct 12 2026 Carlo - 0.2.0-1
- la schermata principale chiede la chiave una volta sola, poi mostra tutte le
macchine dell'account con lo stato di ciascuna
- avviso di sistema a fine lavaggio (anche se il ciclo e' finito mentre l'app
era chiusa)
- comandi per singola macchina: avvio/stop, spegnimento, risveglio, stop ritardato
- multilingua italiano/inglese
* Mon Oct 12 2026 Carlo - 0.1.2-1 * Mon Oct 12 2026 Carlo - 0.1.2-1
- nome mostrato nel launcher: ThinQ - nome mostrato nel launcher: ThinQ
+12
View File
@@ -53,6 +53,18 @@ IT = {
"Language": "Lingua", "Language": "Lingua",
"System": "Sistema", "System": "Sistema",
"Version %1": "Versione %1", "Version %1": "Versione %1",
"My machines": "Le mie macchine",
"Updating…": "Aggiornamento…",
"%1 found": "%1 trovate",
"First setup": "Primo avvio",
"Connect": "Collega",
"Not connected": "Non collegata",
"No machine found yet. Pull down to search again.":
"Nessuna macchina trovata. Trascina in basso per cercare di nuovo.",
"Washing finished": "Lavaggio finito",
"Machines": "Macchine",
"The access token is missing": "Manca la chiave di accesso",
"No machine to command": "Nessuna macchina da comandare",
"Washing machine": "Lavatrice", "Washing machine": "Lavatrice",
"Start": "Avvia", "Start": "Avvia",
"Stop": "Ferma", "Stop": "Ferma",
+2 -2
View File
@@ -21,7 +21,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
app->setOrganizationName(QStringLiteral("harbour")); app->setOrganizationName(QStringLiteral("harbour"));
app->setApplicationName(QStringLiteral("thinq")); app->setApplicationName(QStringLiteral("thinq"));
app->setApplicationVersion(QStringLiteral("0.1.2")); app->setApplicationVersion(QStringLiteral("0.2.0"));
Settings settings; Settings settings;
ThinQClient api(&settings); ThinQClient api(&settings);
@@ -34,7 +34,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QQuickView *view = SailfishApp::createView(); QQuickView *view = SailfishApp::createView();
// Prima riga del log: dice se il device sta girando la build nuova o una stale. // Prima riga del log: dice se il device sta girando la build nuova o una stale.
qDebug() << "harbour-thinq v0.1.2 build" << __DATE__ << __TIME__; qDebug() << "harbour-thinq v0.2.0 build" << __DATE__ << __TIME__;
view->rootContext()->setContextProperty(QStringLiteral("appSettings"), &settings); view->rootContext()->setContextProperty(QStringLiteral("appSettings"), &settings);
view->rootContext()->setContextProperty(QStringLiteral("api"), &api); view->rootContext()->setContextProperty(QStringLiteral("api"), &api);
+15
View File
@@ -104,3 +104,18 @@ void Settings::setLanguage(const QString &value)
m_settings.sync(); m_settings.sync();
emit languageChanged(); emit languageChanged();
} }
int Settings::notifiedCycleFor(const QString &deviceId) const
{
if (deviceId.isEmpty())
return 0;
return m_settings.value(QStringLiteral("notified/") + deviceId, 0).toInt();
}
void Settings::setNotifiedCycleFor(const QString &deviceId, int cycle)
{
if (deviceId.isEmpty() || cycle <= 0)
return;
m_settings.setValue(QStringLiteral("notified/") + deviceId, cycle);
m_settings.sync();
}
+6
View File
@@ -41,6 +41,12 @@ public:
QString language() const { return m_language; } QString language() const { return m_language; }
void setLanguage(const QString &value); void setLanguage(const QString &value);
// Ciclo gia' avvisato per ciascuna macchina: serve a non ripetere l'avviso
// di fine lavaggio, e a recuperarlo se l'app era chiusa quando la macchina
// ha finito.
int notifiedCycleFor(const QString &deviceId) const;
void setNotifiedCycleFor(const QString &deviceId, int cycle);
signals: signals:
void tokenChanged(); void tokenChanged();
void countryChanged(); void countryChanged();
+281 -99
View File
@@ -3,7 +3,6 @@
#include "settings.h" #include "settings.h"
#include <QCoreApplication> #include <QCoreApplication>
#include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
@@ -27,72 +26,145 @@ ThinQClient::ThinQClient(Settings *settings, QObject *parent)
, m_settings(settings) , m_settings(settings)
{ {
m_pollTimer.setSingleShot(true); m_pollTimer.setSingleShot(true);
// Una richiesta per volta: il timer riparte dopo ogni risposta (vedi scheduleNextPoll). // Una macchina per volta: ogni risposta fa partire la richiesta successiva
// (pumpQueue), cosi' l'app non bombarda il cloud LG.
connect(&m_pollTimer, &QTimer::timeout, this, [this]() { refresh(); }); connect(&m_pollTimer, &QTimer::timeout, this, [this]() { refresh(); });
connect(m_settings, &Settings::tokenChanged, this, [this]() { connect(m_settings, &Settings::tokenChanged, this, [this]() {
m_state = WasherState(); m_devices.clear();
m_stale = false; m_queue.clear();
m_updated.clear(); m_stateInFlight = false;
emit infoChanged(); setBusy(false);
emit devicesChanged();
emit stateChanged(); emit stateChanged();
}); });
connect(m_settings, &Settings::deviceChanged, this, [this]() {
m_state = WasherState();
emit infoChanged();
emit stateChanged();
refresh();
});
} }
bool ThinQClient::configured() const bool ThinQClient::configured() const
{ {
return !m_settings->token().isEmpty() && !m_settings->deviceId().isEmpty(); return !m_settings->token().isEmpty();
} }
QString ThinQClient::alias() const int ThinQClient::activeIndex() const
{ {
const QString a = m_settings->deviceAlias(); for (int i = 0; i < m_devices.size(); ++i) {
return a.isEmpty() ? QCoreApplication::translate("ThinQ", "Washing machine") : a; if (ThinQJson::statusLevel(m_devices.at(i).state) == 1)
return i;
}
for (int i = 0; i < m_devices.size(); ++i) {
if (m_devices.at(i).hasState)
return i;
}
return m_devices.isEmpty() ? -1 : 0;
} }
QString ThinQClient::phaseText() const bool ThinQClient::validIndex(int index) const
{ {
if (!m_state.valid) return index >= 0 && index < m_devices.size();
}
QString ThinQClient::labelAt(int index) const
{
if (!validIndex(index))
return QString();
const QString label = m_devices.at(index).label;
return label.isEmpty()
? QCoreApplication::translate("ThinQ", "Washing machine")
: label;
}
bool ThinQClient::hasStateAt(int index) const
{
return validIndex(index) && m_devices.at(index).hasState;
}
bool ThinQClient::offlineAt(int index) const
{
return validIndex(index) && m_devices.at(index).offline;
}
bool ThinQClient::staleAt(int index) const
{
return validIndex(index) && m_devices.at(index).stale;
}
QString ThinQClient::phaseTextAt(int index) const
{
if (!hasStateAt(index))
return QCoreApplication::translate("ThinQ", "No data"); return QCoreApplication::translate("ThinQ", "No data");
return ThinQJson::phaseLabel(m_state); return ThinQJson::phaseLabel(m_devices.at(index).state);
} }
int ThinQClient::statusLevel() const int ThinQClient::statusLevelAt(int index) const
{ {
return ThinQJson::statusLevel(m_state); if (!validIndex(index))
return -1;
return ThinQJson::statusLevel(m_devices.at(index).state);
} }
QString ThinQClient::remainText() const QString ThinQClient::remainTextAt(int index) const
{ {
return ThinQJson::durationText(m_state.remainMinutes); if (!validIndex(index))
return QString();
return ThinQJson::durationText(m_devices.at(index).state.remainMinutes);
} }
QString ThinQClient::totalText() const QString ThinQClient::totalTextAt(int index) const
{ {
return ThinQJson::durationText(m_state.totalMinutes); if (!validIndex(index))
return QString();
return ThinQJson::durationText(m_devices.at(index).state.totalMinutes);
} }
QString ThinQClient::primaryLabel() const QString ThinQClient::totalLineAt(int index) const
{ {
if (!m_state.valid) const QString total = totalTextAt(index);
if (total.isEmpty())
return QString();
return QCoreApplication::translate("ThinQ", "of %1").arg(total);
}
int ThinQClient::cycleCountAt(int index) const
{
if (!validIndex(index))
return 0;
return m_devices.at(index).state.cycleCount;
}
bool ThinQClient::remoteEnabledAt(int index) const
{
if (!hasStateAt(index))
return false;
return m_devices.at(index).state.remoteEnabled;
}
QString ThinQClient::primaryLabelAt(int index) const
{
if (!hasStateAt(index))
return QCoreApplication::translate("ThinQ", "Start"); return QCoreApplication::translate("ThinQ", "Start");
return ThinQJson::primaryActionLabel(m_state); return ThinQJson::primaryActionLabel(m_devices.at(index).state);
} }
bool ThinQClient::canCommand() const bool ThinQClient::canCommandAt(int index) const
{ {
return configured() && m_state.valid && m_state.remoteEnabled; if (!hasStateAt(index))
return false;
const DeviceEntry &e = m_devices.at(index);
return !e.offline && e.state.remoteEnabled;
} }
QString ThinQClient::updatedText() const QString ThinQClient::updatedTextAt(int index) const
{ {
return m_updated; if (!validIndex(index))
return QString();
return m_devices.at(index).updated;
}
QString ThinQClient::deviceIdAt(int index) const
{
if (!validIndex(index))
return QString();
return m_devices.at(index).id;
} }
void ThinQClient::setDelayHours(int hours) void ThinQClient::setDelayHours(int hours)
@@ -143,7 +215,11 @@ void ThinQClient::startPolling()
{ {
if (!configured()) if (!configured())
return; return;
refresh(); // Primo avvio con la chiave gia' salvata: prima le macchine, poi lo stato.
if (m_devices.isEmpty())
discover();
else
refresh();
if (!m_pollTimer.isActive()) { if (!m_pollTimer.isActive()) {
m_pollTimer.start(m_pollInterval); m_pollTimer.start(m_pollInterval);
emit pollingChanged(); emit pollingChanged();
@@ -162,61 +238,90 @@ void ThinQClient::scheduleNextPoll()
m_pollTimer.start(m_pollInterval); m_pollTimer.start(m_pollInterval);
} }
void ThinQClient::queueAllStates()
{
m_queue.clear();
for (int i = 0; i < m_devices.size(); ++i)
m_queue << i;
}
void ThinQClient::pumpQueue()
{
if (m_stateInFlight || !configured())
return;
if (m_devices.isEmpty()) {
scheduleNextPoll();
return;
}
if (m_queue.isEmpty()) {
scheduleNextPoll();
return;
}
const int index = m_queue.takeFirst();
if (!validIndex(index)) {
pumpQueue();
return;
}
m_stateInFlight = true;
setBusy(true);
get(QStringLiteral("devices/%1/state").arg(m_devices.at(index).id), KindState, index);
}
void ThinQClient::refresh() void ThinQClient::refresh()
{ {
if (!configured()) if (!configured())
return; return;
get(QStringLiteral("devices/%1/state").arg(m_settings->deviceId()), KindState); if (m_devices.isEmpty()) {
discover();
return;
}
queueAllStates();
pumpQueue();
} }
void ThinQClient::discover() void ThinQClient::discover()
{ {
if (m_settings->token().isEmpty()) { if (!configured()) {
setNotice(QCoreApplication::translate("ThinQ", "Enter the access token first"), true); setNotice(QCoreApplication::translate("ThinQ", "Enter the access token first"), true);
return; return;
} }
get(QStringLiteral("devices"), KindDevices); get(QStringLiteral("devices"), KindDevices);
} }
void ThinQClient::chooseDevice(int index) void ThinQClient::runPrimaryAt(int index)
{ {
if (index < 0 || index >= m_deviceIds.size()) if (!hasStateAt(index)) {
return;
const QString id = m_deviceIds.at(index);
const QString label = m_deviceLabels.at(index);
m_selected = index;
m_settings->setDeviceAlias(label);
m_settings->setDeviceId(id);
setNotice(QCoreApplication::translate("ThinQ", "Machine selected"), false);
emit devicesChanged();
}
void ThinQClient::runPrimary()
{
if (!m_state.valid) {
setNotice(QCoreApplication::translate("ThinQ", "No data from the machine yet"), true); setNotice(QCoreApplication::translate("ThinQ", "No data from the machine yet"), true);
return; return;
} }
post(QStringLiteral("devices/%1/control").arg(m_settings->deviceId()), post(QStringLiteral("devices/%1/control").arg(m_devices.at(index).id),
ThinQJson::operationPayload(ThinQJson::primaryAction(m_state))); ThinQJson::operationPayload(ThinQJson::primaryAction(m_devices.at(index).state)), index);
} }
void ThinQClient::powerOff() void ThinQClient::powerOffAt(int index)
{ {
post(QStringLiteral("devices/%1/control").arg(m_settings->deviceId()), if (!validIndex(index))
ThinQJson::operationPayload(QStringLiteral("POWER_OFF"))); return;
post(QStringLiteral("devices/%1/control").arg(m_devices.at(index).id),
ThinQJson::operationPayload(QStringLiteral("POWER_OFF")), index);
} }
void ThinQClient::wakeUp() void ThinQClient::wakeUpAt(int index)
{ {
post(QStringLiteral("devices/%1/control").arg(m_settings->deviceId()), if (!validIndex(index))
ThinQJson::operationPayload(QStringLiteral("WAKE_UP"))); return;
post(QStringLiteral("devices/%1/control").arg(m_devices.at(index).id),
ThinQJson::operationPayload(QStringLiteral("WAKE_UP")), index);
} }
void ThinQClient::sendDelay() void ThinQClient::sendDelayAt(int index)
{ {
post(QStringLiteral("devices/%1/control").arg(m_settings->deviceId()), if (!validIndex(index))
ThinQJson::delayPayload(m_delayHours)); return;
post(QStringLiteral("devices/%1/control").arg(m_devices.at(index).id),
ThinQJson::delayPayload(m_delayHours), index);
} }
void ThinQClient::prepare(QNetworkRequest &request, bool command) const void ThinQClient::prepare(QNetworkRequest &request, bool command) const
@@ -237,13 +342,13 @@ void ThinQClient::prepare(QNetworkRequest &request, bool command) const
request.setRawHeader("x-conditional-control", "true"); request.setRawHeader("x-conditional-control", "true");
} }
void ThinQClient::get(const QString &endpoint, RequestKind kind) void ThinQClient::get(const QString &endpoint, RequestKind kind, int deviceIndex)
{ {
const QUrl url(ThinQJson::apiBase(m_settings->country()) + QLatin1Char('/') + endpoint); const QUrl url(ThinQJson::apiBase(m_settings->country()) + QLatin1Char('/') + endpoint);
QNetworkRequest request(url); QNetworkRequest request(url);
prepare(request, /*command=*/false); prepare(request, /*command=*/false);
if (kind == KindState || kind == KindCommand) if (kind == KindDevices)
setBusy(true); setBusy(true);
QNetworkReply *reply = m_nam.get(request); QNetworkReply *reply = m_nam.get(request);
@@ -255,18 +360,23 @@ void ThinQClient::get(const QString &endpoint, RequestKind kind)
connect(guard, &QTimer::timeout, reply, &QNetworkReply::abort); connect(guard, &QTimer::timeout, reply, &QNetworkReply::abort);
guard->start(kRequestTimeoutMs); guard->start(kRequestTimeoutMs);
connect(reply, &QNetworkReply::finished, this, [this, reply, kind]() { connect(reply, &QNetworkReply::finished, this, [this, reply, kind, deviceIndex]() {
reply->deleteLater(); reply->deleteLater();
const QByteArray body = reply->readAll(); const QByteArray body = reply->readAll();
const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (kind == KindState) if (kind == KindState)
setBusy(false); m_stateInFlight = false;
if (reply->error() != QNetworkReply::NoError || status < 200 || status >= 300) { if (reply->error() != QNetworkReply::NoError || status < 200 || status >= 300) {
const QString netErr = reply->error() == QNetworkReply::NoError const QString netErr = reply->error() == QNetworkReply::NoError
? QString() : reply->errorString(); ? QString() : reply->errorString();
handleFailure(status, body, netErr, kind == KindCommand); setBusy(false);
handleFailure(status, body, netErr, kind == KindCommand, deviceIndex);
if (kind == KindState)
pumpQueue(); // una macchina muta non blocca le altre
else
scheduleNextPoll();
return; return;
} }
@@ -276,8 +386,8 @@ void ThinQClient::get(const QString &endpoint, RequestKind kind)
: QJsonValue(doc.isArray() ? QJsonValue(doc.array()) : QJsonValue()); : QJsonValue(doc.isArray() ? QJsonValue(doc.array()) : QJsonValue());
if (kind == KindDevices) { if (kind == KindDevices) {
m_deviceLabels.clear(); setBusy(false);
m_deviceIds.clear(); m_devices.clear();
const QJsonArray arr = response.toArray(); const QJsonArray arr = response.toArray();
for (int i = 0; i < arr.size(); ++i) { for (int i = 0; i < arr.size(); ++i) {
const QJsonObject dev = arr.at(i).toObject(); const QJsonObject dev = arr.at(i).toObject();
@@ -287,43 +397,61 @@ void ThinQClient::get(const QString &endpoint, RequestKind kind)
&& !type.startsWith(QLatin1String("DEVICE_WASHCOMBO")) && !type.startsWith(QLatin1String("DEVICE_WASHCOMBO"))
&& !type.startsWith(QLatin1String("DEVICE_WASHTOWER")) && !type.startsWith(QLatin1String("DEVICE_WASHTOWER"))
&& !type.startsWith(QLatin1String("DEVICE_DRYER"))) { && !type.startsWith(QLatin1String("DEVICE_DRYER"))) {
continue; // l'app controlla lavatrici e lavasciughe continue; // questa app comanda lavatrici e lavasciughe
} }
QString label = info.value(QStringLiteral("alias")).toString(); DeviceEntry entry;
if (label.isEmpty()) entry.id = dev.value(QStringLiteral("deviceId")).toString();
label = info.value(QStringLiteral("modelName")).toString(); entry.label = info.value(QStringLiteral("alias")).toString();
m_deviceLabels << label; if (entry.label.isEmpty())
m_deviceIds << dev.value(QStringLiteral("deviceId")).toString(); entry.label = info.value(QStringLiteral("modelName")).toString();
m_devices << entry;
} }
m_selected = m_deviceIds.indexOf(m_settings->deviceId());
emit devicesChanged(); emit devicesChanged();
if (m_deviceLabels.isEmpty()) if (m_devices.isEmpty()) {
setNotice(QCoreApplication::translate("ThinQ", "No washing machine found on this account"), true); setNotice(QCoreApplication::translate("ThinQ", "No washing machine found on this account"), true);
else scheduleNextPoll();
setNotice(QCoreApplication::translate("ThinQ", "Machines found: %1").arg(m_deviceLabels.size()), false); } else {
setNotice(QCoreApplication::translate("ThinQ", "Machines found: %1").arg(m_devices.size()), false);
queueAllStates();
pumpQueue();
}
return; return;
} }
if (kind == KindState) { if (kind == KindState) {
setBusy(false);
if (!validIndex(deviceIndex)) {
pumpQueue();
return;
}
const bool hadState = m_devices.at(deviceIndex).hasState;
const int previousLevel = hadState
? ThinQJson::statusLevel(m_devices.at(deviceIndex).state) : -1;
const QByteArray payload = QJsonDocument(response.toArray()).toJson(QJsonDocument::Compact); const QByteArray payload = QJsonDocument(response.toArray()).toJson(QJsonDocument::Compact);
applyState(ThinQJson::parseState(payload)); applyState(deviceIndex, hadState, previousLevel, ThinQJson::parseState(payload));
pumpQueue();
return; return;
} }
// kind == KindCommand // kind == KindCommand
m_pendingCommand = false; setBusy(false);
setNotice(QCoreApplication::translate("ThinQ", "Command sent"), false); setNotice(QCoreApplication::translate("ThinQ", "Command sent"), false);
refresh(); refresh();
}); });
} }
void ThinQClient::post(const QString &endpoint, const QString &payload) void ThinQClient::post(const QString &endpoint, const QString &payload, int deviceIndex)
{ {
if (!configured()) { if (!configured()) {
setNotice(QCoreApplication::translate("ThinQ", "Set the access token and the machine first"), true); setNotice(QCoreApplication::translate("ThinQ", "The access token is missing"), true);
return; return;
} }
if (!m_state.valid || !m_state.remoteEnabled) { if (!validIndex(deviceIndex)) {
setNotice(QCoreApplication::translate("ThinQ", "No machine to command"), true);
return;
}
const DeviceEntry &entry = m_devices.at(deviceIndex);
if (!entry.hasState || !entry.state.remoteEnabled) {
setNotice(QCoreApplication::translate("ThinQ", "Remote start is off on the machine: switch it on from its panel"), true); setNotice(QCoreApplication::translate("ThinQ", "Remote start is off on the machine: switch it on from its panel"), true);
return; return;
} }
@@ -332,7 +460,6 @@ void ThinQClient::post(const QString &endpoint, const QString &payload)
QNetworkRequest request(url); QNetworkRequest request(url);
prepare(request, /*command=*/true); prepare(request, /*command=*/true);
m_pendingCommand = true;
setBusy(true); setBusy(true);
QNetworkReply *reply = m_nam.post(request, payload.toUtf8()); QNetworkReply *reply = m_nam.post(request, payload.toUtf8());
@@ -341,7 +468,7 @@ void ThinQClient::post(const QString &endpoint, const QString &payload)
connect(guard, &QTimer::timeout, reply, &QNetworkReply::abort); connect(guard, &QTimer::timeout, reply, &QNetworkReply::abort);
guard->start(kRequestTimeoutMs); guard->start(kRequestTimeoutMs);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply, deviceIndex]() {
reply->deleteLater(); reply->deleteLater();
const QByteArray body = reply->readAll(); const QByteArray body = reply->readAll();
const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); const int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
@@ -350,7 +477,7 @@ void ThinQClient::post(const QString &endpoint, const QString &payload)
if (reply->error() != QNetworkReply::NoError || status < 200 || status >= 300) { if (reply->error() != QNetworkReply::NoError || status < 200 || status >= 300) {
const QString netErr = reply->error() == QNetworkReply::NoError const QString netErr = reply->error() == QNetworkReply::NoError
? QString() : reply->errorString(); ? QString() : reply->errorString();
handleFailure(status, body, netErr, true); handleFailure(status, body, netErr, true, deviceIndex);
return; return;
} }
setNotice(QCoreApplication::translate("ThinQ", "Command sent"), false); setNotice(QCoreApplication::translate("ThinQ", "Command sent"), false);
@@ -358,20 +485,63 @@ void ThinQClient::post(const QString &endpoint, const QString &payload)
}); });
} }
void ThinQClient::applyState(const WasherState &state) void ThinQClient::applyState(int deviceIndex, bool hadState, int previousLevel,
const WasherState &state)
{ {
m_state = state; if (!validIndex(deviceIndex))
m_stale = false; return;
m_updated = QCoreApplication::translate("ThinQ", "Updated at %1").arg(
DeviceEntry &entry = m_devices[deviceIndex];
entry.state = state;
entry.hasState = state.valid;
entry.offline = false;
entry.stale = false;
entry.updated = QCoreApplication::translate("ThinQ", "Updated at %1").arg(
QLocale().toString(QTime::currentTime(), QLocale::ShortFormat)); QLocale().toString(QTime::currentTime(), QLocale::ShortFormat));
if (m_pollInterval != kPollFastMs) if (m_pollInterval != kPollFastMs)
m_pollInterval = kPollFastMs; m_pollInterval = kPollFastMs;
emit stateChanged(); emit stateChanged();
scheduleNextPoll(); noteFinished(deviceIndex, hadState, previousLevel);
}
void ThinQClient::noteFinished(int deviceIndex, bool hadState, int previousLevel)
{
if (!validIndex(deviceIndex))
return;
const DeviceEntry &entry = m_devices.at(deviceIndex);
const int level = ThinQJson::statusLevel(entry.state);
const int saved = m_settings->notifiedCycleFor(entry.id);
if (level == 3) {
// Appena finito sotto i nostri occhi, oppure finito mentre l'app era
// chiusa (il numero di ciclo e' avanzato rispetto all'ultimo avvisato).
const bool justEnded = hadState && (previousLevel == 1 || previousLevel == 2);
const bool missedWhileClosed = saved > 0 && entry.state.cycleCount > saved;
if (justEnded || missedWhileClosed) {
m_settings->setNotifiedCycleFor(entry.id, entry.state.cycleCount);
emit cycleFinished(entry.label, entry.state.cycleCount);
} else if (saved == 0) {
// Prima volta che vediamo questa macchina: si annota il ciclo senza
// avvisare, altrimenti al primo avvio scatterebbe un avviso per un
// lavaggio finito giorni fa.
m_settings->setNotifiedCycleFor(entry.id, entry.state.cycleCount);
}
return;
}
// Ciclo in corso: si annota il numero, cosi' l'avviso scattera' solo se il
// ciclo finisce davvero.
if (saved == 0 && entry.state.cycleCount > 0)
m_settings->setNotifiedCycleFor(entry.id, entry.state.cycleCount);
} }
void ThinQClient::handleFailure(int httpStatus, const QByteArray &body, void ThinQClient::handleFailure(int httpStatus, const QByteArray &body,
const QString &networkError, bool commandRequest) const QString &networkError, bool commandRequest,
int deviceIndex)
{ {
QString code; QString code;
QString message; QString message;
@@ -385,13 +555,28 @@ void ThinQClient::handleFailure(int httpStatus, const QByteArray &body,
qDebug() << "[thinq] errore LG" << httpStatus << code << message qDebug() << "[thinq] errore LG" << httpStatus << code << message
<< (networkError.isEmpty() ? QString() : networkError); << (networkError.isEmpty() ? QString() : networkError);
// Macchina spenta o senza rete: si annota SULLA macchina, non sulla barra
// dei messaggi, altrimenti ogni giro di aggiornamento ripeterebbe lo
// stesso avviso.
if (!commandRequest && validIndex(deviceIndex)
&& (code == QLatin1String("1222") || code == QLatin1String("1223")
|| code == QLatin1String("1231") || code == QLatin1String("1209"))) {
DeviceEntry &entry = m_devices[deviceIndex];
entry.offline = true;
entry.hasState = false;
entry.updated.clear();
entry.stale = false;
emit stateChanged();
return;
}
if (code == QLatin1String("1103") || code == QLatin1String("1218") if (code == QLatin1String("1103") || code == QLatin1String("1218")
|| code == QLatin1String("1302")) { || code == QLatin1String("1302") || httpStatus == 401) {
setNotice(QCoreApplication::translate("ThinQ", "The access token is no longer valid: enter a new one in Settings"), true); setNotice(QCoreApplication::translate("ThinQ", "The access token is no longer valid: enter a new one in Settings"), true);
} else if (code == QLatin1String("1306")) { } else if (code == QLatin1String("1306")) {
m_pollInterval = kPollSlowMs; m_pollInterval = kPollSlowMs;
setNotice(QCoreApplication::translate("ThinQ", "Too many requests to LG: slowing down"), true); setNotice(QCoreApplication::translate("ThinQ", "Too many requests to LG: slowing down"), true);
} else if (code == QLatin1String("1222")) { } else if (code == QLatin1String("1222") || code == QLatin1String("1223")) {
setNotice(QCoreApplication::translate("ThinQ", "The washing machine is not connected (switched off or offline)"), true); setNotice(QCoreApplication::translate("ThinQ", "The washing machine is not connected (switched off or offline)"), true);
} else if (code == QLatin1String("2301")) { } else if (code == QLatin1String("2301")) {
setNotice(QCoreApplication::translate("ThinQ", "Remote start is off on the machine: switch it on from its panel"), true); setNotice(QCoreApplication::translate("ThinQ", "Remote start is off on the machine: switch it on from its panel"), true);
@@ -405,13 +590,10 @@ void ThinQClient::handleFailure(int httpStatus, const QByteArray &body,
setNotice(QCoreApplication::translate("ThinQ", "The LG cloud refused the request (HTTP %1)").arg(httpStatus), true); setNotice(QCoreApplication::translate("ThinQ", "The LG cloud refused the request (HTTP %1)").arg(httpStatus), true);
} }
if (commandRequest)
m_pendingCommand = false;
// I dati a schermo non sono piu' freschi: dirlo, invece di mostrare i // I dati a schermo non sono piu' freschi: dirlo, invece di mostrare i
// numeri vecchi come se fossero attuali. // numeri vecchi come se fossero attuali.
if (m_state.valid) { if (validIndex(deviceIndex) && m_devices.at(deviceIndex).hasState) {
m_stale = true; m_devices[deviceIndex].stale = true;
emit stateChanged(); emit stateChanged();
} }
scheduleNextPoll(); scheduleNextPoll();
+58 -49
View File
@@ -1,6 +1,7 @@
#ifndef THINQCLIENT_H #ifndef THINQCLIENT_H
#define THINQCLIENT_H #define THINQCLIENT_H
#include <QList>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
@@ -11,66 +12,62 @@
class Settings; class Settings;
class QNetworkReply; class QNetworkReply;
// Parla direttamente con il cloud LG ThinQ Connect: nessun ponte, nessun // Tutte le macchine dell'account, ognuna col suo stato. Una sola classe parla
// server di mezzo. Il token di accesso sta nelle impostazioni dell'app. // col cloud LG: nessun ponte, nessun server di mezzo, nessun servizio.
//
// Il QML legge per indice (labelAt/phaseTextAt/...): l'elenco cambia raramente e
// cosi' le stesse funzioni servono la schermata principale e la copertina.
class ThinQClient : public QObject class ThinQClient : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool configured READ configured NOTIFY infoChanged) Q_PROPERTY(bool configured READ configured NOTIFY infoChanged)
Q_PROPERTY(QString alias READ alias NOTIFY infoChanged) Q_PROPERTY(int deviceCount READ deviceCount NOTIFY devicesChanged)
Q_PROPERTY(bool hasState READ hasState NOTIFY stateChanged) Q_PROPERTY(int activeIndex READ activeIndex NOTIFY stateChanged)
Q_PROPERTY(QString phaseText READ phaseText NOTIFY stateChanged)
Q_PROPERTY(int statusLevel READ statusLevel NOTIFY stateChanged)
Q_PROPERTY(QString remainText READ remainText NOTIFY stateChanged)
Q_PROPERTY(QString totalText READ totalText NOTIFY stateChanged)
Q_PROPERTY(int cycleCount READ cycleCount NOTIFY stateChanged)
Q_PROPERTY(bool remoteEnabled READ remoteEnabled NOTIFY stateChanged)
Q_PROPERTY(QString primaryLabel READ primaryLabel NOTIFY stateChanged)
Q_PROPERTY(bool canCommand READ canCommand NOTIFY stateChanged)
Q_PROPERTY(QString updatedText READ updatedText NOTIFY stateChanged)
Q_PROPERTY(bool stale READ stale NOTIFY stateChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged) Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
Q_PROPERTY(bool polling READ polling NOTIFY pollingChanged) Q_PROPERTY(bool polling READ polling NOTIFY pollingChanged)
Q_PROPERTY(QString notice READ notice NOTIFY noticeChanged) Q_PROPERTY(QString notice READ notice NOTIFY noticeChanged)
Q_PROPERTY(bool noticeIsError READ noticeIsError NOTIFY noticeChanged) Q_PROPERTY(bool noticeIsError READ noticeIsError NOTIFY noticeChanged)
Q_PROPERTY(QStringList deviceLabels READ deviceLabels NOTIFY devicesChanged)
Q_PROPERTY(int deviceCount READ deviceCount NOTIFY devicesChanged)
Q_PROPERTY(int selectedDevice READ selectedDevice NOTIFY devicesChanged)
Q_PROPERTY(int delayHours READ delayHours WRITE setDelayHours NOTIFY delayHoursChanged) Q_PROPERTY(int delayHours READ delayHours WRITE setDelayHours NOTIFY delayHoursChanged)
public: public:
explicit ThinQClient(Settings *settings, QObject *parent = nullptr); explicit ThinQClient(Settings *settings, QObject *parent = nullptr);
// La chiave di accesso c'e': la schermata principale mostra i dispositivi
// invece di chiedere le credenziali.
bool configured() const; bool configured() const;
QString alias() const; int deviceCount() const { return m_devices.size(); }
bool hasState() const { return m_state.valid; } // La macchina che sta lavorando (per la copertina), altrimenti la prima.
QString phaseText() const; int activeIndex() const;
int statusLevel() const;
QString remainText() const;
QString totalText() const;
int cycleCount() const { return m_state.cycleCount; }
bool remoteEnabled() const { return m_state.remoteEnabled; }
QString primaryLabel() const;
bool canCommand() const;
QString updatedText() const;
bool stale() const { return m_stale; }
bool busy() const { return m_busy; } bool busy() const { return m_busy; }
bool polling() const { return m_pollTimer.isActive(); } bool polling() const { return m_pollTimer.isActive(); }
QString notice() const { return m_notice; } QString notice() const { return m_notice; }
bool noticeIsError() const { return m_noticeIsError; } bool noticeIsError() const { return m_noticeIsError; }
QStringList deviceLabels() const { return m_deviceLabels; }
int deviceCount() const { return m_deviceLabels.size(); }
int selectedDevice() const { return m_selected; }
int delayHours() const { return m_delayHours; } int delayHours() const { return m_delayHours; }
void setDelayHours(int hours); void setDelayHours(int hours);
Q_INVOKABLE QString labelAt(int index) const;
Q_INVOKABLE bool hasStateAt(int index) const;
Q_INVOKABLE bool offlineAt(int index) const;
Q_INVOKABLE bool staleAt(int index) const;
Q_INVOKABLE QString phaseTextAt(int index) const;
Q_INVOKABLE int statusLevelAt(int index) const;
Q_INVOKABLE QString remainTextAt(int index) const;
Q_INVOKABLE QString totalTextAt(int index) const;
Q_INVOKABLE QString totalLineAt(int index) const;
Q_INVOKABLE int cycleCountAt(int index) const;
Q_INVOKABLE bool remoteEnabledAt(int index) const;
Q_INVOKABLE QString primaryLabelAt(int index) const;
Q_INVOKABLE bool canCommandAt(int index) const;
Q_INVOKABLE QString updatedTextAt(int index) const;
Q_INVOKABLE QString deviceIdAt(int index) const;
Q_INVOKABLE bool validIndex(int index) const;
Q_INVOKABLE void refresh(); Q_INVOKABLE void refresh();
Q_INVOKABLE void discover(); Q_INVOKABLE void discover();
Q_INVOKABLE void chooseDevice(int index); Q_INVOKABLE void runPrimaryAt(int index);
Q_INVOKABLE void runPrimary(); Q_INVOKABLE void powerOffAt(int index);
Q_INVOKABLE void powerOff(); Q_INVOKABLE void wakeUpAt(int index);
Q_INVOKABLE void wakeUp(); Q_INVOKABLE void sendDelayAt(int index);
Q_INVOKABLE void sendDelay();
Q_INVOKABLE void startPolling(); Q_INVOKABLE void startPolling();
Q_INVOKABLE void stopPolling(); Q_INVOKABLE void stopPolling();
Q_INVOKABLE void clearNotice(); Q_INVOKABLE void clearNotice();
@@ -85,35 +82,47 @@ signals:
void noticeChanged(); void noticeChanged();
void devicesChanged(); void devicesChanged();
void delayHoursChanged(); void delayHoursChanged();
// Fine di un lavaggio: la macchina e' arrivata a END. Il QML lo trasforma in
// una notifica di sistema.
void cycleFinished(const QString &label, int cycleCount);
private: private:
enum RequestKind { KindDevices, KindState, KindCommand }; enum RequestKind { KindDevices, KindState, KindCommand };
struct DeviceEntry {
QString id;
QString label;
WasherState state;
bool hasState = false;
bool offline = false;
bool stale = false;
QString updated;
};
void prepare(QNetworkRequest &request, bool command) const; void prepare(QNetworkRequest &request, bool command) const;
void get(const QString &endpoint, RequestKind kind); void get(const QString &endpoint, RequestKind kind, int deviceIndex = -1);
void post(const QString &endpoint, const QString &payload); void post(const QString &endpoint, const QString &payload, int deviceIndex);
void applyState(const WasherState &state); void applyState(int deviceIndex, bool hadState, int previousLevel, const WasherState &state);
void handleFailure(int httpStatus, const QByteArray &body, const QString &networkError, void handleFailure(int httpStatus, const QByteArray &body, const QString &networkError,
bool commandRequest); bool commandRequest, int deviceIndex);
void setNotice(const QString &text, bool isError); void setNotice(const QString &text, bool isError);
void setBusy(bool busy); void setBusy(bool busy);
void scheduleNextPoll(); void scheduleNextPoll();
void queueAllStates();
void pumpQueue();
void noteFinished(int deviceIndex, bool hadState, int previousLevel);
Settings *m_settings; Settings *m_settings;
QNetworkAccessManager m_nam; QNetworkAccessManager m_nam;
QTimer m_pollTimer; QTimer m_pollTimer;
WasherState m_state; QList<DeviceEntry> m_devices;
QStringList m_deviceLabels; QList<int> m_queue; // macchine da leggere, una richiesta per volta
QStringList m_deviceIds; bool m_stateInFlight = false;
int m_selected = -1; int m_pollInterval = 45000; // a schermata aperta
int m_pollInterval = 45000;
int m_delayHours = 4; int m_delayHours = 4;
bool m_busy = false; bool m_busy = false;
bool m_stale = false;
bool m_pendingCommand = false;
QString m_notice; QString m_notice;
bool m_noticeIsError = false; bool m_noticeIsError = false;
QString m_updated;
}; };
#endif // THINQCLIENT_H #endif // THINQCLIENT_H
+20
View File
@@ -162,6 +162,26 @@ static void testItalian(const QString &catalog)
checkEq(ThinQJson::primaryActionLabel(s), "Avvia", "tasto tradotto"); checkEq(ThinQJson::primaryActionLabel(s), "Avvia", "tasto tradotto");
s.phase = QStringLiteral("PAUSE"); s.phase = QStringLiteral("PAUSE");
checkEq(ThinQJson::primaryActionLabel(s), "Riprendi", "riprendi tradotto"); checkEq(ThinQJson::primaryActionLabel(s), "Riprendi", "riprendi tradotto");
// Le scritte delle schermate nuove (primo avvio, elenco, avviso): se una
// sfugge al catalogo, la si vede qui invece che sul telefono.
// ATTENZIONE al contesto: nelle pagine QML il contesto e' il NOME DEL FILE
// (MainPage, SettingsPage), non "ThinQ" come nel codice C++.
checkEq(QCoreApplication::translate("MainPage", "My machines"), "Le mie macchine",
"titolo tradotto");
checkEq(QCoreApplication::translate("MainPage", "First setup"), "Primo avvio",
"primo avvio tradotto");
checkEq(QCoreApplication::translate("MainPage", "Connect"), "Collega", "tasto collega tradotto");
checkEq(QCoreApplication::translate("MainPage", "Not connected"), "Non collegata",
"macchina non collegata tradotta");
checkEq(QCoreApplication::translate("SettingsPage", "Machines"), "Macchine",
"sezione macchine tradotta");
checkEq(QCoreApplication::translate("MainPage", "%1 found").arg(2), "2 trovate",
"conteggio tradotto");
checkEq(QCoreApplication::translate("harbour-thinq", "Washing finished"), "Lavaggio finito",
"avviso di fine lavaggio tradotto");
checkEq(QCoreApplication::translate("ThinQ", "No machine to command"),
"Nessuna macchina da comandare", "comando senza macchina tradotto");
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
+361 -230
View File
@@ -1,298 +1,162 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1" language="it_IT"> <TS version="2.1" language="it_IT">
<context>
<name>ThinQ</name>
<message>
<location filename="../src/thinqclient.cpp" line="56"/>
<source>Washing machine</source>
<translation>Lavatrice</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="62"/>
<source>No data</source>
<translation>Nessun dato</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="84"/>
<location filename="../src/thinqjson.cpp" line="151"/>
<source>Start</source>
<translation>Avvia</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="175"/>
<source>Enter the access token first</source>
<translation>Inserisci prima la chiave di accesso</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="190"/>
<source>Machine selected</source>
<translation>Macchina scelta</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="197"/>
<source>No data from the machine yet</source>
<translation>Ancora nessun dato dalla macchina</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="289"/>
<source>No washing machine found on this account</source>
<translation>Nessuna lavatrice trovata su questo account</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="291"/>
<source>Machines found: %1</source>
<translation>Macchine trovate: %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="303"/>
<location filename="../src/thinqclient.cpp" line="351"/>
<source>Command sent</source>
<translation>Comando inviato</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="311"/>
<source>Set the access token and the machine first</source>
<translation>Imposta prima la chiave di accesso e la macchina</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="315"/>
<location filename="../src/thinqclient.cpp" line="392"/>
<source>Remote start is off on the machine: switch it on from its panel</source>
<translation>L'avvio a distanza e' spento sulla macchina: accendilo dal pannello</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="360"/>
<source>Updated at %1</source>
<translation>Aggiornato alle %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="385"/>
<source>The access token is no longer valid: enter a new one in Settings</source>
<translation>La chiave di accesso non e' piu' valida: inseriscine una nuova nelle Impostazioni</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="388"/>
<source>Too many requests to LG: slowing down</source>
<translation>Troppe richieste a LG: rallento gli aggiornamenti</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="390"/>
<source>The washing machine is not connected (switched off or offline)</source>
<translation>La lavatrice non e' collegata (spenta o senza rete)</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="394"/>
<source>The machine does not accept this command</source>
<translation>La macchina non accetta questo comando</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="396"/>
<source>LG error %1: %2</source>
<translation>Errore LG %1: %2</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="398"/>
<source>No answer from the LG cloud: %1</source>
<translation>Nessuna risposta dal cloud LG: %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="400"/>
<source>The LG cloud refused the request (HTTP %1)</source>
<translation>Il cloud LG ha rifiutato la richiesta (HTTP %1)</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="112"/>
<source>Washing</source>
<translation>In lavaggio</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="113"/>
<source>Rinsing</source>
<translation>In risciacquo</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="114"/>
<source>Spinning</source>
<translation>In centrifuga</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="115"/>
<source>Drying</source>
<translation>In asciugatura</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="116"/>
<source>Cooling down</source>
<translation>Raffreddamento</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="117"/>
<source>Refreshing</source>
<translation>Rinfrescando</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="118"/>
<source>Steam softening</source>
<translation>Ammorbidente a vapore</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="119"/>
<source>Detecting the load</source>
<translation>Rilevamento del carico</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="120"/>
<source>Delayed start</source>
<translation>Partenza ritardata</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="121"/>
<source>Rinse hold</source>
<translation>Ammollo</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="122"/>
<source>Paused</source>
<translation>In pausa</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="123"/>
<source>Finished</source>
<translation>Fine</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="124"/>
<source>Ready</source>
<translation>Pronta</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="125"/>
<source>Off</source>
<translation>Spenta</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="126"/>
<source>Standby</source>
<translation>In attesa</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="127"/>
<source>Error</source>
<translation>Errore</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="146"/>
<source>Stop</source>
<translation>Ferma</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="148"/>
<source>Switch off</source>
<translation>Spegni</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="150"/>
<source>Resume</source>
<translation>Riprendi</translation>
</message>
</context>
<context> <context>
<name>CoverPage</name> <name>CoverPage</name>
<message> <message>
<location filename="../qml/cover/CoverPage.qml" line="25"/> <location filename="../qml/cover/CoverPage.qml" line="31"/>
<source>No data</source> <source>No data</source>
<translation>Nessun dato</translation> <translation>Nessun dato</translation>
<translation>Nessun dato</translation>
</message> </message>
</context> </context>
<context> <context>
<name>DelayDialog</name> <name>DelayDialog</name>
<message> <message>
<location filename="../qml/pages/DelayDialog.qml" line="22"/> <location filename="../qml/pages/DelayDialog.qml" line="26"/>
<source>Delayed stop</source> <source>Delayed stop</source>
<translation>Stop ritardato</translation> <translation>Stop ritardato</translation>
<translation>Stop ritardato</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/DelayDialog.qml" line="23"/> <location filename="../qml/pages/DelayDialog.qml" line="27"/>
<source>Set</source> <source>Set</source>
<translation>Imposta</translation> <translation>Imposta</translation>
<translation>Imposta</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/DelayDialog.qml" line="32"/> <location filename="../qml/pages/DelayDialog.qml" line="36"/>
<source>The machine will stop on its own after the chosen time, then resume its programme.</source> <source>The machine will stop on its own after the chosen time, then resume its programme.</source>
<translation>La macchina si ferma da sola allo scadere del tempo scelto, poi riprende il programma.</translation> <translation>La macchina si ferma da sola allo scadere del tempo scelto, poi riprende il programma.</translation>
<translation>La macchina si ferma da sola allo scadere del tempo scelto, poi riprende il programma.</translation>
</message> </message>
</context> </context>
<context> <context>
<name>MainPage</name> <name>MainPage</name>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="25"/> <location filename="../qml/pages/MainPage.qml" line="29"/>
<source>Refresh</source> <source>Refresh</source>
<translation>Aggiorna</translation> <translation>Aggiorna</translation>
<translation>Aggiorna</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="29"/> <location filename="../qml/pages/MainPage.qml" line="45"/>
<source>My machines</source>
<translation>Le mie macchine</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="47"/>
<source>Updating…</source>
<translation>Aggiornamento…</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="47"/>
<source>%1 found</source>
<translation>%1 trovate</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="48"/>
<source>First setup</source>
<translation>Primo avvio</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="65"/>
<source>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.</source>
<translation>La chiave di accesso si crea su connect-pat.lgthinq.com e resta solo su questo telefono. Se LG non la accetta piu', incollane una nuova qui.</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="72"/>
<source>Access token</source>
<translation>Chiave di accesso</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="73"/>
<source>paste the token</source>
<translation>incolla la chiave</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="81"/>
<source>Country code</source>
<translation>Paese</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="92"/>
<source>Connect</source>
<translation>Collega</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="155"/>
<source>Not connected</source>
<translation>Non collegata</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="204"/>
<source>The washing machine is not connected (switched off or offline)</source>
<translation>La lavatrice non e' collegata (spenta o senza rete)</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="222"/>
<source>Delayed stop…</source> <source>Delayed stop…</source>
<translation>Stop ritardato…</translation> <translation>Stop ritardato…</translation>
<translation>Stop ritardato…</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="33"/> <location filename="../qml/pages/MainPage.qml" line="228"/>
<source>Switch off</source> <source>Switch off</source>
<translation>Spegni</translation> <translation>Spegni</translation>
<translation>Spegni</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="38"/> <location filename="../qml/pages/MainPage.qml" line="233"/>
<source>Wake the display up</source> <source>Wake the display up</source>
<translation>Risveglia il display</translation> <translation>Risveglia il display</translation>
<translation>Risveglia il display</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="43"/> <location filename="../qml/pages/MainPage.qml" line="255"/>
<location filename="../qml/pages/MainPage.qml" line="75"/> <source>No machine found yet. Pull down to search again.</source>
<translation>Nessuna macchina trovata. Trascina in basso per cercare di nuovo.</translation>
</message>
<message>
<location filename="../qml/pages/MainPage.qml" line="34"/>
<source>Settings</source> <source>Settings</source>
<translation>Impostazioni</translation> <translation>Impostazioni</translation>
<translation>Impostazioni</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="56"/>
<source>Not up to date</source> <source>Not up to date</source>
<translation>Non aggiornato</translation> <translation>Non aggiornato</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="57"/>
<source>Not configured</source> <source>Not configured</source>
<translation>Da configurare</translation> <translation>Da configurare</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="69"/>
<source>Enter the LG access token in Settings and pick your machine.</source> <source>Enter the LG access token in Settings and pick your machine.</source>
<translation>Inserisci la chiave di accesso LG nelle Impostazioni e scegli la macchina.</translation> <translation>Inserisci la chiave di accesso LG nelle Impostazioni e scegli la macchina.</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="134"/>
<source>of %1</source> <source>of %1</source>
<translation>su %1</translation> <translation>su %1</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="147"/>
<source>Cycle</source> <source>Cycle</source>
<translation>Ciclo</translation> <translation>Ciclo</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="152"/>
<source>Remote start</source> <source>Remote start</source>
<translation>Avvio a distanza</translation> <translation>Avvio a distanza</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="153"/>
<source>on</source> <source>on</source>
<translation>attivo</translation> <translation>attivo</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="153"/>
<source>off</source> <source>off</source>
<translation>spento</translation> <translation>spento</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/MainPage.qml" line="166"/> <location filename="../qml/pages/MainPage.qml" line="194"/>
<source>To send commands, switch remote start on from the machine panel.</source> <source>To send commands, switch remote start on from the machine panel.</source>
<translation>Per inviare comandi, accendi l'avvio a distanza dal pannello della macchina.</translation> <translation>Per inviare comandi, accendi l'avvio a distanza dal pannello della macchina.</translation>
</message> </message>
@@ -300,71 +164,338 @@
<context> <context>
<name>SettingsPage</name> <name>SettingsPage</name>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="19"/> <location filename="../qml/pages/SettingsPage.qml" line="21"/>
<source>Settings</source> <source>Settings</source>
<translation>Impostazioni</translation> <translation>Impostazioni</translation>
<translation>Impostazioni</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="23"/> <location filename="../qml/pages/SettingsPage.qml" line="25"/>
<source>LG account</source> <source>LG account</source>
<translation>Account LG</translation> <translation>Account LG</translation>
<translation>Account LG</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="32"/> <location filename="../qml/pages/SettingsPage.qml" line="34"/>
<source>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.</source> <source>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.</source>
<translation>La chiave di accesso si crea su connect-pat.lgthinq.com e resta solo su questo telefono. Se LG non la accetta piu', incollane una nuova qui.</translation> <translation>La chiave di accesso si crea su connect-pat.lgthinq.com e resta solo su questo telefono. Se LG non la accetta piu', incollane una nuova qui.</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="39"/> <location filename="../qml/pages/SettingsPage.qml" line="41"/>
<source>Access token</source> <source>Access token</source>
<translation>Chiave di accesso</translation> <translation>Chiave di accesso</translation>
<translation>Chiave di accesso</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="40"/> <location filename="../qml/pages/SettingsPage.qml" line="42"/>
<source>paste the token</source> <source>paste the token</source>
<translation>incolla la chiave</translation> <translation>incolla la chiave</translation>
<translation>incolla la chiave</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="50"/> <location filename="../qml/pages/SettingsPage.qml" line="52"/>
<source>Country code</source> <source>Country code</source>
<translation>Paese</translation> <translation>Paese</translation>
<translation>Paese</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="58"/> <location filename="../qml/pages/SettingsPage.qml" line="63"/>
<source>Save the token</source> <source>Save the token</source>
<translation>Salva la chiave</translation> <translation>Salva la chiave</translation>
<translation>Salva la chiave</translation>
</message>
<message>
<location filename="../qml/pages/SettingsPage.qml" line="72"/>
<source>Machines</source>
<translation>Macchine</translation>
</message>
<message>
<location filename="../qml/pages/SettingsPage.qml" line="81"/>
<source>%1 found</source>
<translation>%1 trovate</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="67"/>
<location filename="../qml/pages/SettingsPage.qml" line="79"/>
<source>Machine</source> <source>Machine</source>
<translation>Macchina</translation> <translation>Macchina</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="72"/> <location filename="../qml/pages/SettingsPage.qml" line="86"/>
<source>Find my machines</source> <source>Find my machines</source>
<translation>Trova le macchine</translation> <translation>Trova le macchine</translation>
<translation>Trova le macchine</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="102"/>
<source>Selected: %1</source> <source>Selected: %1</source>
<translation>Scelta: %1</translation> <translation>Scelta: %1</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="106"/> <location filename="../qml/pages/SettingsPage.qml" line="91"/>
<location filename="../qml/pages/SettingsPage.qml" line="112"/> <location filename="../qml/pages/SettingsPage.qml" line="97"/>
<source>Language</source> <source>Language</source>
<translation>Lingua</translation> <translation>Lingua</translation>
<translation>Lingua</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="115"/> <location filename="../qml/pages/SettingsPage.qml" line="100"/>
<source>System</source> <source>System</source>
<translation>Sistema</translation> <translation>Sistema</translation>
<translation>Sistema</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/SettingsPage.qml" line="131"/> <location filename="../qml/pages/SettingsPage.qml" line="116"/>
<source>Version %1</source> <source>Version %1</source>
<translation>Versione %1</translation> <translation>Versione %1</translation>
<translation>Versione %1</translation>
</message>
</context>
<context>
<name>ThinQ</name>
<message>
<location filename="../src/thinqclient.cpp" line="72"/>
<source>Washing machine</source>
<translation>Lavatrice</translation>
<translation>Lavatrice</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="94"/>
<source>No data</source>
<translation>Nessun dato</translation>
<translation>Nessun dato</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="124"/>
<source>of %1</source>
<translation>su %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="144"/>
<location filename="../src/thinqjson.cpp" line="162"/>
<source>Start</source>
<translation>Avvia</translation>
<translation>Avvia</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="287"/>
<source>Enter the access token first</source>
<translation>Inserisci prima la chiave di accesso</translation>
<translation>Inserisci prima la chiave di accesso</translation>
</message>
<message>
<source>Machine selected</source>
<translation>Macchina scelta</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="296"/>
<source>No data from the machine yet</source>
<translation>Ancora nessun dato dalla macchina</translation>
<translation>Ancora nessun dato dalla macchina</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="411"/>
<source>No washing machine found on this account</source>
<translation>Nessuna lavatrice trovata su questo account</translation>
<translation>Nessuna lavatrice trovata su questo account</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="414"/>
<source>Machines found: %1</source>
<translation>Macchine trovate: %1</translation>
<translation>Macchine trovate: %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="438"/>
<location filename="../src/thinqclient.cpp" line="483"/>
<source>Command sent</source>
<translation>Comando inviato</translation>
<translation>Comando inviato</translation>
</message>
<message>
<source>Set the access token and the machine first</source>
<translation>Imposta prima la chiave di accesso e la macchina</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="446"/>
<source>The access token is missing</source>
<translation>Manca la chiave di accesso</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="450"/>
<source>No machine to command</source>
<translation>Nessuna macchina da comandare</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="455"/>
<location filename="../src/thinqclient.cpp" line="582"/>
<source>Remote start is off on the machine: switch it on from its panel</source>
<translation>L'avvio a distanza e' spento sulla macchina: accendilo dal pannello</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="499"/>
<source>Updated at %1</source>
<translation>Aggiornato alle %1</translation>
<translation>Aggiornato alle %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="575"/>
<source>The access token is no longer valid: enter a new one in Settings</source>
<translation>La chiave di accesso non e' piu' valida: inseriscine una nuova nelle Impostazioni</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="578"/>
<source>Too many requests to LG: slowing down</source>
<translation>Troppe richieste a LG: rallento gli aggiornamenti</translation>
<translation>Troppe richieste a LG: rallento gli aggiornamenti</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="580"/>
<source>The washing machine is not connected (switched off or offline)</source>
<translation>La lavatrice non e' collegata (spenta o senza rete)</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="584"/>
<source>The machine does not accept this command</source>
<translation>La macchina non accetta questo comando</translation>
<translation>La macchina non accetta questo comando</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="586"/>
<source>LG error %1: %2</source>
<translation>Errore LG %1: %2</translation>
<translation>Errore LG %1: %2</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="588"/>
<source>No answer from the LG cloud: %1</source>
<translation>Nessuna risposta dal cloud LG: %1</translation>
<translation>Nessuna risposta dal cloud LG: %1</translation>
</message>
<message>
<location filename="../src/thinqclient.cpp" line="590"/>
<source>The LG cloud refused the request (HTTP %1)</source>
<translation>Il cloud LG ha rifiutato la richiesta (HTTP %1)</translation>
<translation>Il cloud LG ha rifiutato la richiesta (HTTP %1)</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="123"/>
<source>Washing</source>
<translation>In lavaggio</translation>
<translation>In lavaggio</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="124"/>
<source>Rinsing</source>
<translation>In risciacquo</translation>
<translation>In risciacquo</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="125"/>
<source>Spinning</source>
<translation>In centrifuga</translation>
<translation>In centrifuga</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="126"/>
<source>Drying</source>
<translation>In asciugatura</translation>
<translation>In asciugatura</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="127"/>
<source>Cooling down</source>
<translation>Raffreddamento</translation>
<translation>Raffreddamento</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="128"/>
<source>Refreshing</source>
<translation>Rinfrescando</translation>
<translation>Rinfrescando</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="129"/>
<source>Steam softening</source>
<translation>Ammorbidente a vapore</translation>
<translation>Ammorbidente a vapore</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="130"/>
<source>Detecting the load</source>
<translation>Rilevamento del carico</translation>
<translation>Rilevamento del carico</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="131"/>
<source>Delayed start</source>
<translation>Partenza ritardata</translation>
<translation>Partenza ritardata</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="132"/>
<source>Rinse hold</source>
<translation>Ammollo</translation>
<translation>Ammollo</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="133"/>
<source>Paused</source>
<translation>In pausa</translation>
<translation>In pausa</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="134"/>
<source>Finished</source>
<translation>Fine</translation>
<translation>Fine</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="135"/>
<source>Ready</source>
<translation>Pronta</translation>
<translation>Pronta</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="136"/>
<source>Off</source>
<translation>Spenta</translation>
<translation>Spenta</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="137"/>
<source>Standby</source>
<translation>In attesa</translation>
<translation>In attesa</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="138"/>
<source>Error</source>
<translation>Errore</translation>
<translation>Errore</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="157"/>
<source>Stop</source>
<translation>Ferma</translation>
<translation>Ferma</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="159"/>
<source>Switch off</source>
<translation>Spegni</translation>
<translation>Spegni</translation>
</message>
<message>
<location filename="../src/thinqjson.cpp" line="161"/>
<source>Resume</source>
<translation>Riprendi</translation>
<translation>Riprendi</translation>
</message>
</context>
<context>
<name>harbour-thinq</name>
<message>
<location filename="../qml/harbour-thinq.qml" line="28"/>
<source>Washing finished</source>
<translation>Lavaggio finito</translation>
</message> </message>
</context> </context>
</TS> </TS>