Commit 10aa1374 authored by Gavin Bisesi's avatar Gavin Bisesi
Browse files

Merge pull request #562 from poixen/chat_click_mentions

Click tag mentions
parents fe53d6d6 222105be
...@@ -249,12 +249,22 @@ void ChatView::mousePressEvent(QMouseEvent *event) ...@@ -249,12 +249,22 @@ void ChatView::mousePressEvent(QMouseEvent *event)
break; break;
} }
case HoveredUser: { case HoveredUser: {
if (event->button() == Qt::RightButton) { if (event->button() != Qt::MidButton) {
const int delimiterIndex = hoveredContent.indexOf("_"); const int delimiterIndex = hoveredContent.indexOf("_");
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
const QString userName = hoveredContent.mid(delimiterIndex + 1); const QString userName = hoveredContent.mid(delimiterIndex + 1);
switch(event->button()) {
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel); 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; break;
} }
......
...@@ -49,6 +49,7 @@ signals: ...@@ -49,6 +49,7 @@ signals:
void cardNameHovered(QString cardName); void cardNameHovered(QString cardName);
void showCardInfoPopup(QPoint pos, QString cardName); void showCardInfoPopup(QPoint pos, QString cardName);
void deleteCardInfoPopup(QString cardName); void deleteCardInfoPopup(QString cardName);
void addMentionTag(QString mentionTag);
}; };
#endif #endif
...@@ -418,6 +418,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -418,6 +418,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString))); connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
connect(messageLog, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
sayLabel = new QLabel; sayLabel = new QLabel;
sayEdit = new QLineEdit; sayEdit = new QLineEdit;
sayLabel->setBuddy(sayEdit); sayLabel->setBuddy(sayEdit);
...@@ -507,6 +508,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -507,6 +508,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
messageLog->logGameJoined(gameInfo.game_id()); messageLog->logGameJoined(gameInfo.game_id());
} }
void TabGame::addMentionTag(QString value) {
sayEdit->insert(value + " ");
sayEdit->setFocus();
}
TabGame::~TabGame() TabGame::~TabGame()
{ {
delete replay; delete replay;
......
...@@ -195,6 +195,8 @@ private slots: ...@@ -195,6 +195,8 @@ private slots:
void actPhaseAction(); void actPhaseAction();
void actNextPhase(); void actNextPhase();
void actNextTurn(); void actNextTurn();
void addMentionTag(QString value);
public: public:
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes); TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay); TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
......
...@@ -45,6 +45,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI ...@@ -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(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
sayLabel = new QLabel; sayLabel = new QLabel;
sayEdit = new QLineEdit; sayEdit = new QLineEdit;
sayLabel->setBuddy(sayEdit); sayLabel->setBuddy(sayEdit);
...@@ -239,6 +240,11 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event) ...@@ -239,6 +240,11 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
emit userEvent(false); emit userEvent(false);
} }
void TabRoom::addMentionTag(QString mentionTag) {
sayEdit->insert(mentionTag + " ");
sayEdit->setFocus();
}
PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &cmd) PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &cmd)
{ {
return client->prepareRoomCommand(cmd, roomId); return client->prepareRoomCommand(cmd, roomId);
......
...@@ -58,6 +58,7 @@ private slots: ...@@ -58,6 +58,7 @@ private slots:
void actClearChat(); void actClearChat();
void actOpenChatSettings(); void actOpenChatSettings();
void ignoreUnregisteredUsersChanged(); void ignoreUnregisteredUsersChanged();
void addMentionTag(QString mentionTag);
void processListGamesEvent(const Event_ListGames &event); void processListGamesEvent(const Event_ListGames &event);
void processJoinRoomEvent(const Event_JoinRoom &event); void processJoinRoomEvent(const Event_JoinRoom &event);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment