Changeset View
Changeset View
Standalone View
Standalone View
libs/flake/KoToolManager_p.cpp
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "KoToolManager_p.h" | 20 | #include "KoToolManager_p.h" | ||
21 | 21 | | |||
22 | #include <KoShapeManager.h> | 22 | #include <KoShapeManager.h> | ||
23 | #include <KoSelection.h> | 23 | #include <KoSelection.h> | ||
24 | #include <KoToolBase.h> | 24 | #include <KoToolBase.h> | ||
25 | #include <KoToolFactoryBase.h> | 25 | #include <KoToolFactoryBase.h> | ||
26 | 26 | #include "kis_action_registry.h" | |||
27 | 27 | | |||
28 | static int newUniqueToolHelperId() | 28 | static int newUniqueToolHelperId() | ||
29 | { | 29 | { | ||
30 | static int idCounter = 0; | 30 | static int idCounter = 0; | ||
31 | return ++idCounter; | 31 | return ++idCounter; | ||
32 | } | 32 | } | ||
33 | 33 | | |||
34 | /* ************ ToolHelper ********** | 34 | /* ************ ToolHelper ********** | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 122 | if (tool) { | |||
123 | tool->setToolId(id()); | 123 | tool->setToolId(id()); | ||
124 | } | 124 | } | ||
125 | return tool; | 125 | return tool; | ||
126 | } | 126 | } | ||
127 | 127 | | |||
128 | ShortcutToolAction* ToolHelper::createShortcutToolAction(QObject *parent) | 128 | ShortcutToolAction* ToolHelper::createShortcutToolAction(QObject *parent) | ||
129 | { | 129 | { | ||
130 | ShortcutToolAction* action = new ShortcutToolAction(id(), text(), parent); | 130 | ShortcutToolAction* action = new ShortcutToolAction(id(), text(), parent); | ||
131 | action->setShortcut(shortcut()); | 131 | | ||
132 | KisActionRegistry::instance()->propertizeAction(id(), action); | ||||
132 | 133 | | |||
133 | connect(action, SIGNAL(changed()), SLOT(shortcutToolActionUpdated())); | 134 | connect(action, SIGNAL(changed()), SLOT(shortcutToolActionUpdated())); | ||
134 | 135 | | |||
135 | return action; | 136 | return action; | ||
136 | } | 137 | } | ||
137 | 138 | | |||
138 | QString ToolHelper::toolType() const | 139 | QString ToolHelper::toolType() const | ||
139 | { | 140 | { | ||
Show All 9 Lines | |||||
149 | { | 150 | { | ||
150 | if (m_hasCustomShortcut) { | 151 | if (m_hasCustomShortcut) { | ||
151 | return m_customShortcut; | 152 | return m_customShortcut; | ||
152 | } | 153 | } | ||
153 | 154 | | |||
154 | return m_toolFactory->shortcut(); | 155 | return m_toolFactory->shortcut(); | ||
155 | } | 156 | } | ||
156 | 157 | | |||
158 | | ||||
159 | // ************ KoToolAction::Private ********** | ||||
160 | | ||||
161 | class Q_DECL_HIDDEN KoToolAction::Private | ||||
162 | { | ||||
163 | public: | ||||
164 | ToolHelper* toolHelper; | ||||
165 | }; | ||||
166 | | ||||
167 | KoToolAction::KoToolAction(ToolHelper* toolHelper) | ||||
168 | : QObject(toolHelper) | ||||
169 | , d(new Private) | ||||
170 | { | ||||
171 | d->toolHelper = toolHelper; | ||||
172 | } | ||||
173 | | ||||
174 | KoToolAction::~KoToolAction() | ||||
175 | { | ||||
176 | delete d; | ||||
177 | } | ||||
178 | | ||||
179 | void KoToolAction::trigger() | ||||
180 | { | ||||
181 | d->toolHelper->activate(); | ||||
182 | } | ||||
183 | | ||||
184 | | ||||
185 | QString KoToolAction::iconText() const | ||||
186 | { | ||||
187 | return d->toolHelper->iconText(); | ||||
188 | } | ||||
189 | | ||||
190 | QString KoToolAction::toolTip() const | ||||
191 | { | ||||
192 | return d->toolHelper->toolTip(); | ||||
193 | } | ||||
194 | | ||||
195 | QString KoToolAction::id() const | ||||
196 | { | ||||
197 | return d->toolHelper->id(); | ||||
198 | } | ||||
199 | | ||||
200 | QString KoToolAction::iconName() const | ||||
201 | { | ||||
202 | return d->toolHelper->iconName(); | ||||
203 | } | ||||
204 | | ||||
205 | QKeySequence KoToolAction::shortcut() const | ||||
206 | { | ||||
207 | return d->toolHelper->shortcut(); | ||||
208 | } | ||||
209 | | ||||
210 | | ||||
211 | QString KoToolAction::section() const | ||||
212 | { | ||||
213 | return d->toolHelper->toolType(); | ||||
214 | } | ||||
215 | | ||||
216 | int KoToolAction::priority() const | ||||
217 | { | ||||
218 | return d->toolHelper->priority(); | ||||
219 | } | ||||
220 | | ||||
221 | int KoToolAction::buttonGroupId() const | ||||
222 | { | ||||
223 | return d->toolHelper->uniqueId(); | ||||
224 | } | ||||
225 | | ||||
226 | QString KoToolAction::visibilityCode() const | ||||
227 | { | ||||
228 | return d->toolHelper->activationShapeId(); | ||||
229 | } | ||||
230 | | ||||
231 | | ||||
232 | | ||||
157 | // ************ Connector ********** | 233 | // ************ Connector ********** | ||
158 | Connector::Connector(KoShapeManager *parent) | 234 | Connector::Connector(KoShapeManager *parent) | ||
159 | : QObject(parent), | 235 | : QObject(parent), | ||
160 | m_shapeManager(parent) | 236 | m_shapeManager(parent) | ||
161 | { | 237 | { | ||
162 | connect(m_shapeManager, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); | 238 | connect(m_shapeManager, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); | ||
163 | } | 239 | } | ||
164 | 240 | | |||
Show All 11 Lines | |||||
176 | } | 252 | } | ||
177 | 253 | | |||
178 | ShortcutToolAction::~ShortcutToolAction() | 254 | ShortcutToolAction::~ShortcutToolAction() | ||
179 | { | 255 | { | ||
180 | } | 256 | } | ||
181 | 257 | | |||
182 | void ShortcutToolAction::actionTriggered() | 258 | void ShortcutToolAction::actionTriggered() | ||
183 | { | 259 | { | ||
184 | // TODO: why not ToolHelper::activate(); and thus a slightly different behaviour? | 260 | // todo: why not ToolHelper::activate(); and thus a slightly different behaviour? | ||
261 | // Answering the todo item: switchToolRequested | ||||
185 | KoToolManager::instance()->switchToolRequested(m_toolID); | 262 | KoToolManager::instance()->switchToolRequested(m_toolID); | ||
186 | } | 263 | } | ||
187 | 264 | |