1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Speech module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37
38
39#include "qvoice.h"
40#include "qvoice_p.h"
41#include "qtexttospeech.h"
42
43QT_BEGIN_NAMESPACE
44
45/*!
46 \class QVoice
47 \brief The QVoice class allows to set and retrieve values of a particular voice.
48 \inmodule QtSpeech
49*/
50
51/*!
52 \enum QVoice::Age
53
54 The age of a voice.
55
56 \value Child Voice of a child
57 \value Teenager Voice of a teenager
58 \value Adult Voice of an adult
59 \value Senior Voice of a senior
60 \value Other Voice of unknown age
61*/
62
63/*!
64 \enum QVoice::Gender
65
66 The gender of a voice.
67
68 \value Male Voice of a male
69 \value Female Voice of a female
70 \value Unknown Voice of unknown gender
71*/
72
73QVoice::QVoice()
74{
75 d = new QVoicePrivate();
76}
77
78QVoice::QVoice(const QVoice &other)
79 :d(other.d)
80{
81}
82
83QVoice::QVoice(const QString &name, Gender gender, Age age, const QVariant &data)
84 :d(new QVoicePrivate(name, gender, age, data))
85{
86}
87
88QVoice::~QVoice()
89{
90}
91
92void QVoice::operator=(const QVoice &other)
93{
94 d->name = other.d->name;
95 d->gender = other.d->gender;
96 d->age = other.d->age;
97 d->data = other.d->data;
98}
99
100/*!
101 Compares the \l name, \l gender, and \l age of this voice with \a other.
102 Returns \c true if all of them match.
103*/
104bool QVoice::operator==(const QVoice &other)
105{
106 if (d->name != other.d->name ||
107 d->gender != other.d->gender ||
108 d->age != other.d->age ||
109 d->data != other.d->data)
110 return false;
111 return true;
112}
113
114/*!
115 Compares the \l name, \l gender, and \l age of this voice with \a other.
116 Returns \c true if they are not identical.
117*/
118bool QVoice::operator!=(const QVoice &other)
119{
120 return !operator==(other);
121}
122
123/*!
124 Assign a \a name to a voice.
125*/
126void QVoice::setName(const QString &name)
127{
128 d->name = name;
129}
130
131/*!
132 Assign a \a gender to a voice.
133*/
134void QVoice::setGender(Gender gender)
135{
136 d->gender = gender;
137}
138
139/*!
140 Set the \a age property.
141*/
142void QVoice::setAge(Age age)
143{
144 d->age = age;
145}
146
147void QVoice::setData(const QVariant &data)
148{
149 d->data = data;
150}
151
152/*!
153 Returns the name of a voice.
154*/
155QString QVoice::name() const
156{
157 return d->name;
158}
159
160/*!
161 Returns the age of a voice.
162*/
163QVoice::Age QVoice::age() const
164{
165 return d->age;
166}
167
168/*!
169 Returns the gender of a voice.
170*/
171QVoice::Gender QVoice::gender() const
172{
173 return d->gender;
174}
175
176QVariant QVoice::data() const
177{
178 return d->data;
179}
180
181/*!̈́
182 Returns the \a gender name of a voice.
183*/
184QString QVoice::genderName(QVoice::Gender gender)
185{
186 QString retval;
187 switch (gender) {
188 case QVoice::Male:
189 retval = QTextToSpeech::tr(s: "Male", c: "Gender of a voice");
190 break;
191 case QVoice::Female:
192 retval = QTextToSpeech::tr(s: "Female", c: "Gender of a voice");
193 break;
194 case QVoice::Unknown:
195 default:
196 retval = QTextToSpeech::tr(s: "Unknown Gender", c: "Voice gender is unknown");
197 break;
198 }
199 return retval;
200}
201
202/*!
203 Returns a string representing the \a age class of a voice.
204*/
205QString QVoice::ageName(QVoice::Age age)
206{
207 QString retval;
208 switch (age) {
209 case QVoice::Child:
210 retval = QTextToSpeech::tr(s: "Child", c: "Age of a voice");
211 break;
212 case QVoice::Teenager:
213 retval = QTextToSpeech::tr(s: "Teenager", c: "Age of a voice");
214 break;
215 case QVoice::Adult:
216 retval = QTextToSpeech::tr(s: "Adult", c: "Age of a voice");
217 break;
218 case QVoice::Senior:
219 retval = QTextToSpeech::tr(s: "Senior", c: "Age of a voice");
220 break;
221 case QVoice::Other:
222 default:
223 retval = QTextToSpeech::tr(s: "Other Age", c: "Unknown age of a voice");
224 break;
225 }
226 return retval;
227}
228
229QT_END_NAMESPACE
230

source code of qtspeech/src/tts/qvoice.cpp