mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
166 lines
4.1 KiB
C++
166 lines
4.1 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
Initialize();
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::Initialize()
|
|
{
|
|
|
|
ui->settingsWidget->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;
|
|
externalExecuter = new ExternalExecuter;
|
|
|
|
connect(recognizeSystem,&RecognizeSystem::UpdateBytesAvailable,this,&MainWindow::UpdateProgress);
|
|
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(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::onCalculateHash,updateController,&UpdateController::CalculateHash);
|
|
|
|
connectionThread->start();
|
|
updateControllerThread->start();
|
|
|
|
emit onCalculateHash();
|
|
emit onInitializeClient(updateController,recognizeSystem,externalExecuter);
|
|
|
|
recognizeSystem->Initialize(updateController,dataParser);
|
|
|
|
screenChecker->Check();
|
|
ui->disblayCount->setText(screenChecker->getScreenCount());
|
|
ui->updateButton->setEnabled(false);
|
|
ui->startButton->setEnabled(false);
|
|
|
|
maxBytesAvailable = 0;
|
|
ui->loadingProgressBar->setValue(0);
|
|
|
|
emit onSetConnect(dataParser->GetServerSettings());
|
|
|
|
}
|
|
|
|
void MainWindow::UpdateProgress(qint64 size,quint64 sended)
|
|
{
|
|
|
|
ui->loadingProgressBar->setMaximum(size);
|
|
ui->loadingProgressBar->setMinimum(0);
|
|
|
|
ui->loadingProgressBar->setValue(sended);
|
|
}
|
|
|
|
void MainWindow::LoadComplete()
|
|
{
|
|
ui->loadingProgressBar->setValue(100);
|
|
ui->updateButton->setEnabled(false);
|
|
externalExecuter->FindApp();
|
|
ui->startButton->setEnabled(true);
|
|
}
|
|
|
|
void MainWindow::SetNeedUpdate(bool flag)
|
|
{
|
|
ui->updateButton->setEnabled(flag);
|
|
ui->startButton->setEnabled(!flag);
|
|
}
|
|
|
|
void MainWindow::LostConnection()
|
|
{
|
|
ui->loadingProgressBar->setValue(0);
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_loginButton_clicked()
|
|
{
|
|
QString username = ui->loginInputField->text();
|
|
QString password = ui->passwordInputField->text();
|
|
|
|
ClientAutorization *autorization = new ClientAutorization;
|
|
autorization->Login = username;
|
|
autorization->Password = password;
|
|
|
|
dataParser->CreateAuthMessage(autorization);
|
|
client->SendClientAutorization();
|
|
}
|
|
|
|
void MainWindow::on_updateButton_clicked()
|
|
{
|
|
emit onSendMessage("update");
|
|
ui->loadingProgressBar->setValue(0);
|
|
}
|
|
|
|
void MainWindow::on_startButton_clicked()
|
|
{
|
|
externalExecuter->CallApp();
|
|
}
|
|
|
|
|
|
void MainWindow::on_saveServerButton_clicked()
|
|
{
|
|
ui->settingsWidget->hide();
|
|
ui->loginWidget->show();
|
|
|
|
QString server = ui->serverInputField->text();
|
|
QString port = ui->portInputField->text();
|
|
|
|
dataParser->CreateServerSettings(server,port);
|
|
|
|
emit onSetConnect(dataParser->GetServerSettings());
|
|
}
|
|
|
|
void MainWindow::on_settingsButton_clicked()
|
|
{
|
|
ui->settingsWidget->show();
|
|
ui->loginWidget->hide();
|
|
|
|
ServerSettings *currentSettings = dataParser->GetServerSettings();
|
|
|
|
ui->serverInputField->setText(currentSettings->Address);
|
|
ui->portInputField->setText(currentSettings->Port);
|
|
}
|
|
|
|
void MainWindow::DebugLog(QString message)
|
|
{
|
|
ui->debugText->append(message);
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
connectionThread->quit();
|
|
connectionThread->wait();
|
|
|
|
delete connectionThread;
|
|
delete ui;
|
|
}
|
|
|
|
|
|
void MainWindow::on_checkUpdate_clicked()
|
|
{
|
|
emit onSendMessage("check");
|
|
}
|