File indexing completed on 2024-04-28 07:54:58

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 <KCrash>
0040 #include <KLocalizedString>
0041 
0042 #include <QApplication>
0043 #include <QCommandLineParser>
0044 #include <QCommandLineOption>
0045 
0046 
0047 // Debug level for the program
0048 int global_debug = 0;
0049 // Skip intro
0050 bool global_skip_intro = false;
0051 // Demo (autoplay mode)
0052 bool global_demo_mode  = false;
0053 
0054 int main(int argc, char *argv[])
0055 {
0056     global_debug = 0;
0057 
0058     QApplication application(argc, argv);
0059     KLocalizedString::setApplicationDomain("lskat");
0060 
0061     KAboutData aboutData(QStringLiteral("lskat"), i18n("LSkat"),
0062                           QStringLiteral(LSKAT_VERSION_STRING),
0063                           i18n("LSkat: A desktop card game"),
0064                           KAboutLicense::GPL,
0065                           i18n("(c) 1995-2007, Martin Heni"),
0066                           QString(),
0067                           QStringLiteral("https://apps.kde.org/lskat"));
0068 
0069     // I18N: These are the same strings as in kwin4, you can copy the translations
0070     aboutData.addAuthor(i18n("Martin Heni"), i18n("Game design and code"), QStringLiteral("kde@heni-online.de"));
0071     aboutData.addAuthor(i18n("Eugene Trounev"), i18n("Graphics"), QStringLiteral("eugene.trounev@gmail.com"));
0072     // end I18N
0073     aboutData.addAuthor(i18n("Benjamin Meyer"), i18n("Code Improvements"));
0074     // 'Thanks to' aboutData.addCredit(i18n("KDE"), i18n("KDE"));
0075 
0076     KAboutData::setApplicationData(aboutData);
0077     QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("lskat")));
0078 
0079     QCommandLineParser parser;
0080     parser.addOption(QCommandLineOption({QStringLiteral("d"), QStringLiteral("debug")}, i18n("Enter debug level"), QStringLiteral("level")));
0081     parser.addOption(QCommandLineOption({QStringLiteral("skipintro")}, i18n("Skip intro animation")));
0082     parser.addOption(QCommandLineOption({QStringLiteral("demo")}, i18n("Run game in demo (autoplay) mode")));
0083     aboutData.setupCommandLine(&parser);
0084     parser.process(application);
0085     aboutData.processCommandLine(&parser);
0086 
0087     /* command line handling */
0088 
0089     KCrash::initialize();
0090 
0091     // Check for debug command line option
0092     if (parser.isSet(QStringLiteral("debug")))
0093     {
0094         global_debug = QString(parser.value(QStringLiteral("debug"))).toInt();
0095         qCDebug(LSKAT_LOG) << "Debug level set to" << global_debug;
0096     }
0097     // Check for debug command line option
0098     if (parser.isSet(QStringLiteral("skipintro")))
0099     {
0100         global_skip_intro = true;
0101         qCDebug(LSKAT_LOG) << "Skip intro cmd line chosen" << global_skip_intro;
0102     }
0103     // Check for debug command line option
0104     if (parser.isSet(QStringLiteral("demo")))
0105     {
0106         global_demo_mode = true;
0107         qCDebug(LSKAT_LOG) << "Running in demo mode" << global_demo_mode;
0108     }
0109 
0110     if (application.isSessionRestored())
0111     {
0112         kRestoreMainWindows<Mainwindow>();
0113     }
0114     else
0115     {
0116         Mainwindow *mainwindow = new Mainwindow();
0117         mainwindow->show();
0118     }
0119 
0120     return application.exec();
0121 }