some thoughts about icons
This commit is contained in:
parent
cf2f387f58
commit
abc3ebf80a
8 changed files with 166 additions and 5 deletions
|
@ -11,6 +11,7 @@ qt_add_qml_module(magpieComponents
|
|||
QML_FILES
|
||||
Modal.qml
|
||||
AssetLine.qml
|
||||
IconPicker.qml
|
||||
)
|
||||
|
||||
target_link_libraries(magpie PRIVATE magpieComponents)
|
||||
|
|
54
qml/Components/IconPicker.qml
Normal file
54
qml/Components/IconPicker.qml
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue