From 45112e49b127cc009db536d975a6ed74a4b3c41c Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 14:47:16 +0100 Subject: [PATCH 1/4] Click tag mentions You can now click on a username in the main chat to add a "@username" tag to the chat. Makes communication with other users using tags faster. --- cockatrice/src/chatview.cpp | 11 +++++++---- cockatrice/src/chatview.h | 1 + cockatrice/src/tab_room.cpp | 5 +++++ cockatrice/src/tab_room.h | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index f3d672532..659d5c127 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -249,12 +249,15 @@ void ChatView::mousePressEvent(QMouseEvent *event) break; } case HoveredUser: { - if (event->button() == Qt::RightButton) { + if (event->button() != Qt::MidButton) { const int delimiterIndex = hoveredContent.indexOf("_"); - UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt()); const QString userName = hoveredContent.mid(delimiterIndex + 1); - - userContextMenu->showContextMenu(event->globalPos(), userName, userLevel); + if (event->button() == Qt::RightButton) { + UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt()); + userContextMenu->showContextMenu(event->globalPos(), userName, userLevel); + } + else if (event->button() == Qt::LeftButton) + emit addMentionTag("@" + userName); } break; } diff --git a/cockatrice/src/chatview.h b/cockatrice/src/chatview.h index 678492622..4f06cb5e9 100644 --- a/cockatrice/src/chatview.h +++ b/cockatrice/src/chatview.h @@ -49,6 +49,7 @@ signals: void cardNameHovered(QString cardName); void showCardInfoPopup(QPoint pos, QString cardName); void deleteCardInfoPopup(QString cardName); + void addMentionTag(QString mentionTag); }; #endif diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index fa307e7d8..18e196a6c 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -44,6 +44,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool))); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); + connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString))); sayLabel = new QLabel; sayEdit = new QLineEdit; sayLabel->setBuddy(sayEdit); @@ -225,6 +226,10 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event) emit userEvent(false); } +void TabRoom::addMentionTag(QString mentionTag) { + sayEdit->insert(mentionTag + " "); +} + PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &cmd) { return client->prepareRoomCommand(cmd, roomId); diff --git a/cockatrice/src/tab_room.h b/cockatrice/src/tab_room.h index 600513a25..6826cc114 100644 --- a/cockatrice/src/tab_room.h +++ b/cockatrice/src/tab_room.h @@ -56,6 +56,7 @@ private slots: void actIgnoreUnregisteredUsers(); void actClearChat(); void ignoreUnregisteredUsersChanged(); + void addMentionTag(QString mentionTag); void processListGamesEvent(const Event_ListGames &event); void processJoinRoomEvent(const Event_JoinRoom &event); From 8bc2adb70be924f08ba807e0b4f2d7b5b18d507c Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sat, 17 Jan 2015 14:53:41 +0100 Subject: [PATCH 2/4] Set focus The line edit now gets focus for faster typing. --- cockatrice/src/tab_room.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 18e196a6c..e27d2b92e 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -228,6 +228,7 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event) void TabRoom::addMentionTag(QString mentionTag) { sayEdit->insert(mentionTag + " "); + sayEdit->setFocus(); } PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &cmd) From 041e91412dc520b2efaab528effdfe79865fe661 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Mon, 19 Jan 2015 08:33:28 +0100 Subject: [PATCH 3/4] Switch Statement --- cockatrice/src/chatview.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index 659d5c127..b61491ef6 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -252,12 +252,19 @@ void ChatView::mousePressEvent(QMouseEvent *event) if (event->button() != Qt::MidButton) { const int delimiterIndex = hoveredContent.indexOf("_"); const QString userName = hoveredContent.mid(delimiterIndex + 1); - if (event->button() == Qt::RightButton) { + switch(event->button()) { + case Qt::RightButton :{ UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt()); userContextMenu->showContextMenu(event->globalPos(), userName, userLevel); - } - else if (event->button() == Qt::LeftButton) + break; + } + case Qt::LeftButton :{ emit addMentionTag("@" + userName); + break; + } + default: + break; + } } break; } From 222105be610bf27a9eba5979a0b809439eff515b Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Mon, 19 Jan 2015 21:29:15 +0100 Subject: [PATCH 4/4] Added functionality in game --- cockatrice/src/tab_game.cpp | 6 ++++++ cockatrice/src/tab_game.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 4144409c3..aefcf02e9 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -418,6 +418,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList &_client connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString))); connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); + connect(messageLog, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString))); sayLabel = new QLabel; sayEdit = new QLineEdit; sayLabel->setBuddy(sayEdit); @@ -507,6 +508,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList &_client messageLog->logGameJoined(gameInfo.game_id()); } +void TabGame::addMentionTag(QString value) { + sayEdit->insert(value + " "); + sayEdit->setFocus(); +} + TabGame::~TabGame() { delete replay; diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index 50f77e1a1..0725f373a 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -195,6 +195,8 @@ private slots: void actPhaseAction(); void actNextPhase(); void actNextTurn(); + + void addMentionTag(QString value); public: TabGame(TabSupervisor *_tabSupervisor, QList &_clients, const Event_GameJoined &event, const QMap &_roomGameTypes); TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);