From 5aa2647adeb076dda9f2a0dbb074b063f4569966 Mon Sep 17 00:00:00 2001 From: doitux Date: Sun, 9 Dec 2007 13:44:23 +0000 Subject: [PATCH] BROKEN --- src/gui/qt/chattools/chattools.cpp | 12 ++++++++---- src/gui/qt/chattools/chattools.h | 5 ++++- src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp | 13 ++----------- src/gui/qt/mainwindow/mainwindowimpl.cpp | 6 +++--- src/gui/qt/mainwindow/mainwindowimpl.h | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/gui/qt/chattools/chattools.cpp b/src/gui/qt/chattools/chattools.cpp index 7a0918c0..54e295d5 100644 --- a/src/gui/qt/chattools/chattools.cpp +++ b/src/gui/qt/chattools/chattools.cpp @@ -20,12 +20,13 @@ #include "chattools.h" #include "session.h" #include "configfile.h" +#include "sdlplayer.h" #include 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, SDLPlayer *s, QDialog *p) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickTreeWidget(t), myNickStringList(NULL), myTextBrowser(b), myNotifyMode(notifyMode), myConfig(c), mySDLPlayer(s), myParentDialog(p) { } @@ -64,7 +65,6 @@ void ChatTools::receiveMessage(QString playerName, QString message) { break; default:; } - myTextBrowser->append(playerName + ": " + tempMsg); } else { switch (myNotifyMode) { @@ -75,9 +75,13 @@ void ChatTools::receiveMessage(QString playerName, QString message) { case 2: tempMsg = QString(""+message+""); break; default:; - } - myTextBrowser->append(playerName + ": " + tempMsg); + } } + myTextBrowser->append(playerName + ": " + tempMsg); + } + if(myParentDialog) { + if(myParentDialog->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) + mySDLPlayer->playSound("lobbychatnotify",0); } } diff --git a/src/gui/qt/chattools/chattools.h b/src/gui/qt/chattools/chattools.h index 5bfd2ba8..90657537 100644 --- a/src/gui/qt/chattools/chattools.h +++ b/src/gui/qt/chattools/chattools.h @@ -26,13 +26,14 @@ class Session; class ConfigFile; +class SDLPlayer; class ChatTools : public QObject { Q_OBJECT public: - ChatTools(QLineEdit* l, ConfigFile *c, int notifyMode = 0, QTextBrowser *b = NULL, QTreeWidget *t = NULL ); + ChatTools(QLineEdit* l, ConfigFile *c, int notifyMode = 0, QTextBrowser *b = NULL, QTreeWidget *t = NULL, SDLPlayer *s = NULL, QDialog *p = NULL ); ~ChatTools(); @@ -67,6 +68,8 @@ private: Session *mySession; int myNotifyMode; // 0 == no notification, 1 == bold notification, 2 == yellow notification ConfigFile *myConfig; + SDLPlayer *mySDLPlayer; + QDialog *myParentDialog; //needed for visible check for audio-nick-notification // friend class GuiWrapper; diff --git a/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp b/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp index 5ff6aac4..63070a60 100644 --- a/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp +++ b/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp @@ -32,7 +32,7 @@ using namespace std; LobbyChat::LobbyChat(gameLobbyDialogImpl* l, ConfigFile *c) : myLobby(l), myConfig(c) { - myChatTools = new ChatTools(myLobby->lineEdit_ChatInput, myConfig, 1, myLobby->textBrowser_ChatDisplay, myLobby->treeWidget_NickList); + myChatTools = new ChatTools(myLobby->lineEdit_ChatInput, myConfig, 1, myLobby->textBrowser_ChatDisplay, myLobby->treeWidget_NickList, myLobby->getMyW()->getMySDLPlayer(), myLobby); } LobbyChat::~LobbyChat() @@ -128,16 +128,7 @@ void LobbyChat::playerLeft(QString playerName) void LobbyChat::displayMessage(QString playerName, QString message) { - QString tempMsg; - if(message.contains(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()), Qt::CaseInsensitive)) { - tempMsg = QString(""+message+""); - if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) - myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0); - } - else { - tempMsg = message; - } - myLobby->textBrowser_ChatDisplay->append(playerName + ": " + tempMsg); + myChatTools->receiveMessage(playerName, message); } void LobbyChat::checkInputLength(QString string) { diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index b7dc3dcb..2d3c7c59 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -78,6 +78,9 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) setupUi(this); + //Sound + mySDLPlayer = new SDLPlayer(myConfig); + //Player0 pixmapCardsLabel needs Myw pixmapLabel_card0b->setMyW(this); pixmapLabel_card0a->setMyW(this); @@ -648,9 +651,6 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalIrcError(int)), myGameLobbyDialog->getLobbyChat(), SLOT(chatError(int))); connect(this, SIGNAL(signalIrcServerError(int)), myGameLobbyDialog->getLobbyChat(), SLOT(chatServerError(int))); - //Sound - mySDLPlayer = new SDLPlayer(myConfig); - } mainWindowImpl::~mainWindowImpl() { diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index 149c8fb0..34a7966a 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -52,9 +52,9 @@ class changeHumanPlayerNameDialogImpl; class gameLobbyDialogImpl; class QColor; - class SDLPlayer; + class mainWindowImpl: public QMainWindow, public Ui::mainWindow { Q_OBJECT