From 6b307469fe306c1d2af8ec536aed97489045f66e Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Tue, 7 Apr 2015 23:09:51 +0200 Subject: [PATCH] Fixed issue with clicking on PM bubbles Previously would not open the client if the window was minimized. Added the same popup fix for mentions --- cockatrice/src/chatview.cpp | 3 +-- cockatrice/src/tab_message.cpp | 6 +++--- cockatrice/src/tab_message.h | 1 + cockatrice/src/tab_room.cpp | 1 + cockatrice/src/tab_room.h | 1 + cockatrice/src/tab_supervisor.cpp | 6 ++++++ cockatrice/src/tab_supervisor.h | 2 ++ cockatrice/src/window_main.cpp | 5 +++++ cockatrice/src/window_main.h | 2 ++ 9 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp index 53bb32ca..99da5a6c 100644 --- a/cockatrice/src/chatview.cpp +++ b/cockatrice/src/chatview.cpp @@ -275,8 +275,7 @@ void ChatView::actMessageClicked() { } bool ChatView::shouldShowSystemPopup() { - return tabSupervisor->currentIndex() != tabSupervisor->indexOf(this) || - QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0; + return QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0 ||tabSupervisor->currentIndex() != tabSupervisor->indexOf(this); } void ChatView::showSystemPopup(QString &sender) { diff --git a/cockatrice/src/tab_message.cpp b/cockatrice/src/tab_message.cpp index fbfaf699..43c31b19 100644 --- a/cockatrice/src/tab_message.cpp +++ b/cockatrice/src/tab_message.cpp @@ -118,9 +118,8 @@ void TabMessage::processUserMessageEvent(const Event_UserMessage &event) } bool TabMessage::shouldShowSystemPopup(const Event_UserMessage &event) { - return (event.sender_name() == otherUserInfo->name() && - tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)) || - QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0; + return (QApplication::activeWindow() == 0 || QApplication::focusWidget() == 0 || + event.sender_name() == otherUserInfo->name() && tabSupervisor->currentIndex() != tabSupervisor->indexOf(this)); } void TabMessage::showSystemPopup(const Event_UserMessage &event) { @@ -132,6 +131,7 @@ void TabMessage::showSystemPopup(const Event_UserMessage &event) { void TabMessage::messageClicked() { tabSupervisor->setCurrentIndex(tabSupervisor->indexOf(this)); QApplication::setActiveWindow(this); + emit maximizeClient(); } void TabMessage::processUserLeft() diff --git a/cockatrice/src/tab_message.h b/cockatrice/src/tab_message.h index b6fe1f03..ac468880 100644 --- a/cockatrice/src/tab_message.h +++ b/cockatrice/src/tab_message.h @@ -25,6 +25,7 @@ private: QAction *aLeave; signals: void talkClosing(TabMessage *tab); + void maximizeClient(); private slots: void sendMessage(); void actLeave(); diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index 106e03f6..579081a4 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -133,6 +133,7 @@ void TabRoom::retranslateUi() void TabRoom::focusTab() { QApplication::setActiveWindow(this); tabSupervisor->setCurrentIndex(tabSupervisor->indexOf(this)); + emit maximizeClient(); } void TabRoom::actShowMentionPopup(QString &sender) { diff --git a/cockatrice/src/tab_room.h b/cockatrice/src/tab_room.h index fcb4e64e..377f357f 100644 --- a/cockatrice/src/tab_room.h +++ b/cockatrice/src/tab_room.h @@ -49,6 +49,7 @@ private: signals: void roomClosing(TabRoom *tab); void openMessageDialog(const QString &userName, bool focus); + void maximizeClient(); private slots: void sendMessage(); void sayFinished(const Response &response); diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index 6e44eae4..867f84b3 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -364,6 +364,7 @@ void TabSupervisor::gameLeft(TabGame *tab) void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent) { TabRoom *tab = new TabRoom(this, client, userInfo, info); + connect(tab, SIGNAL(maximizeClient()), this, SLOT(maximizeMainWindow())); connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *))); connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool))); int tabIndex = myAddTab(tab); @@ -422,6 +423,7 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus tab = new TabMessage(this, client, *userInfo, otherUser); connect(tab, SIGNAL(talkClosing(TabMessage *)), this, SLOT(talkLeft(TabMessage *))); + connect(tab, SIGNAL(maximizeClient()), this, SLOT(maximizeMainWindow())); int tabIndex = myAddTab(tab); addCloseButtonToTab(tab, tabIndex); messageTabs.insert(receiverName, tab); @@ -430,6 +432,10 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus return tab; } +void TabSupervisor::maximizeMainWindow() { + emit maximize(); +} + void TabSupervisor::talkLeft(TabMessage *tab) { if (tab == currentWidget()) diff --git a/cockatrice/src/tab_supervisor.h b/cockatrice/src/tab_supervisor.h index d5706bf7..0144de12 100644 --- a/cockatrice/src/tab_supervisor.h +++ b/cockatrice/src/tab_supervisor.h @@ -78,9 +78,11 @@ signals: void setMenu(const QList &newMenuList = QList()); void localGameEnded(); void adminLockChanged(bool lock); + void maximize(); public slots: TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen); void openReplay(GameReplay *replay); + void maximizeMainWindow(); private slots: void closeButtonPressed(); void updateCurrent(int index); diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 528f0dbb..8d8eec07 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -408,6 +408,7 @@ MainWindow::MainWindow(QWidget *parent) tabSupervisor = new TabSupervisor(client); connect(tabSupervisor, SIGNAL(setMenu(QList)), this, SLOT(updateTabMenu(QList))); connect(tabSupervisor, SIGNAL(localGameEnded()), this, SLOT(localGameEnded())); + connect(tabSupervisor, SIGNAL(maximize()), this, SLOT(maximize())); tabSupervisor->addDeckEditorTab(0); setCentralWidget(tabSupervisor); @@ -507,3 +508,7 @@ void MainWindow::pixmapCacheSizeChanged(int newSizeInMBs) // translate MBs to KBs QPixmapCache::setCacheLimit(newSizeInMBs * 1024); } + +void MainWindow::maximize() { + showNormal(); +} diff --git a/cockatrice/src/window_main.h b/cockatrice/src/window_main.h index f8799ccf..d52be9bd 100644 --- a/cockatrice/src/window_main.h +++ b/cockatrice/src/window_main.h @@ -59,6 +59,8 @@ private slots: void actAbout(); void iconActivated(QSystemTrayIcon::ActivationReason reason); + + void maximize(); private: static const QString appName; void setClientStatusTitle();