File indexing completed on 2023-11-26 10:50:28

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 <KLocalizedString>
0033 // Qt
0034 #include <QApplication>
0035 #include <QCommandLineOption>
0036 #include <QCommandLineParser>
0037 
0038 // Debug level for the program
0039 int global_debug = 0;
0040 // Skip intro
0041 bool global_skip_intro = false;
0042 // Demo (autoplay mode)
0043 bool global_demo_mode = false;
0044 
0045 // Main function
0046 int main(int argc, char *argv[])
0047 {
0048     global_debug = 0;
0049 
0050     QApplication app(argc, argv);
0051 
0052     KLocalizedString::setApplicationDomain("kfourinline");
0053     KAboutData aboutData(QStringLiteral("kfourinline"),
0054                          i18n("KFourInLine"),
0055                          QStringLiteral(KFOURINLINE_VERSION_STRING),
0056                          i18n("KFourInLine: Two player board game"),
0057                          KAboutLicense::GPL,
0058                          i18n("(c) 1995-2007, Martin Heni"));
0059     aboutData.addAuthor(i18n("Martin Heni"), i18n("Game design and code"), QStringLiteral("kde@heni-online.de"));
0060     aboutData.addAuthor(i18n("Johann Ollivier Lapeyre"), i18n("Graphics"), QStringLiteral("johann.ollivierlapeyre@gmail.com"));
0061     aboutData.addAuthor(i18n("Eugene Trounev"), i18n("Graphics"), QStringLiteral("eugene.trounev@gmail.com"));
0062     aboutData.addAuthor(i18n("Benjamin Meyer"), i18n("Code Improvements"));
0063     aboutData.setHomepage(QStringLiteral("https://apps.kde.org/kfourinline"));
0064     QCommandLineParser parser;
0065     KAboutData::setApplicationData(aboutData);
0066     KCrash::initialize();
0067     parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("d") << QStringLiteral("debug"), i18n("Enter debug level"), QStringLiteral("level")));
0068     parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("skipintro"), i18n("Skip intro animation")));
0069     parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("demo"), i18n("Run game in demo (autoplay) mode")));
0070 
0071     aboutData.setupCommandLine(&parser);
0072     parser.process(app);
0073     aboutData.processCommandLine(&parser);
0074 
0075     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kfourinline")));
0076     /* command line handling */
0077 
0078     // Check for debug command line option
0079     if (parser.isSet(QStringLiteral("debug"))) {
0080         global_debug = QString(parser.value(QStringLiteral("debug"))).toInt();
0081         qCDebug(KFOURINLINE_LOG) << "Debug level set to" << global_debug;
0082     }
0083     // Check for debug command line option
0084     if (parser.isSet(QStringLiteral("skipintro"))) {
0085         global_skip_intro = true;
0086         qCDebug(KFOURINLINE_LOG) << "Skip intro cmd line chosen" << global_skip_intro;
0087     }
0088     // Check for debug command line option
0089     if (parser.isSet(QStringLiteral("demo"))) {
0090         global_demo_mode = true;
0091         qCDebug(KFOURINLINE_LOG) << "Running in demo mode" << global_demo_mode;
0092     }
0093 
0094     // Start application
0095     // Start session
0096     if (app.isSessionRestored()) {
0097         kRestoreMainWindows<KWin4App>();
0098     } else {
0099         KWin4App *kwin4 = new KWin4App();
0100         kwin4->show();
0101     }
0102 
0103     return app.exec();
0104 }