mirror-chatterino2/src/widgets/dialogs/UserInfoPopup.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
2.6 KiB
C++
Raw Normal View History

2018-06-06 13:35:06 +02:00
#pragma once
#include "widgets/DraggablePopup.hpp"
#include <pajlada/signals/scoped-connection.hpp>
2018-06-06 13:35:06 +02:00
#include <pajlada/signals/signal.hpp>
#include <chrono>
2018-06-06 13:35:06 +02:00
class QCheckBox;
2018-06-06 13:35:06 +02:00
namespace chatterino {
class Channel;
using ChannelPtr = std::shared_ptr<Channel>;
2018-06-11 21:57:17 +02:00
class Label;
class ChannelView;
class Split;
class UserInfoPopup final : public DraggablePopup
2018-06-06 13:35:06 +02:00
{
Q_OBJECT
2018-06-06 13:35:06 +02:00
public:
UserInfoPopup(bool closeAutomatically, QWidget *parent,
Split *split = nullptr);
2018-06-06 13:35:06 +02:00
void setData(const QString &name, const ChannelPtr &channel);
void setData(const QString &name, const ChannelPtr &contextChannel,
const ChannelPtr &openingChannel);
2018-06-07 17:43:21 +02:00
protected:
void themeChangedEvent() override;
void scaleChangedEvent(float scale) override;
2018-06-06 13:35:06 +02:00
private:
2018-07-06 19:23:47 +02:00
void installEvents();
void updateUserData();
void updateLatestMessages();
2018-07-06 19:23:47 +02:00
void loadAvatar(const QUrl &url);
bool isMod_{};
bool isBroadcaster_{};
Split *split_;
2018-06-06 13:35:06 +02:00
QString userName_;
QString userId_;
QString avatarUrl_;
// The channel the popup was opened from (e.g. /mentions or #forsen). Can be a special channel.
2018-06-06 13:35:06 +02:00
ChannelPtr channel_;
// The channel the messages are rendered from (e.g. #forsen). Can be a special channel, but will try to not be where possible.
ChannelPtr underlyingChannel_;
2018-07-06 19:23:47 +02:00
pajlada::Signals::NoArgSignal userStateChanged_;
std::unique_ptr<pajlada::Signals::ScopedConnection> refreshConnection_;
// If we should close the dialog automatically if the user clicks out
// Set based on the "Automatically close usercard when it loses focus" setting
// Pinned status is tracked in DraggablePopup::isPinned_.
const bool closeAutomatically_;
2018-06-06 13:35:06 +02:00
struct {
2018-08-08 15:35:54 +02:00
Button *avatarButton = nullptr;
Button *localizedNameCopyButton = nullptr;
2018-06-11 21:57:17 +02:00
Label *nameLabel = nullptr;
Label *localizedNameLabel = nullptr;
2018-06-11 21:57:17 +02:00
Label *followerCountLabel = nullptr;
Label *createdDateLabel = nullptr;
Label *userIDLabel = nullptr;
Label *followageLabel = nullptr;
Label *subageLabel = nullptr;
QCheckBox *block = nullptr;
2018-06-06 13:35:06 +02:00
QCheckBox *ignoreHighlights = nullptr;
Label *noMessagesLabel = nullptr;
ChannelView *latestMessages = nullptr;
2018-06-06 13:35:06 +02:00
} ui_;
2018-06-06 13:35:06 +02:00
class TimeoutWidget : public BaseWidget
{
public:
enum Action { Ban, Unban, Timeout };
2018-06-06 13:35:06 +02:00
TimeoutWidget();
pajlada::Signals::Signal<std::pair<Action, int>> buttonClicked;
2018-06-06 13:35:06 +02:00
protected:
void paintEvent(QPaintEvent *event) override;
};
};
2018-06-06 13:35:06 +02:00
} // namespace chatterino