magpie/qml/Components/AssetLine.qml

79 lines
2.0 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
IconLabel {
anchors.fill: parent
icon {
name: line.icon
width: width
height: height
}
}
}
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);
})
}
}
}