ref: change initialize logic

*complete without change animation
This commit is contained in:
semenov
2025-08-14 15:40:46 +03:00
parent 05e09792d7
commit 0c805708ef
38 changed files with 1047 additions and 1008 deletions

View File

@@ -3,18 +3,18 @@
#include <QThread>
UpdateController::UpdateController(DataParserOutput *dataParserOut, SendSystem *sendSystem, QObject *parent) :
UpdateController::UpdateController(QObject *parent) :
QObject(parent),
versionContainer(nullptr)
{
this->sendSystem = sendSystem;
this->dataParserOut = dataParserOut;
applicationFolderPath = QDir::currentPath() + applicationFolderName;
}
void UpdateController::initialize(VersionContainer *versionContainer)
void UpdateController::initialize(VersionContainer *versionContainer,DataParserOutput *dataParserOut, SendSystem *sendSystem)
{
this->versionContainer = versionContainer;
this->sendSystem = sendSystem;
this->dataParserOut = dataParserOut;
}
void UpdateController::calculateCommonHash()

View File

@@ -26,17 +26,16 @@ class UpdateController : public QObject
Q_OBJECT
public:
explicit UpdateController(DataParserOutput *dataParser, SendSystem *sendSystem,
QObject *parent = 0);
explicit UpdateController(QObject *parent = 0);
void initialize(VersionContainer *versionContainer);
void initialize(VersionContainer *versionContainer,DataParserOutput *dataParser, SendSystem *sendSystem);
void calculateCommonHash();
void calculateStreamingHash();
~UpdateController();
void updateFilesOnServer(QList<FileData> *fileSendList);
void checkCanUpdate();
signals:
void sigUpdateComplete(bool flag);
private:

View File

@@ -132,27 +132,27 @@ void DataParser::xmlParser(const QByteArray& array)
postProcessSystem->startCompare();
}
if (value == "BASEDELETETRY")
{
emit sigNotify(tr("Нельзя удалять базовую версию"));
}
// if (value == "BASEDELETETRY")
// {
// emit sigNotify(tr("Нельзя удалять базовую версию"));
// }
if (value == "TRYACTIVEDELETE")
{
emit sigNotify(tr("Нельзя удалять активную версию"));
}
// if (value == "TRYACTIVEDELETE")
// {
// emit sigNotify(tr("Нельзя удалять активную версию"));
// }
if (value == "DUPLICATEVERNAME")
{
emit sigNotify(tr("Такое имя уже существет"));
}
// if (value == "DUPLICATEVERNAME")
// {
// emit sigNotify(tr("Такое имя уже существет"));
// }
if (value == "UNCHANGEABLE")
{
emit sigNotify(tr("Нельзя выгружать в базовую версию"));
postProcessSystem->showUpdateList();
//emit recognizeSystem->sigShowUpdateList();
}
// if (value == "UNCHANGEABLE")
// {
// emit sigNotify(tr("Нельзя выгружать в базовую версию"));
// postProcessSystem->showUpdateList();
// //emit recognizeSystem->sigShowUpdateList();
// }
if (value == "CHANGEABLE")
{

View File

@@ -256,7 +256,7 @@ void DataParserOutput::addRunData(QList<int> displays)
}
void DataParserOutput::saveClientSettrings(const QString& language, bool isAutoStart)
void DataParserOutput::saveClientSettings(const QString& language, bool isAutoStart)
{
QFile file(settingsName);
file.open(QIODevice::ReadOnly | QIODevice::Text);

View File

@@ -22,7 +22,7 @@ public:
void createAuthData(ServerAuthorization *serverAuth);
void createAuthDataOffline(const QString& username,const QString& pass);
void addRunData(QList<int> displays);
void saveClientSettrings(const QString& language, bool isAutoStart);
void saveClientSettings(const QString& language, bool isAutoStart);
QList<FileData> *xmlFileDataParse(const QByteArray& array,const QString& filter = "");
QByteArray xmlAnswer_notify(const QString& code);
QByteArray xmlAnswer(const QList<SXmlAnswerTag>& listTag, const QString& elemUp1 = "", const QString& elemUp2 = "");

View File

@@ -27,3 +27,13 @@ bool ExternalExecuter::findApp()
return false;
}
bool ExternalExecuter::getIsAutoStart() const
{
return isAutoStart;
}
void ExternalExecuter::setIsAutoStart(bool value)
{
isAutoStart = value;
}

View File

@@ -20,8 +20,12 @@ public:
void callApp();
bool findApp();
bool getIsAutoStart() const;
void setIsAutoStart(bool value);
private:
QString programPath;
bool isAutoStart;
};
#endif // EXTERNALEXECUTER_H

View File

