Changeset View
Changeset View
Standalone View
Standalone View
libs/flake/tools/KoPathTool.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | #include "KoPathPointRubberSelectStrategy.h" | 44 | #include "KoPathPointRubberSelectStrategy.h" | ||
45 | #include "KoPathSegmentChangeStrategy.h" | 45 | #include "KoPathSegmentChangeStrategy.h" | ||
46 | #include "KoPathConnectionPointStrategy.h" | 46 | #include "KoPathConnectionPointStrategy.h" | ||
47 | #include "KoParameterChangeStrategy.h" | 47 | #include "KoParameterChangeStrategy.h" | ||
48 | #include "PathToolOptionWidget.h" | 48 | #include "PathToolOptionWidget.h" | ||
49 | #include "KoConnectionShape.h" | 49 | #include "KoConnectionShape.h" | ||
50 | #include "KoSnapGuide.h" | 50 | #include "KoSnapGuide.h" | ||
51 | #include "KoShapeController.h" | 51 | #include "KoShapeController.h" | ||
52 | #include "kis_action_registry.h" | ||||
52 | 53 | | |||
53 | #include <KoIcon.h> | 54 | #include <KoIcon.h> | ||
54 | 55 | | |||
55 | #include <QAction> | 56 | #include <QAction> | ||
56 | #include <FlakeDebug.h> | 57 | #include <FlakeDebug.h> | ||
57 | #include <klocalizedstring.h> | 58 | #include <klocalizedstring.h> | ||
58 | #include <QPainter> | 59 | #include <QPainter> | ||
59 | #include <QBitmap> | 60 | #include <QBitmap> | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 100 | KoPathTool::KoPathTool(KoCanvasBase *canvas) | |||
101 | , m_pointSelection(this) | 102 | , m_pointSelection(this) | ||
102 | , m_activeHandle(0) | 103 | , m_activeHandle(0) | ||
103 | , m_handleRadius(3) | 104 | , m_handleRadius(3) | ||
104 | , m_activeSegment(0) | 105 | , m_activeSegment(0) | ||
105 | , m_currentStrategy(0) | 106 | , m_currentStrategy(0) | ||
106 | { | 107 | { | ||
107 | QActionGroup *points = new QActionGroup(this); | 108 | QActionGroup *points = new QActionGroup(this); | ||
108 | // m_pointTypeGroup->setExclusive(true); | 109 | // m_pointTypeGroup->setExclusive(true); | ||
109 | m_actionPathPointCorner = new QAction(koIcon("pathpoint-corner"), i18n("Corner point"), this); | 110 | KisActionRegistry *actionRegistry = KisActionRegistry::instance(); | ||
111 | m_actionPathPointCorner = actionRegistry->makeQAction("pathpoint-corner", this); | ||||
110 | addAction("pathpoint-corner", m_actionPathPointCorner); | 112 | addAction("pathpoint-corner", m_actionPathPointCorner); | ||
111 | m_actionPathPointCorner->setData(KoPathPointTypeCommand::Corner); | 113 | m_actionPathPointCorner->setData(KoPathPointTypeCommand::Corner); | ||
112 | points->addAction(m_actionPathPointCorner); | 114 | points->addAction(m_actionPathPointCorner); | ||
113 | 115 | | |||
114 | m_actionPathPointSmooth = new QAction(koIcon("pathpoint-smooth"), i18n("Smooth point"), this); | 116 | m_actionPathPointSmooth = actionRegistry->makeQAction("pathpoint-smooth", this); | ||
115 | addAction("pathpoint-smooth", m_actionPathPointSmooth); | 117 | addAction("pathpoint-smooth", m_actionPathPointSmooth); | ||
116 | m_actionPathPointSmooth->setData(KoPathPointTypeCommand::Smooth); | 118 | m_actionPathPointSmooth->setData(KoPathPointTypeCommand::Smooth); | ||
117 | points->addAction(m_actionPathPointSmooth); | 119 | points->addAction(m_actionPathPointSmooth); | ||
118 | 120 | | |||
119 | m_actionPathPointSymmetric = new QAction(koIcon("pathpoint-symmetric"), i18n("Symmetric Point"), this); | 121 | m_actionPathPointSymmetric = actionRegistry->makeQAction("pathpoint-symmetric", this); | ||
120 | addAction("pathpoint-symmetric", m_actionPathPointSymmetric); | 122 | addAction("pathpoint-symmetric", m_actionPathPointSymmetric); | ||
121 | m_actionPathPointSymmetric->setData(KoPathPointTypeCommand::Symmetric); | 123 | m_actionPathPointSymmetric->setData(KoPathPointTypeCommand::Symmetric); | ||
122 | points->addAction(m_actionPathPointSymmetric); | 124 | points->addAction(m_actionPathPointSymmetric); | ||
123 | 125 | | |||
124 | m_actionCurvePoint = new QAction(koIcon("pathpoint-curve"), i18n("Make curve point"), this); | 126 | m_actionCurvePoint = actionRegistry->makeQAction("pathpoint-curve", this); | ||
125 | addAction("pathpoint-curve", m_actionCurvePoint); | 127 | addAction("pathpoint-curve", m_actionCurvePoint); | ||
126 | connect(m_actionCurvePoint, SIGNAL(triggered()), this, SLOT(pointToCurve())); | 128 | connect(m_actionCurvePoint, SIGNAL(triggered()), this, SLOT(pointToCurve())); | ||
127 | 129 | | |||
128 | m_actionLinePoint = new QAction(koIcon("pathpoint-line"), i18n("Make line point"), this); | 130 | m_actionLinePoint = actionRegistry->makeQAction("pathpoint-line", this); | ||
129 | addAction("pathpoint-line", m_actionLinePoint); | 131 | addAction("pathpoint-line", m_actionLinePoint); | ||
130 | connect(m_actionLinePoint, SIGNAL(triggered()), this, SLOT(pointToLine())); | 132 | connect(m_actionLinePoint, SIGNAL(triggered()), this, SLOT(pointToLine())); | ||
131 | 133 | | |||
132 | m_actionLineSegment = new QAction(koIcon("pathsegment-line"), i18n("Segment to Line"), this); | 134 | m_actionLineSegment = actionRegistry->makeQAction("pathsegment-line", this); | ||
133 | m_actionLineSegment->setShortcut(Qt::Key_F); | | |||
134 | addAction("pathsegment-line", m_actionLineSegment); | 135 | addAction("pathsegment-line", m_actionLineSegment); | ||
135 | connect(m_actionLineSegment, SIGNAL(triggered()), this, SLOT(segmentToLine())); | 136 | connect(m_actionLineSegment, SIGNAL(triggered()), this, SLOT(segmentToLine())); | ||
136 | 137 | | |||
137 | m_actionCurveSegment = new QAction(koIcon("pathsegment-curve"), i18n("Segment to Curve"), this); | 138 | m_actionCurveSegment = actionRegistry->makeQAction("pathsegment-curve", this); | ||
138 | m_actionCurveSegment->setShortcut(Qt::Key_C); | | |||
139 | addAction("pathsegment-curve", m_actionCurveSegment); | 139 | addAction("pathsegment-curve", m_actionCurveSegment); | ||
140 | connect(m_actionCurveSegment, SIGNAL(triggered()), this, SLOT(segmentToCurve())); | 140 | connect(m_actionCurveSegment, SIGNAL(triggered()), this, SLOT(segmentToCurve())); | ||
141 | 141 | | |||
142 | m_actionAddPoint = new QAction(koIcon("pathpoint-insert"), i18n("Insert point"), this); | 142 | m_actionAddPoint = actionRegistry->makeQAction("pathpoint-insert", this); | ||
143 | m_actionAddPoint->setShortcut(Qt::Key_Insert); | | |||
144 | addAction("pathpoint-insert", m_actionAddPoint); | 143 | addAction("pathpoint-insert", m_actionAddPoint); | ||
145 | connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints())); | 144 | connect(m_actionAddPoint, SIGNAL(triggered()), this, SLOT(insertPoints())); | ||
146 | 145 | | |||
147 | m_actionRemovePoint = new QAction(koIcon("pathpoint-remove"), i18n("Remove point"), this); | 146 | m_actionRemovePoint = actionRegistry->makeQAction("pathpoint-remove", this); | ||
148 | m_actionRemovePoint->setShortcut(Qt::Key_Backspace); | | |||
149 | addAction("pathpoint-remove", m_actionRemovePoint); | 147 | addAction("pathpoint-remove", m_actionRemovePoint); | ||
150 | connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints())); | 148 | connect(m_actionRemovePoint, SIGNAL(triggered()), this, SLOT(removePoints())); | ||
151 | 149 | | |||
152 | m_actionBreakPoint = new QAction(koIcon("path-break-point"), i18n("Break at point"), this); | 150 | m_actionBreakPoint = actionRegistry->makeQAction("path-break-point", this); | ||
153 | addAction("path-break-point", m_actionBreakPoint); | 151 | addAction("path-break-point", m_actionBreakPoint); | ||
154 | connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint())); | 152 | connect(m_actionBreakPoint, SIGNAL(triggered()), this, SLOT(breakAtPoint())); | ||
155 | 153 | | |||
156 | m_actionBreakSegment = new QAction(koIcon("path-break-segment"), i18n("Break at segment"), this); | 154 | m_actionBreakSegment = actionRegistry->makeQAction("path-break-segment", this); | ||
157 | addAction("path-break-segment", m_actionBreakSegment); | 155 | addAction("path-break-segment", m_actionBreakSegment); | ||
158 | connect(m_actionBreakSegment, SIGNAL(triggered()), this, SLOT(breakAtSegment())); | 156 | connect(m_actionBreakSegment, SIGNAL(triggered()), this, SLOT(breakAtSegment())); | ||
159 | 157 | | |||
160 | m_actionJoinSegment = new QAction(koIcon("pathpoint-join"), i18n("Join with segment"), this); | 158 | m_actionJoinSegment = actionRegistry->makeQAction("pathpoint-join", this); | ||
161 | m_actionJoinSegment->setShortcut(Qt::Key_J); | | |||
162 | addAction("pathpoint-join", m_actionJoinSegment); | 159 | addAction("pathpoint-join", m_actionJoinSegment); | ||
163 | connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints())); | 160 | connect(m_actionJoinSegment, SIGNAL(triggered()), this, SLOT(joinPoints())); | ||
164 | 161 | | |||
165 | m_actionMergePoints = new QAction(koIcon("pathpoint-merge"), i18n("Merge points"), this); | 162 | m_actionMergePoints = actionRegistry->makeQAction("pathpoint-merge", this); | ||
166 | addAction("pathpoint-merge", m_actionMergePoints); | 163 | addAction("pathpoint-merge", m_actionMergePoints); | ||
167 | connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints())); | 164 | connect(m_actionMergePoints, SIGNAL(triggered()), this, SLOT(mergePoints())); | ||
168 | 165 | | |||
169 | m_actionConvertToPath = new QAction(koIcon("convert-to-path"), i18n("To Path"), this); | 166 | m_actionConvertToPath = actionRegistry->makeQAction("convert-to-path", this); | ||
170 | m_actionConvertToPath->setShortcut(Qt::Key_P); | | |||
171 | addAction("convert-to-path", m_actionConvertToPath); | 167 | addAction("convert-to-path", m_actionConvertToPath); | ||
172 | connect(m_actionConvertToPath, SIGNAL(triggered()), this, SLOT(convertToPath())); | 168 | connect(m_actionConvertToPath, SIGNAL(triggered()), this, SLOT(convertToPath())); | ||
173 | 169 | | |||
170 | | ||||
174 | connect(points, SIGNAL(triggered(QAction*)), this, SLOT(pointTypeChanged(QAction*))); | 171 | connect(points, SIGNAL(triggered(QAction*)), this, SLOT(pointTypeChanged(QAction*))); | ||
175 | connect(&m_pointSelection, SIGNAL(selectionChanged()), this, SLOT(pointSelectionChanged())); | 172 | connect(&m_pointSelection, SIGNAL(selectionChanged()), this, SLOT(pointSelectionChanged())); | ||
176 | 173 | | |||
177 | QBitmap b = QBitmap::fromData(QSize(16, 16), needle_bits); | 174 | QBitmap b = QBitmap::fromData(QSize(16, 16), needle_bits); | ||
178 | QBitmap m = b.createHeuristicMask(false); | 175 | QBitmap m = b.createHeuristicMask(false); | ||
179 | 176 | | |||
180 | m_selectCursor = QCursor(b, m, 2, 0); | 177 | m_selectCursor = QCursor(b, m, 2, 0); | ||
181 | 178 | | |||
▲ Show 20 Lines • Show All 787 Lines • Show Last 20 Lines |