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 361 of file kis_tool_transform.h.

Constructor & Destructor Documentation

◆ KisToolTransformFactory()

KisToolTransformFactory::KisToolTransformFactory ( )
inline

Definition at line 368 of file kis_tool_transform.h.

369 : KisToolPaintFactoryBase("KisToolTransform") {
370 setToolTip(i18n("Transform a layer or a selection"));
372 setIconName(koIconNameCStr("krita_tool_transform"));
373 setShortcut(QKeySequence(Qt::CTRL | Qt::Key_T));
374 setPriority(2);
376 }
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 378 of file kis_tool_transform.h.

378{}

Member Function Documentation

◆ activateSubtool()

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

Definition at line 1521 of file kis_tool_transform.cc.

1522{
1523 KoToolManager *toolManager = KoToolManager::instance();
1524
1525 KoCanvasController *canvasController = toolManager->activeCanvasController();
1526 if (!canvasController) return;
1527 KoCanvasBase *canvas = canvasController->canvas();
1528 if (!canvas) return;
1529
1530 KoToolBase *tool = toolManager->toolById(canvas, id());
1532 KisToolTransform *transformTool = dynamic_cast<KisToolTransform*>(tool);
1533 KIS_SAFE_ASSERT_RECOVER_RETURN(transformTool);
1534
1535 if (toolManager->activeToolId() == id()) {
1536 // Transform tool is already active, switch the current mode
1537 transformTool->setTransformMode(mode);
1538 } else {
1539 // Works like KoToolFactoryBase::activateTool, but tells the tool beforehand which initial transform mode to use
1540 transformTool->setNextActivationTransformMode(mode);
1541 toolManager->switchToolRequested(id());
1542 }
1543}
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 1556 of file kis_tool_transform.cc.

1557{
1559}
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 1491 of file kis_tool_transform.cc.

1492{
1495
1496 actions << actionRegistry->makeQAction("movetool-move-up", this);
1497 actions << actionRegistry->makeQAction("movetool-move-down", this);
1498 actions << actionRegistry->makeQAction("movetool-move-left", this);
1499 actions << actionRegistry->makeQAction("movetool-move-right", this);
1500 actions << actionRegistry->makeQAction("movetool-move-up-more", this);
1501 actions << actionRegistry->makeQAction("movetool-move-down-more", this);
1502 actions << actionRegistry->makeQAction("movetool-move-left-more", this);
1503 actions << actionRegistry->makeQAction("movetool-move-right-more", this);
1504
1505 auto makeSubtoolAction = [&actionRegistry, &actions, this](QString actionName, const char *slot) {
1506 QAction *action = actionRegistry->makeQAction(actionName, this);
1507 action->setProperty("always_enabled", true); // To allow this action to be triggered when the transform tool isn't already active
1508 connect(action, SIGNAL(triggered()), slot);
1509 actions << action;
1510 };
1511 makeSubtoolAction("KisToolTransformFree", SLOT(activateSubtoolFree()));
1512 makeSubtoolAction("KisToolTransformPerspective", SLOT(activateSubtoolPerspective()));
1513 makeSubtoolAction("KisToolTransformWarp", SLOT(activateSubtoolWarp()));
1514 makeSubtoolAction("KisToolTransformCage", SLOT(activateSubtoolCage()));
1515 makeSubtoolAction("KisToolTransformLiquify", SLOT(activateSubtoolLiquify()));
1516 makeSubtoolAction("KisToolTransformMesh", SLOT(activateSubtoolMesh()));
1517
1518 return actions;
1519}
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 380 of file kis_tool_transform.h.

380 {
381 return new KisToolTransform(canvas);
382 }

References Private::canvas.


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