mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
init commit 2
This commit is contained in:
132
mainwindow.cpp
Normal file
132
mainwindow.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#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();
|
||||
client = new TCPClient;
|
||||
dataParser = new DataParser;
|
||||
|
||||
updateController = new UpdateController(dataParser);
|
||||
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(client,&TCPClient::onSendDebugLog,this,&MainWindow::DebugLog);
|
||||
|
||||
client->Initialize(updateController,recognizeSystem,externalExecuter);
|
||||
recognizeSystem->Initialize(updateController);
|
||||
|
||||
screenChecker->Check();
|
||||
ui->disblayCount->setText(screenChecker->getScreenCount());
|
||||
ui->updateButton->setEnabled(false);
|
||||
ui->startButton->setEnabled(false);
|
||||
|
||||
maxBytesAvailable = 0;
|
||||
ui->loadingProgressBar->setValue(0);
|
||||
|
||||
client->SetConnect(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::on_loginButton_clicked()
|
||||
{
|
||||
QString username = ui->loginInputField->text();
|
||||
QString password = ui->passwordInputField->text();
|
||||
|
||||
qDebug() << "Try login: " << username;
|
||||
qDebug() << "Try pass: " << password;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_updateButton_clicked()
|
||||
{
|
||||
client->onMessageEntered("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);
|
||||
client->SetConnect(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()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_checkUpdate_clicked()
|
||||
{
|
||||
client->onMessageEntered("check");
|
||||
}
|
||||
Reference in New Issue
Block a user