File indexing completed on 2024-12-15 03:43:13

0001 /*
0002     SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "%{APPNAMELC}shell.h"
0008 
0009 // KF headers
0010 #include <KAboutData>
0011 #include <KLocalizedString>
0012 
0013 // Qt headers
0014 #include <QApplication>
0015 #include <QCommandLineParser>
0016 #include <QUrl>
0017 #include <QDir>
0018 #include <QIcon>
0019 
0020 int main(int argc, char **argv)
0021 {
0022     QApplication app(argc, argv);
0023 
0024     KLocalizedString::setApplicationDomain("%{APPNAMELC}");
0025 
0026     KAboutData aboutData(QStringLiteral("%{APPNAMELC}"),
0027         i18n("%{APPNAME}"),
0028         QStringLiteral("%{VERSION}"),
0029         i18n("A KPart Application"),
0030         KAboutLicense::GPL,
0031         i18n("Copyright %{CURRENT_YEAR} %{AUTHOR}"));
0032     aboutData.addAuthor(i18n("%{AUTHOR}"), i18n("Author"), QStringLiteral("%{EMAIL}"));
0033     aboutData.setOrganizationDomain("example.org");
0034     aboutData.setDesktopFileName(QStringLiteral("org.example.%{APPNAMELC}"));
0035 
0036     KAboutData::setApplicationData(aboutData);
0037     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("%{APPNAMELC}")));
0038 
0039     QCommandLineParser parser;
0040     aboutData.setupCommandLine(&parser);
0041     parser.addPositionalArgument(QStringLiteral("urls"), i18n("Document(s) to load."), QStringLiteral("[urls...]"));
0042 
0043     parser.process(app);
0044     aboutData.processCommandLine(&parser);
0045 
0046     const auto urls = parser.positionalArguments();
0047 
0048     if (urls.isEmpty()) {
0049         auto window = new %{APPNAME}Shell;
0050         window->show();
0051     } else {
0052         for (const auto &url : urls) {
0053             auto window = new %{APPNAME}Shell;
0054             window->show();
0055             window->loadDocument(QUrl::fromUserInput(url, QDir::currentPath(), QUrl::AssumeLocalFile));
0056         }
0057     }
0058 
0059     return app.exec();
0060 }