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