File indexing completed on 2022-09-20 12:32:07

0001 /*
0002     SPDX-FileCopyrightText: 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
0003     SPDX-FileCopyrightText: 2006 Peter Hedlund <peter.hedlund@kdemail.net>
0004     SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 /// @file src/main.cpp
0009 
0010 #include "parleymainwindow.h"
0011 #include <config-parley.h>
0012 
0013 #include <KAboutData>
0014 #include <KCrash>
0015 #include <KLocalizedString>
0016 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0017 #include <Kdelibs4ConfigMigrator>
0018 #endif
0019 #include <QApplication>
0020 #include <QCommandLineParser>
0021 
0022 int main(int argc, char *argv[])
0023 {
0024     QApplication app(argc, argv);
0025 
0026     KLocalizedString::setApplicationDomain("parley");
0027 
0028     /* for migration*/
0029 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0030     QStringList configFiles;
0031     configFiles << QStringLiteral("parleyrc");
0032     Kdelibs4ConfigMigrator migrator(QStringLiteral("parley"));
0033     migrator.setConfigFiles(configFiles);
0034     migrator.migrate();
0035 #endif
0036 
0037     KAboutData aboutData(QStringLiteral("parley"), ki18n("Parley").toString(), PARLEY_VERSION_STRING);
0038     aboutData.setShortDescription(ki18n("Vocabulary Trainer").toString());
0039     aboutData.setLicense(KAboutLicense::GPL);
0040     aboutData.setCopyrightStatement(ki18n("© 1999-2002\tEwald Arnold\n"
0041                                           "© 2001-2002\tThe KDE team\n"
0042                                           "© 2004-2007\tPeter Hedlund\n"
0043                                           "© 2007-2010\tFrederik Gladhorn\n")
0044                                         .toString());
0045     aboutData.setOtherText(ki18n("Helps you train your vocabulary").toString());
0046     aboutData.setHomepage(QStringLiteral("https://edu.kde.org/parley"));
0047     aboutData.setBugAddress("submit@bugs.kde.org");
0048 
0049     aboutData.addAuthor(ki18n("Inge Wallin").toString(), ki18n("Developer and Co-maintainer").toString(), QStringLiteral("inge@lysator.liu.se"));
0050 
0051     aboutData.addAuthor(ki18n("Amarvir Singh").toString(), ki18n("Developer and Co-maintainer").toString(), QStringLiteral("amarvir.ammu.93@gmail.com"));
0052 
0053     aboutData.addAuthor(ki18n("Frederik Gladhorn").toString(), ki18n("Developer, former maintainer").toString(), QStringLiteral("gladhorn@kde.org"));
0054 
0055     aboutData.addAuthor(ki18n("Daniel Laidig").toString(), ki18n("Developer").toString(), QStringLiteral("d.laidig@gmx.de"));
0056 
0057     aboutData.addAuthor(ki18n("David Capel").toString(), ki18n("Practice Dialogs").toString(), QStringLiteral("wot.narg@gmail.com"));
0058 
0059     aboutData.addAuthor(ki18n("Avgoustinos Kadis").toString(), ki18n("Scripting").toString(), QStringLiteral("avgoustinos.kadis@kdemail.net"));
0060 
0061     aboutData.addAuthor(ki18n("Peter Hedlund").toString(),
0062                         ki18n("Countless fixes, former maintainer, port to KDE4").toString(),
0063                         QStringLiteral("peter.hedlund@kdemail.net"));
0064 
0065     aboutData.addAuthor(ki18n("Ewald Arnold").toString(),
0066                         ki18n("Original Author").toString(),
0067                         QStringLiteral("kvoctrain@ewald-arnold.de"),
0068                         QStringLiteral("http://www.ewald-arnold.de"));
0069 
0070     aboutData.addCredit(ki18n("Lee Olson").toString(), ki18n("Artwork and Oxygen Icons").toString());
0071 
0072     aboutData.addCredit(ki18n("Anne-Marie Mahfouf").toString(), ki18n("Port to KConfig XT").toString());
0073 
0074     aboutData.addCredit(ki18n("Jeremy Whiting").toString(), ki18n("Rewriting the kvtml library for KDE4").toString());
0075 
0076     aboutData.addCredit(ki18n("Markus Büchele").toString(), ki18n("Bug reports and testing on the way to KDE4").toString());
0077 
0078     aboutData.addCredit(ki18n("Ramona Knapp").toString(), ki18n("Conceived the name Parley").toString());
0079 
0080     KAboutData::setApplicationData(aboutData);
0081 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0082     app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0083 #endif
0084     QApplication::setApplicationName(QStringLiteral("parley"));
0085     QApplication::setApplicationVersion(PARLEY_VERSION_STRING);
0086     QApplication::setOrganizationDomain(QStringLiteral("kde.org"));
0087 
0088     KCrash::initialize();
0089 
0090     QCommandLineParser parser;
0091     parser.addPositionalArgument(ki18n("[file]").toString(), ki18n("Document file to open").toString());
0092 
0093     aboutData.setupCommandLine(&parser);
0094     parser.process(app);
0095     aboutData.processCommandLine(&parser);
0096 
0097     if (app.isSessionRestored()) {
0098         int n = 1;
0099         while (KMainWindow::canBeRestored(n)) {
0100             (new ParleyMainWindow())->restore(n);
0101             n++;
0102         }
0103         return app.exec();
0104     } else {
0105         KMainWindow *parleyApp;
0106 
0107         const QStringList args = parser.positionalArguments();
0108 
0109         if (!args.isEmpty()) {
0110             parleyApp = new ParleyMainWindow(QUrl::fromLocalFile(args.first()));
0111         } else {
0112             parleyApp = new ParleyMainWindow();
0113         }
0114 
0115         parleyApp->show();
0116         return app.exec();
0117     }
0118 }