Kirigami-addons

AvatarButton.qml
1// SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4import QtQuick 2.15
5import QtQuick.Controls 2.15 as QQC2
6import org.kde.kirigami 2.15 as Kirigami
7
8/**
9 * @brief An button that represents a user, either with initials, an icon, or a profile image.
10 */
11QQC2.AbstractButton {
12 id: root
13
14 /**
15 * @brief This property holds the given name of a user.
16 * @see org:kde::kirigamiaddons::components::Avatar::source
17 */
18 property alias name: avatar.name
19
20 /**
21 * @brief This property holds avatar's icon source.
22 * @see org:kde::kirigamiaddons::components::Avatar::source
23 */
24 property alias source: avatar.source
26 /**
27 * @brief This property holds how the button should represent the user when no user-set image is available.
28 * @see org:kde::kirigamiaddons::components::Avatar::initialsMode
29 */
30 property alias initialsMode: avatar.initialsMode
31
32 /**
33 * @brief This property holds how the avatar should be shown.
34 * @see org:kde::kirigamiaddons::components::Avatar::imageMode
35 */
36 property alias imageMode: avatar.imageMode
37
38 /**
39 * @brief This property sets whether the provided image should be cached.
40 * @see QtQuick.Image::cache
41 */
42 property alias cache: avatar.cache
44 /**
45 * @brief This property holds the source size of the user's profile picture.
46 */
47 property alias sourceSize: avatar.sourceSize
48
49 /**
50 * @brief This property holds the color to use for this avatar.
51 */
52 property alias color: avatar.color
53
54 /**
55 * @brief This property holds the color of the avatar's initials.
56 */
57 property alias initialsColor: avatar.initialsColor
58
59 /**
60 * @brief This property holds the default color of the avatar's initials.
61 */
62 readonly property alias defaultInitialsColor: avatar.defaultInitialsColor
63
64 /**
65 * @brief This item holds the parent item on the clipped circle.
66 *
67 * Implementations may add custom graphics which will be clipped along with
68 * the rest of the avatar content.
69 */
70 readonly property alias clippedContent: avatar.clippedContent
71
72 Kirigami.Theme.colorSet: Kirigami.Theme.Button
73 Kirigami.Theme.inherit: false
74
75 text: name
76
77 padding: 1
78
79 hoverEnabled: true // so the tooltip works
80
81 contentItem: Avatar {
82 id: avatar
83 }
84
85 background: Rectangle {
86 radius: height
87 color: Kirigami.Theme.focusColor
88 visible: root.visualFocus || root.down
89 }
90
91 HoverHandler {
92 cursorShape: Qt.PointingHandCursor
93 }
94
95 QQC2.ToolTip.visible: hovered && text.length > 0
96 QQC2.ToolTip.text: text
97 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
98}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.