1 /*
2    SPDX-FileCopyrightText: 2014-2021 Laurent Montel <montel@kde.org>
3 
4    SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "texttospeechconfiginterface.h"
8 #include <QTextToSpeech>
9 using namespace KPIMTextEdit;
10 
TextToSpeechConfigInterface(QObject * parent)11 TextToSpeechConfigInterface::TextToSpeechConfigInterface(QObject *parent)
12     : AbstractTextToSpeechConfigInterface(parent)
13     , mTextToSpeech(new QTextToSpeech(this))
14 {
15 }
16 
~TextToSpeechConfigInterface()17 TextToSpeechConfigInterface::~TextToSpeechConfigInterface()
18 {
19 }
20 
availableVoices() const21 QStringList TextToSpeechConfigInterface::availableVoices() const
22 {
23     QStringList lst;
24     const QVector<QVoice> voices = mTextToSpeech->availableVoices();
25     lst.reserve(voices.count());
26     for (const QVoice &voice : voices) {
27         lst << voice.name();
28     }
29     return lst;
30 }
31 
availableEngines() const32 QStringList TextToSpeechConfigInterface::availableEngines() const
33 {
34     return mTextToSpeech->availableEngines();
35 }
36 
availableLocales() const37 QVector<QLocale> TextToSpeechConfigInterface::availableLocales() const
38 {
39     return mTextToSpeech->availableLocales();
40 }
41 
locale() const42 QLocale TextToSpeechConfigInterface::locale() const
43 {
44     return mTextToSpeech->locale();
45 }
46 
setEngine(const QString & engineName)47 void TextToSpeechConfigInterface::setEngine(const QString &engineName)
48 {
49     delete mTextToSpeech;
50     mTextToSpeech = new QTextToSpeech(engineName, this);
51 }
52