/**************************************************************************** Copyright (C) 2020 Tobias Fella <fella@posteo.de> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the ** Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ****************************************************************************/import QtQuick 2.12import QtQuick.Controls 2.12 as Controlsimport org.kde.kirigami 2.7 as KirigamiControls.ComboBox {id: comboBoxproperty string labelproperty var componentKirigami.FormData.label: labelmodel: component.applicationstextRole: "name"currentIndex: component.indexonActivated: component.select(currentIndex, true)delegate: Controls.ItemDelegate {width: comboBox.popup.widthtext: modelData[comboBox.textRole]highlighted: comboBox.highlightedIndex == indexicon.name: modelData.icon}// HACK QQC2 doesn't support icons, so we just tamper with the desktop style ComboBox's backgroundComponent.onCompleted: {if (!background || !background.hasOwnProperty("properties")) {//not a KQuickStyleItemreturn;}var props = background.properties || {};background.properties = Qt.binding(function() {var newProps = props;newProps.currentIcon = component.applications[currentIndex]["icon"];newProps.iconColor = Kirigami.Theme.textColor;return newProps;});}}