magpie/qml/Components/AssetLine.qml

84 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 remove(id: int)
signal edit(id: int)
Row {
readonly property int iconSize: height
readonly property int freespace: width - deleteButton.width - editButton.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
anchors.margins: 2
iconName: line.icon
color: pickColor(line.color)
}
}
Label {
width: parent.freespace / 3
height: parent.height
text: title
verticalAlignment: Text.AlignVCenter
font.bold: true
}
Label {
width: parent.freespace / 3
height: parent.height
text: balance
verticalAlignment: Text.AlignVCenter
}
Label {
width: parent.freespace / 3
height: parent.height
text: currency
verticalAlignment: Text.AlignVCenter
}
Button {
id: editButton
text: qsTr("Edit")
icon.name: "entry-edit"
flat: true
height: parent.height
onClicked: edit(assetID)
}
Button {
id: deleteButton
text: qsTr("Delete")
icon.name: "delete"
height: parent.height
onClicked: remove(assetID)
palette { //unfortunately doesn't work anymore
button: "red"
}
}
}
}