Krita Source Code Documentation
Loading...
Searching...
No Matches
KisToolTransformFactory Class Reference

#include <kis_tool_transform.h>

+ Inheritance diagram for KisToolTransformFactory:

Public Member Functions

QList< QAction * > createActionsImpl () override
 createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a valid objectName().
 
KoToolBasecreateTool (KoCanvasBase *canvas) override
 
 KisToolTransformFactory ()
 
 ~KisToolTransformFactory () override
 
- Public Member Functions inherited from KisToolPaintFactoryBase
 KisToolPaintFactoryBase (const QString &id)
 
 ~KisToolPaintFactoryBase () override
 
- Public Member Functions inherited from KoToolFactoryBase
QString activationShapeId () const
 
QList< QAction * > createActions (KisKActionCollection *actionCollection)
 
QString iconName () const
 
QString id () const
 
 KoToolFactoryBase (const QString &id)
 
int priority () const
 
 Private (const QString &i)
 
QString section () const
 
QKeySequence shortcut () const
 
QString toolTip () const
 
virtual ~KoToolFactoryBase ()
 

Private Slots

void activateSubtoolCage ()
 
void activateSubtoolFree ()
 
void activateSubtoolLiquify ()
 
void activateSubtoolMesh ()
 
void activateSubtoolPerspective ()
 
void activateSubtoolWarp ()
 

Private Member Functions

void activateSubtool (KisToolTransform::TransformToolMode mode)
 

Additional Inherited Members

- Public Attributes inherited from KoToolFactoryBase
QString activationId
 
QString iconName
 
const QString id
 
int priority
 
QString section
 
QKeySequence shortcut
 
QString tooltip
 
- Protected Member Functions inherited from KoToolFactoryBase
void setActivationShapeId (const QString &activationShapeId)
 
void setIconName (const char *iconName)
 
void setIconName (const QString &iconName)
 
void setPriority (int newPriority)
 
void setSection (const QString &section)
 
void setShortcut (const QKeySequence &shortcut)
 
void setToolTip (const QString &tooltip)
 

Detailed Description

Definition at line 358 of file kis_tool_transform.h.

Constructor & Destructor Documentation

◆ KisToolTransformFactory()

KisToolTransformFactory::KisToolTransformFactory ( )
inline

Definition at line 365 of file kis_tool_transform.h.

366 : KisToolPaintFactoryBase("KisToolTransform") {
367 setToolTip(i18n("Transform a layer or a selection"));
369 setIconName(koIconNameCStr("krita_tool_transform"));
370 setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
371 setPriority(2);
373 }
KisToolPaintFactoryBase(const QString &id)
void setShortcut(const QKeySequence &shortcut)
void setSection(const QString &section)
void setActivationShapeId(const QString &activationShapeId)
void setIconName(const char *iconName)
void setToolTip(const QString &tooltip)
void setPriority(int newPriority)
#define koIconNameCStr(name)
Definition kis_icon.h:28
static const QString KRITA_TOOL_ACTIVATION_ID
Definition kis_tool.h:37
static const QString Transform
Tools that transform the layer.

References koIconNameCStr, KRITA_TOOL_ACTIVATION_ID, KoToolFactoryBase::setActivationShapeId(), KoToolFactoryBase::setIconName(), KoToolFactoryBase::setPriority(), KoToolFactoryBase::setSection(), KoToolFactoryBase::setShortcut(), KoToolFactoryBase::setToolTip(), and ToolBoxSection::Transform.

◆ ~KisToolTransformFactory()

KisToolTransformFactory::~KisToolTransformFactory ( )
inlineoverride

Definition at line 375 of file kis_tool_transform.h.

375{}

Member Function Documentation

◆ activateSubtool()

void KisToolTransformFactory::activateSubtool ( KisToolTransform::TransformToolMode mode)
private

Definition at line 1484 of file kis_tool_transform.cc.

1485{
1486 KoToolManager *toolManager = KoToolManager::instance();
1487
1488 KoCanvasController *canvasController = toolManager->activeCanvasController();
1489 if (!canvasController) return;
1490 KoCanvasBase *canvas = canvasController->canvas();
1491 if (!canvas) return;
1492
1493 KoToolBase *tool = toolManager->toolById(canvas, id());
1495 KisToolTransform *transformTool = dynamic_cast<KisToolTransform*>(tool);
1496 KIS_SAFE_ASSERT_RECOVER_RETURN(transformTool);
1497
1498 if (toolManager->activeToolId() == id()) {
1499 // Transform tool is already active, switch the current mode
1500 transformTool->setTransformMode(mode);
1501 } else {
1502 // Works like KoToolFactoryBase::activateTool, but tells the tool beforehand which initial transform mode to use
1503 transformTool->setNextActivationTransformMode(mode);
1504 toolManager->switchToolRequested(id());
1505 }
1506}
void setNextActivationTransformMode(TransformToolMode mode)
void setTransformMode(KisToolTransform::TransformToolMode newMode)
virtual KoCanvasBase * canvas() const
KoToolBase * toolById(KoCanvasBase *canvas, const QString &id) const
void switchToolRequested(const QString &id)
KoCanvasController * activeCanvasController() const
QString activeToolId() const
Returns the toolId of the currently active tool.
static KoToolManager * instance()
Return the toolmanager singleton.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KisCanvas2 * canvas

