-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·55 lines (45 loc) · 1.48 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <QtCore>
#include <QtGui>
#include <QTranslator>
#include <QDebug>
#include <QFile>
#include "globals.h"
#include "view/mainwindow.h"
#include "controller/game/game.h"
// Nadefinovani referenci ze tridy Globals.
QApplication * Globals::application = NULL;
QSettings * Globals::settings = NULL;
Game * Game::game = NULL;
/**
* Vstupni bod do systemu.
* @param argc Pocet argumentu prikazove radky.
* @param argv[] Pole parametru prikazove radky.
* @return Navratova hodnota programu.
*/
int main(int argc, char *argv[])
{
// Inicializace Qt.
QApplication app(argc, argv);
Globals::application = &app;
// Zkontroluje se existence konfiguracniho souboru a jinak se vytvori z resource.
if (!QFile::exists("config.ini")) {
QFile::copy(":/config.ini", "config.ini");
}
// Nacte se konfigurace.
Globals::settings = new QSettings("config.ini", QSettings::IniFormat);
// Inicializuje se translator.
QTranslator translator;
translator.load(":/lang/felchess_" + Globals::settings->value("language/defaultLanguage").toString() + ".qm");
app.installTranslator(&translator);
// Inicializuje se vstupni bod kontroleru.
Game * game = Game::getInstance();
// Vytvori se okno aplikace.
MainWindow * mainWindow = new MainWindow();
mainWindow->show();
// Spusteni Qt.
return app.exec();
// Uvolneni pameti alokovane ve staticke tride Globals.
delete Globals::settings;
delete game;
delete mainWindow;
}