31
31
#include "document/abstractdocumenteditor.h"
32
32
#include "document/documentjob.h"
37
37
struct TransformImageOperationPrivate {
38
Orientation mOrientation;
38
Orientation mOrientation;
42
class TransformJob : public ThreadedDocumentJob {
41
class TransformJob : public ThreadedDocumentJob
44
TransformJob(Orientation orientation)
45
: mOrientation(orientation)
44
TransformJob(Orientation orientation)
45
: mOrientation(orientation)
48
virtual void threadedStart() {
49
if (!checkDocumentEditor()) {
52
document()->editor()->applyTransformation(mOrientation);
48
virtual void threadedStart()
50
if (!checkDocumentEditor()) {
53
document()->editor()->applyTransformation(mOrientation);
57
Orientation mOrientation;
58
Orientation mOrientation;
61
61
TransformImageOperation::TransformImageOperation(Orientation orientation)
62
: d(new TransformImageOperationPrivate) {
63
d->mOrientation = orientation;
64
switch (d->mOrientation) {
66
setText(i18nc("(qtundo-format)", "Rotate Right"));
69
setText(i18nc("(qtundo-format)", "Rotate Left"));
72
setText(i18nc("(qtundo-format)", "Mirror"));
75
setText(i18nc("(qtundo-format)", "Flip"));
78
// We should not get there because the transformations listed above are
79
// the only one available from the UI. Define a default text nevertheless.
80
setText(i18nc("(qtundo-format)", "Transform"));
86
TransformImageOperation::~TransformImageOperation() {
91
void TransformImageOperation::redo() {
92
redoAsDocumentJob(new TransformJob(d->mOrientation));
96
void TransformImageOperation::undo() {
97
Orientation orientation;
98
switch (d->mOrientation) {
100
orientation = ROT_270;
103
orientation = ROT_90;
106
orientation = d->mOrientation;
109
document()->enqueueJob(new TransformJob(orientation));
62
: d(new TransformImageOperationPrivate)
64
d->mOrientation = orientation;
65
switch (d->mOrientation) {
67
setText(i18nc("(qtundo-format)", "Rotate Right"));
70
setText(i18nc("(qtundo-format)", "Rotate Left"));
73
setText(i18nc("(qtundo-format)", "Mirror"));
76
setText(i18nc("(qtundo-format)", "Flip"));
79
// We should not get there because the transformations listed above are
80
// the only one available from the UI. Define a default text nevertheless.
81
setText(i18nc("(qtundo-format)", "Transform"));
86
TransformImageOperation::~TransformImageOperation()
91
void TransformImageOperation::redo()
93
redoAsDocumentJob(new TransformJob(d->mOrientation));
96
void TransformImageOperation::undo()
98
Orientation orientation;
99
switch (d->mOrientation) {
101
orientation = ROT_270;
104
orientation = ROT_90;
107
orientation = d->mOrientation;
110
document()->enqueueJob(new TransformJob(orientation));