diff -r c739b503ae31 -r d56d18802481 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 22 08:51:02 2011 +0200 +++ b/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 22 10:52:07 2011 +0200 @@ -182,12 +182,16 @@ void HWChatWidget::displayNotice(const QString & message) { addLine("msg_Notice", " *** " + message); + // scroll to the end + chatText->moveCursor(QTextCursor::End); } void HWChatWidget::displayWarning(const QString & message) { addLine("msg_Warning", " *!* " + message); + // scroll to the end + chatText->moveCursor(QTextCursor::End); } @@ -197,9 +201,14 @@ { this->gameSettings = gameSettings; this->notify = notify; - if(notify && gameSettings->value("frontend/sound", true).toBool()) - helloSound = HWDataManager::instance().findFileForRead( - "Sounds/voices/Classic/Hello.ogg"); + if(gameSettings->value("frontend/sound", true).toBool()) + { + if (notify) + m_helloSound = HWDataManager::instance().findFileForRead( + "Sounds/voices/Classic/Hello.ogg"); + m_hilightSound = HWDataManager::instance().findFileForRead( + "Sounds/1C.ogg"); + } mainLayout.setSpacing(1); mainLayout.setMargin(1); @@ -264,6 +273,8 @@ showReady = false; setShowFollow(true); + + clear(); } @@ -442,7 +453,8 @@ QString cssClass("msg_UserChat"); // check first character for color code and set color properly - switch (str[0].toAscii()) { + char c = str[0].toAscii(); + switch (c) { case 3: cssClass = (isFriend ? "msg_FriendJoin" : "msg_UserJoin"); break; @@ -454,10 +466,10 @@ cssClass = "msg_FriendChat"; } - addLine(cssClass,formattedStr); + addLine(cssClass, formattedStr, (!nick.isEmpty()) && str.contains(m_userNick)); } -void HWChatWidget::addLine(const QString & cssClass, QString line) +void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight) { if (s_displayNone->contains(cssClass)) return; // the css forbids us to display this line @@ -465,7 +477,13 @@ if (chatStrings.size() > 250) chatStrings.removeFirst(); - line = QString("%1").arg(line).arg(cssClass); + line = QString("%2").arg(cssClass).arg(line); + + if (isHighlight) + { + line = QString("%1").arg(line); + SDLInteraction::instance().playSoundFile(m_hilightSound); + } chatStrings.append(line); @@ -486,20 +504,20 @@ chatText->moveCursor(QTextCursor::End); } -void HWChatWidget::nickAdded(const QString& nick, bool notifyNick) +void HWChatWidget::nickAdded(const QString & nick, bool notifyNick) { bool isIgnored = ignoreList.contains(nick, Qt::CaseInsensitive); QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored); updateNickItem(item); chatNicks->addItem(item); - if (!isIgnored) + if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name chatEditLine->addNickname(nick); emit nickCountUpdate(chatNicks->count()); if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { - SDLInteraction::instance().playSoundFile(helloSound); + SDLInteraction::instance().playSoundFile(m_helloSound); } } @@ -519,6 +537,7 @@ chatText->clear(); chatStrings.clear(); chatNicks->clear(); + m_userNick = gameSettings->value("net/nick","").toString(); } void HWChatWidget::onKick()