user_avatars
Shared, non-blocking source of round user-avatar pixmaps.
Widgets that show a single user can simply build an :class:AYUserImage. Painters that render many users - table cells, item delegates - need a pixmap on the paint path without touching the network, which is what this cache provides: initials are available immediately, and the real avatar replaces them once it has been downloaded in the background.
UserAvatarCache
Bases: QObject
Cache of round avatar pixmaps keyed by user name and size.
:meth:pixmap never blocks: it returns an initials avatar right away and schedules the real image, emitting :attr:avatar_updated when the download lands so views can repaint.
Source code in client/ayon_core/ui/components/user_avatars.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
clear()
Drop every cached pixmap and downloaded source path.
Source code in client/ayon_core/ui/components/user_avatars.py
127 128 129 130 | |
pixmap(user_name, full_name, size)
Return the avatar for user_name, scheduling a download once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name | str | Login name, used as the cache key and for initials. | required |
full_name | str | Display name the initials are derived from. | required |
size | int | Avatar diameter in logical pixels. | required |
Returns:
| Type | Description |
|---|---|
QPixmap | None | A rendered pixmap, or |
Source code in client/ayon_core/ui/components/user_avatars.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
set_avatar_decoration(option, avatar_cache, user_name, full_name=None, size=ITEM_AVATAR_SIZE)
Show the avatar of a user as the decoration of a view item.
Meant to be called from initStyleOption of an item delegate, so the avatar is painted the same way as an icon of the item, to the left of its text. The view should repaint on :attr:UserAvatarCache.avatar_updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
option | QStyleOptionViewItem | Style option of the painted item. | required |
avatar_cache | UserAvatarCache | Cache the avatar is taken from. | required |
user_name | str | None | Login name of the user, nothing is changed without it. | required |
full_name | str | None | Display name the initials are derived from. | None |
size | int | Avatar diameter in logical pixels. | ITEM_AVATAR_SIZE |
Source code in client/ayon_core/ui/components/user_avatars.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |