mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-22 06:19:01 +00:00
Add a new QtTextToSpeech backend
This commit is contained in:
parent
cb4c38411a
commit
7c21be4e26
@ -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)
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,19 @@
|
||||
#include "speech.h"
|
||||
|
||||
Speech::Speech(QObject *parent) : QObject(parent)
|
||||
#include <QtTextToSpeech/QTextToSpeech>
|
||||
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()));
|
||||
}
|
||||
|
@ -1,17 +1,23 @@
|
||||
#ifndef SPEECH_H
|
||||
#define SPEECH_H
|
||||
|
||||
#include <QObject>
|
||||
#include <plugins/snoresecondarybackend.h>
|
||||
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user