2024-01-17 21:57:34 +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-20 21:17:21 +00:00
|
|
|
import magpie
|
2024-01-17 21:57:34 +00:00
|
|
|
import magpie.Components as Components
|
|
|
|
|
|
|
|
Item {
|
2024-04-05 16:17:24 +00:00
|
|
|
property string name: qsTr("New asset")
|
|
|
|
property string icon: "wallet"
|
|
|
|
property color color: "green"
|
|
|
|
property int currency: 1
|
|
|
|
|
|
|
|
property string title: qsTr("New asset")
|
|
|
|
|
|
|
|
signal confirm (name: string, icon: string, color: color, currency: int)
|
2024-01-17 21:57:34 +00:00
|
|
|
signal cancel
|
|
|
|
|
2024-04-05 16:17:24 +00:00
|
|
|
id: form
|
|
|
|
|
2024-01-17 21:57:34 +00:00
|
|
|
Column {
|
|
|
|
id: inner
|
|
|
|
spacing: 5
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2024-04-05 16:17:24 +00:00
|
|
|
text: title
|
2024-01-17 21:57:34 +00:00
|
|
|
font.pixelSize: 14
|
|
|
|
}
|
|
|
|
|
|
|
|
Grid {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
columns: 2
|
|
|
|
columnSpacing: 10
|
|
|
|
rowSpacing: 5
|
|
|
|
verticalItemAlignment: Grid.AlignVCenter
|
|
|
|
horizontalItemAlignment: Grid.AlignRight
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Title") + ":";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: titleField
|
2024-04-05 16:17:24 +00:00
|
|
|
text: name
|
|
|
|
|
|
|
|
onTextChanged: name = text
|
2024-01-17 21:57:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Icon") + ":";
|
|
|
|
}
|
|
|
|
|
2024-04-02 01:45:48 +00:00
|
|
|
Components.IconPicker {
|
2024-01-17 21:57:34 +00:00
|
|
|
id: iconField
|
2024-04-05 16:17:24 +00:00
|
|
|
icon: form.icon
|
|
|
|
|
|
|
|
onIconChanged: form.icon = icon
|
2024-01-17 21:57:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Color") + ":";
|
|
|
|
}
|
|
|
|
|
2024-04-05 16:17:24 +00:00
|
|
|
Components.ColorPicker {
|
2024-01-17 21:57:34 +00:00
|
|
|
id: colorField
|
2024-04-05 16:17:24 +00:00
|
|
|
color: form.color
|
|
|
|
|
|
|
|
onColorChanged: form.color = colorField.color
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Currency") + ":";
|
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox {
|
|
|
|
id: currencyField
|
|
|
|
|
2024-04-08 22:46:26 +00:00
|
|
|
textRole: "code"
|
2024-04-05 16:17:24 +00:00
|
|
|
valueRole: "id"
|
|
|
|
|
|
|
|
model: Magpie.currencies
|
|
|
|
|
|
|
|
Component.onCompleted: currentIndex = indexOfValue(currency)
|
|
|
|
onActivated: index => currency = currentValue
|
2024-01-17 21:57:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
spacing: 5
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
Button {
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: cancel()
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
2024-04-05 16:17:24 +00:00
|
|
|
text: qsTr("Confirm")
|
|
|
|
onClicked: inner.onConfirmClick()
|
2024-01-17 21:57:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-05 16:17:24 +00:00
|
|
|
function onConfirmClick () {
|
2024-04-02 01:45:48 +00:00
|
|
|
//TODO validation
|
2024-04-05 16:17:24 +00:00
|
|
|
confirm(name, icon, form.color, currency);
|
2024-01-17 21:57:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|