26 #include <QApplication>
32 #include <QTextCursor>
33 #include <QTextDocumentFragment>
34 #include <QDBusInterface>
35 #include <QDBusConnection>
36 #include <QDBusConnectionInterface>
59 class KTextEdit::Private
64 customPalette( false ),
66 findReplaceEnabled(true),
68 showAutoCorrectionButton(false),
70 lastReplacedPosition(-1)
73 KConfig sonnetKConfig(
"sonnetrc");
82 QString metaMsg =
i18nc(
"Italic placeholder text in line edits: 0 no, 1 yes",
"1");
83 italicizePlaceholder = (metaMsg.trimmed() !=
QString(
'0'));
100 bool overrideShortcut(
const QKeyEvent* e);
104 bool handleShortcut(
const QKeyEvent* e);
106 void spellCheckerMisspelling(
const QString &text,
int pos );
107 void spellCheckerCorrected(
const QString &,
int,
const QString &);
109 void spellCheckerCanceled();
110 void spellCheckerFinished();
111 void toggleAutoSpellCheck();
113 void slotFindHighlight(
const QString& text,
int matchingIndex,
int matchingLength);
114 void slotReplaceText(
const QString &text,
int replacementIndex,
int ,
int matchedLength);
120 void undoableClear();
123 void menuActivated(
QAction* action );
125 QRect clickMessageRect()
const;
136 bool italicizePlaceholder : 1;
137 bool customPalette : 1;
140 bool findReplaceEnabled: 1;
142 bool showAutoCorrectionButton: 1;
143 QTextDocumentFragment originalDoc;
144 QString spellCheckingConfigFileName;
151 int findIndex, repIndex;
152 int lastReplacedPosition;
156 void KTextEdit::Private::checkSpelling(
bool force)
158 if(parent->document()->isEmpty())
162 emit parent->spellCheckingFinished();
167 if(!spellCheckingLanguage.isEmpty())
170 backgroundSpellCheck, force ? parent : 0);
171 backgroundSpellCheck->setParent(spellDialog);
172 spellDialog->setAttribute(Qt::WA_DeleteOnClose,
true);
176 connect(spellDialog, SIGNAL(misspelling(
QString,
int)),
177 parent, SLOT(spellCheckerMisspelling(
QString,
int)));
180 connect(spellDialog, SIGNAL(done(
QString)),
181 parent, SLOT(spellCheckerFinished()));
182 connect(spellDialog, SIGNAL(
cancel()),
183 parent, SLOT(spellCheckerCanceled()));
189 connect(spellDialog, SIGNAL(spellCheckStatus(
QString)),
190 parent, SIGNAL(spellCheckStatus(
QString)));
191 connect(spellDialog, SIGNAL(languageChanged(
QString)),
192 parent, SIGNAL(languageChanged(
QString)));
194 connect(spellDialog, SIGNAL(done(
QString)),parent, SIGNAL(spellCheckingFinished()));
195 connect(spellDialog, SIGNAL(
cancel()), parent, SIGNAL(spellCheckingCanceled()));
199 originalDoc = QTextDocumentFragment(parent->document());
200 spellDialog->
setBuffer(parent->toPlainText());
205 void KTextEdit::Private::spellCheckerCanceled()
207 QTextDocument *doc = parent->document();
209 QTextCursor cursor(doc);
210 cursor.insertFragment(originalDoc);
211 spellCheckerFinished();
214 void KTextEdit::Private::spellCheckerAutoCorrect(
const QString& currentWord,
const QString& autoCorrectWord)
216 emit parent->spellCheckerAutoCorrect(currentWord, autoCorrectWord);
219 void KTextEdit::Private::spellCheckerMisspelling(
const QString &text,
int pos )
222 parent->highlightWord( text.length(), pos );
225 void KTextEdit::Private::spellCheckerCorrected(
const QString& oldWord,
int pos,
const QString& newWord)
228 if (oldWord != newWord ) {
229 QTextCursor cursor(parent->document());
230 cursor.setPosition(pos);
231 cursor.setPosition(pos+oldWord.length(),QTextCursor::KeepAnchor);
232 cursor.insertText(newWord);
236 void KTextEdit::Private::spellCheckerFinished()
238 QTextCursor cursor(parent->document());
239 cursor.clearSelection();
240 parent->setTextCursor(cursor);
241 if (parent->highlighter())
242 parent->highlighter()->rehighlight();
245 void KTextEdit::Private::toggleAutoSpellCheck()
247 parent->setCheckSpellingEnabled( !parent->checkSpellingEnabled() );
250 void KTextEdit::Private::undoableClear()
252 QTextCursor cursor = parent->textCursor();
253 cursor.beginEditBlock();
254 cursor.movePosition(QTextCursor::Start);
256 cursor.removeSelectedText();
257 cursor.endEditBlock();
260 void KTextEdit::Private::slotAllowTab()
262 parent->setTabChangesFocus( !parent->tabChangesFocus() );
265 void KTextEdit::Private::menuActivated(
QAction* action )
267 if ( action == spellCheckAction )
268 parent->checkSpelling();
269 else if ( action == autoSpellCheckAction )
270 toggleAutoSpellCheck();
271 else if ( action == allowTab )
276 void KTextEdit::Private::slotFindHighlight(
const QString& text,
int matchingIndex,
int matchingLength)
280 QTextCursor tc = parent->textCursor();
281 tc.setPosition(matchingIndex);
282 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, matchingLength);
283 parent->setTextCursor(tc);
284 parent->ensureCursorVisible();
288 void KTextEdit::Private::slotReplaceText(const
QString &text,
int replacementIndex,
int replacedLength,
int matchedLength) {
290 QTextCursor tc = parent->textCursor();
291 tc.setPosition(replacementIndex);
292 tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, matchedLength);
293 tc.removeSelectedText();
294 tc.insertText(text.mid(replacementIndex, replacedLength));
296 parent->setTextCursor(tc);
297 parent->ensureCursorVisible();
299 lastReplacedPosition = replacementIndex;
302 QRect KTextEdit::Private::clickMessageRect()
const
304 int margin = int(parent->document()->documentMargin());
305 QRect rect = parent->viewport()->rect().adjusted(margin, margin, -margin, -margin);
306 return parent->fontMetrics().boundingRect(rect, Qt::AlignTop | Qt::TextWordWrap, clickMessage);
309 void KTextEdit::Private::init()
313 parent->connect(parent, SIGNAL(languageChanged(
QString)),
314 parent, SLOT(setSpellCheckingLanguage(
QString)));
318 :
QTextEdit( text, parent ), d( new Private( this ) )
324 :
QTextEdit( parent ), d( new Private( this ) )
336 d->spellCheckingConfigFileName = _fileName;
341 return d->spellCheckingLanguage;
351 if (_language != d->spellCheckingLanguage) {
352 d->spellCheckingLanguage = _language;
362 if (!d->spellCheckingLanguage.isEmpty())
364 if (!windowIcon.isEmpty())
365 dialog.setWindowIcon(
KIcon(windowIcon));
373 if (ev->type() == QEvent::ShortcutOverride) {
374 QKeyEvent *e =
static_cast<QKeyEvent *
>( ev );
375 if (d->overrideShortcut(e)) {
380 return QTextEdit::event(ev);
383 bool KTextEdit::Private::handleShortcut(
const QKeyEvent* event)
385 const int key =
event->key() |
event->modifiers();
397 if(!parent->isReadOnly())
401 if(!parent->isReadOnly())
405 if (!parent->isReadOnly())
406 parent->deleteWordBack();
409 if (!parent->isReadOnly())
410 parent->deleteWordForward();
413 QTextCursor cursor = parent->textCursor();
414 cursor.movePosition( QTextCursor::PreviousWord );
415 parent->setTextCursor( cursor );
418 QTextCursor cursor = parent->textCursor();
419 cursor.movePosition( QTextCursor::NextWord );
420 parent->setTextCursor( cursor );
423 QTextCursor cursor = parent->textCursor();
425 qreal lastY = parent->cursorRect(cursor).bottom();
428 qreal y = parent->cursorRect(cursor).bottom();
429 distance += qAbs(y - lastY);
431 moved = cursor.movePosition(QTextCursor::Down);
432 }
while (moved && distance < parent->viewport()->height());
436 parent->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
438 parent->setTextCursor(cursor);
441 QTextCursor cursor = parent->textCursor();
443 qreal lastY = parent->cursorRect(cursor).bottom();
446 qreal y = parent->cursorRect(cursor).bottom();
447 distance += qAbs(y - lastY);
450 }
while (moved && distance < parent->viewport()->height());
453 cursor.movePosition(QTextCursor::Down);
454 parent->verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
456 parent->setTextCursor(cursor);
459 QTextCursor cursor = parent->textCursor();
460 cursor.movePosition( QTextCursor::Start );
461 parent->setTextCursor( cursor );
464 QTextCursor cursor = parent->textCursor();
466 parent->setTextCursor( cursor );
469 QTextCursor cursor = parent->textCursor();
470 cursor.movePosition( QTextCursor::StartOfLine );
471 parent->setTextCursor( cursor );
474 QTextCursor cursor = parent->textCursor();
476 parent->setTextCursor( cursor );
482 parent->slotFindNext();
485 if (!parent->isReadOnly())
486 parent->slotReplace();
489 QString text = QApplication::clipboard()->text( QClipboard::Selection );
490 if ( !text.isEmpty() )
491 parent->insertPlainText( text );
497 static void deleteWord(QTextCursor cursor, QTextCursor::MoveOperation op)
499 cursor.clearSelection();
500 cursor.movePosition( op, QTextCursor::KeepAnchor );
501 cursor.removeSelectedText();
506 deleteWord(textCursor(), QTextCursor::PreviousWord);
511 deleteWord(textCursor(), QTextCursor::WordRight);
516 QMenu *popup = createStandardContextMenu();
517 if (!popup)
return 0;
518 connect( popup, SIGNAL(triggered(
QAction*)),
519 this, SLOT(menuActivated(
QAction*)) );
521 const bool emptyDocument = document()->isEmpty();
525 enum { UndoAct, RedoAct, CutAct, CopyAct, PasteAct, ClearAct, SelectAllAct, NCountActs };
527 int idx = actionList.indexOf( actionList[SelectAllAct] ) + 1;
528 if ( idx < actionList.count() )
529 separatorAction = actionList.at( idx );
530 if ( separatorAction )
534 clearAllAction->setEnabled(
false );
535 popup->insertAction( separatorAction, clearAllAction );
544 popup->addSeparator();
545 d->spellCheckAction = popup->addAction(
KIcon(
"tools-check-spelling" ),
546 i18n(
"Check Spelling..." ) );
548 d->spellCheckAction->setEnabled(
false );
549 d->autoSpellCheckAction = popup->addAction(
i18n(
"Auto Spell Check" ) );
550 d->autoSpellCheckAction->setCheckable(
true );
552 popup->addSeparator();
553 if (d->showTabAction) {
554 d->allowTab = popup->addAction(
i18n(
"Allow Tabulations") );
555 d->allowTab->setCheckable(
true );
556 d->allowTab->setChecked( !tabChangesFocus() );
560 if (d->findReplaceEnabled) {
564 findAction->setEnabled(
false);
565 findNextAction->setEnabled(
false);
567 findNextAction->setEnabled(d->find != 0);
569 popup->addSeparator();
570 popup->addAction(findAction);
571 popup->addAction(findNextAction);
576 replaceAction->setEnabled(
false);
578 popup->addAction(replaceAction);
581 popup->addSeparator();
582 QAction *speakAction = popup->addAction(
i18n(
"Speak Text"));
583 speakAction->setIcon(
KIcon(
"preferences-desktop-text-to-speech"));
584 speakAction->setEnabled(!emptyDocument );
585 connect( speakAction, SIGNAL(triggered(
bool)),
this, SLOT(
slotSpeakText()) );
592 if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
"org.kde.kttsd"))
601 QDBusInterface ktts(
"org.kde.kttsd",
"/KSpeech",
"org.kde.KSpeech");
603 if(textCursor().hasSelection())
604 text = textCursor().selectedText();
606 text = toPlainText();
607 ktts.asyncCall(
"say", text, 0);
613 QTextCursor cursorAtMouse = cursorForPosition(event->pos());
614 const int mousePos = cursorAtMouse.position();
615 QTextCursor cursor = textCursor();
618 const bool selectedWordClicked = cursor.hasSelection() &&
619 mousePos >= cursor.selectionStart() &&
620 mousePos <= cursor.selectionEnd();
624 QTextCursor wordSelectCursor(cursorAtMouse);
625 wordSelectCursor.clearSelection();
626 wordSelectCursor.select(QTextCursor::WordUnderCursor);
627 QString selectedWord = wordSelectCursor.selectedText();
629 bool isMouseCursorInsideWord =
true;
630 if ((mousePos < wordSelectCursor.selectionStart() ||
631 mousePos >= wordSelectCursor.selectionEnd())
632 && (selectedWord.length() > 1)) {
633 isMouseCursorInsideWord =
false;
637 wordSelectCursor.setPosition(wordSelectCursor.position()-selectedWord.size());
638 if (selectedWord.startsWith(
'\'') || selectedWord.startsWith(
'\"')) {
639 selectedWord = selectedWord.right(selectedWord.size() - 1);
640 wordSelectCursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor);
642 if (selectedWord.endsWith(
'\'') || selectedWord.endsWith(
'\"'))
643 selectedWord.chop(1);
645 wordSelectCursor.movePosition(QTextCursor::NextCharacter,
646 QTextCursor::KeepAnchor, selectedWord.size());
648 const bool wordIsMisspelled = isMouseCursorInsideWord &&
650 !selectedWord.isEmpty() &&
658 bool inQuote =
false;
659 if (d->spellInterface &&
660 !d->spellInterface->shouldBlockBeSpellChecked(cursorAtMouse.block().text()))
662 if (!selectedWordClicked) {
663 if (wordIsMisspelled && !inQuote)
664 setTextCursor(wordSelectCursor);
666 setTextCursor(cursorAtMouse);
667 cursor = textCursor();
672 if (!wordIsMisspelled || selectedWordClicked || inQuote) {
673 QMetaObject::invokeMethod(
this,
"mousePopupMenuImplementation", Q_ARG(
QPoint, event->globalPos()));
680 if (reps.isEmpty()) {
681 QAction *suggestionsAction = menu.addAction(
i18n(
"No suggestions for %1", selectedWord));
682 suggestionsAction->setEnabled(
false);
685 QStringList::const_iterator
end(reps.constEnd());
686 for (QStringList::const_iterator it = reps.constBegin(); it !=
end; ++it) {
693 QAction *ignoreAction = menu.addAction(
i18n(
"Ignore"));
694 QAction *addToDictAction = menu.addAction(
i18n(
"Add to Dictionary"));
696 const QAction *selectedAction = menu.exec(event->globalPos());
698 if (selectedAction) {
699 Q_ASSERT(cursor.selectedText() == selectedWord);
701 if (selectedAction == ignoreAction) {
705 else if (selectedAction == addToDictAction) {
712 const QString replacement = selectedAction->text();
713 Q_ASSERT(reps.contains(replacement));
714 cursor.insertText(replacement);
715 setTextCursor(cursor);
724 QTextEdit::wheelEvent( event );
726 QAbstractScrollArea::wheelEvent( event );
736 return d->highlighter;
741 delete d->highlighter;
742 d->highlighter = _highLighter;
747 if (d->spellInterface)
748 d->spellInterface->setSpellCheckingEnabled(check);
756 if ( check == d->checkSpellingEnabled )
763 d->checkSpellingEnabled = check;
774 delete d->highlighter;
781 if ( d->checkSpellingEnabled && !isReadOnly() && !d->highlighter )
784 QTextEdit::focusInEvent( event );
789 if (d->spellInterface)
790 return d->spellInterface->isSpellCheckingEnabled();
797 return d->checkSpellingEnabled;
802 if ( !readOnly && hasFocus() && d->checkSpellingEnabled && !d->highlighter )
805 if ( readOnly == isReadOnly() )
809 delete d->highlighter;
812 d->customPalette = testAttribute( Qt::WA_SetPalette );
813 QPalette p = palette();
814 QColor color = p.color( QPalette::Disabled, QPalette::Background );
815 p.setColor( QPalette::Base, color );
816 p.setColor( QPalette::Background, color );
819 if ( d->customPalette && testAttribute( Qt::WA_SetPalette ) ) {
820 QPalette p = palette();
821 QColor color = p.color( QPalette::Normal, QPalette::Base );
822 p.setColor( QPalette::Base, color );
823 p.setColor( QPalette::Background, color );
826 setPalette( QPalette() );
829 QTextEdit::setReadOnly( readOnly );
834 d->checkSpelling(
false);
839 d->checkSpelling(
true);
844 QTextCursor cursor(document());
845 cursor.setPosition(pos);
846 cursor.setPosition(pos+length,QTextCursor::KeepAnchor);
847 setTextCursor (cursor);
848 ensureCursorVisible();
853 if ( document()->isEmpty() )
861 connect( d->repDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoReplace()) );
873 if(d->repDlg->pattern().isEmpty()) {
876 ensureCursorVisible();
881 d->replace =
new KReplace(d->repDlg->pattern(), d->repDlg->replacement(), d->repDlg->options(),
this);
884 d->repIndex = textCursor().anchor();
889 connect(d->replace, SIGNAL(highlight(
QString,
int,
int)),
890 this, SLOT(slotFindHighlight(
QString,
int,
int)));
893 this, SLOT(slotReplaceText(
QString,
int,
int,
int)));
905 d->lastReplacedPosition = -1;
907 textCursor().beginEditBlock();
908 viewport()->setUpdatesEnabled(
false);
913 if (d->replace->needData())
914 d->replace->setData(toPlainText(), d->repIndex);
915 res = d->replace->replace();
917 textCursor().endEditBlock();
918 if (d->lastReplacedPosition >= 0) {
919 QTextCursor tc = textCursor();
920 tc.setPosition(d->lastReplacedPosition);
922 ensureCursorVisible();
925 viewport()->setUpdatesEnabled(
true);
926 viewport()->update();
930 d->replace->displayFinalDialog();
931 d->replace->disconnect(
this);
932 d->replace->deleteLater();
934 ensureCursorVisible();
948 if( d->findDlg->pattern().isEmpty())
955 d->find =
new KFind(d->findDlg->pattern(), d->findDlg->options(),
this);
958 d->findIndex = textCursor().anchor();
963 connect(d->find, SIGNAL(highlight(
QString,
int,
int)),
964 this, SLOT(slotFindHighlight(
QString,
int,
int)));
968 d->find->closeFindNextDialog();
977 if(document()->isEmpty())
979 d->find->disconnect(
this);
980 d->find->deleteLater();
986 if (d->find->needData())
987 d->find->setData(toPlainText(), d->findIndex);
988 res = d->find->find();
991 d->find->displayFinalDialog();
992 d->find->disconnect(
this);
993 d->find->deleteLater();
1004 if ( document()->isEmpty() )
1011 connect( d->findDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoFind()) );
1019 if ( document()->isEmpty() )
1027 connect( d->repDlg, SIGNAL(okClicked()),
this, SLOT(
slotDoReplace()) );
1034 d->findReplaceEnabled = enabled;
1039 d->showTabAction = show;
1044 d->spellInterface = spellInterface;
1047 bool KTextEdit::Private::overrideShortcut(
const QKeyEvent* event)
1049 const int key =
event->key() |
event->modifiers();
1091 }
else if (event->modifiers() == Qt::ControlModifier &&
1092 (
event->key() == Qt::Key_Return ||
event->key() == Qt::Key_Enter) &&
1093 qobject_cast<KDialog*>(parent->window()) ) {
1102 if (d->handleShortcut(event)) {
1104 }
else if (event->modifiers() == Qt::ControlModifier &&
1105 (
event->key() == Qt::Key_Return ||
event->key() == Qt::Key_Enter) &&
1106 qobject_cast<KDialog*>(window()) ) {
1109 QTextEdit::keyPressEvent(event);
1115 if (msg != d->clickMessage) {
1116 if (!d->clickMessage.isEmpty()) {
1117 viewport()->update(d->clickMessageRect());
1119 d->clickMessage = msg;
1120 if (!d->clickMessage.isEmpty()) {
1121 viewport()->update(d->clickMessageRect());
1128 return d->clickMessage;
1133 QTextEdit::paintEvent(ev);
1135 if (!d->clickMessage.isEmpty() && document()->isEmpty()) {
1136 QPainter p(viewport());
1139 f.setItalic(d->italicizePlaceholder);
1142 QColor color(palette().color(viewport()->foregroundRole()));
1143 color.setAlphaF(0.5);
1146 QRect cr = d->clickMessageRect();
1147 p.drawText(cr, Qt::AlignTop | Qt::TextWordWrap, d->clickMessage);
1153 QTextEdit::focusOutEvent(ev);
1158 d->showAutoCorrectionButton = show;
1171 #include "ktextedit.moc"
KGuiItem cancel()
Returns the 'Cancel' gui item.
void setCheckSpellingEnabled(bool check)
Turns background spell checking for this text edit on or off.
QString i18n(const char *text)
const KShortcut & findNext()
Find/search next.
void showAutoCorrectButton(bool show)
const KShortcut & deleteWordForward()
Delete a word forward from mouse/cursor position.
void checkSpellingChanged(bool)
emit signal when we activate or not autospellchecking
const KShortcut & next()
Scroll down one page.
virtual void deleteWordForward()
Deletes a word forwards from the current cursor position, if available.
void enableFindReplace(bool enabled)
Enable find replace action.
const KShortcut & forwardWord()
ForwardWord.
const KShortcut & redo()
Redo.
StandardShortcut find(const QKeySequence &seq)
Return the StandardShortcut id of the standard accel action which uses this key sequence, or AccelNone if none of them do.
bool checkSpellingEnabled() const
Returns true if background spell checking is enabled for this text edit.
void showTabAction(bool show)
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
Display an "Information" dialog.
QMenu * mousePopupMenu()
Return standard KTextEdit popupMenu.
const KShortcut & undo()
Undo last operation.
This interface is a workaround to keep binary compatibility in KDE4, because adding the virtual keywo...
Sonnet::Highlighter * highlighter() const
Returns the current highlighter, which is 0 if spell checking is disabled.
static void deleteWord(QTextCursor cursor, QTextCursor::MoveOperation op)
void ignoreWord(const QString &word)
Ignores the given word.
void replace()
Create replace dialogbox.
void setBuffer(const QString &)
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
Initiate a 'find' request in the current document.
QString clickMessage() const
KAction * findNext(const QObject *recvr, const char *slot, QObject *parent)
Find the next instance of a stored 'find'.
QString i18nc(const char *ctxt, const char *text)
KSharedConfigPtr config()
void setSpellCheckingConfigFileName(const QString &fileName)
Allows to override the config file where the settings for spell checking, like the current language o...
A generic "replace" dialog.
void languageChanged(const QString &language)
Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when ...
void highlightWord(int length, int pos)
Selects the characters at the specified position.
void forceSpellChecking()
void mousePopupMenuImplementation(const QPoint &pos)
static void activateWindow(WId win, long time=0)
Requests that window win is activated.
void setSpellInterface(KTextEditSpellInterface *spellInterface)
Sets the spell interface, which is used to delegate certain function calls to the interface...
Start from current cursor position.
void changeLanguage(const QString &lang)
virtual void setReadOnly(bool readOnly)
Reimplemented to set a proper "deactivated" background color.
A generic implementation of the "replace" function.
void setClickMessage(const QString &msg)
This makes the text edit display a grayed-out hinting text as long as the user didn't enter any text...
virtual void paintEvent(QPaintEvent *)
Reimplemented to paint clickMessage.
void setHighlighter(Sonnet::Highlighter *_highLighter)
Sets a custom backgound spell highlighter for this text edit.
const KShortcut & endOfLine()
Goto end of current line.
static bool wheelMouseZooms()
Typically, QScrollView derived classes can be scrolled fast by holding down the Ctrl-button during wh...
virtual void wheelEvent(QWheelEvent *)
Reimplemented to allow fast-wheelscrolling with Ctrl-Wheel or zoom.
const KShortcut & backwardWord()
BackwardWord.
A wrapper around QIcon that provides KDE icon features.
const KShortcut & beginningOfLine()
Goto beginning of current line.
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
Clear the content of the focus widget.
const KShortcut & replace()
Find and replace matches.
virtual void createHighlighter()
Allows to create a specific highlighter if reimplemented.
~KTextEdit()
Destroys the KTextEdit object.
void addWordToDictionary(const QString &word)
Adds the given word permanently to the dictionary.
QString language() const
return selected language
void activeAutoCorrect(bool _active)
const KShortcut & copy()
Copy selected area into the clipboard.
KTextEdit(const QString &text, QWidget *parent=0)
Constructs a KTextEdit object.
const QString & spellCheckingLanguage() const
void setCurrentLanguage(const QString &lang)
virtual void deleteWordBack()
Deletes a word backwards from the current cursor position, if available.
bool isWordMisspelled(const QString &word)
Checks if a given word is marked as misspelled by the highlighter.
static void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter=false)
Sets auto-hiding the cursor for widget w.
A generic implementation of the "find" function.
const KShortcut & cut()
Cut selected area and store it in the clipboard.
QStringList suggestionsForWord(const QString &word, int max=10)
Returns a list of suggested replacements for the given misspelled word.
virtual void contextMenuEvent(QContextMenuEvent *)
Reimplemented from QTextEdit to add spelling related items when appropriate.
KAction * replace(const QObject *recvr, const char *slot, QObject *parent)
Find and replace matches.
const KShortcut & deleteWordBack()
Delete a word back from mouse/cursor position.
virtual void focusInEvent(QFocusEvent *)
Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled.
const KShortcut & prior()
Scroll up one page.
const KShortcut & pasteSelection()
Paste the selection at mouse/cursor position.
Class to encapsulate user-driven action or event.
void showSpellConfigDialog(const QString &configFileName, const QString &windowIcon=QString())
Opens a Sonnet::ConfigDialog for this text edit.
void spellCheckerAutoCorrect(const QString ¤tWord, const QString &autoCorrectWord)
void setCheckSpellingEnabledInternal(bool check)
Enable or disable the spellchecking.
void setLanguage(const QString &language)
Sets the language/dictionary that will be selected by default in this config dialog.
bool checkSpellingEnabledInternal() const
Checks whether spellchecking is enabled or disabled.
virtual void keyPressEvent(QKeyEvent *)
Reimplemented for internal reasons.
void checkSpelling()
Show a dialog to check the spelling.
static void assignIconsToContextMenu(ContextMenus type, QList< QAction * > actions)
Assigns standard icons to the various standard text edit context menus.
void setSpellCheckingLanguage(const QString &language)
Set the spell check language which will be used for highlighting spelling mistakes and for the spellc...
virtual void focusOutEvent(QFocusEvent *)
const KShortcut & end()
Goto end of the document.
virtual bool event(QEvent *)
Reimplemented to catch "delete word" shortcut events.
void aboutToShowContextMenu(QMenu *menu)
Emitted before the context menu is displayed.
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
Display an "Error" dialog.
const KShortcut & paste()
Paste contents of clipboard at mouse/cursor position.
const KShortcut & begin()
Goto beginning of the document.