2018-01-19 14:42:21 +01:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2018-07-24 09:24:21 +02:00
|
|
|
#include <unordered_set>
|
2018-01-19 14:42:21 +01:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include <QVariant>
|
|
|
|
#include "network/network.h"
|
2018-04-18 18:29:03 +02:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ChatRoom;
|
|
|
|
}
|
2018-01-19 14:42:21 +01:00
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
class AnnounceMultiplayerSession;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ConnectionError;
|
|
|
|
class ComboBoxProxyModel;
|
|
|
|
|
|
|
|
class ChatMessage;
|
|
|
|
|
|
|
|
class ChatRoom : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ChatRoom(QWidget* parent);
|
2018-10-09 17:08:33 +02:00
|
|
|
void RetranslateUi();
|
2018-01-19 14:42:21 +01:00
|
|
|
void SetPlayerList(const Network::RoomMember::MemberList& member_list);
|
|
|
|
void Clear();
|
|
|
|
void AppendStatusMessage(const QString& msg);
|
2018-04-18 18:29:03 +02:00
|
|
|
~ChatRoom();
|
2018-01-19 14:42:21 +01:00
|
|
|
|
2018-11-24 09:26:12 +01:00
|
|
|
void SetModPerms(bool is_mod);
|
2019-01-16 15:01:21 +01:00
|
|
|
void UpdateIconDisplay();
|
2018-11-24 09:26:12 +01:00
|
|
|
|
2018-01-19 14:42:21 +01:00
|
|
|
public slots:
|
|
|
|
void OnRoomUpdate(const Network::RoomInformation& info);
|
|
|
|
void OnChatReceive(const Network::ChatEntry&);
|
2018-11-09 14:55:57 +01:00
|
|
|
void OnStatusMessageReceive(const Network::StatusMessageEntry&);
|
2018-01-19 14:42:21 +01:00
|
|
|
void OnSendChat();
|
|
|
|
void OnChatTextChanged();
|
2018-07-24 09:24:21 +02:00
|
|
|
void PopupContextMenu(const QPoint& menu_location);
|
2018-01-19 14:42:21 +01:00
|
|
|
void Disable();
|
|
|
|
void Enable();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void ChatReceived(const Network::ChatEntry&);
|
2018-11-09 14:55:57 +01:00
|
|
|
void StatusMessageReceived(const Network::StatusMessageEntry&);
|
2018-12-01 02:28:55 +01:00
|
|
|
void UserPinged();
|
2018-01-19 14:42:21 +01:00
|
|
|
|
|
|
|
private:
|
2018-04-09 19:00:56 +02:00
|
|
|
static constexpr u32 max_chat_lines = 1000;
|
2018-01-19 14:42:21 +01:00
|
|
|
void AppendChatMessage(const QString&);
|
|
|
|
bool ValidateMessage(const std::string&);
|
2018-11-24 09:26:12 +01:00
|
|
|
void SendModerationRequest(Network::RoomMessageTypes type, const std::string& nickname);
|
2018-10-27 09:49:00 +02:00
|
|
|
|
2018-11-24 09:26:12 +01:00
|
|
|
bool has_mod_perms = false;
|
2018-01-19 14:42:21 +01:00
|
|
|
QStandardItemModel* player_list;
|
2018-04-18 07:06:02 +02:00
|
|
|
std::unique_ptr<Ui::ChatRoom> ui;
|
2018-07-24 09:24:21 +02:00
|
|
|
std::unordered_set<std::string> block_list;
|
2018-10-27 09:49:00 +02:00
|
|
|
std::unordered_map<std::string, QPixmap> icon_cache;
|
2018-01-19 14:42:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Network::ChatEntry);
|
2018-11-09 14:55:57 +01:00
|
|
|
Q_DECLARE_METATYPE(Network::StatusMessageEntry);
|
2018-01-19 14:42:21 +01:00
|
|
|
Q_DECLARE_METATYPE(Network::RoomInformation);
|
|
|
|
Q_DECLARE_METATYPE(Network::RoomMember::State);
|
2018-11-24 09:26:12 +01:00
|
|
|
Q_DECLARE_METATYPE(Network::RoomMember::Error);
|