File indexing completed on 2024-10-06 03:45:27

0001 /*
0002     This file is part of the KDE games kwin4 program
0003     SPDX-FileCopyrightText: 1995-2007 Martin Heni <kde@heni-online.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 /**
0009  * \mainpage KWin4 API Documentation
0010  *
0011  * \section intro_sec Introduction
0012  *
0013  * This is the API documentation for the KDE game 'kwin4'.
0014  *
0015  * \section design_sec Design
0016  *
0017  * The design diagram shows the dependencies for the key classes of
0018  * the KWin4 program.
0019  * The coloring of the classes shows roughly their function in the
0020  * groups (program, document and engine, display, QGraphics and KGame library).
0021  *
0022  * \image html kwin4classes.png "Class diagram for KWin4"
0023  */
0024 
0025 // own
0026 #include "kfourinline_debug.h"
0027 #include "kfourinline_version.h"
0028 #include "kwin4.h"
0029 // KF
0030 #include <KAboutData>
0031 #include <KCrash>
0032 #include <KDBusService>
0033 #include <KLocalizedString>
0034 // Qt
0035 #include <QApplication>
0036 #include <QCommandLineOption>
0037 #include <QCommandLineParser>
0038 
0039 // Debug level for the program
0040 int global_debug = 0;
0041 // Skip intro
0042 bool global_skip_intro = false;
0043 // Demo (autoplay mode)
0044 bool global_demo_mode = false;
0045 
0046 // Main function
0047 int main(int argc, char *argv[])
0048 {
0049     global_debug = 0;
0050 
0051     QApplication app(argc, argv);
0052 
0053     KLocalizedString::setApplicationDomain(QByteArrayLiteral("kfourinline"));
0054 
0055     KAboutData aboutData(QStringLiteral("kfourinline"),
0056                          i18n("KFourInLine"),
0057                          QStringLiteral(KFOURINLINE_VERSION_STRING),
0058                          i18n("KFourInLine: Two player board game"),
0059                          KAboutLicense::GPL,
0060                          i18n("(c) 1995-2007, Martin Heni"));
0061     aboutData.addAuthor(i18n("Martin Heni"), i18n("Game design and code"), QStringLiteral("kde@heni-online.de"));
0062     aboutData.addAuthor(i18n("Johann Ollivier Lapeyre"), i18n("Graphics"), QStringLiteral("johann.ollivierlapeyre@gmail.com"));
0063     aboutData.addAuthor(i18n("Eugene Trounev"), i18n("Graphics"), QStringLiteral("eugene.trounev@gmail.com"));
0064     aboutData.addAuthor(i18n("Benjamin Meyer"), i18n("Code Improvements"));
0065     aboutData.setHomepage(QStringLiteral("https://apps.kde.org/kfourinline"));
0066 
0067     KAboutData::setApplicationData(aboutData);
0068 
0069     KCrash::initialize();
0070 
0071     QCommandLineParser parser;
0072     parser.addOption(QCommandLineOption({QStringLiteral("d"), QStringLiteral("debug")}, i18n("Enter debug level"), QStringLiteral("level")));
0073     parser.addOption(QCommandLineOption({QStringLiteral("skipintro")}, i18n("Skip intro animation")));
0074     parser.addOption(QCommandLineOption({QStringLiteral("demo")}, i18n("Run game in demo (autoplay) mode")));
0075 
0076     aboutData.setupCommandLine(&parser);
0077     parser.process(app);
0078     aboutData.processCommandLine(&parser);
0079 
0080     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kfourinline")));
0081     /* command line handling */
0082 
0083     // Check for debug command line option
0084     if (parser.isSet(QStringLiteral("debug"))) {
0085         global_debug = QString(parser.value(QStringLiteral("debug"))).toInt();
0086         qCDebug(KFOURINLINE_LOG) << "Debug level set to" << global_debug;
0087     }
0088     // Check for debug command line option
0089     if (parser.isSet(QStringLiteral("skipintro"))) {
0090         global_skip_intro = true;
0091         qCDebug(KFOURINLINE_LOG) << "Skip intro cmd line chosen" << global_skip_intro;
0092     }
0093     // Check for debug command line option
0094     if (parser.isSet(QStringLiteral("demo"))) {
0095         global_demo_mode = true;
0096         qCDebug(KFOURINLINE_LOG) << "Running in demo mode" << global_demo_mode;
0097     }
0098 
0099     KDBusService service;
0100 
0101     // Start application
0102     // Start session
0103     if (app.isSessionRestored()) {
0104         kRestoreMainWindows<KWin4App>();
0105     } else {
0106         KWin4App *kwin4 = new KWin4App();
0107         kwin4->show();
0108     }
0109 
0110     return app.exec();
0111 }