1 /* ============================================================ 2 * 3 * SPDX-FileCopyrightText: 2009 Kare Sars <kare dot sars at iki dot fi> 4 * SPDX-FileCopyrightText: 2014 Gregor Mitsch : port to KDE5 frameworks 5 * SPDX-FileCopyrightText: 2021 Alexander Stippich <a.stippich@gmx.net> 6 * 7 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 8 * 9 * ============================================================ */ 10 11 #ifndef KSANE_WIDGET_PRIVATE_H 12 #define KSANE_WIDGET_PRIVATE_H 13 14 #include <QWidget> 15 #include <QCheckBox> 16 #include <QTimer> 17 #include <QProgressBar> 18 #include <QTabWidget> 19 #include <QPushButton> 20 #include <QVector> 21 #include <QSplitter> 22 #include <QToolButton> 23 #include <QSet> 24 25 #include "ksanecore.h" 26 #include "ksanewidget.h" 27 #include "ksaneoptionwidget.h" 28 #include "ksaneviewer.h" 29 #include "labeledcombo.h" 30 #include "labeledfslider.h" 31 #include "labeledentry.h" 32 #include "ksanebutton.h" 33 #include "labeledgamma.h" 34 #include "labeledcheckbox.h" 35 #include "splittercollapser.h" 36 37 #define IMG_DATA_R_SIZE 100000 38 39 /** This namespace collects all methods and classes in LibKSane. */ 40 namespace KSaneIface 41 { 42 class KSaneWidgetPrivate: public QObject 43 { 44 Q_OBJECT 45 46 public: 47 KSaneWidgetPrivate(KSaneWidget *); 48 void clearDeviceOptions(); 49 void createOptInterface(); 50 void updatePreviewSize(); 51 void setBusy(bool busy); 52 KSaneOptionWidget *createOptionWidget(QWidget *parent, KSaneOption *option); 53 KSaneWidget::ImageFormat getImgFormat(const QImage &image); 54 55 float ratioToScanAreaX(float ratio); 56 float ratioToScanAreaY(float ratio); 57 float scanAreaToRatioX(float scanArea); 58 float scanAreaToRatioY(float scanArea); 59 60 float ratioToDispUnitX(float ratio); 61 float ratioToDispUnitY(float ratio); 62 float dispUnitToRatioX(float mm); 63 float dispUnitToRatioY(float mm); 64 65 bool scanSourceADF(); 66 67 public Q_SLOTS: 68 void startFinalScan(); 69 void startPreviewScan(); 70 void scanDone(KSaneCore::KSaneScanStatus status, const QString &strStatus); 71 void previewScanDone(KSaneCore::KSaneScanStatus status, const QString &strStatus); 72 void oneFinalScanDone(KSaneCore::KSaneScanStatus status, const QString &strStatus); 73 void updateProgress(int progress); 74 void updateCountDown(int remainingSeconds); 75 void handleSelection(float tl_x, float tl_y, float br_x, float br_y); 76 void signalDevListUpdate(const QList<KSaneCore::DeviceInfo> &deviceList); 77 void imageReady(const QImage &image); 78 79 private Q_SLOTS: 80 81 void setTLX(const QVariant &x); 82 void setTLY(const QVariant &y); 83 void setBRX(const QVariant &x); 84 void setBRY(const QVariant &y); 85 86 void checkInvert(); 87 void invertPreview(); 88 89 void updateScanSelection(); 90 void setPossibleScanSizes(); 91 void setPageSize(int index); 92 93 void updateCommonGamma(); 94 void updatePreviewViewer(); 95 96 public: 97 void alertUser(KSaneCore::KSaneScanStatus status, const QString &strStatus); 98 99 public: 100 KSaneCore *m_ksaneCoreInterface; 101 102 // backend independent 103 QTabWidget *m_optsTabWidget; 104 QScrollArea *m_basicScrollA; 105 QWidget *m_basicOptsTab; 106 QWidget *m_colorOpts; 107 QScrollArea *m_advancedScrollA; 108 QWidget *m_advancedOptsTab; 109 QScrollArea *m_otherScrollA; 110 QWidget *m_otherOptsTab; 111 112 QVector<int> m_sizeCodes; 113 LabeledCombo *m_scanareaPapersize; 114 bool m_settingPageSize = false; 115 LabeledFSlider *m_scanareaWidth; 116 LabeledFSlider *m_scanareaHeight; 117 LabeledFSlider *m_scanareaX; 118 LabeledFSlider *m_scanareaY; 119 120 QSplitter *m_splitter; 121 SplitterCollapser *m_optionsCollapser; 122 123 QWidget *m_previewFrame; 124 KSaneViewer *m_previewViewer; 125 QWidget *m_btnFrame; 126 QToolButton *m_zInBtn; 127 QToolButton *m_zOutBtn; 128 QToolButton *m_zSelBtn; 129 QToolButton *m_zFitBtn; 130 QToolButton *m_clearSelBtn; 131 QPushButton *m_scanBtn; 132 QPushButton *m_prevBtn; 133 134 QWidget *m_activityFrame; 135 QLabel *m_warmingUp; 136 QLabel *m_countDown; 137 QProgressBar *m_progressBar; 138 QPushButton *m_cancelBtn; 139 140 // Option variables 141 QSet<QString> m_handledOptions; 142 KSaneOption *m_optSource; 143 KSaneOption *m_optNegative; 144 KSaneOption *m_optFilmType; 145 KSaneOption *m_optMode; 146 KSaneOption *m_optDepth; 147 KSaneOption *m_optRes; 148 KSaneOption *m_optResX; 149 KSaneOption *m_optResY; 150 KSaneOption *m_optTlX; 151 KSaneOption *m_optTlY; 152 KSaneOption *m_optBrX; 153 KSaneOption *m_optBrY; 154 KSaneOption *m_optPreview; 155 KSaneOption *m_optGamR; 156 KSaneOption *m_optGamG; 157 KSaneOption *m_optGamB; 158 KSaneOption *m_optInvert; 159 LabeledCheckbox *m_splitGamChB; 160 LabeledGamma *m_commonGamma; 161 KSaneOption *m_optWaitForBtn; 162 163 // preview variables 164 float m_previewWidth; 165 float m_previewHeight; 166 float m_previewDPI; 167 QImage m_previewImg; 168 bool m_isPreview; 169 bool m_autoSelect; 170 171 bool m_cancelMultiScan = false; 172 bool m_scanOngoing = false; 173 int m_selIndex; 174 175 KSaneWidget *q; 176 }; 177 178 } // NameSpace KSaneIface 179 180 #endif // SANE_WIDGET_H 181