File indexing completed on 2024-04-14 14:35:57

0001 /************************************************************************
0002  *                                  *
0003  *  This file is part of Kooka, a scanning/OCR application using    *
0004  *  Qt <http://www.qt.io> and KDE Frameworks <http://www.kde.org>.  *
0005  *                                  *
0006  *  Copyright (C) 1999-2016 Klaas Freitag <freitag@suse.de>     *
0007  *                          Jonathan Marten <jjm@keelhaul.me.uk>    *
0008  *                                  *
0009  *  Kooka is free software; you can redistribute it and/or modify it    *
0010  *  under the terms of the GNU Library General Public License as    *
0011  *  published by the Free Software Foundation and appearing in the  *
0012  *  file COPYING included in the packaging of this file;  either    *
0013  *  version 2 of the License, or (at your option) any later version.    *
0014  *                                  *
0015  *  As a special exception, permission is given to link this program    *
0016  *  with any version of the KADMOS OCR/ICR engine (a product of     *
0017  *  reRecognition GmbH, Kreuzlingen), and distribute the resulting  *
0018  *  executable without including the source code for KADMOS in the  *
0019  *  source distribution.                        *
0020  *                                  *
0021  *  This program is distributed in the hope that it will be useful, *
0022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of  *
0023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *
0024  *  GNU General Public License for more details.            *
0025  *                                  *
0026  *  You should have received a copy of the GNU General Public       *
0027  *  License along with this program;  see the file COPYING.  If     *
0028  *  not, see <http://www.gnu.org/licenses/>.                *
0029  *                                  *
0030  ************************************************************************/
0031 
0032 #include <qapplication.h>
0033 #include <qcommandlineparser.h>
0034 
0035 #include <kaboutdata.h>
0036 #include <klocalizedstring.h>
0037 
0038 #include "kooka.h"
0039 #include "vcsversion.h"
0040 #include "kooka_logging.h"
0041 
0042 
0043 static const char shortDesc[] =
0044     I18N_NOOP("Scanning, image gallery and OCR");
0045 
0046 static const char longDesc[] =
0047     I18N_NOOP("Kooka provides access to scanner hardware using the "
0048               "<a href=\"http://www.sane-project.org/\">SANE</a> library."
0049               "\n\n"
0050               "Kooka allows you to scan, save and view in any image format that KDE supports, "
0051               "and can perform Optical Character Recognition using the open source "
0052               "<a href=\"http://jocr.sourceforge.net/\">GOCR</a> or "
0053               "<a href=\"http://www.gnu.org/software/ocrad/ocrad.html\">OCRAD</a> programs, "
0054               "or the commercial <a href=\"http://www.rerecognition.com/\">KADMOS</a> library.");
0055 
0056 static const char addLicense[] =
0057     I18N_NOOP("This program is distributed under the terms of the GPL v2 as published\n"
0058               "by the Free Software Foundation.\n"
0059               "\n"
0060               "As a special exception, permission is given to link this program\n"
0061               "with any version of the KADMOS OCR/ICR engine of reRecognition GmbH\n"
0062               "(http://www.rerecognition.com), and distribute the resulting executable\n"
0063               "without including the source code for KADMOS in the source distribution.\n"
0064               "\n"
0065               "Note that linking against KADMOS is not permitted under the terms of\n"
0066               "the Qt GPL licence, so if you wish to do this then you must have a\n"
0067               "commercial Qt development licence.\n");
0068 
0069 static const char copyright[] =
0070     I18N_NOOP("(C) 2000-2018, the Kooka developers and contributors");
0071 
0072 
0073 int main(int argc, char *argv[])
0074 {
0075     QApplication app(argc, argv);           // first of all, so that i18n() works
0076     KLocalizedString::setApplicationDomain("kooka");
0077     KAboutData about("kooka",                   // componentName
0078                      i18n("Kooka"),             // displayName
0079 #if VCS_AVAILABLE
0080                      (VERSION " (" VCS_TYPE " " VCS_REVISION ")"),
0081 #else
0082                      "VERSION",             // version
0083 #endif
0084                      i18n(shortDesc),               // shortDescription
0085                      KAboutLicense::GPL_V2,         // licenseType
0086                      i18n(copyright),               // copyrightStatement
0087                      i18n(longDesc),                // otherText
0088                      "http://techbase.kde.org/Projects/Kooka"); // homePageAddress
0089 
0090     about.addAuthor(i18n("Jonathan Marten"), i18n("Current maintainer, KDE4 port"), "jjm@keelhaul.me.uk");
0091     about.addAuthor(i18n("Montel Laurent"), i18n("Initial KF5 port"), "montel@kde.org");
0092     about.addAuthor(i18n("Klaas Freitag"), i18n("Developer"), "freitag@suse.de");
0093     about.addCredit(i18n("Mat Colton"), i18n("Graphics, web"), "mat@colton.de");
0094     about.addCredit(i18n("Ivan Shvedunov"), i18n("Original kscan application"), "ivan@rf-hp.npi.msu.su");
0095     about.addCredit(i18n("Alex Kempshall"), i18n("Photocopy facility"), "alexkempshall@btinternet.com");
0096     about.addLicenseText(i18n(addLicense));
0097 
0098     KAboutData::setApplicationData(about);
0099 
0100     QCommandLineParser parser;
0101     parser.setApplicationDescription(about.shortDescription());
0102     parser.addHelpOption();
0103     parser.addVersionOption();
0104 
0105     QCommandLineOption opt = QCommandLineOption("g", i18n("Gallery mode - do not connect to scanner"));
0106     parser.addOption(opt);
0107 
0108     opt = QCommandLineOption("d", i18n("The SANE device specification (e.g. 'umax:/dev/sg0')"), i18n("device"));
0109     parser.addOption(opt);
0110 
0111     parser.process(app);
0112 
0113     QString devToUse = parser.value("d");
0114     if (parser.isSet("g")) devToUse = "gallery";
0115     qCDebug(KOOKA_LOG) << "device to use" << devToUse;
0116 
0117     // TODO: try ScanGlobal::init(), if that fails no point in carrying on
0118     // so show an error box and give up (or can we carry on and run in
0119     // gallery mode only?)
0120 
0121     Kooka *kooka = new Kooka(devToUse.toLocal8Bit());
0122     kooka->show();
0123     app.processEvents();
0124     kooka->startup();
0125 
0126     return (app.exec());
0127 }