7#include "richtexteditorwidget.h"
8#include "richtexteditfindbar.h"
9#include "richtexteditor.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::RichTextEditorWidgetPrivate
24 RichTextEditorWidgetPrivate() =
default;
28#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
36 , d(new TextCustomEditor::RichTextEditorWidgetPrivate)
41RichTextEditorWidget::RichTextEditorWidget(
QWidget *parent)
43 , d(new TextCustomEditor::RichTextEditorWidgetPrivate)
48RichTextEditorWidget::~RichTextEditorWidget() =
default;
50void RichTextEditorWidget::clear()
60void RichTextEditorWidget::setAcceptRichText(
bool b)
62 d->mEditor->setAcceptRichText(b);
65bool RichTextEditorWidget::acceptRichText()
const
67 return d->mEditor->acceptRichText();
70void RichTextEditorWidget::setSpellCheckingConfigFileName(
const QString &_fileName)
72 d->mEditor->setSpellCheckingConfigFileName(_fileName);
75void RichTextEditorWidget::setHtml(
const QString &html)
77 d->mEditor->setHtml(html);
80QString RichTextEditorWidget::toHtml()
const
82 return d->mEditor->toHtml();
85void RichTextEditorWidget::setPlainText(
const QString &text)
87 d->mEditor->setPlainText(text);
90bool RichTextEditorWidget::isEmpty()
const
92 return d->mEditor->document()->isEmpty();
95QString RichTextEditorWidget::toPlainText()
const
97 return d->mEditor->toPlainText();
103 lay->setContentsMargins({});
104#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
106 lay->addWidget(d->mTextToSpeechWidget);
109 d->mEditor = customEditor;
113#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
114 connect(d->mEditor, &RichTextEditor::say, d->mTextToSpeechWidget, &TextEditTextToSpeech::TextToSpeechContainerWidget::say);
116 lay->addWidget(d->mEditor);
121 d->mFindBar->setHideWhenClose(
false);
122 connect(d->mFindBar, &TextCustomEditor::RichTextEditFindBar::displayMessageIndicator, d->mEditor, &RichTextEditor::slotDisplayMessageIndicator);
124 connect(d->mFindBar, &TextCustomEditor::RichTextEditFindBar::hideFindBar,
this, &RichTextEditorWidget::slotHideFindBar);
125 d->mSliderContainer->setContent(d->mFindBar);
126 lay->addWidget(d->mSliderContainer);
128 connect(d->mEditor, &RichTextEditor::findText,
this, &RichTextEditorWidget::slotFind);
129 connect(d->mEditor, &RichTextEditor::replaceText,
this, &RichTextEditorWidget::slotReplace);
132void RichTextEditorWidget::slotHideFindBar()
134 d->mSliderContainer->slideOut();
135 d->mEditor->setFocus();
138bool RichTextEditorWidget::isReadOnly()
const
140 return d->mEditor->isReadOnly();
143void RichTextEditorWidget::setReadOnly(
bool readOnly)
145 d->mEditor->setReadOnly(readOnly);
148void RichTextEditorWidget::slotReplace()
150 if (d->mEditor->searchSupport()) {
151 if (d->mEditor->textCursor().hasSelection()) {
152 d->mFindBar->setText(d->mEditor->textCursor().selectedText());
154 d->mFindBar->showReplace();
155 d->mSliderContainer->slideIn();
156 d->mFindBar->focusAndSetCursor();
160void RichTextEditorWidget::slotFindNext()
162 if (d->mEditor->searchSupport()) {
163 if (d->mFindBar->isVisible()) {
164 d->mFindBar->findNext();
171void RichTextEditorWidget::slotFind()
173 if (d->mEditor->searchSupport()) {
174 if (d->mEditor->textCursor().hasSelection()) {
175 d->mFindBar->setText(d->mEditor->textCursor().selectedText());
179 d->mFindBar->showFind();
180 d->mSliderContainer->slideIn();
181 d->mFindBar->focusAndSetCursor();
185#include "moc_richtexteditorwidget.cpp"
This widget is design to contain one child widget, the "content" widget.
The RichTextEditFindBar class.
The RichTextEditor class.
The TextToSpeechContainerWidget class.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)