Warning, /network/neochat/src/qml/AvatarFlow.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003 
0004 import QtQuick
0005 import QtQuick.Controls as QQC2
0006 
0007 import org.kde.kirigami as Kirigami
0008 import org.kde.kirigamiaddons.labs.components as KirigamiComponents
0009 
0010 Flow {
0011     id: root
0012 
0013     property var avatarSize: Kirigami.Units.iconSizes.small
0014     property alias model: avatarFlowRepeater.model
0015     property string toolTipText
0016     property alias excessAvatars: excessAvatarsLabel.text
0017 
0018     spacing: -avatarSize / 2
0019     Repeater {
0020         id: avatarFlowRepeater
0021         delegate: KirigamiComponents.Avatar {
0022             required property var modelData
0023 
0024             implicitWidth: root.avatarSize
0025             implicitHeight: root.avatarSize
0026 
0027             name: modelData.displayName
0028             source: modelData.avatarSource
0029             color: modelData.color
0030         }
0031     }
0032     QQC2.Label {
0033         id: excessAvatarsLabel
0034         visible: text !== ""
0035         color: Kirigami.Theme.textColor
0036         horizontalAlignment: Text.AlignHCenter
0037         background: Kirigami.ShadowedRectangle {
0038             color: Kirigami.Theme.backgroundColor
0039             Kirigami.Theme.inherit: false
0040             Kirigami.Theme.colorSet: Kirigami.Theme.View
0041             radius: height / 2
0042             shadow.size: Kirigami.Units.smallSpacing
0043             shadow.color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.10)
0044             border.color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.15)
0045             border.width: 1
0046         }
0047 
0048         height: Kirigami.Units.iconSizes.small + Kirigami.Units.smallSpacing
0049         width: Math.max(excessAvatarsTextMetrics.advanceWidth + Kirigami.Units.smallSpacing * 2, height)
0050 
0051         TextMetrics {
0052             id: excessAvatarsTextMetrics
0053             text: excessAvatarsLabel.text
0054         }
0055     }
0056 
0057     QQC2.ToolTip.text: toolTipText
0058     QQC2.ToolTip.visible: hoverHandler.hovered
0059     QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0060 
0061     HoverHandler {
0062         id: hoverHandler
0063         margin: Kirigami.Units.smallSpacing
0064     }
0065 }