DocsUpdater в отдельный поток

This commit is contained in:
2025-11-12 10:55:31 +03:00
parent 81d7e5e6d6
commit 650b0525a3
10 changed files with 103 additions and 18 deletions

View File

@@ -26,7 +26,7 @@
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="InstructorsAndTrainees.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/lms.png</normaloff>:/resources/icons/lms.png</iconset>
</property>
<property name="sizeGripEnabled">
@@ -242,7 +242,7 @@
<string>Save</string>
</property>
<property name="icon">
<iconset resource="InstructorsAndTrainees.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/circleGreen.png</normaloff>:/resources/icons/circleGreen.png</iconset>
</property>
<property name="iconSize">
@@ -301,7 +301,7 @@
<string>Version</string>
</property>
<property name="icon">
<iconset resource="InstructorsAndTrainees.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/updateVersion.png</normaloff>:/resources/icons/updateVersion.png</iconset>
</property>
<property name="iconSize">
@@ -333,7 +333,7 @@
<string>Style</string>
</property>
<property name="icon">
<iconset resource="InstructorsAndTrainees.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/style.png</normaloff>:/resources/icons/style.png</iconset>
</property>
<property name="iconSize">
@@ -370,7 +370,7 @@
</layout>
</widget>
<resources>
<include location="InstructorsAndTrainees.qrc"/>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -19,5 +19,6 @@
<file>resources/icons/checkDB.png</file>
<file>resources/icons/editorDB.png</file>
<file>resources/icons/procedure.png</file>
<file>resources/icons/exchange.png</file>
</qresource>
</RCC>

View File

