nick highlighting also works now for nicks with whitespace
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
ChatTools::ChatTools(QLineEdit* l, ConfigFile *c, int notifyMode, QTextBrowser *b, QTreeWidget *t) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b), myNotifyMode(notifyMode), myConfig(c)
|
||||
ChatTools::ChatTools(QLineEdit* l, ConfigFile *c, int notifyMode, QTextBrowser *b, QTreeWidget *t) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b), myNotifyMode(notifyMode), myConfig(c), myNick("")
|
||||
{
|
||||
|
||||
}
|
||||
@@ -53,7 +53,12 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||
message = message.replace(">",">");
|
||||
|
||||
QString tempMsg;
|
||||
if(message.contains(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()), Qt::CaseInsensitive)) {
|
||||
QString nickString;
|
||||
|
||||
if(myNick == "") { nickString = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()); }
|
||||
else { nickString = myNick; }
|
||||
|
||||
if(message.contains(nickString, Qt::CaseInsensitive)) {
|
||||
|
||||
switch (myNotifyMode) {
|
||||
case 0: tempMsg = message;
|
||||
|
||||
@@ -53,8 +53,11 @@ public slots:
|
||||
void setChatTextEdited();
|
||||
|
||||
void setPlayerNicksList(QStringList value) { myNickStringList = value; }
|
||||
void setMyNick ( const QString& theValue ) { myNick = theValue; }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QStringList chatLinesHistory;
|
||||
QString lastChatString;
|
||||
QStringList lastMatchStringList;
|
||||
@@ -68,6 +71,7 @@ private:
|
||||
int myNotifyMode; // 0 == no notification, 1 == bold notification, 2 == yellow notification
|
||||
ConfigFile *myConfig;
|
||||
|
||||
QString myNick;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -64,6 +64,7 @@ void LobbyChat::connected(QString server)
|
||||
void LobbyChat::selfJoined(QString ownName, QString channel)
|
||||
{
|
||||
myNick = ownName;
|
||||
myChatTools->setMyNick(myNick);
|
||||
myLobby->textBrowser_ChatDisplay->append(tr("Joined channel:") + " " + channel + " " + tr("as user") + " " + ownName + ".");
|
||||
myLobby->textBrowser_ChatDisplay->append("");
|
||||
myLobby->lineEdit_ChatInput->setEnabled(true);
|
||||
@@ -92,8 +93,10 @@ void LobbyChat::playerChanged(QString oldNick, QString newNick)
|
||||
tmpList.front()->setData(0, Qt::DisplayRole, "@" + newNick);
|
||||
}
|
||||
|
||||
if (myNick == oldNick)
|
||||
if (myNick == oldNick) {
|
||||
myNick = newNick;
|
||||
myChatTools->setMyNick(myNick);
|
||||
}
|
||||
}
|
||||
|
||||
void LobbyChat::playerKicked(QString nickName, QString byWhom, QString reason)
|
||||
@@ -127,7 +130,7 @@ void LobbyChat::displayMessage(QString playerName, QString message) {
|
||||
|
||||
myChatTools->receiveMessage(playerName, message);
|
||||
|
||||
if(message.contains(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()), Qt::CaseInsensitive) && myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) {
|
||||
if(message.contains(myNick, Qt::CaseInsensitive) && myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) {
|
||||
myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user