magpie/qml/Components/AssetLine.qml

76 lines
1.9 KiB
QML

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
import magpie
Item {
id: line
required property string title
required property string icon
required property color color
required property string balance
required property string currency
required property int assetId
signal error (err:string)
Row {
readonly property int iconSize: height
readonly property int freespace: width - deleteButton.width - iconSize - spacing * children.length - 1
anchors.fill: parent
spacing: 5
Rectangle {
width: parent.iconSize
height: parent.iconSize
color: line.color
Icon {
anchors.fill: parent
iconName: line.icon
color: pickColor(line.color)
}
}
Text {
width: parent.freespace / 3
height: parent.height
text: title
verticalAlignment: Text.AlignVCenter
color: palette.text
font.bold: true
}
Text {
width: parent.freespace / 3
height: parent.height
text: balance
verticalAlignment: Text.AlignVCenter
color: palette.text
}
Text {
width: parent.freespace / 3
height: parent.height
text: currency
verticalAlignment: Text.AlignVCenter
color: palette.text
}
Button {
id: deleteButton
text: qsTr("Delete")
flat: true
height: parent.height
onClicked: API.deleteAsset(line.assetId, function(err) {
if (err)
Magpie.displayError("Error deleting asset " + line.title + ": " + err);
})
}
}
}