diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index f3d672532..b61491ef6 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -249,12 +249,22 @@ 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); + switch(event->button()) { + case Qt::RightButton :{ + UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt()); + userContextMenu->showContextMenu(event->globalPos(), userName, userLevel); + break; + } + case Qt::LeftButton :{ + emit addMentionTag("@" + userName); + break; + } + default: + break; + } } 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_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); diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 981ee3d45..5b134b1d2 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -45,6 +45,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); @@ -239,6 +240,11 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event) emit userEvent(false); } +void TabRoom::addMentionTag(QString mentionTag) { + sayEdit->insert(mentionTag + " "); + sayEdit->setFocus(); +} + 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 b43d35595..e27384a37 100644 --- a/cockatrice/src/tab_room.h +++ b/cockatrice/src/tab_room.h @@ -58,6 +58,7 @@ private slots: void actClearChat(); void actOpenChatSettings(); void ignoreUnregisteredUsersChanged(); + void addMentionTag(QString mentionTag); void processListGamesEvent(const Event_ListGames &event); void processJoinRoomEvent(const Event_JoinRoom &event);