Warning, /libraries/kirigami-addons/src/components/AvatarButton.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Controls 2.15 as QQC2
0006 import org.kde.kirigami 2.15 as Kirigami
0007 
0008 /**
0009  * @brief An button that represents a user, either with initials, an icon, or a profile image.
0010  */
0011 QQC2.AbstractButton {
0012     id: root
0013 
0014     /**
0015      * @brief This property holds the given name of a user.
0016      * @see org:kde::kirigamiaddons::components::Avatar::source
0017      */
0018     property alias name: avatar.name
0019 
0020     /**
0021      * @brief This property holds avatar's icon source.
0022      * @see org:kde::kirigamiaddons::components::Avatar::source
0023      */
0024     property alias source: avatar.source
0025 
0026     /**
0027      * @brief This property holds how the button should represent the user when no user-set image is available.
0028      * @see org:kde::kirigamiaddons::components::Avatar::initialsMode
0029      */
0030     property alias initialsMode: avatar.initialsMode
0031 
0032     /**
0033      * @brief This property holds how the avatar should be shown.
0034      * @see org:kde::kirigamiaddons::components::Avatar::imageMode
0035      */
0036     property alias imageMode: avatar.imageMode
0037 
0038     /**
0039      * @brief This property sets whether the provided image should be cached.
0040      * @see QtQuick.Image::cache
0041      */
0042     property alias cache: avatar.cache
0043 
0044     /**
0045      * @brief This property holds the source size of the user's profile picture.
0046      */
0047     property alias sourceSize: avatar.sourceSize
0048 
0049     /**
0050      * @brief This property holds the color to use for this avatar.
0051      */
0052     property alias color: avatar.color
0053 
0054     /**
0055      * @brief This property holds the color of the avatar's initials.
0056      */
0057     property alias initialsColor: avatar.initialsColor
0058 
0059     /**
0060      * @brief This property holds the default color of the avatar's initials.
0061      */
0062     readonly property alias defaultInitialsColor: avatar.defaultInitialsColor
0063 
0064     /**
0065      * @brief This item holds the parent item on the clipped circle.
0066      *
0067      * Implementations may add custom graphics which will be clipped along with
0068      * the rest of the avatar content.
0069      */
0070     readonly property alias clippedContent: avatar.clippedContent
0071 
0072     Kirigami.Theme.colorSet: Kirigami.Theme.Button
0073     Kirigami.Theme.inherit: false
0074 
0075     text: name
0076 
0077     padding: 1
0078 
0079     hoverEnabled: true // so the tooltip works
0080 
0081     contentItem: Avatar {
0082         id: avatar
0083     }
0084 
0085     background: Rectangle {
0086         radius: height
0087         color: Kirigami.Theme.focusColor
0088         visible: root.visualFocus || root.down
0089     }
0090 
0091     HoverHandler {
0092         cursorShape: Qt.PointingHandCursor
0093     }
0094 
0095     QQC2.ToolTip.visible: hovered && text.length > 0
0096     QQC2.ToolTip.text: text
0097     QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0098 }