From 278d3859689ca139c96a86773c81ac1699774534 Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Sun, 3 Sep 2023 16:09:14 +0200 Subject: [PATCH] Issue #65: Text2Speech doesn't work on Linux --- Pdf4QtViewer/pdfsidebarwidget.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Pdf4QtViewer/pdfsidebarwidget.cpp b/Pdf4QtViewer/pdfsidebarwidget.cpp index aea1f30..c23617c 100644 --- a/Pdf4QtViewer/pdfsidebarwidget.cpp +++ b/Pdf4QtViewer/pdfsidebarwidget.cpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace pdfviewer { @@ -275,6 +276,20 @@ void PDFSidebarWidget::selectPage(Page 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::getValidPages() const