feat: stable loading

This commit is contained in:
semenov
2024-09-27 13:01:03 +03:00
parent 4d7590c02d
commit df74b09159
15 changed files with 125 additions and 73 deletions

View File

@@ -80,7 +80,7 @@ void MainWindow::bindConnection()
connect(timer,&QTimer::timeout,this,&MainWindow::slotDisableNotify);
connect(recognizeSystem,&RecognizeSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas);
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress);
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress,Qt::QueuedConnection);
connect(recognizeSystem,&RecognizeSystem::sigLoadComplete,this,&MainWindow::loadComplete);
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&MainWindow::setNeedUpdate);
connect(recognizeSystem,&RecognizeSystem::sigSendDebugLog,this,&MainWindow::debugLog);
@@ -102,6 +102,7 @@ void MainWindow::bindConnection()
connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
connect(this,&MainWindow::sigGetConnected,client,&TCPClient::getIsConnected);
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
connect(this,&MainWindow::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
}
@@ -109,7 +110,8 @@ void MainWindow::bindConnection()
void MainWindow::updateProgress()
{
filesLoaded++;
ui->loadingProgressBar->setValue(filesLoaded);
float value = 100 / ((float)fileCountForUpdate / filesLoaded);
ui->loadingProgressBar->setValue(value);
}
void MainWindow::loadComplete()
@@ -119,8 +121,7 @@ void MainWindow::loadComplete()
ui->startButton->setEnabled(true);
autoStart();
ui->inlineTextDebug->setText(tr("Обновление завершено..."));
ui->loadingProgressBar->setMaximum(fileCountForUpdate);
ui->loadingProgressBar->setValue(fileCountForUpdate);
ui->loadingProgressBar->setValue(100);
}
void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount)
@@ -311,6 +312,16 @@ void MainWindow::bindNotifyWidget(UpdateNotifyWidget *widget)
void MainWindow::on_loginButton_clicked()
{
if (!client->getIsConnected())
{
QPalette palette = ui->notificationLabel->palette();
palette.setColor(ui->notificationLabel->foregroundRole(),Qt::red);
ui->notificationLabel->setText(tr("Соединение отсутсвует"));
ui->notificationLabel->setPalette(palette);
ui->notificationLabel->show();
return;
}
QString username = ui->loginInputField->text();
QString password = ui->passwordInputField->text();
@@ -338,9 +349,11 @@ void MainWindow::on_startButton_clicked()
void MainWindow::on_saveServerButton_clicked()
{
ui->settingsWidget->hide();
ui->loginWidget->show();
if(client->getIsConnected()) return;
QString server = ui->serverInputField->text();
QString port = ui->portInputField->text();