# HG changeset patch # User sheepluva # Date 1416715391 -3600 # Node ID 1010df878643c97586a3d454bd7fe217c5cc028c # Parent 428085a1be6e7127bf9d5386c5363191058ab0b7 don't flash frontend on hilight - while in-game diff -r 428085a1be6e -r 1010df878643 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Sun Nov 23 03:58:56 2014 +0100 +++ b/QTfrontend/ui/widget/chatwidget.cpp Sun Nov 23 05:03:11 2014 +0100 @@ -179,6 +179,8 @@ this->gameSettings = NULL; this->notify = notify; + m_usersModel = NULL; + m_isAdmin = false; m_autoKickEnabled = false; @@ -409,26 +411,27 @@ void HWChatWidget::printChatString( const QString & nick, const QString & str, const QString & cssClassPart, bool highlight) { - QSortFilterProxyModel * playersSortFilterModel = qobject_cast(chatNicks->model()); - if(!playersSortFilterModel) - return; - - PlayersListModel * players = qobject_cast(playersSortFilterModel->sourceModel()); - - if(!players) + if(!m_usersModel) return; // don't show chat lines that are from ignored nicks - if (players->isFlagSet(nick, PlayersListModel::Ignore)) + if (m_usersModel->isFlagSet(nick, PlayersListModel::Ignore)) return; - bool isFriend = (!nick.isEmpty()) && players->isFlagSet(nick, PlayersListModel::Friend); + bool isFriend = (!nick.isEmpty()) && m_usersModel->isFlagSet(nick, PlayersListModel::Friend); QString cssClass = (isFriend ? "msg_Friend" : "msg_User") + cssClassPart; addLine(cssClass, str, highlight); } +bool HWChatWidget::isInGame() { + if (!m_usersModel) + return false; + + return m_usersModel->isFlagSet(m_userNick, PlayersListModel::InGame); +} + void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight) { if (s_displayNone->contains(cssClass)) @@ -452,7 +455,8 @@ { line = QString("%1").arg(line); SDLInteraction::instance().playSoundFile(m_hilightSound); - HWApplication::alert(this, 800); + if (!isInGame()) + HWApplication::alert(this, 800); } chatStrings.append(line); @@ -853,6 +857,12 @@ chatNicks->setModel(model); chatNicks->setModelColumn(0); + + QSortFilterProxyModel * sfpModel = qobject_cast(model); + if (sfpModel) + m_usersModel = qobject_cast(sfpModel->sourceModel()); + else + m_usersModel = qobject_cast(model); } void HWChatWidget::nicksContextMenuRequested(const QPoint &pos) diff -r 428085a1be6e -r 1010df878643 QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Sun Nov 23 03:58:56 2014 +0100 +++ b/QTfrontend/ui/widget/chatwidget.h Sun Nov 23 05:03:11 2014 +0100 @@ -32,6 +32,7 @@ #include "SDLInteraction.h" #include "SmartLineEdit.h" +#include "playerslistmodel.h" class QTextBrowser; class QLineEdit; @@ -87,6 +88,7 @@ QString linkedNick(const QString & nickname); void beforeContentAdd(); void afterContentAdd(); + bool isInGame(); /** * @brief Checks whether the message contains a highlight. @@ -132,6 +134,7 @@ void consoleCommand(const QString & command); private: + PlayersListModel* m_usersModel; bool m_isAdmin; QHBoxLayout mainLayout; QTextBrowser* chatText;