7#include "richtextbrowserwidget.h"
8#include "richtextbrowser.h"
9#include "richtextbrowserfindbar.h"
11#include "config-textcustomeditor.h"
14#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
15#include <TextEditTextToSpeech/TextToSpeechContainerWidget>
17#include <TextAddonsWidgets/SlideContainer>
19using namespace TextCustomEditor;
21class Q_DECL_HIDDEN TextCustomEditor::RichTextBrowserWidgetPrivate
24 RichTextBrowserWidgetPrivate() =
default;
28#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
36 , d(new TextCustomEditor::RichTextBrowserWidgetPrivate)
41RichTextBrowserWidget::RichTextBrowserWidget(
QWidget *parent)
43 , d(new TextCustomEditor::RichTextBrowserWidgetPrivate)
48RichTextBrowserWidget::~RichTextBrowserWidget() =
default;
50void RichTextBrowserWidget::clear()
60void RichTextBrowserWidget::setAcceptRichText(
bool b)
62 d->mEditor->setAcceptRichText(b);
65bool RichTextBrowserWidget::acceptRichText()
const
67 return d->mEditor->acceptRichText();
70void RichTextBrowserWidget::setHtml(
const QString &html)
72 d->mEditor->setHtml(html);
75QString RichTextBrowserWidget::toHtml()
const
77 return d->mEditor->toHtml();
80void RichTextBrowserWidget::setPlainText(
const QString &text)
82 d->mEditor->setPlainText(text);
85bool RichTextBrowserWidget::isEmpty()
const
87 return d->mEditor->document()->isEmpty();
90QString RichTextBrowserWidget::toPlainText()
const
92 return d->mEditor->toPlainText();
98 lay->setContentsMargins({});
99#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
101 lay->addWidget(d->mTextToSpeechWidget);
104 d->mEditor = customEditor;
108#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
109 connect(d->mEditor, &RichTextBrowser::say, d->mTextToSpeechWidget, &TextEditTextToSpeech::TextToSpeechContainerWidget::say);
111 lay->addWidget(d->mEditor);
116 d->mFindBar->setHideWhenClose(
false);
117 connect(d->mFindBar, &TextCustomEditor::RichTextBrowserFindBar::displayMessageIndicator, d->mEditor, &RichTextBrowser::slotDisplayMessageIndicator);
119 connect(d->mFindBar, &TextCustomEditor::RichTextBrowserFindBar::hideFindBar,
this, &RichTextBrowserWidget::slotHideFindBar);
120 d->mSliderContainer->setContent(d->mFindBar);
121 lay->addWidget(d->mSliderContainer);
123 connect(d->mEditor, &RichTextBrowser::findText,
this, &RichTextBrowserWidget::slotFind);
126void RichTextBrowserWidget::slotHideFindBar()
128 d->mSliderContainer->slideOut();
129 d->mEditor->setFocus();
132void RichTextBrowserWidget::slotFindNext()
134 if (d->mEditor->searchSupport()) {
135 if (d->mFindBar->isVisible()) {
136 d->mFindBar->findNext();
143void RichTextBrowserWidget::slotFind()
145 if (d->mEditor->searchSupport()) {
146 if (d->mEditor->textCursor().hasSelection()) {
147 d->mFindBar->setText(d->mEditor->textCursor().selectedText());
151 d->mFindBar->showFind();
152 d->mSliderContainer->slideIn();
153 d->mFindBar->focusAndSetCursor();
157#include "moc_richtextbrowserwidget.cpp"
This widget is design to contain one child widget, the "content" widget.
The RichTextBrowserFindBar class.
The RichTextBrowser class.
The TextToSpeechContainerWidget class.
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)