import QtQuick import "../theme" // Icon tile: a Nerd Font glyph when one is installed, otherwise the fallback text. Rectangle { id: root property string glyph: "" property string fallback: "" // An image (e.g. the project crest) replaces the glyph when set. property url image: "" property bool active: false property int size: 30 property int glyphSize: Math.round(size * 0.5) property color glyphColor: active ? Theme.accentText : Theme.text implicitWidth: size implicitHeight: size radius: Math.min(size / 2, Math.max(6, Theme.radius * 0.4)) color: active ? Theme.accent : Theme.surfaceVariant border.width: active ? 0 : 1 border.color: Theme.hairline Behavior on color { ColorAnimation { duration: Theme.duration } } Image { anchors.fill: parent anchors.margins: Math.round(root.size * 0.12) visible: root.image.toString() !== "" source: root.image sourceSize: Qt.size(root.size * 2, root.size * 2) fillMode: Image.PreserveAspectFit smooth: true mipmap: true asynchronous: true } Text { anchors.centerIn: parent visible: root.image.toString() === "" text: Icons.available && root.glyph ? root.glyph : root.fallback font.family: Icons.available && root.glyph ? Icons.family : "" font.pixelSize: Icons.available && root.glyph ? root.glyphSize : Math.round(root.glyphSize * 0.9) font.weight: Font.DemiBold color: root.glyphColor } }