some thoughts about icons

This commit is contained in:
Blue 2024-04-01 22:45:48 -03:00
parent cf2f387f58
commit abc3ebf80a
Signed by: blue
GPG key ID: 9B203B252A63EE38
8 changed files with 166 additions and 5 deletions

View file

@ -11,6 +11,7 @@ qt_add_qml_module(magpieComponents
QML_FILES
Modal.qml
AssetLine.qml
IconPicker.qml
)
target_link_libraries(magpie PRIVATE magpieComponents)

View file

@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
ComboBox {
property string icon: ""
id: box
model: ["wallet", "whatever"]
delegate: MenuItem {
required property string modelData
required property int index
width: parent.width
highlighted: box.highlightedIndex === index
contentItem: View {
icon: modelData
}
}
contentItem: View {
icon: currentText
padding: 5
}
component View: Row {
required property string icon
property int iconSize: 20
spacing: 5
IconImage {
id: image
anchors.verticalCenter: parent.verticalCenter
color: palette.text
source: "qrc:/icons/" + icon + ".svg"
height: parent.iconSize
width: parent.iconSize
IconImage {
id: fallback
anchors.fill: parent
source: "qrc:/icons/wallet.svg"
visible: parent.status == Image.Error
color: palette.text
}
}
Label {
anchors.verticalCenter: parent.verticalCenter
text: icon
}
}
}

View file

@ -36,15 +36,16 @@ Item {
TextField {
id: titleField
text: "New Asset"
}
Label {
text: qsTr("Icon") + ":";
}
TextField {
Components.IconPicker {
id: iconField
text: "list-add"
icon: "list-add"
}
Label {
@ -66,7 +67,7 @@ Item {
Button {
text: qsTr("Create")
onClicked: inner.send(titleField.text, iconField.text, colorField.text)
onClicked: inner.confirm()
}
}
@ -74,12 +75,17 @@ Item {
id: modal
}
function confirm () {
//TODO validation
send(titleField.text, iconField.icon, colorField.text);
}
function send (title, icon, color) {
if (modal.inProgress)
return;
titleField.text = title;
iconField.text = icon;
iconField.icon = icon;
colorField.text = color;
modal.inProgress = true;