|
Krita Source Code Documentation
|
#include <KoToolManager.h>
Inheritance diagram for KoToolManager:Public Slots | |
| void | switchBackRequested () |
| void | switchInputDeviceRequested (const KoInputDevice &id) |
| void | switchToolRequested (const QString &id) |
| void | themeChanged () |
Signals | |
| void | aboutToChangeTool (KoCanvasController *canvas) |
| void | addedTool (KoToolAction *toolAction, KoCanvasController *canvas) |
| void | changedCanvas (const KoCanvasBase *canvas) |
| void | changedStatusText (const QString &statusText) |
| void | changedTool (KoCanvasController *canvas) |
| void | createOpacityResource (bool isOpacityPresetMode, KoToolBase *tool) |
| void | currentLayerChanged (const KoCanvasController *canvas, const KoShapeLayer *layer) |
| void | inputDeviceChanged (const KoInputDevice &device) |
| void | textModeChanged (bool text) |
| void | toolCodesSelected (const QList< QString > &types) |
| void | toolOptionWidgetsChanged (KoCanvasController *controller, const QList< QPointer< QWidget > > &widgets) |
Static Public Member Functions | |
| static KoToolManager * | instance () |
| Return the toolmanager singleton. | |
Public Attributes | |
| CanvasData * | canvasData |
| QHash< KoCanvasController *, QList< CanvasData * > > | canvasses |
| KoInputDevice | inputDevice |
| bool | layerExplicitlyDisabled |
| QHash< KoCanvasBase *, KoToolProxy * > | proxies |
| KoToolManager * | q |
| QList< KoToolAction * > | toolActionList |
Private Member Functions | |
| KoToolManager (const KoToolManager &) | |
| KoToolManager | operator= (const KoToolManager &) |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| Private *const | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
This class manages the activation and deactivation of tools for each input device.
Managing the active tool and switching tool based on various variables.
The state of the toolbox will be the same for all views in the process so practically you can say we have one toolbox per application instance (process). Implementation does not allow one widget to be in more then one view, so we just make sure the toolbox is hidden in not-in-focus views.
The ToolManager is a singleton and will manage all views in all applications that are loaded in this process. This means you will have to register and unregister your view. When creating your new view you should use a KoCanvasController() and register that with the ToolManager like this:
For a new view that extends KoView all you need to do is implement KoView::createToolBox()
KoToolManager also keeps track of the current tool based on a complex set of conditions and heuristics:
Nota bene: if you use KoToolManager and register your canvases with it you no longer have to manually implement methods to route mouse, tablet, key or wheel events to the active tool. In fact, it's no longer interesting to you which tool is active; you can safely route the paint event through KoToolProxy::paint().
(The reason the input events are handled completely by the toolmanager and the paint events not is that, generally speaking, it's okay if the tools get the input events first, but you want to paint your shapes or other canvas stuff first and only then paint the tool stuff.)
Definition at line 127 of file KoToolManager.h.
| KoToolManager::KoToolManager | ( | ) |
Definition at line 191 of file KoToolManager.cpp.
References connect(), and movedFocus().
|
override |
|
private |
| KoToolManager::~Private | ( | ) |
|
signal |
Emitted when a new tool is going to override the current tool
| canvas | the currently active canvas. |
| KoCanvasController * KoToolManager::activeCanvasController | ( | ) | const |
Definition at line 282 of file KoToolManager.cpp.
References Private::canvas, and d.
| QString KoToolManager::activeToolId | ( | ) | const |
Returns the toolId of the currently active tool.
Definition at line 344 of file KoToolManager.cpp.
References d.
| void KoToolManager::addController | ( | KoCanvasController * | controller | ) |
Register a new canvas controller
| controller | the view controller that this toolmanager will manage the tools for |
Definition at line 226 of file KoToolManager.cpp.
References attachCanvas(), attemptCanvasControllerRemoval(), connect(), d, detachCanvas(), and KoCanvasController::proxyObject.
|
signal |
emitted whenever a new tool is dynamically added for the given canvas
| void KoToolManager::attachCanvas | ( | KoCanvasController * | controller | ) |
| void KoToolManager::attemptCanvasControllerRemoval | ( | QObject * | controller | ) |
Attempt to remove a controller. This is automatically called when a controller's proxy object is deleted, and it ensures that the controller is, in fact, removed, even if the creator forgot to do so.
| controller | the proxy object of the controller to be removed |
Definition at line 246 of file KoToolManager.cpp.
References KoCanvasControllerProxyObject::canvasController(), and removeCanvasController().
|
signal |
Emitted whenever the active canvas changed.
| canvas | the new activated canvas (might be 0) |
|
signal |
Emitted whenever the active tool changes the status text.
| statusText | the new status text |
|
signal |
Emitted when a new tool was selected or became active.
| canvas | the currently active canvas. |
| void KoToolManager::connectActiveTool | ( | ) |
| CanvasData * KoToolManager::createCanvasData | ( | KoCanvasController * | controller, |
| const KoInputDevice & | device ) |
|
signal |
Emitted to create and store the opacity resource in tool. The opacity is a derived or abstract resource depending on isOpacityPresetMode.
| KoToolBase * KoToolManager::createTool | ( | KoCanvasController * | controller, |
| KoToolAction * | toolAction ) |
| KoInputDevice KoToolManager::currentInputDevice | ( | ) | const |
Definition at line 216 of file KoToolManager.cpp.
References d.
|
signal |
Emitted after the current layer changed either its properties or to a new layer.
| canvas | the currently active canvas. |
| layer | the layer that is selected. |
| void KoToolManager::currentLayerChanged | ( | const KoShapeLayer * | layer | ) |
| void KoToolManager::detachCanvas | ( | KoCanvasController * | controller | ) |
| void KoToolManager::disconnectActiveTool | ( | ) |
| bool KoToolManager::eventFilter | ( | QObject * | object, |
| QEvent * | event ) |
| void KoToolManager::initializeCurrentToolForCanvas | ( | ) |
Definition at line 318 of file KoToolManager.cpp.
References d, and KIS_ASSERT_RECOVER_RETURN.
| void KoToolManager::initializeToolActions | ( | ) |
Initialize actions for switching to tools. The actions will have the text / shortcut as stated by the toolFactory. If the application calls this in their KoView extending class they will have all the benefits from allowing this in the menus and to allow the use to configure the shortcuts used.
Definition at line 221 of file KoToolManager.cpp.
References d.
|
signal |
Every time a new input device gets used by a tool, this event is emitted.
| device | the new input device that the user picked up. |
|
static |
Return the toolmanager singleton.
Definition at line 339 of file KoToolManager.cpp.
| void KoToolManager::movedFocus | ( | QWidget * | from, |
| QWidget * | to ) |
|
private |
| void KoToolManager::postSwitchTool | ( | ) |
For the list of shapes find out which tool is the highest priority tool that can handle it.
| shapes | a list of shapes, a selection for example, that is used to look for the tool. |
Definition at line 288 of file KoToolManager.cpp.
References KoToolFactoryBase::activationShapeId(), d, KoToolAction::id(), KoInteractionTool_ID, KoToolAction::priority(), KoShape::shapeId(), and KoToolAction::toolFactory.
| KoToolManager::Private * KoToolManager::priv | ( | ) |
| KoToolManager::Private | ( | KoToolManager * | ) |
| void KoToolManager::registerToolProxy | ( | KoToolProxy * | proxy, |
| KoCanvasBase * | canvas ) |
Whenever a new tool proxy class is instantiated, it will use this method to register itself so the toolManager can update it to the latest active tool.
| proxy | the proxy to register. |
| canvas | which canvas the proxy is associated with; whenever a new tool is selected for that canvas, the proxy gets an update. |
| void KoToolManager::removeCanvasController | ( | KoCanvasController * | controller | ) |
Remove a set of controllers When the controller is no longer used it should be removed so all tools can be deleted and stop eating memory.
| controller | the controller that is removed |
Definition at line 238 of file KoToolManager.cpp.
References attachCanvas(), d, detachCanvas(), and KoCanvasController::proxyObject.
| void KoToolManager::requestToolActivation | ( | KoCanvasController * | controller | ) |
| void KoToolManager::setAbstractResource | ( | KoAbstractCanvasResourceInterfaceSP | abstractResource, |
| KoToolBase * | tool ) |
Definition at line 355 of file KoToolManager.cpp.
References KoToolBase::setAbstractResource().
| void KoToolManager::setConverter | ( | KoDerivedResourceConverterSP | converter, |
| KoToolBase * | tool ) |
Definition at line 350 of file KoToolManager.cpp.
References KoToolBase::setConverter().
| void KoToolManager::setup | ( | ) |
|
slot |
Switches to the last tool used just before the current one, if any.
Definition at line 265 of file KoToolManager.cpp.
References d.
| void KoToolManager::switchBackRequested | ( | ) |
| void KoToolManager::switchCanvasData | ( | CanvasData * | cd | ) |
| void KoToolManager::switchInputDevice | ( | const KoInputDevice & | device | ) |
Request a switch from to the param input device. This will cause the tool for that device to be selected.
|
slot |
Request change input device
| id | the id of the input device |
Definition at line 259 of file KoToolManager.cpp.
References d.
| void KoToolManager::switchTool | ( | const QString & | id | ) |
|
slot |
Request switching tool
| id | the id of the tool |
Definition at line 254 of file KoToolManager.cpp.
References d.
| void KoToolManager::switchToolTemporaryRequested | ( | const QString & | id | ) |
|
signal |
Emitted when the tool's text mode has changed.
| inTextMode | whether it is now in text mode. |
|
slot |
Notify theme changes
Definition at line 328 of file KoToolManager.cpp.
References CanvasData::allTools, canvasData, d, and KoToolBase::updateOptionsWidgetIcons().
| QList< KoToolAction * > KoToolManager::toolActionList | ( | ) | const |
Returns the list of toolActions for the current tools.
| KoToolBase * KoToolManager::toolById | ( | KoCanvasBase * | canvas, |
| const QString & | id ) const |
Returns the tool for the given tool id. The tool may be 0
| canvas | the canvas that is a child of a previously registered controller who's tool you want. |
| id | the tool identifier |
Definition at line 272 of file KoToolManager.cpp.
References KoCanvasController::canvas(), Private::canvas, and d.
Emitted after the selection changed to state which unique shape-types are now in the selection.
| types | a list of string that are the shape types of the selected objects. |
|
signal |
Emit the new tool option widgets to be used with this canvas.
| void KoToolManager::updateCursor | ( | const QCursor & | cursor | ) |
| void KoToolManager::updateToolForProxy | ( | ) |
| CanvasData* KoToolManager::canvasData |
Definition at line 81 of file KoToolManager_p.h.
| QHash<KoCanvasController*, QList<CanvasData*> > KoToolManager::canvasses |
Definition at line 78 of file KoToolManager_p.h.
|
private |
Definition at line 313 of file KoToolManager.h.
| KoInputDevice KoToolManager::inputDevice |
Definition at line 83 of file KoToolManager_p.h.
| bool KoToolManager::layerExplicitlyDisabled |
Definition at line 85 of file KoToolManager_p.h.
| QHash<KoCanvasBase*, KoToolProxy*> KoToolManager::proxies |
Definition at line 79 of file KoToolManager_p.h.
| KoToolManager* KoToolManager::q |
Definition at line 74 of file KoToolManager_p.h.
| QList< KoToolAction * > KoToolManager::toolActionList |
Definition at line 76 of file KoToolManager_p.h.