diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-06-13 16:13:17 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-06-20 12:45:07 +0200 |
commit | c623f5fa124b7f23d8aa1f3d916ff87c9923e670 (patch) | |
tree | 6bbbad434f542f684330e711e6b9c9fdf01bb378 /src | |
parent | 31f9c944ddde1832b25f55a72b0632777a61cec9 (diff) |
Header cleanup
- add trailing comma for enums to minimize diff for future additions
- remove unnecessarily inline keyword
- use q20::remove_cvref_t instead of std::decay_t so that we don't decay
arrays
- remove unncessary parenths
- add semi-public API warning to plugin headers
Pick-to: 6.6
Change-Id: I2608bf2e3feff968d0404b20c1cb00a28da5c02c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/tts/qtexttospeech.h | 41 | ||||
-rw-r--r-- | src/tts/qtexttospeechengine.h | 10 | ||||
-rw-r--r-- | src/tts/qtexttospeechplugin.h | 10 | ||||
-rw-r--r-- | src/tts/qvoice.h | 2 |
4 files changed, 42 insertions, 21 deletions
diff --git a/src/tts/qtexttospeech.h b/src/tts/qtexttospeech.h index 8b4bd17..a9e18b5 100644 --- a/src/tts/qtexttospeech.h +++ b/src/tts/qtexttospeech.h @@ -8,11 +8,12 @@ #define QTEXTTOSPEECH_H #include <QtTextToSpeech/qtexttospeech_global.h> +#include <QtTextToSpeech/qvoice.h> #include <QtCore/qobject.h> #include <QtCore/qshareddata.h> -#include <QtCore/QSharedDataPointer> #include <QtCore/qlocale.h> -#include <QtTextToSpeech/qvoice.h> + +#include <QtCore/q20type_traits.h> QT_BEGIN_NAMESPACE @@ -39,7 +40,7 @@ public: Speaking, Paused, Error, - Synthesizing + Synthesizing, }; Q_ENUM(State) @@ -48,7 +49,7 @@ public: Initialization, Configuration, Input, - Playback + Playback, }; Q_ENUM(ErrorReason) @@ -57,7 +58,7 @@ public: Immediate, Word, Sentence, - Utterance + Utterance, }; Q_ENUM(BoundaryHint) @@ -128,19 +129,19 @@ public: synthesize(text, nullptr, std::forward<Functor>(func)); } - template<typename ...Args> - inline QList<QVoice> findVoices(Args &&...args) const + template <typename ...Args> + QList<QVoice> findVoices(Args &&...args) const { // if any of the arguments is a locale, then we can avoid iterating through all // and only have to search through the voices for that locale. QLocale locale; QLocale *plocale = nullptr; - if constexpr (std::disjunction_v<std::is_same<std::decay_t<Args>, QLocale>...>) { + if constexpr (std::disjunction_v<std::is_same<q20::remove_cvref_t<Args>, QLocale>...>) { locale = std::get<QLocale>(std::make_tuple(args...)); plocale = &locale; } - auto voices(allVoices(plocale)); + auto voices = allVoices(plocale); if constexpr (sizeof...(args) > 0) findVoicesImpl(voices, std::forward<Args>(args)...); return voices; @@ -204,24 +205,24 @@ private: static constexpr qsizetype value = lastIndexOf(std::make_integer_sequence<qsizetype, sizeof...(Ts)>{}); }; - template<typename Arg0, typename ...Args> - inline void findVoicesImpl(QList<QVoice> &voices, Arg0 &&arg0, Args &&...args) const + template <typename Arg0, typename ...Args> + void findVoicesImpl(QList<QVoice> &voices, Arg0 &&arg0, Args &&...args) const { - using ArgType = std::decay_t<Arg0>; - voices.removeIf([=](const auto &voice){ + using ArgType = q20::remove_cvref_t<Arg0>; + voices.removeIf([&](const auto &voice){ if constexpr (std::is_same_v<ArgType, QLocale>) { - return (voice.locale() != arg0); + return voice.locale() != arg0; } else if constexpr (std::is_same_v<ArgType, QLocale::Language>) { - return (voice.locale().language() != arg0); + return voice.locale().language() != arg0; } else if constexpr (std::is_same_v<ArgType, QLocale::Territory>) { - return (voice.locale().territory() != arg0); + return voice.locale().territory() != arg0; } else if constexpr (std::is_same_v<ArgType, QVoice::Gender>) { - return (voice.gender() != arg0); + return voice.gender() != arg0; } else if constexpr (std::is_same_v<ArgType, QVoice::Age>) { - return (voice.age() != arg0); + return voice.age() != arg0; } else if constexpr (std::disjunction_v<std::is_convertible<ArgType, QString>, std::is_convertible<ArgType, QStringView>>) { - return (voice.name() != arg0); + return voice.name() != arg0; } else if constexpr (std::is_same_v<ArgType, QRegularExpression>) { return !arg0.match(voice.name()).hasMatch(); } else { @@ -231,7 +232,7 @@ private: } }); if constexpr (sizeof...(args) > 0) { - static_assert(LastIndexOf<ArgType, std::tuple<std::decay_t<Args>...>>::value == -1, + static_assert(LastIndexOf<ArgType, std::tuple<q20::remove_cvref_t<Args>...>>::value == -1, "Using multiple criteria of the same type is not supported"); findVoicesImpl(voices, std::forward<Args>(args)...); } diff --git a/src/tts/qtexttospeechengine.h b/src/tts/qtexttospeechengine.h index fe02ff9..b62d2d1 100644 --- a/src/tts/qtexttospeechengine.h +++ b/src/tts/qtexttospeechengine.h @@ -4,6 +4,16 @@ #ifndef QTEXTTOSPEECHENGINE_H #define QTEXTTOSPEECHENGINE_H +// +// W A R N I N G +// ------------- +// +// This file is part of the Qt TextToSpeech plugin API, with limited compatibility +// guarantees. +// Usage of this API may make your code source and binary incompatible with +// future versions of Qt. +// + #include <QtTextToSpeech/qtexttospeech.h> #include <QtCore/QObject> diff --git a/src/tts/qtexttospeechplugin.h b/src/tts/qtexttospeechplugin.h index b29a5c2..3ae9155 100644 --- a/src/tts/qtexttospeechplugin.h +++ b/src/tts/qtexttospeechplugin.h @@ -4,6 +4,16 @@ #ifndef QTEXTTOSPEECHPLUGIN_H #define QTEXTTOSPEECHPLUGIN_H +// +// W A R N I N G +// ------------- +// +// This file is part of the Qt TextToSpeech plugin API, with limited compatibility +// guarantees. +// Usage of this API may make your code source and binary incompatible with +// future versions of Qt. +// + #include <QtTextToSpeech/qtexttospeechengine.h> #include <QtCore/QtPlugin> diff --git a/src/tts/qvoice.h b/src/tts/qvoice.h index 78c04b2..286c137 100644 --- a/src/tts/qvoice.h +++ b/src/tts/qvoice.h @@ -69,7 +69,7 @@ public: Gender gender() const; Age age() const; - inline QLocale::Language language() const { return locale().language(); } + QLocale::Language language() const { return locale().language(); } static QString genderName(QVoice::Gender gender); static QString ageName(QVoice::Age age); |