diff --git a/src/plugins/secondary_backends/CMakeLists.txt b/src/plugins/secondary_backends/CMakeLists.txt index 332a366..1ab2117 100644 --- a/src/plugins/secondary_backends/CMakeLists.txt +++ b/src/plugins/secondary_backends/CMakeLists.txt @@ -1,4 +1,5 @@ ecm_optional_add_subdirectory(toasty) ecm_optional_add_subdirectory(nma) ecm_optional_add_subdirectory(sound) +ecm_optional_add_subdirectory(speech) ecm_optional_add_subdirectory(pushover_backend) diff --git a/src/plugins/secondary_backends/sound/sound.cpp b/src/plugins/secondary_backends/sound/sound.cpp index 5987d67..96f6e0e 100644 --- a/src/plugins/secondary_backends/sound/sound.cpp +++ b/src/plugins/secondary_backends/sound/sound.cpp @@ -28,7 +28,7 @@ Sound::Sound(): // connect(m_player,QMediaPlayer::positionChanged,[](qint64 pos){ // qCDebug(SNORE) << "Player: " << pos; // }); - connect(m_player, &QMediaPlayer::stateChanged, [](QMediaPlayer::State state) { + connect(m_player, &QMediaPlayer::stateChanged, this, [](QMediaPlayer::State state) { qCDebug(SNORE) << "Player: " << state; }); } diff --git a/src/plugins/secondary_backends/speech/speech.cpp b/src/plugins/secondary_backends/speech/speech.cpp index 05507a0..9faffff 100644 --- a/src/plugins/secondary_backends/speech/speech.cpp +++ b/src/plugins/secondary_backends/speech/speech.cpp @@ -1,6 +1,19 @@ #include "speech.h" -Speech::Speech(QObject *parent) : QObject(parent) +#include +Speech::Speech() + : Snore::SnoreSecondaryBackend() + , m_speech(new QTextToSpeech(this)) { - + connect(m_speech, &QTextToSpeech::stateChanged, this, [this](QTextToSpeech::State state){ + qCDebug(SNORE) << state; + if (state == QTextToSpeech::BackendError) { + setErrorString(tr("Sytem Backend Error")); + } + }); +} + +void Speech::slotNotificationDisplayed(Snore::Notification notification) +{ + m_speech->say(tr("%1: %2 %3").arg(notification.application().name(), notification.title(), notification.text())); } diff --git a/src/plugins/secondary_backends/speech/speech.h b/src/plugins/secondary_backends/speech/speech.h index 1c8bc90..db558e1 100644 --- a/src/plugins/secondary_backends/speech/speech.h +++ b/src/plugins/secondary_backends/speech/speech.h @@ -1,17 +1,23 @@ #ifndef SPEECH_H #define SPEECH_H -#include +#include -class Speech : public QObject +class QTextToSpeech; + +class Speech : public Snore::SnoreSecondaryBackend { Q_OBJECT + Q_INTERFACES(Snore::SnoreSecondaryBackend) + Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0" FILE "snore_plugin.json") public: - explicit Speech(QObject *parent = 0); + explicit Speech(); + ~Speech() = default; -signals: - -public slots: +public Q_SLOTS: + void slotNotificationDisplayed(Snore::Notification notification) override; +private: + QTextToSpeech *m_speech; }; -#endif // SPEECH_H \ No newline at end of file +#endif // SPEECH_H