bugfix/feat: main loading bar, add bar for sender

This commit is contained in:
semenov
2024-09-24 13:23:29 +03:00
parent 95c281dba1
commit ad7fe8ccb6
24 changed files with 1016 additions and 143 deletions

View File

@@ -13,6 +13,39 @@ MainWindow::MainWindow(QWidget *parent)
}
void MainWindow::initialize()
{
ui->loadingProgressBar->setValue(0);
ui->settingsWidget->hide();
ui->notificationLabel->hide();
ui->loadingProgressBar->hide();
ui->updateButton->hide();
ui->connectButton->hide();
ui->startButton->setEnabled(false);
ui->debugText->hide();
ui->displayGroupWidget->hide();
ui->autostartCheckBox->hide();
ui->updateButton->setEnabled(false);
ui->startButton->setEnabled(false);
createObjects();
bindConnection();
emit sigCalculateHash();
emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem,connectionThread);
recognizeSystem->initialize(updateController,dataParser,this);
screenChecker->check();
loadStaticData();
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
checkAppAvailable();
}
void MainWindow::createObjects()
{
connectionThread = new QThread;
@@ -55,6 +88,7 @@ void MainWindow::bindConnection()
connect(recognizeSystem,&RecognizeSystem::sigSaveLoginData,this,&MainWindow::checkLoginResult);
connect(recognizeSystem,&RecognizeSystem::sigSocketWaitForReadyRead,client,&TCPClient::waitRead,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigServerBlocked,this,&MainWindow::serverBlocked);
connect(hashComparer,&HashComparer::sigCallCheck,this,&MainWindow::checkUpdate);
connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParser,&DataParser::slotGetXmlAnswer);
@@ -72,80 +106,46 @@ void MainWindow::bindConnection()
connect(this,&MainWindow::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
}
void MainWindow::initialize()
void MainWindow::updateProgress()
{
maxBytesAvailable = 0;
globalValue = 0;
ui->loadingProgressBar->setValue(0);
ui->settingsWidget->hide();
ui->notificationLabel->hide();
ui->loadingProgressBar->hide();
ui->updateButton->hide();
ui->connectButton->hide();
ui->startButton->setEnabled(false);
ui->debugText->hide();
ui->displayGroupWidget->hide();
ui->autostartCheckBox->hide();
ui->updateButton->setEnabled(false);
ui->startButton->setEnabled(false);
createObjects();
bindConnection();
emit sigCalculateHash();
emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem,connectionThread);
recognizeSystem->initialize(updateController,dataParser,this);
screenChecker->check();
loadStaticData();
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
checkAppAvailable();
}
void MainWindow::updateProgress(qint64 size,quint64 sended)
{
float currentValue = 100.00 / (maxBytesAvailable / size);
globalValue += currentValue;
ui->loadingProgressBar->setValue(globalValue);
filesLoaded++;
ui->loadingProgressBar->setValue(filesLoaded);
}
void MainWindow::loadComplete()
{
ui->loadingProgressBar->setValue(100);
ui->updateButton->setEnabled(false);
externalExecuter->findApp();
ui->updateButton->setEnabled(false);
ui->startButton->setEnabled(true);
autoStart();
ui->inlineTextDebug->setText(tr("Обновление завершено..."));
ui->loadingProgressBar->setMaximum(fileCountForUpdate);
ui->loadingProgressBar->setValue(fileCountForUpdate);
}
void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount)
{
maxBytesAvailable = 0;
fileCountForUpdate = 0;
filesLoaded = 0;
fileCountForUpdate = fileCount;
QString availableSizeText;
if (flag){
QString result = tr("Доступно обновление: ") + Tools::convertFileSize(size);
result += tr("Количество файлов: ") + QString::number(fileCount);
ui->inlineTextDebug->setText(result);
maxBytesAvailable = size;
}
else
{
ui->inlineTextDebug->setText(tr("Установлена последняя версия"));
ui->loadingProgressBar->setMaximum(100);
ui->loadingProgressBar->setValue(100);
autoStart();
}
ui->updateButton->setEnabled(flag);
ui->startButton->setEnabled(!flag);
ui->loadingProgressBar->setRange(0,100);
}
void MainWindow::lostConnection()
@@ -166,7 +166,6 @@ void MainWindow::serverBlocked()
timer->start(3000);
}
void MainWindow::checkLoginResult(ServerAuthorization *serverAuth)
{
if (serverAuth->Result)
@@ -177,7 +176,6 @@ void MainWindow::checkLoginResult(ServerAuthorization *serverAuth)
checkUpdate();
}
ui->loadingProgressBar->show();
ui->updateButton->show();
ui->displayGroupWidget->show();
ui->autostartCheckBox->show();
@@ -275,7 +273,6 @@ void MainWindow::slotServerDisconnect()
slotConnectionState(false);
}
void MainWindow::slotDisableNotify()
{
ui->notificationLabel->hide();
@@ -309,6 +306,7 @@ void MainWindow::callUpdateList()
void MainWindow::bindNotifyWidget(UpdateNotifyWidget *widget)
{
updateWidget = widget;
connect(sendSystem,&SendSystem::sigSend,updateWidget,&UpdateNotifyWidget::updateCount);
}
void MainWindow::on_loginButton_clicked()
@@ -338,7 +336,6 @@ void MainWindow::on_startButton_clicked()
sendSystem->sendDisable();
}
void MainWindow::on_saveServerButton_clicked()
{
ui->settingsWidget->hide();
@@ -358,7 +355,6 @@ void MainWindow::on_settingsButton_clicked()
ui->loginWidget->hide();
}
void MainWindow::on_connectButton_clicked()
{
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
@@ -372,9 +368,10 @@ void MainWindow::on_languageComboBox_activated(const QString &arg1)
ui->retranslateUi(this);
}
void MainWindow::checkUpdate()
{
ui->loadingProgressBar->setValue(0);
ui->loadingProgressBar->show();
emit sigSendCommand("check");
ui->inlineTextDebug->setText(tr("Проверка обновлений..."));
}