File indexing completed on 2024-05-12 04:34:49

0001 /* ============================================================
0002  *
0003  * SPDX-FileCopyrightText: 2007-2012 Kåre Särs <kare.sars@iki .fi>
0004  * SPDX-FileCopyrightText: 2014 Gregor Mitsch : port to KDE5 frameworks
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007  *
0008  * ============================================================ */
0009 
0010 #ifndef Skanlite_h
0011 #define Skanlite_h
0012 
0013 #include <QUrl>
0014 #include <QDialog>
0015 #include <QTimer>
0016 
0017 
0018 #include "ui_settings.h"
0019 #include "DBusInterface.h"
0020 
0021 class ShowImageDialog;
0022 class SaveLocation;
0023 class QProgressBar;
0024 
0025 namespace KSaneIface {
0026 class KSaneWidget;
0027 }
0028 
0029 class Skanlite : public QDialog
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     explicit Skanlite(const QString &device, QWidget *parent);
0035 
0036 private:
0037     // Order of items in save mode combo-box
0038     enum SaveMode {
0039         SaveModeManual = 0,
0040         SaveModeAskFirst = 1,
0041     };
0042 
0043     void readSettings();
0044     void loadScannerOptions();
0045 
0046     void processSelectionOptions(QMap<QString, QString> &opts, bool ignoreSelection);
0047 
0048 private Q_SLOTS:
0049     void showSettingsDialog();
0050     void imageReady(const QImage &image);
0051     void saveImage();
0052     void updateSaveProgress();
0053     void imageSaved(const QUrl &url, const QString &name, bool success);
0054     void saveWindowSize();
0055     void saveScannerDevice();
0056 
0057     void saveScannerOptions();
0058     void defaultScannerOptions();
0059     void applyScannerOptions(const QMap<QString, QString> &opts);
0060 
0061     void alertUser(int type, const QString &strStatus);
0062     void buttonPressed(const QString &optionName, const QString &optionLabel, bool pressed);
0063 
0064     void showHelp();
0065 
0066     // slots to communicate with D-Bus interface
0067     void getScannerOptions();
0068     void setScannerOptions(const QStringList &options, bool ignoreSelection);
0069     void getDefaultScannerOptions();
0070     void saveScannerOptionsToProfile(const QStringList &options, const QString &profile, bool ignoreSelection);
0071     void switchToProfile(const QString &profile, bool ignoreSelection);
0072     void getDeviceName();
0073     void getSelection();
0074     void setSelection(const QStringList &options);
0075 
0076     void reselectScannerDevice();
0077     void updateWindowTitle(const QString &deviceName, const QString &deviceVendor = QString(), const QString &deviceModel = QString());
0078 
0079 protected:
0080     void closeEvent(QCloseEvent *event) override;
0081 
0082 private:
0083     KSaneIface::KSaneWidget             *m_ksanew = nullptr;
0084     QProgressBar            *m_saveProgressBar = nullptr;
0085     QPushButton             *m_btnReselectDevice = nullptr;
0086     QUrl                     m_currentSaveUrl;
0087     QTimer                   m_saveUpdateTimer;
0088     Ui::SkanliteSettings     m_settingsUi;
0089     QDialog                 *m_settingsDialog = nullptr;
0090     ShowImageDialog         *m_showImgDialog = nullptr;
0091     SaveLocation            *m_saveLocation = nullptr;
0092     QString                  m_deviceName;
0093     QString                  m_deviceVendor;
0094     QString                  m_deviceModel;
0095     QMap<QString, QString>   m_defaultScanOpts;
0096     QMap<QString, QString>   m_pendingApplyScanOpts;
0097     QImage                   m_img;
0098 
0099     DBusInterface            m_dbusInterface;
0100     QStringList              m_filterList;
0101     QStringList              m_filter16BitList;
0102     bool                     m_firstImage;
0103 };
0104 
0105 #endif
0106