File indexing completed on 2024-05-12 16:45:29

0001 /***************************************************************************
0002  * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr
0003  * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  ***************************************************************************/
0006 /** @file
0007 * This file defines the main of SKGMyAppliTest.
0008 *
0009 * @author Stephane MANKOWSKI / Guillaume DE BURE
0010  */
0011 #include "skguniqueapplication.h"
0012 #include "skgdocument.h"
0013 #include "skgtraces.h"
0014 
0015 #include <kaboutdata.h>
0016 
0017 #include <qcommandlineparser.h>
0018 #include <qcommandlineoption.h>
0019 
0020 /**
0021  * The main of the application
0022  * @param argc number of arguments
0023  * @param argv arguments
0024  * @return return code
0025  */
0026 int main(int argc, char** argv)
0027 {
0028     KAboutData about("skgmyapplitest",
0029                      0,
0030                      ki18nc("The name of the application", "SKGMyAppliTest"),
0031                      "0.1.0",
0032                      ki18nc("The description of the application", "Blablabla"),
0033                      KAboutLicense::GPL_V3,
0034                      i18nc("Fullname", "(c) 2007-%1 Stephane MANKOWSKI & Guillaume DE BURE", QDate::currentDate().toString(QStringLiteral("yyyy"))),
0035                      "",
0036                      "https://skrooge.org");
0037 
0038     about.addAuthor(ki18nc("Fullname", "Stephane MANKOWSKI"), ki18nc("A job description", "Architect & Developer"), "stephane@mankowski.fr");
0039     about.setOtherText(ki18nc("The description of the application", "An application test."));
0040 
0041     QApplication app(argc, argv);
0042     QCommandLineParser parser;
0043     KAboutData::setApplicationData(aboutData);
0044     app.setApplicationName(aboutData.componentName());
0045     app.setApplicationDisplayName(aboutData.displayName());
0046     app.setOrganizationDomain(aboutData.organizationDomain());
0047     app.setApplicationVersion(aboutData.version());
0048     parser.addVersionOption();
0049     parser.addHelpOption();
0050     //PORTING SCRIPT: adapt aboutdata variable if necessary
0051     aboutData.setupCommandLine(&parser);
0052     parser.process(app);
0053     aboutData.processCommandLine(&parser);
0054 
0055     parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("+[URL]"), i18nc("Application argument", "Document to open")));
0056 
0057     int rc = 0;
0058     if (!SKGUniqueApplication::start()) {
0059         fprintf(stderr, "SKGMyAppliTest is already running!\n");
0060     } else {
0061         // Creating a main panel on a generic document
0062         SKGDocument doc;
0063         SKGUniqueApplication kApp(&doc);
0064 
0065         rc = kApp.exec();  // krazy:exclude=crashy
0066     }
0067     SKGTraces::dumpProfilingStatistics();
0068     return rc;
0069 }