mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
fead: load without animation
This commit is contained in:
195
mainwindow.cpp
195
mainwindow.cpp
@@ -1,5 +1,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "updatenotifywidget.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
@@ -12,11 +13,71 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::createObjects()
|
||||
{
|
||||
connectionThread = new QThread;
|
||||
|
||||
client = new TCPClient;
|
||||
client->moveToThread(connectionThread);
|
||||
|
||||
dataParser = new DataParser;
|
||||
|
||||
sendSystem = new SendSystem;
|
||||
sendSystem->moveToThread(connectionThread);
|
||||
|
||||
updateController = new UpdateController(dataParser,sendSystem);
|
||||
updateController->moveToThread(connectionThread);
|
||||
|
||||
recognizeSystem = new RecognizeSystem;
|
||||
recognizeSystem->moveToThread(connectionThread);
|
||||
|
||||
screenChecker = new ScreenChecker(dataParser,ui->displayWidget);
|
||||
externalExecuter = new ExternalExecuter;
|
||||
|
||||
hashComparer = new HashComparer(dataParser);
|
||||
|
||||
connectionThread->start();
|
||||
connectionThread->setPriority(QThread::HighestPriority);
|
||||
|
||||
timer = new QTimer;
|
||||
}
|
||||
|
||||
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::sigLoadComplete,this,&MainWindow::loadComplete);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&MainWindow::setNeedUpdate);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSendDebugLog,this,&MainWindow::debugLog);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSocketDisabled,this,&MainWindow::lostConnection);
|
||||
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);
|
||||
|
||||
connect(client,&TCPClient::sigSendDebugLog,this,&MainWindow::debugLog,Qt::AutoConnection);
|
||||
|
||||
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(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
|
||||
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
|
||||
|
||||
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
|
||||
connect(this,&MainWindow::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
||||
}
|
||||
|
||||
void MainWindow::initialize()
|
||||
{
|
||||
maxBytesAvailable = 0;
|
||||
globalValue = 0;
|
||||
|
||||
ui->loadingProgressBar->setValue(0);
|
||||
ui->settingsWidget->hide();
|
||||
ui->notificationLabel->hide();
|
||||
ui->loadingProgressBar->hide();
|
||||
@@ -26,70 +87,22 @@ void MainWindow::initialize()
|
||||
ui->debugText->hide();
|
||||
ui->displayGroupWidget->hide();
|
||||
ui->autostartCheckBox->hide();
|
||||
|
||||
updateControllerThread = new QThread;
|
||||
connectionThread = new QThread;
|
||||
|
||||
client = new TCPClient;
|
||||
client->moveToThread(connectionThread);
|
||||
|
||||
dataParser = new DataParser;
|
||||
|
||||
updateController = new UpdateController(dataParser);
|
||||
updateController->moveToThread(updateControllerThread);
|
||||
|
||||
recognizeSystem = new RecognizeSystem;
|
||||
screenChecker = new ScreenChecker(dataParser,ui->displayWidget);
|
||||
externalExecuter = new ExternalExecuter;
|
||||
|
||||
timer = new QTimer;
|
||||
connect(timer,&QTimer::timeout,this,&MainWindow::slotDisableNotify);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigLoadComplete,this,&MainWindow::loadComplete);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&MainWindow::setNeedUpdate);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSendDebugLog,this,&MainWindow::debugLog);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSocketDisabled,this,&MainWindow::lostConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSaveLoginData,this,&MainWindow::checkLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSocketWaitForReadyRead,client,&TCPClient::waitRead,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigServerBlocked,this,&MainWindow::serverBlocked);
|
||||
|
||||
connect(client,&TCPClient::sigGetXmlAnswer,dataParser,&DataParser::slotGetXmlAnswer);
|
||||
|
||||
connectionThread->start();
|
||||
updateControllerThread->start();
|
||||
|
||||
updateControllerThread->setPriority(QThread::LowPriority);
|
||||
connectionThread->setPriority(QThread::HighestPriority);
|
||||
|
||||
connect(client,&TCPClient::sigSendDebugLog,this,&MainWindow::debugLog,Qt::AutoConnection);
|
||||
|
||||
connect(this,&MainWindow::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSendMessage,client,&TCPClient::slotMessageEntered,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSendClientAuthorization,client,&TCPClient::sendClientAutorization,Qt::AutoConnection);
|
||||
|
||||
connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
|
||||
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
|
||||
|
||||
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateHash);
|
||||
|
||||
emit sigCalculateHash();
|
||||
emit sigInitializeClient(recognizeSystem,externalExecuter);
|
||||
|
||||
recognizeSystem->initialize(updateController,dataParser);
|
||||
|
||||
screenChecker->check();
|
||||
ui->updateButton->setEnabled(false);
|
||||
ui->startButton->setEnabled(false);
|
||||
|
||||
maxBytesAvailable = 0;
|
||||
globalValue = 0;
|
||||
createObjects();
|
||||
|
||||
ui->loadingProgressBar->setValue(0);
|
||||
bindConnection();
|
||||
|
||||
emit sigCalculateHash();
|
||||
emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem,connectionThread);
|
||||
|
||||
recognizeSystem->initialize(updateController,dataParser,this);
|
||||
|
||||
screenChecker->check();
|
||||
|
||||
loadStaticData();
|
||||
emit sigSetConnect(dataParser->getServerSettings());
|
||||
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
|
||||
|
||||
checkAppAvailable();
|
||||
|
||||
@@ -153,12 +166,16 @@ void MainWindow::serverBlocked()
|
||||
timer->start(3000);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::checkLoginResult(ServerAuthorization *serverAuth)
|
||||
{
|
||||
if (serverAuth->Result){
|
||||
emit sigSendMessage("check");
|
||||
if (serverAuth->Result)
|
||||
{
|
||||
|
||||
ui->inlineTextDebug->setText(tr("Проверка обновлений..."));
|
||||
if (serverAuth->AccessType != "instructor") //временно для отладки загрузки на сервер
|
||||
{
|
||||
checkUpdate();
|
||||
}
|
||||
|
||||
ui->loadingProgressBar->show();
|
||||
ui->updateButton->show();
|
||||
@@ -247,15 +264,15 @@ void MainWindow::slotConnectionState(bool flag)
|
||||
|
||||
void MainWindow::slotServerDisconnect()
|
||||
{
|
||||
ui->loadingProgressBar->hide();
|
||||
ui->updateButton->hide();
|
||||
ui->displayGroupWidget->hide();
|
||||
ui->autostartCheckBox->hide();
|
||||
ui->loadingProgressBar->hide();
|
||||
ui->updateButton->hide();
|
||||
ui->displayGroupWidget->hide();
|
||||
ui->autostartCheckBox->hide();
|
||||
|
||||
ui->loginWidget->show();
|
||||
ui->inlineTextDebug->setText("");
|
||||
ui->updateButton->setEnabled(false);
|
||||
slotConnectionState(false);
|
||||
ui->loginWidget->show();
|
||||
ui->inlineTextDebug->setText("");
|
||||
ui->updateButton->setEnabled(false);
|
||||
slotConnectionState(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -277,6 +294,22 @@ void MainWindow::debugLog(QString message)
|
||||
ui->debugText->append(message);
|
||||
}
|
||||
|
||||
void MainWindow::callUpdateList()
|
||||
{
|
||||
updateController->calculateStreamingHash();
|
||||
hashComparer->setWidget(updateWidget);
|
||||
|
||||
QByteArray answer = dataParser->xmlAnswer_notify("GETSERVERDATALIST");
|
||||
sendSystem->sendXMLAnswer(answer);
|
||||
|
||||
updateWidget->initialize(this,updateController);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::bindNotifyWidget(UpdateNotifyWidget *widget)
|
||||
{
|
||||
updateWidget = widget;
|
||||
}
|
||||
|
||||
void MainWindow::on_loginButton_clicked()
|
||||
{
|
||||
@@ -288,12 +321,13 @@ void MainWindow::on_loginButton_clicked()
|
||||
autorization->Password = password;
|
||||
|
||||
dataParser->createAuthMessage(autorization);
|
||||
emit sigSendClientAuthorization();
|
||||
emit sigSendAutorization();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_updateButton_clicked()
|
||||
{
|
||||
emit sigSendMessage("update");
|
||||
emit sigSendCommand("update");
|
||||
ui->updateButton->hide();
|
||||
ui->loadingProgressBar->setValue(0);
|
||||
}
|
||||
@@ -301,7 +335,7 @@ void MainWindow::on_updateButton_clicked()
|
||||
void MainWindow::on_startButton_clicked()
|
||||
{
|
||||
externalExecuter->callApp();
|
||||
client->sendDisable();
|
||||
sendSystem->sendDisable();
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +349,7 @@ void MainWindow::on_saveServerButton_clicked()
|
||||
|
||||
dataParser->createServerSettings(server,port);
|
||||
|
||||
emit sigSetConnect(dataParser->getServerSettings());
|
||||
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
|
||||
}
|
||||
|
||||
void MainWindow::on_settingsButton_clicked()
|
||||
@@ -327,7 +361,7 @@ void MainWindow::on_settingsButton_clicked()
|
||||
|
||||
void MainWindow::on_connectButton_clicked()
|
||||
{
|
||||
emit sigSetConnect(dataParser->getServerSettings());
|
||||
emit sigSetConnect(dataParser->getServerSettings(),connectionThread);
|
||||
}
|
||||
|
||||
void MainWindow::on_languageComboBox_activated(const QString &arg1)
|
||||
@@ -338,18 +372,21 @@ void MainWindow::on_languageComboBox_activated(const QString &arg1)
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::checkUpdate()
|
||||
{
|
||||
emit sigSendCommand("check");
|
||||
ui->inlineTextDebug->setText(tr("Проверка обновлений..."));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
connectionThread->quit();
|
||||
connectionThread->wait();
|
||||
|
||||
updateControllerThread->quit();
|
||||
updateControllerThread->wait();
|
||||
|
||||
client->sendDisable();
|
||||
sendSystem->sendDisable();
|
||||
|
||||
delete connectionThread;
|
||||
delete updateControllerThread;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user