120 lines
3.8 KiB
QML
120 lines
3.8 KiB
QML
/* Card per un servizio AI: saldo residuo grande + barra + sottocampi. */
|
|
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 badge: "" // es. "USD"
|
|
property color accent: "#00bcd4"
|
|
property string remainingText: "—" // testo grande del residuo (es. "$1.56")
|
|
property string subText: "" // riga secondaria
|
|
property string footText: "" // riga footer (es. "16% · usati $8.44")
|
|
property real progress: 1.0 // 0..1 per la barra; NaN per nasconderla
|
|
property bool available: true
|
|
property bool hasError: false
|
|
property string errorText: ""
|
|
|
|
Layout.fillWidth: true
|
|
Layout.minimumWidth: 0
|
|
Layout.preferredHeight: 54
|
|
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: 34
|
|
Layout.preferredHeight: 14
|
|
radius: 8
|
|
color: root.accent
|
|
PC3.Label {
|
|
anchors.centerIn: parent
|
|
text: root.badge
|
|
color: "#101012"
|
|
font.bold: true
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize - 3
|
|
}
|
|
}
|
|
PC3.Label {
|
|
text: root.title
|
|
font.bold: true
|
|
elide: Text.ElideRight
|
|
Layout.fillWidth: true
|
|
Layout.minimumWidth: 0
|
|
}
|
|
Rectangle {
|
|
visible: !root.hasError
|
|
Layout.preferredWidth: 8
|
|
Layout.preferredHeight: 8
|
|
radius: 4
|
|
color: root.available ? root.accent : Kirigami.Theme.negativeTextColor
|
|
}
|
|
PC3.Label {
|
|
text: root.remainingText
|
|
color: root.accent
|
|
font.bold: true
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize + 3
|
|
}
|
|
}
|
|
|
|
Item {
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 6
|
|
visible: !root.hasError && !isNaN(root.progress)
|
|
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.progress))
|
|
height: parent.height
|
|
radius: 4
|
|
color: root.accent
|
|
}
|
|
}
|
|
|
|
PC3.Label {
|
|
visible: root.hasError
|
|
Layout.fillWidth: true
|
|
wrapMode: Text.Wrap
|
|
color: Kirigami.Theme.negativeTextColor
|
|
text: root.errorText
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize - 3
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
visible: !root.hasError
|
|
PC3.Label {
|
|
text: root.subText
|
|
color: Kirigami.Theme.disabledTextColor
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize - 3
|
|
Layout.fillWidth: true
|
|
Layout.minimumWidth: 0
|
|
elide: Text.ElideRight
|
|
}
|
|
PC3.Label {
|
|
text: root.footText
|
|
color: Kirigami.Theme.disabledTextColor
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize - 3
|
|
}
|
|
}
|
|
}
|
|
} |