Show icons in device type list

This commit is contained in:
Michael Ehrenreich
2023-02-23 00:34:31 +01:00
parent bbb3ccd0db
commit 97be6c6b6e
5 changed files with 19 additions and 4 deletions

View File

@ -16,6 +16,8 @@ ColumnLayout {
EditableListView { EditableListView {
id: listView id: listView
iconSourceRole: "iconUrl"
Layout.preferredWidth: 300 Layout.preferredWidth: 300
Layout.maximumWidth: 300 Layout.maximumWidth: 300
Layout.fillHeight: true Layout.fillHeight: true

View File

@ -4,6 +4,7 @@ import QtQuick.Layouts
ColumnLayout { ColumnLayout {
property string textRole: "name" property string textRole: "name"
property string iconSourceRole
property alias model: listView.model property alias model: listView.model
property alias currentIndex: listView.currentIndex property alias currentIndex: listView.currentIndex
@ -13,6 +14,8 @@ ColumnLayout {
signal addClicked(index: int) signal addClicked(index: int)
signal removeClicked(index: int) signal removeClicked(index: int)
id: editableListViewLayout
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
@ -97,8 +100,7 @@ ColumnLayout {
contentItem: IconChooserDelegateLayout { contentItem: IconChooserDelegateLayout {
anchors.fill: parent anchors.fill: parent
text: model[textRole] text: model[textRole]
// TODO iconSource: (model && model[iconSourceRole]) ? model[iconSourceRole] : null
//iconSource: comboBox.getIconUrl(index)
} }
onClicked: listView.currentIndex = index onClicked: listView.currentIndex = index
down: listView.currentIndex === index down: listView.currentIndex === index

View File

@ -5,12 +5,13 @@ import QtQuick.Layouts
RowLayout { RowLayout {
property string text property string text
property string iconSource property string iconSource
property bool isInsideMaterialComboBox: false
id: layout id: layout
Image { Image {
Layout.topMargin: 15 Layout.topMargin: isInsideMaterialComboBox ? 15 : 9
Layout.bottomMargin: 15 Layout.bottomMargin: isInsideMaterialComboBox ? 15 : 9
Layout.fillHeight: true Layout.fillHeight: true
source: layout.iconSource source: layout.iconSource
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit

View File

@ -33,5 +33,6 @@ ComboBox {
contentItem: IconChooserDelegateLayout { contentItem: IconChooserDelegateLayout {
text: comboBox.displayText text: comboBox.displayText
iconSource: comboBox.currentIndex >= 0 ? comboBox.getIconUrl(comboBox.currentIndex) : "" iconSource: comboBox.currentIndex >= 0 ? comboBox.getIconUrl(comboBox.currentIndex) : ""
isInsideMaterialComboBox: true
} }
} }

View File

@ -4,4 +4,13 @@ import Qt.labs.folderlistmodel 2.4
FolderListModel { FolderListModel {
folder: "qrc:/scheincommander/icons/" folder: "qrc:/scheincommander/icons/"
showDirs: false showDirs: false
function getUrlForIcon(name) {
let myFolder = folder;
if (myFolder.length < 1 || myFolder.charAt(myFolder.length - 1) !== '/') {
myFolder = myFolder + '/';
}
return myFolder + name + ".png"
}
} }