23 #include "ircsounds.h"
25 #include "irc/configuration/ircconfig.h"
28 #include <QSoundEffect>
34 if (gIRCConfig.sounds.bUseNicknameUsedSound)
36 QString path = gIRCConfig.sounds.nicknameUsedSound;
37 sounds.insert(NicknameUsed, loadIfExists(path));
40 if (gIRCConfig.sounds.bUsePrivateMessageReceivedSound)
42 QString path = gIRCConfig.sounds.privateMessageReceivedSound;
43 sounds.insert(PrivateMessageReceived, loadIfExists(path));
47 QSoundEffect *IRCSounds::loadIfExists(
const QString &path)
49 QFileInfo fileInfo(path);
50 if (fileInfo.isFile())
52 auto sfx =
new QSoundEffect();
53 sfx->setSource(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
61 auto pSound = sounds[sound];
62 if (pSound !=
nullptr)
66 void IRCSounds::unload()
68 for (
auto sfx : sounds)