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
|
/*
SPDX-FileCopyrightText: 2023-2026 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "texttospeechcontainerwidget.h"
#include "texttospeechwidget.h"
#include <QHBoxLayout>
using namespace Qt::Literals::StringLiterals;
using namespace TextEditTextToSpeech;
class Q_DECL_HIDDEN TextEditTextToSpeech::TextToSpeechContainerWidgetPrivate
{
public:
TextToSpeechContainerWidgetPrivate(TextToSpeechContainerWidget *q)
: mainLayout(new QHBoxLayout(q))
{
mainLayout->setObjectName(u"mainLayout"_s);
mainLayout->setContentsMargins({});
}
TextToSpeechWidget *textToSpeechWidget = nullptr;
QHBoxLayout *const mainLayout;
};
TextToSpeechContainerWidget::TextToSpeechContainerWidget(QWidget *parent)
: QWidget{parent}
, d(new TextEditTextToSpeech::TextToSpeechContainerWidgetPrivate(this))
{
setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
hide();
}
TextToSpeechContainerWidget::~TextToSpeechContainerWidget() = default;
void TextToSpeechContainerWidget::say(const QString &text)
{
initialize();
d->textToSpeechWidget->say(text);
}
void TextToSpeechContainerWidget::initialize()
{
if (!d->textToSpeechWidget) {
d->textToSpeechWidget = new TextToSpeechWidget(this);
connect(d->textToSpeechWidget, &TextToSpeechWidget::changeVisibility, this, &TextToSpeechContainerWidget::setVisible);
d->mainLayout->addWidget(d->textToSpeechWidget);
}
}
qsizetype TextToSpeechContainerWidget::enqueue(const QString &text)
{
initialize();
return d->textToSpeechWidget->enqueue(text);
}
#include "moc_texttospeechcontainerwidget.cpp"
|