From da4ba2b7dc18ba20994dad54e754ed1d9d9c7a48 Mon Sep 17 00:00:00 2001
From: Laurent Montel <montel@kde.org>
Date: Mon, 14 Feb 2022 19:16:56 +0100
Subject: [PATCH] Compile without text to speech support

---
 messageviewer/src/viewer/viewer_p.cpp | 10 ++++++----
 messageviewer/src/viewer/viewer_p.h   |  8 +++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index 5e7af8e01..15e71482f 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -1403,11 +1403,11 @@ void ViewerPrivate::createWidgets()
     mOpenSavedFileFolderWidget = new OpenSavedFileFolderWidget(readerBox);
     mOpenSavedFileFolderWidget->setObjectName(QStringLiteral("opensavefilefolderwidget"));
     readerBoxVBoxLayout->addWidget(mOpenSavedFileFolderWidget);
-
+#if KPIMTEXTEDIT_TEXT_TO_SPEECH
     mTextToSpeechWidget = new KPIMTextEdit::TextToSpeechWidget(readerBox);
     mTextToSpeechWidget->setObjectName(QStringLiteral("texttospeechwidget"));
     readerBoxVBoxLayout->addWidget(mTextToSpeechWidget);
-
+#endif
     mViewer = new MailWebEngineView(mActionCollection, readerBox);
     mViewer->setViewer(this);
     readerBoxVBoxLayout->addWidget(mViewer);
@@ -1609,12 +1609,12 @@ void ViewerPrivate::createActions()
     ac->setDefaultShortcut(loadExternalReferenceAction, QKeySequence(Qt::SHIFT | Qt::CTRL | Qt::Key_R));
     connect(loadExternalReferenceAction, &QAction::triggered, this, &ViewerPrivate::slotLoadExternalReference);
     MessageViewer::Util::addHelpTextAction(loadExternalReferenceAction, i18n("Load external references from the Internet for this message."));
-
+#if KPIMTEXTEDIT_TEXT_TO_SPEECH
     mSpeakTextAction = new QAction(i18n("Speak Text"), this);
     mSpeakTextAction->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-text-to-speech")));
     ac->addAction(QStringLiteral("speak_text"), mSpeakTextAction);
     connect(mSpeakTextAction, &QAction::triggered, this, &ViewerPrivate::slotSpeakText);
-
+#endif
     auto purposeMenuWidget = new MailfilterPurposeMenuWidget(mViewer, this);
     mShareTextAction = new QAction(i18n("Share Text..."), this);
     mShareTextAction->setMenu(purposeMenuWidget->menu());
@@ -2605,10 +2605,12 @@ void ViewerPrivate::replyMessage(KMime::Content *atmNode, bool replyToAll)
 
 void ViewerPrivate::slotSpeakText()
 {
+#if KPIMTEXTEDIT_TEXT_TO_SPEECH
     const QString text = mViewer->selectedText();
     if (!text.isEmpty()) {
         mTextToSpeechWidget->say(text);
     }
+#endif
 }
 
 QUrl ViewerPrivate::imageUrl() const
diff --git a/messageviewer/src/viewer/viewer_p.h b/messageviewer/src/viewer/viewer_p.h
index 88cb605e5..467163a2a 100644
--- a/messageviewer/src/viewer/viewer_p.h
+++ b/messageviewer/src/viewer/viewer_p.h
@@ -13,18 +13,18 @@
 #include "messageviewer_private_export.h"
 #include "viewer.h" //not so nice, it is actually for the enums from MailViewer
 #include "widgets/opensavedfilefolderwidget.h"
-#include <PimCommon/ShareServiceUrlManager>
-#include <WebEngineViewer/CheckPhishingUrlUtil>
-
 #include <Akonadi/Item>
 #include <Akonadi/Monitor>
 #include <Akonadi/Session>
 #include <KIO/Job>
 #include <KMime/Message>
 #include <KService>
+#include <PimCommon/ShareServiceUrlManager>
 #include <QPointer>
 #include <QUrl>
 #include <QVector>
+#include <WebEngineViewer/CheckPhishingUrlUtil>
+#include <kpimtextedit/kpimtextedit-texttospeech.h>
 
 #include <QObject>
 #include <QTimer>
@@ -695,7 +695,9 @@ public:
     MessageViewer::OpenSavedFileFolderWidget *mOpenSavedFileFolderWidget = nullptr;
     WebEngineViewer::SubmittedFormWarningWidget *mSubmittedFormWarning = nullptr;
     WebEngineViewer::TrackingWarningWidget *mMailTrackingWarning = nullptr;
+#if KPIMTEXTEDIT_TEXT_TO_SPEECH
     KPIMTextEdit::TextToSpeechWidget *mTextToSpeechWidget = nullptr;
+#endif
     Viewer::DisplayFormatMessage mDisplayFormatMessageOverwrite;
     KPIMTextEdit::SlideContainer *mSliderContainer = nullptr;
     PimCommon::ShareServiceUrlManager *mShareServiceManager = nullptr;
-- 
GitLab

