mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
Rename method, address comments.
Took 5 minutes
This commit is contained in:
parent
de2b948533
commit
80a972f90e
4 changed files with 17 additions and 24 deletions
|
|
@ -123,13 +123,9 @@ void TabMessage::sendMessage()
|
||||||
sayEdit->clear();
|
sayEdit->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabMessage::sendInviteMessage(const QString &text)
|
bool TabMessage::isUserOnline() const
|
||||||
{
|
{
|
||||||
if (!userOnline) {
|
return userOnline;
|
||||||
notifyUserOffline();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendPrivateMessage(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabMessage::messageSent(const Response &response,
|
void TabMessage::messageSent(const Response &response,
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,10 @@ public:
|
||||||
void processUserLeft();
|
void processUserLeft();
|
||||||
void processUserJoined(const ServerInfo_User &_userInfo);
|
void processUserJoined(const ServerInfo_User &_userInfo);
|
||||||
|
|
||||||
void sendInviteMessage(const QString &text);
|
[[nodiscard]] bool isUserOnline() const;
|
||||||
|
void sendPrivateMessage(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendPrivateMessage(const QString &text);
|
|
||||||
bool shouldShowSystemPopup(const Event_UserMessage &event);
|
bool shouldShowSystemPopup(const Event_UserMessage &event);
|
||||||
void showSystemPopup(const Event_UserMessage &event);
|
void showSystemPopup(const Event_UserMessage &event);
|
||||||
void notifyUserOffline();
|
void notifyUserOffline();
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
|
||||||
userList = userListPanel->getUserList();
|
userList = userListPanel->getUserList();
|
||||||
connect(userListPanel, &UserListPanelWidget::openMessageDialog, this, &TabRoom::openMessageDialog);
|
connect(userListPanel, &UserListPanelWidget::openMessageDialog, this, &TabRoom::openMessageDialog);
|
||||||
|
|
||||||
const std::function<QList<GameInviteOption>()> gameInviteLinkProvider = [this]() -> QList<GameInviteOption> {
|
const auto gameInviteLinkProvider = [this]() { return tabSupervisor->getGameInviteLinksForRoom(roomId); };
|
||||||
return tabSupervisor->getGameInviteLinksForRoom(roomId);
|
|
||||||
};
|
|
||||||
userList->setGameInviteLinkProvider(gameInviteLinkProvider);
|
userList->setGameInviteLinkProvider(gameInviteLinkProvider);
|
||||||
|
|
||||||
chatView = new ChatView(tabSupervisor, nullptr, true, this);
|
chatView = new ChatView(tabSupervisor, nullptr, true, this);
|
||||||
|
|
|
||||||
|
|
@ -961,9 +961,7 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
|
||||||
// The inviter may be in several games of the same room (hosting one and
|
// The inviter may be in several games of the same room (hosting one and
|
||||||
// spectating another, for example). Return every game so the caller can
|
// spectating another, for example). Return every game so the caller can
|
||||||
// let the user choose which one to invite to.
|
// let the user choose which one to invite to.
|
||||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
for (TabGame *tab : gameTabs) {
|
||||||
while (gameIterator.hasNext()) {
|
|
||||||
TabGame *tab = gameIterator.next().value();
|
|
||||||
GameMetaInfo *metaInfo = tab->getGame()->getGameMetaInfo();
|
GameMetaInfo *metaInfo = tab->getGame()->getGameMetaInfo();
|
||||||
if (metaInfo->proto().room_id() != roomId) {
|
if (metaInfo->proto().room_id() != roomId) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -977,14 +975,15 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
|
||||||
const int gameId = metaInfo->gameId();
|
const int gameId = metaInfo->gameId();
|
||||||
const QString description = QString::fromStdString(metaInfo->proto().description());
|
const QString description = QString::fromStdString(metaInfo->proto().description());
|
||||||
|
|
||||||
GameInviteOption option;
|
GameInviteOption option{
|
||||||
option.gameId = gameId;
|
.gameId = gameId,
|
||||||
option.label =
|
.label =
|
||||||
description.isEmpty() ? tr("Game #%1").arg(gameId) : tr("Game #%1 — %2").arg(gameId).arg(description);
|
description.isEmpty() ? tr("Game #%1").arg(gameId) : tr("Game #%1 — %2").arg(gameId).arg(description),
|
||||||
option.url = makeGameJoinLink(client->serverName(), client->serverPort(), roomId, gameId, description);
|
.url = makeGameJoinLink(client->serverName(), client->serverPort(), roomId, gameId, description),
|
||||||
option.description = description;
|
.description = description,
|
||||||
option.onlyBuddies = metaInfo->proto().only_buddies();
|
.onlyBuddies = metaInfo->proto().only_buddies(),
|
||||||
option.creatorName = QString::fromStdString(metaInfo->proto().creator_info().name());
|
.creatorName = QString::fromStdString(metaInfo->proto().creator_info().name()),
|
||||||
|
};
|
||||||
options.append(option);
|
options.append(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -994,8 +993,8 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
|
||||||
void TabSupervisor::sendInviteToUser(const QString &userName, const QString &inviteText)
|
void TabSupervisor::sendInviteToUser(const QString &userName, const QString &inviteText)
|
||||||
{
|
{
|
||||||
TabMessage *tab = addMessageTab(userName, true);
|
TabMessage *tab = addMessageTab(userName, true);
|
||||||
if (tab) {
|
if (tab && tab->isUserOnline()) {
|
||||||
tab->sendInviteMessage(inviteText);
|
tab->sendPrivateMessage(inviteText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue