Files
kde-ollamacloud-dashboard/contents/ui/LimitRow.qml
T
Matteo Benedetto 374a54d46a feat: dashboard KDE Plasma 6 per residui Ollama Cloud con countdown reset
Widget desktop 224x224 che mostra:
- residuo sessione (5h) e settimanale (7d) con barre colorate
- conteggio richieste, costo 4 settimane, modello top
- timer di reset stimati (calibrati al primo reset osservato)
- backend bash che chiama https://ollama.com/api/usage
- legge la chiave API da ~/.pi/agent/auth.json (provider ollama-cloud)
2026-08-20 18:34:38 +02:00

97 lines
2.8 KiB
QML

/* Card compatta per una quota Ollama Cloud, pensata per il dashboard desktop. */
import QtQuick
import QtQuick.Layouts
import org.kde.plasma.components 3.0 as PC3
import org.kde.kirigami as Kirigami
Rectangle {
id: root
property string title: ""
property string period: ""
property real remaining: 0.0
property real used: 0.0
property color accent: "#00bcd4"
property var models: []
function requestCount() {
let count = 0
for (let i = 0; i < models.length; ++i) count += Number(models[i].request_count || 0)
return count
}
function requestLabel() {
const count = requestCount()
return count >= 1000 ? (count / 1000).toFixed(1) + "K req" : count + " req"
}
Layout.fillWidth: true
Layout.minimumWidth: 0
Layout.preferredHeight: 42
radius: 6
color: Qt.rgba(0, 0, 0, 0.26)
border.width: 1
border.color: root.accent
ColumnLayout {
anchors.fill: parent
anchors.margins: 5
spacing: 2
RowLayout {
Layout.fillWidth: true
spacing: 5
Rectangle {
Layout.preferredWidth: 25
Layout.preferredHeight: 14
radius: 8
color: root.accent
PC3.Label {
anchors.centerIn: parent
text: root.period
color: "#101012"
font.bold: true
font.pointSize: Kirigami.Theme.defaultFont.pointSize - 2
}
}
PC3.Label {
text: root.title
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
Layout.minimumWidth: 0
}
PC3.Label {
text: root.requestLabel()
color: Kirigami.Theme.disabledTextColor
font.pointSize: Kirigami.Theme.defaultFont.pointSize - 3
}
PC3.Label {
text: Math.round(root.remaining * 100) + "%"
color: root.accent
font.bold: true
font.pointSize: Kirigami.Theme.defaultFont.pointSize + 3
}
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: 6
Rectangle {
id: track
anchors.fill: parent
radius: 4
color: Qt.rgba(0, 0, 0, 0.55)
}
Rectangle {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: track.width * Math.max(0, Math.min(1, root.remaining))
height: parent.height
radius: 4
color: root.accent
}
}
}
}