feat: add version container

This commit is contained in:
semenov
2024-12-27 10:43:26 +03:00
parent 9ac5b46030
commit 2944f2d510
85 changed files with 1875 additions and 632 deletions

View File

@@ -22,19 +22,19 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::initialize()
{
createObjects();
loadStaticData();
updateWidget->initialize(this);
updateWidget->initialize(this,versionContainer);
entryWidget->initialize(this);
versionSelectWidget->initialize(sendSystem);
hashComparer->initialize(this);
updateController->initialize(this);
versionSelectWidget->initialize(sendSystem,versionContainer);
hashComparer->initialize(this,versionContainer);
updateController->initialize(this,versionContainer);
commonButtonGroupWidget->initialize(externalExecuter,sendSystem,client);
commonButtonGroupWidget->initialize(this,externalExecuter,sendSystem,client);
commonButtonGroupWidget->show();
//instructorButtonGroupWidget->initialize(this);
ui->notificationLabel->hide();
ui->unsafeChangingButton->hide();
ui->offlineStartButton->show();
ui->offlineStartButton->setEnabled(false);
@@ -46,31 +46,33 @@ void MainWindow::initialize()
sendSystem->initialize(this,dataParser);
dataParser->initialize(recognizeSystem);
emit sigCalculateHash();
emit sigInitializeClient(this,recognizeSystem,externalExecuter,sendSystem,workerThread);
emit sigRecognize(updateController,dataParser,this,hashComparer,client);
recognizeSystem->initialize(updateController,dataParser,this,hashComparer,client,versionContainer);
//emit sigRecognize(updateController,dataParser,this,hashComparer,client);
screenChecker->check();
loadStaticData();
emit sigSetConnect(dataParser->getServerSettings(),workerThread);
checkAppAvailable();
//test
}
void MainWindow::createObjects()
{
updateWidget = new UpdateNotifyWidget;
updateWidget->setParent(this);
commonButtonGroupWidget = new CommonButtonGroupWidget;
//instructorButtonGroupWidget = new InstructorButtonGroupWidget;
entryWidget = new EntryWidget;
versionSelectWidget = new VersionSelectWidget;
ui->changButtonGroup->addWidget(commonButtonGroupWidget);
//updateWidget->setButtonWidget(instructorButtonGroupWidget);
ui->interactiveGroup->addWidget(entryWidget);
ui->interactiveGroup->addWidget(versionSelectWidget);
@@ -99,6 +101,8 @@ void MainWindow::createObjects()
hashComparer = new HashComparer(dataParser);
hashComparer->moveToThread(workerThread);
versionContainer = new VersionContainer;
workerThread->start();
workerThread->setPriority(QThread::HighestPriority);
@@ -114,7 +118,7 @@ void MainWindow::bindConnection()
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(this,&MainWindow::sigRecognize,recognizeSystem,&RecognizeSystem::initialize,Qt::AutoConnection);
//connect(this,&MainWindow::sigRecognize,recognizeSystem,&RecognizeSystem::initialize,Qt::AutoConnection);
connect(this,&MainWindow::sigGetConnected,client,&TCPClient::getIsConnected);
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
@@ -137,9 +141,12 @@ void MainWindow::loadComplete()
ui->offlineStartButton->setEnabled(true);
ui->autostartCheckBox->hide();
ui->offlineStartButton->show();
dataParser->changeVersion(versionContainer->getServerVersionData()->getViewName());
setTitle();
}
void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount)
void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount,quint64 deleteCount)
{
fileCountForUpdate = 0;
filesLoaded = 0;
@@ -153,8 +160,17 @@ void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount)
}
else if(flag)
{
QString result = tr("Доступно обновление: ") + Tools::convertFileSize(size);
result += tr("Количество файлов: ") + QString::number(fileCount);
QString result;
if(fileCount > 0)
{
result = tr("Доступно обновление: ") + Tools::convertFileSize(size);
result += tr("Количество файлов: ") + QString::number(fileCount);
}
else
{
result = tr("Файлов к удалению: ") + QString::number(deleteCount);
}
ui->inlineTextDebug->setText(result);
commonButtonGroupWidget->needUpdateState(flag);
ui->autostartCheckBox->show();
@@ -165,7 +181,10 @@ void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount)
ui->inlineTextDebug->setText(tr("Установлена последняя версия"));
autoStart();
commonButtonGroupWidget->lastVerInstalledState();
ui->unsafeChangingButton->hide();
ui->offlineStartButton->setEnabled(true);
dataParser->changeVersion(versionContainer->getServerVersion());
setTitle();
stopLoadingMovie();
}
}
@@ -219,6 +238,7 @@ void MainWindow::checkLoginResult(ServerAuthorization *serverAuth)
}
else
{
entryWidget->loginIsActive(true);
ui->notificationLabel->setText(tr("Неверный логин/пароль"));
timer->setInterval(3000);
timer->start();
@@ -261,6 +281,15 @@ void MainWindow::autoStart()
}
}
void MainWindow::setTitle()
{
ServerSettings *currentSettings = dataParser->getServerSettings();
QString title = tr("Тренажер процедур технического обслуживания самолета RRJ-95NEW-100");
title.append(" (" + currentSettings->LocalVersionName + ")");
ui->headerLabel->setText(title);
}
void MainWindow::loadStaticData()
{
ServerSettings *currentSettings = dataParser->getServerSettings();
@@ -270,6 +299,7 @@ void MainWindow::loadStaticData()
ui->autostartCheckBox->setChecked(currentSettings->isAutoStart);
checkLanguage(currentSettings->Language);
setTitle();
}
void MainWindow::showConnectionEmpty()
@@ -282,7 +312,14 @@ void MainWindow::showConnectionEmpty()
ui->offlineStartButton->show();
ui->offlineStartButton->setGeometry(280,340,250,40);
ui->settingsButton->show();
//instructorButtonGroupWidget->hide();
ui->unsafeChangingButton->hide();
versionSelectWidget->hide();
}
void MainWindow::disableUnsaveButton(bool flag)
{
if(!flag) ui->unsafeChangingButton->show();
else ui->unsafeChangingButton->hide();
}
void MainWindow::slotConnectionState(bool flag)
@@ -333,7 +370,6 @@ void MainWindow::callUpdateList()
{
hashComparer->setWidget(updateWidget);
emit sigSendXMLAnswer(cmd_GetServerHash);
updateWidget->initialize(this);
}
@@ -366,6 +402,7 @@ void MainWindow::saveServerSettingsWithConnect()
}
//TODO: не заполняется 2 поля (автостарт и язык)
ServerSettings *settings = entryWidget->getServerSettings();
settings->LocalVersionName = dataParser->getServerSettings()->LocalVersionName;
dataParser->createServerSettings(settings);
emit sigSetConnect(settings,workerThread);
@@ -389,9 +426,9 @@ void MainWindow::loadToServer()
{
ui->inlineTextDebug->setText(tr("Отправка файлов..."));
commonButtonGroupWidget->showProgressBar(true);
//instructorButtonGroupWidget->hide();
ui->offlineStartButton->setEnabled(false);
updateWidget->hide();
ui->unsafeChangingButton->hide();
emit sigUpdateFilesOnServer(hashComparer->getFilesForUpdate());
}
@@ -402,7 +439,6 @@ void MainWindow::undoCurrentChanges()
commonButtonGroupWidget->showProgressBar(true);
ui->offlineStartButton->setEnabled(false);
//instructorButtonGroupWidget->hide();
updateWidget->hide();
startLoadingAnim();
@@ -436,6 +472,12 @@ void MainWindow::on_offlineStartButton_clicked()
startUnityClient();
}
void MainWindow::on_unsafeChangingButton_clicked()
{
updateWidget->show();
}
void MainWindow::on_exitButton_clicked()
{
exit(0);
@@ -451,11 +493,11 @@ void MainWindow::showUpdateInfo()
{
stopLoadingMovie();
updateWidget->showWithFill();
ui->unsafeChangingButton->show();
entryWidget->hide();
commonButtonGroupWidget->hide();
//instructorButtonGroupWidget->show();
commonButtonGroupWidget->show();
ui->offlineStartButton->setGeometry(540,549,250,40);
fileCountForUpdate = hashComparer->getFilesForUpdate()->length();
fileCountForUpdate = hashComparer->getFileUpdateCount();
filesLoaded = 0;
}
@@ -465,7 +507,7 @@ void MainWindow::showCompleteDialogBox()
ui->inlineTextDebug->setText(tr("Загрузка завершена"));
startLoadingAnim();
QTime dieTime= QTime::currentTime().addSecs(10);
QTime dieTime= QTime::currentTime().addSecs(10); //DELAY ДЛЯ ПЕРЕСЧЕТА ХЭША НА СЕРВЕРЕ
while (QTime::currentTime() < dieTime)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
@@ -479,9 +521,9 @@ void MainWindow::startUnityClient()
emit sigSendXMLAnswer("DISABLE");
}
void MainWindow::setCurrentVersionName(QString versionName)
void MainWindow::setCurrentVersionName(StreamingVersionData *version)
{
versionSelectWidget->fillCurrentVersionName(versionName);
versionContainer->setLocalVersionData(version);
}
void MainWindow::keyPressEvent(QKeyEvent *event)
@@ -513,6 +555,20 @@ void MainWindow::painting()
ui->settingsButton->setIcon(icon);
//caution
QPixmap cautionIcon(":resource/Icons/caution.png");
painter.begin(&cautionIcon);
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
painter.fillRect(cautionIcon.rect(),color);
painter.end();
icon.addPixmap(cautionIcon,QIcon::Normal,QIcon::Off);
QSize cautionIconSize(30,30);
ui->unsafeChangingButton->setIcon(icon);
ui->unsafeChangingButton->setIconSize(cautionIconSize);
//exit
QPixmap crossPixmap(":resource/Icons/crossInCircle.png");
QPainter painterCross;
@@ -567,3 +623,4 @@ MainWindow::~MainWindow()