20 #include <QDesktopServices> |
20 #include <QDesktopServices> |
21 #include <QTextBrowser> |
21 #include <QTextBrowser> |
22 #include <QLineEdit> |
22 #include <QLineEdit> |
23 #include <QAction> |
23 #include <QAction> |
24 #include <QTextDocument> |
24 #include <QTextDocument> |
25 #include <QDir> |
25 #include <QFile> |
26 #include <QSettings> |
26 #include <QSettings> |
27 #include <QFile> |
|
28 #include <QTextStream> |
27 #include <QTextStream> |
29 #include <QMenu> |
28 #include <QMenu> |
30 #include <QCursor> |
29 #include <QCursor> |
31 #include <QScrollBar> |
30 #include <QScrollBar> |
32 #include <QItemSelectionModel> |
31 #include <QItemSelectionModel> |
33 #include <QStringList> |
32 #include <QStringList> |
34 |
33 |
|
34 #include "HWDataManager.h" |
35 #include "hwconsts.h" |
35 #include "hwconsts.h" |
36 #include "SDLs.h" |
|
37 #include "gameuiconfig.h" |
36 #include "gameuiconfig.h" |
|
37 |
38 #include "chatwidget.h" |
38 #include "chatwidget.h" |
39 |
39 |
40 ListWidgetNickItem::ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored) : QListWidgetItem(nick) |
40 ListWidgetNickItem::ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored) : QListWidgetItem(nick) |
41 { |
41 { |
42 this->aFriend = isFriend; |
42 this->aFriend = isFriend; |
114 .Error { color: #ff0000 }\ |
114 .Error { color: #ff0000 }\ |
115 .Warning { color: #ff8000 }\ |
115 .Warning { color: #ff8000 }\ |
116 .Notice { color: #fefefe }\ |
116 .Notice { color: #fefefe }\ |
117 "; |
117 "; |
118 |
118 |
119 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) : |
119 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : |
120 QWidget(parent), |
120 QWidget(parent), |
121 mainLayout(this) |
121 mainLayout(this) |
122 { |
122 { |
123 this->gameSettings = gameSettings; |
123 this->gameSettings = gameSettings; |
124 this->sdli = sdli; |
|
125 this->notify = notify; |
124 this->notify = notify; |
126 if(notify && gameSettings->value("frontend/sound", true).toBool()) { |
125 if(notify && gameSettings->value("frontend/sound", true).toBool()) { |
127 QFile tmpfile; |
126 QFile * tmpFile = HWDataManager::instance().findFileForRead( |
128 sdli->SDLMusicInit(); |
127 "Sounds/voices/Classic/Hello.ogg"); |
129 for(int i=0;i<4;i++) { |
128 |
130 tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Sounds/voices/Classic/Hello.ogg"); |
129 helloSound = tmpFile->fileName(); |
131 if (tmpfile.exists()) sound[i] = Mix_LoadWAV(QFileInfo(tmpfile).absoluteFilePath().toLocal8Bit().constData()); |
130 |
132 else sound[i] = Mix_LoadWAV(QString(datadir->absolutePath() + |
131 // this QFile isn't needed any further |
133 "/Sounds/voices/Classic/Hello.ogg").toLocal8Bit().constData()); |
132 delete tmpFile; |
134 } |
|
135 } |
133 } |
136 |
134 |
137 mainLayout.setSpacing(1); |
135 mainLayout.setSpacing(1); |
138 mainLayout.setMargin(1); |
136 mainLayout.setMargin(1); |
139 mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
137 mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
424 chatEditLine->addNickname(nick); |
422 chatEditLine->addNickname(nick); |
425 |
423 |
426 emit nickCountUpdate(chatNicks->count()); |
424 emit nickCountUpdate(chatNicks->count()); |
427 |
425 |
428 if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { |
426 if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { |
429 Mix_PlayChannel(-1, sound[rand()%4], 0); |
427 SDLInteraction::instance().playSoundFile(helloSound); |
430 } |
428 } |
431 } |
429 } |
432 |
430 |
433 void HWChatWidget::nickRemoved(const QString& nick) |
431 void HWChatWidget::nickRemoved(const QString& nick) |
434 { |
432 { |