1 #pragma once
2 
3 #include "widgets/BaseWindow.hpp"
4 #include "widgets/helper/ChannelView.hpp"
5 
6 #include <pajlada/signals/signal.hpp>
7 
8 class QCheckBox;
9 
10 namespace chatterino {
11 
12 class Channel;
13 using ChannelPtr = std::shared_ptr<Channel>;
14 class Label;
15 
16 class UserInfoPopup final : public BaseWindow
17 {
18     Q_OBJECT
19 
20 public:
21     UserInfoPopup(bool closeAutomatically, QWidget *parent);
22     ~UserInfoPopup();
23 
24     void setData(const QString &name, const ChannelPtr &channel);
25 
26 protected:
27     virtual void themeChangedEvent() override;
28     virtual void scaleChangedEvent(float scale) override;
29 
30 private:
31     void installEvents();
32     void updateUserData();
33     void updateLatestMessages();
34 
35     void loadAvatar(const QUrl &url);
36     bool isMod_;
37     bool isBroadcaster_;
38 
39     QString userName_;
40     QString userId_;
41     QString avatarUrl_;
42     ChannelPtr channel_;
43 
44     pajlada::Signals::NoArgSignal userStateChanged_;
45 
46     // replace with ScopedConnection once https://github.com/pajlada/signals/pull/10 gets merged
47     pajlada::Signals::Connection refreshConnection_;
48 
49     std::shared_ptr<bool> hack_;
50 
51     struct {
52         Button *avatarButton = nullptr;
53 
54         Label *nameLabel = nullptr;
55         Label *viewCountLabel = nullptr;
56         Label *followerCountLabel = nullptr;
57         Label *createdDateLabel = nullptr;
58         Label *userIDLabel = nullptr;
59         Label *followageLabel = nullptr;
60         Label *subageLabel = nullptr;
61 
62         QCheckBox *block = nullptr;
63         QCheckBox *ignoreHighlights = nullptr;
64 
65         Label *noMessagesLabel = nullptr;
66         ChannelView *latestMessages = nullptr;
67         QPushButton *refreshButton = nullptr;
68     } ui_;
69 
70     class TimeoutWidget : public BaseWidget
71     {
72     public:
73         enum Action { Ban, Unban, Timeout };
74 
75         TimeoutWidget();
76 
77         pajlada::Signals::Signal<std::pair<Action, int>> buttonClicked;
78 
79     protected:
80         void paintEvent(QPaintEvent *event) override;
81     };
82 };
83 
84 }  // namespace chatterino
85