KTextAddons

texttospeechcontainerwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "texttospeechcontainerwidget.h"
8#include "texttospeechwidget.h"
9#include <QHBoxLayout>
10using namespace TextEditTextToSpeech;
11
12class Q_DECL_HIDDEN TextEditTextToSpeech::TextToSpeechContainerWidgetPrivate
13{
14public:
15 TextToSpeechContainerWidgetPrivate(TextToSpeechContainerWidget *q)
16 : mainLayout(new QHBoxLayout(q))
17 {
18 mainLayout->setObjectName(QStringLiteral("mainLayout"));
19 mainLayout->setContentsMargins({});
20 }
21 TextToSpeechWidget *textToSpeechWidget = nullptr;
22 QHBoxLayout *const mainLayout;
23};
24
25TextToSpeechContainerWidget::TextToSpeechContainerWidget(QWidget *parent)
26 : QWidget{parent}
27 , d(new TextEditTextToSpeech::TextToSpeechContainerWidgetPrivate(this))
28{
30 hide();
31}
32
33TextToSpeechContainerWidget::~TextToSpeechContainerWidget() = default;
34
35void TextToSpeechContainerWidget::say(const QString &text)
36{
37 if (!d->textToSpeechWidget) {
38 d->textToSpeechWidget = new TextToSpeechWidget(this);
39 connect(d->textToSpeechWidget, &TextToSpeechWidget::changeVisibility, this, &TextToSpeechContainerWidget::setVisible);
40 d->mainLayout->addWidget(d->textToSpeechWidget);
41 }
42 d->textToSpeechWidget->say(text);
43}
44
45#include "moc_texttospeechcontainerwidget.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
virtual void setVisible(bool visible)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.