--- a/QTfrontend/chatwidget.cpp Tue Feb 09 01:50:36 2010 +0000
+++ b/QTfrontend/chatwidget.cpp Tue Feb 09 02:03:31 2010 +0000
@@ -30,12 +30,21 @@
#include "gameuiconfig.h"
#include "chatwidget.h"
-HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) :
+HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) :
QWidget(parent),
mainLayout(this)
{
this->gameSettings = gameSettings;
this->sdli = sdli;
+ this->notify = notify;
+ if(notify && gameSettings->value("audio/sound", true).toBool()) {
+ QDir tmpdir;
+
+ tmpdir.cd(datadir->absolutePath());
+ tmpdir.cd("Sounds/");
+ sdli->SDLMusicInit();
+ sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/switchhog.ogg").toLocal8Bit().constData());
+ }
mainLayout.setSpacing(1);
mainLayout.setMargin(1);
@@ -119,18 +128,11 @@
void HWChatWidget::nickAdded(const QString& nick)
{
- Mix_Chunk *sound;
- QDir tmpdir;
-
QListWidgetItem * item = new QListWidgetItem(nick);
item->setIcon(QIcon(":/res/hh_small.png"));
chatNicks->addItem(item);
- if(gameSettings->value("audio/sound", true).toBool()) {
- sdli->SDLMusicInit();
- tmpdir.cd(datadir->absolutePath());
- tmpdir.cd("Sounds/");
- sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/switchhog.ogg").toLocal8Bit().constData());
+ if(notify && gameSettings->value("audio/sound", true).toBool()) {
Mix_PlayChannel(-1, sound, 0);
}
}
--- a/QTfrontend/chatwidget.h Tue Feb 09 01:50:36 2010 +0000
+++ b/QTfrontend/chatwidget.h Tue Feb 09 02:03:31 2010 +0000
@@ -24,6 +24,8 @@
#include <QString>
#include <QGridLayout>
+#include "SDLs.h"
+
class QTextBrowser;
class QLineEdit;
class QListWidget;
@@ -35,8 +37,7 @@
Q_OBJECT
public:
-// HWChatWidget(QWidget* parent=0);
- HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli);
+ HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify);
public slots:
void onChatString(const QString& str);
@@ -66,7 +67,8 @@
QAction * acFollow;
QSettings * gameSettings;
SDLInteraction * sdli;
-
+ Mix_Chunk *sound;
+ bool notify;
private slots:
void returnPressed();
--- a/QTfrontend/pages.cpp Tue Feb 09 01:50:36 2010 +0000
+++ b/QTfrontend/pages.cpp Tue Feb 09 02:03:31 2010 +0000
@@ -641,7 +641,7 @@
pageLayout->setColumnStretch(1, 50);
// chatwidget
- pChatWidget = new HWChatWidget(this, gameSettings, sdli);
+ pChatWidget = new HWChatWidget(this, gameSettings, sdli, true);
pageLayout->addWidget(pChatWidget, 1, 0, 1, 2);
pageLayout->setRowStretch(1, 100);
@@ -818,7 +818,7 @@
pageLayout->addWidget(roomsList, 1, 0, 3, 1);
pageLayout->setRowStretch(2, 100);
- chatWidget = new HWChatWidget(this, gameSettings, sdli);
+ chatWidget = new HWChatWidget(this, gameSettings, sdli, false);
pageLayout->addWidget(chatWidget, 4, 0, 1, 2);
pageLayout->setRowStretch(4, 350);