diff --git a/app/imagetransform.cpp b/app/imagetransform.cpp index cc0dc04..163278e 100644 --- a/app/imagetransform.cpp +++ b/app/imagetransform.cpp @@ -1,101 +1,98 @@ /************************************************************************ * * * This file is part of Kooka, a scanning/OCR application using * * Qt and KDE Frameworks . * * * * Copyright (C) 2013-2016 Jonathan Marten * * * * Kooka is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as * * published by the Free Software Foundation and appearing in the * * file COPYING included in the packaging of this file; either * * version 2 of the License, or (at your option) any later version. * * * * As a special exception, permission is given to link this program * * with any version of the KADMOS OCR/ICR engine (a product of * * reRecognition GmbH, Kreuzlingen), and distribute the resulting * * executable without including the source code for KADMOS in the * * source distribution. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public * * License along with this program; see the file COPYING. If * * not, see . * * * ************************************************************************/ #include "imagetransform.h" #include #include #include ImageTransform::ImageTransform(const QImage &img, ImageTransform::Operation op, - const QString fileName, QObject *parent) + const QString &fileName, QObject *parent) : QThread(parent) { mImage = img; mOperation = op; mFileName = fileName; //qDebug() << "for operation" << mOperation; } -ImageTransform::~ImageTransform() -{ -} void ImageTransform::run() { //qDebug() << "thread started for operation" << mOperation; QImage resultImg; QMatrix m; switch (mOperation) { case ImageTransform::Rotate90: emit statusMessage(i18n("Rotate image +90 degrees")); m.rotate(+90); resultImg = mImage.transformed(m); break; case ImageTransform::MirrorBoth: case ImageTransform::Rotate180: emit statusMessage(i18n("Rotate image 180 degrees")); resultImg = mImage.mirrored(true, true); break; case ImageTransform::Rotate270: emit statusMessage(i18n("Rotate image -90 degrees")); m.rotate(-90); resultImg = mImage.transformed(m); break; case ImageTransform::MirrorHorizontal: emit statusMessage(i18n("Mirror image horizontally")); resultImg = mImage.mirrored(true, false); break; case ImageTransform::MirrorVertical: emit statusMessage(i18n("Mirror image vertically")); resultImg = mImage.mirrored(false, true); break; default: //qDebug() << "Unknown operation" << mOperation; break; } if (resultImg.save(mFileName)) { emit done(QUrl::fromLocalFile(mFileName)); } else { emit statusMessage(i18n("Error updating image %1", mFileName)); } //qDebug() << "thread finished"; } diff --git a/app/imagetransform.h b/app/imagetransform.h index b1b7e9e..dc6ee30 100644 --- a/app/imagetransform.h +++ b/app/imagetransform.h @@ -1,71 +1,71 @@ /************************************************************************ * * * This file is part of Kooka, a scanning/OCR application using * * Qt and KDE Frameworks . * * * * Copyright (C) 2013-2016 Jonathan Marten * * * * Kooka is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as * * published by the Free Software Foundation and appearing in the * * file COPYING included in the packaging of this file; either * * version 2 of the License, or (at your option) any later version. * * * * As a special exception, permission is given to link this program * * with any version of the KADMOS OCR/ICR engine (a product of * * reRecognition GmbH, Kreuzlingen), and distribute the resulting * * executable without including the source code for KADMOS in the * * source distribution. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public * * License along with this program; see the file COPYING. If * * not, see . * * * ************************************************************************/ #ifndef IMAGETRANSFORM_H #define IMAGETRANSFORM_H #include #include class QUrl; class ImageTransform : public QThread { Q_OBJECT public: enum Operation { Rotate90, // 90 degrees clockwise Rotate180, // 180 degrees Rotate270, // 90 degrees anticlockwise MirrorHorizontal, // mirror horizontally MirrorVertical, // mirror vertically MirrorBoth // effectively same as Rotate180 }; explicit ImageTransform(const QImage &img, ImageTransform::Operation op, - const QString fileName, QObject *parent = nullptr); - ~ImageTransform() override; + const QString &fileName, QObject *parent = nullptr); + ~ImageTransform() override = default; signals: void statusMessage(const QString &message); void done(const QUrl &imageUrl); protected: void run() override; private: ImageTransform::Operation mOperation; QString mFileName; QImage mImage; }; #endif // IMAGETRANSFORM_H