mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
ref: change initialize logic
*complete without change animation
This commit is contained in:
488
mainwindow.cpp
488
mainwindow.cpp
@@ -8,7 +8,6 @@
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include <Widgets/updatenotifywidget.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
@@ -17,70 +16,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
offlinePosition(240,340,300,40)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
isRecovery = false;
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||
_background.load(":/resource/SSJ_backgroundDarkSM.png");
|
||||
}
|
||||
|
||||
void MainWindow::createObjects()
|
||||
{
|
||||
qRegisterMetaType<PacketType>("PacketType");
|
||||
updateWidget = new UpdateNotifyWidget;
|
||||
|
||||
QMutex *mutex = new QMutex;
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
updateWidget->setParent(this);
|
||||
commonButtonGroupWidget = new CommonButtonGroupWidget;
|
||||
instructorButtonGroup = new InstructorButtonGroupWidget;
|
||||
|
||||
entryWidget = new EntryWidget;
|
||||
versionSelectWidget = new VersionSelectWidget;
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
waitAnimationWidget->setParent(this);
|
||||
|
||||
ui->changButtonGroup->addWidget(commonButtonGroupWidget);
|
||||
ui->interactiveGroup->addWidget(entryWidget);
|
||||
|
||||
workerThread = new QThread;
|
||||
animationThread = new QThread;
|
||||
|
||||
client = new TCPClient;
|
||||
client->moveToThread(workerThread);
|
||||
|
||||
notifyController = new NotifyController;
|
||||
notifyController->setParent(this);
|
||||
|
||||
dataParser = new DataParser;
|
||||
dataParser->moveToThread(workerThread);
|
||||
|
||||
dataParserOutput = new DataParserOutput;
|
||||
dataParser->moveToThread(workerThread);
|
||||
|
||||
sendSystem = new SendSystem;
|
||||
sendSystem->moveToThread(workerThread);
|
||||
|
||||
updateController = new UpdateController(dataParserOutput,sendSystem);
|
||||
updateController->moveToThread(workerThread);
|
||||
|
||||
recognizeSystem = new RecognizeSystem;
|
||||
recognizeSystem->moveToThread(workerThread);
|
||||
|
||||
postProcessorSystem = new PostProcessorSystem;
|
||||
postProcessorSystem->moveToThread(workerThread);
|
||||
|
||||
screenChecker = new ScreenChecker(this,dataParserOutput,ui->displayLayout);
|
||||
externalExecuter = new ExternalExecuter;
|
||||
|
||||
hashComparer = new HashComparer(dataParser);
|
||||
hashComparer->moveToThread(workerThread);
|
||||
|
||||
versionContainer = new VersionContainer;
|
||||
resourceManager = new ResourceManager;
|
||||
|
||||
workerThread->start();
|
||||
workerThread->setPriority(QThread::HighestPriority);
|
||||
|
||||
timer = new QTimer;
|
||||
}
|
||||
@@ -101,178 +39,53 @@ void MainWindow::paintEvent(QPaintEvent*) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::initialize()
|
||||
void MainWindow::initialize(ResourceManager *resourceManager)
|
||||
{
|
||||
createObjects();
|
||||
loadStaticData();
|
||||
bindConnection();
|
||||
|
||||
updateWidget->initialize(versionContainer,pos());
|
||||
entryWidget->initialize();
|
||||
versionSelectWidget->initialize(sendSystem,versionContainer,notifyController);
|
||||
hashComparer->initialize(versionContainer);
|
||||
updateController->initialize(versionContainer);
|
||||
postProcessorSystem->initialize(dataParserOutput,hashComparer,versionContainer,updateController);
|
||||
dataParser->initialize(postProcessorSystem);
|
||||
recognizeSystem->initialize(dataParser, versionContainer, postProcessorSystem);
|
||||
resourceManager->painting();
|
||||
commonButtonGroupWidget->initialize(externalExecuter,sendSystem);
|
||||
commonButtonGroupWidget->show();
|
||||
this->resourceManager = resourceManager;
|
||||
ui->LanguageWidget->hide();
|
||||
|
||||
setUpUi();
|
||||
}
|
||||
|
||||
void MainWindow::setStartState()
|
||||
{
|
||||
show();
|
||||
setInlineDebug(tr("Инициализация..."));
|
||||
emit sigCalculateHash();
|
||||
emit sigInitializeClient(recognizeSystem,sendSystem);
|
||||
|
||||
screenChecker->check();
|
||||
|
||||
emit sigSetConnect(dataParser->getClientSettings(),workerThread);
|
||||
checkAppAvailable();
|
||||
|
||||
//post
|
||||
QString title = tr("Тренажер процедур технического обслуживания самолета RRJ-95NEW-100");
|
||||
ui->headerLabel->setText(title);
|
||||
ui->versionLayoutWidget->hide();
|
||||
setUpUi();
|
||||
}
|
||||
|
||||
void MainWindow::bindConnection()
|
||||
{
|
||||
connect(timer,&QTimer::timeout,this,&MainWindow::slotDisableNotify);
|
||||
|
||||
connect(this,&MainWindow::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSendCommand,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSendCheck,sendSystem,&SendSystem::sendCheckHash,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
|
||||
connect(this,&MainWindow::sigSendCheckUpdate,updateController,&UpdateController::checkCanUpdate,Qt::AutoConnection);
|
||||
connect(this,&MainWindow::sigGetConnected,client,&TCPClient::getIsConnected);
|
||||
connect(this,&MainWindow::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
|
||||
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigCallUpdateList,this,&MainWindow::callUpdateList,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigSocketDisabled,this,&MainWindow::lostConnection,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigServerBlocked,this,&MainWindow::serverBlocked,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas,Qt::AutoConnection); // ОПАСНОСТЬ
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigSaveLoginData,this,&MainWindow::checkLoginResult,Qt::AutoConnection);
|
||||
connect(postProcessorSystem,&PostProcessorSystem::sigShowUpdateList,this,&MainWindow::showUpdateInfo,Qt::AutoConnection);
|
||||
|
||||
connect(versionContainer,&VersionContainer::sigSetServerVersion,this,&MainWindow::setServerVersion);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&MainWindow::updateProgress,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigLoadComplete,this,&MainWindow::loadComplete);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&MainWindow::setNeedUpdate);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigCheckUpdate,this,&MainWindow::checkUpdate,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigSetInineDebug,this,&MainWindow::setInlineDebug,Qt::AutoConnection);
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAnimationActivated,this,&MainWindow::activateLoadingAnimation,Qt::AutoConnection);
|
||||
|
||||
connect(updateWidget,&UpdateNotifyWidget::sigLoadToServerBehaviour,this,&MainWindow::loadToServer,Qt::AutoConnection);
|
||||
connect(updateWidget,&UpdateNotifyWidget::sigUndoCurrentChanges,this,&MainWindow::undoCurrentChanges,Qt::AutoConnection);
|
||||
connect(updateWidget,&UpdateNotifyWidget::sigStartUnityClient,this,&MainWindow::startUnityClient,Qt::AutoConnection);
|
||||
connect(updateWidget,&UpdateNotifyWidget::sigShowMainFrame,this,&MainWindow::showMainFrame,Qt::AutoConnection);
|
||||
|
||||
connect(hashComparer,&HashComparer::sigCallCheck,this,&MainWindow::checkUpdate);
|
||||
connect(hashComparer,&HashComparer::sigHaveDelta,this,&MainWindow::showUpdateInfo);
|
||||
|
||||
connect(updateController,&UpdateController::sigUpdateComplete,this,&MainWindow::showCompleteDialogBox);
|
||||
|
||||
connect(client,&TCPClient::sigConnectionState,this,&MainWindow::slotConnectionState,Qt::AutoConnection);
|
||||
connect(client,&TCPClient::sigServerDisconnect,this,&MainWindow::slotServerDisconnect);
|
||||
|
||||
connect(sendSystem,&SendSystem::sigSend,this,&MainWindow::updateProgress);
|
||||
|
||||
connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParserOutput,&DataParserOutput::xmlAnswer_notify,Qt::DirectConnection);//ОПАСНОСТЬ
|
||||
|
||||
connect(commonButtonGroupWidget,&CommonButtonGroupWidget::sigUpdateCommonWidget,this,&MainWindow::commonWidgetState);
|
||||
connect(entryWidget,&EntryWidget::sigTryLogin,this,&MainWindow::login,Qt::AutoConnection);
|
||||
connect(entryWidget,&EntryWidget::sigSaveServerSettings,this,&MainWindow::saveServerSettingsWithConnect,Qt::AutoConnection);
|
||||
|
||||
connect(instructorButtonGroup,&InstructorButtonGroupWidget::sigLoadToServer,this,&MainWindow::loadToServer, Qt::AutoConnection);
|
||||
connect(instructorButtonGroup,&InstructorButtonGroupWidget::sigUndoCurrentChanges,this,&MainWindow::undoCurrentChanges, Qt::AutoConnection);
|
||||
connect(instructorButtonGroup,&InstructorButtonGroupWidget::sigStartUnityClient,this,&MainWindow::startUnityClient, Qt::AutoConnection);
|
||||
|
||||
connect(dataParser,&DataParser::sigNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection);//ОПАСНОСТЬ
|
||||
connect(dataParser,&DataParser::sigUpdateFilesOnServer,updateController,&UpdateController::updateFilesOnServer,Qt::AutoConnection);//ОПАСНОСТЬ
|
||||
}
|
||||
|
||||
void MainWindow::updateProgress()
|
||||
void MainWindow::loadCompleteState()
|
||||
{
|
||||
filesLoaded++;
|
||||
float value = 100 / ((float)fileCountForUpdate / filesLoaded);
|
||||
commonButtonGroupWidget->updateProgressBar(value);
|
||||
}
|
||||
|
||||
void MainWindow::loadComplete()
|
||||
{
|
||||
externalExecuter->findApp();
|
||||
commonButtonGroupWidget->loadCompleteState();
|
||||
autoStart();
|
||||
ui->inlineTextDebug->setText(tr("Обновление завершено"));
|
||||
ui->offlineStartButton->setEnabled(true);
|
||||
ui->autostartCheckBox->hide();
|
||||
ui->offlineStartButton->show();
|
||||
|
||||
dataParserOutput->changeVersion(versionContainer->getServerVersionData());
|
||||
setTitle();
|
||||
}
|
||||
|
||||
void MainWindow::setNeedUpdate(bool flag,quint64 size, quint64 fileCount,quint64 deleteCount)
|
||||
bool MainWindow::getIsAutoStart()
|
||||
{
|
||||
fileCountForUpdate = 0;
|
||||
filesLoaded = 0;
|
||||
fileCountForUpdate = fileCount;
|
||||
QString availableSizeText;
|
||||
|
||||
if (flag && isRecovery)
|
||||
{
|
||||
ui->inlineTextDebug->setText(tr("Восстановление версии..."));
|
||||
|
||||
}
|
||||
else if(flag)
|
||||
{
|
||||
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();
|
||||
activateLoadingAnimation(false);
|
||||
setTitle();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->inlineTextDebug->setText(tr("Установлена последняя версия"));
|
||||
autoStart();
|
||||
commonButtonGroupWidget->lastVerInstalledState();
|
||||
ui->unsafeChangingButton->hide();
|
||||
ui->offlineStartButton->setEnabled(true);
|
||||
dataParserOutput->changeVersion(versionContainer->getServerVersionData());
|
||||
activateLoadingAnimation(false);
|
||||
setTitle();
|
||||
}
|
||||
return ui->autostartCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void MainWindow:: showServerListWidget(QList<StreamingVersionData *> *serverData)
|
||||
void MainWindow::setLastVersionState()
|
||||
{
|
||||
entryWidget->hide();
|
||||
activateLoadingAnimation(false);
|
||||
versionSelectWidget->fillView(serverData);
|
||||
setInlineDebug(tr("Установлена последняя версия"));
|
||||
ui->unsafeChangingButton->hide();
|
||||
ui->offlineStartButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::lostConnection()
|
||||
void MainWindow::setNeedUpdateState(const QString& notifyText)
|
||||
{
|
||||
commonButtonGroupWidget->updateProgressBar(0);
|
||||
slotConnectionState(false);
|
||||
setInlineDebug(notifyText);
|
||||
ui->autostartCheckBox->show();
|
||||
}
|
||||
|
||||
void MainWindow::serverBlocked()
|
||||
@@ -287,109 +100,47 @@ void MainWindow::serverBlocked()
|
||||
timer->start(3000);
|
||||
}
|
||||
|
||||
void MainWindow::checkLoginResult(ServerAuthorization *serverAuth)
|
||||
void MainWindow::setLoginSuccessState()
|
||||
{
|
||||
if (serverAuth->Result)
|
||||
{
|
||||
|
||||
if (serverAuth->AccessType != "instructor") //временно для отладки загрузки на сервер
|
||||
{
|
||||
checkUpdate();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sigSendXMLAnswer(cmd_CheckVersionList);
|
||||
}
|
||||
|
||||
dataParserOutput->createAuthData(serverAuth);
|
||||
entryWidget->loginIsActive(false);
|
||||
//ui->LanguageWidget->hide();
|
||||
ui->settingsButton->hide();
|
||||
ui->offlineStartButton->show();
|
||||
activateLoadingAnimation(true);
|
||||
setTitle();
|
||||
}
|
||||
else
|
||||
{
|
||||
entryWidget->loginIsActive(true);
|
||||
ui->notificationLabel->setText(tr("Неверный логин/пароль"));
|
||||
timer->setInterval(3000);
|
||||
timer->start();
|
||||
|
||||
QPalette palette = ui->notificationLabel->palette();
|
||||
palette.setColor(ui->notificationLabel->foregroundRole(), Qt::red);
|
||||
|
||||
ui->notificationLabel->setPalette(palette);
|
||||
ui->notificationLabel->show();
|
||||
}
|
||||
|
||||
ui->settingsButton->hide();
|
||||
ui->offlineStartButton->show();
|
||||
ui->versionLayoutWidget->show();
|
||||
}
|
||||
|
||||
void MainWindow::checkAppAvailable()
|
||||
void MainWindow::setLoginFailedState()
|
||||
{
|
||||
ui->notificationLabel->setText(tr("Неверный логин/пароль"));
|
||||
timer->setInterval(3000);
|
||||
timer->start();
|
||||
|
||||
QPalette palette = ui->notificationLabel->palette();
|
||||
palette.setColor(ui->notificationLabel->foregroundRole(), Qt::red);
|
||||
|
||||
ui->notificationLabel->setPalette(palette);
|
||||
ui->notificationLabel->show();
|
||||
}
|
||||
|
||||
void MainWindow::setStartOfflineButton(bool isAvailable)
|
||||
{
|
||||
bool isAvailable = externalExecuter->findApp();
|
||||
commonButtonGroupWidget->startButtonActive(isAvailable);
|
||||
ui->offlineStartButton->setEnabled(isAvailable);
|
||||
}
|
||||
|
||||
void MainWindow::checkLanguage(QString language)
|
||||
void MainWindow::setClientVersionName(const QString& versionName)
|
||||
{
|
||||
if (language == "RUS")
|
||||
{
|
||||
translator.load("QtLanguage_ru_RU",".");
|
||||
}
|
||||
else if(language == "ENG")
|
||||
{
|
||||
translator.load("QtLanguage_eng_EN",".");
|
||||
}
|
||||
|
||||
qApp->installTranslator(&translator);
|
||||
ui->retranslateUi(this);
|
||||
ui->valueClientVersion->setText(versionName);
|
||||
}
|
||||
|
||||
void MainWindow::autoStart()
|
||||
{
|
||||
if(ui->autostartCheckBox->isChecked()){
|
||||
startUnityClient();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setTitle()
|
||||
{
|
||||
ui->versionLayoutWidget->show();
|
||||
ServerSettings *currentSettings = dataParser->getClientSettings();
|
||||
StreamingVersionData *versionData = new StreamingVersionData;
|
||||
versionData->setName(currentSettings->LocalVersionName);
|
||||
versionData->setIsChangeable(currentSettings->versionData.getIsChangeable());
|
||||
versionContainer->setLocalVersionData(versionData);
|
||||
|
||||
ui->valueClientVersion->setText(versionContainer->getLocalVersion());
|
||||
//title.append(" (" + currentSettings->LocalVersionName + ")");
|
||||
}
|
||||
|
||||
void MainWindow::loadStaticData()
|
||||
{
|
||||
ServerSettings *currentSettings = dataParser->getClientSettings();
|
||||
entryWidget->fillSettings(currentSettings);
|
||||
ui->languageComboBox->setCurrentText(currentSettings->Language);
|
||||
ui->autostartCheckBox->setChecked(currentSettings->isAutoStart);
|
||||
|
||||
checkLanguage(currentSettings->Language);
|
||||
}
|
||||
|
||||
void MainWindow::showConnectionEmpty()
|
||||
{
|
||||
QPalette palette = ui->notificationLabel->palette();
|
||||
palette.setColor(ui->notificationLabel->foregroundRole(),Qt::red);
|
||||
ui->notificationLabel->setText(tr("Соединение отсутсвует"));
|
||||
entryWidget->connectionEmptyState();
|
||||
updateWidget->hide();
|
||||
ui->offlineStartButton->show();
|
||||
ui->offlineStartButton->setGeometry(offlinePosition);
|
||||
ui->offlineStartButton->raise();
|
||||
ui->settingsButton->show();
|
||||
ui->unsafeChangingButton->hide();
|
||||
versionSelectWidget->hide();
|
||||
}
|
||||
|
||||
void MainWindow::disableUnsaveButton(bool flag)
|
||||
@@ -404,14 +155,12 @@ void MainWindow::slotConnectionState(bool flag)
|
||||
QPalette palette = ui->notificationLabel->palette();
|
||||
ui->versionLayoutWidget->hide();
|
||||
|
||||
activateLoadingAnimation(false);
|
||||
setInlineDebug("");
|
||||
|
||||
if(flag)
|
||||
{
|
||||
palette.setColor(ui->notificationLabel->foregroundRole(),Qt::green);
|
||||
ui->notificationLabel->setText(tr("Соединение установлено"));
|
||||
entryWidget->loginIsActive(true);
|
||||
|
||||
ui->offlineStartButton->show();
|
||||
ui->offlineStartButton->setGeometry(bottomRightPosition);
|
||||
@@ -427,7 +176,6 @@ void MainWindow::slotConnectionState(bool flag)
|
||||
|
||||
void MainWindow::slotServerDisconnect()
|
||||
{
|
||||
commonButtonGroupWidget->disconnectState();
|
||||
ui->autostartCheckBox->hide();
|
||||
ui->inlineTextDebug->setText("");
|
||||
slotConnectionState(false);
|
||||
@@ -444,63 +192,23 @@ void MainWindow::slotDisableNotify()
|
||||
timer->stop();
|
||||
}
|
||||
|
||||
void MainWindow::callUpdateList()
|
||||
void MainWindow::showOfflineButton(bool flag)
|
||||
{
|
||||
hashComparer->setWidget(updateWidget);
|
||||
emit sigSendXMLAnswer(cmd_GetServerHash);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::login()
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
{
|
||||
showConnectionEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
entryWidget->loginIsActive(false);
|
||||
ClientAutorization *autorization = entryWidget->getAuthData();
|
||||
dataParserOutput->createAuthMessage(autorization);
|
||||
emit sigSendAutorization();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::saveServerSettingsWithConnect()
|
||||
{
|
||||
activateLoadingAnimation(true);
|
||||
entryWidget->isActive(false);
|
||||
ServerSettings *settings = entryWidget->getServerSettings();
|
||||
settings->LocalVersionName = dataParser->getClientSettings()->LocalVersionName;
|
||||
dataParserOutput->createServerSettings(settings);
|
||||
|
||||
if(client->getIsConnected())
|
||||
{
|
||||
entryWidget->loginIsActive(true);
|
||||
if (flag)
|
||||
ui->offlineStartButton->show();
|
||||
activateLoadingAnimation(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sigSetConnect(settings,workerThread);
|
||||
}
|
||||
|
||||
//TODO: не заполняется 2 поля (автостарт и язык)
|
||||
|
||||
ui->offlineStartButton->hide();
|
||||
}
|
||||
|
||||
void MainWindow::on_settingsButton_clicked()
|
||||
{
|
||||
entryWidget->settingsState();
|
||||
entryWidget->isActive(true);
|
||||
emit sigShowSettings(true);
|
||||
ui->offlineStartButton->hide();
|
||||
}
|
||||
|
||||
void MainWindow::on_languageComboBox_activated(const QString &arg1)
|
||||
{
|
||||
qDebug() << arg1;
|
||||
dataParserOutput->saveClientSettrings(arg1,ui->autostartCheckBox->isChecked());
|
||||
checkLanguage(arg1);
|
||||
emit sigChangeLanguage(arg1);
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
@@ -508,96 +216,40 @@ void MainWindow::loadToServer()
|
||||
{
|
||||
ui->mainFrame->show();
|
||||
ui->inlineTextDebug->setText(tr("Отправка файлов..."));
|
||||
commonButtonGroupWidget->showProgressBar(true);
|
||||
ui->offlineStartButton->setEnabled(false);
|
||||
updateWidget->hide();
|
||||
ui->unsafeChangingButton->hide();
|
||||
|
||||
emit sigSendCheckUpdate();
|
||||
}
|
||||
|
||||
void MainWindow::undoCurrentChanges()
|
||||
{
|
||||
isRecovery = true;
|
||||
emit sigSendCheck();
|
||||
ui->mainFrame->show();
|
||||
|
||||
commonButtonGroupWidget->showProgressBar(false);
|
||||
ui->offlineStartButton->setEnabled(false);
|
||||
updateWidget->hide();
|
||||
|
||||
activateLoadingAnimation(true);
|
||||
|
||||
//delay
|
||||
|
||||
QTime dieTime= QTime::currentTime().addSecs(10);
|
||||
while (QTime::currentTime() < dieTime)
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
|
||||
activateLoadingAnimation(true);
|
||||
|
||||
emit sigSendCommand(PacketType::TYPE_UPDATE);
|
||||
ui->unsafeChangingButton->hide();
|
||||
|
||||
isRecovery = false;
|
||||
activateLoadingAnimation(false);
|
||||
}
|
||||
|
||||
void MainWindow::on_unsafeChangingButton_clicked()
|
||||
{
|
||||
showUpdateInfo();
|
||||
updateWidget->show();
|
||||
emit sigShowUpdateInfo();
|
||||
}
|
||||
|
||||
void MainWindow::on_exitButton_clicked()
|
||||
{
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
client->disconnect();
|
||||
|
||||
workerThread->quit();
|
||||
workerThread->wait();
|
||||
|
||||
delete workerThread;
|
||||
emit sigExit();
|
||||
delete ui;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void MainWindow::checkUpdate()
|
||||
{
|
||||
emit sigSendCheck();
|
||||
ui->inlineTextDebug->setText(tr("Проверка обновлений..."));
|
||||
}
|
||||
|
||||
void MainWindow::showUpdateInfo()
|
||||
{
|
||||
activateLoadingAnimation(false);
|
||||
updateWidget->showWithFill();
|
||||
showMainFrame(false);
|
||||
ui->unsafeChangingButton->show();
|
||||
entryWidget->hide();
|
||||
commonButtonGroupWidget->show();
|
||||
ui->offlineStartButton->setGeometry(bottomRightPosition);
|
||||
fileCountForUpdate = hashComparer->getFileUpdateCount();
|
||||
|
||||
filesLoaded = 0;
|
||||
}
|
||||
|
||||
void MainWindow::showCompleteDialogBox()
|
||||
{
|
||||
ui->inlineTextDebug->setText(tr("Загрузка завершена"));
|
||||
activateLoadingAnimation(true);
|
||||
}
|
||||
|
||||
void MainWindow::startUnityClient()
|
||||
{
|
||||
externalExecuter->callApp();
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentVersionName(StreamingVersionData *version)
|
||||
{
|
||||
versionContainer->setLocalVersionData(version);
|
||||
}
|
||||
|
||||
void MainWindow::setUpUi()
|
||||
@@ -615,16 +267,12 @@ void MainWindow::setUpUi()
|
||||
ui->unsafeChangingButton->setIcon(*resourceManager->getUnsavedIcon());
|
||||
ui->unsafeChangingButton->setIconSize(cautionIconSize);
|
||||
|
||||
waitAnimationWidget->setMovie(resourceManager->getMovie());
|
||||
|
||||
QSize iconSize(20,20);
|
||||
ui->exitButton->setIcon(*resourceManager->getCloseIcon());
|
||||
ui->exitButton->setIconSize(iconSize);
|
||||
|
||||
ui->displayGroupWidget->show();
|
||||
ui->autostartCheckBox->hide();
|
||||
|
||||
activateLoadingAnimation(true);
|
||||
}
|
||||
|
||||
void MainWindow::commonWidgetState()
|
||||
@@ -637,20 +285,8 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
|
||||
{
|
||||
if (entryWidget->isLoginFieldsFill()) return;
|
||||
login();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::activateLoadingAnimation(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
emit sigTryLogin();
|
||||
//if (entryWidget->isLoginFieldsFill()) return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,24 +306,30 @@ void MainWindow::setServerVersion(StreamingVersionData *version)
|
||||
ui->valueServerVersion->setText(version->getViewName());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
QHBoxLayout *MainWindow::getDisplayLayout() const
|
||||
{
|
||||
workerThread->quit();
|
||||
workerThread->wait();
|
||||
return ui->displayLayout;
|
||||
}
|
||||
|
||||
emit sigSendXMLAnswer(cmd_Disable);
|
||||
void MainWindow::addWidgetToChangeGroup(CommonButtonGroupWidget *commonWidgetGroup)
|
||||
{
|
||||
ui->changButtonGroup->addWidget(commonWidgetGroup);
|
||||
}
|
||||
|
||||
delete workerThread;
|
||||
delete ui;
|
||||
void MainWindow::addWidgetToInteractiveGroup(EntryWidget *entryWidget)
|
||||
{
|
||||
ui->interactiveGroup->addWidget(entryWidget);
|
||||
}
|
||||
|
||||
void MainWindow::setLoadSettings(ServerSettings *serverSettings)
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
|
||||
ui->languageComboBox->setCurrentText(serverSettings->Language);
|
||||
ui->autostartCheckBox->setChecked(serverSettings->isAutoStart);
|
||||
}
|
||||
|
||||
void MainWindow::on_offlineStartButton_clicked()
|
||||
{
|
||||
QString username = "offlineUser";
|
||||
QString password = "000000";
|
||||
|
||||
dataParserOutput->createAuthDataOffline(username,password);
|
||||
startUnityClient();
|
||||
|
||||
|
||||
emit sigStartOffline();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user