summaryrefslogtreecommitdiff
blob: d7fa7474a4bf49ca2617c2f1d0dfcaf0f2177bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
From 53f187315f51e7d53a03c4ed464812b388465c10 Mon Sep 17 00:00:00 2001
From: Laurent Montel <montel@kde.org>
Date: Mon, 27 Dec 2021 07:53:16 +0100
Subject: [PATCH] Add support for building without texttospeech as for the
 moment we don't

have it in qt6
---
 CMakeLists.txt                                | 10 +++++-
 src/CMakeLists.txt                            | 34 ++++++++++++++-----
 .../plaintexteditor/plaintexteditor.cpp       |  4 +++
 .../plaintexteditor/plaintexteditorwidget.cpp | 10 ++++--
 .../richtexteditor/richtexteditor.cpp         |  5 ++-
 .../richtexteditor/richtexteditorwidget.cpp   |  9 ++++-
 6 files changed, 59 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae59804..d1a0181 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,7 +76,15 @@ add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02)
 add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055A00)
 
 
-find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS TextToSpeech)
+find_package(Qt5TextToSpeech ${QT_REQUIRED_VERSION} CONFIG)
+set_package_properties(Qt5TextToSpeech PROPERTIES DESCRIPTION
+    "Add support for texttospeed"
+    TYPE OPTIONAL
+)
+if(TARGET Qt5::TextToSpeech)
+    set(HAVE_TEXT_TO_SPEECH_SUPPORT TRUE)
+    add_definitions(-DHAVE_TEXT_TO_SPEECH_SUPPORT)
+endif()
 
 if(BUILD_TESTING)
    find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Test)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2720e0a..98e2854 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -53,7 +53,7 @@ target_sources(KF5PimTextEdit PRIVATE
     composer-ng/richtextcomposeremailquotehighlighter.h
     composer-ng/richtextcomposerwidget.h
     )
