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