summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/speech/hello_speak/mainwindow.cpp2
-rw-r--r--src/tts/qtexttospeech.cpp25
-rw-r--r--src/tts/qtexttospeech.h3
3 files changed, 26 insertions, 4 deletions
diff --git a/examples/speech/hello_speak/mainwindow.cpp b/examples/speech/hello_speak/mainwindow.cpp
index b496cda..6f2f300 100644
--- a/examples/speech/hello_speak/mainwindow.cpp
+++ b/examples/speech/hello_speak/mainwindow.cpp
@@ -103,7 +103,7 @@ void MainWindow::engineSelected(int index)
if (engineName == "default")
m_speech = new QTextToSpeech(this);
else
- m_speech = new QTextToSpeech(this, engineName);
+ m_speech = new QTextToSpeech(engineName, QVariantMap(), this);
disconnect(ui.language, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MainWindow::languageSelected);
ui.language->clear();
// Populate the languages combobox before connecting its signal.
diff --git a/src/tts/qtexttospeech.cpp b/src/tts/qtexttospeech.cpp
index 7157318..0fe752e 100644
--- a/src/tts/qtexttospeech.cpp
+++ b/src/tts/qtexttospeech.cpp
@@ -59,6 +59,7 @@ QTextToSpeechPrivate::QTextToSpeechPrivate(QTextToSpeech *speech, const QString
m_providerName(engine),
m_plugin(0)
{
+ qRegisterMetaType<QTextToSpeech::State>();
if (m_providerName.isEmpty()) {
m_providerName = QTextToSpeech::availableEngines().value(0);
if (m_providerName.isEmpty()) {
@@ -185,6 +186,27 @@ void QTextToSpeechPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list)
*/
/*!
+ Loads a text-to-speech engine from a plug-in that uses the default
+ engine plug-in and constructs a QTextToSpeech object as the child
+ of \a parent.
+
+ The default engine may be platform-specific.
+
+ If loading the plug-in fails, QTextToSpeech::state() will return
+ QTextToSpeech::BackendError.
+
+ \sa availableEngines()
+*/
+QTextToSpeech::QTextToSpeech(QObject *parent)
+ : QObject(*new QTextToSpeechPrivate(this, QString(), QVariantMap()), parent)
+{
+ Q_D(QTextToSpeech);
+ // Connect state change signal directly from the engine to the public API signal
+ if (d->m_engine)
+ connect(d->m_engine, &QTextToSpeechEngine::stateChanged, this, &QTextToSpeech::stateChanged);
+}
+
+/*!
Loads a text-to-speech engine from a plug-in that matches parameter \a engine and
constructs a QTextToSpeech object as the child of \a parent.
@@ -197,11 +219,10 @@ void QTextToSpeechPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list)
\sa availableEngines()
*/
-QTextToSpeech::QTextToSpeech(QObject *parent, const QString &engine, const QVariantMap &parameters)
+QTextToSpeech::QTextToSpeech(const QString &engine, const QVariantMap &parameters, QObject *parent)
: QObject(*new QTextToSpeechPrivate(this, engine, parameters), parent)
{
Q_D(QTextToSpeech);
- qRegisterMetaType<QTextToSpeech::State>();
// Connect state change signal directly from the engine to the public API signal
if (d->m_engine)
connect(d->m_engine, &QTextToSpeechEngine::stateChanged, this, &QTextToSpeech::stateChanged);
diff --git a/src/tts/qtexttospeech.h b/src/tts/qtexttospeech.h
index bcbe511..bd35c8f 100644
--- a/src/tts/qtexttospeech.h
+++ b/src/tts/qtexttospeech.h
@@ -70,7 +70,8 @@ public:
BackendError
};
- explicit QTextToSpeech(QObject *parent = 0, const QString &engine = QString(), const QVariantMap &parameters = QVariantMap());
+ explicit QTextToSpeech(QObject *parent = Q_NULLPTR);
+ explicit QTextToSpeech(const QString &engine, const QVariantMap &parameters = QVariantMap(), QObject *parent = Q_NULLPTR);
State state() const;
QVector<QLocale> availableLocales() const;