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 "cutechesscoreapp.h"
22 #include <enginemanager.h>
27 CuteChessCoreApplication::CuteChessCoreApplication(int& argc
, char* argv
[])
28 : QCoreApplication(argc
, argv
), m_engineManager(0)
30 qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
32 QCoreApplication::setOrganizationName(QLatin1String("cutechess"));
33 QCoreApplication::setOrganizationDomain(QLatin1String("cutechess.org"));
34 QCoreApplication::setApplicationName(QLatin1String("cutechess"));
36 // Use Ini format on all platforms
37 QSettings::setDefaultFormat(QSettings::IniFormat
);
39 qInstallMsgHandler(CuteChessCoreApplication::messageHandler
);
42 // Note that we can't use QDesktopServices because of dependencies
44 QFileInfo
fi(settings
.fileName());
45 engineManager()->loadEngines(fi
.absolutePath() +
46 QLatin1String("/engines.json"));
49 CuteChessCoreApplication::~CuteChessCoreApplication()
53 void CuteChessCoreApplication::messageHandler(QtMsgType type
,
59 fprintf(stdout
, "%s\n", message
);
63 fprintf(stderr
, "Warning: %s\n", message
);
67 fprintf(stderr
, "Critical: %s\n", message
);
71 fprintf(stderr
, "Fatal: %s\n", message
);
76 EngineManager
* CuteChessCoreApplication::engineManager()
78 if (m_engineManager
== 0)
79 m_engineManager
= new EngineManager(this);
81 return m_engineManager
;
84 CuteChessCoreApplication
* CuteChessCoreApplication::instance()
86 return static_cast<CuteChessCoreApplication
*>(QCoreApplication::instance());