diff --git a/DeviceTypesSettingsPage.qml b/DeviceTypesSettingsPage.qml index fe8cac5..3ffb3cd 100644 --- a/DeviceTypesSettingsPage.qml +++ b/DeviceTypesSettingsPage.qml @@ -16,6 +16,8 @@ ColumnLayout { EditableListView { id: listView + iconSourceRole: "iconUrl" + Layout.preferredWidth: 300 Layout.maximumWidth: 300 Layout.fillHeight: true diff --git a/EditableListView.qml b/EditableListView.qml index 3e9e01d..4079615 100644 --- a/EditableListView.qml +++ b/EditableListView.qml @@ -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 diff --git a/IconChooserDelegateLayout.qml b/IconChooserDelegateLayout.qml index 49da30e..30b3464 100644 --- a/IconChooserDelegateLayout.qml +++ b/IconChooserDelegateLayout.qml @@ -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 diff --git a/IconComboBox.qml b/IconComboBox.qml index 73f0ecf..2aac585 100644 --- a/IconComboBox.qml +++ b/IconComboBox.qml @@ -33,5 +33,6 @@ ComboBox { contentItem: IconChooserDelegateLayout { text: comboBox.displayText iconSource: comboBox.currentIndex >= 0 ? comboBox.getIconUrl(comboBox.currentIndex) : "" + isInsideMaterialComboBox: true } } diff --git a/IconsModel.qml b/IconsModel.qml index 87ce116..8ac8238 100644 --- a/IconsModel.qml +++ b/IconsModel.qml @@ -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" + } }