|
Krita Source Code Documentation
|
The SvgTextCursor class. More...
#include <SvgTextCursor.h>
Inheritance diagram for SvgTextCursor:Public Types | |
| enum | MoveMode { MoveNone , MoveLeft , MoveRight , MoveUp , MoveDown , MoveNextChar , MovePreviousChar , MoveNextLine , MovePreviousLine , MoveWordLeft , MoveWordRight , MoveWordEnd , MoveWordStart , MoveLineStart , MoveLineEnd , ParagraphStart , ParagraphEnd } |
Signals | |
| void | selectionChanged () |
| void | sigOpenGlyphPalette () |
| void | updateCursorDecoration (QRectF updateRect) |
Public Member Functions | |
| void | copy () const |
| copy copies plain text into the clipboard between anchor and pos. | |
| QPair< KoSvgTextProperties, KoSvgTextProperties > | currentTextProperties () const |
| currentTextProperties | |
| void | deselectText () |
| void | focusIn () |
| Turns on blinking cursor. | |
| void | focusOut () |
| Stops blinking cursor. | |
| int | getAnchor () |
| Get the current selection anchor. This is the same as position, unless there's a selection. | |
| int | getPos () |
| Get the current position. | |
| bool | hasSelection () override |
| return true if the tool currently has something selected that can be copied or deleted. | |
| void | inputMethodEvent (QInputMethodEvent *event) |
| QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
| void | insertRichText (KoSvgTextShape *insert) |
| Insert rich text at getPos();. | |
| void | insertText (QString text) |
| Insert text at getPos() | |
| bool | isAddingCommand () const |
| the cursor is currently adding a command | |
| void | keyPressEvent (QKeyEvent *event) |
| Handle the cursor-related key events. | |
| void | mergePropertiesIntoSelection (const KoSvgTextProperties props, const QSet< KoSvgTextProperties::PropertyId > removeProperties=QSet< KoSvgTextProperties::PropertyId >()) |
| void | moveCursor (MoveMode mode, bool moveAnchor=true) |
| Move the cursor, and, if you don't want a selection, move the anchor. | |
| void | notifyCursorPosChanged (int pos, int anchor) override |
| void | notifyMarkupChanged () override |
| void | notifyShapeChanged (KoShape::ChangeType type, KoShape *shape) override |
| void | paintDecorations (QPainter &gc, QColor selectionColor, int decorationThickness=1) |
| bool | paste () |
| paste pastes plain text in the clipboard at pos. Uses pasteRichTextByDefault to determine whether to try and paste rich text. | |
| QList< KoSvgTextProperties > | propertiesForRange () const |
| bool | registerPropertyAction (QAction *action, const QString &name) |
| Register an action. | |
| void | removeLastCodePoint () |
| void | removeSelection () |
| removeSelection if there's a selection, creates a text-removal command. | |
| void | removeText (MoveMode first, MoveMode second) |
| removeText remove text relative to the current position. This will move the cursor according to the move modes and then remove the text between the two positions. | |
| void | setCaretSetting (int cursorWidth=1, int cursorFlash=1000, int cursorFlashLimit=5000) |
| setCaretSetting Set the caret settings for the cursor. Qt has some standard functionality associated, which we pass via this. | |
| void | setPasteRichTextByDefault (const bool pasteRichText=true) |
| setPasteRichText | |
| void | setPos (int pos, int anchor) |
| Set the pos and the anchor. | |
| void | setPosToPoint (QPointF point, bool moveAnchor=true) |
| Set the pos from a point. This currently does a search inside the text shape. | |
| void | setShape (KoSvgTextShape *textShape) |
| setShape | |
| void | setVisualMode (const bool visualMode=true) |
| setVisualMode set whether the navigation mode is visual or logical. This right now primarily affects Bidirectional text. | |
| KoSvgTextShape * | shape () const |
| Get the current text shape. | |
| SvgTextCursor (KoCanvasBase *canvas) | |
| KoSvgTextPropertiesInterface * | textPropertyInterface () |
| ~SvgTextCursor () | |
Public Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Public Member Functions inherited from KoToolSelection | |
| KoToolSelection (QObject *parent=0) | |
| ~KoToolSelection () override | |
Public Member Functions inherited from KoSvgTextShape::TextCursorChangeListener | |
| void | notifyShapeChanged (ChangeType type, KoShape *shape) override |
Public Member Functions inherited from KoShape::ShapeChangeListener | |
| virtual | ~ShapeChangeListener () |
Public Attributes | |
| QList< QAction * > | actions |
| int | anchor = 0 |
| QLineF | anchorCaret |
| int | anchorIndex = 0 |
| bool | blockQueryUpdates = false |
| Block qApp->inputMethod->update(), enabled during the inputmethod event flow. | |
| KoCanvasBase * | canvas |
| QLineF | cursorCaret |
| QColor | cursorColor |
| QTimer | cursorFlash |
| QTimer | cursorFlashLimit |
| QPainterPath | cursorShape |
| bool | cursorVisible = false |
| int | cursorWidth = 1 |
| QPainterPath | IMEDecoration |
| The decorations for the current preedit string. | |
| SvgTextCursorPropertyInterface * | interface {nullptr} |
| bool | isAddingCommand = false |
| QRectF | oldCursorRect |
| QRectF | oldIMEDecorationRect |
| Update Rectangle of previous decoration. | |
| QRectF | oldSelectionRect |
| bool | pasteRichText = true |
| int | pos = 0 |
| int | posIndex = 0 |
| SvgTextInsertCommand * | preEditCommand {nullptr} |
| PreEdit string as an command provided by the input method. | |
| int | preEditLength = -1 |
| Length of the preEditString. | |
| int | preEditStart = -1 |
| Start of the preEdit string as a cursor pos. | |
| QPainterPath | selection |
| KoSvgTextShape * | shape {nullptr} |
| QVector< IMEDecorationInfo > | styleMap |
| Decoration info (underlines) for the preEdit string to differentiate it from regular text. | |
| bool | visualNavigation = true |
Public Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
Private Slots | |
| void | blinkCursor () |
| void | canvasResourceChanged (int key, const QVariant &value) |
| bool | pastePlainText () |
| pastePlainText Explicitely paste plaintext at pos. | |
| bool | pasteRichText () |
| pasteRichText | |
| void | propertyAction () |
| void | stopBlinkCursor () |
| void | toggleProperty (KoSvgTextProperties::PropertyId property) |
| void | updateInputMethodItemTransform () |
Private Member Functions | |
| bool | acceptableInput (const QKeyEvent *event) const |
| More or less copied from bool QInputControl::isAcceptableInput(const QKeyEvent *event) const. | |
| void | addCommandToUndoAdapter (KUndo2Command *cmd) |
| void | commitIMEPreEdit () |
| int | moveModeResult (MoveMode &mode, int &pos, bool visual=false) const |
| SvgTextRemoveCommand * | removeSelectionImpl (bool allowCleanUp, KUndo2Command *parent=0) |
| removeSelection if there's a selection, creates a text-removal command. | |
| void | updateCanvasResources () |
| void | updateCursor (bool firstUpdate=false) |
| update the cursor shape. First update will block ensuring the canvas is visible so setShape won't cause this. | |
| void | updateIMEDecoration () |
| void | updateSelection () |
Private Attributes | |
| const QScopedPointer< Private > | d |
The SvgTextCursor class.
This class handles cursor movement and text editing operations.
It acts as the KoToolSelection for SvgTextTool, allowing it to integrate with the basic KoToolBase functionality for copy, cut paste and clear.
A selection is defined as the anchor being different from the cursor position, with the move operation accepting whether you want to shift the cursor position.
It is also a shape listener to allow the textcursor to update itself whenever the corresponding text shape changes.
Definition at line 106 of file SvgTextCursor.cpp.
Definition at line 49 of file SvgTextCursor.h.
|
explicit |
Definition at line 147 of file SvgTextCursor.cpp.
References canvas, canvasResourceChanged(), connect(), d, and updateInputMethodItemTransform().
| SvgTextCursor::~SvgTextCursor | ( | ) |
Definition at line 160 of file SvgTextCursor.cpp.
References commitIMEPreEdit(), and d.
|
private |
More or less copied from bool QInputControl::isAcceptableInput(const QKeyEvent *event) const.
Definition at line 1431 of file SvgTextCursor.cpp.
|
private |
|
privateslot |
Definition at line 844 of file SvgTextCursor.cpp.
References d, and updateCursorDecoration().
|
privateslot |
Definition at line 886 of file SvgTextCursor.cpp.
References KoSvgTextProperties::background(), KoCanvasResource::BackgroundColor, d, KoSvgTextProperties::FillId, KoCanvasResource::ForegroundColor, hasSelection(), KoSvgTextProperties::isEmpty(), mergePropertiesIntoSelection(), KoSvgTextProperties::setProperty(), KoSvgTextProperties::stroke(), KoSvgTextProperties::StrokeId, KoColor::toQColor(), and value().
|
private |
Definition at line 1455 of file SvgTextCursor.cpp.
References d, updateCursor(), and updateIMEDecoration().
| void SvgTextCursor::copy | ( | ) | const |
copy copies plain text into the clipboard between anchor and pos.
Definition at line 391 of file SvgTextCursor.cpp.
References KoSvgTextShapeMarkupConverter::convertToHtml(), KoSvgTextShapeMarkupConverter::convertToSvg(), d, and length().
| QPair< KoSvgTextProperties, KoSvgTextProperties > SvgTextCursor::currentTextProperties | ( | ) | const |
currentTextProperties
Definition at line 338 of file SvgTextCursor.cpp.
References d.
| void SvgTextCursor::deselectText | ( | ) |
Definition at line 475 of file SvgTextCursor.cpp.
| void SvgTextCursor::focusIn | ( | ) |
Turns on blinking cursor.
Definition at line 1236 of file SvgTextCursor.cpp.
References blinkCursor(), and d.
| void SvgTextCursor::focusOut | ( | ) |
Stops blinking cursor.
Definition at line 1244 of file SvgTextCursor.cpp.
References stopBlinkCursor().
| int SvgTextCursor::getAnchor | ( | ) |
Get the current selection anchor. This is the same as position, unless there's a selection.
Definition at line 216 of file SvgTextCursor.cpp.
References d.
| int SvgTextCursor::getPos | ( | ) |
|
overridevirtual |
return true if the tool currently has something selected that can be copied or deleted.
Reimplemented from KoToolSelection.
Definition at line 967 of file SvgTextCursor.cpp.
References d.
| void SvgTextCursor::inputMethodEvent | ( | QInputMethodEvent * | event | ) |
Definition at line 640 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), d, dbgTools, insertText(), IMEDecorationInfo::length, removeSelectionImpl(), IMEDecorationInfo::setDecorationFromQTextCharFormat(), IMEDecorationInfo::start, styleMap, updateCursor(), updateIMEDecoration(), and updateSelection().
| QVariant SvgTextCursor::inputMethodQuery | ( | Qt::InputMethodQuery | query | ) | const |
Definition at line 523 of file SvgTextCursor.cpp.
| void SvgTextCursor::insertRichText | ( | KoSvgTextShape * | insert | ) |
Insert rich text at getPos();.
Definition at line 286 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), KoShape::anchor(), d, hasSelection(), and removeSelectionImpl().
| void SvgTextCursor::insertText | ( | QString | text | ) |
Insert text at getPos()
Definition at line 270 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), d, hasSelection(), and removeSelectionImpl().
| bool SvgTextCursor::isAddingCommand | ( | ) | const |
the cursor is currently adding a command
| void SvgTextCursor::keyPressEvent | ( | QKeyEvent * | event | ) |
Handle the cursor-related key events.
Definition at line 996 of file SvgTextCursor.cpp.
References acceptableInput(), d, KoSvgTextProperties::DirectionId, KoSvgText::DirectionRightToLeft, insertText(), KIS_SAFE_ASSERT_RECOVER_RETURN, moveCursor(), MoveDown, MoveLeft, MoveLineEnd, MoveLineStart, MoveNextChar, MoveNextLine, MoveNone, MovePreviousChar, MovePreviousLine, MoveRight, MoveUp, MoveWordEnd, MoveWordStart, ParagraphEnd, ParagraphStart, KoSvgTextProperties::propertyOrDefault(), removeLastCodePoint(), removeText(), KoSvgText::VerticalRL, and KoSvgTextProperties::WritingModeId.
| void SvgTextCursor::mergePropertiesIntoSelection | ( | const KoSvgTextProperties | props, |
| const QSet< KoSvgTextProperties::PropertyId > | removeProperties = QSet<KoSvgTextProperties::PropertyId>() ) |
Definition at line 358 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), d, and hasSelection().
Move the cursor, and, if you don't want a selection, move the anchor.
Definition at line 255 of file SvgTextCursor.cpp.
References d, moveModeResult(), updateCursor(), and updateSelection().
|
private |
Definition at line 1356 of file SvgTextCursor.cpp.
References d, MoveDown, MoveLeft, MoveLineEnd, MoveLineStart, MoveNextChar, MoveNextLine, MoveNone, MovePreviousChar, MovePreviousLine, MoveRight, MoveUp, MoveWordEnd, MoveWordLeft, MoveWordRight, MoveWordStart, ParagraphEnd, ParagraphStart, and pos.
|
overridevirtual |
TextCursorChangeListener reimplementation, this allows undo commands to update the cursor without having the cursor owned by the command.
Implements KoSvgTextShape::TextCursorChangeListener.
Definition at line 983 of file SvgTextCursor.cpp.
References anchor, d, pos, updateCursor(), and updateSelection().
|
overridevirtual |
Implements KoSvgTextShape::TextCursorChangeListener.
Definition at line 991 of file SvgTextCursor.cpp.
References d.
|
overridevirtual |
ShapeChangeListener reimplementation. This will update the cursor position when the shape was updated.
Implements KoShape::ShapeChangeListener.
Definition at line 972 of file SvgTextCursor.cpp.
References d, shape, updateCursor(), updateInputMethodItemTransform(), and updateSelection().
| void SvgTextCursor::paintDecorations | ( | QPainter & | gc, |
| QColor | selectionColor, | ||
| int | decorationThickness = 1 ) |
Definition at line 485 of file SvgTextCursor.cpp.
References bgColorForCaret(), and d.
| bool SvgTextCursor::paste | ( | ) |
paste pastes plain text in the clipboard at pos. Uses pasteRichTextByDefault to determine whether to try and paste rich text.
Definition at line 421 of file SvgTextCursor.cpp.
References d, pastePlainText(), and pasteRichText.
|
privateslot |
pastePlainText Explicitely paste plaintext at pos.
Definition at line 463 of file SvgTextCursor.cpp.
References insertText().
|
privateslot |
pasteRichText
| QList< KoSvgTextProperties > SvgTextCursor::propertiesForRange | ( | ) | const |
Definition at line 346 of file SvgTextCursor.cpp.
References d.
|
privateslot |
Definition at line 956 of file SvgTextCursor.cpp.
References d, SvgTextShortCuts::getModifiedProperties(), KoSvgTextProperties::isEmpty(), mergePropertiesIntoSelection(), and p.
| bool SvgTextCursor::registerPropertyAction | ( | QAction * | action, |
| const QString & | name ) |
Register an action.
Definition at line 1249 of file SvgTextCursor.cpp.
References SvgTextShortCuts::configureAction(), connect(), d, pastePlainText(), pasteRichText, propertyAction(), and sigOpenGlyphPalette().
| void SvgTextCursor::removeLastCodePoint | ( | ) |
Definition at line 323 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), d, hasSelection(), and removeSelectionImpl().
| void SvgTextCursor::removeSelection | ( | ) |
removeSelection if there's a selection, creates a text-removal command.
| parent |
Definition at line 372 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), and removeSelectionImpl().
|
private |
removeSelection if there's a selection, creates a text-removal command.
| parent |
Definition at line 378 of file SvgTextCursor.cpp.
| void SvgTextCursor::removeText | ( | SvgTextCursor::MoveMode | first, |
| SvgTextCursor::MoveMode | second ) |
removeText remove text relative to the current position. This will move the cursor according to the move modes and then remove the text between the two positions.
| first | how the cursor should move to get to the start position. |
| second | how the cursor should move to get to the end position. |
Definition at line 301 of file SvgTextCursor.cpp.
References addCommandToUndoAdapter(), d, hasSelection(), length(), moveModeResult(), and removeSelectionImpl().
|
signal |
| void SvgTextCursor::setCaretSetting | ( | int | cursorWidth = 1, |
| int | cursorFlash = 1000, | ||
| int | cursorFlashLimit = 5000 ) |
setCaretSetting Set the caret settings for the cursor. Qt has some standard functionality associated, which we pass via this.
| cursorWidth | - Cursor width from the style. |
| cursorFlash | - the total time it takes for a cursor to hide reapear. |
| cursorFlashLimit | - maximum amount of time a cursor is allowed to flash. |
Definition at line 192 of file SvgTextCursor.cpp.
References blinkCursor(), connect(), cursorFlash, cursorFlashLimit, cursorWidth, d, and stopBlinkCursor().
| void SvgTextCursor::setPasteRichTextByDefault | ( | const bool | pasteRichText = true | ) |
setPasteRichText
| pasteRichText | – whether to paste rich text when possible. |
Definition at line 206 of file SvgTextCursor.cpp.
References d, and pasteRichText.
| void SvgTextCursor::setPos | ( | int | pos, |
| int | anchor ) |
Set the pos and the anchor.
Definition at line 221 of file SvgTextCursor.cpp.
References anchor, d, pos, updateCursor(), and updateSelection().
| void SvgTextCursor::setPosToPoint | ( | QPointF | point, |
| bool | moveAnchor = true ) |
Set the pos from a point. This currently does a search inside the text shape.
Definition at line 229 of file SvgTextCursor.cpp.
References commitIMEPreEdit(), d, pos, posIndex, updateCursor(), and updateSelection().
| void SvgTextCursor::setShape | ( | KoSvgTextShape * | textShape | ) |
setShape
| textShape | KoSvgTextShape to set, is allowed to be a nullptr, the cursor just won't do anything. |
Definition at line 173 of file SvgTextCursor.cpp.
References KoShape::addShapeChangeListener(), commitIMEPreEdit(), d, updateCursor(), updateInputMethodItemTransform(), and updateSelection().
| void SvgTextCursor::setVisualMode | ( | const bool | visualMode = true | ) |
setVisualMode set whether the navigation mode is visual or logical. This right now primarily affects Bidirectional text.
| mode | whether to turn off visual mode. |
Definition at line 201 of file SvgTextCursor.cpp.
References d.
| KoSvgTextShape * SvgTextCursor::shape | ( | ) | const |
Get the current text shape.
|
signal |
|
privateslot |
Definition at line 852 of file SvgTextCursor.cpp.
References d, and updateCursorDecoration().
| KoSvgTextPropertiesInterface * SvgTextCursor::textPropertyInterface | ( | ) |
Definition at line 1271 of file SvgTextCursor.cpp.
References d.
|
privateslot |
Definition at line 915 of file SvgTextCursor.cpp.
References d, KoSvgText::DecorationUnderline, KoSvgTextProperties::FontStyleId, KoSvgTextProperties::FontWeightId, mergePropertiesIntoSelection(), p, KoSvgTextProperties::setProperty(), KoSvgText::CssFontStyleData::style, KoSvgTextProperties::TextDecorationLineId, and value().
|
private |
Definition at line 1475 of file SvgTextCursor.cpp.
References SvgTextShortCuts::actionEnabled(), KoSvgTextProperties::background(), KoColorBackground::color(), KoShapeStroke::color, d, KoColor::fromQColor(), hasSelection(), KoColor::setOpacity(), and KoSvgTextProperties::stroke().
|
private |
update the cursor shape. First update will block ensuring the canvas is visible so setShape won't cause this.
Definition at line 1276 of file SvgTextCursor.cpp.
References blinkCursor(), d, selectionChanged(), and updateCanvasResources().
|
signal |
|
private |
Definition at line 1318 of file SvgTextCursor.cpp.
References d, IMEDecorationInfo::decor, KoSvgText::DecorationUnderline, IMEDecorationInfo::length, IMEDecorationInfo::start, IMEDecorationInfo::style, IMEDecorationInfo::thick, and updateCursorDecoration().
|
privateslot |
Definition at line 862 of file SvgTextCursor.cpp.
|
private |
Definition at line 1308 of file SvgTextCursor.cpp.
References d, and updateCursorDecoration().
| QList<QAction*> SvgTextCursor::actions |
Definition at line 144 of file SvgTextCursor.cpp.
| int SvgTextCursor::anchor = 0 |
Definition at line 110 of file SvgTextCursor.cpp.
| QLineF SvgTextCursor::anchorCaret |
Definition at line 121 of file SvgTextCursor.cpp.
| int SvgTextCursor::anchorIndex = 0 |
Definition at line 129 of file SvgTextCursor.cpp.
| bool SvgTextCursor::blockQueryUpdates = false |
Block qApp->inputMethod->update(), enabled during the inputmethod event flow.
Definition at line 140 of file SvgTextCursor.cpp.
| KoCanvasBase* SvgTextCursor::canvas |
Definition at line 107 of file SvgTextCursor.cpp.
| QLineF SvgTextCursor::cursorCaret |
Definition at line 120 of file SvgTextCursor.cpp.
| QColor SvgTextCursor::cursorColor |
Definition at line 118 of file SvgTextCursor.cpp.
| QTimer SvgTextCursor::cursorFlash |
Definition at line 113 of file SvgTextCursor.cpp.
| QTimer SvgTextCursor::cursorFlashLimit |
Definition at line 114 of file SvgTextCursor.cpp.
| QPainterPath SvgTextCursor::cursorShape |
Definition at line 117 of file SvgTextCursor.cpp.
| bool SvgTextCursor::cursorVisible = false |
Definition at line 115 of file SvgTextCursor.cpp.
| int SvgTextCursor::cursorWidth = 1 |
Definition at line 122 of file SvgTextCursor.cpp.
|
private |
Definition at line 262 of file SvgTextCursor.h.
| QPainterPath SvgTextCursor::IMEDecoration |
The decorations for the current preedit string.
Definition at line 138 of file SvgTextCursor.cpp.
| SvgTextCursorPropertyInterface* SvgTextCursor::interface {nullptr} |
Definition at line 142 of file SvgTextCursor.cpp.
| bool SvgTextCursor::isAddingCommand = false |
Definition at line 108 of file SvgTextCursor.cpp.
| QRectF SvgTextCursor::oldCursorRect |
Definition at line 119 of file SvgTextCursor.cpp.
| QRectF SvgTextCursor::oldIMEDecorationRect |
Update Rectangle of previous decoration.
Definition at line 139 of file SvgTextCursor.cpp.
| QRectF SvgTextCursor::oldSelectionRect |
Definition at line 124 of file SvgTextCursor.cpp.
| bool SvgTextCursor::pasteRichText = true |
Definition at line 132 of file SvgTextCursor.cpp.
| int SvgTextCursor::pos = 0 |
Definition at line 109 of file SvgTextCursor.cpp.
| int SvgTextCursor::posIndex = 0 |
Definition at line 128 of file SvgTextCursor.cpp.
| SvgTextInsertCommand* SvgTextCursor::preEditCommand {nullptr} |
PreEdit string as an command provided by the input method.
Definition at line 134 of file SvgTextCursor.cpp.
| int SvgTextCursor::preEditLength = -1 |
Length of the preEditString.
Definition at line 136 of file SvgTextCursor.cpp.
| int SvgTextCursor::preEditStart = -1 |
Start of the preEdit string as a cursor pos.
Definition at line 135 of file SvgTextCursor.cpp.
| QPainterPath SvgTextCursor::selection |
Definition at line 123 of file SvgTextCursor.cpp.
| KoSvgTextShape * SvgTextCursor::shape {nullptr} |
Definition at line 111 of file SvgTextCursor.cpp.
| QVector<IMEDecorationInfo> SvgTextCursor::styleMap |
Decoration info (underlines) for the preEdit string to differentiate it from regular text.
Definition at line 137 of file SvgTextCursor.cpp.
| bool SvgTextCursor::visualNavigation = true |
Definition at line 131 of file SvgTextCursor.cpp.