forked from Shinonome/dots-hyprland
added symbol (icon) support to items
This commit is contained in:
@@ -42,10 +42,15 @@ ComboBox {
|
|||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
active: root.buttonIcon.length > 0
|
active: root.buttonIcon.length > 0 || (root.currentIndex >= 0 && root.model[root.currentIndex]?.icon)
|
||||||
visible: active
|
visible: active
|
||||||
sourceComponent: MaterialSymbol {
|
sourceComponent: MaterialSymbol {
|
||||||
text: root.buttonIcon
|
text: {
|
||||||
|
if (root.currentIndex >= 0 && root.model[root.currentIndex]?.icon) {
|
||||||
|
return root.model[root.currentIndex].icon;
|
||||||
|
}
|
||||||
|
return root.buttonIcon;
|
||||||
|
}
|
||||||
iconSize: Appearance.font.pixelSize.larger
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
color: Appearance.colors.colOnSecondaryContainer
|
color: Appearance.colors.colOnSecondaryContainer
|
||||||
}
|
}
|
||||||
@@ -88,13 +93,36 @@ ComboBox {
|
|||||||
anchors.leftMargin: 12
|
anchors.leftMargin: 12
|
||||||
anchors.rightMargin: 12
|
anchors.rightMargin: 12
|
||||||
|
|
||||||
StyledText {
|
Loader {
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
color: root.currentIndex === itemDelegate.index ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer
|
Layout.preferredHeight: Appearance.font.pixelSize.larger
|
||||||
text: itemDelegate.model[root.textRole]
|
active: itemDelegate.model.icon && itemDelegate.model.icon.length > 0
|
||||||
elide: Text.ElideRight
|
visible: active
|
||||||
verticalAlignment: Text.AlignVCenter
|
sourceComponent: Item {
|
||||||
|
implicitWidth: icon.implicitWidth
|
||||||
|
implicitHeight: Appearance.font.pixelSize.larger
|
||||||
|
MaterialSymbol {
|
||||||
|
id: icon
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: itemDelegate.model.icon
|
||||||
|
iconSize: Appearance.font.pixelSize.larger
|
||||||
|
color: root.currentIndex === itemDelegate.index ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: Appearance.font.pixelSize.larger
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: parent.width
|
||||||
|
color: root.currentIndex === itemDelegate.index ? Appearance.colors.colOnPrimary : Appearance.colors.colOnSecondaryContainer
|
||||||
|
text: itemDelegate.model[root.textRole]
|
||||||
|
elide: Text.ElideRight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,6 +162,7 @@ ComboBox {
|
|||||||
id: listView
|
id: listView
|
||||||
clip: true
|
clip: true
|
||||||
implicitHeight: contentHeight
|
implicitHeight: contentHeight
|
||||||
|
spacing: 2
|
||||||
model: root.popup.visible ? root.delegateModel : null
|
model: root.popup.visible ? root.delegateModel : null
|
||||||
currentIndex: root.highlightedIndex
|
currentIndex: root.highlightedIndex
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user