From b20ae9710ce6d1376bedc42ec76c9eb5939aba1d Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Sun, 5 Apr 2015 12:43:02 +0200 Subject: [PATCH] Mention popup fix + will now only popup with a mention alert when you are not on the same tab/window. + will also no longer popup by mentioning yourself --- cockatrice/src/chatview.cpp | 6 +----- cockatrice/src/chatview.h | 1 + cockatrice/src/tab_room.cpp | 12 ++++++++++++ cockatrice/src/tab_room.h | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index de5891b6..53bb32ca 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -5,13 +5,11 @@ #include #include #include -#include #include "chatview.h" #include "user_level.h" #include "user_context_menu.h" #include "pixmapgenerator.h" #include "settingscache.h" -#include "main.h" #include "tab_userlists.h" const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47); @@ -282,9 +280,7 @@ bool ChatView::shouldShowSystemPopup() { } void ChatView::showSystemPopup(QString &sender) { - disconnect(trayIcon, SIGNAL(messageClicked()), 0, 0); - trayIcon->showMessage(sender + tr(" mentioned you."), tr("Click to view")); - connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(actMessageClicked())); + emit showMentionPopup(sender); } diff --git a/cockatrice/src/chatview.h b/cockatrice/src/chatview.h index 4fec655a..b7437f45 100644 --- a/cockatrice/src/chatview.h +++ b/cockatrice/src/chatview.h @@ -65,6 +65,7 @@ signals: void deleteCardInfoPopup(QString cardName); void addMentionTag(QString mentionTag); void messageClickedSignal(); + void showMentionPopup(QString &sender); }; #endif diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 06600b5b..106e03f6 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "tab_supervisor.h" #include "tab_room.h" #include "tab_userlists.h" @@ -18,6 +19,7 @@ #include "chatview.h" #include "gameselector.h" #include "settingscache.h" +#include "main.h" #include "get_pb_extension.h" #include "pb/room_commands.pb.h" @@ -43,6 +45,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool))); chatView = new ChatView(tabSupervisor, 0, true); + connect(chatView, SIGNAL(showMentionPopup(QString&)), this, SLOT(actShowMentionPopup(QString&))); connect(chatView, SIGNAL(messageClickedSignal()), this, SLOT(focusTab())); connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool))); connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString))); @@ -132,6 +135,15 @@ void TabRoom::focusTab() { tabSupervisor->setCurrentIndex(tabSupervisor->indexOf(this)); } +void TabRoom::actShowMentionPopup(QString &sender) { + if (tabSupervisor->currentIndex() != tabSupervisor->indexOf(this) + || QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0) { + disconnect(trayIcon, SIGNAL(messageClicked()), 0, 0); + trayIcon->showMessage(sender + tr(" mentioned you."), tr("Click to view")); + connect(trayIcon, SIGNAL(messageClicked()), chatView, SLOT(actMessageClicked())); + } +} + void TabRoom::closeRequest() { actLeaveRoom(); diff --git a/cockatrice/src/tab_room.h b/cockatrice/src/tab_room.h index 4783b11f..fcb4e64e 100644 --- a/cockatrice/src/tab_room.h +++ b/cockatrice/src/tab_room.h @@ -57,6 +57,7 @@ private slots: void actOpenChatSettings(); void addMentionTag(QString mentionTag); void focusTab(); + void actShowMentionPopup(QString &sender); void processListGamesEvent(const Event_ListGames &event); void processJoinRoomEvent(const Event_JoinRoom &event);