added sound event to lobbies (patch from Manuel Davis)

This commit is contained in:
Cyril Soler 2016-01-28 10:22:32 -05:00
parent 3bc444b087
commit b1f165fec8
3 changed files with 12 additions and 3 deletions

View File

@ -85,6 +85,7 @@ void SoundManager::soundEvents(SoundEvents &events)
events.addEvent(tr("Chatmessage"), tr("New Msg"), SOUND_NEW_CHAT_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
events.addEvent(tr("Message"), tr("Message arrived"), SOUND_MESSAGE_ARRIVED, QFileInfo(baseDir, "receive.wav").absoluteFilePath());
events.addEvent(tr("Download"), tr("Download complete"), SOUND_DOWNLOAD_COMPLETE, QFileInfo(baseDir, "ft_complete.wav").absoluteFilePath());
events.addEvent(tr("Lobby"), tr("Message arrived"), SOUND_NEW_LOBBY_MESSAGE, QFileInfo(baseDir, "incomingchat.wav").absoluteFilePath());
/* add plugin events */
int pluginCount = rsPlugins->nbPlugins();
@ -243,9 +244,9 @@ void SoundManager::playFile(const QString &filename)
bool played = false ;
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
if (!QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).isEmpty())
if (!QAudioDeviceInfo::availableDevices(QAudio::AudioOutput).isEmpty())
#else
if (QSound::isAvailable())
if (QSound::isAvailable())
#endif
{
QSound::play(playFilename);

View File

@ -29,6 +29,7 @@
#define SOUND_USER_ONLINE "User_go_Online"
#define SOUND_MESSAGE_ARRIVED "MessageArrived"
#define SOUND_DOWNLOAD_COMPLETE "DownloadComplete"
#define SOUND_NEW_LOBBY_MESSAGE "NewLobbyMessage"
class SoundEvents
{

View File

@ -18,6 +18,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* ccr . 2016 Jan 26
*
* Play sound on incoming messages.
*
****************************************************************/
#include <unistd.h>
@ -42,6 +47,7 @@
#include "gui/gxs/GxsIdChooser.h"
#include "gui/gxs/GxsIdDetails.h"
#include "util/HandleRichText.h"
#include "gui/SoundManager.h"
#include <retroshare/rsnotify.h>
@ -400,7 +406,8 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;
ui.chatWidget->addChatMsg(msg.incoming, name, gxs_id, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL);
emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
emit messageReceived(msg.incoming, id(), sendTime, name, message) ;
SoundManager::play(SOUND_NEW_LOBBY_MESSAGE);
// This is a trick to translate HTML into text.
QTextEdit editor;