diff options
author | Tuomas Tuononen <tuomas.tuononen@code-q.fi> | 2015-11-25 12:35:30 +0200 |
---|---|---|
committer | Jeremy Whiting <jpwhiting@kde.org> | 2016-02-10 02:16:04 +0000 |
commit | ca8768b90c07bff5804b1fbb704041a4472f65e9 (patch) | |
tree | 717215823c535aaf8eb54724bcc484a171d9fbc7 | |
parent | de17485da6879c0173145341410738df99cc7444 (diff) |
Add engine parameters in QTextToSpeech constructor
- Some engines may need init-time parameters like resource path
Change-Id: I6992c842a132791876f895ae0f54267e640bf777
Reviewed-by: Jeremy Whiting <jpwhiting@kde.org>
Reviewed-by: Johannes Oikarinen <johannes.oikarinen@theqtcompany.com>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
-rw-r--r-- | src/tts/qtexttospeech.cpp | 13 | ||||
-rw-r--r-- | src/tts/qtexttospeech.h | 2 | ||||
-rw-r--r-- | src/tts/qtexttospeech_p.h | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/tts/qtexttospeech.cpp b/src/tts/qtexttospeech.cpp index 0d381a1..7157318 100644 --- a/src/tts/qtexttospeech.cpp +++ b/src/tts/qtexttospeech.cpp @@ -53,7 +53,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, QMutex QTextToSpeechPrivate::m_mutex; -QTextToSpeechPrivate::QTextToSpeechPrivate(QTextToSpeech *speech, const QString &engine) +QTextToSpeechPrivate::QTextToSpeechPrivate(QTextToSpeech *speech, const QString &engine, const QVariantMap ¶meters) : m_engine(0), m_speech(speech), m_providerName(engine), @@ -73,10 +73,9 @@ QTextToSpeechPrivate::QTextToSpeechPrivate(QTextToSpeech *speech, const QString loadPlugin(); if (m_plugin) { QString errorString; - m_engine = m_plugin->createTextToSpeechEngine(QVariantMap(), 0, &errorString); + m_engine = m_plugin->createTextToSpeechEngine(parameters, 0, &errorString); if (!m_engine) { - qCritical() << "Error creating text-to-speech engine" << m_providerName - << (errorString.isEmpty() ? QStringLiteral("") : (QStringLiteral(": ") + errorString)); + qCritical() << "Error creating text-to-speech engine" << m_providerName << errorString; } } else { qCritical() << "Error loading text-to-speech plug-in" << m_providerName; @@ -192,12 +191,14 @@ void QTextToSpeechPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list) If \a engine is empty, the default engine plug-in is used. The default engine may be platform-specific. + The method optionally accepts \a parameters that may be engine-specific. + If loading the plug-in fails, QTextToSpeech::state() will return QTextToSpeech::BackendError. \sa availableEngines() */ -QTextToSpeech::QTextToSpeech(QObject *parent, const QString &engine) - : QObject(*new QTextToSpeechPrivate(this, engine), parent) +QTextToSpeech::QTextToSpeech(QObject *parent, const QString &engine, const QVariantMap ¶meters) + : QObject(*new QTextToSpeechPrivate(this, engine, parameters), parent) { Q_D(QTextToSpeech); qRegisterMetaType<QTextToSpeech::State>(); diff --git a/src/tts/qtexttospeech.h b/src/tts/qtexttospeech.h index 8142e32..bcbe511 100644 --- a/src/tts/qtexttospeech.h +++ b/src/tts/qtexttospeech.h @@ -70,7 +70,7 @@ public: BackendError }; - explicit QTextToSpeech(QObject *parent = 0, const QString &engine = QString()); + explicit QTextToSpeech(QObject *parent = 0, const QString &engine = QString(), const QVariantMap ¶meters = QVariantMap()); State state() const; QVector<QLocale> availableLocales() const; diff --git a/src/tts/qtexttospeech_p.h b/src/tts/qtexttospeech_p.h index c6e213e..45c0395 100644 --- a/src/tts/qtexttospeech_p.h +++ b/src/tts/qtexttospeech_p.h @@ -61,7 +61,7 @@ class QTextToSpeech; class QTextToSpeechPrivate : public QObjectPrivate { public: - QTextToSpeechPrivate(QTextToSpeech *speech, const QString &engine); + QTextToSpeechPrivate(QTextToSpeech *speech, const QString &engine, const QVariantMap ¶meters); ~QTextToSpeechPrivate(); static QHash<QString, QJsonObject> plugins(bool reload = false); |