| 455 | } |
| 456 | |
| 457 | void PeerData::paintUserpic( |
| 458 | QPainter &p, |
| 459 | Ui::PeerUserpicView &view, |
| 460 | PaintUserpicContext context) const { |
| 461 | if (const auto broadcast = monoforumBroadcast()) { |
| 462 | if (context.shape == Ui::PeerUserpicShape::Auto) { |
| 463 | context.shape = Ui::PeerUserpicShape::Monoforum; |
| 464 | } |
| 465 | broadcast->paintUserpic(p, view, context); |
| 466 | return; |
| 467 | } |
| 468 | const auto size = context.size; |
| 469 | const auto cloud = userpicCloudImage(view); |
| 470 | const auto shouldLoad = cloud |
| 471 | && (!GetEnhancedBool("screenshot_mode") |
| 472 | || isVerified() |
| 473 | || isServiceUser()); |
| 474 | const auto ratio = style::DevicePixelRatio(); |
| 475 | if (context.shape == Ui::PeerUserpicShape::Auto) { |
| 476 | context.shape = (isForum() && !isBot()) |
| 477 | ? Ui::PeerUserpicShape::Forum |
| 478 | : isMonoforum() |
| 479 | ? Ui::PeerUserpicShape::Monoforum |
| 480 | : Ui::PeerUserpicShape::Circle; |
| 481 | } |
| 482 | Ui::ValidateUserpicCache( |
| 483 | view, |
| 484 | shouldLoad ? cloud : nullptr, |
| 485 | shouldLoad ? nullptr : ensureEmptyUserpic().get(), |
| 486 | size * ratio, |
| 487 | context.shape); |
| 488 | p.drawImage(QRect(context.position, QSize(size, size)), view.cached); |
| 489 | } |
| 490 | |
| 491 | void PeerData::loadUserpic() { |
| 492 | _userpic.load(&session(), userpicOrigin()); |
no test coverage detected