/*SPDX-FileCopyrightText: 2020 Tobias Fella <fella@posteo.de>SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Controls as QQC2import org.kde.kirigami as Kirigamiimport org.kde.kitemmodels as KItemModelsQQC2.ComboBox {id: comboBoxproperty var componentmodel: component.applicationstextRole: "name"currentIndex: component.indexonActivated: component.select(currentIndex)// HACK QQC2 doesn't support icons, so we just tamper with the desktop style ComboBox's backgroundfunction loadProps() {if (!background || !background.hasOwnProperty("properties")) {//not a KQuickStyleItemreturn;}const props = background.properties || {};background.properties = Qt.binding(() => {const modelIndex = model.index(currentIndex, 0);const currentIcon = model.data(modelIndex, model.KItemModels.KRoleNames.role("icon"));return Object.assign(props, {currentIcon,iconColor: Kirigami.Theme.textColor,});});}Connections {target: comboBox.componentfunction onIndexChanged() {comboBox.loadProps();}}delegate: QQC2.ItemDelegate {width: ListView.view.widthtext: model.namehighlighted: comboBox.highlightedIndex == indexicon.name: model.icon}Component.onCompleted: loadProps()}