Chatterino
UserInfoPopup.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <pajlada/signals/scoped-connection.hpp>
7 #include <pajlada/signals/signal.hpp>
8 
9 #include <chrono>
10 
11 class QCheckBox;
12 
13 namespace chatterino {
14 
15 class Channel;
16 using ChannelPtr = std::shared_ptr<Channel>;
17 class Label;
18 
19 class UserInfoPopup final : public DraggablePopup
20 {
21  Q_OBJECT
22 
23 public:
24  UserInfoPopup(bool closeAutomatically, QWidget *parent,
25  Split *split = nullptr);
26 
27  void setData(const QString &name, const ChannelPtr &channel);
28  void setData(const QString &name, const ChannelPtr &contextChannel,
29  const ChannelPtr &openingChannel);
30 
31 protected:
32  virtual void themeChangedEvent() override;
33  virtual void scaleChangedEvent(float scale) override;
34 
35 private:
36  void installEvents();
37  void updateUserData();
38  void updateLatestMessages();
39  void updateFocusLoss();
40 
41  void loadAvatar(const QUrl &url);
42  bool isMod_;
43  bool isBroadcaster_;
44 
45  Split *split_;
46 
47  QString userName_;
48  QString userId_;
49  QString avatarUrl_;
50 
51  // The channel the popup was opened from (e.g. /mentions or #forsen). Can be a special channel.
52  ChannelPtr channel_;
53 
54  // The channel the messages are rendered from (e.g. #forsen). Can be a special channel, but will try to not be where possible.
55  ChannelPtr underlyingChannel_;
56 
57  pajlada::Signals::NoArgSignal userStateChanged_;
58 
59  std::unique_ptr<pajlada::Signals::ScopedConnection> refreshConnection_;
60 
61  // If we should close the dialog automatically if the user clicks out
62  // Initially set based on the "Automatically close usercard when it loses focus" setting
63  // If that setting is enabled, this can be toggled on and off using the pin in the top-right corner
64  bool closeAutomatically_;
65 
66  struct {
67  Button *avatarButton = nullptr;
69 
70  Label *nameLabel = nullptr;
73  Label *createdDateLabel = nullptr;
74  Label *userIDLabel = nullptr;
75  // Can be uninitialized if usercard is not configured to close on focus loss
76  Button *pinButton = nullptr;
77  Label *followageLabel = nullptr;
78  Label *subageLabel = nullptr;
79 
80  QCheckBox *block = nullptr;
81  QCheckBox *ignoreHighlights = nullptr;
82 
83  Label *noMessagesLabel = nullptr;
85  } ui_;
86 
87  class TimeoutWidget : public BaseWidget
88  {
89  public:
90  enum Action { Ban, Unban, Timeout };
91 
92  TimeoutWidget();
93 
94  pajlada::Signals::Signal<std::pair<Action, int>> buttonClicked;
95 
96  protected:
97  void paintEvent(QPaintEvent *event) override;
98  };
99 };
100 
101 } // namespace chatterino
Definition: Label.hpp:10
Definition: UserInfoPopup.hpp:19
UserInfoPopup(bool closeAutomatically, QWidget *parent, Split *split=nullptr)
Definition: UserInfoPopup.cpp:133
Label * followageLabel
Definition: UserInfoPopup.hpp:77
Label * localizedNameLabel
Definition: UserInfoPopup.hpp:71
Button * avatarButton
Definition: UserInfoPopup.hpp:67
ChannelView * latestMessages
Definition: UserInfoPopup.hpp:84
Label * noMessagesLabel
Definition: UserInfoPopup.hpp:83
Button * localizedNameCopyButton
Definition: UserInfoPopup.hpp:68
virtual void themeChangedEvent() override
Definition: UserInfoPopup.cpp:530
Definition: Application.cpp:48
Label * createdDateLabel
Definition: UserInfoPopup.hpp:73
virtual float scale() const override
Definition: BaseWindow.cpp:121
Label * userIDLabel
Definition: UserInfoPopup.hpp:74
Definition: Split.hpp:36
Label * followerCountLabel
Definition: UserInfoPopup.hpp:72
void setData(const QString &name, const ChannelPtr &channel)
Definition: UserInfoPopup.cpp:663
Definition: Button.hpp:16
Definition: DraggablePopup.hpp:12
QCheckBox * ignoreHighlights
Definition: UserInfoPopup.hpp:81
virtual void scaleChangedEvent(float scale) override
Definition: UserInfoPopup.cpp:540
Definition: ChannelView.hpp:61
Button * pinButton
Definition: UserInfoPopup.hpp:76
QString name
Definition: Credentials.cpp:94
std::shared_ptr< Channel > ChannelPtr
Definition: Channel.hpp:125
Label * subageLabel
Definition: UserInfoPopup.hpp:78
Definition: BaseWidget.hpp:14
QCheckBox * block
Definition: UserInfoPopup.hpp:80
virtual void paintEvent(QPaintEvent *) override
Definition: BaseWindow.cpp:691
Label * nameLabel
Definition: UserInfoPopup.hpp:70
virtual bool event(QEvent *event) override
Definition: BaseWindow.cpp:333