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 : a plugin to convert documented images to text 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 #include "textconverterplugin.h" 0017 0018 // Qt includes 0019 0020 #include <QPointer> 0021 0022 // KDE includes 0023 0024 #include <klocalizedstring.h> 0025 0026 // Local includes 0027 0028 #include "textconverterdialog.h" 0029 0030 namespace DigikamGenericTextConverterPlugin 0031 { 0032 0033 TextConverterPlugin::TextConverterPlugin(QObject* const parent) 0034 : DPluginGeneric(parent) 0035 { 0036 } 0037 0038 TextConverterPlugin::~TextConverterPlugin() 0039 { 0040 } 0041 0042 QString TextConverterPlugin::name() const 0043 { 0044 return i18nc("@title", "OCR Text Converter"); 0045 } 0046 0047 QString TextConverterPlugin::iid() const 0048 { 0049 return QLatin1String(DPLUGIN_IID); 0050 } 0051 0052 QIcon TextConverterPlugin::icon() const 0053 { 0054 return QIcon::fromTheme(QLatin1String("text-x-generic")); 0055 } 0056 0057 QString TextConverterPlugin::description() const 0058 { 0059 return i18nc("@info", "A tool to batch convert documented images to text using OCR"); 0060 } 0061 0062 QString TextConverterPlugin::details() const 0063 { 0064 return i18nc("@info", "This tool can convert documented images data to Text format " 0065 "by using Tesseract, an open-source Optical Characters Recognition engine, originally developed at HP labs and now sponsored by Google.\n\n" 0066 "It supports multiple languages and scripts (including right-to-left text) and page layout analysis.\n\n" 0067 "See details on %1 for more information on Tesseract", 0068 QLatin1String("<a href='https://github.com/tesseract-ocr/tesseract'>https://github.com/tesseract-ocr/tesseract</a>")); 0069 } 0070 0071 QString TextConverterPlugin::handbookSection() const 0072 { 0073 return QLatin1String("post_processing"); 0074 } 0075 0076 QString TextConverterPlugin::handbookChapter() const 0077 { 0078 return QLatin1String("ocrtext_converter"); 0079 } 0080 0081 QList<DPluginAuthor> TextConverterPlugin::authors() const 0082 { 0083 return QList<DPluginAuthor>() 0084 << DPluginAuthor(QString::fromUtf8("TRAN Quoc Hung"), 0085 QString::fromUtf8("quochungtran at gmail dot com"), 0086 QString::fromUtf8("(C) 2022")) 0087 ; 0088 } 0089 0090 void TextConverterPlugin::setup(QObject* const parent) 0091 { 0092 DPluginAction* const ac = new DPluginAction(parent); 0093 ac->setIcon(icon()); 0094 ac->setText(i18nc("@action", "OCR Text Converter...")); 0095 ac->setObjectName(QLatin1String("textconverter")); 0096 ac->setActionCategory(DPluginAction::GenericTool); 0097 0098 connect(ac, SIGNAL(triggered(bool)), 0099 this, SLOT(slotTextConverter())); 0100 0101 addAction(ac); 0102 } 0103 0104 void TextConverterPlugin::slotTextConverter() 0105 { 0106 QPointer<TextConverterDialog> dialog = new TextConverterDialog(nullptr, infoIface(sender())); 0107 dialog->setPlugin(this); 0108 dialog->exec(); 0109 delete dialog; 0110 } 0111 0112 } // namespace DigikamGenericTextConverterPlugin 0113 0114 #include "moc_textconverterplugin.cpp"