@@ -3,9 +3,9 @@
#include "tools.h"
DocsUpdater::DocsUpdater(UpdateController* updateController, QWidget *parentWidget):
DocsUpdater::DocsUpdater(UpdateController* updateController, QObject *parent):
QObject(parent),
updateController(updateController),
parentWidget(parentWidget),
flagStop(false)
{
@@ -16,7 +16,7 @@ DocsUpdater::~DocsUpdater()
}
bool DocsUpdater::update()
bool DocsUpdater::slot_update()
{
QMutexLocker locker(&mtxAccess);

View File

@@ -1,17 +1,21 @@
#ifndef DOCSUPDATER_H
#define DOCSUPDATER_H
#include <QObject>
#include "updatecontroller.h"
#include "module.h"
class DocsUpdater
class DocsUpdater : public QObject
{
Q_OBJECT
public:
DocsUpdater(UpdateController* updateController, QWidget *parentWidget);
DocsUpdater(UpdateController* updateController, QObject *parent = nullptr);
~DocsUpdater();
bool update();
public slots:
bool slot_update();
private:
void domElementParserAMM(QDomElement element, Module* moduleParent);
@@ -21,7 +25,6 @@ private:
private:
UpdateController* updateController;
QWidget *parentWidget;
QMutex mtxAccess;
bool flagStop;
QList<Module*> listAllModulesAMM; //?

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -59,6 +59,7 @@ ServerLMSWidget::~ServerLMSWidget()
delete dataParser;
delete processingSystem;
delete updateController;
delete docsUpdater;
delete assetsManager;
delete chatSystem;
@@ -114,6 +115,13 @@ void ServerLMSWidget::slot_ErrorPostgreSQL(QString text)
QMessageBox::critical(this, tr("Error PostgreSQL!"),text);
}
void ServerLMSWidget::slot_UpdateDocs()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
emit signal_DocsUpdaterUpdate();
QApplication::restoreOverrideCursor();
}
void ServerLMSWidget::start()
{
startInitialization();
@@ -190,6 +198,8 @@ void ServerLMSWidget::on_btnSettings_clicked()
connect(&dlg, &DialogSettingsTray::signal_LanguageChanged, this, &ServerLMSWidget::slot_LanguageChanged);
//connect(&dlg, &DialogSettingsTray::signal_UpdateStyleSheet, this, &ServerLMSWidget::slot_UpdateStyleSheet);
connect(&dlg, &DialogSettingsTray::signal_UpdateDocs, this, &ServerLMSWidget::slot_UpdateDocs);
switch( dlg.exec() )
{
@@ -271,6 +281,8 @@ QString ServerLMSWidget::loadStyleSheet()
void ServerLMSWidget::startInitialization()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
providerDBLMS = new ProviderDBLMS(this);
connect(providerDBLMS, &ProviderDBLMS::signal_ErrorPostgreSQL, this, &ServerLMSWidget::slot_ErrorPostgreSQL);
connect(providerDBLMS, &ProviderDBLMS::signal_BlockAutorization, this, &ServerLMSWidget::slot_BlockAutorization);
@@ -315,7 +327,9 @@ void ServerLMSWidget::startInitialization()
emit sigUpdateController(commonClientHandler,dataParser,assetsManager);
docsUpdater = new DocsUpdater(updateController, this);
docsUpdater->update();
connect(this, &ServerLMSWidget::signal_DocsUpdaterUpdate, docsUpdater, &DocsUpdater::slot_update,Qt::DirectConnection);
docsUpdater->moveToThread(updateThread);
slot_UpdateDocs();
ui->btnStopServer->setEnabled(false);
ui->btnStartServer->setEnabled(true);
@@ -323,6 +337,8 @@ void ServerLMSWidget::startInitialization()
flStartInitialization = true;
updateStateServer();
QApplication::restoreOverrideCursor();
}
void ServerLMSWidget::tryConnectionToDB()

View File

@@ -78,6 +78,8 @@ signals:
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
QTcpSocket* sigGetSocket();
void signal_DocsUpdaterUpdate();
public slots:
void slot_LanguageChanged(QString language);
void slot_UpdateListClients();
@@ -86,6 +88,8 @@ public slots:
void slot_ErrorPostgreSQL(QString text);
void slot_UpdateDocs();
public:
QString getLanguage()
{

View File

@@ -17,6 +17,7 @@ DialogSettingsTray::DialogSettingsTray(ProviderDBLMS* providerDBLMS, QWidget *pa
ui->btnSave->setObjectName("btnSave");
ui->btnCheckDB->setObjectName("btnCheckDB");
ui->btnUpdateDocs->setObjectName("btnUpdateDocs");
/* Создаем строку для регулярного выражения */
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
@@ -349,3 +350,8 @@ void DialogSettingsTray::on_btnCheckDB_clicked()
return;
}
}
void DialogSettingsTray::on_btnUpdateDocs_clicked()
{
emit signal_UpdateDocs();
}

View File

@@ -38,6 +38,7 @@ public:
signals:
//сигнал об изменении языка интерфейса
void signal_LanguageChanged(QString language);
void signal_UpdateDocs();
private slots:
void on_btnSave_clicked();
@@ -60,6 +61,8 @@ private slots:
void on_checkLocalhost_stateChanged(int arg1);
void on_btnUpdateDocs_clicked();
private:
bool saveSettings();

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<width>550</width>
<height>400</height>
</rect>
</property>
@@ -245,7 +245,7 @@
<string>Check&amp;&amp;Repare</string>
</property>
<property name="icon">
<iconset resource="ServerLMS.qrc">
<iconset resource="../ServerLMS.qrc">
<normaloff>:/resources/icons/checkDB.png</normaloff>:/resources/icons/checkDB.png</iconset>
</property>
<property name="iconSize">
@@ -293,7 +293,7 @@
<string>Save</string>
</property>
<property name="icon">
<iconset resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
<iconset resource="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/circleGreen.png</normaloff>:/resources/icons/circleGreen.png</iconset>
</property>
<property name="iconSize">
@@ -314,13 +314,65 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_Additional">
<property name="title">
<string>Additional</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_Additional">
<item>
<widget class="QToolButton" name="btnUpdateDocs">
<property name="minimumSize">
<size>
<width>80</width>
<height>58</height>
</size>
</property>
<property name="text">
<string>Update Docs</string>
</property>
<property name="icon">
<iconset resource="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<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>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../InstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
<include location="ServerLMS.qrc"/>
<include location="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
<include location="../ServerLMS.qrc"/>
</resources>
<connections/>
</ui>