-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
61 lines (50 loc) · 2.38 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
56
57
58
59
60
61
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "api_controller.h"
#include "system_manager.h"
#include "filesystem_manager.h"
#include "gui_controller.h"
#include "logger.h"
#include "QDebug"
#include "QQmlContext"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
GuiController guiController(nullptr);
if (!guiController.initialize())
return -1;
const QString defaultRootDir = "/home/anastasia/tp/cpp/mydir";
ApiController apiController;
SystemManager systemController;
FileSystemManager fileSystemController(defaultRootDir);
// connection GUI controller signals to slots
QObject::connect(&guiController, &GuiController::portChanged,
&apiController, &ApiController::onPortChangedRestart);
QObject::connect(&guiController, &GuiController::rootDirPathChanged,
&fileSystemController, &FileSystemManager::onRootDirChanged);
// connection logger signals to slots
QObject::connect(Logger::Instance(), &Logger::newLogMsg,
&guiController, &GuiController::onNewLogMsg);
QObject::connect(Logger::Instance(), &Logger::newErrorLogMsg,
&guiController, &GuiController::onNewErrorLogMsg);
// connecting web controller signals to slots
QObject::connect(&apiController, &ApiController::volumeSetValue,
&systemController, &SystemManager::setVolumeValue);
QObject::connect(&apiController, &ApiController::volumeTurnValue,
&systemController, &SystemManager::turnVolumeValue);
QObject::connect(&apiController, &ApiController::volumeSetIsMute,
&systemController, &SystemManager::setVolumeIsMute);
// connectiong web api signals to slots
QObject::connect(&apiController, &ApiController::fsGetFilesList,
&fileSystemController, &FileSystemManager::getFilesList);
QObject::connect(&apiController, &ApiController::fsCopyFiles,
&fileSystemController, &FileSystemManager::copyFiles);
guiController.updateServerPortField(apiController.getCurrentPort());
guiController.updateRootDirPathField(defaultRootDir);
apiController.startListen();
const int retVal = app.exec();
// cleaning up
Logger::Destroy();
return retVal;
}