File indexing completed on 2024-05-19 05:47:14

0001 /***************************************************************************
0002  *   Copyright 2008-2009 Stefan Majewsky <majewsky@gmx.net>
0003  *
0004  *   This program is free software; you can redistribute it and/or
0005  *   modify it under the terms of the GNU General Public
0006  *   License as published by the Free Software Foundation; either
0007  *   version 2 of the License, or (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details.
0013  *
0014  *   You should have received a copy of the GNU General Public License
0015  *   along with this program; if not, write to the Free Software
0016  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  ***************************************************************************/
0018 
0019 #include "mainwindow.h"
0020 #include "settings.h"
0021 #include "kdiamond_version.h"
0022 
0023 #include <ctime>
0024 
0025 #include <KAboutData>
0026 #include <KCrash>
0027 
0028 #include <KLocalizedString>
0029 
0030 #include <KgDifficulty>
0031 #include <kdelibs4configmigrator.h>
0032 #include <QApplication>
0033 #include <QCommandLineParser>
0034 #include <QStandardPaths>
0035 #include <KDBusService>
0036 
0037 static const char description[] = I18N_NOOP("KDiamond, a three-in-a-row game.");
0038 
0039 int main(int argc, char **argv)
0040 {
0041     // Fixes blurry icons with fractional scaling
0042     QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
0043     QApplication app(argc, argv);
0044     Kdelibs4ConfigMigrator migrate(QStringLiteral("kdiamond"));
0045     migrate.setConfigFiles(QStringList() << QStringLiteral("kdiamondrc") << QStringLiteral("kdiamond.notifyrc"));
0046     migrate.setUiFiles(QStringList() << QStringLiteral("kdiamondui.rc"));
0047     migrate.migrate();
0048 
0049     KLocalizedString::setApplicationDomain("kdiamond");
0050     KAboutData about(QStringLiteral("kdiamond"), i18nc("The application's name", "KDiamond"), QLatin1String(KDIAMOND_VERSION_STRING), i18n(description),
0051                      KAboutLicense::GPL, i18n("(C) 2008-2010 Stefan Majewsky and others"), QStringLiteral("https://kde.org/applications/games/org.kde.kdiamond"));
0052     about.addAuthor(i18n("Stefan Majewsky"), i18n("Original author and current maintainer"), QStringLiteral("majewsky@gmx.net"));
0053     about.addAuthor(i18n("Paul Bunbury"), i18n("Gameplay refinement"), QStringLiteral("happysmileman@googlemail.com"));
0054     about.addCredit(i18n("Eugene Trounev"), i18n("Default theme"), QStringLiteral("eugene.trounev@gmail.com"));
0055     about.addCredit(i18n("Felix Lemke"), i18n("Classic theme"), QStringLiteral("lemke.felix@ages-skripte.org"));
0056     about.addCredit(i18n("Jeffrey Kelling"), i18n("Technical consultant"), QStringLiteral("kelling.jeffrey@ages-skripte.org"));
0057     QCommandLineParser parser;
0058     KAboutData::setApplicationData(about);
0059     KCrash::initialize();
0060     about.setupCommandLine(&parser);
0061     parser.process(app);
0062     about.processCommandLine(&parser);
0063 
0064     app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdiamond")));
0065 
0066     //resource directory for KNewStuff2 (this call causes the directory to be created; its existence is necessary for the downloader)
0067     QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/themes/");
0068 
0069     Kg::difficulty()->addStandardLevelRange(
0070         KgDifficultyLevel::VeryEasy,
0071         KgDifficultyLevel::VeryHard
0072     );
0073     KDBusService service;
0074     // see if we are starting with session management
0075     if (app.isSessionRestored()) {
0076         kRestoreMainWindows<MainWindow>();
0077     } else {
0078         MainWindow *window = new MainWindow;
0079         window->show();
0080     }
0081     return app.exec();
0082 }