mirror-chatterino2/src/widgets/accountpopup.hpp

85 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include "basewindow.hpp"
#include "twitch/twitchchannel.hpp"
#include "util/concurrentmap.hpp"
2017-04-12 17:46:44 +02:00
#include <QPushButton>
2017-04-12 17:46:44 +02:00
#include <QWidget>
#include <memory>
2017-04-14 17:52:22 +02:00
namespace Ui {
2017-04-19 15:24:19 +02:00
class AccountPopup;
2017-04-12 17:46:44 +02:00
}
2017-04-14 17:52:22 +02:00
namespace chatterino {
2017-04-12 17:46:44 +02:00
class Channel;
2017-04-14 17:52:22 +02:00
namespace widgets {
2017-04-12 17:46:44 +02:00
class AccountPopupWidget : public BaseWindow
2017-04-12 17:46:44 +02:00
{
Q_OBJECT
public:
AccountPopupWidget(ChannelPtr _channel);
2017-04-12 17:46:44 +02:00
void setName(const QString &name);
void setChannel(ChannelPtr _channel);
2017-04-12 17:46:44 +02:00
public slots:
void actuallyRefreshButtons();
signals:
void refreshButtons();
protected:
virtual void dpiMultiplierChanged(float oldDpi, float newDpi) override;
2017-04-12 17:46:44 +02:00
private:
Ui::AccountPopup *ui;
2017-04-12 17:46:44 +02:00
void getUserId();
void getUserData();
void loadAvatar(const QUrl &avatarUrl);
void updateButtons(QWidget *layout, bool state);
void timeout(QPushButton *button, int time);
void sendCommand(QPushButton *button, QString command);
void refreshLayouts();
enum class UserType { User, Mod, Owner };
ChannelPtr channel;
QPixmap avatar;
2017-12-31 22:58:35 +01:00
util::ConcurrentMap<QString, QPixmap> avatarMap;
struct User {
QString username;
QString userID;
UserType userType = UserType::User;
void refreshUserType(const ChannelPtr &channel, bool loggedInUser);
};
User loggedInUser;
User popupWidgetUser;
struct {
bool following = false;
bool ignoring = false;
} relationship;
protected:
virtual void focusOutEvent(QFocusEvent *event) override;
virtual void showEvent(QShowEvent *event) override;
2017-04-12 17:46:44 +02:00
};
2017-04-14 17:52:22 +02:00
} // namespace widgets
} // namespace chatterino