7#include "plaintexteditorwidget.h"
8#include "config-textcustomeditor.h"
9#include "plaintexteditfindbar.h"
10#include "plaintexteditor.h"
11#include <TextAddonsWidgets/SlideContainer>
12#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
13#include <TextEditTextToSpeech/TextToSpeechContainerWidget>
18using namespace TextCustomEditor;
19class Q_DECL_HIDDEN TextCustomEditor::PlainTextEditorWidgetPrivate
22 PlainTextEditorWidgetPrivate() =
default;
26#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
34 , d(new TextCustomEditor::PlainTextEditorWidgetPrivate)
39PlainTextEditorWidget::PlainTextEditorWidget(
QWidget *parent)
41 , d(new TextCustomEditor::PlainTextEditorWidgetPrivate)
46PlainTextEditorWidget::~PlainTextEditorWidget() =
default;
53void PlainTextEditorWidget::clear()
58void PlainTextEditorWidget::setSpellCheckingConfigFileName(
const QString &_fileName)
60 d->mEditor->setSpellCheckingConfigFileName(_fileName);
63void PlainTextEditorWidget::setPlainText(
const QString &text)
65 d->mEditor->setPlainText(text);
68bool PlainTextEditorWidget::isEmpty()
const
70 return d->mEditor->document()->isEmpty();
73QString PlainTextEditorWidget::toPlainText()
const
75 return d->mEditor->toPlainText();
81 lay->setContentsMargins({});
82#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
84 lay->addWidget(d->mTextToSpeechWidget);
87 d->mEditor = customEditor;
91 lay->addWidget(d->mEditor);
92#if HAVE_KTEXTADDONS_TEXT_TO_SPEECH_SUPPORT
93 connect(d->mEditor, &PlainTextEditor::say, d->mTextToSpeechWidget, &TextEditTextToSpeech::TextToSpeechContainerWidget::say);
98 d->mFindBar->setHideWhenClose(
false);
99 connect(d->mFindBar, &TextCustomEditor::PlainTextEditFindBar::displayMessageIndicator, d->mEditor, &PlainTextEditor::slotDisplayMessageIndicator);
100 connect(d->mFindBar, &TextCustomEditor::PlainTextEditFindBar::hideFindBar,
this, &PlainTextEditorWidget::slotHideFindBar);
101 d->mSliderContainer->setContent(d->mFindBar);
103 lay->addWidget(d->mSliderContainer);
105 connect(d->mEditor, &PlainTextEditor::findText,
this, &PlainTextEditorWidget::slotFind);
107 connect(d->mEditor, &PlainTextEditor::replaceText,
this, &PlainTextEditorWidget::slotReplace);
110void PlainTextEditorWidget::slotHideFindBar()
112 d->mSliderContainer->slideOut();
113 d->mEditor->setFocus();
116bool PlainTextEditorWidget::isReadOnly()
const
118 return d->mEditor->isReadOnly();
121void PlainTextEditorWidget::setReadOnly(
bool readOnly)
123 d->mEditor->setReadOnly(readOnly);
126void PlainTextEditorWidget::slotReplace()
128 if (d->mEditor->searchSupport()) {
129 if (d->mEditor->textCursor().hasSelection()) {
130 d->mFindBar->setText(d->mEditor->textCursor().selectedText());
132 d->mFindBar->showReplace();
133 d->mSliderContainer->slideIn();
134 d->mFindBar->focusAndSetCursor();
138void PlainTextEditorWidget::slotFind()
140 if (d->mEditor->searchSupport()) {
141 if (d->mEditor->textCursor().hasSelection()) {
142 d->mFindBar->setText(d->mEditor->textCursor().selectedText());
145 d->mFindBar->showFind();
146 d->mSliderContainer->slideIn();
147 d->mFindBar->focusAndSetCursor();
151#include "moc_plaintexteditorwidget.cpp"
This widget is design to contain one child widget, the "content" widget.
The PlainTextEditFindBar class.
The PlainTextEditor class.
The TextToSpeechContainerWidget class.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)