@@ -8,9 +8,11 @@ HashComparer::HashComparer(QObject *) :
}
void HashComparer::initialize(VersionContainer *versionContainer)
void HashComparer::initialize(VersionContainer *versionContainer,UpdateNotifyWidget* updateWidget)
{
this->versionContainer = versionContainer;
this->updateWidget = updateWidget;
filesForUpdate = new QList<FileData>;
}
void HashComparer::CompareDeltas(QList<FileData> *serverStreamingHash, QList<FileData> localStreamingHash)
@@ -47,11 +49,6 @@ void HashComparer::showDeltas()
emit sigHaveDelta();
}
void HashComparer::setWidget(UpdateNotifyWidget* updateWidget)
{
this->updateWidget = updateWidget;
}
quint16 HashComparer::getFileUpdateCount() const
{
return filesForUpdate->count();

View File

@@ -13,12 +13,11 @@ class HashComparer :public QObject
Q_OBJECT
public:
explicit HashComparer(QObject *parent = nullptr);
void initialize(VersionContainer *versionContainer);
void initialize(VersionContainer *versionContainer,UpdateNotifyWidget* updateWidget);
void CompareDeltas(QList<FileData> *serverStreamingHash, QList<FileData> localStreamingHash);
~HashComparer() = default;
void showDeltas();
void setWidget(UpdateNotifyWidget *updateWidget);
quint16 getFileUpdateCount() const;
QList<FileData> *getFilesForUpdate() const;
signals:

View File

@@ -1,6 +1,5 @@
#include "Core/recognizesystem.h"
RecognizeSystem::RecognizeSystem(QObject *parent):
QObject(parent),
versionContainer(nullptr),

View File

@@ -27,7 +27,6 @@ public:
void recognize(QTcpSocket *socket);
void showServerDataList(QList<StreamingVersionData*> *showServerDataList);
signals:
void sigUpdateBytesAvailable();
void sigLoadComplete();

View File

@@ -1,13 +1,10 @@
#include "screenchecker.h"
#include <windows.h>
ScreenChecker::ScreenChecker(QWidget *mainWidget,DataParserOutput *dataParserOut, QHBoxLayout *layout, QObject *parent) :
ScreenChecker::ScreenChecker(QObject *parent) :
QObject(parent)
{
screenCount = 0;
this->mainWidget = mainWidget;
this->layout = layout;
this->dataParserOutput = dataParserOut;
}
void ScreenChecker::check()
@@ -129,6 +126,12 @@ QString ScreenChecker::getScreenCount() const
return QString::number(screenCount);
}
void ScreenChecker::initialize(DataParserOutput *dataParserOutput, QHBoxLayout *layout)
{
this->layout = layout;
this->dataParserOutput = dataParserOutput;
}
ScreenChecker::~ScreenChecker()
{
for (auto & button : buttons)

View File

@@ -22,7 +22,8 @@ class ScreenChecker : public QObject
Q_OBJECT
public:
explicit ScreenChecker(QWidget *mainWidget,DataParserOutput *dataParserOutput, QHBoxLayout *layout,QObject *parent = nullptr);
explicit ScreenChecker(QObject *parent = nullptr);
void initialize(DataParserOutput *dataParserOutput, QHBoxLayout *layout);
~ScreenChecker();
void check();
QString getScreenCount() const;

View File

@@ -29,6 +29,9 @@ static QString cmd_GetServerHash = "GETSERVERDATALIST";
static QString cmd_Disable = "DISABLE";
static QString baseNamePackage = "base";
static QString instructorTypeName = "instructor";
static QString traineeTypeName = "trainee";
enum PacketType{
TYPE_NONE = 0,
TYPE_UNITY = 1,

View File

@@ -36,12 +36,14 @@ SOURCES += \
Widgets\commonbuttongroupwidget.cpp \
Widgets\entrywidget.cpp \
Widgets\instructorbuttongroupwidget.cpp \
bootstrap.cpp \
coremanager.cpp \
main.cpp \
mainwindow.cpp \
mywinheader.cpp \
Widgets\newversionwidget.cpp \
Widgets\updatenotifywidget.cpp \
Widgets\versionselectwidget.cpp \
widgetmanager.cpp
HEADERS += \
Core/dataparseroutput.h \
@@ -66,11 +68,13 @@ HEADERS += \
Widgets\commonbuttongroupwidget.h \
Widgets\entrywidget.h \
Widgets\instructorbuttongroupwidget.h \
bootstrap.h \
coremanager.h \
mainwindow.h \
mywinheader.h \
Widgets\newversionwidget.h \
Widgets\updatenotifywidget.h \
Widgets\versionselectwidget.h \
widgetmanager.h
FORMS += \
Widgets/waitanimationwidget.ui \
@@ -80,7 +84,6 @@ FORMS += \
mainwindow.ui \
Widgets\newversionwidget.ui \
Widgets\updatenotifywidget.ui \
Widgets\versionselectwidget.ui \
TRANSLATIONS = QtLanguage_ru.ts\
QtLanguage_eng.ts

View File

@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<AuthData Login="I1" Password="1111" InstructorName="Горинин Г.Г." ClientName="Горинин Г.Г." AccessType="instructor"/>
<AuthData Login="O1" Password="1111" InstructorName="" ClientName="Иванов И.И." AccessType="trainee"/>

View File

@@ -12,10 +12,6 @@
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/etc/mono/4.5" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/etc/mono/4.5/Browsers" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/etc/mono/mconfig" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data/Plugins" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data/Plugins/x86_64" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Plugins" Hash="FOLDER"/>
@@ -37,6 +33,7 @@
<FileData Path="/Application/RRJLoader/RRJ_Data/StreamingAssets/RUS/Scens" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/StreamingAssets/Sounds" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/StreamingAssets/Sounds/UI" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Temp" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/D3D12/D3D12Core.dll" Hash="7fc05c9a8366d19302dfd13d09d3ebac"/>
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/EmbedRuntime/mono-2.0-bdwgc.dll" Hash="127988c5569e01545ab82529630f4b3a"/>
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/EmbedRuntime/MonoPosixHelper.dll" Hash="f3db766a8a5ab9154e25de200a61e9ef"/>
@@ -61,15 +58,14 @@
<FileData Path="/Application/RRJLoader/nvngx_dlss.dll" Hash="e557b8eb18fbd710f82073d9f6fa55a9"/>
<FileData Path="/Application/RRJLoader/NVUnityPlugin.dll" Hash="7ea7367d7d2ddf75e5d5826ecba6e729"/>
<FileData Path="/Application/RRJLoader/RRJ.exe" Hash="b5765d286e416d63a08bb1f31ce4dc69"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data/Plugins/x86_64/lib_burst_generated.txt" Hash="56d687a9e8c5faa541830db17c2a5168"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/app.info" Hash="b0ac82165a3b21497e6e81ade4e23fe0"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/boot.config" Hash="7673265ef133ac05e95282ec5db9e6b6"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers" Hash="408ea1468f16b8ceef5e94fb29ad689d"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/boot.config" Hash="2a643340ca956ce11942a5bdaace5752"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers" Hash="d649246ca5adfbc6a7095054885cad81"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers.assets" Hash="c89ad7a0d7160f416c1efaa6f2d0b99a"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers.assets.resS" Hash="cc481c35e79b509dcd950c6adf2346ce"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/level0" Hash="6cccc6a0d9656a6cacab02d230ef3b51"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/level0.resS" Hash="3668556c7cc37236bfda94232caddb6b"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/Assembly-CSharp.dll" Hash="ba0d5865229740d36690cf2a495fb02b"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/Assembly-CSharp.dll" Hash="bcd149f15fe3580930c71276a909ab00"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/IngameDebugConsole.Runtime.dll" Hash="68c3bbc50f53aa8595149deff79539bf"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/Mono.Security.dll" Hash="051c8aaf3606869c9718c9352c4a0e89"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/mscorlib.dll" Hash="bdbb3cfe503185d616c99317438535a6"/>
@@ -192,11 +188,11 @@
<FileData Path="/Application/RRJLoader/RRJ_Data/Plugins/x86_64/pdfrenderer.dll" Hash="bb9613277346c4b3bf0ea29a44c903e9"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Resources/unity default resources" Hash="267f4472590aa65a9eea4f8c546077f4"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Resources/unity_builtin_extra" Hash="17e3c3ea97ad2574403c41477a7d6f9d"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/resources.assets" Hash="f18912a6cdf6c601786c3882aa9b16fc"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/resources.assets" Hash="7ad47392ff1144f6bfecc211ef3b0d47"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/resources.assets.resS" Hash="1d0b761a8d558d20b60c84d50d9d5721"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/RuntimeInitializeOnLoads.json" Hash="74bff99baeee016cd49dd3bf1385bd95"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/ScriptingAssemblies.json" Hash="af37f074cdc279e68638741a84bd003b"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.assets" Hash="1a66030b7233c24ee00fe9cb132b3a6c"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.assets" Hash="8f183648b225b265880594754d5f5347"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.assets.resS" Hash="4ad63d43c63f7ca778c7132dac84cd3e"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.resource" Hash="9c07c706a4ee630e3be0b492ab0bf4b8"/>
<FileData Path="/Application/RRJLoader/UnityCrashHandler64.exe" Hash="3725d98e4ac1229e90d5463029536f58"/>

View File

@@ -12,10 +12,6 @@
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/etc/mono/4.5" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/etc/mono/4.5/Browsers" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/MonoBleedingEdge/etc/mono/mconfig" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data/Plugins" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data/Plugins/x86_64" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed" Hash="FOLDER"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Plugins" Hash="FOLDER"/>
@@ -45,15 +41,14 @@
<FileData Path="/Application/RRJLoader/nvngx_dlss.dll" Hash="e557b8eb18fbd710f82073d9f6fa55a9"/>
<FileData Path="/Application/RRJLoader/NVUnityPlugin.dll" Hash="7ea7367d7d2ddf75e5d5826ecba6e729"/>
<FileData Path="/Application/RRJLoader/RRJ.exe" Hash="b5765d286e416d63a08bb1f31ce4dc69"/>
<FileData Path="/Application/RRJLoader/RRJ_BurstDebugInformation_DoNotShip/Data/Plugins/x86_64/lib_burst_generated.txt" Hash="56d687a9e8c5faa541830db17c2a5168"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/app.info" Hash="b0ac82165a3b21497e6e81ade4e23fe0"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/boot.config" Hash="7673265ef133ac05e95282ec5db9e6b6"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers" Hash="408ea1468f16b8ceef5e94fb29ad689d"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/boot.config" Hash="2a643340ca956ce11942a5bdaace5752"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers" Hash="d649246ca5adfbc6a7095054885cad81"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers.assets" Hash="c89ad7a0d7160f416c1efaa6f2d0b99a"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/globalgamemanagers.assets.resS" Hash="cc481c35e79b509dcd950c6adf2346ce"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/level0" Hash="6cccc6a0d9656a6cacab02d230ef3b51"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/level0.resS" Hash="3668556c7cc37236bfda94232caddb6b"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/Assembly-CSharp.dll" Hash="ba0d5865229740d36690cf2a495fb02b"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/Assembly-CSharp.dll" Hash="bcd149f15fe3580930c71276a909ab00"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/IngameDebugConsole.Runtime.dll" Hash="68c3bbc50f53aa8595149deff79539bf"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/Mono.Security.dll" Hash="051c8aaf3606869c9718c9352c4a0e89"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Managed/mscorlib.dll" Hash="bdbb3cfe503185d616c99317438535a6"/>
@@ -176,11 +171,11 @@
<FileData Path="/Application/RRJLoader/RRJ_Data/Plugins/x86_64/pdfrenderer.dll" Hash="bb9613277346c4b3bf0ea29a44c903e9"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Resources/unity default resources" Hash="267f4472590aa65a9eea4f8c546077f4"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/Resources/unity_builtin_extra" Hash="17e3c3ea97ad2574403c41477a7d6f9d"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/resources.assets" Hash="f18912a6cdf6c601786c3882aa9b16fc"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/resources.assets" Hash="7ad47392ff1144f6bfecc211ef3b0d47"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/resources.assets.resS" Hash="1d0b761a8d558d20b60c84d50d9d5721"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/RuntimeInitializeOnLoads.json" Hash="74bff99baeee016cd49dd3bf1385bd95"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/ScriptingAssemblies.json" Hash="af37f074cdc279e68638741a84bd003b"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.assets" Hash="1a66030b7233c24ee00fe9cb132b3a6c"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.assets" Hash="8f183648b225b265880594754d5f5347"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.assets.resS" Hash="4ad63d43c63f7ca778c7132dac84cd3e"/>
<FileData Path="/Application/RRJLoader/RRJ_Data/sharedassets0.resource" Hash="9c07c706a4ee630e3be0b492ab0bf4b8"/>
<FileData Path="/Application/RRJLoader/UnityCrashHandler64.exe" Hash="3725d98e4ac1229e90d5463029536f58"/>

View File

@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ServerSettingsContainer>
<ServerSettings Language="RUS" Port="6000" Address="192.168.100.83" AutoStart="0" UseMathModel="1" DestPortMath="18003" LocalPortMath="18004"/>
<VersionData Version="base" isChangable="0" Created="Пт авг 8 13:27:27 2025"/>
<ServerSettings Address="192.168.100.134" UseMathModel="1" Language="RUS" LocalPortMath="18004" AutoStart="0" Port="6000" DestPortMath="18003"/>
<VersionData Created="Чт авг 7 17:38:47 2025" isChangable="0" Version="base"/>
</ServerSettingsContainer>

View File

@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<ClientNotify Code="CHECKVERSIONLIST"/>
<ClientNotify Code="CANCHANGE"/>

View File

@@ -8,18 +8,14 @@ CommonButtonGroupWidget::CommonButtonGroupWidget(QWidget *parent) :
ui->setupUi(this);
}
void CommonButtonGroupWidget::initialize(ExternalExecuter *extExec,SendSystem *sendSystem)
void CommonButtonGroupWidget::initialize()
{
externalExecuter = extExec;
this->sendSystem = sendSystem;
ui->loadingProgressBar->setValue(0);
ui->loadingProgressBar->hide();
ui->updateButton->hide();
ui->startButton->hide();
ui->startButton->setEnabled(false);
connect(this,&CommonButtonGroupWidget::sigSendPacket,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
connect(this,&CommonButtonGroupWidget::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
ui->startButton->setEnabled(false);
show();
}
void CommonButtonGroupWidget::updateProgressBar(float value)
@@ -41,6 +37,7 @@ void CommonButtonGroupWidget::lastVerInstalledState()
show();
ui->updateButton->hide();
ui->loadingProgressBar->hide();
ui->startButton->setEnabled(true);
ui->startButton->show();
}
@@ -88,8 +85,7 @@ void CommonButtonGroupWidget::on_updateButton_clicked()
void CommonButtonGroupWidget::on_startButton_clicked()
{
externalExecuter->callApp();
emit sigSendXMLAnswer(cmd_Disable);
emit sigStartUnityClient();
}
CommonButtonGroupWidget::~CommonButtonGroupWidget()

View File

@@ -8,17 +8,13 @@ namespace Ui {
class CommonButtonGroupWidget;
}
class TCPClient;
class ExternalExecuter;
class SendSystem;
class CommonButtonGroupWidget : public QWidget
{
Q_OBJECT
public:
explicit CommonButtonGroupWidget(QWidget *parent = nullptr);
void initialize(ExternalExecuter *extExec,SendSystem *sendSystem);
void initialize();
void loadCompleteState();
void lastVerInstalledState();
void disconnectState();
@@ -32,6 +28,7 @@ signals:
void sigSendPacket(PacketType packet);
void sigSendXMLAnswer(QString answer);
void sigUpdateCommonWidget();
void sigStartUnityClient();
private slots:
void on_updateButton_clicked();
@@ -42,8 +39,6 @@ public:
private:
Ui::CommonButtonGroupWidget *ui;
ExternalExecuter *externalExecuter;
SendSystem *sendSystem;
};
#endif // COMMONBUTTONGROUPWIDGET_H

View File

@@ -12,9 +12,8 @@ UpdateNotifyWidget::UpdateNotifyWidget(QWidget *) :
// setAttribute(Qt::WA_ShowModal,true);
}
void UpdateNotifyWidget::initialize(VersionContainer *verContainer,QPoint startPos)
void UpdateNotifyWidget::initialize(QPoint startPos)
{
this->versionContainer = verContainer;
currentLoadingCount = 0;
hide();
@@ -23,6 +22,11 @@ void UpdateNotifyWidget::initialize(VersionContainer *verContainer,QPoint startP
move(pos);
}
void UpdateNotifyWidget::setVersionContainer(VersionContainer *versionContainer)
{
this->versionContainer = versionContainer;
}
void UpdateNotifyWidget::addToList(FileData fileData)
{
QString itemName = fileData.path;

View File

@@ -11,7 +11,7 @@
namespace Ui {
class UpdateNotifyWidget;
}
class InstructorButtonGroupWidget;
class UpdateNotifyWidget : public QWidget
{
@@ -19,14 +19,14 @@ class UpdateNotifyWidget : public QWidget
public:
explicit UpdateNotifyWidget(QWidget *parent = nullptr);
void initialize(VersionContainer *versionContainer,QPoint startPos);
void initialize(QPoint startPos);
void addToList(FileData fileData);
void showWithFill();
~UpdateNotifyWidget();
void showTryChangeBase();
void setVersionContainer(VersionContainer *versionContainer);
signals:
void sigLoadToServerBehaviour();
void sigUndoCurrentChanges();

View File

@@ -1,105 +0,0 @@
#include "versionselectwidget.h"
#include "ui_versionselectwidget.h"
#include "Widgets/newversionwidget.h"
#include <QMessageBox>
VersionSelectWidget::VersionSelectWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::VersionSelectWidget),
selectedVersion(nullptr)
{
ui->setupUi(this);
}
void VersionSelectWidget::initialize(SendSystem *sendSystem,VersionContainer *versionContainer,NotifyController *notifyController)
{
connect(this,&VersionSelectWidget::sigSendSwitchVersion,sendSystem,&SendSystem::sendChangeVersion,Qt::AutoConnection);
connect(this,&VersionSelectWidget::sigSendCopyVersion,sendSystem,&SendSystem::sendCopyVersion,Qt::AutoConnection);
connect(this,&VersionSelectWidget::sigSendDeleteVersion,sendSystem,&SendSystem::sendDeleteVersion,Qt::AutoConnection);
connect(this,&VersionSelectWidget::sigSendNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection);
this->versionContainer = versionContainer;
hide();
}
void VersionSelectWidget::fillView(QList<StreamingVersionData *> *serverData)
{
show();
ui->verListView->clear();
serverDataList = serverData;
ui->verValue->setText(versionContainer->getServerVersionData()->getViewName());
foreach(StreamingVersionData *data,*serverData)
{
ui->verListView->addItem(data->getViewName());
}
}
void VersionSelectWidget::on_verListView_itemDoubleClicked(QListWidgetItem *item)
{
foreach(StreamingVersionData *data,*serverDataList)
{
if(data->getViewName() == item->text())
{
QString info = "Имя версии: " + data->getViewName() + "\n";
info.append("Создан: " + data->getCreateData().toString());
ui->infoValue->setText(info);
selectedVersion = data;
}
}
}
void VersionSelectWidget::on_createDuplicateButton_clicked()
{
NewVersionWidget *newVersionWidget = new NewVersionWidget;
newVersionWidget->initialize(selectedVersion->getViewName());
newVersionWidget->show();
connect(newVersionWidget,&NewVersionWidget::sigSendCopy,this,&VersionSelectWidget::sendCopyEmit);
}
void VersionSelectWidget::sendCopyEmit(QString newName)
{
QString result = selectedVersion->getViewName() + ";" + newName;
if (selectedVersion == nullptr)
{
sigSendNotify(tr("Версия не выбрана"));
return;
}
//versionContainer->setLocalVersionData(selectedVersion);
emit sigSendCopyVersion(result);
}
void VersionSelectWidget::on_DeleteVersionButton_clicked()
{
if (selectedVersion == nullptr)
{
sigSendNotify(tr("Версия не выбрана"));
return;
}
emit sigSendDeleteVersion(selectedVersion);
}
void VersionSelectWidget::on_switchServerVersionButton_clicked()
{
if (selectedVersion == nullptr)
{
sigSendNotify(tr("Версия не выбрана"));
return;
}
versionContainer->setServerVersionData(selectedVersion);
ui->verValue->setText(selectedVersion->getViewName());
emit sigSendSwitchVersion(selectedVersion);
}
VersionSelectWidget::~VersionSelectWidget()
{
delete ui;
}

View File

@@ -1,48 +0,0 @@
#ifndef VERSIONSELECTWIDGET_H
#define VERSIONSELECTWIDGET_H
#include <QListWidget>
#include <QWidget>
#include <Core/notifycontroller.h>
#include <Core/sendsystem.h>
#include <Core/versioncontainer.h>
#include <Data/streamingversiondata.h>
namespace Ui {
class VersionSelectWidget;
}
class VersionSelectWidget : public QWidget
{
Q_OBJECT
public:
explicit VersionSelectWidget(QWidget *parent = nullptr);
void initialize(SendSystem *sendSystem,VersionContainer *versionContainer,NotifyController *notifyController);
void fillView(QList<StreamingVersionData*> *serverData);
~VersionSelectWidget();
private slots:
void on_verListView_itemDoubleClicked(QListWidgetItem *item);
void on_createDuplicateButton_clicked();
void on_DeleteVersionButton_clicked();
void on_switchServerVersionButton_clicked();
void sendCopyEmit(QString newName);
signals:
void sigSendDeleteVersion(StreamingVersionData *streaming);
void sigSendSwitchVersion(StreamingVersionData *selectVersion);
void sigSendCopyVersion(QString versionPair);
void sigSendNotify(QString message);
private:
Ui::VersionSelectWidget *ui;
SendSystem *sendSystem;
QList<StreamingVersionData*> *serverDataList;
VersionContainer *versionContainer;
NotifyController *notifyController;
StreamingVersionData *selectedVersion;
};
#endif // VERSIONSELECTWIDGET_H

View File

@@ -1,240 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VersionSelectWidget</class>
<widget class="QWidget" name="VersionSelectWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>786</width>
<height>229</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>301</width>
<height>171</height>
</rect>
</property>
<layout class="QVBoxLayout" name="actualServerListLayout">
<item>
<widget class="QLabel" name="verListTitle">
<property name="font">
<font>
<family>Calibri</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::PreventContextMenu</enum>
</property>
<property name="text">
<string>Доступные версии на сервере</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="verListView"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>180</y>
<width>781</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="ButtonLayout" stretch="0,0,0">
<property name="spacing">
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="createDuplicateButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Создать копию</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="DeleteVersionButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Удалить</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="switchServerVersionButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Переключить версию сервера</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>170</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_2">
<property name="geometry">
<rect>
<x>310</x>
<y>0</y>
<width>471</width>
<height>131</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="infoViewTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Информация:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="infoValue">
<property name="text">
<string>Тут будет информация о версии...</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>310</x>
<y>140</y>
<width>471</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="ServerInfoLayout">
<item>
<widget class="QLabel" name="verTitle">
<property name="text">
<string>Текущая версия сервера:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="verValue">
<property name="text">
<string>none</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -9,10 +9,16 @@ WaitAnimationWidget::WaitAnimationWidget(QWidget *parent) :
ui->setupUi(this);
}
void WaitAnimationWidget::setMovie(QMovie *movie)
void WaitAnimationWidget::initialize(ResourceManager *resourceManager)
{
ui->MovieLabel->setMovie(movie);
loadingMovie = movie;
loadingMovie = resourceManager->getMovie();
ui->MovieLabel->setMovie(loadingMovie);
}
void WaitAnimationWidget::slotActivateLoadingAnimation(bool flag)
{
if (flag)showWithPlay();
else hideWithStop();
}
void WaitAnimationWidget::showWithPlay()
@@ -31,3 +37,5 @@ WaitAnimationWidget::~WaitAnimationWidget()
{
delete ui;
}

View File

@@ -3,6 +3,7 @@
#include <QMovie>
#include <QWidget>
#include <UI/resourcemanager.h>
namespace Ui {
class WaitAnimationWidget;
@@ -14,11 +15,14 @@ class WaitAnimationWidget : public QWidget
public:
explicit WaitAnimationWidget(QWidget *parent = nullptr);
void setMovie(QMovie *movie);
void initialize(ResourceManager *resourceManager);
void showWithPlay();
void hideWithStop();
~WaitAnimationWidget();
public slots:
void slotActivateLoadingAnimation(bool flag);
private:
Ui::WaitAnimationWidget *ui;
QMovie *loadingMovie;

21
bootstrap.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include "bootstrap.h"
Bootstrap::Bootstrap(QObject *parent) : QObject(parent)
{
widgetManager = new WidgetManager;
coreManager = new CoreManager;
workerThread = new QThread;
animationThread = new QThread;
}
void Bootstrap::initialize()
{
qRegisterMetaType<PacketType>("PacketType");
widgetManager->initialize();
coreManager->initialize(widgetManager, workerThread);
widgetManager->start();
}

26
bootstrap.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef BOOTSTRAP_H
#define BOOTSTRAP_H
#include "coremanager.h"
#include "widgetmanager.h"
#include <QObject>
class Bootstrap : public QObject
{
Q_OBJECT
public:
explicit Bootstrap(QObject *parent = nullptr);
void initialize();
~Bootstrap(){}
signals:
private:
CoreManager *coreManager;
WidgetManager *widgetManager;
QThread *workerThread;
QThread *animationThread;
};
#endif // BOOTSTRAP_H

387
coremanager.cpp Normal file
View File

@@ -0,0 +1,387 @@
#include "coremanager.h"
CoreManager::CoreManager(QObject *parent) :
QObject(parent),
isRecovery(false)
{
client = new TCPClient;
dataParser = new DataParser;
dataParserOutput = new DataParserOutput;
updateController = new UpdateController;
recognizeSystem = new RecognizeSystem;
screenChecker = new ScreenChecker;
externalExecuter = new ExternalExecuter;
sendSystem = new SendSystem;
hashComparer = new HashComparer;
versionContainer = new VersionContainer;
resourceManager = new ResourceManager;
postProcessorSystem = new PostProcessorSystem;
}
void CoreManager::initialize(WidgetManager *widgetManager,QThread *workerThread)
{
this->workerThread = workerThread;
this->widgetManager = widgetManager;
client->moveToThread(workerThread);
dataParser->moveToThread(workerThread);
dataParserOutput->moveToThread(workerThread);
sendSystem->moveToThread(workerThread);
updateController->moveToThread(workerThread);
recognizeSystem->moveToThread(workerThread);
postProcessorSystem->moveToThread(workerThread);
hashComparer->moveToThread(workerThread);
versionContainer->moveToThread(workerThread); //проверить работоспособность
resourceManager->moveToThread(workerThread); //проверить работоспособность
workerThread->start();
//workerThread->setPriority(QThread::HighestPriority);
binding();
initializeSystems();
initializeWidgets();
loadStaticData();
}
void CoreManager::loadStaticData()
{
ServerSettings *currentSettings = dataParser->getClientSettings();
setLanguage(currentSettings->Language);
emit sigSetLoadSettings(currentSettings);
}
void CoreManager::binding()
{
connect(recognizeSystem,&RecognizeSystem::sigSetInineDebug,widgetManager,&WidgetManager::slotInlineDebug,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigAnimationActivated,widgetManager,&WidgetManager::slotActivateLoadAnimation,Qt::AutoConnection);
connect(this,&CoreManager::sigInitializeClient,client,&TCPClient::initialize,Qt::AutoConnection);
connect(this,&CoreManager::sigSetConnect,client,&TCPClient::setConnect,Qt::AutoConnection);
connect(this,&CoreManager::sigSendCommand,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
connect(this,&CoreManager::sigSendCheckUpdate,sendSystem,&SendSystem::sendCheckHash,Qt::AutoConnection);
connect(this,&CoreManager::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
connect(this,&CoreManager::sigSendAutorization,sendSystem,&SendSystem::sendClientAutorization);
connect(this,&CoreManager::sigSendCheckUpdate,updateController,&UpdateController::checkCanUpdate,Qt::AutoConnection);
connect(this,&CoreManager::sigGetConnected,client,&TCPClient::getIsConnected);
connect(this,&CoreManager::sigCalculateHash,updateController,&UpdateController::calculateCommonHash);
connect(this,&CoreManager::sigSetLoadSettings,widgetManager,&WidgetManager::slotSetLoadSettings,Qt::AutoConnection);
connect(postProcessorSystem,&PostProcessorSystem::sigCallUpdateList,this,&CoreManager::callUpdateList,Qt::AutoConnection);
connect(postProcessorSystem,&PostProcessorSystem::sigSocketDisabled,this,&CoreManager::lostConnection,Qt::AutoConnection);
connect(postProcessorSystem,&PostProcessorSystem::sigServerBlocked,this,&CoreManager::serverBlocked,Qt::AutoConnection);
connect(postProcessorSystem,&PostProcessorSystem::sigStartCompare,hashComparer,&HashComparer::CompareDeltas,Qt::AutoConnection); // ОПАСНОСТЬ
connect(postProcessorSystem,&PostProcessorSystem::sigSaveLoginData,this,&CoreManager::checkLoginResult,Qt::AutoConnection);
connect(postProcessorSystem,&PostProcessorSystem::sigShowUpdateList,this,&CoreManager::checkUpdateInfo,Qt::AutoConnection);
connect(versionContainer,&VersionContainer::sigSetServerVersion,this,&CoreManager::setServerVersion);
connect(recognizeSystem,&RecognizeSystem::sigUpdateBytesAvailable,this,&CoreManager::calcUpdateProgress,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigLoadComplete,this,&CoreManager::loadComplete);
connect(recognizeSystem,&RecognizeSystem::sigNeedUpdate,this,&CoreManager::checkNeedUpdate);
connect(recognizeSystem,&RecognizeSystem::sigCheckUpdate,this,&CoreManager::checkUpdate,Qt::AutoConnection);
connect(hashComparer,&HashComparer::sigCallCheck,this,&CoreManager::checkUpdate);
connect(hashComparer,&HashComparer::sigHaveDelta,this,&CoreManager::checkUpdateInfo);
connect(updateController,&UpdateController::sigUpdateComplete,widgetManager,&WidgetManager::setCompeteState);//ОПАСНОСТЬ
connect(client,&TCPClient::sigConnectionState,widgetManager,&WidgetManager::setConnectionState,Qt::AutoConnection);//ОПАСНОСТЬ
connect(client,&TCPClient::sigServerDisconnect,widgetManager,&WidgetManager::setServerDisconnectState,Qt::AutoConnection);//ОПАСНОСТЬ
connect(sendSystem,&SendSystem::sigSend,this,&CoreManager::calcUpdateProgress);
connect(sendSystem,&SendSystem::sigGetXmlAnswer,dataParserOutput,&DataParserOutput::xmlAnswer_notify,Qt::DirectConnection);//ОПАСНОСТЬ
connect(dataParser,&DataParser::sigNotify,widgetManager->getNotifyController(),&NotifyController::showWarning,Qt::AutoConnection);//ОПАСНОСТЬ
connect(dataParser,&DataParser::sigUpdateFilesOnServer,updateController,&UpdateController::updateFilesOnServer,Qt::AutoConnection);//ОПАСНОСТЬ
}
void CoreManager::initializeSystems()
{
updateController->initialize(versionContainer,dataParserOutput,sendSystem);
screenChecker->initialize(dataParserOutput,widgetManager->getMainWindow()->getDisplayLayout());
hashComparer->initialize(versionContainer,widgetManager->getUpdateWidget());
postProcessorSystem->initialize(dataParserOutput,hashComparer,versionContainer,updateController);
dataParser->initialize(postProcessorSystem);
recognizeSystem->initialize(dataParser,versionContainer,postProcessorSystem);
resourceManager->painting();
emit sigCalculateHash();
emit sigInitializeClient(recognizeSystem,sendSystem);
screenChecker->check();
emit sigSetConnect(dataParser->getClientSettings());
}
void CoreManager::initializeWidgets()
{
widgetManager->getMainWindow()->initialize(resourceManager);
widgetManager->getWaitAnimationWidget()->initialize(resourceManager);
widgetManager->getUpdateWidget()->setVersionContainer(versionContainer);
connect(widgetManager->getUpdateWidget(),&UpdateNotifyWidget::sigLoadToServerBehaviour,this,&CoreManager::loadToServer,Qt::AutoConnection);
connect(widgetManager->getUpdateWidget(),&UpdateNotifyWidget::sigUndoCurrentChanges,this,&CoreManager::undoCurrentChanges,Qt::AutoConnection);
connect(widgetManager->getUpdateWidget(),&UpdateNotifyWidget::sigStartUnityClient,this,&CoreManager::startUnityClient,Qt::AutoConnection);
connect(widgetManager->getEntryWidget(),&EntryWidget::sigTryLogin,this,&CoreManager::tryLogin,Qt::AutoConnection);
connect(widgetManager->getEntryWidget(),&EntryWidget::sigSaveServerSettings,this,&CoreManager::saveServerSettingsWithConnect,Qt::AutoConnection);
connect(widgetManager->getInstructorButtonGroupWiget(),&InstructorButtonGroupWidget::sigLoadToServer,this,&CoreManager::loadToServer, Qt::AutoConnection);
connect(widgetManager->getInstructorButtonGroupWiget(),&InstructorButtonGroupWidget::sigUndoCurrentChanges,this,&CoreManager::undoCurrentChanges, Qt::AutoConnection);
connect(widgetManager->getInstructorButtonGroupWiget(),&InstructorButtonGroupWidget::sigStartUnityClient,this,&CoreManager::startUnityClient, Qt::AutoConnection);
connect(widgetManager->getCommonButtonGroupWidget(),&CommonButtonGroupWidget::sigSendPacket,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
connect(widgetManager->getCommonButtonGroupWidget(),&CommonButtonGroupWidget::sigSendXMLAnswer,sendSystem,&SendSystem::xmlAnswer,Qt::AutoConnection);
connect(widgetManager->getCommonButtonGroupWidget(),&CommonButtonGroupWidget::sigStartUnityClient,this,&CoreManager::startUnityClient,Qt::AutoConnection);
connect(widgetManager->getMainWindow(),&MainWindow::sigChangeLanguage,this,&CoreManager::setLanguage,Qt::AutoConnection);
connect(widgetManager->getMainWindow(),&MainWindow::sigShowUpdateInfo,this,&CoreManager::checkUpdateInfo,Qt::AutoConnection);
connect(widgetManager->getMainWindow(),&MainWindow::sigExit,this,&CoreManager::exit,Qt::AutoConnection);
connect(widgetManager->getMainWindow(),&MainWindow::sigTryLogin,this,&CoreManager::tryLogin,Qt::AutoConnection);
connect(widgetManager->getMainWindow(),&MainWindow::sigStartOffline,this,&CoreManager::startOffline,Qt::AutoConnection);
}
RecognizeSystem *CoreManager::getRecognizeSystem() const
{
return recognizeSystem;
}
void CoreManager::callUpdateList()
{
emit sigSendXMLAnswer(cmd_GetServerHash);
}
void CoreManager::lostConnection()
{
widgetManager->setLostConnectionState();
}
void CoreManager::serverBlocked()
{
widgetManager->getMainWindow()->serverBlocked();
}
void CoreManager::setServerVersion(StreamingVersionData *version)
{
widgetManager->getMainWindow()->setServerVersion(version);
}
void CoreManager::setLocalVersion()
{
ServerSettings *currentSettings = dataParser->getClientSettings();
StreamingVersionData *version = new StreamingVersionData;
version->setName(currentSettings->LocalVersionName);
version->setIsChangeable(currentSettings->versionData.getIsChangeable());
versionContainer->setLocalVersionData(version);
}
void CoreManager::checkLoginResult(ServerAuthorization *auth)
{
if (auth->Result)
{
checkAccessType(auth->AccessType);
dataParserOutput->createAuthData(auth);
setLocalVersion();
widgetManager->setLoginSuccess();
widgetManager->getMainWindow()->setClientVersionName(versionContainer->getLocalVersion());
}
else
{
widgetManager->setLoginFailed();
}
}
void CoreManager::tryLogin()
{
if (!client->getIsConnected())
{
widgetManager->getMainWindow()->showConnectionEmpty();
return;
}
widgetManager->getEntryWidget()->loginIsActive(false);
ClientAutorization *auth = widgetManager->getEntryWidget()->getAuthData();
dataParserOutput->createAuthMessage(auth);
emit sigSendAutorization();
}
void CoreManager::checkUpdate()
{
emit sigSendCheckUpdate();
widgetManager->getMainWindow()->setInlineDebug(tr("Проверка обновлений..."));
}
void CoreManager::checkAccessType(const QString& accessType)
{
if (accessType == traineeTypeName)
{
checkUpdate();
}
else
{
emit sigSendXMLAnswer(cmd_CheckVersionList);
}
}
void CoreManager::checkUpdateInfo()
{
fileCountForUpdate = hashComparer->getFileUpdateCount();
widgetManager->showUpdateInfo();
}
void CoreManager::checkNeedUpdate(bool isNeedUpdate,quint64 size, quint64 fileCount,quint64 deleteCount)
{
filesLoaded = 0;
fileCountForUpdate = fileCount;
QString availableSizeText;
if (isNeedUpdate && isRecovery)
{
widgetManager->setRecoveryState();
}
else if(isNeedUpdate)
{
widgetManager->setNeedUpdateState(size,fileCount,deleteCount);
setLocalVersion();
}
else
{
widgetManager->setLastVersionState();
checkAutoStart();
dataParserOutput->changeVersion(versionContainer->getServerVersionData());
setLocalVersion();
}
}
void CoreManager::calcUpdateProgress()
{
filesLoaded++;
float value = 100 / ((float)fileCountForUpdate / filesLoaded);
widgetManager->getCommonButtonGroupWidget()->updateProgressBar(value);
}
void CoreManager::checkAutoStart()
{
if (externalExecuter->getIsAutoStart())
{
startUnityClient();
}
}
void CoreManager::startUnityClient()
{
externalExecuter->callApp();
emit sigSendXMLAnswer(cmd_Disable);
}
VersionContainer *CoreManager::getVersionContainer() const
{
return versionContainer;
}
void CoreManager::loadComplete()
{
widgetManager->setLoadCompleteState();
externalExecuter->findApp();
externalExecuter->setIsAutoStart(widgetManager->getMainWindow()->getIsAutoStart());
dataParserOutput->changeVersion(versionContainer->getServerVersionData());
setLocalVersion();
checkAutoStart();
}
void CoreManager::loadToServer()
{
widgetManager->setSendFileToServerState();
emit sigSendCheckUpdate();
}
void CoreManager::undoCurrentChanges()
{
isRecovery = true;
emit sigSendCheckUpdate();
widgetManager->setUndoCurrentChangesState();
emit sigSendCommand(PacketType::TYPE_UPDATE);
//тут был таймер
isRecovery = false;
widgetManager->activateLoadingAnimation(false);
}
void CoreManager::startOffline()
{
QString username = "offlineUser";
QString password = "000000";
dataParserOutput->createAuthDataOffline(username,password);
startUnityClient();
}
void CoreManager::saveServerSettingsWithConnect()
{
widgetManager->activateLoadingAnimation(true);
EntryWidget *entryWidget = widgetManager->getEntryWidget();
entryWidget->isActive(false);
ServerSettings *settings = entryWidget->getServerSettings();
settings->LocalVersionName = dataParser->getClientSettings()->LocalVersionName;
dataParserOutput->createServerSettings(settings);
if(client->getIsConnected())
{
entryWidget->loginIsActive(true);
widgetManager->getMainWindow()->showOfflineButton(true);
widgetManager->activateLoadingAnimation(false);
}
else
{
emit sigSetConnect(settings);
}
}
void CoreManager::checkAppAvailable()
{
bool isAvailable = externalExecuter->findApp();
widgetManager->activateStartButtons(isAvailable);
}
void CoreManager::setLanguage(const QString& language)
{
if (language == "RUS")
{
translator.load("QtLanguage_ru_RU",".");
}
else if(language == "ENG")
{
translator.load("QtLanguage_eng_EN",".");
}
qApp->installTranslator(&translator);
dataParserOutput->saveClientSettings(language,widgetManager->getMainWindow()->getIsAutoStart());
}
void CoreManager::exit()
{
emit sigSendXMLAnswer(cmd_Disable);
client->disconnect();
workerThread->quit();
workerThread->wait();
delete workerThread;
}
ResourceManager *CoreManager::getResourceManager() const
{
return resourceManager;
}
SendSystem *CoreManager::getSendSystem() const
{
return sendSystem;
}

103
coremanager.h Normal file
View File

@@ -0,0 +1,103 @@
#ifndef COREMANAGER_H
#define COREMANAGER_H
#include <QObject>
#include <QTranslator>
#include <QThread>
#include <QTranslator>
#include <Core/dataparser.h>
#include <Core/tcpclient.h>
#include <Core/screenchecker.h>
#include <Core/UpdateController.h>
#include <Core/sendsystem.h>
#include <Core/hashcomparer.h>
#include <Core/versioncontainer.h>
#include <widgetmanager.h>
#include <UI/resourcemanager.h>
class CoreManager : public QObject
{
Q_OBJECT
public:
explicit CoreManager(QObject *parent = nullptr);
~CoreManager(){}
void initialize(WidgetManager *widgetManager,QThread *workerThread);
void checkUpdateInfo();
void checkAutoStart();
void setLanguage(const QString &language);
VersionContainer *getVersionContainer() const;
SendSystem *getSendSystem() const;
ResourceManager *getResourceManager() const;
RecognizeSystem *getRecognizeSystem() const;
void loadToServer();
void undoCurrentChanges();
void startUnityClient();
void tryLogin();
void startOffline();
void saveServerSettingsWithConnect();
void checkAppAvailable();
void exit();
void initializeWidgets();
signals:
void sigInitializeClient(RecognizeSystem *recognize,SendSystem *sendSystem);
void sigSendCommand(PacketType packetType);
void sigSendXMLAnswer(QString answer);
void sigSetConnect(ServerSettings* serverSettings);
void sigCalculateHash();
void sigSendAutorization();
void sigSendCheckUpdate();
bool sigGetConnected();
void sigSetLoadSettings(ServerSettings *serverSettings);
private:
QTranslator translator;
TCPClient *client;
DataParser *dataParser;
DataParserOutput *dataParserOutput;
UpdateController *updateController;
RecognizeSystem *recognizeSystem;
ScreenChecker *screenChecker;
ExternalExecuter *externalExecuter;
SendSystem *sendSystem;
HashComparer *hashComparer;
VersionContainer *versionContainer;
ResourceManager *resourceManager;
PostProcessorSystem *postProcessorSystem;
WidgetManager *widgetManager;
QThread *workerThread;
quint16 fileCountForUpdate;
quint16 filesLoaded;
bool isRecovery;
bool autostart;
void loadStaticData();
void binding();
void initializeSystems();
void callUpdateList();
void lostConnection();
void serverBlocked();
void checkLoginResult(ServerAuthorization *auth);
void checkAccessType(const QString &accessType);
void setServerVersion(StreamingVersionData *version);
void calcUpdateProgress();
void loadComplete();
void setLocalVersion();
void checkNeedUpdate(bool flag, quint64 size, quint64 fileCount, quint64 deleteCount);
void checkUpdate();
};
#endif // COREMANAGER_H

View File

@@ -1,3 +1,4 @@
#include "bootstrap.h"
#include "mainwindow.h"
#include <QApplication>
@@ -12,9 +13,7 @@ int main(int argc, char *argv[])
file.open(QFile::ReadOnly);
a.setStyleSheet(file.readAll());
a.setWindowIcon(QIcon(":/resource/Icons/planeCustom.png"));
MainWindow w;
w.initialize();
w.show();
Bootstrap bootstrap;
bootstrap.initialize();
return a.exec();
}

View File

@@ -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();
}

View File

@@ -3,23 +3,13 @@
#include <QMainWindow>
#include <QDebug>
#include <QThread>
#include <QTranslator>
#include <Core/dataparser.h>
#include <Core/tcpclient.h>
#include <Core/screenchecker.h>
#include <Core/UpdateController.h>
#include <Core/sendsystem.h>
#include <Core/hashcomparer.h>
#include <Core/versioncontainer.h>
#include <Core/notifycontroller.h>
#include <Data/Datas.h>
#include <QHBoxLayout>
#include <Widgets/commonbuttongroupwidget.h>
#include <Widgets/entrywidget.h>
#include <Widgets/instructorbuttongroupwidget.h>
#include <Widgets/updatenotifywidget.h>
#include <Widgets/versionselectwidget.h>
#include <Widgets/waitanimationwidget.h>
#include <Widgets/entrywidget.h>
#include <Data/Datas.h>
#include <UI/resourcemanager.h>
#include "mywinheader.h"
@@ -34,113 +24,67 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget *parent = nullptr);
void callUpdateList();
void checkUpdate();
~MainWindow();
~MainWindow(){};
void initialize(ResourceManager *resourceManager);
void addWidgetToChangeGroup(CommonButtonGroupWidget *commonWidgetGroup);
void addWidgetToInteractiveGroup(EntryWidget *entryWidget);
void setLoadSettings(ServerSettings *serverSettings);
void setLoginSuccessState();
void setLoginFailedState();
void setClientVersionName(const QString &versionName);
void initialize();
void bindConnection();
void login();
void saveServerSettingsWithConnect();
void loadToServer();
void undoCurrentChanges();
void startUnityClient();
void setCurrentVersionName(StreamingVersionData *version);
void disableUnsaveButton(bool flag);
void activateLoadingAnimation(bool flag);
void showMainFrame(bool flag);
void showWarning(QString text);
void loadCompleteState();
void setInlineDebug(QString value);
signals:
void sigInitializeClient(RecognizeSystem *recognize,SendSystem *sendSystem);
void sigRecognize(UpdateController* updateController,
DataParser* dataParser,
MainWindow* mainWindow,
HashComparer* hashComparer,
TCPClient *tcpClient);
void sigSendCommand(PacketType packetType);
void sigSendXMLAnswer(QString answer);
void sigSetConnect(ServerSettings* serverSettings,QThread *thread);
void sigCalculateHash();
void sigSendAutorization();
void sigSendCheck();
bool sigGetConnected();
void sigSendCheckUpdate();
bool getIsAutoStart();
void setNeedUpdateState(const QString &notifyText);
void setLastVersionState();
void showConnectionEmpty();
void showOfflineButton(bool flag);
void setStartOfflineButton(bool isAvailable);
void setStartState();
void serverBlocked();
QHBoxLayout *getDisplayLayout() const;
public slots:
void showUpdateInfo();
void showCompleteDialogBox();
void slotShowUpdateInfo();
void slotConnectionState(bool flag);
void slotServerDisconnect();
void updateProgress();
void loadComplete();
void lostConnection();
void serverBlocked();
void checkLoginResult(ServerAuthorization * serverAuth);
void setNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
void showServerListWidget(QList<StreamingVersionData*> *serverData);
void slotCommonWidgetState();
void setServerVersion(StreamingVersionData *version);
signals:
void sigShowSettings(bool isActive);
void sigChangeLanguage(const QString& arg1);
void sigShowUpdateInfo();
void sigExit();
void sigTryLogin();
void sigStartOffline();
private slots:
void on_settingsButton_clicked();
void on_languageComboBox_activated(const QString &arg1);
void slotDisableNotify();
void on_exitButton_clicked();
void on_offlineStartButton_clicked();
void on_unsafeChangingButton_clicked();
void slotDisableNotify();
private:
Ui::MainWindow *ui;
MyWinHeader *header;
UpdateNotifyWidget *updateWidget;
CommonButtonGroupWidget *commonButtonGroupWidget;
EntryWidget *entryWidget;
VersionSelectWidget *versionSelectWidget;
WaitAnimationWidget *waitAnimationWidget;
InstructorButtonGroupWidget *instructorButtonGroup;
QTranslator translator;
TCPClient *client;
DataParser *dataParser;
DataParserOutput *dataParserOutput;
UpdateController *updateController;
RecognizeSystem *recognizeSystem;
ScreenChecker *screenChecker;
ExternalExecuter *externalExecuter;
SendSystem *sendSystem;
HashComparer *hashComparer;
VersionContainer *versionContainer;
ResourceManager *resourceManager;
NotifyController *notifyController;
PostProcessorSystem *postProcessorSystem;
QThread *workerThread;
QThread *animationThread;
QTimer *timer;
QList<FileData> *updateList;
QPixmap _background;
QPixmap background;
QRect bottomRightPosition;
QRect offlinePosition;
int fileCountForUpdate;
int filesLoaded;
bool isRecovery;
void checkAppAvailable();
void checkLanguage(QString language);
void autoStart();
void loadStaticData();
void bindClient();
void createObjects();
void showConnectionEmpty();
void setTitle();
void bindConnection();
void setUpUi();
void commonWidgetState();
void setServerVersion(StreamingVersionData *version);
void paintEvent(QPaintEvent *event);
protected:
virtual void keyPressEvent(QKeyEvent *event);

226
widgetmanager.cpp Normal file
View File

@@ -0,0 +1,226 @@
#include "widgetmanager.h"
WidgetManager::WidgetManager(QObject *parent) : QObject(parent)
{
mainWindow = new MainWindow;
updateWidget = new UpdateNotifyWidget;
commonButtonGroupWidget = new CommonButtonGroupWidget;
entryWidget = new EntryWidget;
waitAnimationWidget = new WaitAnimationWidget;
instructorButtonGroupWiget = new InstructorButtonGroupWidget;
notifyController = new NotifyController;
}
void WidgetManager::initialize()
{
updateWidget->setParent(mainWindow);
waitAnimationWidget->setParent(mainWindow);
notifyController->setParent(mainWindow);
mainWindow->addWidgetToChangeGroup(commonButtonGroupWidget);
mainWindow->addWidgetToInteractiveGroup(entryWidget);
updateWidget->initialize(mainWindow->pos());
entryWidget->initialize();
commonButtonGroupWidget->initialize();
//activateLoadingAnimation(true);
binding();
}
void WidgetManager::binding()
{
connect(updateWidget,&UpdateNotifyWidget::sigShowMainFrame,this,&WidgetManager::showMainFrame,Qt::AutoConnection);
connect(commonButtonGroupWidget,&CommonButtonGroupWidget::sigUpdateCommonWidget,mainWindow,&MainWindow::commonWidgetState);
connect(mainWindow,&MainWindow::sigShowSettings,this,&WidgetManager::showSettings,Qt::AutoConnection);
}
void WidgetManager::slotSetLoadSettings(ServerSettings *settings)
{
mainWindow->setLoadSettings(settings);
entryWidget->fillSettings(settings);
}
void WidgetManager::setLostConnectionState()
{
commonButtonGroupWidget->updateProgressBar(0);
mainWindow->slotConnectionState(false);
waitAnimationWidget->hideWithStop();
entryWidget->connectionEmptyState();
updateWidget->hide();
}
void WidgetManager::setLoginSuccess()
{
entryWidget->loginIsActive(false);
mainWindow->setLoginSuccessState();
activateLoadingAnimation(false);
}
void WidgetManager::setLoginFailed()
{
entryWidget->loginIsActive(true);
mainWindow->setLoginFailedState();
activateLoadingAnimation(false);
}
void WidgetManager::showUpdateInfo()
{
waitAnimationWidget->hideWithStop();
updateWidget->showWithFill();
mainWindow->showMainFrame(true);
mainWindow->showUpdateInfo();
entryWidget->hide();
commonButtonGroupWidget->hide();
}
void WidgetManager::setLoadCompleteState()
{
commonButtonGroupWidget->loadCompleteState();
mainWindow->loadCompleteState();
}
void WidgetManager::setCompeteState()
{
mainWindow->setInlineDebug(tr("Загрузка завершена"));
waitAnimationWidget->hideWithStop();
}
void WidgetManager::activateLoadingAnimation(bool flag)
{
if (flag) waitAnimationWidget->showWithPlay();
else waitAnimationWidget->hideWithStop();
}
void WidgetManager::setNeedUpdateState(quint64 size, quint64 fileCount,quint64 deleteCount)
{
QString result;
if(fileCount > 0)
{
result = tr("Доступно обновление: ") + Tools::convertFileSize(size);
//result += tr("Количество файлов: ") + QString::number(fileCount);
}
else
{
result = tr("Файлов к удалению: ") + QString::number(deleteCount);
}
mainWindow->setNeedUpdateState(result);
commonButtonGroupWidget->needUpdateState(true);
waitAnimationWidget->hideWithStop();
}
void WidgetManager::setRecoveryState()
{
mainWindow->setInlineDebug(tr("Восстановление версии..."));
}
void WidgetManager::setLastVersionState()
{
mainWindow->setLastVersionState();
commonButtonGroupWidget->lastVerInstalledState();
waitAnimationWidget->hideWithStop();
}
void WidgetManager::setConnectionState(bool isConnected)
{
mainWindow->slotConnectionState(isConnected);
if (isConnected)
{
entryWidget->loginIsActive(true);
}
waitAnimationWidget->hideWithStop();
}
void WidgetManager::setSendFileToServerState()
{
mainWindow->loadToServer();
commonButtonGroupWidget->showProgressBar(true);
updateWidget->hide();
}
void WidgetManager::start()
{
waitAnimationWidget->showWithPlay();
mainWindow->setStartState();
waitAnimationWidget->hideWithStop();
}
void WidgetManager::setServerDisconnectState()
{
commonButtonGroupWidget->disconnectState();
mainWindow->slotServerDisconnect();
}
void WidgetManager::setUndoCurrentChangesState()
{
mainWindow->undoCurrentChanges();
commonButtonGroupWidget->showProgressBar(false);
updateWidget->hide();
waitAnimationWidget->showWithPlay();
}
void WidgetManager::showMainFrame(bool flag)
{
mainWindow->showMainFrame(flag);
}
void WidgetManager::activateStartButtons(bool isAvailable)
{
commonButtonGroupWidget->startButtonActive(isAvailable);
mainWindow->setStartOfflineButton(isAvailable);
}
void WidgetManager::showSettings(bool isActive)
{
entryWidget->settingsState();
entryWidget->isActive(isActive);
}
void WidgetManager::slotInlineDebug(const QString& text)
{
mainWindow->setInlineDebug(text);
}
void WidgetManager::slotActivateLoadAnimation(bool flag)
{
waitAnimationWidget->slotActivateLoadingAnimation(flag);
}
NotifyController *WidgetManager::getNotifyController() const
{
return notifyController;
}
MainWindow *WidgetManager::getMainWindow() const
{
return mainWindow;
}
UpdateNotifyWidget *WidgetManager::getUpdateWidget() const
{
return updateWidget;
}
CommonButtonGroupWidget *WidgetManager::getCommonButtonGroupWidget() const
{
return commonButtonGroupWidget;
}
EntryWidget *WidgetManager::getEntryWidget() const
{
return entryWidget;
}
WaitAnimationWidget *WidgetManager::getWaitAnimationWidget() const
{
return waitAnimationWidget;
}
InstructorButtonGroupWidget *WidgetManager::getInstructorButtonGroupWiget() const
{
return instructorButtonGroupWiget;
}

69
widgetmanager.h Normal file
View File

@@ -0,0 +1,69 @@
#ifndef WIDGETMANAGER_H
#define WIDGETMANAGER_H
#include "mainwindow.h"
#include <Widgets/commonbuttongroupwidget.h>
#include <Widgets/entrywidget.h>
#include <Widgets/instructorbuttongroupwidget.h>
#include <Widgets/updatenotifywidget.h>
#include <Widgets/waitanimationwidget.h>
#include <Core/notifycontroller.h>
#include <QObject>
#include <QWidget>
class WidgetManager : public QObject
{
Q_OBJECT
public:
explicit WidgetManager(QObject *parent = nullptr);
void initialize();
MainWindow *getMainWindow() const;
UpdateNotifyWidget *getUpdateWidget() const;
CommonButtonGroupWidget *getCommonButtonGroupWidget() const;
EntryWidget *getEntryWidget() const;
WaitAnimationWidget *getWaitAnimationWidget() const;
InstructorButtonGroupWidget *getInstructorButtonGroupWiget() const;
NotifyController *getNotifyController() const;
void setLostConnectionState();
void setLoginSuccess();
void setLoginFailed();
void showUpdateInfo();
void setLoadCompleteState();
void setNeedUpdateState(quint64 size, quint64 fileCount,quint64 deleteCount);
void setRecoveryState();
void setLastVersionState();
void activateLoadingAnimation(bool flag);
void setCompeteState();
void setConnectionState(bool isConnected);
void setServerDisconnectState();
void setSendFileToServerState();
void start();
void setUndoCurrentChangesState();
void showMainFrame(bool flag);
void activateStartButtons(bool isAvailable);
void slotInlineDebug(const QString &text);
public slots:
void showSettings(bool isActive);
void slotSetLoadSettings(ServerSettings *settings);
void slotActivateLoadAnimation(bool flag);
signals:
private:
MainWindow *mainWindow;
UpdateNotifyWidget *updateWidget;
CommonButtonGroupWidget *commonButtonGroupWidget;
EntryWidget *entryWidget;
WaitAnimationWidget *waitAnimationWidget;
InstructorButtonGroupWidget *instructorButtonGroupWiget;
NotifyController *notifyController;
void binding();
};
#endif // WIDGETMANAGER_H