KTextWidgets 5.109.0
|
A KRichTextEdit with common actions. More...
#include <KRichTextWidget>
Public Types | |
typedef QFlags< RichTextSupportValues > | RichTextSupport |
Stores a combination of #RichTextSupportValues values. | |
enum | RichTextSupportValues { DisableRichText = 0x00 , SupportBold = 0x01 , SupportItalic = 0x02 , SupportUnderline = 0x04 , SupportStrikeOut = 0x08 , SupportFontFamily = 0x10 , SupportFontSize = 0x20 , SupportTextForegroundColor = 0x40 , SupportTextBackgroundColor = 0x80 , FullTextFormattingSupport = 0xff , SupportChangeListStyle = 0x100 , SupportIndentLists = 0x200 , SupportDedentLists = 0x400 , FullListSupport = 0xf00 , SupportAlignment = 0x100000 , SupportRuleLine = 0x400000 , SupportHyperlinks = 0x800000 , SupportFormatPainting = 0x1000000 , SupportToPlainText = 0x2000000 , SupportSuperScriptAndSubScript = 0x4000000 , SupportDirection = 0x8000000 , SupportHeading = 0x10000000 , FullSupport = 0xffffffff } |
These flags describe what actions will be created by createActions() after passing a combination of these flags to setRichTextSupport(). More... | |
![]() | |
enum | Mode { Plain , Rich } |
The mode the edit widget is in. More... | |
Properties | |
RichTextSupport | richTextSupport |
![]() | |
bool | checkSpellingEnabled |
QString | spellCheckingLanguage |
Public Slots | |
void | setActionsEnabled (bool enabled) |
Disables or enables all of the actions created by createActions(). | |
![]() | |
void | alignCenter () |
Sets the alignment of the current block to Centered. | |
void | alignJustify () |
Sets the alignment of the current block to Justified. | |
void | alignLeft () |
Sets the alignment of the current block to Left Aligned. | |
void | alignRight () |
Sets the alignment of the current block to Right Aligned. | |
void | indentListLess () |
Decreases the nesting level of the current block or selected blocks. | |
void | indentListMore () |
Increases the nesting level of the current block or selected blocks. | |
void | insertHorizontalRule () |
Inserts a horizontal rule below the current block. | |
void | insertPlainTextImplementation () |
void | makeLeftToRight () |
Sets the direction of the current block to Left-To-Right. | |
void | makeRightToLeft () |
Sets the direction of the current block to Right-To-Left. | |
void | setFont (const QFont &font) |
Sets the current word or selection to the font font. | |
void | setFontFamily (const QString &fontFamily) |
Sets the current word or selection to the font family fontFamily. | |
void | setFontSize (int size) |
Sets the current word or selection to the font size size. | |
void | setHeadingLevel (int level) |
Sets the heading level of a current block or selection. | |
void | setListStyle (int _styleIndex) |
Sets the list style of the current list, or creates a new list using the current block. | |
void | setTextBackgroundColor (const QColor &color) |
Sets the background color of the current word or selection to color. | |
void | setTextBold (bool bold) |
Toggles the bold formatting of the current word or selection at the current cursor position. | |
void | setTextForegroundColor (const QColor &color) |
Sets the foreground color of the current word or selection to color. | |
void | setTextItalic (bool italic) |
Toggles the italic formatting of the current word or selection at the current cursor position. | |
void | setTextStrikeOut (bool strikeOut) |
Toggles the strikeout formatting of the current word or selection at the current cursor position. | |
void | setTextSubScript (bool subscript) |
Toggles the subscript formatting of the current word or selection at the current cursor position. | |
void | setTextSuperScript (bool superscript) |
Toggles the superscript formatting of the current word or selection at the current cursor position. | |
void | setTextUnderline (bool underline) |
Toggles the underline formatting of the current word or selection at the current cursor position. | |
void | switchToPlainText () |
This will switch the editor to plain text mode. | |
QString | toCleanHtml () const |
This will clean some of the bad html produced by the underlying QTextEdit It walks over all lines and cleans up a bit. | |
![]() | |
void | addTextDecorator (Sonnet::SpellCheckDecorator *decorator) |
Add custom spell checker decorator. | |
void | checkSpelling () |
Show a dialog to check the spelling. | |
void | clearDecorator () |
clearDecorator clear the spellcheckerdecorator | |
void | replace () |
Create replace dialogbox. | |
void | setSpellCheckingLanguage (const QString &language) |
Set the spell check language which will be used for highlighting spelling mistakes and for the spellcheck dialog. | |
void | showSpellConfigDialog (const QString &windowIcon=QString()) |
Opens a Sonnet::ConfigDialog for this text edit. | |
Public Member Functions | |
KRichTextWidget (const QString &text, QWidget *parent=nullptr) | |
Constructs a KRichTextWidget object. | |
KRichTextWidget (QWidget *parent) | |
Constructor. | |
~KRichTextWidget () override | |
Destructor. | |
virtual QList< QAction * > | createActions () |
Creates the actions and adds them to the given action collection. | |
RichTextSupport | richTextSupport () const |
Returns the supported rich text subset available. | |
void | setRichTextSupport (const KRichTextWidget::RichTextSupport &support) |
Sets the supported rich text subset available. | |
void | updateActionStates () |
Tells KRichTextWidget to update the state of the actions created by createActions(). | |
![]() | |
KRichTextEdit (const QString &text, QWidget *parent=nullptr) | |
Constructs a KRichTextEdit object. | |
KRichTextEdit (QWidget *parent=nullptr) | |
Constructs a KRichTextEdit object. | |
~KRichTextEdit () override | |
Destructor. | |
bool | canDedentList () const |
Returns true if the list item at the current position can be dedented. | |
bool | canIndentList () const |
Returns true if the list item at the current position can be indented. | |
QString | currentLinkText () const |
Returns the text of the link at the current position or an empty string if the cursor is not on a link. | |
QString | currentLinkUrl () const |
Returns the URL target (href) of the link at the current position or an empty string if the cursor is not on a link. | |
void | enableRichTextMode () |
This enables rich text mode. | |
void | selectLinkText () const |
Convenience function to select the link text using the active cursor. | |
void | selectLinkText (QTextCursor *cursor) const |
If the cursor is on a link, sets the cursor to a selection of the text of the link. | |
void | setTextOrHtml (const QString &text) |
Replaces all the content of the text edit with the given string. | |
Mode | textMode () const |
QString | textOrHtml () const |
void | updateLink (const QString &linkUrl, const QString &linkText) |
Replaces the current selection with a hyperlink with the link URL linkUrl and the link text linkText. | |
![]() | |
KTextEdit (const QString &text, QWidget *parent=nullptr) | |
Constructs a KTextEdit object. | |
KTextEdit (QWidget *parent=nullptr) | |
Constructs a KTextEdit object. | |
~KTextEdit () override | |
Destroys the KTextEdit object. | |
virtual bool | checkSpellingEnabled () const |
Returns true if background spell checking is enabled for this text edit. | |
virtual void | createHighlighter () |
Allows to create a specific highlighter if reimplemented. | |
void | enableFindReplace (bool enabled) |
Enable find replace action. | |
void | forceSpellChecking () |
Sonnet::Highlighter * | highlighter () const |
Returns the current highlighter, which is 0 if spell checking is disabled. | |
void | highlightWord (int length, int pos) |
Selects the characters at the specified position. | |
virtual QMenu * | mousePopupMenu () |
Return standard KTextEdit popupMenu. | |
virtual void | setCheckSpellingEnabled (bool check) |
Turns background spell checking for this text edit on or off. | |
void | setHighlighter (Sonnet::Highlighter *_highLighter) |
Sets a custom background spell highlighter for this text edit. | |
virtual void | setReadOnly (bool readOnly) |
Reimplemented to set a proper "deactivated" background color. | |
virtual bool | shouldBlockBeSpellChecked (const QString &block) const |
Returns true if the given paragraph or block should be spellcheck. | |
void | showAutoCorrectButton (bool show) |
void | showTabAction (bool show) |
const QString & | spellCheckingLanguage () const |
Protected Member Functions | |
void | mouseReleaseEvent (QMouseEvent *event) override |
Reimplemented. | |
![]() | |
__attribute__ ((visibility("hidden"))) KRichTextEdit(KRichTextEditPrivate &dd | |
__attribute__ ((visibility("hidden"))) KRichTextEdit(KRichTextEditPrivate &dd | |
void | keyPressEvent (QKeyEvent *event) override |
Reimplemented. | |
![]() | |
KTEXTWIDGETS_NO_EXPORT | KTextEdit (KTextEditPrivate &dd, const QString &text, QWidget *parent) |
KTEXTWIDGETS_NO_EXPORT | KTextEdit (KTextEditPrivate &dd, QWidget *parent) |
void | contextMenuEvent (QContextMenuEvent *) override |
Reimplemented from QTextEdit to add spelling related items when appropriate. | |
virtual void | deleteWordBack () |
Deletes a word backwards from the current cursor position, if available. | |
virtual void | deleteWordForward () |
Deletes a word forwards from the current cursor position, if available. | |
bool | event (QEvent *) override |
Reimplemented to catch "delete word" shortcut events. | |
void | focusInEvent (QFocusEvent *) override |
Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled. | |
void | keyPressEvent (QKeyEvent *) override |
Reimplemented for internal reasons. | |
Additional Inherited Members | |
![]() | |
void | selectionFinished () |
Emitted whenever the user has finished making a selection. | |
void | textModeChanged (KRichTextEdit::Mode mode) |
Emitted whenever the text mode is changed. | |
![]() | |
void | aboutToShowContextMenu (QMenu *menu) |
Emitted before the context menu is displayed. | |
void | checkSpellingChanged (bool) |
emit signal when we activate or not autospellchecking | |
void | languageChanged (const QString &language) |
Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when calling setSpellCheckingLanguage(). | |
void | spellCheckerAutoCorrect (const QString ¤tWord, const QString &autoCorrectWord) |
void | spellCheckingCanceled () |
signal spellCheckingCanceled is sent when we cancel spell checking. | |
void | spellCheckingFinished () |
signal spellCheckingFinished is sent when we finish spell check or we click on "Terminate" button in sonnet dialogbox | |
void | spellCheckStatus (const QString &) |
Signal sends when spell checking is finished/stopped/completed. | |
![]() | |
void | slotDoFind () |
void | slotDoReplace () |
void | slotFind () |
void | slotFindNext () |
void | slotFindPrevious () |
void | slotReplace () |
void | slotReplaceNext () |
void | slotSpeakText () |
![]() | |
const QString QWidget * | parent |
QWidget * | parent |
const QString & | text |
A KRichTextEdit with common actions.
This class implements common actions which are often used with KRichTextEdit. All you need to do is to call createActions(), and the actions will be added to your KXMLGUIWindow. Remember to also add the chosen actions to your application ui.rc file.
See the KRichTextWidget::RichTextSupportValues enum for an overview of supported actions.
typedef QFlags< RichTextSupportValues > KRichTextWidget::RichTextSupport |
Stores a combination of #RichTextSupportValues values.
These flags describe what actions will be created by createActions() after passing a combination of these flags to setRichTextSupport().
|
explicit |
Constructor.
parent | the parent widget |
|
explicit |
Constructs a KRichTextWidget object.
text | The initial text of the text edit, which is interpreted as HTML. |
parent | The parent widget |
|
override |
Destructor.
|
virtual |
Creates the actions and adds them to the given action collection.
Call this before calling setupGUI() in your application, but after calling setRichTextSupport().
The XML file of your KXmlGuiWindow needs to have the action names in them, so that the actions actually appear in the menu and in the toolbars.
Below is a list of actions that are created,depending on the supported rich text subset set by setRichTextSupport(). The list contains action names. Those names need to be the same in your XML file.
See the KRichTextWidget::RichTextSupportValues enum documentation for a detailed explanation of each action.
XML Name | RichTextSupportValues flag |
format_text_foreground_color | SupportTextForegroundColor |
format_text_background_color | SupportTextBackgroundColor |
format_font_family | SupportFontFamily |
format_font_size | SupportFontSize |
format_text_bold | SupportBold |
format_text_italic | SupportItalic |
format_text_underline | SupportUnderline |
format_text_strikeout | SupportStrikeOut |
format_align_left | SupportAlignment |
format_align_center | SupportAlignment |
format_align_right | SupportAlignment |
format_align_justify | SupportAlignment |
direction_ltr | SupportDirection |
direction_rtl | SupportDirection |
format_list_style | SupportChangeListStyle |
format_list_indent_more | SupportIndentLists |
format_list_indent_less | SupportDedentLists |
insert_horizontal_rule | SupportRuleLine |
manage_link | SupportHyperlinks |
format_painter | SupportFormatPainting |
action_to_plain_text | SupportToPlainText |
format_text_subscript & format_text_superscript | SupportSuperScriptAndSubScript |
format_heading_level | SupportHeading |
|
overrideprotected |
Reimplemented.
Catches mouse release events. Used to know when a selection has been completed.
RichTextSupport KRichTextWidget::richTextSupport | ( | ) | const |
Returns the supported rich text subset available.
|
slot |
Disables or enables all of the actions created by createActions().
This may be useful in cases where rich text mode may be set on or off.
enabled | Whether to enable or disable the actions. |
void KRichTextWidget::setRichTextSupport | ( | const KRichTextWidget::RichTextSupport & | support | ) |
Sets the supported rich text subset available.
The default is KRichTextWidget::FullSupport and will be set in the constructor.
You need to call createActions() afterwards.
support | The supported subset. |
void KRichTextWidget::updateActionStates | ( | ) |
Tells KRichTextWidget to update the state of the actions created by createActions().
This is normally automatically done, but there might be a few cases where you'll need to manually call this function.
Call this function only after calling createActions().