![]() |
Walls And Holes
1
|
The ToolManager class represents a group of mutually exclusive tools out of which only one can be active at a time. More...
#include <toolmanager.h>
Public Slots | |
void | activateTool (QString name) |
Activates the desired tool. More... | |
void | deactivateTool (QString name) |
Deactivates the tool if it is active. NOTE: A ToolManager is exclusive, so activateTool() automatically deactivates the previous tool. More... | |
QToolBar * | contextToolBar () |
Returns the context toolBar of the current active tool. More... | |
void | mousePressEvent (QMouseEvent *event) |
void | mouseReleaseEvent (QMouseEvent *event) |
void | mouseMoveEvent (QMouseEvent *event) |
void | wheelEvent (QWheelEvent *event) |
Signals | |
void | toolWasActivated (AbstractTool *tool, QString name) |
Signal emitted when a new tool is activated. More... | |
Public Member Functions | |
ToolManager (QObject *parent=nullptr) | |
QAction * | registerTool (AbstractTool *tool, QString name, QIcon icon=QIcon(), QKeySequence ks=QKeySequence()) |
Registers the tool with the given identifier. More... | |
QAction * | getAction (QString name) |
Finds the action associated with the name. More... | |
Protected Attributes | |
QMap< QString, AbstractTool * > | mTools |
QMap< QString, QAction * > | mToolActions |
A map from tool names to tool objects. More... | |
QActionGroup * | mActionGroup |
The actions associated to each tool. All pointers delete selves when the ToolManager is destructed. More... | |
AbstractTool * | mActiveTool |
The action group containing all of the ToolManager's actions. More... | |
QToolBar * | mContextToolBar |
The active tool. More... | |
The ToolManager class represents a group of mutually exclusive tools out of which only one can be active at a time.
The object that owns the ToolManager (and therefore sends its events to the ToolManager) must be the object in which the tools are used. For example, one window may contain several different kind of views, including a map view. The map view should own the ToolManager for rectangle / line / point brush tools because these tools only make sense within the map view.
A UI element which desires to use the ToolManager should forward mouse events to the ToolManager so that they can reach the active tool.
ToolManager::ToolManager | ( | QObject * | parent = nullptr | ) |
|
slot |
Activates the desired tool.
name | The name of the tool. |
This slot can be activated directly from a UI element to enable a tool.
|
slot |
Returns the context toolBar of the current active tool.
|
slot |
Deactivates the tool if it is active. NOTE: A ToolManager is exclusive, so activateTool() automatically deactivates the previous tool.
name | The name of the tool. |
QAction * ToolManager::getAction | ( | QString | name | ) |
Finds the action associated with the name.
name | The tool name. |
|
slot |
|
slot |
|
slot |
QAction * ToolManager::registerTool | ( | AbstractTool * | tool, |
QString | name, | ||
QIcon | icon = QIcon() , |
||
QKeySequence | ks = QKeySequence() |
||
) |
Registers the tool with the given identifier.
tool | The tool to be registered. |
name | The identifier to be given to the tool. |
Icon | of the tool, an icon is not necessary |
Key | Sequence for the tool, not necessary |
|
signal |
Signal emitted when a new tool is activated.
tool | The tool that was activated. |
name | The name of the tool. |
|
slot |
|
protected |
The actions associated to each tool. All pointers delete selves when the ToolManager is destructed.
|
protected |
The action group containing all of the ToolManager's actions.
|
protected |
The active tool.
|
protected |
A map from tool names to tool objects.
|
protected |