networkgame-nick-highlighting
This commit is contained in:
@@ -19,12 +19,13 @@
|
||||
***************************************************************************/
|
||||
#include "chattools.h"
|
||||
#include "session.h"
|
||||
#include "configfile.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ChatTools::ChatTools(QLineEdit* l, QTreeWidget *t, QTextBrowser *b) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b)
|
||||
ChatTools::ChatTools(QLineEdit* l, ConfigFile *c, QTreeWidget *t, QTextBrowser *b, int notifyMode) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b), myNotifyMode(notifyMode), myConfig(c)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -46,8 +47,26 @@ void ChatTools::sendMessage() {
|
||||
|
||||
void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||
|
||||
if(myTextBrowser)
|
||||
myTextBrowser->append(playerName + ": " + message);
|
||||
if(myTextBrowser) {
|
||||
|
||||
QString tempMsg;
|
||||
if(message.contains(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()), Qt::CaseInsensitive)) {
|
||||
|
||||
switch (myNotifyMode) {
|
||||
case 0: tempMsg = message;
|
||||
break;
|
||||
case 1: tempMsg = QString("<b>"+message+"</b>");
|
||||
break;
|
||||
case 2: tempMsg = QString("<span style=\"color:#FFFF00;\">"+message+"</span>");
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
myTextBrowser->append(playerName + ": " + tempMsg);
|
||||
}
|
||||
else {
|
||||
myTextBrowser->append(playerName + ": " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTools::clearChat() {
|
||||
|
||||
@@ -25,13 +25,14 @@
|
||||
#include <QtGui>
|
||||
|
||||
class Session;
|
||||
class ConfigFile;
|
||||
|
||||
class ChatTools : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatTools(QLineEdit* l, QTreeWidget *t = NULL, QTextBrowser *b = NULL);
|
||||
ChatTools(QLineEdit* l, ConfigFile *c, QTreeWidget *t = NULL, QTextBrowser *b = NULL, int notifyMode = 0);
|
||||
|
||||
~ChatTools();
|
||||
|
||||
@@ -64,6 +65,10 @@ private:
|
||||
QStringList myNickStringList;
|
||||
QTextBrowser *myTextBrowser;
|
||||
Session *mySession;
|
||||
int myNotifyMode; // 0 == no notification, 1 == bold notification, 2 == yellow notification
|
||||
ConfigFile *myConfig;
|
||||
|
||||
|
||||
// friend class GuiWrapper;
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ using namespace std;
|
||||
|
||||
LobbyChat::LobbyChat(gameLobbyDialogImpl* l, ConfigFile *c) : myLobby(l), myConfig(c)
|
||||
{
|
||||
myChatTools = new ChatTools(myLobby->lineEdit_ChatInput, myLobby->treeWidget_NickList);
|
||||
myChatTools = new ChatTools(myLobby->lineEdit_ChatInput, myConfig, myLobby->treeWidget_NickList);
|
||||
}
|
||||
|
||||
LobbyChat::~LobbyChat()
|
||||
|
||||
@@ -28,7 +28,7 @@ using namespace std;
|
||||
|
||||
Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
|
||||
{
|
||||
myChatTools = new ChatTools(myW->lineEdit_ChatInput);
|
||||
myChatTools = new ChatTools(myW->lineEdit_ChatInput, myConfig);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFi
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
myChat = new ChatTools(lineEdit_ChatInput, treeWidget, textBrowser_ChatDisplay);
|
||||
myChat = new ChatTools(lineEdit_ChatInput, myConfig, treeWidget, textBrowser_ChatDisplay, 1);
|
||||
|
||||
lineEdit_ChatInput->installEventFilter(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user