Merge pull request #562 from poixen/chat_click_mentions

Click tag mentions
This commit is contained in:
Gavin Bisesi 2015-01-20 10:06:04 -05:00
commit 10aa137475
6 changed files with 30 additions and 4 deletions

View file

@ -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;
}

View file

@ -49,6 +49,7 @@ signals:
void cardNameHovered(QString cardName);
void showCardInfoPopup(QPoint pos, QString cardName);
void deleteCardInfoPopup(QString cardName);
void addMentionTag(QString mentionTag);
};
#endif

View file

@ -418,6 +418,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_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<AbstractClient *> &_client
messageLog->logGameJoined(gameInfo.game_id());
}
void TabGame::addMentionTag(QString value) {
sayEdit->insert(value + " ");
sayEdit->setFocus();
}
TabGame::~TabGame()
{
delete replay;

View file

@ -195,6 +195,8 @@ private slots:
void actPhaseAction();
void actNextPhase();
void actNextTurn();
void addMentionTag(QString value);
public:
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);

View file

@ -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);

View file

@ -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);