From 887d3a6888f984bd3e5e5f64b7fbdb0fabff98a2 Mon Sep 17 00:00:00 2001 From: Carlo Baratto Date: Thu, 29 Oct 2026 07:43:05 +0100 Subject: [PATCH] 0.1.3: copertina con CPU, RAM e disco in percentuale --- README.md | 2 +- qml/cover/CoverPage.qml | 104 ++++++++++++++++++++++++++++++++-------- rpm/harbour-server.spec | 6 ++- src/main.cpp | 4 +- 4 files changed, 93 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 447dc97..fe39530 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Requisiti: SDK Sailfish in `~/SailfishOS`, build engine Docker. ## Installazione sul telefono ```sh -devel-su rpm -Uvh harbour-server-0.1.2-1.aarch64.rpm +devel-su rpm -Uvh harbour-server-0.1.3-1.aarch64.rpm ``` Poi, all'apertura: indicare indirizzo (es. `http://192.168.3.21:8792`) e token. diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml index f2548ee..0ec8909 100644 --- a/qml/cover/CoverPage.qml +++ b/qml/cover/CoverPage.qml @@ -6,39 +6,105 @@ CoverBackground { // Guardie: quando lo snapshot non è ancora arrivato i campi mancano e in // JS leggere una proprietà di undefined solleva un'eccezione. - function num(v, fallback) { - return (v === undefined || v === null) ? fallback : v + function cpuPct() { + var d = statusClient.data + return (d && d.cpu && d.cpu.percent !== undefined) ? d.cpu.percent : -1 + } + function memPct() { + var d = statusClient.data + return (d && d.memory && d.memory.percent !== undefined) ? d.memory.percent : -1 + } + function diskPct() { + var d = statusClient.data + if (d && d.disks && d.disks.length > 0 && d.disks[0].percent !== undefined) + return d.disks[0].percent + return -1 + } + + // Stesse soglie delle card: verde, giallo da 85%, rosso da 95%. + function levelColor(p) { + if (p < 0) return Theme.secondaryColor + if (p >= 95) return "#e53935" + if (p >= 85) return "#ffb300" + return "#43a047" + } + function pctText(p) { + return p < 0 ? "—" : statusClient.fmtNum(p, 0) + "%" } Column { anchors.centerIn: parent - width: parent.width - 2 * Theme.paddingLarge + width: parent.width - 2 * Theme.paddingMedium spacing: Theme.paddingSmall Label { - text: "Server" - font.pixelSize: Theme.fontSizeSmall - color: Theme.secondaryColor - anchors.horizontalCenter: parent.horizontalCenter - } - - Label { - text: statusClient.error !== "" ? "—" : statusClient.fmtNum(num(statusClient.data.cpu ? statusClient.data.cpu.percent : undefined, -1), 0) + " %" - font.pixelSize: Theme.fontSizeExtraLarge - anchors.horizontalCenter: parent.horizontalCenter - } - - Label { - text: "CPU" + text: qsTr("Server") font.pixelSize: Theme.fontSizeExtraSmall color: Theme.secondaryColor anchors.horizontalCenter: parent.horizontalCenter } + // CPU · RAM · disco: etichetta a sinistra, percentuale a destra. + Column { + width: parent.width + spacing: Theme.paddingSmall / 2 + + Row { + width: parent.width + Label { + text: qsTr("CPU") + width: parent.width * 0.5 + font.pixelSize: Theme.fontSizeSmall + color: Theme.primaryColor + } + Label { + text: pctText(cpuPct()) + width: parent.width * 0.5 + horizontalAlignment: Text.AlignRight + font.pixelSize: Theme.fontSizeSmall + color: levelColor(cpuPct()) + } + } + + Row { + width: parent.width + Label { + text: qsTr("RAM") + width: parent.width * 0.5 + font.pixelSize: Theme.fontSizeSmall + color: Theme.primaryColor + } + Label { + text: pctText(memPct()) + width: parent.width * 0.5 + horizontalAlignment: Text.AlignRight + font.pixelSize: Theme.fontSizeSmall + color: levelColor(memPct()) + } + } + + Row { + width: parent.width + Label { + text: qsTr("Disco") + width: parent.width * 0.5 + font.pixelSize: Theme.fontSizeSmall + color: Theme.primaryColor + } + Label { + text: pctText(diskPct()) + width: parent.width * 0.5 + horizontalAlignment: Text.AlignRight + font.pixelSize: Theme.fontSizeSmall + color: levelColor(diskPct()) + } + } + } + Label { - text: statusClient.fetchedAt !== "" ? statusClient.fetchedAt : "" + text: statusClient.error !== "" ? qsTr("errore") : statusClient.fetchedAt font.pixelSize: Theme.fontSizeExtraSmall - color: Theme.secondaryColor + color: statusClient.error !== "" ? "#e53935" : Theme.secondaryColor anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/rpm/harbour-server.spec b/rpm/harbour-server.spec index d42e864..9e27dd2 100644 --- a/rpm/harbour-server.spec +++ b/rpm/harbour-server.spec @@ -1,6 +1,6 @@ Name: harbour-server Summary: Parametri del server in una schermata -Version: 0.1.2 +Version: 0.1.3 Release: 1 Group: Qt/Qt License: MIT @@ -23,6 +23,10 @@ schermata sola. Il formato consumato (schema status/1) non dipende dalla macchina: qualunque host che serva lo stesso JSON funziona senza modifiche. %changelog +* Wed Oct 28 2026 Carlo Baratto - 0.1.3-1 +- Copertina (widget): CPU, RAM e disco con le percentuali d'uso in tre righe, + colorate con le stesse soglie delle card (giallo da 85%, rosso da 95%); + in basso l'ora dell'ultimo aggiornamento o "errore" * Wed Oct 28 2026 Carlo Baratto - 0.1.2-1 - Card Backup: età in GIORNI INTERI (arrotondata, non più "41,5 h" o "1,7 giorni") con soglie verde 1-3 giorni, giallo 4-6, rosso da 7 in su; diff --git a/src/main.cpp b/src/main.cpp index d2b8748..2cd2640 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,9 +15,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) // AppConfigLocation = ~/.config/harbour/server (zona persistente). app->setOrganizationName(QStringLiteral("harbour")); app->setApplicationName(QStringLiteral("server")); - app->setApplicationVersion(QStringLiteral("0.1.2")); + app->setApplicationVersion(QStringLiteral("0.1.3")); - qDebug() << "harbour-server v0.1.2 build" << __DATE__ << __TIME__; + qDebug() << "harbour-server v0.1.3 build" << __DATE__ << __TIME__; Settings settings; StatusClient status(&settings);