2019-09-08 22:27:57 +02:00
# pragma once
# include "widgets/BaseWindow.hpp"
2020-06-21 14:15:14 +02:00
# include "widgets/helper/ChannelView.hpp"
2019-09-08 22:27:57 +02:00
2021-12-19 15:57:56 +01:00
# include <pajlada/signals/scoped-connection.hpp>
2019-09-08 22:27:57 +02:00
# include <pajlada/signals/signal.hpp>
2022-01-16 12:31:48 +01:00
# include <chrono>
2019-09-08 22:27:57 +02:00
class QCheckBox ;
namespace chatterino {
class Channel ;
using ChannelPtr = std : : shared_ptr < Channel > ;
class Label ;
class UserInfoPopup final : public BaseWindow
{
Q_OBJECT
public :
2020-10-31 16:42:48 +01:00
UserInfoPopup ( bool closeAutomatically , QWidget * parent ) ;
2019-09-08 22:27:57 +02:00
void setData ( const QString & name , const ChannelPtr & channel ) ;
2022-04-09 13:27:21 +02:00
void setData ( const QString & name , const ChannelPtr & contextChannel ,
const ChannelPtr & openingChannel ) ;
2019-09-08 22:27:57 +02:00
protected :
virtual void themeChangedEvent ( ) override ;
virtual void scaleChangedEvent ( float scale ) override ;
2022-01-16 12:31:48 +01:00
void mousePressEvent ( QMouseEvent * event ) override ;
void mouseReleaseEvent ( QMouseEvent * event ) override ;
void mouseMoveEvent ( QMouseEvent * event ) override ;
2019-09-08 22:27:57 +02:00
private :
void installEvents ( ) ;
void updateUserData ( ) ;
2020-06-21 14:15:14 +02:00
void updateLatestMessages ( ) ;
2019-09-08 22:27:57 +02:00
void loadAvatar ( const QUrl & url ) ;
bool isMod_ ;
bool isBroadcaster_ ;
QString userName_ ;
QString userId_ ;
2021-03-14 15:09:16 +01:00
QString avatarUrl_ ;
2022-04-09 13:27:21 +02:00
// The channel the popup was opened from (e.g. /mentions or #forsen). Can be a special channel.
2019-09-08 22:27:57 +02:00
ChannelPtr channel_ ;
2022-04-09 13:27:21 +02:00
// 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_ ;
2019-09-08 22:27:57 +02:00
2022-01-16 12:31:48 +01:00
// isMoving_ is set to true if the user is holding the left mouse button down and has moved the mouse a small amount away from the original click point (startPosDrag_)
bool isMoving_ = false ;
// startPosDrag_ is the coordinates where the user originally pressed the mouse button down to start dragging
QPoint startPosDrag_ ;
// requestDragPos_ is the final screen coordinates where the widget should be moved to.
// Takes the relative position of where the user originally clicked the widget into account
QPoint requestedDragPos_ ;
// dragTimer_ is called ~60 times per second once the user has initiated dragging
QTimer dragTimer_ ;
2019-09-08 22:27:57 +02:00
pajlada : : Signals : : NoArgSignal userStateChanged_ ;
2021-12-19 15:57:56 +01:00
std : : unique_ptr < pajlada : : Signals : : ScopedConnection > refreshConnection_ ;
2020-09-26 16:59:40 +02:00
2019-09-08 22:27:57 +02:00
std : : shared_ptr < bool > hack_ ;
struct {
Button * avatarButton = nullptr ;
2021-11-06 13:44:27 +01:00
Button * localizedNameCopyButton = nullptr ;
2019-09-08 22:27:57 +02:00
Label * nameLabel = nullptr ;
2021-11-06 13:44:27 +01:00
Label * localizedNameLabel = nullptr ;
2019-09-08 22:27:57 +02:00
Label * followerCountLabel = nullptr ;
Label * createdDateLabel = nullptr ;
Label * userIDLabel = nullptr ;
2020-10-21 17:02:24 +02:00
Label * followageLabel = nullptr ;
Label * subageLabel = nullptr ;
2019-09-08 22:27:57 +02:00
2021-02-14 14:01:13 +01:00
QCheckBox * block = nullptr ;
2019-09-08 22:27:57 +02:00
QCheckBox * ignoreHighlights = nullptr ;
2020-06-21 14:15:14 +02:00
Label * noMessagesLabel = nullptr ;
ChannelView * latestMessages = nullptr ;
2019-09-08 22:27:57 +02:00
} ui_ ;
class TimeoutWidget : public BaseWidget
{
public :
enum Action { Ban , Unban , Timeout } ;
TimeoutWidget ( ) ;
pajlada : : Signals : : Signal < std : : pair < Action , int > > buttonClicked ;
protected :
void paintEvent ( QPaintEvent * event ) override ;
} ;
} ;
} // namespace chatterino