2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-12-16 02:22:35 +01:00
|
|
|
|
2018-01-14 21:55:36 +01:00
|
|
|
#include "basewindow.hpp"
|
2018-02-05 15:11:50 +01:00
|
|
|
#include "providers/twitch/twitchchannel.hpp"
|
2018-01-04 02:19:35 +01:00
|
|
|
#include "util/concurrentmap.hpp"
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-09-23 19:23:10 +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;
|
2018-04-03 02:55:32 +02:00
|
|
|
} // namespace Ui
|
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
|
|
|
|
2018-01-14 21:55:36 +01:00
|
|
|
class AccountPopupWidget : public BaseWindow
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-01-24 13:15:41 +01:00
|
|
|
AccountPopupWidget(ChannelPtr _channel);
|
2017-04-12 17:46:44 +02:00
|
|
|
|
|
|
|
void setName(const QString &name);
|
2018-01-24 13:15:41 +01:00
|
|
|
void setChannel(ChannelPtr _channel);
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-01-18 18:20:40 +01:00
|
|
|
public slots:
|
|
|
|
void actuallyRefreshButtons();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void refreshButtons();
|
2017-09-23 19:23:10 +02:00
|
|
|
|
2017-12-18 01:17:02 +01:00
|
|
|
protected:
|
2018-04-03 02:55:32 +02:00
|
|
|
void scaleChangedEvent(float newDpi) override;
|
2017-12-18 01:17:02 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
private:
|
2017-12-19 01:25:57 +01:00
|
|
|
Ui::AccountPopup *ui;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-07-31 22:14:54 +02:00
|
|
|
void getUserId();
|
|
|
|
void getUserData();
|
|
|
|
void loadAvatar(const QUrl &avatarUrl);
|
|
|
|
|
2017-12-16 02:22:35 +01:00
|
|
|
void updateButtons(QWidget *layout, bool state);
|
|
|
|
void timeout(QPushButton *button, int time);
|
|
|
|
void sendCommand(QPushButton *button, QString command);
|
2017-09-23 19:23:10 +02:00
|
|
|
|
2018-01-18 18:20:40 +01:00
|
|
|
void refreshLayouts();
|
|
|
|
|
|
|
|
enum class UserType { User, Mod, Owner };
|
2017-09-23 19:23:10 +02:00
|
|
|
|
2018-01-24 13:15:41 +01:00
|
|
|
ChannelPtr channel;
|
2017-07-31 22:14:54 +02:00
|
|
|
|
|
|
|
QPixmap avatar;
|
|
|
|
|
2017-12-31 22:58:35 +01:00
|
|
|
util::ConcurrentMap<QString, QPixmap> avatarMap;
|
2017-07-31 22:14:54 +02:00
|
|
|
|
2018-01-18 18:20:40 +01:00
|
|
|
struct User {
|
|
|
|
QString username;
|
|
|
|
QString userID;
|
|
|
|
UserType userType = UserType::User;
|
|
|
|
|
2018-01-24 13:15:41 +01:00
|
|
|
void refreshUserType(const ChannelPtr &channel, bool loggedInUser);
|
2018-01-18 18:20:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
User loggedInUser;
|
|
|
|
|
|
|
|
User popupWidgetUser;
|
|
|
|
|
|
|
|
struct {
|
2018-05-13 17:53:24 +02:00
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
this->following = -1;
|
|
|
|
this->ignoring = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isFollowing() const
|
|
|
|
{
|
|
|
|
return this->following == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isFollowingSet() const
|
|
|
|
{
|
|
|
|
return this->following != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFollowing(bool newVal)
|
|
|
|
{
|
|
|
|
if (newVal) {
|
|
|
|
this->following = 1;
|
|
|
|
} else {
|
|
|
|
this->following = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isIgnoring() const
|
|
|
|
{
|
|
|
|
return this->ignoring == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isIgnoringSet() const
|
|
|
|
{
|
|
|
|
return this->ignoring != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIgnoring(bool newVal)
|
|
|
|
{
|
|
|
|
if (newVal) {
|
|
|
|
this->ignoring = 1;
|
|
|
|
} else {
|
|
|
|
this->ignoring = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int following = -1;
|
|
|
|
int ignoring = -1;
|
2018-01-18 18:20:40 +01:00
|
|
|
} relationship;
|
|
|
|
|
2017-07-31 22:14:54 +02:00
|
|
|
protected:
|
2018-04-03 02:55:32 +02:00
|
|
|
void focusOutEvent(QFocusEvent *event) override;
|
|
|
|
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
|