Issue #65: Text2Speech doesn't work on Linux

This commit is contained in:
Jakub Melka 2023-09-03 16:09:14 +02:00
parent b9786cc3fa
commit 278d385968
1 changed files with 15 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QMessageBox> #include <QMessageBox>
#include <QPainter> #include <QPainter>
#include <QTextToSpeech>
namespace pdfviewer namespace pdfviewer
{ {
@ -275,6 +276,20 @@ void PDFSidebarWidget::selectPage(Page page)
ui->stackedWidget->setCurrentWidget(pageInfo.second.page); ui->stackedWidget->setCurrentWidget(pageInfo.second.page);
} }
} }
if (page == Speech && ui->speechVoiceComboBox->count() == 0)
{
// Check, if speech engine is properly set
QStringList speechEngines = QTextToSpeech::availableEngines();
if (speechEngines.isEmpty())
{
QMessageBox::critical(this, tr("Error"), tr("Speech feature is unavailable. No speech engines detected. If you're using Linux, please install speech libraries like 'flite' or 'speechd'."));
}
else
{
QMessageBox::critical(this, tr("Error"), tr("The speech feature is available, but its options are not properly set. Please check the speech settings in the options dialog."));
}
}
} }
std::vector<PDFSidebarWidget::Page> PDFSidebarWidget::getValidPages() const std::vector<PDFSidebarWidget::Page> PDFSidebarWidget::getValidPages() const