main.cpp 4.17 KB
Newer Older
1 2 3 4
/***************************************************************************
 *   Copyright 2005-2007 Francesco Rossi <redsh@email.it>                  *
 *   Copyright 2006-2007 Mick Kappenburg <ksudoku@kappendburg.net>         *
 *   Copyright 2006-2007 Johannes Bergmeier <johannes.bergmeier@gmx.net>   *
5
 *   Copyright 2015      Ian Wadham <iandw.au@gmail.com>                   *
6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *                                                                         *
 *   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.,                                       *
Johannes Bergmeier's avatar
Johannes Bergmeier committed
20
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
21
 ***************************************************************************/
22 23

#include "ksudoku.h"
24 25

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

30 31 32 33
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDir>
34
#include <QUrl>
35

36
#include <cstdlib>
37
#include <ctime>
38

Johannes Bergmeier's avatar
Johannes Bergmeier committed
39

40
static const char description[] =
Johannes Bergmeier's avatar
Johannes Bergmeier committed
41
    I18N_NOOP("KSudoku - Sudokus and more");
42

43
static const char version[] = "1.3";
44 45 46 47


int main(int argc, char **argv)
{
48
	qsrand(std::time(nullptr));
49 50
	QApplication app(argc, argv);
	KLocalizedString::setApplicationDomain("ksudoku");
51

52 53
	KAboutData about("ksudoku",
	                 i18n("KSudoku"),
Johannes Bergmeier's avatar
Johannes Bergmeier committed
54
	                 version,
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	                 i18n(description),
	                 KAboutLicense::GPL_V2,
	                 i18n("(c) 2005-2007 The KSudoku Authors"),
	                 QString(), "https://games.kde.org/game.php?game=ksudoku");
	about.addAuthor( i18n("Francesco Rossi"), i18n("KSudoku Author"), "redsh@email.it" );
	about.addAuthor( i18n("Johannes Bergmeier"), i18n("Maintainer"), "Johannes.Bergmeier@gmx.net" );
	about.addAuthor( i18n("Ian Wadham"), i18n("New puzzle generator and solver"), "iandw.au@gmail.com" );
	about.addAuthor( i18n("Mick Kappenburg"), i18n("Printing and export of 0.4"), "ksudoku@kappendburg.net");
	about.addAuthor( i18n("Thanks to NeHe for OpenGL tutorials"), QString(), "nehe.gamedev.net");
	about.addCredit( i18n("David Bau"), i18n("Algorithms for new puzzle generator and solver at davidbau.com/archives/2006/09/04/sudoku_generator.html"), "");

	KAboutData::setApplicationData(about);
	app.setOrganizationDomain(QStringLiteral("kde.org"));
	app.setWindowIcon(QIcon::fromTheme(QStringLiteral("ksudoku")));

	QCommandLineParser parser;
	about.setupCommandLine(&parser);
	parser.addVersionOption();
	parser.addHelpOption();
	parser.addPositionalArgument(QLatin1String("[URL]"), i18n( "Document to open" ));

	parser.process(app);
	about.processCommandLine(&parser);

	KCrash::initialize();
Frederik Schwarzer's avatar
Frederik Schwarzer committed
80

81 82
	// register ourselves as a dcop client
//	app.dcopClient()->registerAs(app.name(), false); //TODO PORT
83

84
	KConfigDialogManager::changedMap()->insert("ksudoku::SymbolConfigListWidget", SIGNAL(itemChanged(QListWidgetItem*)));
85 86 87 88 89 90 91 92 93 94 95 96

	// see if we are starting with session management
	/*if (app.isRestored())
	{
			RESTORE(KSudoku);
	}
	else
	{*/
		KSudoku *widget = new KSudoku;
		widget->show();

		// no session.. just start up normally
97
		if (parser.positionalArguments().count() != 0)
98
		{
99
			for (int i = 0; i < parser.positionalArguments().count(); ++i)
100
			{
101
				widget->loadGame(QUrl::fromUserInput(parser.positionalArguments().at(i), QDir::currentPath()));
102 103 104
			}
		}

105
	//} //TODO PORT
Frederik Schwarzer's avatar
Frederik Schwarzer committed
106

107 108
	return app.exec();
}