File indexing completed on 2024-10-06 03:47:47

0001 /*
0002     SPDX-FileCopyrightText: 1999-2006 Éric Bischoff <ebischoff@nerim.net>
0003     SPDX-FileCopyrightText: 2007 Albert Astals Cid <aacid@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 /* Sound factory */
0009 
0010 #ifndef _SOUNDFACTORY_H_
0011 #define _SOUNDFACTORY_H_
0012 
0013 #include <QStringList>
0014 
0015 class QMediaPlayer;
0016 
0017 class SoundFactoryCallbacks
0018 {
0019 public:
0020   virtual ~SoundFactoryCallbacks() {};
0021   virtual bool isSoundEnabled() const = 0;
0022   virtual void registerLanguage(const QString &code, const QString &soundFile, bool enabled) = 0;
0023 };
0024 
0025 class SoundFactory
0026 {
0027 public:
0028   explicit SoundFactory(SoundFactoryCallbacks *callbacks);
0029   ~SoundFactory();
0030   SoundFactory(const SoundFactory &) = delete;
0031   SoundFactory &operator=(const SoundFactory &) = delete;
0032 
0033   bool loadLanguage(const QString &selectedLanguageFile);
0034   void playSound(const QString &soundRef) const;
0035 
0036   QString currentSoundFile() const;
0037 
0038   void registerLanguages();
0039 
0040 private:
0041   SoundFactoryCallbacks *m_callbacks;
0042 
0043   QString currentSndFile;       // The current language
0044 
0045   int sounds;               // Number of sounds
0046   QStringList namesList,        // List of sound names
0047               filesList;           // List of sound files associated with each sound name
0048 
0049   QMediaPlayer *player;
0050 };
0051 
0052 #endif