mirror of
https://github.com/vicr123/theshell.git
synced 2025-01-23 04:11:49 -05:00
Move theWave, add extra features
This commit is contained in:
parent
29efacf123
commit
f957255f6c
10 changed files with 1050 additions and 38 deletions
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1251</width>
|
||||
<height>81</height>
|
||||
<height>83</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -83,8 +83,8 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="mic-on">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
<iconset theme="thewave" resource="resources.qrc">
|
||||
<normaloff>:/icons/thewave.svg</normaloff>:/icons/thewave.svg</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
|
|
189
menu.cpp
189
menu.cpp
|
@ -11,12 +11,20 @@ Menu::Menu(QWidget *parent) :
|
|||
ui->setupUi(this);
|
||||
|
||||
ui->offFrame->setParent(this);
|
||||
ui->thewaveFrame->setParent(this);
|
||||
this->layout()->removeWidget(ui->offFrame);
|
||||
this->layout()->removeWidget(ui->thewaveFrame);
|
||||
ui->offFrame->setGeometry(10, -this->height(), this->width() - 20, this->height() - 20);
|
||||
ui->thewaveFrame->setGeometry(10, -this->height(), this->width() - 20, this->height() - 20);
|
||||
ui->commandLinkButton->setStyleSheet("background-color: #A00;");
|
||||
ui->commandLinkButton_2->setStyleSheet("background-color: #A00;");
|
||||
ui->timerIcon->setPixmap(QIcon::fromTheme("player-time").pixmap(16));
|
||||
ui->userIcon->setPixmap(QIcon::fromTheme("system-users").pixmap(16));
|
||||
ui->timeIcon->setPixmap(QIcon::fromTheme("player-time").pixmap(32));
|
||||
ui->callIcon->setPixmap(QIcon::fromTheme("call-start").pixmap(32));
|
||||
ui->messageIcon->setPixmap(QIcon::fromTheme("message-send").pixmap(32));
|
||||
ui->launchIcon->setPixmap(QIcon::fromTheme("system-run").pixmap(32));
|
||||
ui->infoIcon->setPixmap(QIcon::fromTheme("text-html").pixmap(32));
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
|
@ -131,6 +139,14 @@ void Menu::show() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
App *waveApp = new App();
|
||||
waveApp->setCommand("thewave");
|
||||
waveApp->setIcon(QIcon(":/icons/thewave.svg"));
|
||||
waveApp->setName("theWave");
|
||||
waveApp->setDescription("Personal Assistant");
|
||||
apps->append(waveApp);
|
||||
|
||||
//hotkeyManager->registerHotkey("Power");
|
||||
|
||||
for (App *app : *apps) {
|
||||
|
@ -277,28 +293,16 @@ void Menu::on_commandLinkButton_3_clicked()
|
|||
|
||||
void Menu::on_listWidget_itemClicked(QListWidgetItem *item)
|
||||
{
|
||||
/*for (App* app : *appsShown) {
|
||||
bool correctApp = false;
|
||||
if (item->text().contains("|")) {
|
||||
if (app->name() == item->text().split("|")[1].remove(0, 1)) {
|
||||
correctApp = true;
|
||||
}
|
||||
} else if (app->name() == item->text()) {
|
||||
correctApp = true;
|
||||
if (item->data(Qt::UserRole).toString().startsWith("thewave")) {
|
||||
ui->activateTheWave->click();
|
||||
if (item->data(Qt::UserRole).toString().split(":").count() > 1) {
|
||||
ui->thewave_line->setText(item->data(Qt::UserRole).toString().split(":").at(1));
|
||||
on_thewave_line_returnPressed();
|
||||
}
|
||||
if (correctApp) {
|
||||
QProcess::startDetached(app->command().remove("%u"));
|
||||
emit appOpening(app->name(), app->icon());
|
||||
this->close();
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
|
||||
QProcess::startDetached(item->data(Qt::UserRole).toString().remove("%u"));
|
||||
//emit appOpening(app->name(), app->icon());
|
||||
this->close();
|
||||
|
||||
//App *app = appsShown->at(ui->listWidget->selectionModel()->selectedIndexes().at(0).row());
|
||||
} else {
|
||||
QProcess::startDetached(item->data(Qt::UserRole).toString().remove("%u"));
|
||||
this->close();
|
||||
}
|
||||
}
|
||||
void Menu::on_lineEdit_textChanged(const QString &arg1)
|
||||
{
|
||||
|
@ -414,6 +418,12 @@ void Menu::on_lineEdit_textEdited(const QString &arg1)
|
|||
ui->listWidget->addItem(i);
|
||||
}
|
||||
}
|
||||
|
||||
QListWidgetItem *wave = new QListWidgetItem();
|
||||
wave->setText("Ask theWave about \"" + arg1 + "\"");
|
||||
wave->setIcon(QIcon(":/icons/thewave.svg"));
|
||||
wave->setData(Qt::UserRole, "thewave:" + arg1);
|
||||
ui->listWidget->addItem(wave);
|
||||
}
|
||||
|
||||
bool Menu::eventFilter(QObject *object, QEvent *event) {
|
||||
|
@ -490,3 +500,140 @@ void Menu::on_commandLinkButton_8_clicked()
|
|||
this->close();
|
||||
QProcess::startDetached("xset dpms force off");
|
||||
}
|
||||
|
||||
void Menu::on_activateTheWave_clicked()
|
||||
{
|
||||
this->resetFrames();
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(ui->thewaveFrame, "geometry");
|
||||
anim->setStartValue(QRect(10, this->height(), this->width() - 20, this->height() - 20));
|
||||
anim->setEndValue(QRect(10, 10, this->width() - 20, this->height() - 20));
|
||||
anim->setDuration(500);
|
||||
|
||||
anim->setEasingCurve(QEasingCurve::OutCubic);
|
||||
|
||||
anim->start();
|
||||
|
||||
QThread *t = new QThread();
|
||||
waveWorker = new theWaveWorker();
|
||||
waveWorker->moveToThread(t);
|
||||
//connect(t, SIGNAL(started()), waveWorker, SLOT(begin()));
|
||||
connect(t, &QThread::started, [=]() {
|
||||
this->istheWaveReady = true;
|
||||
});
|
||||
connect(waveWorker, SIGNAL(finished()), waveWorker, SLOT(deleteLater()));
|
||||
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
|
||||
connect(waveWorker, &theWaveWorker::outputResponse, [=](QString response) {
|
||||
ui->thewave_response->setText(response);
|
||||
|
||||
});
|
||||
connect(waveWorker, &theWaveWorker::outputSpeech, [=](QString speech) {
|
||||
ui->thewave_line->setText(speech);
|
||||
});
|
||||
connect(waveWorker, &theWaveWorker::startedListening, [=]() {
|
||||
//ui->pushButton->setIcon(QIcon::fromTheme("mic-on"));
|
||||
isListening = true;
|
||||
});
|
||||
connect(waveWorker, &theWaveWorker::stoppedListening, [=]() {
|
||||
//ui->pushButton->setIcon(QIcon::fromTheme("mic-off"));
|
||||
isListening = false;
|
||||
});
|
||||
connect(waveWorker, SIGNAL(showCallFrame(bool)), this, SLOT(showCallFrame(bool)));
|
||||
connect(waveWorker, SIGNAL(resetFrames()), this, SLOT(resetFrames()));
|
||||
connect(waveWorker, SIGNAL(showMessageFrame()), this, SLOT(showMessageFrame()));
|
||||
connect(waveWorker, SIGNAL(showHelpFrame()), this, SLOT(showHelpFrame()));
|
||||
connect(waveWorker, SIGNAL(showWikipediaFrame(QString,QString)), this, SLOT(showWikipediaFrame(QString,QString)));
|
||||
connect(waveWorker, SIGNAL(launchApp(QString)), this, SLOT(thewave_launchapp(QString)));
|
||||
connect(waveWorker, SIGNAL(setTimer(QTime)), MainWin->getInfoPane(), SLOT(startTimer(QTime)));
|
||||
connect(this, SIGNAL(thewave_processText(QString,bool)), waveWorker, SLOT(processSpeech(QString,bool)));
|
||||
connect(ui->listentheWave, SIGNAL(clicked(bool)), waveWorker, SLOT(begin()));
|
||||
/*connect(w, &speechWorker::outputFrame, [=](QFrame *frame) {
|
||||
ui->frame->layout()->addWidget(frame);
|
||||
});*/
|
||||
|
||||
t->start();
|
||||
}
|
||||
|
||||
void Menu::on_closetheWaveButton_clicked()
|
||||
{
|
||||
this->istheWaveReady = false;
|
||||
this->resetFrames();
|
||||
ui->thewave_response->setText("Hit \"Speak\" to start speaking.");
|
||||
ui->thewave_line->setText("");
|
||||
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(ui->thewaveFrame, "geometry");
|
||||
anim->setStartValue(QRect(10, 10, this->width() - 20, this->height() - 20));
|
||||
anim->setEndValue(QRect(10, this->height(), this->width() - 20, this->height() - 20));
|
||||
anim->setDuration(500);
|
||||
anim->setEasingCurve(QEasingCurve::OutCubic);
|
||||
|
||||
anim->start();
|
||||
|
||||
waveWorker->deleteLater();
|
||||
}
|
||||
|
||||
void Menu::showCallFrame(bool emergency) {
|
||||
ui->thewave_callFrame->setVisible(true);
|
||||
}
|
||||
|
||||
void Menu::showMessageFrame() {
|
||||
ui->thewave_messageframe->setVisible(true);
|
||||
}
|
||||
|
||||
void Menu::showHelpFrame() {
|
||||
ui->thewave_helpFrame->setVisible(true);
|
||||
}
|
||||
|
||||
void Menu::resetFrames() {
|
||||
ui->thewave_callFrame->setVisible(false);
|
||||
ui->thewave_messageframe->setVisible(false);
|
||||
ui->thewave_helpFrame->setVisible(false);
|
||||
ui->wikipediaFrame->setVisible(false);
|
||||
ui->thewave_spacerFrame->setVisible(true);
|
||||
ui->thewave_launchFrame->setVisible(false);
|
||||
}
|
||||
|
||||
void Menu::showWikipediaFrame(QString title, QString text) {
|
||||
ui->wikipediaTitle->setText(title);
|
||||
ui->wikipediaText->setHtml(text);
|
||||
ui->wikipediaFrame->setVisible(true);
|
||||
ui->thewave_spacerFrame->setVisible(false);
|
||||
}
|
||||
|
||||
void Menu::on_thewave_line_returnPressed()
|
||||
{
|
||||
while (!istheWaveReady) {
|
||||
QApplication::processEvents();
|
||||
}
|
||||
emit thewave_processText(ui->thewave_line->text());
|
||||
}
|
||||
|
||||
void Menu::on_closetheWaveButton_2_clicked()
|
||||
{
|
||||
QProcess::startDetached("xdg-open https://en.wikipedia.org/wiki/" + ui->wikipediaTitle->text().replace(" ", "_"));
|
||||
this->close();
|
||||
}
|
||||
|
||||
void Menu::thewave_launchapp(QString appName) {
|
||||
bool foundApp = false;
|
||||
ui->thewave_launchFrame->setVisible(true);
|
||||
for (App *app : *apps) {
|
||||
if (app->name().remove(" ").contains(appName.remove(" "), Qt::CaseInsensitive)) {
|
||||
foundApp = true;
|
||||
ui->thewave_launch_appName->setText(app->name());
|
||||
ui->thewave_launch_appIcon->setPixmap(app->icon().pixmap(64));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundApp) {
|
||||
ui->thewave_launch_appIcon->setVisible(true);
|
||||
ui->thewave_launch_appName->setVisible(true);
|
||||
ui->thewave_launch_error->setVisible(false);
|
||||
ui->thewave_launch_launchapp->setVisible(true);
|
||||
} else {
|
||||
ui->thewave_launch_appIcon->setVisible(false);
|
||||
ui->thewave_launch_appName->setVisible(false);
|
||||
ui->thewave_launch_error->setVisible(true);
|
||||
ui->thewave_launch_launchapp->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
|
27
menu.h
27
menu.h
|
@ -17,6 +17,7 @@
|
|||
#include "endsessionwait.h"
|
||||
#include "app.h"
|
||||
#include "mainwindow.h"
|
||||
#include "thewaveworker.h"
|
||||
|
||||
#undef KeyPress
|
||||
|
||||
|
@ -42,6 +43,8 @@ signals:
|
|||
void appOpening(QString name, QIcon icon);
|
||||
void menuClosing();
|
||||
|
||||
void thewave_processText(QString text, bool isText = false);
|
||||
|
||||
private slots:
|
||||
void checkForclose();
|
||||
|
||||
|
@ -73,6 +76,26 @@ private slots:
|
|||
|
||||
void on_commandLinkButton_8_clicked();
|
||||
|
||||
void on_activateTheWave_clicked();
|
||||
|
||||
void on_closetheWaveButton_clicked();
|
||||
|
||||
void showCallFrame(bool emergency);
|
||||
|
||||
void resetFrames();
|
||||
|
||||
void showMessageFrame();
|
||||
|
||||
void showHelpFrame();
|
||||
|
||||
void showWikipediaFrame(QString title, QString text);
|
||||
|
||||
void thewave_launchapp(QString app);
|
||||
|
||||
void on_thewave_line_returnPressed();
|
||||
|
||||
void on_closetheWaveButton_2_clicked();
|
||||
|
||||
private:
|
||||
Ui::Menu *ui;
|
||||
|
||||
|
@ -86,6 +109,10 @@ private:
|
|||
//void closeEvent(QCloseEvent *event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void changeEvent(QEvent* event);
|
||||
|
||||
theWaveWorker* waveWorker;
|
||||
bool isListening;
|
||||
bool istheWaveReady = false;
|
||||
};
|
||||
|
||||
#endif // MENU_H
|
||||
|
|
624
menu.ui
624
menu.ui
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>560</width>
|
||||
<height>1084</height>
|
||||
<height>2545</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -161,6 +161,23 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="activateTheWave">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="thewave" resource="resources.qrc">
|
||||
<normaloff>:/icons/thewave.svg</normaloff>:/icons/thewave.svg</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
|
@ -340,7 +357,8 @@
|
|||
<string>Turn Off Screen</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="video-display"/>
|
||||
<iconset theme="video-display">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -498,6 +516,608 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="thewaveFrame">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>theWave</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="thewave_line">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="thewave_response">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hit "Speak" to start speaking.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="thewave_callFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Call</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Phone Number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Can't call from this device.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Call</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="call-start">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="thewave_messageframe">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSpeech_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="inputMask">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Phone Number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_4">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Can't send messages from this device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="mail-send">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="thewave_helpFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSpeech_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Try these:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="timeIcon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>I can help you set a timer.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="callIcon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>If you're on a supported device, I can place calls for you</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="messageIcon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>If you have supported software, I can send instant messages, or if you are on a supported device, I can send text messages.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="infoIcon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>I can get information from online sources</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="launchIcon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>I can open apps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="wikipediaFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSpeech_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wikipedia</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="wikipediaTitle">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Title of page.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="wikipediaText">
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Abel'; font-size:12pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Text</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closetheWaveButton_2">
|
||||
<property name="text">
|
||||
<string>Open in Browser</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="text-html">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="thewave_launchFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QLabel" name="launchapp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Launch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="thewave_launch_error">
|
||||
<property name="text">
|
||||
<string>Couldn't find the app you wanted to launch.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="thewave_launch_appIcon">
|
||||
<property name="text">
|
||||
<string>appIcon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="thewave_launch_appName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>20</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>App Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="thewave_launch_launchapp">
|
||||
<property name="text">
|
||||
<string>Launch</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="thewave_spacerFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="listentheWave">
|
||||
<property name="text">
|
||||
<string>Speak</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="mic-on">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closetheWaveButton">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="window-close">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
|
|
|
@ -15,5 +15,6 @@
|
|||
</qresource>
|
||||
<qresource prefix="/icons">
|
||||
<file>icon.svg</file>
|
||||
<file>thewave.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui gui-private x11extras dbus multimedia
|
||||
QT += core gui gui-private x11extras dbus multimedia xml network
|
||||
CONFIG += c++11
|
||||
LIBS += -lX11 -lxcb -lxcb-keysyms -lcups -lsystemd
|
||||
|
||||
|
|
145
thewave.svg
Normal file
145
thewave.svg
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="48"
|
||||
height="48"
|
||||
viewBox="0 0 48 48.000001"
|
||||
id="svg4207"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="thewave.svg">
|
||||
<defs
|
||||
id="defs4209">
|
||||
<linearGradient
|
||||
id="linearGradient5737"
|
||||
osb:paint="solid">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop5739" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4763">
|
||||
<stop
|
||||
style="stop-color:#646400;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop4765" />
|
||||
<stop
|
||||
style="stop-color:#c8c800;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop4767" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4763"
|
||||
id="linearGradient4769"
|
||||
x1="3"
|
||||
y1="1049.3622"
|
||||
x2="45"
|
||||
y2="1007.3622"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.047619,0,0,1.047619,-1.1428552,-1053.3318)" />
|
||||
<filter
|
||||
style="color-interpolation-filters:sRGB"
|
||||
id="filter4279"
|
||||
inkscape:label="filter1">
|
||||
<feGaussianBlur
|
||||
stdDeviation="6"
|
||||
id="feGaussianBlur4285" />
|
||||
</filter>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#000000"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="32.762357"
|
||||
inkscape:cy="31.145584"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
units="px"
|
||||
inkscape:window-width="1280"
|
||||
inkscape:window-height="757"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid4757"
|
||||
snapvisiblegridlinesonly="false"
|
||||
originx="2.7755576e-17"
|
||||
originy="2.4980019e-16"
|
||||
spacingx="1"
|
||||
spacingy="1"
|
||||
dotted="false"
|
||||
empspacing="4" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata4212">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-1004.3622)">
|
||||
<path
|
||||
style="opacity:1;fill:url(#linearGradient4769);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 24 2 A 22 22 0 0 0 19.328125 2.515625 A 12 12 0 0 1 24 12 A 12 12 0 0 1 12 24 A 12 12 0 0 1 2.5234375 19.353516 A 22 22 0 0 0 2 24 A 22 22 0 0 0 2.0078125 24.177734 C 5.4851324 24.785533 7.7203862 26.892261 9.4140625 28.585938 C 11.414062 30.585938 12.666667 32 16 32 C 19.333333 32 20.585938 30.585938 22.585938 28.585938 C 24.585938 26.585938 27.333333 24 32 24 C 36.666667 24 39.414062 26.585938 41.414062 28.585938 C 42.579808 29.751682 43.500807 30.706925 44.71875 31.310547 A 22 22 0 0 0 46 24 A 22 22 0 0 0 24 2 z M 32 28 C 28.666667 28 27.414062 29.416016 25.414062 31.416016 C 23.414062 33.416016 20.666667 36 16 36 C 11.333333 36 8.5859375 33.416016 6.5859375 31.416016 C 5.1821671 30.012245 4.1335587 28.907868 2.4882812 28.367188 A 22 22 0 0 0 24 46 A 22 22 0 0 0 35.589844 42.648438 A 5 5 0 0 1 34 39 A 5 5 0 0 1 39 34 A 5 5 0 0 1 42.652344 35.591797 A 22 22 0 0 0 43.064453 34.855469 C 41.172557 33.92066 39.746101 32.576179 38.585938 31.416016 C 36.585938 29.416016 35.333333 28 32 28 z "
|
||||
id="path4761"
|
||||
transform="translate(0,1004.3622)" />
|
||||
<g
|
||||
id="g4157">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4771"
|
||||
d="m 54,1025.3622 -3,3 3,3 0,0 0,0"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4773"
|
||||
d="m 51,1028.3622 6,0"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
</g>
|
||||
<g
|
||||
id="g4153">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4801"
|
||||
d="m 21,998.3622 3,3 3,-3"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4803"
|
||||
d="m 24,1001.3622 0,-6"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
</g>
|
||||
<g
|
||||
id="g4254"
|
||||
transform="translate(1.4285711,1.1071)"
|
||||
style="stroke-width:1.39999998;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 5.5 KiB |
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>585</width>
|
||||
<height>460</height>
|
||||
<height>465</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -32,8 +32,8 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="mic-off">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/thewave.svg</normaloff>:/icons/thewave.svg</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
|
|
@ -44,6 +44,10 @@ theWaveWorker::theWaveWorker(QObject *parent) : QObject(parent)
|
|||
numberDictionary["million"] = 100000;
|
||||
}
|
||||
|
||||
theWaveWorker::~theWaveWorker() {
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void theWaveWorker::begin() {
|
||||
if (resetOnNextBegin) {
|
||||
resetOnNextBegin = false;
|
||||
|
@ -118,7 +122,11 @@ void theWaveWorker::outputAvailable() {
|
|||
}
|
||||
}
|
||||
|
||||
void theWaveWorker::processSpeech(QString speech) {
|
||||
void theWaveWorker::processSpeech(QString speech, bool voiceFeedback) {
|
||||
if (resetOnNextBegin) {
|
||||
resetOnNextBegin = false;
|
||||
emit resetFrames();
|
||||
}
|
||||
QString parse = speech.toLower();
|
||||
if (speech == "") {
|
||||
emit outputResponse("That flew past me. Try again.");
|
||||
|
@ -135,7 +143,7 @@ void theWaveWorker::processSpeech(QString speech) {
|
|||
} else if (parse.contains("call")) {
|
||||
emit outputResponse("Unfortunately, I can't place a call from this device.");
|
||||
speak("Unfortunately, I can't place a call from this device.");
|
||||
emit showCallFrame();
|
||||
emit showCallFrame(false);
|
||||
resetOnNextBegin = true;
|
||||
} else if (parse.contains("text") || parse.contains("message")) {
|
||||
emit outputResponse("Unfortunately, I can't send text messages from this device. This functionality may come later for IM applications.");
|
||||
|
@ -162,15 +170,65 @@ void theWaveWorker::processSpeech(QString speech) {
|
|||
|
||||
if (hour == 0 && minute == 0 && second == 0) {
|
||||
emit outputResponse("How long do you want this timer to be set for?");
|
||||
speak("How long do you want this timer to be set for?", true);
|
||||
speak("How long do you want this timer to be set for?", voiceFeedback);
|
||||
state = TimerGetTime;
|
||||
} else {
|
||||
goto TimerGetTime;
|
||||
}
|
||||
} else if (parse.contains("help") || parse.contains("what can you do")) {
|
||||
emit outputResponse("I can do some things. Try asking me something from this list.");
|
||||
speak("I can do some things. Try asking me something from this list.");
|
||||
emit showHelpFrame();
|
||||
resetOnNextBegin = true;
|
||||
} else if (parse.startsWith("start", Qt::CaseInsensitive) || parse.startsWith("launch", Qt::CaseInsensitive)) {
|
||||
emit launchApp(parse.remove(0, 6));
|
||||
resetOnNextBegin = true;
|
||||
} else {
|
||||
emit outputResponse("Unfortunately, I don't understand you. Try again.");
|
||||
speak("Unfortunately, I don't understand you. Try again.");
|
||||
errorListeningSound->play();
|
||||
emit outputResponse("Looking online for information...");
|
||||
speak("Looking online for information...");
|
||||
|
||||
bool isInfoFound = false;
|
||||
|
||||
if (settings.value("thewave/wikipediaSearch", true).toBool()) {
|
||||
QEventLoop eventLoop;
|
||||
|
||||
QNetworkRequest request;
|
||||
QUrl requestUrl("https://en.wikipedia.org/w/api.php?action=query&titles=" + parse.replace(" ", "%20") + "&format=xml&prop=extracts&redirects=true&exintro=true");
|
||||
request.setUrl(requestUrl);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, "theWave/2.0 (vicr12345@gmail.com)");
|
||||
QNetworkAccessManager networkManager;
|
||||
connect(&networkManager, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
|
||||
QNetworkReply* NetworkReply = networkManager.get(request);
|
||||
|
||||
eventLoop.exec();
|
||||
|
||||
QString reply(NetworkReply->readAll());
|
||||
qDebug() << reply;
|
||||
|
||||
if (reply.contains("title=") && !reply.contains("missing=\"\"")) {
|
||||
isInfoFound = true;
|
||||
QString title = reply.split("title=\"").at(1).split("\"").at(0);
|
||||
QString text;
|
||||
|
||||
text = "<!DOCTYPE HTML><html><head></head><body>" + reply.split("<extract xml:space=\"preserve\">").at(1).split("</extract>").at(0) + "</body></html>";
|
||||
text.replace("<", "<");
|
||||
text.replace(">", ">");
|
||||
text.replace(""", "\"");
|
||||
text.replace("&", "&");
|
||||
|
||||
emit showWikipediaFrame(title, text);
|
||||
emit outputResponse("I found some information. Take a look.");
|
||||
speak("I found some information. Take a look.");
|
||||
resetOnNextBegin = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!isInfoFound) {
|
||||
emit outputResponse("Unfortunately, I don't understand you. Try again.");
|
||||
speak("Unfortunately, I don't understand you. Try again.");
|
||||
errorListeningSound->play();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TimerGetTime:
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
#include <QAudioRecorder>
|
||||
#include <QAudioEncoderSettings>
|
||||
#include <QAudioProbe>
|
||||
#include <QThread>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QSettings>
|
||||
#include <QXmlSimpleReader>
|
||||
#include <QXmlInputSource>
|
||||
#include <QEventLoop>
|
||||
|
||||
class theWaveWorker : public QObject
|
||||
{
|
||||
|
@ -27,6 +35,7 @@ class theWaveWorker : public QObject
|
|||
|
||||
public:
|
||||
explicit theWaveWorker(QObject *parent = 0);
|
||||
~theWaveWorker();
|
||||
|
||||
signals:
|
||||
void outputSpeech(QString);
|
||||
|
@ -38,15 +47,18 @@ signals:
|
|||
void finished();
|
||||
|
||||
void resetFrames();
|
||||
void showCallFrame();
|
||||
void showCallFrame(bool emergency);
|
||||
void showMessageFrame();
|
||||
void showHelpFrame();
|
||||
void showWikipediaFrame(QString title, QString text);
|
||||
void launchApp(QString app);
|
||||
|
||||
void setTimer(QTime);
|
||||
|
||||
public slots:
|
||||
void begin();
|
||||
|
||||
void processSpeech(QString speech);
|
||||
void processSpeech(QString speech, bool voiceFeedback = true);
|
||||
|
||||
void quit();
|
||||
|
||||
|
@ -67,6 +79,8 @@ private:
|
|||
|
||||
bool stopEverything = false;
|
||||
bool resetOnNextBegin = false;
|
||||
|
||||
QSettings settings;
|
||||
};
|
||||
|
||||
#endif // THEWAVEWORKER_H
|
||||
|
|
Loading…
Reference in a new issue