Artifact 2f00c077ba43b35cc1bd46ff16bacec54e4d29f8:

  • File src/ScanImage.hxx — part of check-in [0c6d13a898] at 2019-05-13 08:23:44 on branch async-page — ScanImage: add accessors for original and filtered file. (user: fifr size: 2386) [more...]

/*
 * Copyright (c) 2018 Frank Fischer <frank-fischer@shadow-soft.de>
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * 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.  If not, see  <http://www.gnu.org/licenses/>
 */

#ifndef __FOTOKOPIERER_SCANIMAGE_HXX__
#define __FOTOKOPIERER_SCANIMAGE_HXX__

#include <QtCore/QObject>

#include <memory>

class Document;
class Filter;
class RotateFilter;
class CutFilter;
class ColorizeFilter;

class ScanImage : public QObject
{
    Q_OBJECT

    Q_PROPERTY(RotateFilter* rotateFilter READ rotateFilter CONSTANT);
    Q_PROPERTY(CutFilter* cutFilter READ cutFilter CONSTANT);
    Q_PROPERTY(ColorizeFilter* ColorizeFilter READ colorizeFilter CONSTANT);
    Q_PROPERTY(bool deleteOriginalOnClear READ deleteOriginalOnClear WRITE setDeleteOriginalOnClear
                   NOTIFY deleteOriginalOnClearChanged);

public:
    enum class FilterType {
        None = -1,
        Rotate = 0,
        Cut = 1,
        Colorize = 2,
    };
    Q_ENUM(FilterType);

public:
    ScanImage(QObject* parent = nullptr);

    ~ScanImage() override;

    /// Return the original image.
    QImage original() const;

    /// Compute and return the filtered image.
    QImage computeFilteredImage() const;

    Filter* filter(FilterType type);

    Q_INVOKABLE bool loadFile(const QString& file_name);

    Q_INVOKABLE void saveAndClear(Document* doc);

    Q_INVOKABLE void clear();

    QImage originalImage() const;

    RotateFilter* rotateFilter() const;

    CutFilter* cutFilter() const;

    ColorizeFilter* colorizeFilter() const;

    void setDeleteOriginalOnClear(bool enabled);

    bool deleteOriginalOnClear() const;

signals:
    void originalImageChanged();

    void addPage(QImage original, QImage result);

    void imageSaved();

    void deleteOriginalOnClearChanged();

private:
    struct Data;
    std::unique_ptr<Data> d;
};

#endif