// SPDX-FileCopyrightText: 2023 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick import QtQuick.Controls IconImage { required property string iconName property int iconSize: 20 id: image source: "qrc:/icons/" + iconName + ".svg" height: iconSize width: iconSize sourceSize.width: iconSize sourceSize.height: iconSize IconImage { id: fallback anchors.fill: parent source: "qrc:/icons/unknown.svg" visible: parent.status == Image.Error color: image.color sourceSize.width: iconSize sourceSize.height: iconSize } function pickColor (color: color) { const text = palette.text; const base = palette.base; const t = brightness(text) const b = brightness(base) let l = text, r = base; if (t > b) { l = base; r = text; } const s = (t + b) / 2; if (brightness(color) - s > 0) return l; else return r; } function brightness (color: color) { return Math.sqrt(0.2126 * color.r * color.r + 0.7152 * color.g * color.g + 0.0722 * color.b * color.b); } }