File indexing completed on 2024-03-03 04:14:06

0001 /*
0002     This file is part of the KDE games lskat program
0003     SPDX-FileCopyrightText: 2006 Martin Heni <kde@heni-online.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 
0007                           Lskat
0008                           -----
0009     begin                : March 2000
0010     copyright            : (C) 1995-2007 by Martin Heni
0011     email                : kde@heni-online.de
0012 */
0013 
0014 /**
0015  * \mainpage LSkat API Documentation
0016  *
0017  * \section intro_sec Introduction
0018  *
0019  * This is the API documentation for the KDE game 'lskat'.
0020  *
0021  * \section design_sec Design
0022  *
0023  * The design diagram shows the dependencies for the key classes of
0024  * the Lskat program.
0025  * The coloring of the classes shows roughly their function in the
0026  * groups (program, document and engine, display, QGraphics).
0027  *
0028  * \image html lskatclasses.png "Class diagram for LSkat"
0029  */
0030 
0031 
0032 
0033 #include "lskat_debug.h"
0034 #include "lskat_version.h"
0035 #include "lskatglobal.h"
0036 #include "mainwindow.h"
0037 
0038 #include <KAboutData>
0039 #include <KDBusService>
0040 #include <KCrash>
0041 #include <KLocalizedString>
0042 
0043 #include <QApplication>
0044 #include <QCommandLineParser>
0045 #include <QCommandLineOption>
0046 
0047 
0048 // Debug level for the program
0049 int global_debug = 0;
0050 // Skip intro
0051 bool global_skip_intro = false;
0052 // Demo (autoplay mode)
0053 bool global_demo_mode  = false;
0054 
0055 int main(int argc, char *argv[])
0056 {
0057     global_debug = 0;
0058 
0059     QApplication application(argc, argv);
0060     KLocalizedString::setApplicationDomain(QByteArrayLiteral("lskat"));
0061 
0062     KAboutData aboutData(QStringLiteral("lskat"), i18n("LSkat"),
0063                           QStringLiteral(LSKAT_VERSION_STRING),
0064                           i18n("LSkat: A desktop card game"),
0065                           KAboutLicense::GPL,
0066                           i18n("(c) 1995-2007, Martin Heni"),
0067                           QString(),
0068                           QStringLiteral("https://apps.kde.org/lskat"));
0069 
0070     // I18N: These are the same strings as in kwin4, you can copy the translations
0071     aboutData.addAuthor(i18n("Martin Heni"), i18n("Game design and code"), QStringLiteral("kde@heni-online.de"));
0072     aboutData.addAuthor(i18n("Eugene Trounev"), i18n("Graphics"), QStringLiteral("eugene.trounev@gmail.com"));
0073     // end I18N
0074     aboutData.addAuthor(i18n("Benjamin Meyer"), i18n("Code Improvements"));
0075     // 'Thanks to' aboutData.addCredit(i18n("KDE"), i18n("KDE"));
0076 
0077     KAboutData::setApplicationData(aboutData);
0078     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("lskat")));
0079 
0080     QCommandLineParser parser;
0081     parser.addOption(QCommandLineOption({QStringLiteral("d"), QStringLiteral("debug")}, i18n("Enter debug level"), QStringLiteral("level")));
0082     parser.addOption(QCommandLineOption({QStringLiteral("skipintro")}, i18n("Skip intro animation")));
0083     parser.addOption(QCommandLineOption({QStringLiteral("demo")}, i18n("Run game in demo (autoplay) mode")));
0084     aboutData.setupCommandLine(&parser);
0085     parser.process(application);
0086     aboutData.processCommandLine(&parser);
0087 
0088     /* command line handling */
0089 
0090     KCrash::initialize();
0091     KDBusService service;
0092 
0093     // Check for debug command line option
0094     if (parser.isSet(QStringLiteral("debug")))
0095     {
0096         global_debug = QString(parser.value(QStringLiteral("debug"))).toInt();
0097         qCDebug(LSKAT_LOG) << "Debug level set to" << global_debug;
0098     }
0099     // Check for debug command line option
0100     if (parser.isSet(QStringLiteral("skipintro")))
0101     {
0102         global_skip_intro = true;
0103         qCDebug(LSKAT_LOG) << "Skip intro cmd line chosen" << global_skip_intro;
0104     }
0105     // Check for debug command line option
0106     if (parser.isSet(QStringLiteral("demo")))
0107     {
0108         global_demo_mode = true;
0109         qCDebug(LSKAT_LOG) << "Running in demo mode" << global_demo_mode;
0110     }
0111 
0112     if (application.isSessionRestored())
0113     {
0114         kRestoreMainWindows<Mainwindow>();
0115     }
0116     else
0117     {
0118         Mainwindow *mainwindow = new Mainwindow();
0119         mainwindow->show();
0120     }
0121 
0122     return application.exec();
0123 }