Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextTool.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 SPDX-FileCopyrightText: 2017 Boudewijn Rempt <boud@valdyas.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef SVG_TEXT_TOOL
9#define SVG_TEXT_TOOL
10
11
12#include <KConfigGroup>
13#include <KoToolBase.h>
14#include <QPointer>
15
17#include <KisSignalMapper.h>
18
19#include "SvgTextCursor.h"
22
23#include <memory>
24
25class KoSelection;
26class SvgTextEditor;
27class KoSvgTextShape;
28class SvgTextCursor;
30class KUndo2Command;
31
32class SvgTextTool : public KoToolBase
33{
34 Q_OBJECT
35
37
38public:
40 ~SvgTextTool() override;
42 QRectF decorationsRect() const override;
44 void paint(QPainter &gc, const KoViewConverter &converter) override;
46 void mousePressEvent(KoPointerEvent *event) override;
48 void mouseDoubleClickEvent(KoPointerEvent *event) override;
50 void mouseTripleClickEvent(KoPointerEvent *event) override;
52 void mouseMoveEvent(KoPointerEvent *event) override;
54 void mouseReleaseEvent(KoPointerEvent *event) override;
55
56 void keyPressEvent(QKeyEvent *event) override;
57 void keyReleaseEvent(QKeyEvent *event) override;
58
59 void focusInEvent(QFocusEvent *event) override;
60 void focusOutEvent(QFocusEvent *event) override;
61
63 void activate(const QSet<KoShape *> &shapes) override;
65 void deactivate() override;
66
68
69 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
70 void inputMethodEvent(QInputMethodEvent *event) override;
71
73 void copy() const override;
75 void deleteSelection() override;
77 bool paste() override;
79 bool hasSelection() override;
80
81 bool selectAll() override;
82
83 void deselect() override;
85 KoToolSelection * selection() override;
86
87 void requestStrokeEnd() override;
88 void requestStrokeCancellation() override;
89
90protected:
92 virtual QWidget *createOptionWidget() override;
93
94 KoSelection *koSelection() const;
96
97private:
98 qreal grabSensitivityInPt() const;
99
101
102private Q_SLOTS:
103
104 void showEditor();
106 void textUpdated(KoSvgTextShape *shape, const QString &svg, const QString &defs);
107
112 void showGlyphPalette();
117 void updateGlyphPalette();
124 void insertRichText(KoSvgTextShape *richText, bool replaceLastGlyph = false);
125
131 QString generateDefs(const KoSvgTextProperties &properties = KoSvgTextProperties());
132
138
144
150 void slotUpdateCursorDecoration(QRectF updateRect);
151
156 void slotConvertType(int index);
157
163
169
174 void slotTextTypeUpdated();
175
176private:
177 enum class DragMode {
178 None = 0,
179 Create,
180 Select,
182 Move,
183 };
184 enum class HighlightItem {
185 None = 0,
189 };
190
191 QScopedPointer<SvgTextToolOptionsManager>m_optionManager;
196 std::unique_ptr<KoInteractionStrategy> m_interactionStrategy;
199
200 QScopedPointer<KisSignalMapper> m_textTypeSignalsMapper;
201
202
205
207
216
217};
218
219#endif
The PopupWidgetInterface abstract class defines the basic interface that will be used by all popup wi...
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void activate(const QSet< KoShape * > &shapes) override
reimplemented from KoToolBase
void mouseTripleClickEvent(KoPointerEvent *event) override
reimplemented from KoToolBase
void copy() const override
reimplemented from superclass
bool selectAll() override
selectAll select all data the tool can select.
KisSignalAutoConnectionsStore m_canvasConnections
~SvgTextTool() override
void requestStrokeCancellation() override
void inputMethodEvent(QInputMethodEvent *event) override
QScopedPointer< KisSignalMapper > m_textTypeSignalsMapper
void mouseMoveEvent(KoPointerEvent *event) override
reimplemented from KoToolBase
std::unique_ptr< KoInteractionStrategy > m_interactionStrategy
void keyPressEvent(QKeyEvent *event) override
void requestStrokeEnd() override
void slotTextTypeUpdated()
slotTextTypeUpdated Update the text type in the tool options.
QPointer< GlyphPaletteDialog > m_glyphPalette
QScopedPointer< SvgTextToolOptionsManager > m_optionManager
QCursor m_base_cursor
KoSelection * koSelection() const
DragMode m_dragging
void mouseReleaseEvent(KoPointerEvent *event) override
reimplemented from KoToolBase
void slotUpdateVisualCursor()
slotUpdateVisualCursor update the visual cursor mode on the text cursor.
QString generateDefs(const KoSvgTextProperties &properties=KoSvgTextProperties())
generateDefs This generates a defs section with the appropriate css and css strings assigned.
qreal grabSensitivityInPt() const
void deleteSelection() override
reimplemented from superclass
QCursor m_text_inline_horizontal
QCursor m_ibeam_horizontal
KoSvgTextShape * selectedShape() const
QPointF m_lastMousePos
QCursor m_ibeam_horizontal_done
SvgTextTool(KoCanvasBase *canvas)
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
void slotShapeSelectionChanged()
selectionChanged called when the canvas selection is changed.
void showGlyphPalette()
showGlyphPalette Shows the glyph palette dialog.
void slotTextEditorClosed()
QCursor m_text_inline_vertical
QPainterPath m_hoveredShapeHighlightRect
void focusInEvent(QFocusEvent *event) override
bool hasSelection() override
reimplemented from superclass
KoSvgTextProperties propertiesForNewText() const
propertiesForNewText get the text properties that should be used for new text.
void updateGlyphPalette()
updateGlyphPalette update the glyph palette dialog from the current selection.
void mouseDoubleClickEvent(KoPointerEvent *event) override
reimplemented from superclass
bool m_strategyAddingCommand
KisPopupWidgetInterface * popupWidget() override
HighlightItem m_highlightItem
void focusOutEvent(QFocusEvent *event) override
KoToolSelection * selection() override
reimplemented from superclass
void slotUpdateTextPasteBehaviour()
slotUpdateTextPasteBehaviour update the default text paste behaviour.
void deselect() override
deselect the tool should clear the selection if it has one.
QCursor m_ibeam_vertical
virtual QWidget * createOptionWidget() override
reimplemented from KoToolBase
void insertRichText(KoSvgTextShape *richText, bool replaceLastGlyph=false)
insertRichText Insert a rich text shape, used by the glyph palette..
QCursor m_text_in_shape
void textUpdated(KoSvgTextShape *shape, const QString &svg, const QString &defs)
void deactivate() override
reimplemented from KoToolBase
void mousePressEvent(KoPointerEvent *event) override
reimplemented from KoToolBase
void slotUpdateCursorDecoration(QRectF updateRect)
updateCursor update the canvas decorations in a particular update rect for the text cursor.
QCursor m_text_on_path
void showEditor()
void paint(QPainter &gc, const KoViewConverter &converter) override
reimplemented from KoToolBase
SvgTextCursor m_textCursor
KoSvgText::WritingMode writingMode() const
QRectF decorationsRect() const override
reimplemented from KoToolBase
bool paste() override
reimplemented from superclass
void slotConvertType(int index)
slotConvertType
QPointer< SvgTextEditor > m_editor
void keyReleaseEvent(QKeyEvent *event) override
The SvgTextCursor class.