magpie/qml/Components/AssetLine.qml

84 lines
2.0 KiB
QML
Raw Normal View History

2024-01-18 22:14:33 +00:00
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
2024-01-21 19:22:56 +00:00
import magpie
2024-01-20 21:17:21 +00:00
Item {
2024-01-18 22:14:33 +00:00
id: line
required property string title
required property string icon
2024-01-20 21:17:21 +00:00
required property color color
required property string balance
required property string currency
required property int assetID
2024-01-21 19:22:56 +00:00
signal remove(id: int)
signal edit(id: int)
2024-01-18 22:14:33 +00:00
Row {
2024-01-20 21:17:21 +00:00
readonly property int iconSize: height
readonly property int freespace: width - deleteButton.width - editButton.width - iconSize - spacing * children.length - 1
2024-01-20 21:17:21 +00:00
2024-01-18 22:14:33 +00:00
anchors.fill: parent
2024-01-20 21:17:21 +00:00
spacing: 5
Rectangle {
width: parent.iconSize
height: parent.iconSize
color: line.color
Icon {
2024-01-20 21:17:21 +00:00
anchors.fill: parent
2024-04-05 16:17:24 +00:00
anchors.margins: 2
iconName: line.icon
color: pickColor(line.color)
2024-01-20 21:17:21 +00:00
}
2024-01-18 22:14:33 +00:00
}
Label {
width: parent.freespace / 3
2024-01-20 21:17:21 +00:00
height: parent.height
2024-01-18 22:14:33 +00:00
text: title
2024-01-20 21:17:21 +00:00
verticalAlignment: Text.AlignVCenter
font.bold: true
}
Label {
width: parent.freespace / 3
2024-01-20 21:17:21 +00:00
height: parent.height
text: balance
verticalAlignment: Text.AlignVCenter
2024-01-18 22:14:33 +00:00
}
2024-01-21 19:22:56 +00:00
Label {
width: parent.freespace / 3
height: parent.height
text: currency
verticalAlignment: Text.AlignVCenter
}
Button {
id: editButton
text: qsTr("Edit")
2024-04-07 23:02:00 +00:00
icon.name: "entry-edit"
flat: true
height: parent.height
onClicked: edit(assetID)
}
2024-01-21 19:22:56 +00:00
Button {
id: deleteButton
text: qsTr("Delete")
2024-04-07 23:02:00 +00:00
icon.name: "delete"
2024-01-21 19:22:56 +00:00
height: parent.height
onClicked: remove(assetID)
2024-04-07 23:02:00 +00:00
palette { //unfortunately doesn't work anymore
button: "red"
}
2024-01-21 19:22:56 +00:00
}
2024-01-18 22:14:33 +00:00
}
}