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

#include <kis_image_resize_command.h>

+ Inheritance diagram for KisImageResizeCommand:

Public Member Functions

 KisImageResizeCommand (KisImageWSP image, const QSize &newRect, KUndo2Command *parent=0)
 
void redo () override
 
void undo () override
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () const
 
bool hasParent () const
 
virtual int id () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual bool mergeWith (const KUndo2Command *other)
 
virtual void redoMergedCommands ()
 
void setEndTime ()
 
virtual void setEndTime (const QTime &time)
 
void setExtraData (KUndo2CommandExtraData *data)
 
void setText (const KUndo2MagicString &text)
 
void setTime ()
 
virtual void setTime (const QTime &time)
 
virtual void setTimedID (int timedID)
 
KUndo2MagicString text () const
 
virtual QTime time () const
 
virtual int timedId () const
 
virtual bool timedMergeWith (KUndo2Command *other)
 
virtual void undoMergedCommands ()
 
virtual ~KUndo2Command ()
 

Private Attributes

KisImageWSP m_image
 
QSize m_sizeAfter
 
QSize m_sizeBefore
 

Detailed Description

Definition at line 18 of file kis_image_resize_command.h.

Constructor & Destructor Documentation

◆ KisImageResizeCommand()

KisImageResizeCommand::KisImageResizeCommand ( KisImageWSP image,
const QSize & newRect,
KUndo2Command * parent = 0 )

Definition at line 14 of file kis_image_resize_command.cpp.

16 : KUndo2Command(kundo2_i18n("Resize Image"), parent),
17 m_image(image)
18{
19 // do we really need a translatable name for the command?
20 KisImageSP imageSP = m_image.toStrongRef();
21 if (!imageSP) {
22 return;
23 }
24 m_sizeBefore = imageSP->size();
25 m_sizeAfter = newSize;
26}
KUndo2Command(KUndo2Command *parent=0)
QSize size() const
Definition kis_image.h:547
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
KUndo2MagicString kundo2_i18n(const char *text)

References m_image, m_sizeAfter, m_sizeBefore, KisImage::size(), and KisWeakSharedPtr< T >::toStrongRef().

Member Function Documentation

◆ redo()

void KisImageResizeCommand::redo ( )
overridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KUndo2Command.

Definition at line 28 of file kis_image_resize_command.cpp.

29{
31 if (!image) {
32 return;
33 }
34 image->setSize(m_sizeAfter);
35}
void setSize(const QSize &size)
Definition kis_image.cc:828

References m_image, m_sizeAfter, KisImage::setSize(), and KisWeakSharedPtr< T >::toStrongRef().

◆ undo()

void KisImageResizeCommand::undo ( )
overridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KUndo2Command.

Definition at line 37 of file kis_image_resize_command.cpp.

38{
40 if (!image) {
41 return;
42 }
43 image->setSize(m_sizeBefore);
44}

References m_image, m_sizeBefore, KisImage::setSize(), and KisWeakSharedPtr< T >::toStrongRef().

Member Data Documentation

◆ m_image

KisImageWSP KisImageResizeCommand::m_image
private

Definition at line 29 of file kis_image_resize_command.h.

◆ m_sizeAfter

QSize KisImageResizeCommand::m_sizeAfter
private

Definition at line 28 of file kis_image_resize_command.h.

◆ m_sizeBefore

QSize KisImageResizeCommand::m_sizeBefore
private

Definition at line 27 of file kis_image_resize_command.h.


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