main.cpp 3.53 KB
Newer Older
1
/***************************************************************************
2
 *   Copyright 2008-2009 Stefan Majewsky <majewsky@gmx.net>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public
 *   License as published by the Free Software Foundation; either
 *   version 2 of the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 ***************************************************************************/

19 20
#include "mainwindow.h"
#include "settings.h"
21
#include "kdiamond_version.h"
22

23
#include <ctime>
Laurent Montel's avatar
Laurent Montel committed
24 25

#include <KAboutData>
Frederik Schwarzer's avatar
Frederik Schwarzer committed
26
#include <KCrash>
Laurent Montel's avatar
Laurent Montel committed
27 28

#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
29

30
#include <KgDifficulty>
Laurent Montel's avatar
Migrate  
Laurent Montel committed
31
#include <kdelibs4configmigrator.h>
Laurent Montel's avatar
Laurent Montel committed
32 33
#include <QApplication>
#include <QCommandLineParser>
Laurent Montel's avatar
Laurent Montel committed
34
#include <QStandardPaths>
Laurent Montel's avatar
Dbus  
Laurent Montel committed
35
#include <KDBusService>
36 37 38

static const char description[] = I18N_NOOP("KDiamond, a three-in-a-row game.");

Laurent Montel's avatar
Laurent Montel committed
39
int main(int argc, char **argv)
40
{
Laurent Montel's avatar
Laurent Montel committed
41
    QApplication app(argc, argv);
42 43 44
    Kdelibs4ConfigMigrator migrate(QStringLiteral("kdiamond"));
    migrate.setConfigFiles(QStringList() << QStringLiteral("kdiamondrc") << QStringLiteral("kdiamond.notifyrc"));
    migrate.setUiFiles(QStringList() << QStringLiteral("kdiamondui.rc"));
Laurent Montel's avatar
Migrate  
Laurent Montel committed
45 46
    migrate.migrate();

Laurent Montel's avatar
Laurent Montel committed
47
    qsrand(time(nullptr));
Laurent Montel's avatar
Laurent Montel committed
48
    KLocalizedString::setApplicationDomain("kdiamond");
49
    KAboutData about(QStringLiteral("kdiamond"), i18nc("The application's name", "KDiamond"), QLatin1String(KDIAMOND_VERSION_STRING), i18n(description),
50
                     KAboutLicense::GPL, i18n("(C) 2008-2010 Stefan Majewsky and others"), QStringLiteral("https://kde.org/applications/games/org.kde.kdiamond"));
51 52 53 54 55
    about.addAuthor(i18n("Stefan Majewsky"), i18n("Original author and current maintainer"), QStringLiteral("majewsky@gmx.net"));
    about.addAuthor(i18n("Paul Bunbury"), i18n("Gameplay refinement"), QStringLiteral("happysmileman@googlemail.com"));
    about.addCredit(i18n("Eugene Trounev"), i18n("Default theme"), QStringLiteral("eugene.trounev@gmail.com"));
    about.addCredit(i18n("Felix Lemke"), i18n("Classic theme"), QStringLiteral("lemke.felix@ages-skripte.org"));
    about.addCredit(i18n("Jeffrey Kelling"), i18n("Technical consultant"), QStringLiteral("kelling.jeffrey@ages-skripte.org"));
Laurent Montel's avatar
Laurent Montel committed
56 57
    QCommandLineParser parser;
    KAboutData::setApplicationData(about);
Frederik Schwarzer's avatar
Frederik Schwarzer committed
58
    KCrash::initialize();
Laurent Montel's avatar
Laurent Montel committed
59 60 61
    about.setupCommandLine(&parser);
    parser.process(app);
    about.processCommandLine(&parser);
62

Albert Astals Cid's avatar
Albert Astals Cid committed
63 64
    app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdiamond")));

Laurent Montel's avatar
Laurent Montel committed
65
    //resource directory for KNewStuff2 (this call causes the directory to be created; its existence is necessary for the downloader)
66
    QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/themes/");
67

Laurent Montel's avatar
Laurent Montel committed
68 69 70 71
    Kg::difficulty()->addStandardLevelRange(
        KgDifficultyLevel::VeryEasy,
        KgDifficultyLevel::VeryHard
    );
72
    KDBusService service;
Laurent Montel's avatar
Laurent Montel committed
73 74
    // see if we are starting with session management
    if (app.isSessionRestored()) {
75
        kRestoreMainWindows<MainWindow>();
Laurent Montel's avatar
Laurent Montel committed
76 77 78 79 80
    } else {
        MainWindow *window = new MainWindow;
        window->show();
    }
    return app.exec();
81
}