File indexing completed on 2024-12-08 04:00:44
0001 /* 0002 SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 // application 0008 #include "config.hpp" 0009 #include "window.hpp" 0010 // KF 0011 #include <KAboutData> 0012 #include <KLocalizedString> 0013 // Qt 0014 #include <QApplication> 0015 #include <QCommandLineParser> 0016 #include <QDir> 0017 #include <QUrl> 0018 #include <QIcon> 0019 0020 int main(int argc, char **argv) 0021 { 0022 QApplication application(argc, argv); 0023 0024 KLocalizedString::setApplicationDomain("kodaskanna"); 0025 0026 KAboutData aboutData(QStringLiteral("kodaskanna"), 0027 i18n("Kodaskanna"), 0028 QStringLiteral(KODASKANNA_VERSION), 0029 i18n("Utility to scan data from codes in graphical sources."), 0030 KAboutLicense::LGPL_V2_1, 0031 i18n("Copyright 2022, Friedrich W. H. Kossebau <kossebau@kde.org>"), 0032 QString(), 0033 QStringLiteral("https://commits.kde.org/kodaskanna")); 0034 0035 aboutData.addAuthor(i18n("Friedrich W. H. Kossebau"), i18n("Author"), QStringLiteral("kossebau@kde.org")); 0036 0037 KAboutData::setApplicationData(aboutData); 0038 application.setWindowIcon(QIcon::fromTheme(QStringLiteral("kodaskanna"))); 0039 0040 QCommandLineParser parser; 0041 aboutData.setupCommandLine(&parser); 0042 parser.addPositionalArgument(QStringLiteral("URL"), i18n("Image file to open."), QStringLiteral("[URL}")); 0043 0044 parser.process(application); 0045 aboutData.processCommandLine(&parser); 0046 0047 // empty name: show image select input 0048 QUrl sourceFileUrl; 0049 const QStringList positionalArguments = parser.positionalArguments(); 0050 if (positionalArguments.size() > 0) { 0051 const QString currentPath = QDir::currentPath(); 0052 sourceFileUrl = QUrl::fromUserInput(positionalArguments.first(), currentPath, QUrl::AssumeLocalFile); 0053 } 0054 0055 auto *window = new Kodaskanna::Window; 0056 window->show(); 0057 0058 window->scanFromFile(sourceFileUrl); 0059 0060 return application.exec(); 0061 }