networkgame-nick-highlighting
This commit is contained in:
@@ -19,12 +19,13 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "chattools.h"
|
#include "chattools.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
#include "configfile.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
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,9 +47,27 @@ void ChatTools::sendMessage() {
|
|||||||
|
|
||||||
void ChatTools::receiveMessage(QString playerName, QString message) {
|
void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||||
|
|
||||||
if(myTextBrowser)
|
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);
|
myTextBrowser->append(playerName + ": " + message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatTools::clearChat() {
|
void ChatTools::clearChat() {
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,14 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
class Session;
|
class Session;
|
||||||
|
class ConfigFile;
|
||||||
|
|
||||||
class ChatTools : public QObject
|
class ChatTools : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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();
|
~ChatTools();
|
||||||
|
|
||||||
@@ -64,6 +65,10 @@ private:
|
|||||||
QStringList myNickStringList;
|
QStringList myNickStringList;
|
||||||
QTextBrowser *myTextBrowser;
|
QTextBrowser *myTextBrowser;
|
||||||
Session *mySession;
|
Session *mySession;
|
||||||
|
int myNotifyMode; // 0 == no notification, 1 == bold notification, 2 == yellow notification
|
||||||
|
ConfigFile *myConfig;
|
||||||
|
|
||||||
|
|
||||||
// friend class GuiWrapper;
|
// friend class GuiWrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ using namespace std;
|
|||||||
|
|
||||||
LobbyChat::LobbyChat(gameLobbyDialogImpl* l, ConfigFile *c) : myLobby(l), myConfig(c)
|
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()
|
LobbyChat::~LobbyChat()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ using namespace std;
|
|||||||
|
|
||||||
Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
|
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);
|
setupUi(this);
|
||||||
|
|
||||||
myChat = new ChatTools(lineEdit_ChatInput, treeWidget, textBrowser_ChatDisplay);
|
myChat = new ChatTools(lineEdit_ChatInput, myConfig, treeWidget, textBrowser_ChatDisplay, 1);
|
||||||
|
|
||||||
lineEdit_ChatInput->installEventFilter(this);
|
lineEdit_ChatInput->installEventFilter(this);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user