| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QVOICE_H |
| 5 | #define QVOICE_H |
| 6 | |
| 7 | #include <QtTextToSpeech/qtexttospeech_global.h> |
| 8 | #include <QtCore/qlocale.h> |
| 9 | #include <QtCore/qshareddata.h> |
| 10 | #include <QtCore/qmetatype.h> |
| 11 | #include <QtCore/qvariant.h> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | class QVoicePrivate; |
| 16 | |
| 17 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QVoicePrivate, Q_TEXTTOSPEECH_EXPORT) |
| 18 | |
| 19 | class Q_TEXTTOSPEECH_EXPORT QVoice |
| 20 | { |
| 21 | Q_GADGET |
| 22 | Q_PROPERTY(QString name READ name CONSTANT) |
| 23 | Q_PROPERTY(Gender gender READ gender CONSTANT) |
| 24 | Q_PROPERTY(Age age READ age CONSTANT) |
| 25 | Q_PROPERTY(QLocale locale READ locale CONSTANT) |
| 26 | Q_PROPERTY(QLocale::Language language READ language STORED false REVISION(6, 6)) |
| 27 | |
| 28 | public: |
| 29 | enum Gender { |
| 30 | Male, |
| 31 | Female, |
| 32 | Unknown |
| 33 | }; |
| 34 | Q_ENUM(Gender) |
| 35 | |
| 36 | enum Age { |
| 37 | Child, |
| 38 | Teenager, |
| 39 | Adult, |
| 40 | Senior, |
| 41 | Other |
| 42 | }; |
| 43 | Q_ENUM(Age) |
| 44 | |
| 45 | QVoice(); |
| 46 | ~QVoice(); |
| 47 | QVoice(const QVoice &other) noexcept; |
| 48 | QVoice &operator=(const QVoice &other) noexcept; |
| 49 | QVoice(QVoice &&other) noexcept = default; |
| 50 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QVoice) |
| 51 | |
| 52 | void swap(QVoice &other) noexcept |
| 53 | { d.swap(other&: other.d); } |
| 54 | |
| 55 | friend inline bool operator==(const QVoice &lhs, const QVoice &rhs) noexcept |
| 56 | { return lhs.isEqual(other: rhs); } |
| 57 | friend inline bool operator!=(const QVoice &lhs, const QVoice &rhs) noexcept |
| 58 | { return !lhs.isEqual(other: rhs); } |
| 59 | |
| 60 | #ifndef QT_NO_DATASTREAM |
| 61 | friend inline QDataStream &operator<<(QDataStream &str, const QVoice &voice) |
| 62 | { return voice.writeTo(str); } |
| 63 | friend inline QDataStream &operator>>(QDataStream &str, QVoice &voice) |
| 64 | { return voice.readFrom(str); } |
| 65 | #endif |
| 66 | |
| 67 | QString name() const; |
| 68 | QLocale locale() const; |
| 69 | Gender gender() const; |
| 70 | Age age() const; |
| 71 | |
| 72 | QLocale::Language language() const { return locale().language(); } |
| 73 | |
| 74 | static QString genderName(QVoice::Gender gender); |
| 75 | static QString ageName(QVoice::Age age); |
| 76 | |
| 77 | private: |
| 78 | QVoice(const QString &name, const QLocale &loc, Gender gender, Age age, const QVariant &data); |
| 79 | bool isEqual(const QVoice &other) const noexcept; |
| 80 | #ifndef QT_NO_DATASTREAM |
| 81 | QDataStream &writeTo(QDataStream &) const; |
| 82 | QDataStream &readFrom(QDataStream &); |
| 83 | #endif |
| 84 | |
| 85 | QVariant data() const; |
| 86 | |
| 87 | QExplicitlySharedDataPointer<QVoicePrivate> d; |
| 88 | friend class QVoicePrivate; |
| 89 | friend class QTextToSpeechEngine; |
| 90 | friend Q_TEXTTOSPEECH_EXPORT QDebug operator<<(QDebug, const QVoice &); |
| 91 | }; |
| 92 | |
| 93 | #ifndef QT_NO_DEBUG_STREAM |
| 94 | Q_TEXTTOSPEECH_EXPORT QDebug operator<<(QDebug, const QVoice &); |
| 95 | #endif |
| 96 | |
| 97 | Q_DECLARE_SHARED(QVoice) |
| 98 | |
| 99 | QT_END_NAMESPACE |
| 100 | |
| 101 | Q_DECLARE_METATYPE(QVoice) |
| 102 | Q_DECLARE_METATYPE(QVoice::Age) |
| 103 | Q_DECLARE_METATYPE(QVoice::Gender) |
| 104 | |
| 105 | #endif |
| 106 | |