info_profile_icon.cpp 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "info/profile/info_profile_icon.h"
  8. namespace Info {
  9. namespace Profile {
  10. FloatingIcon::FloatingIcon(
  11. RpWidget *parent,
  12. const style::icon &icon,
  13. QPoint position)
  14. : FloatingIcon(parent, icon, position, Tag{}) {
  15. }
  16. FloatingIcon::FloatingIcon(
  17. RpWidget *parent,
  18. const style::icon &icon,
  19. QPoint position,
  20. const Tag &)
  21. : RpWidget(parent)
  22. , _icon(&icon)
  23. , _point(position) {
  24. resize(
  25. _point.x() + _icon->width(),
  26. _point.y() + _icon->height());
  27. setAttribute(Qt::WA_TransparentForMouseEvents);
  28. parent->widthValue(
  29. ) | rpl::start_with_next(
  30. [this] { moveToLeft(0, 0); },
  31. lifetime());
  32. }
  33. void FloatingIcon::paintEvent(QPaintEvent *e) {
  34. auto p = QPainter(this);
  35. _icon->paint(p, _point, width());
  36. }
  37. } // namespace Profile
  38. } // namespace Info