References KoToolManager::activeCanvasController(), KoToolManager::activeToolId(), KoCanvasController::canvas(), Private::canvas, KoToolManager::instance(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisToolTransform::setNextActivationTransformMode(), KisToolTransform::setTransformMode(), KoToolManager::switchToolRequested(), and KoToolManager::toolById().

◆ activateSubtoolCage

void KisToolTransformFactory::activateSubtoolCage ( )
privateslot

Definition at line 1519 of file kis_tool_transform.cc.

1520{
1522}
void activateSubtool(KisToolTransform::TransformToolMode mode)

References activateSubtool(), and KisToolTransform::CageTransformMode.

◆ activateSubtoolFree

void KisToolTransformFactory::activateSubtoolFree ( )
privateslot

◆ activateSubtoolLiquify

void KisToolTransformFactory::activateSubtoolLiquify ( )
privateslot

◆ activateSubtoolMesh

void KisToolTransformFactory::activateSubtoolMesh ( )
privateslot

◆ activateSubtoolPerspective

void KisToolTransformFactory::activateSubtoolPerspective ( )
privateslot

◆ activateSubtoolWarp

void KisToolTransformFactory::activateSubtoolWarp ( )
privateslot

◆ createActionsImpl()

QList< QAction * > KisToolTransformFactory::createActionsImpl ( )
overridevirtual

createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a valid objectName().

Returns
the list of actions this tool wishes to be available.

Reimplemented from KisToolPaintFactoryBase.

Definition at line 1454 of file kis_tool_transform.cc.

1455{
1458
1459 actions << actionRegistry->makeQAction("movetool-move-up", this);
1460 actions << actionRegistry->makeQAction("movetool-move-down", this);
1461 actions << actionRegistry->makeQAction("movetool-move-left", this);
1462 actions << actionRegistry->makeQAction("movetool-move-right", this);
1463 actions << actionRegistry->makeQAction("movetool-move-up-more", this);
1464 actions << actionRegistry->makeQAction("movetool-move-down-more", this);
1465 actions << actionRegistry->makeQAction("movetool-move-left-more", this);
1466 actions << actionRegistry->makeQAction("movetool-move-right-more", this);
1467
1468 auto makeSubtoolAction = [&actionRegistry, &actions, this](QString actionName, const char *slot) {
1469 QAction *action = actionRegistry->makeQAction(actionName, this);
1470 action->setProperty("always_enabled", true); // To allow this action to be triggered when the transform tool isn't already active
1471 connect(action, SIGNAL(triggered()), slot);
1472 actions << action;
1473 };
1474 makeSubtoolAction("KisToolTransformFree", SLOT(activateSubtoolFree()));
1475 makeSubtoolAction("KisToolTransformPerspective", SLOT(activateSubtoolPerspective()));
1476 makeSubtoolAction("KisToolTransformWarp", SLOT(activateSubtoolWarp()));
1477 makeSubtoolAction("KisToolTransformCage", SLOT(activateSubtoolCage()));
1478 makeSubtoolAction("KisToolTransformLiquify", SLOT(activateSubtoolLiquify()));
1479 makeSubtoolAction("KisToolTransformMesh", SLOT(activateSubtoolMesh()));
1480
1481 return actions;
1482}
QAction * makeQAction(const QString &name, QObject *parent=0)
static KisActionRegistry * instance()
QList< QAction * > createActionsImpl() override
createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a va...

References activateSubtoolCage(), activateSubtoolFree(), activateSubtoolLiquify(), activateSubtoolMesh(), activateSubtoolPerspective(), activateSubtoolWarp(), KisToolPaintFactoryBase::createActionsImpl(), KisActionRegistry::instance(), and KisActionRegistry::makeQAction().

◆ createTool()

KoToolBase * KisToolTransformFactory::createTool ( KoCanvasBase * canvas)
inlineoverridevirtual

Instantiate a new tool

Parameters
canvasthe canvas that the new tool will work on. Should be passed to the constructor of the tool.
Returns
a new KoToolBase instance, or zero if the tool doesn't want to show up.

Implements KoToolFactoryBase.

Definition at line 377 of file kis_tool_transform.h.

377 {
378 return new KisToolTransform(canvas);
379 }

References Private::canvas.


The documentation for this class was generated from the following files: