File indexing completed on 2022-09-27 12:25:42

0001 /*
0002     SPDX-FileCopyrightText: KDE Tuberling <e.bischoff@noos.fr>
0003     SPDX-FileCopyrightText: 2001 Eric Bischoff <e.bischoff@noos.fr>
0004     SPDX-FileCopyrightText: 2004-2007 Anne-Marie Mahfouf <annma@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef _SOUNDFACTORY_H_
0010 #define _SOUNDFACTORY_H_
0011 
0012 #include <QObject>
0013 #include <QStringList>
0014 #include <QDomDocument>
0015 
0016 class KLettres;
0017 namespace Phonon
0018 {
0019     class MediaObject;
0020 }
0021 
0022 /**
0023  * This class manages the sounds to play in KLettres, reading the data about the sounds
0024  * in the sounds.xml file which is in /data.
0025  *
0026  * @short Sounds factory class: find and play the right sound.
0027  * @author Anne-Marie Mahfouf <annma@kde.org>
0028  * @version 1.80
0029  */
0030  
0031 class SoundFactory : public QObject
0032 {
0033   Q_OBJECT
0034 
0035 public:
0036 
0037     explicit SoundFactory(KLettres *parent, const QString &name);
0038     ~SoundFactory() override;
0039 
0040     ///Call the main instance of the program
0041     KLettres *klettres;
0042     ///Change the language when the user changes the language in the Languages menu
0043     void change(const QString &currentLanguage);
0044     ///Play the sound associated to int soundRef
0045     void playSound(int ) ;
0046     ///Number of sounds corresponding to the current language and level (alphabet or syllables)
0047     uint sounds;
0048     ///List of sound names
0049     QStringList namesList;
0050     ///List of sound files associated with each sound name
0051     QStringList filesList;
0052     /**
0053     * Load the sounds of one given language
0054     * Call that when you read the language from Config and when the language changes
0055     * or when the level changes
0056     */
0057     bool loadLanguage(QDomDocument &layoutDocument, const QString &currentLanguage);
0058     ///The language document
0059     QDomDocument m_layoutsDocument;
0060     ///The random sequence of integers
0061     QList<int> randomList;
0062 
0063 private:
0064     ///Report a load failure
0065     void loadFailure();
0066     ///Shuffle the index in random to get random sounds. The sequence of random sounds will take 1 random sound after another, then restart when all sounds have been played
0067     void setSoundSequence();
0068     Phonon::MediaObject *m_player;
0069 };
0070 
0071 #endif