mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-14 19:18:55 -07:00
[Room] Additionally show a tab for friends and ignored users instead of just all online users.
Took 21 minutes Took 12 minutes
This commit is contained in:
parent
6be9cec6e2
commit
bdb0f12f66
5 changed files with 33 additions and 10 deletions
|
|
@ -42,6 +42,7 @@ void UserListManager::handleDisconnect()
|
|||
|
||||
delete ownUserInfo;
|
||||
ownUserInfo = nullptr;
|
||||
emit listsChanged();
|
||||
}
|
||||
|
||||
void UserListManager::setOwnUserInfo(const ServerInfo_User &userInfo)
|
||||
|
|
@ -66,6 +67,7 @@ void UserListManager::processListUsersResponse(const Response &response)
|
|||
const QString &userName = QString::fromStdString(info.name());
|
||||
onlineUsers.insert(userName, info);
|
||||
}
|
||||
emit listsChanged();
|
||||
}
|
||||
|
||||
void UserListManager::processUserJoinedEvent(const Event_UserJoined &event)
|
||||
|
|
@ -73,12 +75,14 @@ void UserListManager::processUserJoinedEvent(const Event_UserJoined &event)
|
|||
const auto &info = event.user_info();
|
||||
const QString &userName = QString::fromStdString(info.name());
|
||||
onlineUsers.insert(userName, info);
|
||||
emit listsChanged();
|
||||
}
|
||||
|
||||
void UserListManager::processUserLeftEvent(const Event_UserLeft &event)
|
||||
{
|
||||
const auto &userName = QString::fromStdString(event.name());
|
||||
onlineUsers.remove(userName);
|
||||
emit listsChanged();
|
||||
}
|
||||
|
||||
void UserListManager::buddyListReceived(const QList<ServerInfo_User> &_buddyList)
|
||||
|
|
@ -86,6 +90,7 @@ void UserListManager::buddyListReceived(const QList<ServerInfo_User> &_buddyList
|
|||
for (const auto &user : _buddyList) {
|
||||
const auto &userName = QString::fromStdString(user.name());
|
||||
buddyUsers.insert(userName, user);
|
||||
emit listsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +99,7 @@ void UserListManager::ignoreListReceived(const QList<ServerInfo_User> &_ignoreLi
|
|||
for (const auto &user : _ignoreList) {
|
||||
const auto &userName = QString::fromStdString(user.name());
|
||||
ignoredUsers.insert(userName, user);
|
||||
emit listsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,6 +120,7 @@ void UserListManager::processAddToListEvent(const Event_AddToList &event)
|
|||
}
|
||||
|
||||
userMap->insert(userName, user);
|
||||
emit listsChanged();
|
||||
}
|
||||
|
||||
void UserListManager::processRemoveFromListEvent(const Event_RemoveFromList &event)
|
||||
|
|
@ -131,6 +138,7 @@ void UserListManager::processRemoveFromListEvent(const Event_RemoveFromList &eve
|
|||
}
|
||||
|
||||
userMap->remove(userName);
|
||||
emit listsChanged();
|
||||
}
|
||||
|
||||
bool UserListManager::isOwnUserRegistered() const
|
||||
|
|
|
|||
|
|
@ -47,15 +47,17 @@ public:
|
|||
explicit UserListManager(AbstractClient *_client, QObject *parent = nullptr);
|
||||
~UserListManager() override;
|
||||
|
||||
[[nodiscard]] QMap<QString, ServerInfo_User> getAllUsersList() const
|
||||
[[nodiscard]] const QMap<QString, ServerInfo_User> &getAllUsersList() const
|
||||
{
|
||||
return onlineUsers;
|
||||
}
|
||||
[[nodiscard]] QMap<QString, ServerInfo_User> getBuddyList() const
|
||||
|
||||
[[nodiscard]] const QMap<QString, ServerInfo_User> &getBuddyList() const
|
||||
{
|
||||
return buddyUsers;
|
||||
}
|
||||
[[nodiscard]] QMap<QString, ServerInfo_User> getIgnoreList() const
|
||||
|
||||
[[nodiscard]] const QMap<QString, ServerInfo_User> &getIgnoreList() const
|
||||
{
|
||||
return ignoredUsers;
|
||||
}
|
||||
|
|
@ -73,6 +75,7 @@ public slots:
|
|||
signals:
|
||||
void userLeft(const QString &userName);
|
||||
void userJoined(const ServerInfo_User &userInfo);
|
||||
void listsChanged();
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_USER_LIST_MANAGER_H
|
||||
|
|
|
|||
|
|
@ -49,10 +49,25 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
|||
QMap<int, GameTypeMap> tempMap;
|
||||
tempMap.insert(info.room_id(), gameTypes);
|
||||
gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap, true, true);
|
||||
|
||||
auto *tabs = new QTabWidget(this);
|
||||
|
||||
friendsList = new UserListWidget(tabSupervisor, client, UserListWidget::BuddyList);
|
||||
friendsList->bind(tabSupervisor->getUserListManager());
|
||||
userList = new UserListWidget(tabSupervisor, client, UserListWidget::RoomList);
|
||||
userList->bind(tabSupervisor->getUserListManager());
|
||||
ignoreList = new UserListWidget(tabSupervisor, client, UserListWidget::IgnoreList);
|
||||
ignoreList->bind(tabSupervisor->getUserListManager());
|
||||
|
||||
connect(friendsList, SIGNAL(openMessageDialog(const QString &, bool)), this,
|
||||
SIGNAL(openMessageDialog(const QString &, bool)));
|
||||
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this,
|
||||
SIGNAL(openMessageDialog(const QString &, bool)));
|
||||
|
||||
tabs->addTab(friendsList, tr("Friends"));
|
||||
tabs->addTab(userList, tr("Online"));
|
||||
tabs->addTab(ignoreList, tr("Ignored"));
|
||||
|
||||
chatView = new ChatView(tabSupervisor, nullptr, true, this);
|
||||
connect(chatView, &ChatView::showMentionPopup, this, &TabRoom::actShowMentionPopup);
|
||||
connect(chatView, &ChatView::messageClickedSignal, this, &TabRoom::focusTab);
|
||||
|
|
@ -101,7 +116,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
|||
|
||||
auto *hbox = new QHBoxLayout;
|
||||
hbox->addWidget(splitter, 3);
|
||||
hbox->addWidget(userList, 1);
|
||||
hbox->addWidget(tabs, 1);
|
||||
|
||||
aLeaveRoom = new QAction(this);
|
||||
connect(aLeaveRoom, &QAction::triggered, this, &TabRoom::closeRequest);
|
||||
|
|
@ -112,10 +127,8 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
|||
|
||||
const int userListSize = info.user_list_size();
|
||||
for (int i = 0; i < userListSize; ++i) {
|
||||
userList->processUserInfo(info.user_list(i), true);
|
||||
autocompleteUserList.append("@" + QString::fromStdString(info.user_list(i).name()));
|
||||
}
|
||||
userList->sortItems();
|
||||
|
||||
const int gameListSize = info.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i) {
|
||||
|
|
@ -269,8 +282,6 @@ void TabRoom::processListGamesEvent(const Event_ListGames &event)
|
|||
|
||||
void TabRoom::processJoinRoomEvent(const Event_JoinRoom &event)
|
||||
{
|
||||
userList->processUserInfo(event.user_info(), true);
|
||||
userList->sortItems();
|
||||
if (!autocompleteUserList.contains("@" + QString::fromStdString(event.user_info().name()))) {
|
||||
autocompleteUserList << "@" + QString::fromStdString(event.user_info().name());
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
|
|
@ -279,7 +290,6 @@ void TabRoom::processJoinRoomEvent(const Event_JoinRoom &event)
|
|||
|
||||
void TabRoom::processLeaveRoomEvent(const Event_LeaveRoom &event)
|
||||
{
|
||||
userList->deleteUser(QString::fromStdString(event.name()));
|
||||
autocompleteUserList.removeOne("@" + QString::fromStdString(event.name()));
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ private:
|
|||
QMap<int, QString> gameTypes;
|
||||
|
||||
GameSelector *gameSelector;
|
||||
UserListWidget *friendsList;
|
||||
UserListWidget *userList;
|
||||
UserListWidget *ignoreList;
|
||||
const UserListProxy *userListProxy;
|
||||
ChatView *chatView;
|
||||
QLabel *sayLabel;
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public:
|
|||
return userInfo;
|
||||
}
|
||||
[[nodiscard]] AbstractClient *getClient() const;
|
||||
[[nodiscard]] const UserListManager *getUserListManager() const
|
||||
[[nodiscard]] UserListManager *getUserListManager() const
|
||||
{
|
||||
return userListManager;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue