Warning, file /libraries/ktextaddons/textedittexttospeech/texttospeechcontainerwidget.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002    SPDX-FileCopyrightText: 2023 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "texttospeechcontainerwidget.h"
0008 #include "texttospeechwidget.h"
0009 #include <QHBoxLayout>
0010 using namespace TextEditTextToSpeech;
0011 
0012 class Q_DECL_HIDDEN TextEditTextToSpeech::TextToSpeechContainerWidgetPrivate
0013 {
0014 public:
0015     TextToSpeechContainerWidgetPrivate(TextToSpeechContainerWidget *q)
0016         : mainLayout(new QHBoxLayout(q))
0017     {
0018         mainLayout->setObjectName(QStringLiteral("mainLayout"));
0019         mainLayout->setContentsMargins({});
0020     }
0021     TextToSpeechWidget *textToSpeechWidget = nullptr;
0022     QHBoxLayout *const mainLayout;
0023 };
0024 
0025 TextToSpeechContainerWidget::TextToSpeechContainerWidget(QWidget *parent)
0026     : QWidget{parent}
0027     , d(new TextEditTextToSpeech::TextToSpeechContainerWidgetPrivate(this))
0028 {
0029     setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
0030     hide();
0031 }
0032 
0033 TextToSpeechContainerWidget::~TextToSpeechContainerWidget() = default;
0034 
0035 void TextToSpeechContainerWidget::say(const QString &text)
0036 {
0037     if (!d->textToSpeechWidget) {
0038         d->textToSpeechWidget = new TextToSpeechWidget(this);
0039         connect(d->textToSpeechWidget, &TextToSpeechWidget::changeVisibility, this, &TextToSpeechContainerWidget::setVisible);
0040         d->mainLayout->addWidget(d->textToSpeechWidget);
0041     }
0042     d->textToSpeechWidget->say(text);
0043 }
0044 
0045 #include "moc_texttospeechcontainerwidget.cpp"