From 1fa62a4551aa5b2c3bbd6831fe627b43330b6b8e Mon Sep 17 00:00:00 2001 From: Claudio Date: Thu, 27 Aug 2026 15:36:54 +0200 Subject: [PATCH] tooltip: una riga per finestra, ognuna completa del suo reset Il reset stava su una riga a se', sotto entrambe le finestre, e si leggeva come se appartenesse all'ultima: un dato giusto attribuito alla riga sbagliata e' peggio di un dato assente. windowSummary sta in main.qml e non in format.js perche' quello e' .pragma library e non vede i18nc. Nel riallineare il catalogo, msgmerge aveva assegnato come fuzzy una traduzione con due segnaposto a una stringa che ne ha tre: in italiano il tempo al reset sarebbe sparito. --- plasmoid/contents/ui/format.js | 1 + plasmoid/contents/ui/main.qml | 52 ++++++++++++++++++++++++---------- translations/dipstick.pot | 19 +++++++++---- translations/it.po | 17 +++++++---- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/plasmoid/contents/ui/format.js b/plasmoid/contents/ui/format.js index 0686000..bdb9be6 100644 --- a/plasmoid/contents/ui/format.js +++ b/plasmoid/contents/ui/format.js @@ -179,3 +179,4 @@ function shortDate(iso) { } return d.toLocaleDateString(Qt.locale(), "d MMM") } + diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index 8bcaf47..3df0338 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -25,26 +25,48 @@ PlasmoidItem { ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus - toolTipMainText: primary - ? i18nc("window label and percentage", "%1: %2%", - Format.windowLabel(primary, i18n), primary.percent) + // Una finestra riassunta in una riga sola, completa di reset. + // + // Sta qui e non in format.js perche' quello e' `.pragma library` e non + // vede `i18nc`. Le altre funzioni la' dentro ricevono `i18n` come + // parametro; per il contesto servirebbe passarne un secondo, e a quel + // punto tanto vale comporre dove il contesto c'e' gia'. + function windowSummary(win, now) { + if (!win) { + return "" + } + var label = Format.windowLabel(win, i18n) + var reset = Format.untilReset(win.resets_at, now, i18n) + if (reset === "") { + return i18nc("quota window and its percentage", "%1: %2%", label, win.percent) + } + return i18nc("quota window, its percentage and when it resets", + "%1: %2% — %3", label, win.percent, reset) + } + + // Il tooltip: una riga per finestra, ognuna completa. + // + // Prima il reset stava su una riga sua, sotto entrambe le finestre, e si + // leggeva come se appartenesse all'ultima. Un dato giusto attribuito alla + // riga sbagliata e' peggio di un dato assente. + toolTipMainText: quotaState && quotaState.compact + ? i18n("Claude usage") : i18n("Claude quota unavailable") toolTipSubText: { if (!quotaState || !quotaState.compact) { - return stateProblem === "missing" - ? i18n("The dipstick daemon is not running") - : "" - } - var lines = [] - var c = quotaState.compact - if (c.secondary) { - lines.push(i18nc("window label and percentage", "%1: %2%", - Format.windowLabel(c.secondary, i18n), c.secondary.percent)) + if (stateProblem === "missing") { + return i18n("The dipstick daemon is not running") + } + if (quotaState && quotaState.quota.needs_auth) { + return i18n("Sign in with: dipstick auth") + } + return quotaState && quotaState.quota.error ? quotaState.quota.error : "" } - var reset = Format.untilReset(c.primary.resets_at, Date.now(), i18n) - if (reset !== "") { - lines.push(reset) + var now = Date.now() + var lines = [windowSummary(quotaState.compact.primary, now)] + if (quotaState.compact.secondary) { + lines.push(windowSummary(quotaState.compact.secondary, now)) } return lines.join("\n") } diff --git a/translations/dipstick.pot b/translations/dipstick.pot index 4f98493..c10a575 100644 --- a/translations/dipstick.pot +++ b/translations/dipstick.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: dipstick 0.1\n" +"Project-Id-Version: dipstick\n" "Report-Msgid-Bugs-To: https://github.com/claudioquaglia/dipstick/issues\n" -"POT-Creation-Date: 2026-08-27 14:51+0200\n" +"POT-Creation-Date: 2026-08-27 15:36+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -56,6 +56,7 @@ msgid "Reinstall dipstick so both halves are on the same version." msgstr "" #: plasmoid/contents/ui/FullRepresentation.qml:120 +#: plasmoid/contents/ui/main.qml:62 msgid "Sign in with: dipstick auth" msgstr "" @@ -68,6 +69,7 @@ msgid "%1 in the last 5h · %2 this week" msgstr "" #: plasmoid/contents/ui/FullRepresentation.qml:180 +#: plasmoid/contents/ui/main.qml:53 msgid "Claude usage" msgstr "" @@ -91,16 +93,21 @@ msgstr "" msgid "Extra usage credits are enabled: reaching 100% will not block you." msgstr "" -#: plasmoid/contents/ui/main.qml:29 plasmoid/contents/ui/main.qml:42 -msgctxt "window label and percentage" +#: plasmoid/contents/ui/main.qml:41 +msgctxt "quota window and its percentage" msgid "%1: %2%" msgstr "" -#: plasmoid/contents/ui/main.qml:31 +#: plasmoid/contents/ui/main.qml:44 +msgctxt "quota window, its percentage and when it resets" +msgid "%1: %2% — %3" +msgstr "" + +#: plasmoid/contents/ui/main.qml:54 msgid "Claude quota unavailable" msgstr "" -#: plasmoid/contents/ui/main.qml:36 +#: plasmoid/contents/ui/main.qml:59 msgid "The dipstick daemon is not running" msgstr "" diff --git a/translations/it.po b/translations/it.po index ca6d63c..6b3dd31 100644 --- a/translations/it.po +++ b/translations/it.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: dipstick 0.1\n" "Report-Msgid-Bugs-To: https://github.com/claudioquaglia/dipstick/issues\n" -"POT-Creation-Date: 2026-08-27 14:51+0200\n" +"POT-Creation-Date: 2026-08-27 15:36+0200\n" "PO-Revision-Date: 2026-08-27 14:00+0200\n" "Last-Translator: Claudio Quaglia\n" "Language-Team: Italiano\n" @@ -56,6 +56,7 @@ msgid "Reinstall dipstick so both halves are on the same version." msgstr "Reinstalla dipstick per allineare le due meta'." #: plasmoid/contents/ui/FullRepresentation.qml:120 +#: plasmoid/contents/ui/main.qml:62 msgid "Sign in with: dipstick auth" msgstr "Accedi con: dipstick auth" @@ -68,6 +69,7 @@ msgid "%1 in the last 5h · %2 this week" msgstr "%1 nelle ultime 5h · %2 questa settimana" #: plasmoid/contents/ui/FullRepresentation.qml:180 +#: plasmoid/contents/ui/main.qml:53 msgid "Claude usage" msgstr "Consumo Claude" @@ -91,16 +93,21 @@ msgstr "I dati della quota potrebbero non essere aggiornati." msgid "Extra usage credits are enabled: reaching 100% will not block you." msgstr "I crediti aggiuntivi sono attivi: toccare il 100% non ti bloccherà." -#: plasmoid/contents/ui/main.qml:29 plasmoid/contents/ui/main.qml:42 -msgctxt "window label and percentage" +#: plasmoid/contents/ui/main.qml:41 +msgctxt "quota window and its percentage" msgid "%1: %2%" msgstr "%1: %2%" -#: plasmoid/contents/ui/main.qml:31 +#: plasmoid/contents/ui/main.qml:44 +msgctxt "quota window, its percentage and when it resets" +msgid "%1: %2% — %3" +msgstr "%1: %2% — %3" + +#: plasmoid/contents/ui/main.qml:54 msgid "Claude quota unavailable" msgstr "Quota Claude non disponibile" -#: plasmoid/contents/ui/main.qml:36 +#: plasmoid/contents/ui/main.qml:59 msgid "The dipstick daemon is not running" msgstr "Il demone dipstick non e' in esecuzione" -- knotmirror 0.0.1