-
+if (HAVE_TEXT_TO_SPEECH_SUPPORT)
 target_sources(KF5PimTextEdit PRIVATE
     texttospeech/texttospeech.cpp
     texttospeech/texttospeechwidget.cpp
@@ -76,6 +76,7 @@ target_sources(KF5PimTextEdit PRIVATE
     texttospeech/texttospeechlanguagecombobox.h
     texttospeech/texttospeechactions.h
     )
+endif()
 
 target_sources(KF5PimTextEdit PRIVATE
     grantleebuilder/plaintextmarkupbuilder.cpp
@@ -168,7 +169,12 @@ target_link_libraries(KF5PimTextEdit
     KF5::SyntaxHighlighting
     Qt::TextToSpeech
     )
-
+if (HAVE_TEXT_TO_SPEECH_SUPPORT)
+    target_link_libraries(KF5PimTextEdit
+        PRIVATE
+        Qt::TextToSpeech
+        )
+endif()
 set_target_properties(KF5PimTextEdit PROPERTIES
     VERSION ${KPIMTEXTEDIT_VERSION}
     SOVERSION ${KPIMTEXTEDIT_SOVERSION}
@@ -240,7 +246,7 @@ ecm_generate_headers(KPimTextEdit_CamelCasetexteditor_commonwidget_HEADERS
     )
 
 
-
+if (HAVE_TEXT_TO_SPEECH_SUPPORT)
 ecm_generate_headers(KPimTextEdit_CamelCasetexttospeechs_HEADERS
     HEADER_NAMES
     TextToSpeech
@@ -252,7 +258,7 @@ ecm_generate_headers(KPimTextEdit_CamelCasetexttospeechs_HEADERS
     PREFIX KPIMTextEdit
     RELATIVE texttospeech
     )
-
+endif()
 ecm_generate_headers(KPimTextEdit_Camelcasecomposerng_HEADERS
     HEADER_NAMES
     RichTextComposer
@@ -269,11 +275,22 @@ ecm_generate_headers(KPimTextEdit_Camelcasecomposerng_HEADERS
 
 
 ########### install files ###############
+if (HAVE_TEXT_TO_SPEECH_SUPPORT)
+    install(FILES
+        ${KPimTextEdit_texttospeechs_HEADERS}
+        DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KPIMTextEdit/kpimtextedit
+        COMPONENT Devel
+        )
+    install(FILES
+        ${KPimTextEdit_CamelCasetexttospeechs_HEADERS}
+        DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KPIMTextEdit/KPIMTextEdit/
+        COMPONENT Devel
+        )
+endif()
 
 install(FILES
     ${CMAKE_CURRENT_BINARY_DIR}/kpimtextedit_export.h
     ${kpimtextedit_HEADERS}
-    ${KPimTextEdit_texttospeechs_HEADERS}
     ${KPimTextEdit_richtexteditor_HEADERS}
     ${KPimTextEdit_texteditor_commonwidget_HEADERS}
     ${KPimTextEdit_plaintexteditor_HEADERS}
@@ -288,7 +305,6 @@ install(FILES
     ${KPimTextEdit_CamelCase_HEADERS}
     ${KPimTextEdit_CamelCasetextrichtexteditor_HEADERS}
     ${KPimTextEdit_CamelCaseplaintexteditor_HEADERS}
-    ${KPimTextEdit_CamelCasetexttospeechs_HEADERS}
     ${KPimTextEdit_CamelCasetexteditor_commonwidget_HEADERS}
     ${KPimTextEdit_Camelcasecomposerng_HEADERS}
     ${KPimTextEdit_CamelCaseemoticon_HEADERS}
@@ -306,8 +322,10 @@ if (BUILD_TESTING)
     add_subdirectory(texteditor/commonwidget/autotests)
     add_subdirectory(texteditor/plaintexteditor/tests)
     add_subdirectory(texteditor/richtexteditor/tests)
-    add_subdirectory(texttospeech/autotests)
-    add_subdirectory(texttospeech/tests)
+    if (HAVE_TEXT_TO_SPEECH_SUPPORT)
+        add_subdirectory(texttospeech/autotests)
+        add_subdirectory(texttospeech/tests)
+    endif()
     add_subdirectory(composer-ng/autotests)
     add_subdirectory(composer-ng/tests)
     add_subdirectory(grantleebuilder/autotests)
diff --git a/src/texteditor/plaintexteditor/plaintexteditor.cpp b/src/texteditor/plaintexteditor/plaintexteditor.cpp
index cfa0741..4559568 100644
--- a/src/texteditor/plaintexteditor/plaintexteditor.cpp
+++ b/src/texteditor/plaintexteditor/plaintexteditor.cpp
@@ -18,7 +18,9 @@
 #include <QActionGroup>
 #include <QIcon>
 
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
 #include "texttospeech/texttospeech.h"
+#endif
 #include <Sonnet/Dialog>
 #include <sonnet/backgroundchecker.h>
 
@@ -181,6 +183,7 @@ void PlainTextEditor::contextMenuEvent(QContextMenuEvent *event)
             }
         }
         if (d->supportFeatures & TextToSpeech) {
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
             if (KPIMTextEdit::TextToSpeech::self()->isReady()) {
                 if (!emptyDocument) {
                     QAction *speakAction = popup->addAction(i18n("Speak Text"));
@@ -188,6 +191,7 @@ void PlainTextEditor::contextMenuEvent(QContextMenuEvent *event)
                     connect(speakAction, &QAction::triggered, this, &PlainTextEditor::slotSpeakText);
                 }
             }
+#endif
         }
         if (webShortcutSupport() && textCursor().hasSelection()) {
             popup->addSeparator();
diff --git a/src/texteditor/plaintexteditor/plaintexteditorwidget.cpp b/src/texteditor/plaintexteditor/plaintexteditorwidget.cpp
index 3251ea3..77a9b45 100644
--- a/src/texteditor/plaintexteditor/plaintexteditorwidget.cpp
+++ b/src/texteditor/plaintexteditor/plaintexteditorwidget.cpp
@@ -8,8 +8,9 @@
 #include "plaintexteditfindbar.h"
 #include "plaintexteditor.h"
 #include "slidecontainer.h"
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
 #include "texttospeech/texttospeechwidget.h"
-
+#endif
 #include <QTextCursor>
 #include <QVBoxLayout>
 
@@ -21,7 +22,9 @@ public:
 
     KPIMTextEdit::PlainTextEditFindBar *mFindBar = nullptr;
     PlainTextEditor *mEditor = nullptr;
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
     KPIMTextEdit::TextToSpeechWidget *mTextToSpeechWidget = nullptr;
+#endif
     KPIMTextEdit::SlideContainer *mSliderContainer = nullptr;
 };
 
@@ -75,16 +78,19 @@ void PlainTextEditorWidget::init(PlainTextEditor *customEditor)
 {
     auto lay = new QVBoxLayout(this);
     lay->setContentsMargins({});
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
     d->mTextToSpeechWidget = new KPIMTextEdit::TextToSpeechWidget(this);
     lay->addWidget(d->mTextToSpeechWidget);
+#endif
     if (customEditor) {
         d->mEditor = customEditor;
     } else {
         d->mEditor = new PlainTextEditor;
     }
     lay->addWidget(d->mEditor);
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
     connect(d->mEditor, &PlainTextEditor::say, d->mTextToSpeechWidget, &KPIMTextEdit::TextToSpeechWidget::say);
-
+#endif
     d->mSliderContainer = new KPIMTextEdit::SlideContainer(this);
 
     d->mFindBar = new KPIMTextEdit::PlainTextEditFindBar(d->mEditor, this);
diff --git a/src/texteditor/richtexteditor/richtexteditor.cpp b/src/texteditor/richtexteditor/richtexteditor.cpp
index dfdf7c5..a004434 100644
--- a/src/texteditor/richtexteditor/richtexteditor.cpp
+++ b/src/texteditor/richtexteditor/richtexteditor.cpp
@@ -26,7 +26,9 @@
 #include <sonnet/backgroundchecker.h>
 #include <sonnet/spellcheckdecorator.h>
 #include <sonnet/speller.h>
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
 #include <texttospeech/texttospeech.h>
+#endif
 
 #include <QApplication>
 #include <QClipboard>
@@ -247,7 +249,7 @@ QMenu *RichTextEditor::mousePopupMenu(QPoint pos)
             allowTabAction->setChecked(!tabChangesFocus());
             connect(allowTabAction, &QAction::triggered, this, &RichTextEditor::slotAllowTab);
         }
-
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
         if (KPIMTextEdit::TextToSpeech::self()->isReady()) {
             if (!emptyDocument) {
                 QAction *speakAction = popup->addAction(i18n("Speak Text"));
@@ -255,6 +257,7 @@ QMenu *RichTextEditor::mousePopupMenu(QPoint pos)
                 connect(speakAction, &QAction::triggered, this, &RichTextEditor::slotSpeakText);
             }
         }
+#endif
         if (webShortcutSupport() && textCursor().hasSelection()) {
             popup->addSeparator();
             const QString selectedText = textCursor().selectedText();
diff --git a/src/texteditor/richtexteditor/richtexteditorwidget.cpp b/src/texteditor/richtexteditor/richtexteditorwidget.cpp
index d0d8e14..d84cf3f 100644
--- a/src/texteditor/richtexteditor/richtexteditorwidget.cpp
+++ b/src/texteditor/richtexteditor/richtexteditorwidget.cpp
@@ -10,8 +10,9 @@
 
 #include <QTextCursor>
 #include <QVBoxLayout>
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
 #include <texttospeech/texttospeechwidget.h>
-
+#endif
 #include "slidecontainer.h"
 
 using namespace KPIMTextEdit;
@@ -23,7 +24,9 @@ public:
 
     KPIMTextEdit::RichTextEditFindBar *mFindBar = nullptr;
     RichTextEditor *mEditor = nullptr;
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
     KPIMTextEdit::TextToSpeechWidget *mTextToSpeechWidget = nullptr;
+#endif
     KPIMTextEdit::SlideContainer *mSliderContainer = nullptr;
 };
 
@@ -97,14 +100,18 @@ void RichTextEditorWidget::init(RichTextEditor *customEditor)
 {
     auto lay = new QVBoxLayout(this);
     lay->setContentsMargins({});
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
     d->mTextToSpeechWidget = new KPIMTextEdit::TextToSpeechWidget(this);
     lay->addWidget(d->mTextToSpeechWidget);
+#endif
     if (customEditor) {
         d->mEditor = customEditor;
     } else {
         d->mEditor = new RichTextEditor;
     }
+#ifdef HAVE_TEXT_TO_SPEECH_SUPPORT
     connect(d->mEditor, &RichTextEditor::say, d->mTextToSpeechWidget, &KPIMTextEdit::TextToSpeechWidget::say);
+#endif
     lay->addWidget(d->mEditor);
 
     d->mSliderContainer = new KPIMTextEdit::SlideContainer(this);
-- 
GitLab