File indexing completed on 2025-01-19 03:52:37

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2022-08-26
0007  * Description : Text converter batch dialog
0008  *
0009  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2022      by Quoc Hung Tran <quochungtran1999 at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_TEXT_CONVERTER_DIALOG_H
0017 #define DIGIKAM_TEXT_CONVERTER_DIALOG_H
0018 
0019 // Qt includes
0020 
0021 #include <QUrl>
0022 #include <QTreeWidgetItem>
0023 
0024 // Local includes
0025 
0026 #include "dplugindialog.h"
0027 #include "dinfointerface.h"
0028 
0029 using namespace Digikam;
0030 
0031 namespace DigikamGenericTextConverterPlugin
0032 {
0033 
0034 class TextConverterActionData;
0035 
0036 class TextConverterDialog : public DPluginDialog
0037 {
0038 
0039     Q_OBJECT
0040 
0041 public:
0042 
0043     explicit TextConverterDialog(QWidget* const parent, DInfoInterface* const iface);
0044     ~TextConverterDialog() override;
0045 
0046    void addItems(const QList<QUrl>& itemList);
0047 
0048 protected:
0049 
0050     void closeEvent(QCloseEvent* e);
0051 
0052 private:
0053 
0054     void setBusy(bool busy);
0055 
0056     void processAll();
0057     void processingFailed(const QUrl& url, int result);
0058     void processed(const QUrl& url, const QString& outputFile, const QString& ocrResult);
0059 
0060     int  calculateNumberOfWords(const QString& text) const;
0061 
0062     void plugProcessMenu();
0063     void unplugProcessMenu();
0064 
0065 private Q_SLOTS:
0066 
0067     void slotDefault();
0068     void slotClose();
0069     void slotStartStop();
0070     void slotAborted();
0071     void slotThreadFinished();
0072 
0073     void slotTextConverterAction(const DigikamGenericTextConverterPlugin::TextConverterActionData&);
0074     void slotDoubleClick(QTreeWidgetItem* element);
0075     void slotUpdateText();
0076 
0077     void slotSetDisable();
0078 
0079     void slotStartFoundTesseract();
0080     void slotTesseractBinaryFound(bool);
0081     void slotProcessMenu();
0082 
0083 private:
0084 
0085     class Private;
0086     Private* const d;
0087 };
0088 
0089 } // namespace DigikamGenericTextConverterPlugin
0090 
0091 #endif // DIGIKAM_TEXT_CONVERTER_DIALOG_H