Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeTransparencyCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2009 Jan Hambrecht <jaham@gmx.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8#include "KoShape.h"
9
10#include <klocalizedstring.h>
11#include "kis_command_ids.h"
12
25
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}
38
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}
49
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}
62
67
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}
78
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}
89
94
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}
virtual void undo()
void setText(const KUndo2MagicString &text)
virtual void redo()
The undo / redo command for setting the shape transparency.
QList< qreal > newTransparencies
the new transparencies
QList< qreal > oldTransparencies
the old transparencies
void redo() override
redo the command
QList< KoShape * > shapes
the shapes to set background for
KoShapeTransparencyCommand(const QList< KoShape * > &shapes, qreal transparency, KUndo2Command *parent=0)
void undo() override
revert the actions done in redo
bool mergeWith(const KUndo2Command *command) override
void setTransparency(qreal transparency)
Definition KoShape.cpp:722
virtual void update() const
Definition KoShape.cpp:605
qreal transparency(bool recursive=false) const
Definition KoShape.cpp:730
KUndo2MagicString kundo2_i18n(const char *text)