File indexing completed on 2024-04-28 15:39:39

0001 /***************************************************** -*- mode:c++; -*- ***
0002                   kocrbase.h  - base dialog for OCR
0003                              -------------------
0004     begin                : Sun Jun 11 2000
0005     copyright            : (C) 2000 by Klaas Freitag
0006     email                : freitag@suse.de
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *  This file may be distributed and/or modified under the terms of the    *
0012  *  GNU General Public License version 2 as published by the Free Software *
0013  *  Foundation and appearing in the file COPYING included in the           *
0014  *  packaging of this file.                                                *
0015  *
0016  *  As a special exception, permission is given to link this program       *
0017  *  with any version of the KADMOS ocr/icr engine of reRecognition GmbH,   *
0018  *  Kreuzlingen and distribute the resulting executable without            *
0019  *  including the source code for KADMOS in the source distribution.       *
0020  *
0021  *  As a special exception, permission is given to link this program       *
0022  *  with any edition of Qt, and distribute the resulting executable,       *
0023  *  without including the source code for Qt in the source distribution.   *
0024  *                                                                         *
0025  ***************************************************************************/
0026 
0027 #ifndef ABSTRACTOCRDIALOGUE_H
0028 #define ABSTRACTOCRDIALOGUE_H
0029 
0030 #include <kpagedialog.h>
0031 
0032 #include "abstractocrengine.h"
0033 
0034 
0035 /**
0036   *@author Klaas Freitag
0037   */
0038 
0039 class QLabel;
0040 class QSize;
0041 class QCheckBox;
0042 class QGroupBox;
0043 class QPushButton;
0044 class QRadioButton;
0045 class QProgressBar;
0046 
0047 class KPageWidgetItem;
0048 class KFileItem;
0049 
0050 class ScanImage;
0051 
0052 
0053 class PLUGIN_EXPORT AbstractOcrDialogue : public KPageDialog
0054 {
0055     Q_OBJECT
0056 
0057 public:
0058     virtual ~AbstractOcrDialogue() = default;
0059 
0060     virtual bool setupGui();
0061     virtual void introduceImage(ScanImage::Ptr img);
0062 
0063     bool keepTempFiles() const;
0064     bool verboseDebug() const;
0065 
0066     void enableGUI(bool running);
0067 
0068     bool wantInteractiveSpellCheck() const;
0069     bool wantBackgroundSpellCheck() const;
0070     QString customSpellConfigFile() const;
0071 
0072 signals:
0073     void signalOcrStart();
0074     void signalOcrStop();
0075     void signalOcrClose();
0076 
0077 protected:
0078     explicit AbstractOcrDialogue(AbstractOcrEngine *plugin, QWidget *pnt = nullptr);
0079 
0080     AbstractOcrEngine *engine() const           { return (m_plugin); }
0081 
0082     /**
0083      * Enable or disable dialogue fields.
0084      *
0085      * @param enable Whether the dialogue fields should be enabled
0086      *
0087      * @note This is called when the OCR process starts with the parameter @p enable
0088      * set to @c false, and called after OCR has finished and the GUI should accept
0089      * user input again with the parameter @p enable set to @c true.
0090      */
0091     virtual void enableFields(bool enable) = 0;
0092 
0093     QProgressBar *progressBar() const;
0094 
0095     void ocrShowInfo(const QString &binary, const QString &version = QString());
0096     void ocrShowVersion(const QString &version);
0097 
0098     QWidget *addExtraSetupWidget(QWidget *wid = nullptr, bool stretchBefore = false);
0099     QWidget *addExtraEngineWidget(QWidget *wid = nullptr, bool stretchBefore = false);
0100     QWidget *addExtraDebugWidget(QWidget *wid = nullptr, bool stretchBefore = false);
0101 
0102 protected slots:
0103     virtual void slotWriteConfig();
0104     void slotStartOCR();
0105     void slotCustomSpellDialog();
0106 
0107 private:
0108     void setupSetupPage();
0109     void setupSourcePage();
0110     void setupEnginePage();
0111     void setupSpellPage();
0112     void setupDebugPage();
0113 
0114     QWidget *addExtraPageWidget(KPageWidgetItem *page, QWidget *wid, bool stretchBefore);
0115 
0116 private slots:
0117     void slotGotPreview(const KFileItem &item, const QPixmap &newPix);
0118     void stopAnimation();
0119     void startAnimation();
0120 
0121 private:
0122     AbstractOcrEngine *m_plugin;
0123 
0124     KPageWidgetItem *m_setupPage;
0125     KPageWidgetItem *m_sourcePage;
0126     KPageWidgetItem *m_enginePage;
0127     KPageWidgetItem *m_spellPage;
0128     KPageWidgetItem *m_debugPage;
0129 
0130     QLabel *m_previewPix;
0131     QLabel *m_previewLabel;
0132 
0133     QRadioButton *m_rbGlobalSpellSettings;
0134     QRadioButton *m_rbCustomSpellSettings;
0135     QPushButton *m_pbCustomSpellDialog;
0136     QGroupBox *m_gbBackgroundCheck;
0137     QGroupBox *m_gbInteractiveCheck;
0138 
0139     QSize m_previewSize;
0140     bool m_wantDebugCfg;                // show the debug options?
0141 
0142     QCheckBox *m_cbRetainFiles;
0143     QCheckBox *m_cbVerboseDebug;
0144     bool m_retainFiles;
0145     bool m_verboseDebug;
0146 
0147     QLabel *m_lVersion;
0148     QProgressBar *m_progress;
0149 };
0150 
0151 #endif                          // ABSTRACTOCRDIALOGUE_H