Changeset View
Changeset View
Standalone View
Standalone View
plugins/artistictextshape/ArtisticTextTool.cpp
Show All 37 Lines | |||||
38 | #include <KoShapeManager.h> | 38 | #include <KoShapeManager.h> | ||
39 | #include <KoPointerEvent.h> | 39 | #include <KoPointerEvent.h> | ||
40 | #include <KoPathShape.h> | 40 | #include <KoPathShape.h> | ||
41 | #include <KoShapeBackground.h> | 41 | #include <KoShapeBackground.h> | ||
42 | #include <KoShapeController.h> | 42 | #include <KoShapeController.h> | ||
43 | #include <KoShapeContainer.h> | 43 | #include <KoShapeContainer.h> | ||
44 | #include <KoInteractionStrategy.h> | 44 | #include <KoInteractionStrategy.h> | ||
45 | #include <KoIcon.h> | 45 | #include <KoIcon.h> | ||
46 | #include "kis_action_registry.h" | ||||
46 | 47 | | |||
47 | #include <klocalizedstring.h> | 48 | #include <klocalizedstring.h> | ||
48 | #include <kstandardaction.h> | 49 | #include <kstandardaction.h> | ||
49 | #include <QAction> | 50 | #include <QAction> | ||
50 | #include <QDebug> | 51 | #include <QDebug> | ||
51 | 52 | | |||
52 | #include <QAction> | 53 | #include <QAction> | ||
53 | #include <QGridLayout> | 54 | #include <QGridLayout> | ||
54 | #include <QToolButton> | 55 | #include <QToolButton> | ||
55 | #include <QCheckBox> | 56 | #include <QCheckBox> | ||
56 | #include <QPainter> | 57 | #include <QPainter> | ||
57 | #include <QPainterPath> | 58 | #include <QPainterPath> | ||
58 | #include <kundo2command.h> | 59 | #include <kundo2command.h> | ||
59 | 60 | | |||
60 | #include <float.h> | 61 | #include <float.h> | ||
61 | #include <math.h> | 62 | #include <math.h> | ||
62 | 63 | | |||
63 | const int BlinkInterval = 500; | 64 | const int BlinkInterval = 500; | ||
64 | 65 | | |||
65 | ArtisticTextTool::ArtisticTextTool(KoCanvasBase *canvas) | 66 | ArtisticTextTool::ArtisticTextTool(KoCanvasBase *canvas) | ||
66 | : KoToolBase(canvas), m_selection(canvas, this), m_currentShape(0), m_hoverText(0), m_hoverPath(0), m_hoverHandle(false) | 67 | : KoToolBase(canvas), m_selection(canvas, this), m_currentShape(0), m_hoverText(0), m_hoverPath(0), m_hoverHandle(false) | ||
67 | , m_textCursor( -1 ), m_showCursor( true ), m_currentStrategy(0) | 68 | , m_textCursor( -1 ), m_showCursor( true ), m_currentStrategy(0) | ||
68 | { | 69 | { | ||
69 | m_detachPath = new QAction(koIcon("artistictext-detach-path"), i18n("Detach Path"), this); | 70 | KisActionRegistry *ar = KisActionRegistry::instance(); | ||
71 | m_detachPath = ar->makeQAction("artistictext_detach_from_path", this, "Artistic Text Tool"); | ||||
70 | m_detachPath->setEnabled( false ); | 72 | m_detachPath->setEnabled( false ); | ||
71 | connect( m_detachPath, SIGNAL(triggered()), this, SLOT(detachPath()) ); | 73 | connect( m_detachPath, SIGNAL(triggered()), this, SLOT(detachPath()) ); | ||
72 | addAction("artistictext_detach_from_path", m_detachPath); | 74 | addAction("artistictext_detach_from_path", m_detachPath); | ||
73 | 75 | | |||
74 | m_convertText = new QAction(koIcon("pathshape"), i18n("Convert to Path"), this); | 76 | m_convertText = ar->makeQAction("artistictext_convert_to_path", this, "Artistic Text Tool"); | ||
75 | m_convertText->setEnabled( false ); | 77 | m_convertText->setEnabled( false ); | ||
76 | connect( m_convertText, SIGNAL(triggered()), this, SLOT(convertText()) ); | 78 | connect( m_convertText, SIGNAL(triggered()), this, SLOT(convertText()) ); | ||
77 | addAction("artistictext_convert_to_path", m_convertText); | 79 | addAction("artistictext_convert_to_path", m_convertText); | ||
78 | 80 | | |||
79 | m_fontBold = new QAction(koIcon("format-text-bold"), i18n("Bold text"), this); | 81 | m_fontBold = ar->makeQAction("artistictext_font_bold", this, "Artistic Text Tool"); | ||
80 | m_fontBold->setCheckable(true); | | |||
81 | connect(m_fontBold, SIGNAL(toggled(bool)), this, SLOT(toggleFontBold(bool))); | 82 | connect(m_fontBold, SIGNAL(toggled(bool)), this, SLOT(toggleFontBold(bool))); | ||
82 | addAction("artistictext_font_bold", m_fontBold); | 83 | addAction("artistictext_font_bold", m_fontBold); | ||
83 | 84 | | |||
84 | m_fontItalic = new QAction(koIcon("format-text-italic"), i18n("Italic text"), this); | 85 | m_fontItalic = ar->makeQAction("artistictext_font_italic", this, "Artistic Text Tool"); | ||
85 | m_fontItalic->setCheckable(true); | | |||
86 | connect(m_fontItalic, SIGNAL(toggled(bool)), this, SLOT(toggleFontItalic(bool))); | 86 | connect(m_fontItalic, SIGNAL(toggled(bool)), this, SLOT(toggleFontItalic(bool))); | ||
87 | addAction("artistictext_font_italic", m_fontItalic); | 87 | addAction("artistictext_font_italic", m_fontItalic); | ||
88 | 88 | | |||
89 | m_superScript = new QAction(koIcon("format-text-superscript"), i18n("Superscript"), this); | 89 | m_superScript = ar->makeQAction("artistictext_superscript", this, "Artistic Text Tool"); | ||
90 | m_superScript->setCheckable(true); | | |||
91 | connect(m_superScript, SIGNAL(triggered()), this, SLOT(setSuperScript())); | 90 | connect(m_superScript, SIGNAL(triggered()), this, SLOT(setSuperScript())); | ||
92 | addAction("artistictext_superscript", m_superScript); | 91 | addAction("artistictext_superscript", m_superScript); | ||
93 | 92 | | |||
94 | m_subScript = new QAction(koIcon("format-text-subscript"), i18n("Subscript"), this); | 93 | m_subScript = ar->makeQAction("artistictext_subscript", this, "Artistic Text Tool"); | ||
95 | m_subScript->setCheckable(true); | | |||
96 | connect(m_subScript, SIGNAL(triggered()), this, SLOT(setSubScript())); | 94 | connect(m_subScript, SIGNAL(triggered()), this, SLOT(setSubScript())); | ||
97 | addAction("artistictext_subscript", m_subScript); | 95 | addAction("artistictext_subscript", m_subScript); | ||
98 | 96 | | |||
99 | QAction *anchorStart = new QAction(koIcon("format-justify-left"), i18n("Anchor at Start"), this); | 97 | QAction *anchorStart = ar->makeQAction("artistictext_anchor_start", this, "Artistic Text Tool"); | ||
100 | anchorStart->setCheckable( true ); | | |||
101 | anchorStart->setData(ArtisticTextShape::AnchorStart); | 98 | anchorStart->setData(ArtisticTextShape::AnchorStart); | ||
102 | addAction("artistictext_anchor_start", anchorStart); | 99 | addAction("artistictext_anchor_start", anchorStart); | ||
103 | 100 | | |||
104 | QAction *anchorMiddle = new QAction(koIcon("format-justify-center"), i18n("Anchor at Middle"), this); | 101 | QAction *anchorMiddle = ar->makeQAction("artistictext_anchor_middle", this, "Artistic Text Tool"); | ||
105 | anchorMiddle->setCheckable( true ); | | |||
106 | anchorMiddle->setData(ArtisticTextShape::AnchorMiddle); | 102 | anchorMiddle->setData(ArtisticTextShape::AnchorMiddle); | ||
107 | addAction("artistictext_anchor_middle", anchorMiddle); | 103 | addAction("artistictext_anchor_middle", anchorMiddle); | ||
108 | 104 | | |||
109 | QAction *anchorEnd = new QAction(koIcon("format-justify-right"), i18n("Anchor at End"), this); | 105 | QAction *anchorEnd = ar->makeQAction("artistictext_anchor_end", this, "Artistic Text Tool"); | ||
110 | anchorEnd->setCheckable( true ); | | |||
111 | anchorEnd->setData(ArtisticTextShape::AnchorEnd); | 106 | anchorEnd->setData(ArtisticTextShape::AnchorEnd); | ||
112 | addAction("artistictext_anchor_end", anchorEnd); | 107 | addAction("artistictext_anchor_end", anchorEnd); | ||
113 | 108 | | |||
114 | m_anchorGroup = new QActionGroup(this); | 109 | m_anchorGroup = new QActionGroup(this); | ||
115 | m_anchorGroup->setExclusive(true); | 110 | m_anchorGroup->setExclusive(true); | ||
116 | m_anchorGroup->addAction(anchorStart); | 111 | m_anchorGroup->addAction(anchorStart); | ||
117 | m_anchorGroup->addAction(anchorMiddle); | 112 | m_anchorGroup->addAction(anchorMiddle); | ||
118 | m_anchorGroup->addAction(anchorEnd); | 113 | m_anchorGroup->addAction(anchorEnd); | ||
▲ Show 20 Lines • Show All 836 Lines • Show Last 20 Lines |