Show icons in device type list
This commit is contained in:
@ -16,6 +16,8 @@ ColumnLayout {
|
||||
EditableListView {
|
||||
id: listView
|
||||
|
||||
iconSourceRole: "iconUrl"
|
||||
|
||||
Layout.preferredWidth: 300
|
||||
Layout.maximumWidth: 300
|
||||
Layout.fillHeight: true
|
||||
|
@ -4,6 +4,7 @@ import QtQuick.Layouts
|
||||
|
||||
ColumnLayout {
|
||||
property string textRole: "name"
|
||||
property string iconSourceRole
|
||||
|
||||
property alias model: listView.model
|
||||
property alias currentIndex: listView.currentIndex
|
||||
@ -13,6 +14,8 @@ ColumnLayout {
|
||||
signal addClicked(index: int)
|
||||
signal removeClicked(index: int)
|
||||
|
||||
id: editableListViewLayout
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
@ -97,8 +100,7 @@ ColumnLayout {
|
||||
contentItem: IconChooserDelegateLayout {
|
||||
anchors.fill: parent
|
||||
text: model[textRole]
|
||||
// TODO
|
||||
//iconSource: comboBox.getIconUrl(index)
|
||||
iconSource: (model && model[iconSourceRole]) ? model[iconSourceRole] : null
|
||||
}
|
||||
onClicked: listView.currentIndex = index
|
||||
down: listView.currentIndex === index
|
||||
|
@ -5,12 +5,13 @@ import QtQuick.Layouts
|
||||
RowLayout {
|
||||
property string text
|
||||
property string iconSource
|
||||
property bool isInsideMaterialComboBox: false
|
||||
|
||||
id: layout
|
||||
|
||||
Image {
|
||||
Layout.topMargin: 15
|
||||
Layout.bottomMargin: 15
|
||||
Layout.topMargin: isInsideMaterialComboBox ? 15 : 9
|
||||
Layout.bottomMargin: isInsideMaterialComboBox ? 15 : 9
|
||||
Layout.fillHeight: true
|
||||
source: layout.iconSource
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
@ -33,5 +33,6 @@ ComboBox {
|
||||
contentItem: IconChooserDelegateLayout {
|
||||
text: comboBox.displayText
|
||||
iconSource: comboBox.currentIndex >= 0 ? comboBox.getIconUrl(comboBox.currentIndex) : ""
|
||||
isInsideMaterialComboBox: true
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,13 @@ import Qt.labs.folderlistmodel 2.4
|
||||
FolderListModel {
|
||||
folder: "qrc:/scheincommander/icons/"
|
||||
showDirs: false
|
||||
|
||||
function getUrlForIcon(name) {
|
||||
let myFolder = folder;
|
||||
if (myFolder.length < 1 || myFolder.charAt(myFolder.length - 1) !== '/') {
|
||||
myFolder = myFolder + '/';
|
||||
}
|
||||
|
||||
return myFolder + name + ".png"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user