1// Copyright (C) 2023 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 QVOICESELECTORATTACHED_H
5#define QVOICESELECTORATTACHED_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qobject.h>
19#include <QtQml/qqml.h>
20#include <QtTextToSpeech/qvoice.h>
21
22QT_BEGIN_NAMESPACE
23
24class QDeclarativeTextToSpeech;
25
26class QVoiceSelectorAttached : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY(QVariant name READ name WRITE setName NOTIFY nameChanged FINAL)
30 Q_PROPERTY(QVoice::Gender gender READ gender WRITE setGender NOTIFY genderChanged FINAL)
31 Q_PROPERTY(QVoice::Age age READ age WRITE setAge NOTIFY ageChanged FINAL)
32 Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL)
33 Q_PROPERTY(QLocale language READ language WRITE setLanguage NOTIFY languageChanged FINAL)
34
35 QML_NAMED_ELEMENT(VoiceSelector)
36 QML_ADDED_IN_VERSION(6, 6)
37 QML_UNCREATABLE("VoiceSelector is only available via attached properties.")
38 QML_ATTACHED(QVoiceSelectorAttached)
39
40public:
41 static QVoiceSelectorAttached *qmlAttachedProperties(QObject *obj);
42
43 QVariant name() const;
44 void setName(const QVariant &name);
45
46 QVoice::Gender gender() const;
47 void setGender(QVoice::Gender gender);
48
49 QVoice::Age age() const;
50 void setAge(QVoice::Age age);
51
52 QLocale locale() const;
53 void setLocale(const QLocale &locale);
54
55 QLocale language() const;
56 void setLanguage(const QLocale &language);
57
58 QVariantMap selectionCriteria() const { return m_criteria; }
59
60public Q_SLOTS:
61 void select();
62
63Q_SIGNALS:
64 void nameChanged();
65 void genderChanged();
66 void ageChanged();
67 void localeChanged();
68 void languageChanged();
69
70private:
71 explicit QVoiceSelectorAttached(QDeclarativeTextToSpeech *tts = nullptr);
72
73 QVariantMap m_criteria;
74 QDeclarativeTextToSpeech *m_tts;
75};
76
77QT_END_NAMESPACE
78
79#endif // QVOICESELECTORATTACHED_H
80

source code of qtspeech/src/tts/qml/qvoiceselectorattached_p.h