File indexing completed on 2022-09-20 13:02:20

0001 /*
0002     SPDX-FileCopyrightText: 2008-2009 Stefan Majewsky <majewsky@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "mainwindow.h"
0008 #include "settings.h"
0009 #include "kdiamond_version.h"
0010 
0011 #include <ctime>
0012 
0013 #include <KAboutData>
0014 #include <KCrash>
0015 
0016 #include <KLocalizedString>
0017 
0018 #include <KgDifficulty>
0019 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0020 #include <kdelibs4configmigrator.h>
0021 #endif
0022 #include <QApplication>
0023 #include <QCommandLineParser>
0024 #include <QStandardPaths>
0025 #include <KDBusService>
0026 
0027 int main(int argc, char **argv)
0028 {
0029     // Fixes blurry icons with fractional scaling
0030 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0031     QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
0032 #endif
0033     QApplication app(argc, argv);
0034 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0035     Kdelibs4ConfigMigrator migrate(QStringLiteral("kdiamond"));
0036     migrate.setConfigFiles(QStringList() << QStringLiteral("kdiamondrc") << QStringLiteral("kdiamond.notifyrc"));
0037     migrate.setUiFiles(QStringList() << QStringLiteral("kdiamondui.rc"));
0038     migrate.migrate();
0039 #endif
0040 
0041     KLocalizedString::setApplicationDomain("kdiamond");
0042     KAboutData about(QStringLiteral("kdiamond"), i18nc("The application's name", "KDiamond"),
0043                      QStringLiteral(KDIAMOND_VERSION_STRING),
0044                      i18n("KDiamond, a three-in-a-row game."),
0045                      KAboutLicense::GPL, i18n("(C) 2008-2010 Stefan Majewsky and others"),
0046                      QString(),
0047                      QStringLiteral("https://apps.kde.org/kdiamond"));
0048     about.addAuthor(i18n("Stefan Majewsky"), i18n("Original author and current maintainer"), QStringLiteral("majewsky@gmx.net"));
0049     about.addAuthor(i18n("Paul Bunbury"), i18n("Gameplay refinement"), QStringLiteral("happysmileman@googlemail.com"));
0050     about.addCredit(i18n("Eugene Trounev"), i18n("Default theme"), QStringLiteral("eugene.trounev@gmail.com"));
0051     about.addCredit(i18n("Felix Lemke"), i18n("Classic theme"), QStringLiteral("lemke.felix@ages-skripte.org"));
0052     about.addCredit(i18n("Jeffrey Kelling"), i18n("Technical consultant"), QStringLiteral("kelling.jeffrey@ages-skripte.org"));
0053     QCommandLineParser parser;
0054     KAboutData::setApplicationData(about);
0055     KCrash::initialize();
0056     about.setupCommandLine(&parser);
0057     parser.process(app);
0058     about.processCommandLine(&parser);
0059 
0060     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdiamond")));
0061 
0062     //resource directory for KNewStuff2 (this call causes the directory to be created; its existence is necessary for the downloader)
0063     QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/themes/");
0064 
0065     Kg::difficulty()->addStandardLevelRange(
0066         KgDifficultyLevel::VeryEasy,
0067         KgDifficultyLevel::VeryHard
0068     );
0069     KDBusService service;
0070     // see if we are starting with session management
0071     if (app.isSessionRestored()) {
0072         kRestoreMainWindows<MainWindow>();
0073     } else {
0074         MainWindow *window = new MainWindow;
0075         window->show();
0076     }
0077     return app.exec();
0078 }