File indexing completed on 2024-11-17 03:48:12

0001 /*
0002     SPDX-FileCopyrightText: 1998-2000 Anders Widell <awl@passagen.se>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "MainWindow.h"
0008 #include "version.h"
0009 
0010 #include <KCrash>
0011 #include <KDBusService>
0012 #include <KAboutData>
0013 #include <KLocalizedString>
0014 
0015 #include <QApplication>
0016 #include <QCommandLineOption>
0017 #include <QCommandLineParser>
0018 #include <QDir>
0019 
0020 int main(int argc, char **argv)
0021 {
0022 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0023     QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
0024 #endif
0025     QApplication app(argc, argv);
0026     KLocalizedString::setApplicationDomain("skladnik");
0027 
0028     KAboutData aboutData(QStringLiteral("skladnik"),
0029                          i18n("Skladnik"),
0030                          QStringLiteral(SKLADNIK_VERSION_STRING),
0031                          i18n("The japanese warehouse keeper game"),
0032                          KAboutLicense::GPL,
0033                          i18n("(c) 1998 Anders Widell <awl@hem.passagen.se>\n(c) 2012 Lukasz Kalamlacki"),
0034                          QString(),
0035                          QStringLiteral("https://apps.kde.org/skladnik"));
0036     aboutData.addAuthor(i18n("Shlomi Fish"),
0037                         i18n("For porting to Qt5/KF5 and doing other cleanups"),
0038                         QStringLiteral("shlomif@cpan.org"),
0039                         QStringLiteral("https://www.shlomifish.org/"));
0040     aboutData.addAuthor(i18n("Lukasz Kalamlacki"),
0041                         i18n("For rewriting the original ksokoban game from kde3 to kde4"),
0042                         QStringLiteral("kalamlacki@gmail.com"),
0043                         QStringLiteral("https://sourceforge.net/projects/ksokoban/"));
0044     aboutData.addAuthor(i18n("Anders Widell"),
0045                         i18n("For writing the original ksokoban game"),
0046                         QStringLiteral("awl@hem.passagen.se"),
0047                         QStringLiteral("http://hem.passagen.se/awl/ksokoban/"));
0048     aboutData.addCredit(i18n("David W. Skinner"),
0049                         i18n("For contributing the Sokoban levels included in this game"),
0050                         QStringLiteral("sasquatch@bentonrea.com"),
0051                         QStringLiteral("http://users.bentonrea.com/~sasquatch/"));
0052 
0053     KAboutData::setApplicationData(aboutData);
0054 
0055     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("skladnik")));
0056 
0057     KCrash::initialize();
0058 
0059     QCommandLineParser parser;
0060     parser.addPositionalArgument(QStringLiteral("URL"), i18n("Level collection file to load."), QStringLiteral("[URL}"));
0061     aboutData.setupCommandLine(&parser);
0062     parser.process(app);
0063     aboutData.processCommandLine(&parser);
0064 
0065     KDBusService service;
0066 
0067     auto *widget = new MainWindow();
0068     widget->show();
0069 
0070     const QStringList positionalArguments = parser.positionalArguments();
0071     if (!positionalArguments.isEmpty()) {
0072         const QString currentPath = QDir::currentPath();
0073         const QUrl levelFileUrl = QUrl::fromUserInput(positionalArguments.first(), currentPath, QUrl::AssumeLocalFile);
0074         widget->openURL(levelFileUrl);
0075     }
0076 
0077     return app.exec();
0078 }