Commit 60248d92 authored by Fabian Vogt's avatar Fabian Vogt Committed by Stefano Crocco
Browse files

Fix speech getting cancelled early in ttsplugin

The speech stops when QTextToSpeech gets destroyed. Create it on the heap
instead and couple its lifetime to the plugin.
parent 06fdda7c
Pipeline #115878 passed with stage
in 2 minutes and 43 seconds
......@@ -26,6 +26,8 @@ KHTMLPluginTTS::KHTMLPluginTTS(QObject *parent, const QVariantList &)
{
KParts::TextExtension *textExt = KParts::TextExtension::childObject(parent);
if (textExt && qobject_cast<KParts::ReadOnlyPart *>(parent)) {
m_tts = std::unique_ptr<QTextToSpeech>(new QTextToSpeech);
QAction *action = actionCollection()->addAction(QStringLiteral("tools_tts"));
action->setIcon(QIcon::fromTheme(QStringLiteral("text-speak")));
action->setText(i18n("&Speak Text"));
......@@ -48,8 +50,7 @@ void KHTMLPluginTTS::slotReadOut()
query = textExt->completeText(format);
}
QTextToSpeech tts;
tts.say(query);
m_tts->say(query);
}
K_PLUGIN_FACTORY(KHTMLPluginTTSFactory, registerPlugin<KHTMLPluginTTS>();)
......
......@@ -10,6 +10,8 @@
#include <konq_kpart_plugin.h>
class QTextToSpeech;
/**
* KHTML KParts Plugin
*/
......@@ -29,6 +31,8 @@ public:
~KHTMLPluginTTS() override;
public Q_SLOTS:
void slotReadOut();
private:
std::unique_ptr<QTextToSpeech> m_tts;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment