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

The undo / redo command for setting the shape transparency. More...

#include <KoShapeTransparencyCommand.h>

+ Inheritance diagram for KoShapeTransparencyCommand:

Public Member Functions

int id () const override
 
 KoShapeTransparencyCommand (const QList< KoShape * > &shapes, const QList< qreal > &transparencies, KUndo2Command *parent=0)
 
 KoShapeTransparencyCommand (const QList< KoShape * > &shapes, qreal transparency, KUndo2Command *parent=0)
 
 KoShapeTransparencyCommand (KoShape *shape, qreal transparency, KUndo2Command *parent=0)
 
bool mergeWith (const KUndo2Command *command) override
 
 Private ()
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoShapeTransparencyCommand () override
 
 ~Private ()
 
- 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 bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
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 ()
 

Public Attributes

QList< qreal > newTransparencies
 the new transparencies
 
QList< qreal > oldTransparencies
 the old transparencies
 
QList< KoShape * > shapes
 the shapes to set background for
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

The undo / redo command for setting the shape transparency.

Definition at line 13 of file KoShapeTransparencyCommand.cpp.

Constructor & Destructor Documentation

◆ ~Private()

KoShapeTransparencyCommand::~Private ( )
inline

Definition at line 18 of file KoShapeTransparencyCommand.cpp.

18 {
19 }

◆ KoShapeTransparencyCommand() [1/3]

KoShapeTransparencyCommand::KoShapeTransparencyCommand ( const QList< KoShape * > & shapes,
qreal transparency,
KUndo2Command * parent = 0 )

Command to set a new shape transparency.

Parameters
shapesa set of all the shapes that should get the new background.
transparencythe new shape transparency
parentthe parent command used for macro commands

Definition at line 26 of file KoShapeTransparencyCommand.cpp.

27 : KUndo2Command(parent)
28 , d(new Private())
29{
30 d->shapes = shapes;
31 Q_FOREACH (KoShape *shape, d->shapes) {
32 d->oldTransparencies.append(shape->transparency());
33 d->newTransparencies.append(transparency);
34 }
35
36 setText(kundo2_i18n("Set opacity"));
37}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
QList< KoShape * > shapes
the shapes to set background for
qreal transparency(bool recursive=false) const
Definition KoShape.cpp:730
KUndo2MagicString kundo2_i18n(const char *text)

References d, kundo2_i18n(), KUndo2Command::setText(), shapes, and KoShape::transparency().

◆ KoShapeTransparencyCommand() [2/3]

KoShapeTransparencyCommand::KoShapeTransparencyCommand ( KoShape * shape,
qreal transparency,
KUndo2Command * parent = 0 )

Command to set a new shape transparency.

Parameters
shapea single shape that should get the new transparency.
transparencythe new shape transparency
parentthe parent command used for macro commands

Definition at line 39 of file KoShapeTransparencyCommand.cpp.

40 : KUndo2Command(parent)
41 , d(new Private())
42{
43 d->shapes.append(shape);
44 d->oldTransparencies.append(shape->transparency());
45 d->newTransparencies.append(transparency);
46
47 setText(kundo2_i18n("Set opacity"));
48}

References d, kundo2_i18n(), KUndo2Command::setText(), and KoShape::transparency().

◆ KoShapeTransparencyCommand() [3/3]

KoShapeTransparencyCommand::KoShapeTransparencyCommand ( const QList< KoShape * > & shapes,
const QList< qreal > & transparencies,
KUndo2Command * parent = 0 )

Command to set new shape transparencies.

Parameters
shapesa set of all the shapes that should get a new transparency.
fillsthe new transparencies, one for each shape
parentthe parent command used for macro commands

Definition at line 50 of file KoShapeTransparencyCommand.cpp.

51 : KUndo2Command(parent)
52 , d(new Private())
53{
54 d->shapes = shapes;
55 Q_FOREACH (KoShape *shape, d->shapes) {
56 d->oldTransparencies.append(shape->transparency());
57 }
58 d->newTransparencies = transparencies;
59
60 setText(kundo2_i18n("Set opacity"));
61}

References d, kundo2_i18n(), KUndo2Command::setText(), shapes, and KoShape::transparency().

◆ ~KoShapeTransparencyCommand()

KoShapeTransparencyCommand::~KoShapeTransparencyCommand ( )
override

Definition at line 63 of file KoShapeTransparencyCommand.cpp.

64{
65 delete d;
66}

References d.

Member Function Documentation

◆ id()

int KoShapeTransparencyCommand::id ( ) const
overridevirtual

Returns the ID of this command.

A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.

If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.

KUndo2QStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.

See also
mergeWith(), KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 90 of file KoShapeTransparencyCommand.cpp.

References KisCommandUtils::ChangeShapeTransparencyId.

◆ mergeWith()

bool KoShapeTransparencyCommand::mergeWith ( const KUndo2Command * command)
overridevirtual

Attempts to merge this command with command. Returns true on success; otherwise returns false.

If this function returns true, calling this command's redo() must have the same effect as redoing both this command and command. Similarly, calling this command's undo() must have the same effect as undoing command and this command.

KUndo2QStack will only try to merge two commands if they have the same id, and the id is not -1.

The default implementation returns false.

See also
id() KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 95 of file KoShapeTransparencyCommand.cpp.

96{
97 const KoShapeTransparencyCommand *other = dynamic_cast<const KoShapeTransparencyCommand*>(command);
98
99 if (!other || other->d->shapes != d->shapes) {
100 return false;
101 }
102
103 d->newTransparencies = other->d->newTransparencies;
104 return true;
105}
The undo / redo command for setting the shape transparency.

References d.

◆ Private()

KoShapeTransparencyCommand::Private ( )
inline

Definition at line 16 of file KoShapeTransparencyCommand.cpp.

16 {
17 }

◆ redo()

void KoShapeTransparencyCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 68 of file KoShapeTransparencyCommand.cpp.

69{
71 QList<qreal>::iterator transparencyIt = d->newTransparencies.begin();
72 Q_FOREACH (KoShape *shape, d->shapes) {
73 shape->setTransparency(*transparencyIt);
74 shape->update();
75 ++transparencyIt;
76 }
77}
virtual void redo()
void setTransparency(qreal transparency)
Definition KoShape.cpp:722
virtual void update() const
Definition KoShape.cpp:605

References d, KUndo2Command::redo(), KoShape::setTransparency(), and KoShape::update().

◆ undo()

void KoShapeTransparencyCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 79 of file KoShapeTransparencyCommand.cpp.

80{
82 QList<qreal>::iterator transparencyIt = d->oldTransparencies.begin();
83 Q_FOREACH (KoShape *shape, d->shapes) {
84 shape->setTransparency(*transparencyIt);
85 shape->update();
86 ++transparencyIt;
87 }
88}
virtual void undo()

References d, KoShape::setTransparency(), KUndo2Command::undo(), and KoShape::update().

Member Data Documentation

◆ d

Private* const KoShapeTransparencyCommand::d
private

Definition at line 56 of file KoShapeTransparencyCommand.h.

◆ newTransparencies

QList<qreal> KoShapeTransparencyCommand::newTransparencies

the new transparencies

Definition at line 23 of file KoShapeTransparencyCommand.cpp.

◆ oldTransparencies

QList<qreal> KoShapeTransparencyCommand::oldTransparencies

the old transparencies

Definition at line 22 of file KoShapeTransparencyCommand.cpp.

◆ shapes

QList<KoShape*> KoShapeTransparencyCommand::shapes

the shapes to set background for

Definition at line 21 of file KoShapeTransparencyCommand.cpp.


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