Add iconName property to model

This commit is contained in:
2023-02-18 23:48:28 +01:00
parent e968ae42cf
commit e627f8ebca
6 changed files with 70 additions and 25 deletions

32
IconComboBox.qml Normal file
View File

@@ -0,0 +1,32 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
ComboBox {
id: comboBox
property string iconSourceRole
delegate: ItemDelegate {
height: 64
anchors.left: parent.left
anchors.right: parent.right
contentItem: IconChooserDelegateLayout {
anchors.top: parent.top
anchors.bottom: parent.bottom
text: model[comboBox.textRole]
iconSource: model[comboBox.iconSourceRole]
}
}
contentItem: IconChooserDelegateLayout {
text: comboBox.currentText
iconSource: {
if (!comboBox.model)
return '';
const url = comboBox.model.get(comboBox.currentIndex, "fileUrl");
if (!url)
return '';
return url;
}
}
}