mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-13 11:32:48 -04:00
Changed SoundManger to allow the plugins to play sounds.
Added example to VOIP (commented out). git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5709 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
56635e4ce4
commit
232af8e71e
11 changed files with 109 additions and 41 deletions
|
@ -30,16 +30,18 @@
|
|||
|
||||
SoundManager *soundManager = NULL;
|
||||
|
||||
static QString settingName(SoundManager::Events event)
|
||||
SoundEvents::SoundEvents()
|
||||
{
|
||||
switch (event) {
|
||||
case SoundManager::NEW_CHAT_MESSAGE:
|
||||
return "NewChatMessage";
|
||||
case SoundManager::USER_ONLINE:
|
||||
return "User_go_Online";
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
void SoundEvents::addEvent(const QString &groupName, const QString &eventName, const QString &event)
|
||||
{
|
||||
SoundEventInfo info;
|
||||
info.mGroupName = groupName;
|
||||
info.mEventName = eventName;
|
||||
info.mEvent = event;
|
||||
|
||||
mEventInfos.push_back(info);
|
||||
}
|
||||
|
||||
void SoundManager::create()
|
||||
|
@ -71,47 +73,47 @@ bool SoundManager::isMute()
|
|||
return mute;
|
||||
}
|
||||
|
||||
bool SoundManager::eventEnabled(Events event)
|
||||
bool SoundManager::eventEnabled(const QString &event)
|
||||
{
|
||||
Settings->beginGroup(GROUP_MAIN);
|
||||
Settings->beginGroup(GROUP_ENABLE);
|
||||
bool enabled = Settings->value(settingName(event), false).toBool();
|
||||
bool enabled = Settings->value(event, false).toBool();
|
||||
Settings->endGroup();
|
||||
Settings->endGroup();
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SoundManager::setEventEnabled(Events event, bool enabled)
|
||||
void SoundManager::setEventEnabled(const QString &event, bool enabled)
|
||||
{
|
||||
Settings->beginGroup(GROUP_MAIN);
|
||||
Settings->beginGroup(GROUP_ENABLE);
|
||||
Settings->setValue(settingName(event), enabled);
|
||||
Settings->setValue(event, enabled);
|
||||
Settings->endGroup();
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
QString SoundManager::eventFilename(Events event)
|
||||
QString SoundManager::eventFilename(const QString &event)
|
||||
{
|
||||
Settings->beginGroup(GROUP_MAIN);
|
||||
Settings->beginGroup(GROUP_SOUNDFILE);
|
||||
QString filename = Settings->value(settingName(event)).toString();
|
||||
QString filename = Settings->value(event).toString();
|
||||
Settings->endGroup();
|
||||
Settings->endGroup();
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
void SoundManager::setEventFilename(Events event, const QString &filename)
|
||||
void SoundManager::setEventFilename(const QString &event, const QString &filename)
|
||||
{
|
||||
Settings->beginGroup(GROUP_MAIN);
|
||||
Settings->beginGroup(GROUP_SOUNDFILE);
|
||||
Settings->setValue(settingName(event), filename);
|
||||
Settings->setValue(event, filename);
|
||||
Settings->endGroup();
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void SoundManager::play(Events event)
|
||||
void SoundManager::play(const QString &event)
|
||||
{
|
||||
if (isMute() || !QSound::isAvailable() || !eventEnabled(event)) {
|
||||
return;
|
||||
|
@ -121,7 +123,6 @@ void SoundManager::play(Events event)
|
|||
playFile(filename);
|
||||
}
|
||||
|
||||
|
||||
void SoundManager::playFile(const QString &filename)
|
||||
{
|
||||
if (filename.isEmpty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue