Open stdout only once
[sloppygui.git] / projects / gui / src / main.cpp
blob59142db00b7bd155e91ab3b948b3680806fcf965
1 /*
2 This file is part of Cute Chess.
4 Cute Chess is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Cute Chess is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
18 #include <QtGlobal>
20 #if QT_VERSION < 0x040400
21 #error "Qt version 4.4.0 or later is required"
22 #endif
24 #include <QApplication>
25 #include <QDebug>
26 #include <QTextStream>
27 #include <QTime>
28 #include <QSettings>
30 #include "mainwindow.h"
32 int main(int argc, char* argv[])
34 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
36 QCoreApplication::setOrganizationName("cutechess");
37 QCoreApplication::setOrganizationDomain("cutechess.org");
38 QCoreApplication::setApplicationName("cutechess");
40 QApplication app(argc, argv);
42 // Use Ini format on all platforms
43 QSettings::setDefaultFormat(QSettings::IniFormat);
45 QStringList arguments = app.arguments();
46 arguments.takeFirst(); // application name
48 // Use trivial command-line parsing for now
49 QTextStream out(stdout);
50 while (!arguments.empty())
52 if (arguments.first() == QLatin1String("-v") ||
53 arguments.first() == QLatin1String("--version"))
55 out << "Cute Chess " << CUTECHESS_VERSION << endl;
56 out << "Copyright (C) 2008-2009 Ilari Pihlajisto and Arto Jonsson" << endl;
57 out << "This is free software; see the source for copying ";
58 out << "conditions. There is NO" << endl << "warranty; not even for ";
59 out << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.";
60 out << endl << endl;
62 return 0;
64 else
66 qWarning() << "Unknown argument:" << arguments.first();
68 arguments.takeFirst();
71 MainWindow mainWindow;
72 mainWindow.show();
74 return app.exec();