feat: before threading

This commit is contained in:
semenov
2024-08-19 11:57:33 +03:00
parent 883ac44e6b
commit c79faae730
48 changed files with 722 additions and 562 deletions

View File

@@ -16,8 +16,15 @@ void MainWindow::Initialize()
{
ui->settingsWidget->hide();
ui->notificationLabel->hide();
ui->loadingProgressBar->hide();
ui->updateButton->hide();
ui->startButton->setEnabled(false);
updateControllerThread = new QThread;
updateControllerThread->setPriority(QThread::LowPriority);
connectionThread = new QThread;
connectionThread->setPriority(QThread::HighestPriority);
client = new TCPClient;
client->moveToThread(connectionThread);
@@ -32,23 +39,27 @@ void MainWindow::Initialize()
externalExecuter = new ExternalExecuter;
connect(recognizeSystem,&RecognizeSystem::UpdateBytesAvailable,this,&MainWindow::UpdateProgress);
connect(recognizeSystem, &RecognizeSystem::LoadComplete,this,&MainWindow::LoadComplete);
connect(recognizeSystem,&RecognizeSystem::LoadComplete,this,&MainWindow::LoadComplete);
connect(recognizeSystem,&RecognizeSystem::onNeedUpdate,this,&MainWindow::SetNeedUpdate);
connect(recognizeSystem, &RecognizeSystem::onSendDebugLog,this,&MainWindow::DebugLog);
connect(recognizeSystem, &RecognizeSystem::SockedDisabled,this,&MainWindow::LostConnection);
connect(recognizeSystem,&RecognizeSystem::onSendDebugLog,this,&MainWindow::DebugLog);
connect(recognizeSystem,&RecognizeSystem::SockedDisabled,this,&MainWindow::LostConnection);
connect(recognizeSystem,&RecognizeSystem::SaveLoginData,this,&MainWindow::CheckLoginResult);
connect(recognizeSystem,&RecognizeSystem::SocketWaitForReadyRead,client,&TCPClient::WaitRead);
connectionThread->start();
updateControllerThread->start();
connect(client,&TCPClient::onSendDebugLog,this,&MainWindow::DebugLog);
connect(this,&MainWindow::onInitializeClient,client,&TCPClient::Initialize);
connect(this,&MainWindow::onSetConnect,client,&TCPClient::SetConnect);
connect(this,&MainWindow::onSendMessage,client,&TCPClient::MessageEntered);
connect(this,&MainWindow::SendClientAuthorization,client,&TCPClient::SendClientAutorization);
connect(this,&MainWindow::onCalculateHash,updateController,&UpdateController::CalculateHash);
connectionThread->start();
updateControllerThread->start();
emit onCalculateHash();
emit onInitializeClient(updateController,recognizeSystem,externalExecuter);
emit onInitializeClient(recognizeSystem,externalExecuter);
recognizeSystem->Initialize(updateController,dataParser);
@@ -62,6 +73,7 @@ void MainWindow::Initialize()
emit onSetConnect(dataParser->GetServerSettings());
CheckAppAvailable();
}
void MainWindow::UpdateProgress(qint64 size,quint64 sended)
@@ -93,6 +105,28 @@ void MainWindow::LostConnection()
}
void MainWindow::CheckLoginResult(ServerAuthorization *serverAuth)
{
if (serverAuth->Result){
emit onSendMessage("check");
ui->loadingProgressBar->show();
ui->updateButton->show();
dataParser->CreateAuthData(serverAuth);
}
else {
ui->notificationLabel->setText("Неверный логин/пароль");
ui->notificationLabel->show();
}
}
void MainWindow::CheckAppAvailable()
{
bool isAvailable = externalExecuter->FindApp();
ui->startButton->setEnabled(isAvailable);
}
void MainWindow::on_loginButton_clicked()
{
@@ -104,7 +138,7 @@ void MainWindow::on_loginButton_clicked()
autorization->Password = password;
dataParser->CreateAuthMessage(autorization);
client->SendClientAutorization();
emit SendClientAuthorization();
}
void MainWindow::on_updateButton_clicked()
@@ -154,12 +188,11 @@ MainWindow::~MainWindow()
connectionThread->quit();
connectionThread->wait();
updateControllerThread->quit();
updateControllerThread->wait();
delete connectionThread;
delete updateControllerThread;
delete ui;
}
void MainWindow::on_checkUpdate_clicked()
{
emit onSendMessage("check");
}