theshell/thewaveworker.h

125 lines
2.8 KiB
C
Raw Normal View History

2016-03-29 17:42:24 +11:00
#ifndef THEWAVEWORKER_H
#define THEWAVEWORKER_H
#include <QObject>
#include <QProcess>
#include <QFrame>
#include <QSoundEffect>
#include <QSound>
#include <QUrl>
#include <QDebug>
#include <QMap>
#include <QTime>
#include <QAudioRecorder>
#include <QAudioEncoderSettings>
#include <QAudioProbe>
2016-06-03 17:26:25 +10:00
#include <QThread>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QSettings>
#include <QXmlSimpleReader>
#include <QXmlInputSource>
#include <QEventLoop>
2016-06-03 19:37:59 +10:00
#include <QDir>
#include <QApplication>
#include <QGeoPositionInfoSource>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
2016-07-06 11:33:30 +10:00
#include <qmath.h>
#include <akonadi/control.h>
#include <akonadi/servermanager.h>
#include <akonadi/session.h>
#include "menu.h"
class Menu;
2016-03-29 17:42:24 +11:00
class theWaveWorker : public QObject
{
Q_OBJECT
enum SpeechState {
Idle,
TimerGetTime,
};
2016-07-06 11:33:30 +10:00
QMap<QString, float> numberDictionary;
2016-03-29 17:42:24 +11:00
public:
explicit theWaveWorker(QObject *parent = 0);
2016-06-03 17:26:25 +10:00
~theWaveWorker();
2016-03-29 17:42:24 +11:00
signals:
void outputSpeech(QString);
void outputResponse(QString);
void loudnessChanged(qreal loudness);
2016-03-29 17:42:24 +11:00
void outputFrame(QFrame *);
void complete();
void startedListening();
void stoppedListening();
void finished();
void resetFrames();
2016-06-03 17:26:25 +10:00
void showCallFrame(bool emergency);
2016-03-29 17:42:24 +11:00
void showMessageFrame();
2016-06-03 17:26:25 +10:00
void showHelpFrame();
void showWikipediaFrame(QString title, QString text);
void launchApp(QString app);
void doLaunchApp(QString app);
void showFlightFrame(QString flight);
void showSettingsFrame(QIcon icon, QString setting, bool isOn);
2016-07-06 11:33:30 +10:00
void showMathematicsFrame(QString expression, QString answer);
2016-03-29 17:42:24 +11:00
void setTimer(QTime);
public slots:
void begin();
void endAndProcess();
2016-06-03 17:26:25 +10:00
void processSpeech(QString speech, bool voiceFeedback = true);
2016-03-29 17:42:24 +11:00
void quit();
void soundBuffer(QAudioBuffer buffer);
bool launchAkonadi();
void launchAppReply(QString app);
void launchApp_disambiguation(QStringList apps);
void currentSettingChanged(bool isOn);
2016-03-29 17:42:24 +11:00
private slots:
void outputAvailable();
void SetSetting(QString setting, bool isOn);
2016-03-29 17:42:24 +11:00
private:
QProcess *speechProc;
QString buffer;
QTime endListenTimer;
qreal oldLoudness = 0;
2016-03-29 17:42:24 +11:00
void speak(QString speech, bool restartOnceComplete = false);
SpeechState state = Idle;
QSoundEffect* startListeningSound, *okListeningSound, *errorListeningSound, *stopListeningSound;
QAudioRecorder* recorder = NULL;
QAudioProbe* probe = NULL;
2016-03-29 17:42:24 +11:00
QGeoPositionInfoSource* geolocationSource;
QGeoCoordinate currentCoordinates;
2016-03-29 17:42:24 +11:00
bool stopEverything = false;
bool resetOnNextBegin = false;
bool speechPlaying = false;
2016-06-03 17:26:25 +10:00
QString currentSetting;
2016-06-03 17:26:25 +10:00
QSettings settings;
2016-03-29 17:42:24 +11:00
};
#endif // THEWAVEWORKER_H