diff --git a/apps/appslistmodel.cpp b/apps/appslistmodel.cpp
index 7072404..d1836e7 100644
--- a/apps/appslistmodel.cpp
+++ b/apps/appslistmodel.cpp
@@ -70,158 +70,6 @@ void AppsListModel::search(QString query) {
}
}
- bool showtheWaveOption = true;
- /*if (settings.value("thewave/enabled", true).toBool()) {
- if (arg1.toLower() == "emergency call") {
- QListWidgetItem *callItem = new QListWidgetItem();
- callItem->setText(tr("Place a call"));
- callItem->setIcon(QIcon::fromTheme("call-start"));
- callItem->setData(Qt::UserRole, "thewave:emergency call");
- ui->listWidget->addItem(callItem);
-
- QListWidgetItem *call = new QListWidgetItem();
- call->setText(tr("Emergency Call"));
- call->setData(Qt::UserRole, "thewave:emergency call");
- call->setIcon(QIcon(":/icons/blank.svg"));
- QFont font = call->font();
- font.setPointSize(30);
- call->setFont(font);
- ui->listWidget->addItem(call);
- showtheWaveOption = false;
- } else if ((arg1.startsWith("call") && arg1.count() == 4) || arg1.startsWith("call ")) {
- QListWidgetItem *call = new QListWidgetItem();
- QString parse = arg1;
- if (arg1.count() == 4 || arg1.count() == 5) {
- call->setText(tr("Place a call"));
- call->setData(Qt::UserRole, "thewave:call");
- call->setIcon(QIcon::fromTheme("call-start"));
- } else {
- parse.remove(0, 5);
- QListWidgetItem *callItem = new QListWidgetItem();
- callItem->setText(tr("Place a call"));
- callItem->setIcon(QIcon::fromTheme("call-start"));
- callItem->setData(Qt::UserRole, "thewave:call " + parse);
- ui->listWidget->addItem(callItem);
-
- call->setText((QString) parse.at(0).toUpper() + parse.right(parse.length() - 1) + "");
- call->setData(Qt::UserRole, "thewave:call " + parse);
- call->setIcon(QIcon(":/icons/blank.svg"));
-
- QFont font = call->font();
- font.setPointSize(30);
- call->setFont(font);
- }
- ui->listWidget->addItem(call);
- showtheWaveOption = false;
- } else if (arg1.startsWith("weather")) {
- QListWidgetItem *weather = new QListWidgetItem();
-
- QListWidgetItem *weatherItem = new QListWidgetItem();
- weatherItem->setText(tr("Weather"));
- weatherItem->setIcon(QIcon::fromTheme("weather-clear"));
- weatherItem->setData(Qt::UserRole, "thewave:weather");
- ui->listWidget->addItem(weatherItem);
-
- weather->setText(tr("Unknown"));
- weather->setData(Qt::UserRole, "thewave:weather");
- weather->setIcon(QIcon::fromTheme("dialog-error"));
-
- QFont font = weather->font();
- font.setPointSize(30);
- weather->setFont(font);
-
- ui->listWidget->addItem(weather);
- showtheWaveOption = false;
- } else if (arg1.startsWith("play") && MainWin->isMprisAvailable()) {
- QListWidgetItem *i = new QListWidgetItem();
- i->setText(tr("Play"));
- i->setIcon(QIcon::fromTheme("media-playback-start"));
- i->setData(Qt::UserRole, "media:play");
- ui->listWidget->addItem(i);
- showtheWaveOption = false;
- } else if (arg1.startsWith("pause") && MainWin->isMprisAvailable()) {
- QListWidgetItem *i = new QListWidgetItem();
- i->setText(tr("Pause"));
- i->setIcon(QIcon::fromTheme("media-playback-pause"));
- i->setData(Qt::UserRole, "media:pause");
- ui->listWidget->addItem(i);
- showtheWaveOption = false;
- } else if (arg1.startsWith("next") && MainWin->isMprisAvailable()) {
- QListWidgetItem *i = new QListWidgetItem();
- i->setText(tr("Next Track"));
- i->setIcon(QIcon::fromTheme("media-skip-forward"));
- i->setData(Qt::UserRole, "media:next");
- ui->listWidget->addItem(i);
- showtheWaveOption = false;
- } else if ((arg1.startsWith("previous") || arg1.startsWith("back")) && MainWin->isMprisAvailable()) {
- QListWidgetItem *i = new QListWidgetItem();
- i->setText(tr("Previous Track"));
- i->setIcon(QIcon::fromTheme("media-skip-backward"));
- i->setData(Qt::UserRole, "media:previous");
- ui->listWidget->addItem(i);
- showtheWaveOption = false;
- } else if ((arg1.contains("current") || arg1.contains("what") || arg1.contains("now")) &&
- (arg1.contains("track") || arg1.contains("song") || arg1.contains("playing")) && MainWin->isMprisAvailable()) { //Get current song info
- QListWidgetItem *nowPlaying = new QListWidgetItem();
- nowPlaying->setText(tr("Now Playing"));
- nowPlaying->setIcon(QIcon::fromTheme("media-playback-start"));
- nowPlaying->setData(Qt::UserRole, "thewave:current track");
- ui->listWidget->addItem(nowPlaying);
-
- QListWidgetItem *title = new QListWidgetItem();
- title->setText(MainWin->songName());
- title->setData(Qt::UserRole, "thewave:current track");
- title->setIcon(QIcon(":/icons/blank.svg"));
- QFont font = title->font();
- font.setPointSize(30);
- title->setFont(font);
- ui->listWidget->addItem(title);
-
- if (MainWin->songAlbum() != "" || MainWin->songArtist() != "") {
- QListWidgetItem *extra = new QListWidgetItem();
- if (MainWin->songArtist() != "" && MainWin->songAlbum() != "") {
- extra->setText(MainWin->songArtist() + " · " + MainWin->songAlbum());
- } else if (MainWin->songArtist() == "") {
- extra->setText(MainWin->songAlbum());
- } else {
- extra->setText(MainWin->songArtist());
- }
- extra->setData(Qt::UserRole, "thewave:current track");
- extra->setIcon(QIcon(":/icons/blank.svg"));
- ui->listWidget->addItem(extra);
- }
-
- QListWidgetItem *space = new QListWidgetItem();
- ui->listWidget->addItem(space);
-
- QListWidgetItem *play = new QListWidgetItem();
- play->setText(tr("Play"));
- play->setIcon(QIcon::fromTheme("media-playback-start"));
- play->setData(Qt::UserRole, "media:play");
- ui->listWidget->addItem(play);
-
- QListWidgetItem *pause = new QListWidgetItem();
- pause->setText(tr("Pause"));
- pause->setIcon(QIcon::fromTheme("media-playback-pause"));
- pause->setData(Qt::UserRole, "media:pause");
- ui->listWidget->addItem(pause);
-
- QListWidgetItem *next = new QListWidgetItem();
- next->setText(tr("Next Track"));
- next->setIcon(QIcon::fromTheme("media-skip-forward"));
- next->setData(Qt::UserRole, "media:next");
- ui->listWidget->addItem(next);
-
- QListWidgetItem *prev = new QListWidgetItem();
- prev->setText(tr("Previous Track"));
- prev->setIcon(QIcon::fromTheme("media-skip-backward"));
- prev->setData(Qt::UserRole, "media:previous");
- ui->listWidget->addItem(prev);
-
- showtheWaveOption = false;
- }
- }*/
-
int i = 0;
for (App app : apps) {
if (i >= pinnedAppsCount || pinnedAppsCount == 0) {
@@ -294,14 +142,6 @@ void AppsListModel::search(QString query) {
}
}
- if (showtheWaveOption && settings.value("thewave/enabled", true).toBool()) {
- App app;
- app.setCommand("thewave:" + query);
- app.setDescription(tr("Query theWave"));
- app.setName(query);
- app.setIcon(QIcon(":/icons/thewave.svg"));
- appsShown.append(app);
- }
updateData();
}
}
@@ -358,13 +198,6 @@ void AppsListModel::loadData() {
}
}
- App waveApp;
- waveApp.setCommand("thewave");
- waveApp.setIcon(QIcon(":/icons/thewave.svg"));
- waveApp.setName(tr("theWave"));
- waveApp.setDescription(tr("Personal Assistant"));
- apps.append(waveApp);
-
std::sort(apps.begin(), apps.end());
for (int i = pinnedAppsList.count() - 1; i >= 0; i--) {
@@ -632,16 +465,7 @@ bool AppsListModel::launchApp(QModelIndex index) {
on_lineEdit_textEdited(ui->lineEdit->text());
} else {*/
QString command = appsShown.at(index.row()).command().remove("%u");
- if (command.startsWith("thewave")) {
- if (command.split(":").count() > 1) {
- QStringList request = command.split(":");
- request.removeFirst();
- emit queryWave(request.join(" "));
- } else {
- emit queryWave("");
- }
- return false;
- } else if (command.startsWith("call:")) {
+ if (command.startsWith("call:")) {
QString callCommand = command.mid(5);
QStringList parts = callCommand.split(":");
int deviceIndex = parts.at(0).toInt();
diff --git a/apps/appslistmodel.h b/apps/appslistmodel.h
index 94589cc..51001fd 100644
--- a/apps/appslistmodel.h
+++ b/apps/appslistmodel.h
@@ -45,7 +45,6 @@ public slots:
void loadData();
signals:
- void queryWave(QString query);
private:
struct dataLoad {
diff --git a/infopanedropdown.cpp b/infopanedropdown.cpp
index 9e0306e..4634c48 100644
--- a/infopanedropdown.cpp
+++ b/infopanedropdown.cpp
@@ -209,17 +209,6 @@ InfoPaneDropdown::InfoPaneDropdown(WId MainWindowId, QWidget *parent) :
}
ui->redshiftIntensity->setValue(redshiftVal.toInt());
- QString thewaveVoiceEngine = settings.value("thewave/ttsEngine", "festival").toString();
- if (thewaveVoiceEngine == "pico2wave") {
- ui->thewaveTTSpico2wave->setChecked(true);
- } else if (thewaveVoiceEngine == "espeak") {
- ui->thewaveTTSespeak->setChecked(true);
- } else if (thewaveVoiceEngine == "festival") {
- ui->thewaveTTSfestival->setChecked(true);
- } else if (thewaveVoiceEngine == "none") {
- ui->thewaveTTSsilent->setChecked(true);
- }
-
if (settings.value("ui/useFullScreenEndSession", false).toBool()) {
ui->endSessionConfirmFullScreen->setChecked(true);
ui->endSessionConfirmInMenu->setChecked(false);
@@ -273,12 +262,8 @@ InfoPaneDropdown::InfoPaneDropdown(WId MainWindowId, QWidget *parent) :
ui->lockScreenBackground->setText(lockScreenSettings->value("background", "/usr/share/icons/theos/backgrounds/triangle/1920x1080.png").toString());
//ui->lineEdit_2->setText(settings.value("startup/autostart", "").toString());
ui->redshiftPause->setChecked(!settings.value("display/redshiftPaused", true).toBool());
- ui->thewaveWikipediaSwitch->setChecked(settings.value("thewave/wikipediaSearch", true).toBool());
ui->TouchFeedbackSwitch->setChecked(settings.value("input/touchFeedbackSound", false).toBool());
ui->SuperkeyGatewaySwitch->setChecked(settings.value("input/superkeyGateway", true).toBool());
- ui->thewaveOffensiveSwitch->setChecked(settings.value("thewave/blockOffensiveWords", true).toBool());
- ui->theWaveSwitch->setChecked(settings.value("thewave/enabled", true).toBool());
- ui->theWaveName->setText(settings.value("thewave/name", "").toString());
ui->TextSwitch->setChecked(settings.value("bar/showText", true).toBool());
ui->windowManager->setText(settings.value("startup/WindowManagerCommand", "kwin_x11").toString());
ui->barDesktopsSwitch->setChecked(settings.value("bar/showWindowsFromOtherDesktops", true).toBool());
@@ -1278,37 +1263,6 @@ void InfoPaneDropdown::on_TouchFeedbackSwitch_toggled(bool checked)
settings.setValue("input/touchFeedbackSound", checked);
}
-void InfoPaneDropdown::on_thewaveTTSpico2wave_clicked()
-{
- settings.setValue("thewave/ttsEngine", "pico2wave");
-}
-
-void InfoPaneDropdown::on_thewaveTTSfestival_clicked()
-{
- settings.setValue("thewave/ttsEngine", "festival");
-}
-
-
-void InfoPaneDropdown::on_thewaveWikipediaSwitch_toggled(bool checked)
-{
- settings.setValue("thewave/wikipediaSearch", checked);
-}
-
-void InfoPaneDropdown::on_thewaveTTSespeak_clicked()
-{
- settings.setValue("thewave/ttsEngine", "espeak");
-}
-
-void InfoPaneDropdown::on_thewaveOffensiveSwitch_toggled(bool checked)
-{
- settings.setValue("thewave/blockOffensiveWords", checked);
-}
-
-void InfoPaneDropdown::on_theWaveName_textEdited(const QString &arg1)
-{
- settings.setValue("thewave/name", arg1);
-}
-
void InfoPaneDropdown::on_brightnessSlider_sliderMoved(int position)
{
QProcess* backlight = new QProcess(this);
@@ -1369,16 +1323,6 @@ void InfoPaneDropdown::on_barDesktopsSwitch_toggled(bool checked)
settings.setValue("bar/showWindowsFromOtherDesktops", checked);
}
-void InfoPaneDropdown::on_thewaveTTSsilent_clicked()
-{
- settings.setValue("thewave/ttsEngine", "none");
-}
-
-void InfoPaneDropdown::on_theWaveSwitch_toggled(bool checked)
-{
- settings.setValue("thewave/enabled", checked);
-}
-
void InfoPaneDropdown::on_BluetoothSwitch_toggled(bool checked)
{
QDBusInterface("org.thesuite.tsbt", "/org/thesuite/tsbt", "org.thesuite.tsbt", QDBusConnection::sessionBus()).setProperty("BluetoothEnabled", checked);
diff --git a/infopanedropdown.h b/infopanedropdown.h
index 693cf05..901d0b1 100644
--- a/infopanedropdown.h
+++ b/infopanedropdown.h
@@ -172,18 +172,6 @@ private slots:
void on_TouchFeedbackSwitch_toggled(bool checked);
- void on_thewaveTTSpico2wave_clicked();
-
- void on_thewaveTTSfestival_clicked();
-
- void on_thewaveWikipediaSwitch_toggled(bool checked);
-
- void on_thewaveTTSespeak_clicked();
-
- void on_thewaveOffensiveSwitch_toggled(bool checked);
-
- void on_theWaveName_textEdited(const QString &arg1);
-
void on_brightnessSlider_sliderMoved(int position);
void on_brightnessSlider_valueChanged(int value);
@@ -206,10 +194,6 @@ private slots:
void on_barDesktopsSwitch_toggled(bool checked);
- void on_thewaveTTSsilent_clicked();
-
- void on_theWaveSwitch_toggled(bool checked);
-
void bluetoothEnabledChanged();
void on_BluetoothSwitch_toggled(bool checked);
@@ -411,7 +395,6 @@ public slots:
void startTimer(QTime time);
- //Switches for theWave
void on_WifiSwitch_toggled(bool checked);
private:
diff --git a/infopanedropdown.ui b/infopanedropdown.ui
index 3c93380..3904c3e 100644
--- a/infopanedropdown.ui
+++ b/infopanedropdown.ui
@@ -611,14 +611,14 @@
0
1969
9
- 12
+ 11
1969
9
- 12
+ 11
@@ -1755,15 +1755,6 @@
..
- -
-
- theWave
-
-
-
- :/icons/thewave.svg:/icons/thewave.svg
-
-
-
Users
@@ -1823,7 +1814,7 @@
-
- 7
+ 8
@@ -3501,203 +3492,6 @@
-
-
- -
-
-
- Enable theWave
-
-
-
- -
-
-
- Search on Wikipedia
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 15
-
-
-
- theWave
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Qt::Horizontal
-
-
-
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Si&lent
-
-
-
- -
-
-
- Festi&val
-
-
-
- -
-
-
- espea&k
-
-
-
- -
-
-
- pico&2wave
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Text to Speech engine
-
-
-
- -
-
-
- WikipediaSwitch
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Block recognized offensive words
-
-
-
- -
-
-
- -
-
-
- OffensiveSwitch
-
-
-
- -
-
-
- Preferred Name
-
-
-
- -
-
-
- theWaveSwitch
-
-
-
- -
-
-
- Recognized offensive words will be replaced with asterisks. However, there will probably be some false positives.
-
-
-
-
-
-
@@ -4847,14 +4641,6 @@ Items that will be kept if you choose to keep files:
-
- ClickableLabel
- QLabel
-
-
- clicked()
-
-
AnimatedStackedWidget
QStackedWidget
@@ -4866,6 +4652,14 @@ Items that will be kept if you choose to keep files:
QPushButton
+
+ ClickableLabel
+ QLabel
+
+
+ clicked()
+
+
NetworkWidget
QWidget
diff --git a/mainwindow.cpp b/mainwindow.cpp
index e083f5a..53287a9 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1338,11 +1338,6 @@ void MainWindow::on_date_clicked()
infoPane->show(InfoPaneDropdown::Clock);
}
-void MainWindow::on_pushButton_2_clicked()
-{
- openMenu(true);
-}
-
void MainWindow::internetLabelChanged(QString text, QIcon icon) {
/*ui->networkLabel->setText(display);
if (signalStrength == -1) {
@@ -1708,34 +1703,27 @@ void MainWindow::on_desktopBack_clicked()
sendMessageToRootWindow("_NET_CURRENT_DESKTOP", 0, switchToDesktop);
}
-void MainWindow::openMenu(bool openTotheWave, bool startListening) {
- if (gatewayMenu->isVisible()) {
- if (openTotheWave) {
- gatewayMenu->show(openTotheWave, startListening);
+void MainWindow::openMenu() {
+ lockHide = true;
- }
+ QRect screenGeometry = QApplication::desktop()->screenGeometry();
+ QRect availableGeometry = QApplication::desktop()->availableGeometry();
+
+ //gatewayMenu->setGeometry(availableGeometry.x(), availableGeometry.y(), gatewayMenu->width(), availableGeometry.height());
+ if (settings.value("bar/onTop", true).toBool()) {
+ gatewayMenu->setGeometry(this->x() - gatewayMenu->width(), this->y() + this->height() - 1, gatewayMenu->width(), availableGeometry.height() - (this->height() + (this->y() - availableGeometry.y())) + 1);
} else {
- lockHide = true;
+ int height;
- QRect screenGeometry = QApplication::desktop()->screenGeometry();
- QRect availableGeometry = QApplication::desktop()->availableGeometry();
-
- //gatewayMenu->setGeometry(availableGeometry.x(), availableGeometry.y(), gatewayMenu->width(), availableGeometry.height());
- if (settings.value("bar/onTop", true).toBool()) {
- gatewayMenu->setGeometry(this->x() - gatewayMenu->width(), this->y() + this->height() - 1, gatewayMenu->width(), availableGeometry.height() - (this->height() + (this->y() - availableGeometry.y())) + 1);
+ if (availableGeometry.bottom() < screenGeometry.height() - this->height()) {
+ height = availableGeometry.height();
} else {
- int height;
-
- if (availableGeometry.bottom() < screenGeometry.height() - this->height()) {
- height = availableGeometry.height();
- } else {
- height = this->y() - screenGeometry.top() + 1;
- }
- gatewayMenu->setGeometry(this->x() - gatewayMenu->width(), availableGeometry.y() , gatewayMenu->width(), height);
+ height = this->y() - screenGeometry.top() + 1;
}
- gatewayMenu->show(openTotheWave, startListening);
- gatewayMenu->setFocus();
+ gatewayMenu->setGeometry(this->x() - gatewayMenu->width(), availableGeometry.y() , gatewayMenu->width(), height);
}
+ gatewayMenu->show();
+ gatewayMenu->setFocus();
}
bool MainWindow::isMprisAvailable() {
diff --git a/mainwindow.h b/mainwindow.h
index d7c0c77..a85a053 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -85,7 +85,7 @@ public:
QString songAlbum();
public slots:
- void openMenu(bool openTotheWave = false, bool startListening = false);
+ void openMenu();
void doUpdate();
@@ -96,8 +96,6 @@ private slots:
void on_date_clicked();
- void on_pushButton_2_clicked();
-
void internetLabelChanged(QString text, QIcon icon);
void on_networkLabel_clicked();
diff --git a/mainwindow.ui b/mainwindow.ui
index 704a8c5..1f18d1e 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -144,33 +144,6 @@
-
- -
-
-
- Qt::Vertical
-
-
-
- -
-
-
- true
-
-
- theWave
-
-
-
-
-
-
- :/icons/thewave.svg:/icons/thewave.svg
-
-
- true
-
-
-
-
diff --git a/menu.cpp b/menu.cpp
index dfcf4ed..1182d4c 100644
--- a/menu.cpp
+++ b/menu.cpp
@@ -39,22 +39,10 @@ Menu::Menu(BTHandsfree* bt, QWidget *parent) :
ui->offFrame->setParent(this);
ui->offFrame->setVisible(false);
- 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->timerIcon->setPixmap(QIcon::fromTheme("player-time").pixmap(16));
ui->userIcon->setPixmap(QIcon::fromTheme("system-users").pixmap(16));
- ui->thewave_connection_disconnection_label->setPixmap(QIcon::fromTheme("network-disconnect").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));
- ui->mathIcon->setPixmap(QIcon::fromTheme("accessories-calculator").pixmap(32));
- ui->settingsIcon->setPixmap(QIcon::fromTheme("preferences-system").pixmap(32));
- ui->mediaIcon->setPixmap(QIcon::fromTheme("media-playback-start").pixmap(32));
ui->commandLinkButton->setProperty("type", "destructive");
ui->commandLinkButton_2->setProperty("type", "destructive");
@@ -90,25 +78,17 @@ Menu::Menu(BTHandsfree* bt, QWidget *parent) :
//ui->listWidget->installEventFilter(this);
ui->appsListView->installEventFilter(this);
- ui->activateTheWave->installEventFilter(this);
ui->pushButton->installEventFilter(this);
ui->pushButton_3->installEventFilter(this);
this->installEventFilter(this);
- if (QFile("/usr/bin/install_theos").exists()) {
+ if (QFile("/usr/bin/scallop").exists()) {
ui->InstallLayout->setVisible(true);
} else {
ui->InstallLayout->setVisible(false);
}
- QNetworkAccessManager networkManager;
- if (networkManager.networkAccessible() == QNetworkAccessManager::Accessible) {
- ui->thewaveInternetFrame->setVisible(false);
- } else {
- ui->thewaveInternetFrame->setVisible(true);
- }
-
QString seatPath = QString(qgetenv("XDG_SEAT_PATH"));
if (seatPath == "") {
ui->commandLinkButton_4->setEnabled(false);
@@ -121,17 +101,8 @@ Menu::Menu(BTHandsfree* bt, QWidget *parent) :
//listPal.setBrush(QPalette::Inactive, QPalette::HighlightedText, listPal.brush(QPalette::Active, QPalette::HighlightedText));
//ui->listWidget->setPalette(listPal);
- this->theWaveFrame = ui->thewaveFrame;
-
//populateAppList();
AppsListModel* appsListModel = new AppsListModel(bt);
- connect(appsListModel, &AppsListModel::queryWave, [=](QString query) {
- ui->activateTheWave->click();
- if (query != "") {
- ui->thewave_line->setText(query);
- on_thewave_line_returnPressed();
- }
- });
ui->appsListView->setModel(appsListModel);
ui->appsListView->setItemDelegate(new AppsDelegate);
@@ -155,47 +126,32 @@ Menu::~Menu()
delete ui;
}
-void Menu::show(bool openTotheWave, bool startListening) {
- if (this->isVisible()) {
- this->uncollapse();
- } else {
- //Reload menu
- //((AppsListModel*) ui->appsListView->model())->loadData();
+void Menu::show() {
+ unsigned long desktop = 0xFFFFFFFF;
+ XChangeProperty(QX11Info::display(), this->winId(), XInternAtom(QX11Info::display(), "_NET_WM_DESKTOP", False),
+ XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &desktop, 1); //Set visible on all desktops
- unsigned long desktop = 0xFFFFFFFF;
- XChangeProperty(QX11Info::display(), this->winId(), XInternAtom(QX11Info::display(), "_NET_WM_DESKTOP", False),
- XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &desktop, 1); //Set visible on all desktops
+ QDialog::show();
+ doCheckForClose = true;
- QDialog::show();
- doCheckForClose = true;
+ ui->offFrame->setGeometry(10, this->height(), this->width() - 20, this->height() - 20);
- ui->offFrame->setGeometry(10, this->height(), this->width() - 20, this->height() - 20);
- ui->thewaveFrame->setGeometry(10, this->height(), this->width() - 20, this->height() - 20);
+ tPropertyAnimation* animation = new tPropertyAnimation(this, "geometry");
+ animation->setStartValue(this->geometry());
+ animation->setEndValue(QRect(this->x() + this->width(), this->y(), this->width(), this->height()));
+ animation->setDuration(500);
+ animation->setEasingCurve(QEasingCurve::OutCubic);
+ connect(animation, SIGNAL(finished()), animation, SLOT(deleteLater()));
+ animation->start();
- tPropertyAnimation* animation = new tPropertyAnimation(this, "geometry");
- animation->setStartValue(this->geometry());
- animation->setEndValue(QRect(this->x() + this->width(), this->y(), this->width(), this->height()));
- animation->setDuration(500);
- animation->setEasingCurve(QEasingCurve::OutCubic);
- connect(animation, SIGNAL(finished()), animation, SLOT(deleteLater()));
- animation->start();
+ ui->lineEdit->setText("");
+ ui->lineEdit->setFocus();
+ on_lineEdit_textEdited("");
- ui->lineEdit->setText("");
- ui->lineEdit->setFocus();
- on_lineEdit_textEdited("");
+ ui->appsListView->scrollToTop();
- ui->appsListView->scrollToTop();
-
- //Show Tutorial Screen
- TutorialWin->showScreen(TutorialWindow::GatewaySearch);
- }
-
- if (openTotheWave && !this->istheWaveOpen) {
- ui->activateTheWave->click();
- }
- if (startListening && openTotheWave) {
- ui->listentheWave->click();
- }
+ //Show Tutorial Screen
+ TutorialWin->showScreen(TutorialWindow::GatewaySearch);
connect(NativeFilter, &NativeEventFilter::DoRetranslation, [=] {
ui->retranslateUi(this);
@@ -205,47 +161,13 @@ void Menu::show(bool openTotheWave, bool startListening) {
void Menu::changeEvent(QEvent *event) {
QDialog::changeEvent(event);
if (event->type() == QEvent::ActivationChange) {
- if (istheWaveOpen) {
- if (this->isActiveWindow()) {
- uncollapse();
- } else {
- collapse();
- }
- } else {
- if (!this->isActiveWindow()) {
- this->close();
- }
+ if (!this->isActiveWindow()) {
+ this->close();
}
}
}
-void Menu::collapse() {
- QRect screenGeometry = QApplication::desktop()->screenGeometry();
- tPropertyAnimation* animation = new tPropertyAnimation(this, "geometry");
- animation->setStartValue(this->geometry());
- animation->setEndValue(QRect(screenGeometry.x() - (this->width() - 50), this->y(), this->width(), this->height()));
- animation->setDuration(500);
- animation->setEasingCurve(QEasingCurve::OutCubic);
- animation->start();
- connect(animation, SIGNAL(finished()), animation, SLOT(deleteLater()));
-
-}
-
-void Menu::uncollapse() {
- QRect screenGeometry = QApplication::desktop()->screenGeometry();
- tPropertyAnimation* animation = new tPropertyAnimation(this, "geometry");
- animation->setStartValue(this->geometry());
- animation->setEndValue(QRect(screenGeometry.x(), this->y(), this->width(), this->height()));
- animation->setDuration(500);
- animation->setEasingCurve(QEasingCurve::OutCubic);
- animation->start();
- connect(animation, SIGNAL(finished()), animation, SLOT(deleteLater()));
-}
-
void Menu::close() {
- if (istheWaveOpen) {
- ui->closetheWaveButton->click();
- }
tPropertyAnimation* animation = new tPropertyAnimation(this, "geometry");
animation->setStartValue(this->geometry());
animation->setEndValue(QRect(this->x() - this->width(), this->y(), this->width(), this->height()));
@@ -436,82 +358,66 @@ bool Menu::eventFilter(QObject *object, QEvent *event) {
this->close();
return true;
} else {
- //if (object != ui->thewave_line && object != ui->lineEdit) {
- //if (ui->thewave_line->hasFocus() || ui->lineEdit->hasFocus()) {
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *e = (QKeyEvent*) event;
- if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
- if (!istheWaveReady) {
- if (object != ui->lineEdit && object != ui->thewave_line && object != this) {
- if (object == ui->appsListView) {
- on_lineEdit_returnPressed();
- } else {
- ((QPushButton*) object)->click();
- }
- on_lineEdit_returnPressed();
- }
- }
- event->ignore();
- } else {
- if (istheWaveReady) {
- ui->thewave_line->setText(ui->thewave_line->text().append(e->text())); //Type letter into theWave
- ui->thewave_line->setFocus();
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *e = (QKeyEvent*) event;
+ if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
+ if (object != ui->lineEdit && object != this) {
+ if (object == ui->appsListView) {
+ on_lineEdit_returnPressed();
} else {
- if (e->key() != Qt::Key_Up && e->key() != Qt::Key_Down) {
- ui->lineEdit->setText(ui->lineEdit->text().append(e->text())); //Type letter into search box
- ui->lineEdit->setFocus();
- on_lineEdit_textEdited(ui->lineEdit->text());
+ ((QPushButton*) object)->click();
+ }
+ on_lineEdit_returnPressed();
+ }
+ event->ignore();
+ } else {
+ if (e->key() != Qt::Key_Up && e->key() != Qt::Key_Down) {
+ ui->lineEdit->setText(ui->lineEdit->text().append(e->text())); //Type letter into search box
+ ui->lineEdit->setFocus();
+ on_lineEdit_textEdited(ui->lineEdit->text());
+ } else {
+ int currentRow;
+ if (ui->appsListView->selectionModel()->selectedRows().count() == 0) {
+ currentRow = -1;
+ } else {
+ currentRow = ui->appsListView->selectionModel()->selectedRows().first().row();
+ }
+
+ if (e->key() == Qt::Key_Down) {
+ QModelIndex indexToSelect;
+ if (currentRow == pinnedAppsCount - 1 && pinnedAppsCount != 0 && ui->lineEdit->text() == "") {
+ indexToSelect = ui->appsListView->model()->index(pinnedAppsCount + 1, 0);
+ } else if (currentRow == -1) {
+ indexToSelect = ui->appsListView->model()->index(0, 0);
+ } else if (currentRow == ui->appsListView->model()->rowCount() - 1) {
+ indexToSelect = ui->appsListView->model()->index(0, 0);
} else {
- int currentRow;
- if (ui->appsListView->selectionModel()->selectedRows().count() == 0) {
- currentRow = -1;
- } else {
- currentRow = ui->appsListView->selectionModel()->selectedRows().first().row();
- }
-
- if (e->key() == Qt::Key_Down) {
- QModelIndex indexToSelect;
- if (currentRow == pinnedAppsCount - 1 && pinnedAppsCount != 0 && ui->lineEdit->text() == "") {
- indexToSelect = ui->appsListView->model()->index(pinnedAppsCount + 1, 0);
- } else if (currentRow == -1) {
- indexToSelect = ui->appsListView->model()->index(0, 0);
- } else if (currentRow == ui->appsListView->model()->rowCount() - 1) {
- indexToSelect = ui->appsListView->model()->index(0, 0);
- } else {
- indexToSelect = ui->appsListView->model()->index(currentRow + 1, 0);
- }
- ui->appsListView->selectionModel()->select(indexToSelect, QItemSelectionModel::ClearAndSelect);
- ui->appsListView->scrollTo(indexToSelect);
-
- } else if (e->key() == Qt::Key_Up) {
- QModelIndex indexToSelect;
- if (currentRow == pinnedAppsCount + 1 && pinnedAppsCount != 0 && ui->lineEdit->text() == "") {
- indexToSelect = ui->appsListView->model()->index(pinnedAppsCount - 1, 0);
- } else if (currentRow == -1) {
- indexToSelect = ui->appsListView->model()->index(ui->appsListView->model()->rowCount() - 1, 0);
- } else if (currentRow == 0) {
- indexToSelect = ui->appsListView->model()->index(ui->appsListView->model()->rowCount() - 1, 0);
- } else {
- indexToSelect = ui->appsListView->model()->index(currentRow - 1, 0);
- }
- ui->appsListView->selectionModel()->select(indexToSelect, QItemSelectionModel::ClearAndSelect);
- ui->appsListView->scrollTo(indexToSelect);
- }
+ indexToSelect = ui->appsListView->model()->index(currentRow + 1, 0);
}
+ ui->appsListView->selectionModel()->select(indexToSelect, QItemSelectionModel::ClearAndSelect);
+ ui->appsListView->scrollTo(indexToSelect);
+
+ } else if (e->key() == Qt::Key_Up) {
+ QModelIndex indexToSelect;
+ if (currentRow == pinnedAppsCount + 1 && pinnedAppsCount != 0 && ui->lineEdit->text() == "") {
+ indexToSelect = ui->appsListView->model()->index(pinnedAppsCount - 1, 0);
+ } else if (currentRow == -1) {
+ indexToSelect = ui->appsListView->model()->index(ui->appsListView->model()->rowCount() - 1, 0);
+ } else if (currentRow == 0) {
+ indexToSelect = ui->appsListView->model()->index(ui->appsListView->model()->rowCount() - 1, 0);
+ } else {
+ indexToSelect = ui->appsListView->model()->index(currentRow - 1, 0);
+ }
+ ui->appsListView->selectionModel()->select(indexToSelect, QItemSelectionModel::ClearAndSelect);
+ ui->appsListView->scrollTo(indexToSelect);
}
}
- e->ignore();
- return true;
- } else {
- return QDialog::eventFilter(object, event);
- }
- /*} else {
- if (event->type() == QEvent::KeyPress) {
- event->ignore();
- return true;
}
+ e->ignore();
+ return true;
+ } else {
return QDialog::eventFilter(object, event);
- }*/
+ }
}
}
@@ -537,7 +443,7 @@ void Menu::on_lineEdit_returnPressed()
void Menu::on_pushButton_3_clicked()
{
- QProcess::startDetached("install_theos");
+ QProcess::startDetached("scallop");
this->close();
}
@@ -578,367 +484,6 @@ void Menu::on_commandLinkButton_8_clicked()
QProcess::startDetached("xset dpms force off");
}
-void Menu::on_activateTheWave_clicked()
-{
- istheWaveOpen = true;
- this->resetFrames();
- tPropertyAnimation* anim = new tPropertyAnimation(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();
-
- waveWorker = new theWaveWorker();
-
- if (waveWorker->isDisabled()) {
- ui->thewaveDisabledFrame->setVisible(true);
- ui->thewaveFrameInner->setVisible(false);
- ui->listentheWave->setVisible(false);
- } else {
- ui->thewaveDisabledFrame->setVisible(false);
- ui->thewaveFrameInner->setVisible(true);
- ui->listentheWave->setVisible(true);
- ui->theWaveSpeakFrame->setVisible(false);
- ui->thewave_hintFrame->setVisible(false);
- ui->thewaveHintIcon->setPixmap(QIcon::fromTheme("dialog-information").pixmap(16, 16));
-
- QThread *t = new QThread();
- 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) {
- if (settings.value("thewave/blockOffensiveWords").toBool()) {
- //Sorry... If there's a better way though, that'd be good :)
- response.replace("shit", "s•••", Qt::CaseInsensitive);
- response.replace("fuck", "f•••", Qt::CaseInsensitive);
- response.replace("cunt", "c•••", Qt::CaseInsensitive);
- response.replace("bitch", "b••••", Qt::CaseInsensitive);
- }
-
- ui->thewave_response->setText(response);
- ui->thewave_hintFrame->setVisible(false);
- });
- connect(waveWorker, &theWaveWorker::outputHint, [=](QString hint) {
- ui->thewaveHint->setText(hint);
- ui->thewave_hintFrame->setVisible(true);
- });
- connect(waveWorker, SIGNAL(outputSpeech(QString)), this, SLOT(thewave_outputSpeech(QString)));
- connect(waveWorker, &theWaveWorker::startedListening, [=]() {
- isListening = true;
- });
- connect(waveWorker, &theWaveWorker::stoppedListening, [=]() {
- isListening = false;
- });
- connect(waveWorker, &theWaveWorker::doLaunchApp, [=](QString appName) {
- for (App app : ((AppsListModel*) ui->appsListView->model())->availableApps()) {
- if (app.name() == appName) {
- QProcess::startDetached(app.command().remove("%u"));
- this->close();
- }
- }
- });
- connect(waveWorker, &theWaveWorker::showBigListenFrame, [=]() {
- QString name = settings.value("thewave/name").toString();
- if (name == "") {
- switch (qrand() % 5) {
- case 0:
- ui->theWaveSpeakGreeting->setText("Hey there. What's next?");
- break;
- case 1:
- ui->theWaveSpeakGreeting->setText("What can I do for you?");
- break;
- case 2:
- ui->theWaveSpeakGreeting->setText("Hello.");
- break;
- case 3:
- ui->theWaveSpeakGreeting->setText("Oh, hey there!");
- break;
- case 4:
- QTime current = QTime::currentTime();
- if (current.hour() < 12) {
- ui->theWaveSpeakGreeting->setText("Good morning!");
- } else if (current.hour() < 17) {
- ui->theWaveSpeakGreeting->setText("Good afternoon!");
- } else {
- ui->theWaveSpeakGreeting->setText("Good evening!");
- }
- break;
- }
- } else {
- switch (qrand() % 5) {
- case 0:
- ui->theWaveSpeakGreeting->setText("Hey, " + name + ". What's next?");
- break;
- case 1:
- ui->theWaveSpeakGreeting->setText("What can I do for you, " + name + "?");
- break;
- case 2:
- ui->theWaveSpeakGreeting->setText("Hello " + name + "!");
- break;
- case 3:
- ui->theWaveSpeakGreeting->setText("Oh, hey " + name + "!");
- break;
- case 4:
- QTime current = QTime::currentTime();
- if (current.hour() < 12) {
- ui->theWaveSpeakGreeting->setText("Good morning " + name + "!");
- } else if (current.hour() < 17) {
- ui->theWaveSpeakGreeting->setText("Good afternoon " + name + "!");
- } else {
- ui->theWaveSpeakGreeting->setText("Good evening " + name + "!");
- }
- break;
- }
- }
-
- ui->thewaveFrameInner->setVisible(false);
- ui->theWaveSpeakFrame->setVisible(true);
- });
- connect(waveWorker, &theWaveWorker::hideBigListenFrame, [=]() {
- ui->thewaveFrameInner->setVisible(true);
- ui->theWaveSpeakFrame->setVisible(false);
- });
- connect(waveWorker, SIGNAL(showCallFrame(bool)), this, SLOT(showCallFrame(bool))); //Call
- connect(waveWorker, SIGNAL(resetFrames()), this, SLOT(resetFrames())); //Reset
- connect(waveWorker, SIGNAL(showMessageFrame()), this, SLOT(showMessageFrame())); //Text Message
- connect(waveWorker, SIGNAL(showHelpFrame()), this, SLOT(showHelpFrame())); //Help
- connect(waveWorker, SIGNAL(showWikipediaFrame(QString,QString)), this, SLOT(showWikipediaFrame(QString,QString))); //Wikipedia
- connect(waveWorker, SIGNAL(launchApp(QString)), this, SLOT(thewave_launchapp(QString))); //Launch
- connect(waveWorker, SIGNAL(setTimer(QTime)), MainWin->getInfoPane(), SLOT(startTimer(QTime))); //Start a timer
- connect(waveWorker, SIGNAL(showFlightFrame(QString)), this, SLOT(showFlightFrame(QString))); //Flight
- connect(waveWorker, SIGNAL(loudnessChanged(qreal)), this, SLOT(thewaveLoudnessChanged(qreal))); //Input Loudness
- connect(waveWorker, SIGNAL(showSettingsFrame(QIcon,QString,bool)), this, SLOT(showSettingFrame(QIcon,QString,bool))); //Settings
- connect(waveWorker, SIGNAL(showMathematicsFrame(QString,QString)), this, SLOT(showMathematicsFrame(QString,QString))); //Mathematics
- connect(waveWorker, SIGNAL(showMediaFrame(QPixmap,QString,QString,bool)), this, SLOT(showMediaFrame(QPixmap,QString,QString,bool))); //Media Player
- connect(this, SIGNAL(thewave_processText(QString,bool)), waveWorker, SLOT(processSpeech(QString,bool))); //Manual Input Text Processing
- connect(this, SIGNAL(thewaveBegin()), waveWorker, SLOT(begin())); //Begin
- connect(this, SIGNAL(thewaveStop()), waveWorker, SLOT(endAndProcess())); //Stop
- connect(this, SIGNAL(thewave_sayLaunchApp(QString)), waveWorker, SLOT(launchAppReply(QString))); //Launch App User Reply
- connect(this, SIGNAL(thewave_sayLaunchApp_disambiguation(QStringList)), waveWorker, SLOT(launchApp_disambiguation(QStringList))); //Lauch App Disambiguation Reply
- connect(this, SIGNAL(currentSettingChanged(bool)), waveWorker, SLOT(currentSettingChanged(bool)));
-
- connect(waveWorker, SIGNAL(loudnessChanged(qreal)), ui->theWaveFeedback, SLOT(addLevel(qreal)));
- /*connect(w, &speechWorker::outputFrame, [=](QFrame *frame) {
- ui->frame->layout()->addWidget(frame);
- });*/
-
- t->start();
- }
-}
-
-void Menu::thewaveLoudnessChanged(qreal loudness) {
- if (loudness == -1) {
- ui->speechBar->setMaximum(0);
- ui->speechBar->setValue(0);
- } else if (loudness == -2) {
- ui->speechBar->setVisible(false);
- } else {
- ui->speechBar->setMaximum(100);
- ui->speechBar->setValue(loudness * 100);
- ui->speechBar->setVisible(true);
- }
-}
-
-void Menu::thewave_outputSpeech(QString speech) {
- QString displaySpeech = speech;
- if (settings.value("thewave/blockOffensiveWords").toBool()) {
- //Sorry... If there's a better way though, that'd be good :)
- displaySpeech.replace("shit", "s•••", Qt::CaseInsensitive);
- displaySpeech.replace("fuck", "f•••", Qt::CaseInsensitive);
- displaySpeech.replace("cunt", "c•••", Qt::CaseInsensitive);
- displaySpeech.replace("bitch", "b••••", Qt::CaseInsensitive);
- }
- ui->thewave_line->setText(displaySpeech);
- ui->theWaveBigSpeechLabel->setText(displaySpeech);
-}
-
-void Menu::on_closetheWaveButton_clicked()
-{
- if (this->isListening) {
- emit thewaveStop();
- }
-
- this->istheWaveReady = false;
- this->resetFrames();
- ui->thewave_response->setText(tr("Hit \"Speak\" to start speaking."));
- ui->thewave_line->setText("");
-
- tPropertyAnimation* anim = new tPropertyAnimation(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);
- connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
- anim->start();
-
- if (waveWorker != NULL) {
- //waveWorker->quit(); //This deletes the worker thread.
- waveWorker->disconnect();
- waveWorker->deleteLater();
- waveWorker = NULL;
- }
-
- istheWaveOpen = false;
- ui->appsListView->setFocus();
-}
-
-void Menu::showCallFrame(bool emergency) {
- Q_UNUSED(emergency)
-
- ui->thewave_callFrame->setVisible(true);
- ui->thewave_callFrame->setBackupText(tr("Can't place a call from this device."));
-}
-
-void Menu::showMessageFrame() {
- ui->thewave_messageframe->setVisible(true);
- ui->thewave_messageframe->setBackupText(tr("Can't send messages from this device."));
-}
-
-void Menu::showHelpFrame() {
- ui->thewave_helpFrame->setVisible(true);
- ui->thewave_helpFrame->setBackupText(tr("theWave Help."));
-}
-
-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);
- ui->thewaveWeatherFrame->setVisible(false);
- ui->thewave_flightFrame->setVisible(false);
- ui->thewaveSettingsFrame->setVisible(false);
- ui->thewaveMathematicsFrame->setVisible(false);
- ui->thewaveMediaFrame->setVisible(false);
-}
-
-void Menu::showMediaFrame(QPixmap art, QString title, QString artist, bool isPlaying) {
- ui->thewaveMedia_Art->setPixmap(art.scaled(32, 32));
- ui->thewaveMedia_Title->setText(title);
- ui->thewaveMedia_Artist->setText(artist);
- if (isPlaying) {
- ui->thewaveMedia_Play->setIcon(QIcon::fromTheme("media-playback-pause"));
- } else {
- ui->thewaveMedia_Play->setIcon(QIcon::fromTheme("media-playback-start"));
- }
- ui->thewaveMediaFrame->setVisible(true);
-
- if (artist == "") {
- ui->thewaveMediaFrame->setBackupText("Now Playing: " + title);
- } else {
- ui->thewaveMediaFrame->setBackupText("Now Playing: " + title + " · " + artist);
- }
-}
-
-void Menu::showWikipediaFrame(QString title, QString text) {
- ui->wikipediaTitle->setText(title);
- ui->wikipediaText->setHtml(text);
- ui->wikipediaFrame->setVisible(true);
- ui->thewave_spacerFrame->setVisible(false);
- ui->wikipediaFrame->setBackupText("Wikipedia Content");
-}
-
-void Menu::showFlightFrame(QString flight) {
- ui->flightNumber->setText(flight);
- ui->flightImage->setPixmap(QIcon(":/icons/flight/unknown.svg").pixmap(500, 70));
- ui->thewave_flightFrame->setVisible(true);
- ui->wikipediaFrame->setBackupText(flight + " has been cancelled.");
-}
-
-void Menu::showSettingFrame(QIcon icon, QString text, bool isOn) {
- ui->thewaveSettingsFrame_icon->setPixmap(icon.pixmap(64, 64));
- ui->thewaveSettingsFrame_Name->setText(text);
- ui->thewaveSettingsFrame_Switch->setChecked(isOn);
- ui->thewaveSettingsFrame->setVisible(true);
- ui->thewaveSettingsFrame->setBackupText(text + " has been switched " + (isOn ? "on" : "off"));
-}
-
-void Menu::showMathematicsFrame(QString expression, QString answer) {
- ui->thewaveMathematicsFrame->setVisible(true);
- ui->thewaveMathematics_expression->setText(expression);
- ui->thewaveMathematics_answer->setText(answer);
- ui->thewaveMathematicsFrame->setBackupText(expression + answer);
-}
-
-void Menu::on_thewave_line_returnPressed()
-{
- while (!istheWaveReady) {
- QApplication::processEvents();
- }
- emit thewave_processText(ui->thewave_line->text());
- thewave_outputSpeech(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) {
- ui->thewave_launchFrame->setVisible(true);
- QList apps;
- for (App app : ((AppsListModel*) ui->appsListView->model())->availableApps()) {
- if (app.name().remove(" ").contains(appName.remove(" "), Qt::CaseInsensitive)) {
- apps.append(app);
- }
- }
-
- if (apps.count() == 0) {
- ui->thewave_launch_appIcon->setVisible(false);
- ui->thewave_launch_appName->setVisible(false);
- ui->thewave_launch_error->setVisible(true);
- ui->thewave_launch_launchapp->setVisible(false);
- ui->thewave_spacerFrame->setVisible(true);
- } else if (apps.count() == 1) {
- ui->thewave_launch_appIcon->setVisible(true);
- ui->thewave_launch_appName->setVisible(true);
- ui->thewave_launch_error->setVisible(false);
- ui->thewave_launchOneAppFrame->setVisible(true);
- ui->thewave_launch_disambiguation->setVisible(false);
- ui->thewave_launch_launchapp->setVisible(true);
- ui->thewave_spacerFrame->setVisible(true);
-
- ui->thewave_launch_appName->setText(apps.first().name());
- ui->thewave_launch_appIcon->setPixmap(apps.first().icon().pixmap(64));
- ui->thewave_launch_launchapp->setProperty("appcommand", apps.first().command());
-
-
- emit thewave_sayLaunchApp(apps.first().name());
- } else {
- ui->thewave_launch_error->setVisible(false);
- ui->thewave_launchOneAppFrame->setVisible(false);
- ui->thewave_launch_disambiguation->setVisible(true);
- ui->thewave_spacerFrame->setVisible(false);
-
- ui->thewave_launch_disambiguation->clear();
- QStringList appNames;
- for (App app : apps) {
- QListWidgetItem* item = new QListWidgetItem();
- item->setText(app.name());
- item->setIcon(app.icon());
- item->setData(Qt::UserRole, app.command());
- ui->thewave_launch_disambiguation->addItem(item);
- appNames.append(app.name());
- }
-
- emit (thewave_sayLaunchApp_disambiguation(appNames));
- }
-}
-
-void Menu::on_thewave_launch_launchapp_clicked()
-{
- QProcess::startDetached(ui->thewave_launch_launchapp->property("appcommand").toString().remove("%u"));
- this->close();
-}
-
void Menu::on_commandLinkButton_6_clicked()
{
this->close();
@@ -954,41 +499,6 @@ void Menu::on_commandLinkButton_4_clicked()
QDBusConnection::systemBus().send(message);
}
-void Menu::on_listentheWave_clicked()
-{
- if (this->isListening) {
- emit thewaveStop();
- } else {
- emit thewaveBegin();
- }
-}
-
-void Menu::on_thewave_launch_disambiguation_itemClicked(QListWidgetItem *item)
-{
- QProcess::startDetached(item->data(Qt::UserRole).toString().remove("%u"));
- this->close();
-}
-
-void Menu::on_thewaveSettingsFrame_Switch_toggled(bool checked)
-{
- emit currentSettingChanged(checked);
-}
-
-void Menu::on_thewaveMedia_Next_clicked()
-{
- MainWin->nextSong();
-}
-
-void Menu::on_thewaveMedia_Play_clicked()
-{
- MainWin->playPause();
-}
-
-void Menu::on_thewaveMedia_Back_clicked()
-{
- MainWin->previousSong();
-}
-
void Menu::mousePressEvent(QMouseEvent *event) {
}
@@ -1001,50 +511,6 @@ void Menu::mouseReleaseEvent(QMouseEvent *event) {
}
-theWaveFrame::theWaveFrame(QWidget *parent) : QFrame(parent)
-{
-
-}
-
-void theWaveFrame::mousePressEvent(QMouseEvent *event) {
- if (event->button() == Qt::LeftButton) {
- this->startPosition = event->pos();
- }
-}
-
-void theWaveFrame::mouseMoveEvent(QMouseEvent *event)
- {
- if (event->buttons() & Qt::LeftButton && ((event->pos() - this->startPosition).manhattanLength() >= QApplication::startDragDistance())) {
- QPixmap pixmap = this->grab();
- QByteArray pngArray;
- QBuffer buffer(&pngArray);
- buffer.open(QIODevice::WriteOnly);
- pixmap.save(&buffer, "PNG");
- buffer.close();
-
- QDrag *drag = new QDrag(this);
- QMimeData *mime = new QMimeData();
- mime->setData("image/png", pngArray);
- /*if (this->backupText() != "") {
- //mime->setText(this->backupText());
- mime->setText(this->backupText());
- }*/
- drag->setMimeData(mime);
- drag->setPixmap(pixmap);
- ((Menu*) this->window())->collapse();
- drag->exec();
- ((Menu*) this->window())->uncollapse();
- }
-}
-
-void theWaveFrame::setBackupText(QString text) {
- this->bText = text;
-}
-
-QString theWaveFrame::backupText() {
- return this->bText;
-}
-
void Menu::on_exitButton_clicked()
{
QApplication::exit(0);
diff --git a/menu.h b/menu.h
index 20985d2..9aae5fe 100644
--- a/menu.h
+++ b/menu.h
@@ -34,7 +34,6 @@
#include
#include "endsessionwait.h"
#include "mainwindow.h"
-#include "thewaveworker.h"
#include "dbusevents.h"
#include "tutorialwindow.h"
#include "bthandsfree.h"
@@ -43,27 +42,6 @@
#undef KeyPress
-class theWaveWorker;
-
-class theWaveFrame : public QFrame
-{
- Q_OBJECT
- Q_PROPERTY(QString backupText READ backupText WRITE setBackupText)
-public:
- explicit theWaveFrame(QWidget *parent = 0);
-
-signals:
-
-public slots:
- QString backupText();
- void setBackupText(QString text);
-private:
- QPoint startPosition;
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- QString bText;
-};
-
namespace Ui {
class Menu;
}
@@ -79,31 +57,14 @@ public:
void setGeometry(int x, int y, int w, int h);
void setGeometry(QRect geometry);
- void show(bool openTotheWave = false, bool startListening = false);
+ void show();
void close();
- QFrame* theWaveFrame;
-
signals:
void menuClosing();
- void thewave_processText(QString text, bool isText = false);
-
- void thewave_sayLaunchApp(QString app);
-
- void thewave_sayLaunchApp_disambiguation(QStringList apps);
-
- void thewaveBegin();
-
- void thewaveStop();
-
void currentSettingChanged(bool isOn);
-public slots:
- void collapse();
-
- void uncollapse();
-
private slots:
void checkForclose();
@@ -131,56 +92,10 @@ 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();
-
- void on_thewave_launch_launchapp_clicked();
-
- void thewave_outputSpeech(QString speech);
-
- void showFlightFrame(QString flight);
-
- void thewaveLoudnessChanged(qreal loudness);
-
void on_commandLinkButton_6_clicked();
void on_commandLinkButton_4_clicked();
- void on_listentheWave_clicked();
-
- void on_thewave_launch_disambiguation_itemClicked(QListWidgetItem *item);
-
- void showSettingFrame(QIcon icon, QString text, bool isOn);
-
- void on_thewaveSettingsFrame_Switch_toggled(bool checked);
-
- void showMathematicsFrame(QString expression, QString answer);
-
- void showMediaFrame(QPixmap art, QString title, QString artist, bool isPlaying);
-
- void on_thewaveMedia_Next_clicked();
-
- void on_thewaveMedia_Play_clicked();
-
- void on_thewaveMedia_Back_clicked();
-
void on_exitButton_clicked();
void on_fakeEndButton_clicked();
@@ -204,7 +119,6 @@ private:
int pinnedAppsCount = 0;
bool doCheckForClose = false;
- bool istheWaveOpen = false;
//void closeEvent(QCloseEvent *event);
void paintEvent(QPaintEvent* event);
@@ -216,10 +130,7 @@ private:
void reject();
- theWaveWorker* waveWorker;
BTHandsfree* bt;
- bool isListening = false;
- bool istheWaveReady = false;
};
#endif // MENU_H
diff --git a/menu.ui b/menu.ui
index 09440f2..df778f4 100644
--- a/menu.ui
+++ b/menu.ui
@@ -7,7 +7,7 @@
0
0
560
- 3202
+ 1132
@@ -189,26 +189,6 @@
- -
-
-
- true
-
-
- theWave
-
-
-
-
-
-
- :/icons/thewave.svg:/icons/thewave.svg
-
-
- true
-
-
-
-
@@ -598,1386 +578,8 @@ color: #FFF;
- -
-
-
- true
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- theWave
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
-
-
- false
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- TextLabel
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- TextLabel
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Hit "Speak" to start speaking.
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
- true
-
-
-
- -
-
-
- 0
-
-
- false
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Call
-
-
-
- -
-
-
- false
-
-
-
-
-
- Phone Number
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Can't call from this device.
-
-
-
- -
-
-
- false
-
-
- Call
-
-
-
- ..
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Message
-
-
-
- -
-
-
- false
-
-
-
-
-
- Phone Number
-
-
-
- -
-
-
- false
-
-
- Message
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Can't send messages from this device
-
-
-
- -
-
-
- false
-
-
- Send
-
-
-
- ..
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Help
-
-
-
- -
-
-
- Try these:
-
-
-
- -
-
-
-
-
-
- TextLabel
-
-
-
- -
-
-
- I can help you set a timer.
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
- If you're on a supported device, I can place calls for you
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- If you have supported software, I can send instant messages, or if you are on a supported device, I can send text messages.
-
-
- true
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
- I can get information from online sources
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
- I can open apps
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
- I can do some calculations
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
- I can change some settings for you
-
-
-
- -
-
-
- TextLabel
-
-
-
- -
-
-
- I can control the media player
-
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Wikipedia
-
-
-
- -
-
-
-
- 15
-
-
-
- Title of page.
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- <!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:'Contemporary'; font-size:10pt; 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;"><span style=" font-size:12pt;">Text</span></p></body></html>
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Open in Browser
-
-
-
- ..
-
-
- true
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Weather
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Launch
-
-
-
- -
-
-
- Couldn't find the app you wanted to launch.
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
-
-
- appIcon
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- App Name
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Launch
-
-
-
- ..
-
-
- true
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Flight
-
-
-
- -
-
-
-
- 15
-
-
-
- Airline 000
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Can't get flight information
-
-
-
- -
-
-
- 6
-
-
-
-
-
-
- 15
-
-
-
- ???
-
-
-
- -
-
-
-
- 15
-
-
-
- ???
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- FlightImage
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Settings
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
- Icon
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Bluetooth
-
-
-
- -
-
-
- SettingSwitch
-
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Mathematics
-
-
-
- -
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 15
-
-
-
- 5 + 23
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 20
-
-
-
- 28
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 20
-
-
-
- Media Player
-
-
-
- -
-
-
-
-
-
- albumArt
-
-
-
- -
-
-
- 0
-
-
-
-
-
-
- 0
- 0
-
-
-
-
-
-
-
- -
-
-
- false
-
-
-
- 0
- 0
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
- ../tsscreenlock../tsscreenlock
-
-
- true
-
-
-
- -
-
-
-
-
-
-
- ../tsscreenlock../tsscreenlock
-
-
-
- 32
- 32
-
-
-
- true
-
-
-
- -
-
-
-
-
-
-
- ../tsscreenlock../tsscreenlock
-
-
- true
-
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- TextLabel
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- You're disconnected from the internet. Results are limited.
-
-
-
-
-
-
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
-
- 20
-
-
-
- Hello!
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- Go for it!
-
-
- Qt::AlignCenter
-
-
- true
-
-
-
- -
-
-
-
- 0
- 50
-
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
-
-
-
-
- 20
-
-
-
- theWave has been disabled.
-
-
-
- -
-
-
- Go to theWave settings to enable it.
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Speak
-
-
-
- ..
-
-
- true
-
-
-
- -
-
-
- Close
-
-
-
- ..
-
-
- true
-
-
-
-
-
-
-
-
-
-
- Switch
- QPushButton
-
-
-
- theWaveFrame
- QFrame
-
- 1
-
-
- theWaveFeedbackFrame
- QFrame
-
- 1
-
-
diff --git a/nativeeventfilter.cpp b/nativeeventfilter.cpp
index c8d2ec5..ff45b26 100644
--- a/nativeeventfilter.cpp
+++ b/nativeeventfilter.cpp
@@ -47,7 +47,6 @@ NativeEventFilter::NativeEventFilter(QObject* parent) : QObject(parent)
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Delete), ControlMask | Mod1Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_L), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F2), Mod1Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
- XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_space), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_P), Mod4Mask | Mod1Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F1), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F2), Mod4Mask, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
@@ -86,7 +85,6 @@ NativeEventFilter::~NativeEventFilter() {
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F2), Mod1Mask, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Super_L), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_Super_R), AnyModifier, QX11Info::appRootWindow());
- XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_space), Mod4Mask, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_P), Mod4Mask | Mod1Mask, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F1), Mod4Mask, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XK_F2), Mod4Mask, QX11Info::appRootWindow());
@@ -273,9 +271,6 @@ bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *mes
MainWin->openMenu();
}
ignoreSuper = false;
- } else if (button->detail == XKeysymToKeycode(QX11Info::display(), XK_space) && button->state == Mod4Mask) { //theWave
- ignoreSuper = true;
- MainWin->openMenu(true, true);
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XK_F1) && (button->state == Mod4Mask)) {
MainWin->getInfoPane()->show(InfoPaneDropdown::Clock);
ignoreSuper = true;
diff --git a/onboarding.cpp b/onboarding.cpp
index 80f0e40..51d9aff 100644
--- a/onboarding.cpp
+++ b/onboarding.cpp
@@ -22,7 +22,12 @@
#include "ui_onboarding.h"
#include "internationalisation.h"
-#define ChangelogOnbording "New in theShell 7.0:\n"\
+#define ChangelogOnbording \
+ "New in theShell 7.1:\n"\
+ "- theWave has been discontinued.\n"\
+ "- New Notifications system\n"\
+ "\n"\
+ "New in theShell 7.0:\n"\
"- Quiet Mode has been added to theShell! Click on the volume icon in the bar, or head to the Notifications Status Center pane to change the setting.\n"\
"- The Gateway has been revamped and now shows your apps properly, as well as updates automatically whenever you install a new app.\n"\
"- Flight Mode has been added\n"\
@@ -100,7 +105,6 @@ Onboarding::Onboarding(QWidget *parent) :
//ui->buttonBox->setVisible(false);
ui->backButton->setVisible(false);
ui->changelog->setText(ChangelogOnbording);
- ui->thewaveLogo->setPixmap(QIcon(":/icons/thewave.svg").pixmap(256, 256));
ui->stackedWidget->setCurrentIndex(0);
ui->welcomeLabel->setText(tr("Welcome to theShell %1!").arg(TS_VERSION));
ui->tsLogo->setPixmap(QIcon::fromTheme("theshell").pixmap(256, 256));
@@ -171,10 +175,9 @@ void Onboarding::on_stackedWidget_currentChanged(int arg1)
ui->backButton->setVisible(false);
break;
case 3:
- case 4:
ui->nextButton->setEnabled(false);
break;
- case 5:
+ case 4:
ui->nextButton->setText(tr("Start"));
break;
}
@@ -182,7 +185,7 @@ void Onboarding::on_stackedWidget_currentChanged(int arg1)
void Onboarding::on_nextButton_clicked()
{
- if (ui->stackedWidget->currentIndex() == 5) {
+ if (ui->stackedWidget->currentIndex() == 4) {
onboardingDone = true;
this->accept();
} else {
@@ -201,18 +204,6 @@ void Onboarding::on_beginButton_clicked()
this->accept();
}
-void Onboarding::on_enabletheWaveButton_clicked()
-{
- settings.setValue("thewave/enabled", true);
- ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex() + 1);
-}
-
-void Onboarding::on_disabletheWaveButton_clicked()
-{
- settings.setValue("thewave/enabled", false);
- ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex() + 1);
-}
-
void Onboarding::on_changeLanguageButton_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
diff --git a/onboarding.h b/onboarding.h
index 699131f..5bc78b5 100644
--- a/onboarding.h
+++ b/onboarding.h
@@ -54,10 +54,6 @@ private slots:
void on_beginButton_clicked();
- void on_enabletheWaveButton_clicked();
-
- void on_disabletheWaveButton_clicked();
-
void on_changeLanguageButton_clicked();
void on_localeList_currentRowChanged(int currentRow);
diff --git a/onboarding.ui b/onboarding.ui
index 1192d6f..8d1b8be 100644
--- a/onboarding.ui
+++ b/onboarding.ui
@@ -257,137 +257,6 @@ p, li { white-space: pre-wrap; }
-
-
- true
-
-
- -
-
-
-
- 20
-
-
-
- theWave
-
-
-
- -
-
-
- theWave is a personal assistant that comes with theShell.
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- theWave Logo
-
-
- false
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- You can find theWave inside the Gateway or on the bar.
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
-
-
-
- 20
-
-
-
- Enable theWave
-
-
-
- -
-
-
- Disable theWave
-
-
- true
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
true
diff --git a/resources.qrc b/resources.qrc
index 7fdf67a..3c78683 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -33,7 +33,6 @@
icon.svg
- thewave.svg
blank.svg
icon-bp.svg
diff --git a/theShell.pro b/theShell.pro
index 68912ff..f301bb6 100644
--- a/theShell.pro
+++ b/theShell.pro
@@ -59,7 +59,6 @@ SOURCES += main.cpp\
upowerdbus.cpp \
infopanedropdown.cpp \
clickablelabel.cpp \
- thewaveworker.cpp \
loginsplash.cpp \
hoverframe.cpp \
choosebackground.cpp \
@@ -73,7 +72,6 @@ SOURCES += main.cpp\
dbusevents.cpp \
fadebutton.cpp \
rundialog.cpp \
- thewavefeedbackframe.cpp \
mousescrollwidget.cpp \
animatedstackedwidget.cpp \
onboarding.cpp \
@@ -104,7 +102,6 @@ HEADERS += mainwindow.h \
upowerdbus.h \
infopanedropdown.h \
clickablelabel.h \
- thewaveworker.h \
loginsplash.h \
hoverframe.h \
choosebackground.h \
@@ -118,7 +115,6 @@ HEADERS += mainwindow.h \
dbusevents.h \
fadebutton.h \
rundialog.h \
- thewavefeedbackframe.h \
mousescrollwidget.h \
animatedstackedwidget.h \
onboarding.h \
diff --git a/thewave.svg b/thewave.svg
deleted file mode 100644
index 6a78a2a..0000000
--- a/thewave.svg
+++ /dev/null
@@ -1,145 +0,0 @@
-
-
-
-
diff --git a/thewavefeedbackframe.cpp b/thewavefeedbackframe.cpp
deleted file mode 100644
index f6e57f3..0000000
--- a/thewavefeedbackframe.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************
- *
- * theShell - Desktop Environment
- * Copyright (C) 2017 Victor Tran
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * *************************************/
-
-#include "thewavefeedbackframe.h"
-
-theWaveFeedbackFrame::theWaveFeedbackFrame(QWidget *parent) : QFrame(parent)
-{
- connect(&indeterminateTimer, SIGNAL(timeout()), this, SLOT(repaint()));
- indeterminateTimer.setInterval(10);
- for (int i = 0; i < this->width(); i = i + 2) {
- levels.append((qreal) 1 / (qreal) this->height());
- }
-}
-
-void theWaveFeedbackFrame::paintEvent(QPaintEvent *event) {
- QPainter painter(this);
- int i = this->width();
- if (indeterminate) {
- //qreal random = (qreal) qrand() / (RAND_MAX);
- levels.insert(0, (qSin(qDegreesToRadians((qreal) indeterminateStage * 3 - 90))) / 2 + 0.5);
- indeterminateStage++;
- }
- for (qreal level : levels) {
- //painter.drawLine(i, this->height(), i, this->height() - (level * this->height()));
- int distanceFromMiddle = (level * this->height()) / 2;
- painter.drawLine(i, this->height() / 2 + distanceFromMiddle, i, this->height() / 2 - distanceFromMiddle);
- i = i - 2;
- }
-
- event->accept();
-}
-
-void theWaveFeedbackFrame::addLevel(qreal level) {
- if (level == -1) { //Processing
- indeterminate = true;
- indeterminateTimer.start();
- } else if (level == -2) { //Reset
- levels.clear();
- for (int i = 0; i < this->width(); i = i + 2) {
- levels.append((qreal) 1 / (qreal) this->height());
- }
- indeterminateTimer.stop();
-
- } else {
- levels.insert(0, level);
- this->repaint();
- indeterminate = false;
- indeterminateStage = 0;
- indeterminateTimer.stop();
- }
-}
diff --git a/thewavefeedbackframe.h b/thewavefeedbackframe.h
deleted file mode 100644
index 79cdf6b..0000000
--- a/thewavefeedbackframe.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************
- *
- * theShell - Desktop Environment
- * Copyright (C) 2017 Victor Tran
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * *************************************/
-
-#ifndef THEWAVEFEEDBACKFRAME_H
-#define THEWAVEFEEDBACKFRAME_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-class theWaveFeedbackFrame : public QFrame
-{
- Q_OBJECT
-public:
- explicit theWaveFeedbackFrame(QWidget *parent = 0);
-
-signals:
-
-public slots:
- void addLevel(qreal level);
-
-private:
- void paintEvent(QPaintEvent *event);
-
- QList levels;
- bool indeterminate = false;
- int indeterminateStage = 0;
- QTimer indeterminateTimer;
-};
-
-#endif // THEWAVEFEEDBACKFRAME_H
diff --git a/thewaveworker.cpp b/thewaveworker.cpp
deleted file mode 100644
index 8dd5604..0000000
--- a/thewaveworker.cpp
+++ /dev/null
@@ -1,1287 +0,0 @@
-/****************************************
- *
- * theShell - Desktop Environment
- * Copyright (C) 2017 Victor Tran
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * *************************************/
-
-#include "thewaveworker.h"
-
-extern MainWindow* MainWin;
-extern AudioManager* AudioMan;
-
-theWaveWorker::theWaveWorker(QObject *parent) : QObject(parent)
-{
- startListeningSound = new QSoundEffect(this);
- startListeningSound->setSource(QUrl("qrc:/sounds/listening.wav"));
- okListeningSound = new QSoundEffect(this);
- okListeningSound->setSource(QUrl("qrc:/sounds/ok.wav"));
- errorListeningSound = new QSoundEffect(this);
- errorListeningSound->setSource(QUrl("qrc:/sounds/what.wav"));
- stopListeningSound = new QSoundEffect(this);
- stopListeningSound->setSource(QUrl("qrc:/sounds/notlistening.wav"));
-
- if (this->settings.value("thewave/enabled", true).toBool()) {
- geolocationSource = QGeoPositionInfoSource::createDefaultSource(this);
- connect(geolocationSource, &QGeoPositionInfoSource::positionUpdated, [=](QGeoPositionInfo position) {
- this->currentCoordinates = position.coordinate();
- });
- geolocationSource->startUpdates();
-
- numberDictionary["quarter"] = 0.25;
- numberDictionary["half"] = 0.5;
- numberDictionary["zero"] = 0;
- numberDictionary["a"] = 1;
- numberDictionary["one"] = 1;
- numberDictionary["two"] = 2;
- numberDictionary["three"] = 3;
- numberDictionary["four"] = 4;
- numberDictionary["five"] = 5;
- numberDictionary["six"] = 6;
- numberDictionary["seven"] = 7;
- numberDictionary["eight"] = 8;
- numberDictionary["nine"] = 9;
- numberDictionary["ten"] = 10;
- numberDictionary["eleven"] = 11;
- numberDictionary["twelve"] = 12;
- numberDictionary["thirteen"] = 13;
- numberDictionary["fourteen"] = 14;
- numberDictionary["fifteen"] = 15;
- numberDictionary["sixteen"] = 16;
- numberDictionary["seventeen"] = 17;
- numberDictionary["eighteen"] = 18;
- numberDictionary["nineteen"] = 19;
- numberDictionary["twenty"] = 20;
- numberDictionary["thirty"] = 30;
- numberDictionary["forty"] = 40;
- numberDictionary["fifty"] = 50;
- numberDictionary["sixty"] = 60;
- numberDictionary["seventy"] = 70;
- numberDictionary["eighty"] = 80;
- numberDictionary["ninety"] = 90;
- numberDictionary["hundred"] = 100;
- numberDictionary["thousand"] = 1000;
- numberDictionary["million"] = 1000000;
-
- numberDictionary["pi"] = M_PI;
- numberDictionary["tau"] = M_PI * 2;
- numberDictionary["e"] = M_E;
-
- recorder = new QAudioRecorder(this);
- QAudioEncoderSettings settings;
- settings.setCodec("audio/PCM");
- settings.setChannelCount(1);
- settings.setSampleRate(16000);
- settings.setQuality(QMultimedia::NormalQuality);
- settings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
-
- probe = new QAudioProbe(this);
- connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(soundBuffer(QAudioBuffer)));
- oldLoudness = 0;
-
- QFile(QDir::homePath() + "/.thewaveSpeech.wav").remove();
- recorder->setEncodingSettings(settings, QVideoEncoderSettings(), "wav");
- recorder->setOutputLocation(QUrl::fromLocalFile(QDir::homePath() + "/.thewaveSpeech.wav"));
-
- testRecorder = new QAudioRecorder(this);
- testRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), "wav");
- testRecorder->setOutputLocation(QUrl::fromLocalFile(QDir::homePath() + "/.thewaveBeforeSpeech.wav"));
- } else {
- this->disabled = true;
- }
-}
-
-theWaveWorker::~theWaveWorker() {
- this->stopEverything = true;
- emit finished();
-}
-
-void theWaveWorker::begin() {
- if (!isRunning) {
- //Attenuate all audio on system
- AudioMan->attenuateStreams();
-
- isRunning = true;
- if (resetOnNextBegin) { //Check if we need to reset frames
- resetOnNextBegin = false; //Reset Frame Reset bit
- emit resetFrames(); //Tell UI to reset frames
- }
-
- maxLoudnessForSession = 0; //Reset maximum loudness
- isListeningAfterLoudnessChange = false; //Reset if recorder is listening
- //recorder->record(); //Record audio
- testRecorder->record();
- probe->setSource(testRecorder);
-
- endListenTimer.start(); //Start end listening timer
- startListeningSound->play(); //Play start sound
- emit outputSpeech("Go for it!");
- emit startedListening(); //Tell UI that we're listening
-
- if (this->state == Idle) {
- emit showBigListenFrame();
- }
- noVoiceInput = true;
- }
-}
-
-void theWaveWorker::soundBuffer(QAudioBuffer buffer) {
- //Get loudness of sound
- qreal loudness = 0;
- qreal peak_value(USHRT_MAX);
-
- for (int i = 0; i < buffer.frameCount(); i++) {
- qreal value = qAbs(qreal(buffer.constData()[i]));
- if (value > loudness) {
- loudness = value;
- }
- }
-
- loudness /= peak_value;
-
- emit loudnessChanged(loudness);
-
- //If loudness has changed considerably, reset timer
- if (oldLoudness - 0.01 > loudness || oldLoudness + 0.01 < loudness) {
- oldLoudness = loudness;
- endListenTimer.restart();
- }
-
- //Set the maximum loudness
- if (maxLoudnessForSession < loudness) {
- maxLoudnessForSession = loudness;
- if (!isListeningAfterLoudnessChange && loudness > 0.1) { //Start actual recording now
- emit outputSpeech("Listening...");
- testRecorder->stop();
- isListeningAfterLoudnessChange = true;
- recorder->record();
- probe->setSource(recorder);
- }
- }
-
- //If loudness has stayed the same for a second and there has been audio input, stop listening.
- if (endListenTimer.elapsed() >= 1000 && maxLoudnessForSession > 0.1) {
- endAndProcess();
- }
-}
-
-void theWaveWorker::endAndProcess() {
- if (isRunning) {
- recorder->stop();
- testRecorder->stop();
- emit stoppedListening();
- emit loudnessChanged(-1);
-
- if (recorder->duration() <= 1000 || maxLoudnessForSession < 0.1) { //Don't process if too short or not loud enough
- stopListeningSound->play();
- emit loudnessChanged(-2);
- emit outputSpeech("");
-
- //Restore all sounds on system
- AudioMan->restoreStreams();
-
- if (this->state == Idle) {
- emit hideBigListenFrame();
- }
- isRunning = false;
- } else {
- okListeningSound->play();
- emit outputSpeech("Processing...");
-
- speechProc = new QProcess(this);
- speechProc->setProcessChannelMode(QProcess::MergedChannels);
- connect(speechProc, SIGNAL(readyRead()), this, SLOT(outputAvailable()));
- connect(speechProc, static_cast(&QProcess::finished),
- [=](){
- if (noVoiceInput) {
- processSpeech("");
- }
- });
- speechProc->start("pocketsphinx_continuous -infile \"" + QDir::homePath() + "/.thewaveSpeech.wav\"");
- speechProc->waitForStarted();
- }
- }
-}
-
-void theWaveWorker::outputAvailable() {
- buffer.append(QString(speechProc->readAll()));
-
- if (buffer.endsWith("\n")) {
- QStringList bufferOutput = buffer.split("\n");
- for (QString outputString : bufferOutput) {
- qDebug() << outputString;
- if (outputString.startsWith("INFO:")) {
- } else if (outputString.startsWith("-") || outputString == "Current configuration:" || outputString.startsWith("[NAME]")) {
- } else {
- if (outputString != "") {
- noVoiceInput = false;
- emit outputSpeech(outputString);
- processSpeech(outputString);
- disconnect(speechProc, SIGNAL(readyRead()), this, SLOT(outputAvailable()));
- speechProc->kill();
- speechProc->deleteLater();
- //delete speechProc;
- emit loudnessChanged(-2);
- }
- }
- }
- buffer = "";
- }
-}
-
-void theWaveWorker::processSpeech(QString speech, bool voiceFeedback) {
- if (this->settings.value("thewave/enabled", true).toBool()) {
- QString name = settings.value("thewave/name").toString();
- if (resetOnNextBegin) {
- resetOnNextBegin = false;
- emit resetFrames();
- }
- QString parse = speech.toLower();
- QStringList words = parse.split(" ");
- if (speech == "") {
- QString output;
- switch (qrand() % 5) {
- case 0:
- output = "That flew past me. Try again.";
- break;
- case 1:
- output = "Not sure what you said. Try again.";
- break;
- case 2:
- output = "I didn't get that. Could you please say that again?";
- break;
- case 3:
- output = "Sorry, what was that again?";
- break;
- case 4:
- output = "I don't know what you just said. Try again.";
- break;
- }
-
- emit outputResponse(output);
- emit outputSpeech(output);
- speak(output, voiceFeedback);
- } else {
- switch (this->state) {
- case Idle:
- emit hideBigListenFrame();
- if (words.contains("call") || words.contains("ring") || words.contains("dial")) { //Place 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(false);
- resetOnNextBegin = true;
- } else if (words.contains("text") || words.contains("message")) { //Send Text Message
- emit outputResponse("Unfortunately, I can't send text messages from this device. This functionality may come later for IM applications.");
- speak("Unfortunately, I can't send text messages from this device.");
- emit showMessageFrame();
- resetOnNextBegin = true;
- } else if (words.contains("e-mail") || words.contains("email")) { //Send Email
- //if (launchAkonadi()) {
- //emit outputResponse("Who are you sending this email to?");
- //speak("Who are you sending this email to?"); //Pronunciation issues... :P
- //this->state = emailGetRecipient;
- //}
- emit outputResponse("I'm not able to send email yet. Sorry about that.");
- speak("I'm not able to send email yet. Sorry about that."); //Pronunciation issues... :P
-
- } else if (words.contains("timer") || words.contains("countdown") || parse.contains("count down")) { //Set Timer
- QStringList parseSpace = parse.split(" ");
- int currentNumber = 0, hour = 0, minute = 0, second = 0;
- for (QString part : parseSpace) {
- if (numberDictionary.contains(part)) {
- currentNumber = currentNumber + numberDictionary.value(part);
- } else if (part.contains("hour")) {
- hour = hour + currentNumber;
- currentNumber = 0;
- } else if (part.contains("minute")) {
- minute = minute + currentNumber;
- currentNumber = 0;
- } else if (part.contains("second")) {
- second = second + currentNumber;
- currentNumber = 0;
- }
- }
-
- 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?", voiceFeedback);
- state = TimerGetTime;
- } else {
- goto TimerGetTime;
- }
- } else if (words.contains("help") || parse.contains("what can you do")) { //Get Help
- 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)) { //Launch App
- emit launchApp(parse.remove(0, 6));
- } else if (words.contains("flight")) { //Flight Information
- emit showFlightFrame("Unknown Airline 000");
- emit outputResponse("I can't find flight information at the moment.");
- speak("I can't find flight information at the moment.");
- resetOnNextBegin = true;
- } else if (words.contains("turn") || words.contains("switch") || words.contains("on") || words.contains("off")) { //Settings
- bool isOn;
- if (words.contains("on")) {
- isOn = true;
- } else if (words.contains("off")) {
- isOn = false;
- } else {
- emit outputResponse("Not sure what you want me to do with that setting. Try telling me to switch on or off.");
- speak("Not sure what you want me to do with that setting.");
- return;
- }
- if (words.contains("wi-fi") || words.contains("wifi")) {
- this->currentSetting = "wifi";
- emit showSettingsFrame(QIcon::fromTheme("network-wireless"), "Wi-Fi", isOn);
- this->SetSetting("wifi", isOn);
- if (isOn) {
- emit outputResponse("Wi-Fi has been turned on.");
- speak("Wi-Fi has been turned on.");
- } else {
- emit outputResponse("Wi-Fi has been turned off.");
- speak("Wi-Fi has been turned off.");
- }
- } else {
- if (isOn) {
- emit outputResponse("Not sure what you want me to turn on. You can try asking me a different way.");
- speak("Not sure what you want me to turn on.");
- } else {
- emit outputResponse("Not sure what you want me to turn off. You can try asking me a different way.");
- speak("Not sure what you want me to turn off.");
- }
- }
- resetOnNextBegin = true;
- } else if (parse == "where am i") { //Geolocation
- geolocationSource->requestUpdate();
- QGeoCoordinate coordinates = this->currentCoordinates;
- QString output;
- if (coordinates.isValid()) {
- output = "You're at " + QString::number(coordinates.latitude()) + " " + QString::number(coordinates.longitude());
- } else {
- output = "I'm not quite sure where you are.";
- }
- emit outputResponse(output);
- speak(output);
- } else if (words.contains("song") || words.contains("playing") || words.contains("play") || words.contains("pause") ||
- ((words.contains("track") || words.contains("song") || words.contains("playing")) &&
- (words.contains("next") || words.contains("previous") || words.contains("now") || words.contains("current") || words.contains("what")))) { //Media Player Controls
- if (words.contains("pause")) {
- MainWin->pause();
- emit outputResponse("Paused.");
- speak("Paused");
- } else if (words.contains("play")) {
- MainWin->play();
- emit outputResponse("Playing.");
- speak("Playing");
- } else if (words.contains("next")) {
- MainWin->nextSong();
- emit outputResponse("Next Track");
- speak("Next Track");
- } else if (words.contains("previous")) {
- MainWin->previousSong();
- emit outputResponse("Previous Track");
- speak("Previous Track");
- } else if (words.contains("playing") || words.contains("current") || words.contains("what")) {
- if (MainWin->isMprisAvailable()) {
- QString title = MainWin->songName();
- QString artists = MainWin->songArtist();
- QString album = MainWin->songAlbum();
- bool playing = MainWin->isMprisPlaying();
- QPixmap art = QIcon::fromTheme("audio").pixmap(32, 32);
- QString response = "Not sure what you want me to do with the music.";
- if (title != "" && artists != "" && album != "") {
- response = "Right now, " + title + " by " + artists + " on the album " + album + " is playing.";
- emit showMediaFrame(art, title, artists + " · " + album, playing);
- } else if (title != "" && artists != "" && album == "") {
- response = "Right now, " + title + " by " + artists + " is playing.";
- emit showMediaFrame(art, title, artists, playing);
- } else if (title != "" && artists == "" && album != "") {
- response = "Right now, " + title + " on the album " + album + " is playing.";
- emit showMediaFrame(art, title, album, playing);
- } else if (title != "" && artists == "" && album != "") {
- response = "Right now, " + title + " is playing.";
- emit showMediaFrame(art, title, MainWin->mprisApp(), playing);
- } else {
- response = "I'm not sure what's playing now.";
- //emit showMediaFrame(art, title, artists + " · " + album);
- }
- emit outputResponse(response);
- speak(response);
- } else {
- emit outputResponse("There's no media player open now.");
- speak("There's no media player open now.");
- }
- }
- resetOnNextBegin = true;
- } else if ((words.contains("calculate") || words.contains("add") || words.contains("plus") || parse.contains("+") || words.contains("subtract") || words.contains("minus") ||
- parse.contains("-") || words.contains("times") || words.contains("multiply") || parse.contains("*") ||
- words.contains("over") || words.contains("divide") || parse.contains("divided by") ||
- parse.contains("/") || words.contains("exponent") || parse.contains("to the power of") || parse.contains("^") ||
- words.contains("squared") || words.contains("cubed") || words.contains("factorial"))) {
- if (QFile("/usr/bin/thecalculator").exists()) {
- QString numbersAndOperations = parse;
- numbersAndOperations.remove("calculate");
- numbersAndOperations.remove("what is");
- numbersAndOperations.remove("what's");
- numbersAndOperations.replace("add", "+");
- numbersAndOperations.replace("plus", "+");
- numbersAndOperations.replace("minus", "-");
- numbersAndOperations.replace("subtract", "-");
- numbersAndOperations.replace("negative", "-");
- numbersAndOperations.replace("times", "*");
- numbersAndOperations.replace("multiply", "*");
- numbersAndOperations.replace("over", "/");
- numbersAndOperations.replace("divided by", "/");
- numbersAndOperations.replace("divide", "/");
- numbersAndOperations.replace("exponent", "^");
- numbersAndOperations.replace("to the power of", "^");
- numbersAndOperations.replace("squared", "^2");
- numbersAndOperations.replace("cubed", "^3");
- numbersAndOperations.replace("factorial", "!");
-
- QStringList numberReplacer = numbersAndOperations.split(" ");
- float currentNumber = 0;
- int startIndex = -1;
- bool doingPoints = false;
- for (QString part : numberReplacer) {
- bool isNum;
- part.toFloat(&isNum);
- if (isNum) {
- } else if (part == "point") {
- if (startIndex != -1) {
- numberReplacer.replace(startIndex, QString::number(currentNumber));
- for (int i = startIndex + 1; i < numberReplacer.indexOf(part); i++) {
- numberReplacer.replace(i, "");
- }
- currentNumber = 0;
- }
- numberReplacer.replace(numberReplacer.indexOf("point"), ".");
- startIndex = numberReplacer.indexOf(part + 1);
- doingPoints = true;
- } else if (numberDictionary.keys().contains(part)) {
- float number = numberDictionary.value(part);
- if (doingPoints) {
- currentNumber = QString::number(currentNumber).append(QString::number(number)).toInt();
- } else if (number >= 100) {
- currentNumber = currentNumber * number;
- } else {
- currentNumber = currentNumber + number;
- }
- if (startIndex == -1) {
- startIndex = numberReplacer.indexOf(part);
- }
- } else {
- if (startIndex != -1) {
- numberReplacer.replace(startIndex, QString::number(currentNumber));
- for (int i = startIndex + 1; i < numberReplacer.indexOf(part); i++) {
- numberReplacer.replace(i, "");
- }
- currentNumber = 0;
- startIndex = -1;
- }
- doingPoints = false;
- }
- }
-
- if (startIndex != -1) {
- numberReplacer.replace(startIndex, QString::number(currentNumber));
- for (int i = startIndex + 1; i < numberReplacer.count(); i++) {
- numberReplacer.replace(i, "");
- }
- }
-
- numberReplacer.removeAll("");
- numbersAndOperations = numberReplacer.join("");
- numbersAndOperations.replace(" . ", ".");
-
- QString displayExpression = numbersAndOperations;
- displayExpression.replace("*", "×");
- displayExpression.replace("/", "÷");
- displayExpression.replace(" ^ 2", "²");
- displayExpression.replace(" ^ 3", "³");
- displayExpression.replace(" ^ - 1", "⁻¹");
- displayExpression.replace(" ^ - 2", "⁻²");
- displayExpression.replace(" ^ - 3", "⁻³");
- displayExpression.replace(" !", "!");
- displayExpression.append(" =");
-
- //Call on theCalculator to do the heavy work ;)
- QProcess* calc = new QProcess(this);
- calc->setProcessChannelMode(QProcess::MergedChannels);
- calc->start("thecalculator -e \"" + numbersAndOperations + "\"");
- calc->waitForFinished();
- QString answer = calc->readAll().replace("\n", "");
- bool hasErrorOccurred = calc->exitCode() == 2;
- calc->deleteLater();
-
- /*
- bool hasErrorOccurred = false;
- QString errorMessage;
- QStringList expressionToCalculate = numbersAndOperations.split(" ");
-
- while (expressionToCalculate.contains("!") && hasErrorOccurred == false) { //Calcuate Factorials
- int index = expressionToCalculate.indexOf("!");
- float number = expressionToCalculate.at(index - 1).toFloat();
- if (qFloor(number) != number || qCeil(number) != number) {
- hasErrorOccurred = true;
- errorMessage = "factorialNonInt";
- } else if (number == 0) {
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- expressionToCalculate.insert(index - 1, "0");
- } else {
- float result = 1;
-
- for (int i = 2; i <= number; i++) {
- result = result * i;
- }
-
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- expressionToCalculate.insert(index - 1, QString::number(result));
- }
- }
-
-
- while (expressionToCalculate.contains("^") && hasErrorOccurred == false) {
- int index = expressionToCalculate.indexOf("^");
- float base = expressionToCalculate.at(index - 1).toFloat();
- if (index >= 2) {
- if (expressionToCalculate.at(index - 2) == "-") {
- base = base * -1;
- }
- }
-
- float exponent;
- if (expressionToCalculate.at(index + 1) == "-") {
- exponent = expressionToCalculate.at(index + 2).toFloat() * -1;
- } else {
- exponent = expressionToCalculate.at(index + 1).toFloat();
- }
-
- if (base == 0 && exponent == 0) {
- hasErrorOccurred = true;
- errorMessage = "0^0";
- } else if (base == 0 && exponent < 0) {
- hasErrorOccurred = true;
- errorMessage = "0^neg";
- } else {
- float result = qPow(base, exponent);
- if (exponent < 0) {
- expressionToCalculate.removeAt(index + 2);
- }
- expressionToCalculate.removeAt(index + 1);
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- if (base < 0) {
- expressionToCalculate.removeAt(index - 2);
- expressionToCalculate.insert(index - 2, QString::number(result));
- } else {
- expressionToCalculate.insert(index - 1, QString::number(result));
- }
- }
- }
-
- while ((expressionToCalculate.contains("/") || expressionToCalculate.contains("*")) && hasErrorOccurred == false) {
- bool doDiv;
- int divIndex = expressionToCalculate.indexOf("/");
- int mulIndex = expressionToCalculate.indexOf("*");
-
- if (divIndex == -1) {
- doDiv = false;
- } else if (mulIndex == -1) {
- doDiv = true;
- } else if (mulIndex < divIndex) {
- doDiv = false;
- } else {
- doDiv = true;
- }
-
- if (doDiv) {
- int index = divIndex;
- float divisor = expressionToCalculate.at(index - 1).toFloat();
- if (index >= 2) {
- if (expressionToCalculate.at(index - 2) == "-") {
- divisor = divisor * -1;
- }
- }
-
- float dividend;
- if (expressionToCalculate.at(index + 1) == "-") {
- dividend = expressionToCalculate.at(index + 2).toFloat() * -1;
- } else {
- dividend = expressionToCalculate.at(index + 1).toFloat();
- }
-
- if (dividend == 0 && divisor == 0) {
- hasErrorOccurred = true;
- errorMessage = "0div0";
- } else if (dividend == 0) {
- hasErrorOccurred = true;
- errorMessage = "div0";
- } else {
- float result = divisor / dividend;
- if (dividend < 0) {
- expressionToCalculate.removeAt(index + 2);
- }
- expressionToCalculate.removeAt(index + 1);
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- if (divisor < 0) {
- expressionToCalculate.removeAt(index - 2);
- expressionToCalculate.insert(index - 2, QString::number(result));
- } else {
- expressionToCalculate.insert(index - 1, QString::number(result));
- }
- }
- } else {
- int index = mulIndex;
- float multiplicand = expressionToCalculate.at(index - 1).toFloat();
- if (index >= 2) {
- if (expressionToCalculate.at(index - 2) == "-") {
- multiplicand = multiplicand * -1;
- }
- }
-
- float multiplier;
- if (expressionToCalculate.at(index + 1) == "-") {
- multiplier = expressionToCalculate.at(index + 2).toFloat() * -1;
- } else {
- multiplier = expressionToCalculate.at(index + 1).toFloat();
- }
-
- float result = multiplicand * multiplier;
- if (multiplicand < 0) {
- expressionToCalculate.removeAt(index + 2);
- }
- expressionToCalculate.removeAt(index + 1);
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- if (multiplier < 0) {
- expressionToCalculate.removeAt(index - 2);
- expressionToCalculate.insert(index - 2, QString::number(result));
- } else {
- expressionToCalculate.insert(index - 1, QString::number(result));
- }
- }
- }
-
- int ignoreNegativeCount = 0;
- int ignoreNegativeIndex = 0;
- while ((expressionToCalculate.contains("+") || expressionToCalculate.count("-") > ignoreNegativeCount) && hasErrorOccurred == false) {
- bool doAdd;
- int addIndex = expressionToCalculate.indexOf("+");
- int subIndex = expressionToCalculate.indexOf("-", ignoreNegativeIndex);
-
- if (addIndex == -1) {
- doAdd = false;
- } else if (subIndex == -1) {
- doAdd = true;
- } else if (subIndex < addIndex) {
- doAdd = false;
- } else {
- doAdd = true;
- }
-
- if (doAdd) {
- int index = addIndex;
- float addend1 = expressionToCalculate.at(index - 1).toFloat();
- if (index >= 2) {
- if (expressionToCalculate.at(index - 2) == "-") {
- addend1 = addend1 * -1;
- }
- }
-
- float addend2;
- if (expressionToCalculate.at(index + 1) == "-") {
- addend2 = expressionToCalculate.at(index + 2).toFloat() * -1;
- } else {
- addend2 = expressionToCalculate.at(index + 1).toFloat();
- }
-
- float result = addend1 + addend2;
- if (addend2 < 0) {
- expressionToCalculate.removeAt(index + 2);
- }
- expressionToCalculate.removeAt(index + 1);
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- if (addend1 < 0) {
- expressionToCalculate.removeAt(index - 2);
- expressionToCalculate.insert(index - 2, QString::number(result));
- } else {
- expressionToCalculate.insert(index - 1, QString::number(result));
- }
- } else {
- int index = subIndex;
- if (index == 0) {
- ignoreNegativeCount++;
- ignoreNegativeIndex = index + 1;
- } else {
- bool minuendIsFloat;
- expressionToCalculate.at(index - 1).toFloat(&minuendIsFloat);
- if (minuendIsFloat) {
- float minuend = expressionToCalculate.at(index - 1).toFloat();
- if (index >= 2) {
- if (expressionToCalculate.at(index - 2) == "-") {
- minuend = minuend * -1;
- }
- }
-
- float subtrahend;
- if (expressionToCalculate.at(index + 1) == "-") {
- subtrahend = expressionToCalculate.at(index + 2).toFloat() * -1;
- } else {
- subtrahend = expressionToCalculate.at(index + 1).toFloat();
- }
-
- float result = minuend - subtrahend;
- if (subtrahend < 0) {
- expressionToCalculate.removeAt(index + 2);
- }
- expressionToCalculate.removeAt(index + 1);
- expressionToCalculate.removeAt(index);
- expressionToCalculate.removeAt(index - 1);
- if (minuend < 0) {
- expressionToCalculate.removeAt(index - 2);
- expressionToCalculate.insert(index - 2, QString::number(result));
- } else {
- expressionToCalculate.insert(index - 1, QString::number(result));
- }
- } else {
- ignoreNegativeCount++;
- ignoreNegativeIndex = index + 1;
- }
- }
- }
- }*/
-
- if (hasErrorOccurred) {
- /*if (errorMessage == "0div0") {
- emit showMathematicsFrame(displayExpression, "indeterminate");
- if (name == "") {
- emit outputResponse("You've broken mathematics!");
- speak("You've broken mathematics!");
- } else {
- emit outputResponse("You've broken mathematics, " + name + "!");
- speak("You've broken mathematics, " + name + "!");
- }
- } else if (errorMessage == "div0") {
- emit showMathematicsFrame(displayExpression, "undefined");
- emit outputResponse("I can't divide by 0.");
- speak("I can't divide by 0.");
- } else if (errorMessage == "0^0") {
- emit showMathematicsFrame(displayExpression, "undefined");
- emit outputResponse("I can't raise 0 to the power of 0.");
- speak("I can't raise 0 to the power of 0.");
- } else if (errorMessage == "0^neg") {
- emit showMathematicsFrame(displayExpression, "undefined");
- emit outputResponse("I can't raise 0 to the power of a negative number. That would be dividing by zero, which is bad.");
- speak("I can't raise 0 to the power of a negative number. That would be dividing by zero, which is bad.");
- } else if (errorMessage == "factorialNeg") {
- emit showMathematicsFrame(displayExpression, "undefined");
- emit outputResponse("I can't calculate the factorial of a negative number.");
- speak("I can't calculate the factorial of a negative number.");
- } else if (errorMessage == "factorialNonInt") {
- emit showMathematicsFrame(displayExpression, "undefined");
- emit outputResponse("I can't calculate the factorial of a number that isn't an integer.");
- speak("I can't calculate the factorial of a number that isn't an integer.");
- }*/
-
- emit showMathematicsFrame(displayExpression, answer);
- emit outputResponse(answer);
- speak("A mathematical error has occurred.");
- } else {
- QString speakText = answer;
- speakText.replace("e+", " times 10 to the power of ");
- speakText.replace("e-", " times 10 to the power of negative ");
- if (speakText.left(1) == "-") {
- speakText.replace(0, 1, "negative ");
- }
- emit showMathematicsFrame(displayExpression, answer);
- emit outputResponse("");
- speak(speakText);
- }
-
- resetOnNextBegin = true;
- } else {
- emit showMathematicsFrame("", "Install theCalculator first.");
- emit outputResponse("You'll need to install theCalculator to perform calculations using theWave.");
- speak("You'll need to install theCalculator to perform calculations using theWave.");
- }
- /*} else if (parse.contains("weather")) {
- //Get the location the user wants
- QString location = ""; //If Location is blank, get current location.
-
- if (location == "") { //Use current location
- geolocationSource->requestUpdate();
- if (currentCoordinates.isValid()) {
-
- } else {
- emit outputResponse("I'm not sure where you are, so I can't get weather information. Try saying a city name. Sorry about that.");
- speak("I'm not sure where you are, so I can't get weather information. Try saying a city name. Sorry about that.");
- }
- }*/
- } else if (words.contains("time")) {
- if (words.contains("in") || words.contains("at")) {
- QString output = "I can't get times for other places yet.";
- emit outputResponse(output);
- speak(output);
- } else { //Local time
- QTime currentTime = QTime::currentTime();
- QString output = "Right now, it's " + currentTime.toString("hh:mm:ss") + " in " + QLocale::countryToString(QTimeZone::systemTimeZone().country()) + ".";
-
- emit outputResponse(output);
- speak(output);
- }
- } else if (words.at(0) == "spell") {
- QString output = parse;
- output = output.remove("spell ") + ": ";
- QString spelling = parse;
- spelling = spelling.remove("spell ").split("").join(" ");
- output.append(spelling);
- emit outputResponse("");
- speak(output);
- } else if (parse.contains("happy birthday")) { //Fun
- QString output = "It's not my birthday. But I'm assuming it's yours.";
- if (name != "") {
- output = "It's not my birthday. But I'm assuming it's yours. Happy Birthday " + name + "!";
- }
- emit outputResponse(output);
- speak(output);
- } else if (words.contains("hello") || words.contains("hi") | words.contains("hey")) { //Hello
- if (name == "") {
- emit outputResponse("Hey there! Just tell me what you'd like me to do.");
- speak("Hey there! Just tell me what you'd like me to do.");
- } else {
- emit outputResponse("Hello " + name + "! Just tell me what you'd like me to do.");
- speak("Hello " + name + "! Just tell me what you'd like me to do.");
- }
- emit showHelpFrame();
- resetOnNextBegin = true;
- } else if (parse == "roll a die") { //Roll a die
- QString output;
- switch (qrand() % 6) {
- case 0:
- output = "One.";
- break;
- case 1:
- output = "Two.";
- break;
- case 2:
- output = "Three.";
- break;
- case 3:
- output = "Four.";
- break;
- case 4:
- output = "Five.";
- break;
- case 5:
- output = "Six.";
- break;
- }
-
- emit outputResponse(output);
- speak(output);
- } else if (parse == "flip a coin") { //Flip a coin
- QString output;
- switch (qrand() % 2) {
- case 0:
- output = "Heads.";
- break;
- case 1:
- output = "Tails.";
- break;
- }
-
- emit outputResponse(output);
- speak(output);
- } else if (parse == "who am i") { //Name Testing
- if (name == "") {
- emit outputResponse("I'm not quite sure. Tell me in my settings.");
- speak("I'm not quite sure. Tell me in my settings.");
- } else {
- emit outputResponse("You're " + name + ", aren't you?");
- speak("You're " + name + ", aren't you?");
- }
- } else if (parse == "who are you") { //Who are you
- emit outputResponse("Me? I'm theWave. Pleased to meet you.");
- speak("Me? I'm theWave. Pleased to meet you.");
- } else if (parse == "fuck you" || parse == "i hate you" || parse == "you're useless" || parse == "you're shit") { //Fun
- int numberOfChoices;
- if (parse == "fuck you" || parse == "you're shit") {
- numberOfChoices = 4;
- } else {
- numberOfChoices = 3;
- }
-
- switch (qrand() % numberOfChoices) {
- case 0:
- emit outputResponse("Did I do something wrong?");
- speak("Did I do something wrong?");
- break;
- case 1:
- emit outputResponse("Oops?");
- speak("Oops?");
- break;
- case 2:
- emit outputResponse("Ouch. That hurts.");
- speak("Ouch. That hurts.");
- break;
- case 3:
- if (name == "") {
- emit outputResponse("No need to swear at me.");
- speak("No need to swear at me.");
- } else {
- emit outputResponse("No need to swear at me, " + name + ".");
- speak("No need to swear at me, " + name + ".");
- }
- break;
- }
- } else if (parse.contains("what's the best") || parse.contains("what is the best")) { //Fun
- if (parse.contains("operating system")) {
- emit outputResponse("theOS. What else?");
- speak("the O S. What else?");
- } else if (words.contains("phone")) {
- emit outputResponse("I'm kind of drawn to the Plasma Mobiles.");
- speak("I'm kind of drawn to the Plasma Mobiles.");
- } else if (words.contains("tablet")) {
- emit outputResponse("Any tablet computer really. As long as theOS is installed on it.");
- speak("Any tablet computer really. As long as the O S is installed on it.");
- }
- } else if (parse == "tell me a joke") {
- QString output;
- switch (qrand() % 6) {
- case 0:
- output = "I'm always nervous when it comes to jokes. It's kind of... nerve racking.";
- break;
- case 1:
- output = "Two men walked into a bar. They walked out again.\n\nActually, that was a pretty bad joke.";
- break;
- case 2:
- output = "If you're trying to laugh, just smile. It'll make you feel better.";
- break;
- case 3:
- output = "A man walks into a pizzeria. The seller asks \"Do you want your pizza in six or eight slices?\" The man replies \"I'm not hungry, so I'll go for six pieces.\"";
- break;
- case 4:
- output = "What day does the egg fear the most? Boilday.\n\nIs that even a day?";
- break;
- case 5:
- output = "I like cheese. Do you?";
- break;
- }
-
- emit outputResponse(output);
- speak(output);
- } else { //Look Online
- bool doLookupSpeech = false;
- if (settings.value("thewave/wikipediaSearch", true).toBool()) {
- doLookupSpeech = true;
- }
- bool isInfoFound = false;
-
- if (doLookupSpeech) {
- emit outputResponse("Looking online for information...");
- speak("Looking online for information...");
-
-
- if (settings.value("thewave/wikipediaSearch", true).toBool()) {
- QEventLoop eventLoop;
-
- QNetworkRequest request;
- QString term = speech;
- term.replace(" ", "+");
- QUrl requestUrl("https://en.wikipedia.org/w/api.php?action=query&titles=" + term + "&format=xml&prop=extracts&redirects=true&exintro=true");
- request.setUrl(requestUrl);
- request.setHeader(QNetworkRequest::UserAgentHeader, "theWave/2.1 (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 = "" + reply.split("").at(1).split("").at(0) + "";
- text.replace("<", "<");
- text.replace(">", ">");
- text.replace(""", "\"");
- text.replace("&", "&");
-
- if (stopEverything) {
- return;
- }
-
- emit showWikipediaFrame(title, text);
- emit outputResponse("I found some information. Take a look.");
- speak("I found some information. Take a look.");
- resetOnNextBegin = true;
- }
-
- }
- }
-
- if (stopEverything) {
- return;
- }
-
- if (!isInfoFound) {
- QString output;
- switch (qrand() % 4) {
- case 0:
- output = "Unfortunately, I don't understand what that means.";
- break;
- case 1:
- output = "Not sure what you want me to do.";
- break;
- case 2:
- output = "I don't know how to interpret that. Sorry about that.";
- break;
- case 3:
- output = "I probably misheard you. Could you try again?";
- break;
- }
-
- emit outputResponse(output);
- speak(output);
- errorListeningSound->play();
- }
- }
- break;
- case TimerGetTime:
- TimerGetTime:
- if (words.contains("hour") || words.contains("minute") || words.contains("second") ||
- words.contains("hours") || words.contains("minutes") || words.contains("seconds")) {
- int currentNumber = 0, hour = 0, minute = 0, second = 0;
- for (QString part : words) {
- if (numberDictionary.contains(part)) {
- currentNumber = currentNumber + numberDictionary.value(part);
- } else if (part.contains("hour")) {
- hour = hour + currentNumber;
- currentNumber = 0;
- } else if (part.contains("minute")) {
- minute = minute + currentNumber;
- currentNumber = 0;
- } else if (part.contains("second")) {
- second = second + currentNumber;
- currentNumber = 0;
- }
- }
- if (hour >= 60 || minute >= 60 || second >= 60) {
- emit outputResponse("I'm sorry, how long is the timer?");
- emit outputHint("Try saying \"ten seconds\" or \"three hours ten minutes twenty seconds.\"");
- speak("I'm sorry, how long is the timer?", voiceFeedback);
- state = TimerGetTime;
- } else {
- QString compiledSpeech = "I've set the timer for ";
- bool includeAnd = false;
- if (hour != 0) {
- compiledSpeech.append(QString::number(hour) + " hours, ");
- includeAnd = true;
- }
- if (minute != 0) {
- compiledSpeech.append(QString::number(minute) + " minutes, ");
- includeAnd = true;
- }
- if (second != 0) {
- compiledSpeech.append(QString::number(second) + " seconds.");
- }
-
- QTime t(hour, minute, second);
- emit setTimer(t);
- emit outputResponse(compiledSpeech + " You can check your timer next to the clock.");
- speak(compiledSpeech);
- state = Idle;
- }
- } else if (words.contains("cancel") || words.contains("stop")) {
- state = Idle;
- emit outputResponse("OK, I cancelled the timer.");
- speak("OK, I cancelled the timer.");
- } else {
- emit outputResponse("I'm sorry, how long is the timer?");
- emit outputHint("Try saying \"ten seconds\" or \"three hours ten minutes twenty seconds.\"");
- speak("I'm sorry, how long is the timer?", voiceFeedback);
- state = TimerGetTime;
- }
- break;
- case emailGetRecipient:
- {
-
- }
- break;
- }
- }
- isRunning = false;
- } else {
- this->disabled = true;
- }
-}
-
-bool theWaveWorker::launchAkonadi() {
- if (!Akonadi::ServerManager::isRunning()) {
- emit outputResponse("Starting Akonadi. Please wait.");
- speak("Starting Akonadi. Please wait.");
- if (!Akonadi::ServerManager::start()) {
- emit outputResponse("Unfortunately, the Akonadi Personal Information Management service didn't start properly. Sorry about that.");
- speak("Unfortunately, the Akonadi Personal Information Management service didn't start properly Sorry about that.");
- return false;
- }
- }
- return true;
-}
-
-void theWaveWorker::speak(QString speech, bool restartOnceComplete) {
- while (speechPlaying) {
- QApplication::processEvents();
- }
-
- if (stopEverything) {
- return;
- }
-
- speech = speech.replace("\"", "\\\"");
- if (settings.value("thewave/blockOffensiveWords").toBool()) {
- speech = speech.replace("shit", "s-", Qt::CaseInsensitive);
- speech = speech.replace("fuck", "f-", Qt::CaseInsensitive);
- speech = speech.replace("cunt", "c-", Qt::CaseInsensitive);
- speech = speech.replace("bitch", "b-", Qt::CaseInsensitive);
- }
-
- speechPlaying = true;
- if (settings.value("thewave/ttsEngine").toString() == "pico2wave" && QFile("/usr/bin/pico2wave").exists()) {
- QString command = "pico2wave -w=\"" + QDir::homePath() + "/.thewavevoice.wav\" \"" + speech + "\"";
- QProcess::execute(command);
-
- QSoundEffect* sound = new QSoundEffect();
- sound->setSource(QUrl::fromLocalFile(QDir::homePath() + "/.thewavevoice.wav"));
- sound->play();
- connect(sound, &QSoundEffect::playingChanged, [=]() {
- if (!sound->isPlaying()) {
- sound->deleteLater();
-
- //Restore all sounds on system
- AudioMan->restoreStreams();
- }
- });
- connect(sound, &QSoundEffect::destroyed, [=]() {
- if (restartOnceComplete && !stopEverything) {
- begin();
- }
- speechPlaying = false;
- });
- } else if (settings.value("thewave/ttsEngine").toString() == "espeak" && QFile("/usr/bin/espeak").exists()) {
-
- QProcess *s = new QProcess(this);
- s->start("espeak \"" + speech + "\"");
-
- if (restartOnceComplete && !stopEverything) {
- connect(s, SIGNAL(finished(int)), this, SLOT(begin()));
- }
- connect(s, static_cast(&QProcess::finished), [=]() {
- speechPlaying = false;
-
- //Restore all sounds on system
- AudioMan->restoreStreams();
- });
- } else if (settings.value("thewave/ttsEngine").toString() == "festival" && QFile("/usr/bin/festival").exists()) {
- QProcess *s = new QProcess(this);
- s->start("festival --tts");
- s->write(speech.toUtf8());
- s->closeWriteChannel();
-
- if (restartOnceComplete && !stopEverything) {
- connect(s, SIGNAL(finished(int)), this, SLOT(begin()));
- }
-
- connect(s, static_cast(&QProcess::finished), [=]() {
- //Restore all sounds on system
- AudioMan->restoreStreams();
- });
-
- speechPlaying = false;
- } else {
- //Restore all sounds on system
- AudioMan->restoreStreams();
-
- QTimer* waitTimer = new QTimer(this);
- waitTimer->setInterval(5000);
- waitTimer->setSingleShot(true);
- connect(waitTimer, SIGNAL(timeout()), waitTimer, SLOT(deleteLater()));
- if (restartOnceComplete && !stopEverything) {
- connect(waitTimer, SIGNAL(timeout()), this, SLOT(begin()));
- }
- waitTimer->start();
- speechPlaying = false;
- }
-}
-
-void theWaveWorker::quit() {
- speechProc->kill();
- stopEverything = true;
- stopListeningSound->play();
- connect(stopListeningSound, &QSoundEffect::playingChanged, [=]() {
- if (!stopListeningSound->isPlaying()) {
- delete startListeningSound;
- delete okListeningSound;
- delete errorListeningSound;
- delete stopListeningSound;
- }
- });
-}
-
-void theWaveWorker::launchAppReply(QString app) {
- emit outputResponse("Launching " + app + ".");
- speak("Launching " + app + ".");
-
- while (speechPlaying) {
- QApplication::processEvents();
- if (stopEverything) {
- return;
- }
- }
-
- emit doLaunchApp(app);
-}
-
-void theWaveWorker::launchApp_disambiguation(QStringList apps) {
- Q_UNUSED(apps)
- emit outputResponse("There's more than one app. Select the one you'd like to open on your screen.");
- speak("There's more than one app. Select the one you'd to open on your screen.");
-}
-
-void theWaveWorker::currentSettingChanged(bool isOn) {
- this->SetSetting(currentSetting, isOn);
-}
-
-void theWaveWorker::SetSetting(QString setting, bool isOn) {
- if (setting == "wifi") {
- MainWin->getInfoPane()->on_WifiSwitch_toggled(isOn);
- }
-}
-
-bool theWaveWorker::isDisabled() { //Is theWave disabled?
- return this->disabled;
-}
diff --git a/thewaveworker.h b/thewaveworker.h
deleted file mode 100644
index cde474d..0000000
--- a/thewaveworker.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************
- *
- * theShell - Desktop Environment
- * Copyright (C) 2017 Victor Tran
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * *************************************/
-
-#ifndef THEWAVEWORKER_H
-#define THEWAVEWORKER_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "menu.h"
-
-class Menu;
-
-class theWaveWorker : public QObject
-{
- Q_OBJECT
-
- enum SpeechState {
- Idle,
- TimerGetTime,
- emailGetRecipient,
- emailGetSubject,
- emailGetBody,
- emailConfirm
- };
-
- QMap numberDictionary;
-
-public:
- explicit theWaveWorker(QObject *parent = 0);
- ~theWaveWorker();
-
- bool isDisabled();
-
-signals:
- void outputSpeech(QString);
- void outputResponse(QString);
- void outputHint(QString);
- void loudnessChanged(qreal loudness);
- void outputFrame(QFrame *);
- void complete();
- void startedListening();
- void stoppedListening();
- void showBigListenFrame();
- void hideBigListenFrame();
- void finished();
-
- void resetFrames();
- void showCallFrame(bool emergency);
- void showMessageFrame();
- 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);
- void showMathematicsFrame(QString expression, QString answer);
- void showMediaFrame(QPixmap art, QString title, QString artist, bool isPlaying);
-
- void setTimer(QTime);
-
-public slots:
- void begin();
-
- void endAndProcess();
-
- void processSpeech(QString speech, bool voiceFeedback = true);
-
- void quit();
-
- void soundBuffer(QAudioBuffer buffer);
-
- bool launchAkonadi();
-
- void launchAppReply(QString app);
-
- void launchApp_disambiguation(QStringList apps);
-
- void currentSettingChanged(bool isOn);
-
-private slots:
- void outputAvailable();
-
- void SetSetting(QString setting, bool isOn);
-
-private:
- QProcess *speechProc;
- QString buffer;
- QTime endListenTimer;
- qreal oldLoudness = 0;
- qreal maxLoudnessForSession = 0;
- bool isListeningAfterLoudnessChange = false;
-
- void speak(QString speech, bool restartOnceComplete = false);
- SpeechState state = Idle;
-
- QSoundEffect* startListeningSound, *okListeningSound, *errorListeningSound, *stopListeningSound;
- QAudioRecorder* testRecorder = NULL;
- QAudioRecorder* recorder = NULL;
- QAudioProbe* probe = NULL;
-
- QGeoPositionInfoSource* geolocationSource;
- QGeoCoordinate currentCoordinates;
-
- bool stopEverything = false;
- bool resetOnNextBegin = false;
- bool speechPlaying = false;
- bool disabled = false;
- bool isRunning = false;
- bool noVoiceInput = true;
-
- QString currentSetting;
-
- QSettings settings;
-};
-
-#endif // THEWAVEWORKER_H