magpie/qml/Components/IconPicker.qml

55 lines
1.3 KiB
QML
Raw Normal View History

2024-04-02 01:45:48 +00:00
// 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
}
}
}