Warning, file /utilities/skanpage/src/Skanpage.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /**
0002  * SPDX-FileCopyrightText: 2015 by Kåre Särs <kare.sars@iki .fi>
0003  * SPDX-FileCopyrightText: 2021 by Alexander Stippich <a.stippich@gmx.net>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 #ifndef SKANPAGE_H
0009 #define SKANPAGE_H
0010 
0011 #include <QObject>
0012 #include <QString>
0013 
0014 #include <Interface>
0015 #include <DeviceInformation>
0016 
0017 #include <memory>
0018 
0019 #include "SkanpageUtils.h"
0020 #include "skanpage_config.h"
0021 #include "skanpage_state.h"
0022 
0023 class DocumentModel;
0024 class DevicesModel;
0025 class FormatModel;
0026 class FilteredOptionsModel;
0027 class OCRLanguageModel;
0028 class SkanpagePrivate;
0029 
0030 class Skanpage : public QObject
0031 {
0032     Q_OBJECT
0033 
0034     Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
0035     Q_PROPERTY(int countDown READ countDown NOTIFY countDownChanged)
0036     Q_PROPERTY(DocumentModel *documentModel READ documentModel CONSTANT)
0037     Q_PROPERTY(DevicesModel *devicesModel READ devicesModel CONSTANT)
0038     Q_PROPERTY(FormatModel *formatModel READ formatModel CONSTANT)
0039     Q_PROPERTY(FilteredOptionsModel *optionsModel READ optionsModel CONSTANT)
0040     Q_PROPERTY(OCRLanguageModel *languageModel READ languageModel CONSTANT)
0041     Q_PROPERTY(SkanpageConfiguration *configuration READ configuration CONSTANT)
0042     Q_PROPERTY(SkanpageState *stateConfiguration READ stateConfiguration CONSTANT)
0043     Q_PROPERTY(ApplicationState applicationState READ applicationState NOTIFY applicationStateChanged)
0044 
0045     Q_PROPERTY(QString deviceVendor READ deviceVendor NOTIFY deviceInfoUpdated)
0046     Q_PROPERTY(QString deviceModel READ deviceModel NOTIFY deviceInfoUpdated)
0047     Q_PROPERTY(QString deviceName READ deviceName NOTIFY deviceInfoUpdated)
0048 
0049 public:
0050 
0051     enum ApplicationState {
0052         ScanInProgress,
0053         ReadyForScan,
0054         DeviceSelection,
0055         SearchingForDevices,
0056         NoDeviceOpened
0057     };
0058 
0059     Q_ENUM(ApplicationState);
0060 
0061     explicit Skanpage(const QString &deviceName, QObject *parent = nullptr);
0062     ~Skanpage();
0063 
0064     QString deviceVendor() const;
0065     QString deviceModel() const;
0066     QString deviceName() const;
0067 
0068     int progress() const;
0069     int countDown() const;
0070     ApplicationState applicationState() const;
0071 
0072     DocumentModel *documentModel() const;
0073     DevicesModel *devicesModel() const;
0074     FormatModel *formatModel() const;
0075     FilteredOptionsModel *optionsModel() const;
0076     OCRLanguageModel *languageModel() const;
0077     KSaneCore::Interface *ksaneInterface() const;
0078     SkanpageConfiguration *configuration() const;
0079     SkanpageState *stateConfiguration() const;
0080 
0081     Q_INVOKABLE void startScan();
0082     Q_INVOKABLE void cancelScan();
0083     Q_INVOKABLE void reloadDevicesList();
0084     Q_INVOKABLE bool openDevice(const QString &deviceName, const QString &deviceVendor = QString(), const QString &deviceModel = QString());    
0085     Q_INVOKABLE bool OCRavailable() const;
0086 
0087 Q_SIGNALS:
0088     void progressChanged(int progress);
0089     void countDownChanged(int remainingSeconds);
0090     void optionsChanged();
0091     void applicationStateChanged(ApplicationState state);
0092     void deviceInfoUpdated();
0093     void newUserMessage(const QVariant &level, const QVariant &message);
0094 
0095 private Q_SLOTS:
0096 
0097     void imageReady(const QImage &image);
0098     void availableDevices(const QList<KSaneCore::DeviceInformation *> &deviceList);
0099     void showKSaneMessage(KSaneCore::Interface::ScanStatus type, const QString &strStatus);
0100     void showUserMessage(SkanpageUtils::MessageLevel level, const QString &strStatus);
0101     void progressUpdated(int progress);
0102     void batchModeCountDown(int remainingSeconds);
0103     void scanningFinished(KSaneCore::Interface::ScanStatus status, const QString &strStatus);
0104     void imageTemporarilySaved();
0105 
0106 private:
0107     void finishOpeningDevice(const QString &deviceName, const QString &deviceVendor, const QString &deviceModel);
0108     void loadScannerOptions();
0109     void saveScannerOptions();
0110     void checkFinish();
0111     void signalErrorMessage(const QString &text);
0112 
0113     std::unique_ptr<SkanpagePrivate> d;
0114 };
0115 
0116 #endif // SKANPAGE_H