-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowsmanager.cpp
More file actions
56 lines (47 loc) · 1.65 KB
/
windowsmanager.cpp
File metadata and controls
56 lines (47 loc) · 1.65 KB
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
56
#include "windowsmanager.h"
WindowsManager::WindowsManager(QObject *parent)
: QObject{parent}
{
_startMenu = new StartMenu();
connect(_startMenu, &StartMenu::startSimulation, this, &WindowsManager::startSimulation);
_startMenu->setWindowTitle(QCoreApplication::applicationName());
_startMenu->show();
}
WindowsManager::~WindowsManager() {}
void WindowsManager::startSimulation()
{
_mainWindow = new MainWindow(std::move(_startMenu->getGenerator()));
connect(_mainWindow, &MainWindow::endSimulation, this, &WindowsManager::endSimulation);
_mainWindow->setWindowTitle(QCoreApplication::applicationName());
_mainWindow->show();
_startMenu->hide();
_startMenu->setEnabled(true);
}
void WindowsManager::endSimulation()
{
_statWindow = new StatWindow(_mainWindow->statistics(), _mainWindow->cityManager());
connect(_statWindow, &StatWindow::reset, this, &WindowsManager::resetSimulation);
QPalette palette;
palette.setColor(QPalette::Window, QColor(0, 255, 100, 120));
qApp->setPalette(palette);
_statWindow->setWindowTitle(QCoreApplication::applicationName());
_statWindow->show();
_mainWindow->hide();
_mainWindow->setEnabled(true);
}
void WindowsManager::resetSimulation()
{
if (_startMenu != nullptr) {
delete _startMenu;
}
if (_mainWindow != nullptr) {
delete _mainWindow;
}
if (_statWindow != nullptr) {
delete _statWindow;
}
_startMenu = new StartMenu();
connect(_startMenu, &StartMenu::startSimulation, this, &WindowsManager::startSimulation);
_startMenu->setWindowTitle(QCoreApplication::applicationName());
_startMenu->show();
}