From 05e09792d7893489a9f5c43f8fd8bb142a9ef3c5 Mon Sep 17 00:00:00 2001 From: semenov Date: Wed, 13 Aug 2025 10:22:14 +0300 Subject: [PATCH] ref: link argument --- Core/UpdateController.cpp | 7 +++--- Core/UpdateController.h | 2 +- Core/dataparser.cpp | 22 ++++++++--------- Core/dataparser.h | 11 +++------ Core/dataparseroutput.cpp | 17 ++++++------- Core/dataparseroutput.h | 14 +++++------ Core/externalexecuter.cpp | 4 ---- Core/externalexecuter.h | 4 ++-- Core/hashcomparer.cpp | 13 ++++------ Core/hashcomparer.h | 5 +--- Core/notifycontroller.cpp | 2 +- Core/notifycontroller.h | 5 +--- Core/postprocessorsystem.cpp | 9 +++++-- Core/postprocessorsystem.h | 5 ++-- Core/recognizesystem.cpp | 10 ++++---- Core/recognizesystem.h | 2 +- Core/screenchecker.cpp | 12 +++++----- Core/screenchecker.h | 3 +-- Core/sendsystem.cpp | 37 +++++++++++------------------ Core/sendsystem.h | 15 ++++++------ Core/tcpclient.cpp | 17 ++++++------- Core/tcpclient.h | 5 ++-- StaticData/settings.xml | 4 ++-- Widgets/commonbuttongroupwidget.cpp | 3 +-- Widgets/commonbuttongroupwidget.h | 2 +- mainwindow.cpp | 16 +++++++------ mainwindow.h | 2 +- 27 files changed, 111 insertions(+), 137 deletions(-) diff --git a/Core/UpdateController.cpp b/Core/UpdateController.cpp index 3acd6ca..1d5fcf4 100644 --- a/Core/UpdateController.cpp +++ b/Core/UpdateController.cpp @@ -4,7 +4,8 @@ #include UpdateController::UpdateController(DataParserOutput *dataParserOut, SendSystem *sendSystem, QObject *parent) : - QObject(parent) + QObject(parent), + versionContainer(nullptr) { this->sendSystem = sendSystem; this->dataParserOut = dataParserOut; @@ -34,7 +35,7 @@ void UpdateController::calculateStreamingHash() dataParserOut->createFileDataList(streamingDataList,streamingHashFilename); } -QList UpdateController::calculateHash(QString path,QString ignoreName) +QList UpdateController::calculateHash(const QString& path,const QString& ignoreName) { qDebug() << "Try calculate"; @@ -56,7 +57,7 @@ QList UpdateController::calculateHash(QString path,QString ignoreName) QFileInfo fileInfo(dirIterator.next()); FileData currentFile; QString fileName = fileInfo.fileName(); - if(fileInfo.isDir() && !fileInfo.fileName().startsWith(".") && fileInfo.fileName() != "RRJLoader") + if(fileInfo.isDir() && !fileName.startsWith(".") && fileName != "RRJLoader") { currentFile.path = Tools::createLocalPath(fileInfo.absoluteFilePath()); currentFile.hash = "FOLDER"; diff --git a/Core/UpdateController.h b/Core/UpdateController.h index 0c8ee73..4a4d28f 100644 --- a/Core/UpdateController.h +++ b/Core/UpdateController.h @@ -47,7 +47,7 @@ private: QList appDataList; QList streamingDataList; - QList calculateHash(QString path,QString ignoreName); + QList calculateHash(const QString& path,const QString& ignoreName); }; diff --git a/Core/dataparser.cpp b/Core/dataparser.cpp index 0196d42..e809901 100644 --- a/Core/dataparser.cpp +++ b/Core/dataparser.cpp @@ -1,7 +1,8 @@ #include "Core/dataparser.h" DataParser::DataParser(QObject *parent) : - QObject(parent) + QObject(parent), + postProcessSystem(nullptr) { if(!QDir(fullStaticDataFolderName).exists()){ QDir().mkdir(fullStaticDataFolderName); @@ -94,7 +95,7 @@ ServerSettings *DataParser::getClientSettings() return settings; } -void DataParser::xmlParser(QByteArray array) +void DataParser::xmlParser(const QByteArray& array) { QXmlStreamReader xmlReader(array); @@ -171,19 +172,23 @@ void DataParser::xmlParser(QByteArray array) QString name = attr.name().toString(); QString value = attr.value().toString(); - if (name == "Result"){ + if (name == "Result") + { serverAuth->Result = value == "true" ? true : false; } - if (name == "InstructorName"){ + if (name == "InstructorName") + { serverAuth->InstructorName = value; } - if (name == "ClientName"){ + if (name == "ClientName") + { serverAuth->ClientName = value; } - if (name == "AccessType"){ + if (name == "AccessType") + { serverAuth->AccessType = value; postProcessSystem->checkAccessType(value); //recognizeSystem->checkAccessType(value); @@ -260,8 +265,3 @@ void DataParser::xmlParser(QByteArray array) xmlReader.readNext(); } } - -DataParser::~DataParser() -{ - -} diff --git a/Core/dataparser.h b/Core/dataparser.h index ac66770..179cfa0 100644 --- a/Core/dataparser.h +++ b/Core/dataparser.h @@ -12,27 +12,22 @@ #include #include "Core/postprocessorsystem.h" -class NotifyController; - class DataParser : public QObject { - - Q_OBJECT + Q_OBJECT public: explicit DataParser(QObject *parent = 0); + ~DataParser() = default; void initialize(PostProcessorSystem *postProcessSystem); - - ~DataParser(); ServerSettings* getClientSettings(); - void xmlParser(QByteArray array); + void xmlParser(const QByteArray& array); signals: void sigNotify(QString notify); void sigUpdateFilesOnServer(QList *fileSendList); private: - ClientAutorization *authPassCache; PostProcessorSystem *postProcessSystem; }; diff --git a/Core/dataparseroutput.cpp b/Core/dataparseroutput.cpp index 5a4fbe6..f351b3d 100644 --- a/Core/dataparseroutput.cpp +++ b/Core/dataparseroutput.cpp @@ -1,10 +1,11 @@ #include "dataparseroutput.h" -DataParserOutput::DataParserOutput() {} +DataParserOutput::DataParserOutput(QObject *parent) : + QObject(parent), + authPassCache(nullptr){} -QByteArray DataParserOutput::xmlAnswer_notify(QString code) +QByteArray DataParserOutput::xmlAnswer_notify(const QString& code) { - QList listTag; SAttribute attribute1 = {"Code", code}; @@ -16,7 +17,7 @@ QByteArray DataParserOutput::xmlAnswer_notify(QString code) return xmlAnswer(listTag); } -QByteArray DataParserOutput::xmlAnswer(QList listTag, QString elemUp1, QString elemUp2) +QByteArray DataParserOutput::xmlAnswer(const QList& listTag, const QString& elemUp1, const QString& elemUp2) { /* Открываем файл для Записи*/ QFile file(tempName); @@ -77,7 +78,7 @@ QByteArray DataParserOutput::xmlAnswer(QList listTag, QString ele } -void DataParserOutput::createFileDataList(QList fileDataList,QString filename) +void DataParserOutput::createFileDataList(const QList& fileDataList,const QString& filename) { QFile file(filename); file.open(QIODevice::WriteOnly); @@ -215,7 +216,7 @@ void DataParserOutput::createAuthData(ServerAuthorization *serverAuth) } -void DataParserOutput::createAuthDataOffline(QString username, QString pass) +void DataParserOutput::createAuthDataOffline(const QString& username,const QString& pass) { QFile file(authTempName); file.open(QIODevice::WriteOnly); @@ -255,7 +256,7 @@ void DataParserOutput::addRunData(QList displays) } -void DataParserOutput::saveClientSettrings(QString language, bool isAutoStart) +void DataParserOutput::saveClientSettrings(const QString& language, bool isAutoStart) { QFile file(settingsName); file.open(QIODevice::ReadOnly | QIODevice::Text); @@ -277,7 +278,7 @@ void DataParserOutput::saveClientSettrings(QString language, bool isAutoStart) file.close(); } -QList* DataParserOutput::xmlFileDataParse(QByteArray array, QString filter = "") +QList* DataParserOutput::xmlFileDataParse(const QByteArray& array,const QString& filter) { QXmlStreamReader xmlReader(array); QList *datas = new QList; diff --git a/Core/dataparseroutput.h b/Core/dataparseroutput.h index 1edad6d..135d562 100644 --- a/Core/dataparseroutput.h +++ b/Core/dataparseroutput.h @@ -14,18 +14,18 @@ class DataParserOutput : public QObject { Q_OBJECT public: - DataParserOutput(); - void createFileDataList(QList fileDataList, QString filename); + explicit DataParserOutput(QObject *parent = 0); + void createFileDataList(const QList& fileDataList,const QString& filename); void createAuthMessage(ClientAutorization *auth); void createServerSettings(ServerSettings *serverSettings); void changeVersion(StreamingVersionData *versionData); void createAuthData(ServerAuthorization *serverAuth); - void createAuthDataOffline(QString username, QString pass); + void createAuthDataOffline(const QString& username,const QString& pass); void addRunData(QList displays); - void saveClientSettrings(QString language, bool isAutoStart); - QList *xmlFileDataParse(QByteArray array, QString filter); - QByteArray xmlAnswer_notify(QString code); - QByteArray xmlAnswer(QList listTag, QString elemUp1 ="", QString elemUp2 =""); + void saveClientSettrings(const QString& language, bool isAutoStart); + QList *xmlFileDataParse(const QByteArray& array,const QString& filter = ""); + QByteArray xmlAnswer_notify(const QString& code); + QByteArray xmlAnswer(const QList& listTag, const QString& elemUp1 = "", const QString& elemUp2 = ""); private: const QString XMLLanguageProperty = "Language=\""; const QString XMLAutoStartProperty = "AutoStart=\""; diff --git a/Core/externalexecuter.cpp b/Core/externalexecuter.cpp index 449c0dc..5f451ab 100644 --- a/Core/externalexecuter.cpp +++ b/Core/externalexecuter.cpp @@ -1,9 +1,5 @@ #include "externalexecuter.h" -ExternalExecuter::ExternalExecuter() {} - -ExternalExecuter::~ExternalExecuter() {} - void ExternalExecuter::callApp() { QProcess *myProcess = new QProcess(this); diff --git a/Core/externalexecuter.h b/Core/externalexecuter.h index c4f5d05..4932d23 100644 --- a/Core/externalexecuter.h +++ b/Core/externalexecuter.h @@ -15,10 +15,10 @@ class ExternalExecuter : public QObject Q_OBJECT public: - ExternalExecuter(); + ExternalExecuter() {}; + ~ExternalExecuter() {}; void callApp(); bool findApp(); - ~ExternalExecuter(); private: QString programPath; diff --git a/Core/hashcomparer.cpp b/Core/hashcomparer.cpp index 29e9d9e..7af5e0e 100644 --- a/Core/hashcomparer.cpp +++ b/Core/hashcomparer.cpp @@ -1,20 +1,20 @@ #include "hashcomparer.h" -HashComparer::HashComparer(QObject *) +HashComparer::HashComparer(QObject *) : + updateWidget(nullptr), + filesForUpdate(nullptr), + versionContainer(nullptr) { } void HashComparer::initialize(VersionContainer *versionContainer) { - this->versionContainer = versionContainer; } void HashComparer::CompareDeltas(QList *serverStreamingHash, QList localStreamingHash) { - // QList *serverStreamingHash = new QList; - // QList *localStreamingHash = new QList; QList *files = new QList; QMutableListIterator iterator(localStreamingHash); @@ -74,8 +74,3 @@ QList *HashComparer::getFilesForUpdate() const return filesForUpdate; } - -HashComparer::~HashComparer() -{ - -} diff --git a/Core/hashcomparer.h b/Core/hashcomparer.h index 453ed5e..e9c7984 100644 --- a/Core/hashcomparer.h +++ b/Core/hashcomparer.h @@ -8,9 +8,6 @@ #include #include -class UpdateNotifyWidget; -class VersionContainer; - class HashComparer :public QObject { Q_OBJECT @@ -18,7 +15,7 @@ public: explicit HashComparer(QObject *parent = nullptr); void initialize(VersionContainer *versionContainer); void CompareDeltas(QList *serverStreamingHash, QList localStreamingHash); - ~HashComparer(); + ~HashComparer() = default; void showDeltas(); void setWidget(UpdateNotifyWidget *updateWidget); diff --git a/Core/notifycontroller.cpp b/Core/notifycontroller.cpp index 7c09e24..f80b011 100644 --- a/Core/notifycontroller.cpp +++ b/Core/notifycontroller.cpp @@ -5,7 +5,7 @@ NotifyController::NotifyController(QObject *parent) : QObject(parent) } -void NotifyController::showWarning(QString text) +void NotifyController::showWarning(const QString& text) { QMessageBox warning; warning.setText(text); diff --git a/Core/notifycontroller.h b/Core/notifycontroller.h index 1b08ef9..96e9c70 100644 --- a/Core/notifycontroller.h +++ b/Core/notifycontroller.h @@ -9,10 +9,7 @@ class NotifyController : public QObject Q_OBJECT public: explicit NotifyController(QObject *parent = nullptr); - - void showWarning(QString text); -signals: - + void showWarning(const QString& text); }; #endif // NOTIFYCONTROLLER_H diff --git a/Core/postprocessorsystem.cpp b/Core/postprocessorsystem.cpp index 5c827b1..9f61214 100644 --- a/Core/postprocessorsystem.cpp +++ b/Core/postprocessorsystem.cpp @@ -1,6 +1,11 @@ #include "postprocessorsystem.h" -PostProcessorSystem::PostProcessorSystem(QObject *parent) : QObject(parent){} +PostProcessorSystem::PostProcessorSystem(QObject *parent) : + QObject(parent), + hashComparer(nullptr), + versionContainer(nullptr), + updateController(nullptr), + dataParserOutput(nullptr){} void PostProcessorSystem::initialize(DataParserOutput *dataParserOutput, HashComparer *hashComparer, @@ -54,7 +59,7 @@ void PostProcessorSystem::compareFiles() updateController->updateFilesOnServer(hashComparer->getFilesForUpdate()); } -void PostProcessorSystem::checkAccessType(QString type) +void PostProcessorSystem::checkAccessType(const QString& type) { if(type == "instructor") { diff --git a/Core/postprocessorsystem.h b/Core/postprocessorsystem.h index 3cbfe02..7afa220 100644 --- a/Core/postprocessorsystem.h +++ b/Core/postprocessorsystem.h @@ -14,13 +14,14 @@ public: void initialize(DataParserOutput *dataParserOutput, HashComparer *hashComparer, VersionContainer* versionContainer, - UpdateController* updateContorller); + UpdateController* updateController); + void socketDisable(); void serverBlocked(); void startCompare(); void showUpdateList(); void compareFiles(); - void checkAccessType(QString type); + void checkAccessType(const QString& type); void saveLoginData(ServerAuthorization *auth); void setServerVersion(StreamingVersionData *serverVersion); void showServerDataList(QList *versionList); diff --git a/Core/recognizesystem.cpp b/Core/recognizesystem.cpp index 9ed4f61..600d878 100644 --- a/Core/recognizesystem.cpp +++ b/Core/recognizesystem.cpp @@ -2,7 +2,10 @@ RecognizeSystem::RecognizeSystem(QObject *parent): - QObject(parent) + QObject(parent), + versionContainer(nullptr), + dataParser(nullptr), + postProcessorSystem(nullptr) { packetType = PacketType::TYPE_NONE; filePath.clear(); @@ -14,11 +17,6 @@ RecognizeSystem::RecognizeSystem(QObject *parent): folderList = new QList; } -RecognizeSystem::~RecognizeSystem() -{ - -} - void RecognizeSystem::initialize(DataParser *dataParser, VersionContainer *versionContainer,PostProcessorSystem *postProcessorSystem) { this->versionContainer = versionContainer; diff --git a/Core/recognizesystem.h b/Core/recognizesystem.h index e2b60f6..883a5a0 100644 --- a/Core/recognizesystem.h +++ b/Core/recognizesystem.h @@ -22,7 +22,7 @@ class RecognizeSystem : public QObject public: explicit RecognizeSystem(QObject *parent = 0); - ~RecognizeSystem(); + ~RecognizeSystem(){}; void initialize(DataParser *dataParser, VersionContainer* versionContainer,PostProcessorSystem *postProcessorSystem); void recognize(QTcpSocket *socket); diff --git a/Core/screenchecker.cpp b/Core/screenchecker.cpp index 7fabc48..51f35ea 100644 --- a/Core/screenchecker.cpp +++ b/Core/screenchecker.cpp @@ -28,8 +28,8 @@ void ScreenChecker::check() QIcon checkedIcon; checkedIcon.addPixmap(checkedPixmap,QIcon::Disabled,QIcon::On); - qint8 sizeVertical = 90; - quint16 sizeHorizontal = 150; + float sizeVertical = 90; + float sizeHorizontal = 150; if(screens.length() > 3) { @@ -43,9 +43,9 @@ void ScreenChecker::check() (a->geometry().x() == b->geometry().x() && a->geometry().y() < b->geometry().y()); //выше }); - for (int i = 0; i < screens.length() ;i++) + //int i = 0; i < screens.length() ;i++ + for (auto display : screens) { - QScreen *display = screens[i]; screenCount++; QString sizeText = QString::number(display->size().width()) + "x" + QString::number(display->size().height()); @@ -131,8 +131,8 @@ QString ScreenChecker::getScreenCount() const ScreenChecker::~ScreenChecker() { - for (int i = 0; i < buttons.size(); i++) + for (auto & button : buttons) { - delete buttons[i]; + delete button; } } diff --git a/Core/screenchecker.h b/Core/screenchecker.h index 14460d7..42b8bd9 100644 --- a/Core/screenchecker.h +++ b/Core/screenchecker.h @@ -22,7 +22,7 @@ class ScreenChecker : public QObject Q_OBJECT public: - explicit ScreenChecker(QWidget *widget,DataParserOutput *dataParserOutput, QHBoxLayout *layout,QObject *parent = nullptr); + explicit ScreenChecker(QWidget *mainWidget,DataParserOutput *dataParserOutput, QHBoxLayout *layout,QObject *parent = nullptr); ~ScreenChecker(); void check(); QString getScreenCount() const; @@ -30,7 +30,6 @@ public: private: QWidget *mainWidget; - QWidget *widget; DataParserOutput *dataParserOutput; QHBoxLayout *layout; qint64 screenCount; diff --git a/Core/sendsystem.cpp b/Core/sendsystem.cpp index 0db720f..7d4a98c 100644 --- a/Core/sendsystem.cpp +++ b/Core/sendsystem.cpp @@ -1,13 +1,16 @@ #include "sendsystem.h" -SendSystem::SendSystem(QObject *) {} +SendSystem::SendSystem(QObject *parent) : + QObject(parent), + socket(nullptr), + readSize(1025*250){} void SendSystem::setSocket(QTcpSocket *socket) { this->socket = socket; } -void SendSystem::xmlAnswer(QString message) +void SendSystem::xmlAnswer(const QString& message) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); @@ -40,7 +43,7 @@ void SendSystem::sendClientAutorization() file.close(); } -void SendSystem::sendFileBlock(QString path) +void SendSystem::sendFileBlock(const QString& path) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); @@ -62,7 +65,7 @@ void SendSystem::sendFileBlock(QString path) if(file.open(QFile::ReadOnly)){ while(!file.atEnd()){ - QByteArray data = file.read(1025*250); + QByteArray data = file.read(readSize); stream << data; socket->waitForBytesWritten(20); countSend++; @@ -74,13 +77,11 @@ void SendSystem::sendFileBlock(QString path) file.close(); emit sigSend(); - //qDebug() << "Transaction after send file: " << socket->isTransactionStarted(); countSend = 0; - //socket->waitForBytesWritten(); socket->waitForReadyRead(20); } -void SendSystem::sendFolderBlock(QString path) +void SendSystem::sendFolderBlock(const QString& path) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); @@ -91,11 +92,10 @@ void SendSystem::sendFolderBlock(QString path) socket->waitForReadyRead(100); } -void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath) +void SendSystem::sendFileBlockWithVersion(const QString& localPath,const QString& serverPath) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); - //QString fullPath = Tools::createLocalPath(localPath); quint64 fileSize = 0; int countSend = 0; @@ -109,11 +109,10 @@ void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath) stream << serverPath << fileSize; socket->waitForReadyRead(20); - //socket->waitForBytesWritten(); if(file.open(QFile::ReadOnly)){ while(!file.atEnd()){ - QByteArray data = file.read(1025*250); + QByteArray data = file.read(readSize); stream << data; socket->waitForBytesWritten(10); countSend++; @@ -133,8 +132,7 @@ void SendSystem::sendFileBlockWithVersion(QString localPath,QString serverPath) void SendSystem::sendQTConnect() { - //QString value = QString::number(PacketType::TYPE_QT); - QByteArray container; + QByteArray container; //TODO найти более компактное решение int numPackage = (int)PacketType::TYPE_QT; container.append(numPackage & 0x000000ff); container.append((numPackage >> 8) & 0x000000ff); @@ -145,7 +143,7 @@ void SendSystem::sendQTConnect() socket->waitForBytesWritten(); } -void SendSystem::sendXMLAnswer(QByteArray array) +void SendSystem::sendXMLAnswer(const QByteArray& array) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); @@ -189,19 +187,18 @@ void SendSystem::sendDeleteVersion(StreamingVersionData *streamingVersion) socket->waitForReadyRead(100); } -void SendSystem::sendCopyVersion(QString streamingVersion) +void SendSystem::sendCopyVersion(const QString& versionName) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); stream << PacketType::COPY_VERSION; - stream << streamingVersion; + stream << versionName; } void SendSystem::sendPacketType(PacketType packetType) { QDataStream stream(socket); - QByteArray data; stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); stream << packetType; @@ -210,7 +207,6 @@ void SendSystem::sendPacketType(PacketType packetType) void SendSystem::sendCheckHash() { QDataStream stream(socket); - QByteArray data; stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); sendFileBlock(staticDataFolderName + hashFilename); @@ -218,8 +214,3 @@ void SendSystem::sendCheckHash() socket->waitForReadyRead(2000); stream << PacketType::TYPE_CHECK_VERSION; } - -SendSystem::~SendSystem() -{ - -} diff --git a/Core/sendsystem.h b/Core/sendsystem.h index 4767355..ec1908e 100644 --- a/Core/sendsystem.h +++ b/Core/sendsystem.h @@ -17,27 +17,28 @@ public: void setSocket(QTcpSocket *socket); void sendClientAutorization(); void sendDisable(); - void sendFileBlock(QString path); - void sendFolderBlock(QString path); - void sendFileBlockWithVersion(QString localPath, QString serverPath); + void sendFileBlock(const QString& path); + void sendFolderBlock(const QString& path); + void sendFileBlockWithVersion(const QString& localPath,const QString& serverPath); void sendQTConnect(); - void sendXMLAnswer(QByteArray array); + void sendXMLAnswer(const QByteArray& array); void sendFinish(); void sendChangeVersion(StreamingVersionData *streamingVersion); void sendDeleteVersion(StreamingVersionData *streamingVersion); - void sendCopyVersion(QString versionName); + void sendCopyVersion(const QString& versionName); void sendCheckHash(); void sendPacketType(PacketType packetType); - ~SendSystem(); + ~SendSystem(){}; signals: void sigSend(); QByteArray sigGetXmlAnswer(QString); public slots: - void xmlAnswer(QString message); + void xmlAnswer(const QString& message); private: QTcpSocket *socket; + int readSize; }; diff --git a/Core/tcpclient.cpp b/Core/tcpclient.cpp index c269257..8b3a7e2 100644 --- a/Core/tcpclient.cpp +++ b/Core/tcpclient.cpp @@ -1,14 +1,17 @@ #include "tcpclient.h" TCPClient::TCPClient(QObject *parent) : - QObject(parent) + QObject(parent), + sendSystem(nullptr), + socket(nullptr), + recognizeSystem(nullptr), + isConnected(false) { } -void TCPClient::initialize(RecognizeSystem *recognize,ExternalExecuter *externalExecuter,SendSystem *sendSystem) +void TCPClient::initialize(RecognizeSystem *recognize,SendSystem *sendSystem) { this->recognizeSystem = recognize; - this->externalExecuter = externalExecuter; this->sendSystem = sendSystem; isConnected = false; @@ -21,7 +24,7 @@ void TCPClient::setConnect(ServerSettings *serverSettings) { socket = new QTcpSocket(); qDebug() << "TCPCLient thread: " << thread(); - if (socket != NULL && socket->state() == QTcpSocket::ConnectedState) + if (socket != nullptr && socket->state() == QTcpSocket::ConnectedState) { emit sigSendDebugLog("already connected"); return; @@ -74,7 +77,6 @@ void TCPClient::slotConnectNotify() isConnected = false; emit sigSendDebugLog("Connect invalid"); emit sigConnectionState(false); - return; } else { @@ -99,8 +101,3 @@ bool TCPClient::getIsConnected() const { return isConnected; } - -TCPClient::~TCPClient() -{ - -} diff --git a/Core/tcpclient.h b/Core/tcpclient.h index 3d433a1..af2897b 100644 --- a/Core/tcpclient.h +++ b/Core/tcpclient.h @@ -26,12 +26,12 @@ class TCPClient : public QObject public: explicit TCPClient(QObject *parent = 0); - void initialize(RecognizeSystem *recognize,ExternalExecuter *externalExecuter,SendSystem *sendSystem); + void initialize(RecognizeSystem *recognize,SendSystem *sendSystem); void setConnect(ServerSettings *serverSettings); void waitRead(int time); QTcpSocket* getSocket(); - ~TCPClient(); + ~TCPClient(){}; bool getIsConnected() const; @@ -51,7 +51,6 @@ private: SendSystem *sendSystem; QTcpSocket *socket; RecognizeSystem *recognizeSystem; - ExternalExecuter * externalExecuter; bool isConnected; void setDisconnect(); diff --git a/StaticData/settings.xml b/StaticData/settings.xml index 35a010a..445760a 100644 --- a/StaticData/settings.xml +++ b/StaticData/settings.xml @@ -1,5 +1,5 @@ - - + + diff --git a/Widgets/commonbuttongroupwidget.cpp b/Widgets/commonbuttongroupwidget.cpp index 59a83db..be632f5 100644 --- a/Widgets/commonbuttongroupwidget.cpp +++ b/Widgets/commonbuttongroupwidget.cpp @@ -8,7 +8,7 @@ CommonButtonGroupWidget::CommonButtonGroupWidget(QWidget *parent) : ui->setupUi(this); } -void CommonButtonGroupWidget::initialize(ExternalExecuter *extExec,SendSystem *sendSystem,TCPClient *client) +void CommonButtonGroupWidget::initialize(ExternalExecuter *extExec,SendSystem *sendSystem) { externalExecuter = extExec; this->sendSystem = sendSystem; @@ -70,7 +70,6 @@ void CommonButtonGroupWidget::needUpdateState(bool flag) { ui->startButton->hide(); ui->updateButton->setEnabled(flag); - //ui->startButton->setEnabled(externalExecuter->findApp()); ui->updateButton->show(); } diff --git a/Widgets/commonbuttongroupwidget.h b/Widgets/commonbuttongroupwidget.h index 715c980..6b7fdcb 100644 --- a/Widgets/commonbuttongroupwidget.h +++ b/Widgets/commonbuttongroupwidget.h @@ -18,7 +18,7 @@ class CommonButtonGroupWidget : public QWidget public: explicit CommonButtonGroupWidget(QWidget *parent = nullptr); - void initialize(ExternalExecuter *extExec,SendSystem *sendSystem,TCPClient *client); + void initialize(ExternalExecuter *extExec,SendSystem *sendSystem); void loadCompleteState(); void lastVerInstalledState(); void disconnectState(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 06627a3..b3d363d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -25,10 +26,11 @@ MainWindow::MainWindow(QWidget *parent) void MainWindow::createObjects() { qRegisterMetaType("PacketType"); - - updateWidget = new UpdateNotifyWidget; + QMutex *mutex = new QMutex; + QMutexLocker locker(mutex); + updateWidget->setParent(this); commonButtonGroupWidget = new CommonButtonGroupWidget; instructorButtonGroup = new InstructorButtonGroupWidget; @@ -83,7 +85,7 @@ void MainWindow::createObjects() timer = new QTimer; } -void MainWindow::paintEvent(QPaintEvent* event) { +void MainWindow::paintEvent(QPaintEvent*) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -114,7 +116,7 @@ void MainWindow::initialize() dataParser->initialize(postProcessorSystem); recognizeSystem->initialize(dataParser, versionContainer, postProcessorSystem); resourceManager->painting(); - commonButtonGroupWidget->initialize(externalExecuter,sendSystem,client); + commonButtonGroupWidget->initialize(externalExecuter,sendSystem); commonButtonGroupWidget->show(); ui->LanguageWidget->hide(); @@ -122,7 +124,7 @@ void MainWindow::initialize() setInlineDebug(tr("Инициализация...")); emit sigCalculateHash(); - emit sigInitializeClient(recognizeSystem,externalExecuter,sendSystem); + emit sigInitializeClient(recognizeSystem,sendSystem); screenChecker->check(); @@ -135,8 +137,6 @@ void MainWindow::initialize() ui->versionLayoutWidget->hide(); } - - void MainWindow::bindConnection() { connect(timer,&QTimer::timeout,this,&MainWindow::slotDisableNotify); @@ -555,6 +555,8 @@ void MainWindow::on_exitButton_clicked() client->disconnect(); workerThread->quit(); + workerThread->wait(); + delete workerThread; delete ui; diff --git a/mainwindow.h b/mainwindow.h index ed94296..86c9642 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -53,7 +53,7 @@ public: void showWarning(QString text); void setInlineDebug(QString value); signals: - void sigInitializeClient(RecognizeSystem *recognize,ExternalExecuter *externalExecuter,SendSystem *sendSystem); + void sigInitializeClient(RecognizeSystem *recognize,SendSystem *sendSystem); void sigRecognize(UpdateController* updateController, DataParser* dataParser, MainWindow* mainWindow,