mirror of
https://github.com/vicr123/theshell.git
synced 2025-01-23 20:22:27 -05:00
Add espeak, theWave menu commands
This commit is contained in:
parent
8694ff1e8b
commit
905ec82d65
6 changed files with 136 additions and 39 deletions
|
@ -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");
|
||||
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ private slots:
|
|||
|
||||
void on_thewaveWikipediaSwitch_toggled(bool checked);
|
||||
|
||||
void on_thewaveTTSespeak_clicked();
|
||||
|
||||
public slots:
|
||||
void getNetworks();
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
|
103
menu.cpp
103
menu.cpp
|
@ -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,27 +402,13 @@ void Menu::on_lineEdit_textEdited(const QString &arg1)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QUrl uri = QUrl::fromUserInput(arg1);
|
||||
if (uri.scheme() == "http" || uri.scheme() == "https") {
|
||||
App* app = new App();
|
||||
app->setName("Go to " + uri.toDisplayString());
|
||||
app->setCommand("xdg-open \"" + uri.toString() + "\"");
|
||||
app->setIcon(QIcon::fromTheme("text-html"));
|
||||
appsShown->append(app);
|
||||
|
||||
QListWidgetItem *i = new QListWidgetItem();
|
||||
i->setText(app->name());
|
||||
i->setIcon(app->icon());
|
||||
i->setData(Qt::UserRole, app->command());
|
||||
ui->listWidget->addItem(i);
|
||||
} else if (uri.scheme() == "file") {
|
||||
if (QDir(uri.path() + "/").exists()) {
|
||||
QUrl uri = QUrl::fromUserInput(arg1);
|
||||
if (uri.scheme() == "http" || uri.scheme() == "https") {
|
||||
App* app = new App();
|
||||
app->setName("Open " + uri.path());
|
||||
app->setName("Go to " + uri.toDisplayString());
|
||||
app->setCommand("xdg-open \"" + uri.toString() + "\"");
|
||||
app->setIcon(QIcon::fromTheme("system-file-manager"));
|
||||
app->setIcon(QIcon::fromTheme("text-html"));
|
||||
appsShown->append(app);
|
||||
|
||||
QListWidgetItem *i = new QListWidgetItem();
|
||||
|
@ -405,29 +416,47 @@ void Menu::on_lineEdit_textEdited(const QString &arg1)
|
|||
i->setIcon(app->icon());
|
||||
i->setData(Qt::UserRole, app->command());
|
||||
ui->listWidget->addItem(i);
|
||||
} else if (QFile(uri.path()).exists()) {
|
||||
App* app = new App();
|
||||
app->setName("Open " + uri.path());
|
||||
app->setCommand("xdg-open \"" + uri.toString() + "\"");
|
||||
QFile f(uri.toString());
|
||||
QFileInfo info(f);
|
||||
QMimeType mime = (new QMimeDatabase())->mimeTypeForFile(info);
|
||||
app->setIcon(QIcon::fromTheme(mime.iconName(), QIcon::fromTheme("application-octet-stream")));
|
||||
appsShown->append(app);
|
||||
} else if (uri.scheme() == "file") {
|
||||
if (QDir(uri.path() + "/").exists()) {
|
||||
App* app = new App();
|
||||
app->setName("Open " + uri.path());
|
||||
app->setCommand("xdg-open \"" + uri.toString() + "\"");
|
||||
app->setIcon(QIcon::fromTheme("system-file-manager"));
|
||||
appsShown->append(app);
|
||||
|
||||
QListWidgetItem *i = new QListWidgetItem();
|
||||
i->setText(app->name());
|
||||
i->setIcon(app->icon());
|
||||
i->setData(Qt::UserRole, app->command());
|
||||
ui->listWidget->addItem(i);
|
||||
QListWidgetItem *i = new QListWidgetItem();
|
||||
i->setText(app->name());
|
||||
i->setIcon(app->icon());
|
||||
i->setData(Qt::UserRole, app->command());
|
||||
ui->listWidget->addItem(i);
|
||||
} else if (QFile(uri.path()).exists()) {
|
||||
App* app = new App();
|
||||
app->setName("Open " + uri.path());
|
||||
app->setCommand("xdg-open \"" + uri.toString() + "\"");
|
||||
QFile f(uri.toString());
|
||||
QFileInfo info(f);
|
||||
QMimeType mime = (new QMimeDatabase())->mimeTypeForFile(info);
|
||||
app->setIcon(QIcon::fromTheme(mime.iconName(), QIcon::fromTheme("application-octet-stream")));
|
||||
appsShown->append(app);
|
||||
|
||||
QListWidgetItem *i = new QListWidgetItem();
|
||||
i->setText(app->name());
|
||||
i->setIcon(app->icon());
|
||||
i->setData(Qt::UserRole, app->command());
|
||||
ui->listWidget->addItem(i);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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
44
menu.ui
|
@ -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>
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Add table
Reference in a new issue