ref: refactoring treads, check local update instructor

This commit is contained in:
semenov
2024-12-17 17:22:33 +03:00
parent 2dfd76ec18
commit 066a90691c
53 changed files with 2292 additions and 1558 deletions

View File

@@ -26,6 +26,8 @@ void MainWindow::initialize()
updateTextWidget->initialize();
entryWidget->initialize(this);
versionSelectWidget->initialize();
hashComparer->initialize(this);
updateController->initialize(this);
commonButtonGroupWidget->initialize(externalExecuter,sendSystem,client);
commonButtonGroupWidget->show();
@@ -43,14 +45,15 @@ void MainWindow::initialize()
bindConnection();
sendSystem->initialize(this,dataParser);
dataParser->initialize(recognizeSystem);
emit sigCalculateHash();
emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem,connectionThread);
emit sigInitializeClient(this,recognizeSystem,externalExecuter,sendSystem,workerThread);
emit sigRecognize(updateController,dataParser,this,hashComparer,client);
recognizeSystem->initialize(updateController,dataParser,this,hashComparer,client);
screenChecker->check();
loadStaticData();
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
emit sigSetConnect(dataParser->getServerSettings(),workerThread);
checkAppAvailable();
@@ -74,30 +77,32 @@ void MainWindow::createObjects()
ui->interactiveGroup->addWidget(updateTextWidget);
ui->interactiveGroup->addWidget(versionSelectWidget);
connectionThread = new QThread;
workerThread = new QThread;
animationThread = new QThread;
client = new TCPClient;
client->moveToThread(connectionThread);
client->moveToThread(workerThread);
dataParser = new DataParser;
dataParser->moveToThread(workerThread);
sendSystem = new SendSystem;
sendSystem->moveToThread(connectionThread);
sendSystem->moveToThread(workerThread);
updateController = new UpdateController(dataParser,sendSystem);
updateController->moveToThread(connectionThread);
updateController->moveToThread(workerThread);
recognizeSystem = new RecognizeSystem;
recognizeSystem->moveToThread(connectionThread);
recognizeSystem->moveToThread(workerThread);
screenChecker = new ScreenChecker(this,dataParser,ui->displayLayout);
externalExecuter = new ExternalExecuter;
hashComparer = new HashComparer(dataParser);
hashComparer->moveToThread(workerThread);
connectionThread->start();
connectionThread->setPriority(QThread::HighestPriority);
workerThread->start();
workerThread->setPriority(QThread::HighestPriority);
timer = new QTimer;
}
@@ -106,19 +111,12 @@ void MainWindow::bindConnection()
{
connect(timer,&QTimer::timeout,this,&MainWindow::slotDisableNotify);
connect(updateController,&UpdateController::sigUpdateComplete,this,&MainWindow::showCompleteDialogBox);
connect(hashComparer,&HashComparer::sigCallCheck,this,&MainWindow::checkUpdate);
connect(hashComparer,&HashComparer::sigHaveDelta,this,&MainWindow::showUpdateInfo);
connect(this,&MainWindow::sigUpdateFilesOnServer,updateController,&UpdateController::updateFilesOnServer);
connect(this,&MainWindow::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
connect(this,&MainWindow::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
connect(this,&MainWindow::sigSendCommand,client,&TCPClient::slotSendCommand,Qt::AutoConnection);
connect(this,&MainWindow::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
connect(this,&MainWindow::sigRecognize,recognizeSystem,&RecognizeSystem::initialize,Qt::AutoConnection);
connect(this,&MainWindow::sigGetConnected,client,&TCPClient::getIsConnected);
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
@@ -365,7 +363,7 @@ void MainWindow::saveServerSettingsWithConnect()
ServerSettings *settings = entryWidget->getServerSettings();
dataParser->createServerSettings(settings);
emit sigSetConnect(settings,connectionThread);
emit sigSetConnect(settings,workerThread);
}
void MainWindow::on_settingsButton_clicked()
@@ -546,12 +544,12 @@ void MainWindow::stopLoadingMovie()
MainWindow::~MainWindow()
{
connectionThread->quit();
connectionThread->wait();
workerThread->quit();
workerThread->wait();
emit sigSendXMLAnswer("DISABLE");
delete connectionThread;
delete workerThread;
delete ui;
}