Add espeak, theWave menu commands

This commit is contained in:
Victor Tran 2016-06-03 21:30:47 +10:00
parent 8694ff1e8b
commit 905ec82d65
6 changed files with 136 additions and 39 deletions

View file

@ -64,6 +64,8 @@ InfoPaneDropdown::InfoPaneDropdown(NotificationDBus* notificationEngine, UPowerD
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);
}
@ -710,3 +712,9 @@ void InfoPaneDropdown::on_thewaveWikipediaSwitch_toggled(bool checked)
{
settings.setValue("thewave/wikipediaSearch", checked);
}
void InfoPaneDropdown::on_thewaveTTSespeak_clicked()
{
settings.setValue("thewave/ttsEngine", "espeak");
}

View file

@ -124,6 +124,8 @@ private slots:
void on_thewaveWikipediaSwitch_toggled(bool checked);
void on_thewaveTTSespeak_clicked();
public slots:
void getNetworks();

View file

@ -955,6 +955,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="thewaveTTSespeak">
<property name="text">
<string>espeak</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="thewaveTTSpico2wave">
<property name="text">
@ -1797,14 +1804,14 @@
<second>0</second>
<year>1969</year>
<month>12</month>
<day>12</day>
<day>11</day>
</datetime>
</property>
<property name="date">
<date>
<year>1969</year>
<month>12</month>
<day>12</day>
<day>11</day>
</date>
</property>
<property name="displayFormat">

View file

@ -20,6 +20,7 @@ Menu::Menu(QWidget *parent) :
ui->commandLinkButton_2->setStyleSheet("background-color: #A00;");
ui->timerIcon->setPixmap(QIcon::fromTheme("player-time").pixmap(16));
ui->userIcon->setPixmap(QIcon::fromTheme("system-users").pixmap(16));
ui->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));
@ -60,6 +61,13 @@ Menu::Menu(QWidget *parent) :
} else {
ui->InstallLayout->setVisible(false);
}
QNetworkAccessManager networkManager;
if (networkManager.networkAccessible() == QNetworkAccessManager::Accessible) {
ui->thewaveInternetFrame->setVisible(false);
} else {
ui->thewaveInternetFrame->setVisible(true);
}
}
Menu::~Menu()
@ -330,6 +338,23 @@ void Menu::on_lineEdit_textEdited(const QString &arg1)
ui->listWidget->addItem(i);
}
} else {
bool showtheWaveOption = true;
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("Place a call");
call->setData(Qt::UserRole, "thewave:call");
} else {
parse.remove(0, 5);
call->setText("Place a call to " + (QString) parse.at(0).toUpper() + parse.right(parse.length() - 1) + "");
call->setData(Qt::UserRole, "thewave:call " + parse);
}
call->setIcon(QIcon::fromTheme("call-start"));
ui->listWidget->addItem(call);
showtheWaveOption = false;
}
for (App *app : *apps) {
if (app->name().contains(arg1, Qt::CaseInsensitive) || app->description().contains(arg1, Qt::CaseInsensitive)) {
QListWidgetItem *i = new QListWidgetItem();
@ -377,7 +402,6 @@ void Menu::on_lineEdit_textEdited(const QString &arg1)
break;
}
}
}
QUrl uri = QUrl::fromUserInput(arg1);
if (uri.scheme() == "http" || uri.scheme() == "https") {
@ -423,11 +447,16 @@ void Menu::on_lineEdit_textEdited(const QString &arg1)
}
}
if (showtheWaveOption) {
QListWidgetItem *wave = new QListWidgetItem();
wave->setText("Ask theWave about \"" + arg1 + "\"");
wave->setIcon(QIcon(":/icons/thewave.svg"));
wave->setData(Qt::UserRole, "thewave:" + arg1);
ui->listWidget->addItem(wave);
}
}
}
bool Menu::eventFilter(QObject *object, QEvent *event) {

44
menu.ui
View file

@ -1070,6 +1070,50 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="thewaveInternetFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="thewave_connection_disconnection_label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You're disconnected from the internet. Results are limited.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>

View file

@ -319,6 +319,13 @@ void theWaveWorker::speak(QString speech, bool restartOnceComplete) {
//while (!sound.isFinished()) {
//QApplication::processEvents();
//}
} 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()));
}
} else {
QProcess *s = new QProcess(this);
s->start("festival --tts");