mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
WidgetTools::closeAllChildWidgets
This commit is contained in:
@@ -27,8 +27,6 @@ add_library(InstructorsAndTrainees SHARED
|
|||||||
specialmessagebox/specialmessagebox.cpp
|
specialmessagebox/specialmessagebox.cpp
|
||||||
specialmessagebox/specialmessagebox.h
|
specialmessagebox/specialmessagebox.h
|
||||||
specialmessagebox/specialmessagebox.ui
|
specialmessagebox/specialmessagebox.ui
|
||||||
specialmessagebox/notifycontroller.cpp
|
|
||||||
specialmessagebox/notifycontroller.h
|
|
||||||
|
|
||||||
authorization/dialogauthorization.cpp
|
authorization/dialogauthorization.cpp
|
||||||
authorization/dialogauthorization.h
|
authorization/dialogauthorization.h
|
||||||
@@ -141,6 +139,8 @@ add_library(InstructorsAndTrainees SHARED
|
|||||||
widgets/waitanimationwidget.cpp
|
widgets/waitanimationwidget.cpp
|
||||||
widgets/waitanimationwidget.h
|
widgets/waitanimationwidget.h
|
||||||
widgets/waitanimationwidget.ui
|
widgets/waitanimationwidget.ui
|
||||||
|
widgets/widgettools.cpp
|
||||||
|
widgets/widgettools.h
|
||||||
|
|
||||||
InstructorsAndTrainees.qrc
|
InstructorsAndTrainees.qrc
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#include "connectortoserver.h"
|
#include "connectortoserver.h"
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
|
ConnectorToServer::ConnectorToServer(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
parentWidget(parentWidget),
|
|
||||||
connectionThread(nullptr),
|
connectionThread(nullptr),
|
||||||
client(nullptr),
|
client(nullptr),
|
||||||
dataParser(nullptr),
|
dataParser(nullptr),
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "computer.h"
|
#include "computer.h"
|
||||||
#include "classroom.h"
|
#include "classroom.h"
|
||||||
#include "Datas.h"
|
#include "Datas.h"
|
||||||
#include "notifycontroller.h"
|
|
||||||
#include "streamingversiondata.h"
|
#include "streamingversiondata.h"
|
||||||
|
|
||||||
class ConnectorToServer : public QObject
|
class ConnectorToServer : public QObject
|
||||||
@@ -22,7 +21,7 @@ class ConnectorToServer : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConnectorToServer(QWidget* parentWidget, QObject *parent = nullptr);
|
explicit ConnectorToServer(QObject *parent = nullptr);
|
||||||
~ConnectorToServer();
|
~ConnectorToServer();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -167,7 +166,6 @@ private:
|
|||||||
void createObjects();
|
void createObjects();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* parentWidget;
|
|
||||||
QThread *connectionThread;
|
QThread *connectionThread;
|
||||||
TCPClient *client;
|
TCPClient *client;
|
||||||
DataParser *dataParser;
|
DataParser *dataParser;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "dialogsettings.h"
|
#include "dialogsettings.h"
|
||||||
#include "specialmessagebox.h"
|
#include "specialmessagebox.h"
|
||||||
#include "hashtools.h"
|
#include "hashtools.h"
|
||||||
|
#include "widgettools.h"
|
||||||
|
|
||||||
|
|
||||||
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
|
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
|
||||||
@@ -50,7 +51,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
|||||||
|
|
||||||
setLanguageInterfase();
|
setLanguageInterfase();
|
||||||
|
|
||||||
connectorToServer = new ConnectorToServer(this);
|
connectorToServer = new ConnectorToServer();
|
||||||
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
|
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
|
||||||
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
|
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
|
||||||
connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked);
|
connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked);
|
||||||
@@ -406,8 +407,11 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
|||||||
if(!flSettingsServerIsChanged)
|
if(!flSettingsServerIsChanged)
|
||||||
{
|
{
|
||||||
if(!flTryConnectToServer)
|
if(!flTryConnectToServer)
|
||||||
|
{
|
||||||
|
WidgetTools::closeAllChildWidgets(this, "SpecMsgBox");
|
||||||
SpecMsgBox::WarningClose(this, tr("The server is not available!"));
|
SpecMsgBox::WarningClose(this, tr("The server is not available!"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
flSettingsServerIsChanged = false;
|
flSettingsServerIsChanged = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
#include "notifycontroller.h"
|
|
||||||
#include "specialmessagebox.h"
|
|
||||||
|
|
||||||
NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) :
|
|
||||||
QObject(parent),
|
|
||||||
parentWidget(parentWidget)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotifyController::showWarning(QString text, QWidget *parentWidget)
|
|
||||||
{
|
|
||||||
if(parentWidget)
|
|
||||||
SpecMsgBox::WarningClose(parentWidget, text);
|
|
||||||
else
|
|
||||||
SpecMsgBox::WarningClose(this->parentWidget, text);
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#ifndef NOTIFYCONTROLLER_H
|
|
||||||
#define NOTIFYCONTROLLER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
class NotifyController : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit NotifyController(QWidget *parentWidget = nullptr, QObject *parent = nullptr);
|
|
||||||
|
|
||||||
void showWarning(QString text, QWidget *parentWidget = nullptr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QWidget *parentWidget;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // NOTIFYCONTROLLER_H
|
|
||||||
@@ -8,6 +8,8 @@ SpecMsgBox::SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
this->setObjectName("SpecMsgBox");
|
||||||
|
|
||||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
if(type == TypeSpecMsgBox::warningYesNo)
|
if(type == TypeSpecMsgBox::warningYesNo)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "ui_ammtaskswidget.h"
|
#include "ui_ammtaskswidget.h"
|
||||||
#include "checkertask.h"
|
#include "checkertask.h"
|
||||||
#include "specialmessagebox.h"
|
#include "specialmessagebox.h"
|
||||||
|
#include "widgettools.h"
|
||||||
|
|
||||||
AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) :
|
AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
|||||||
24
InstructorsAndTrainees/widgets/widgettools.cpp
Normal file
24
InstructorsAndTrainees/widgets/widgettools.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "widgettools.h"
|
||||||
|
|
||||||
|
WidgetTools::WidgetTools()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Рекурсивная функция для закрытия всех дочерних виджетов
|
||||||
|
void WidgetTools::closeAllChildWidgets(QWidget *parent, QString objName)
|
||||||
|
{
|
||||||
|
// Ищем всех дочерних виджетов типа QWidget
|
||||||
|
QObjectList children = parent->children();
|
||||||
|
foreach(auto obj, children)
|
||||||
|
{
|
||||||
|
if (auto wgt = qobject_cast<QWidget*>(obj))
|
||||||
|
{ // Проверяем имя объекта
|
||||||
|
if(wgt->objectName() == objName)
|
||||||
|
{
|
||||||
|
wgt->close(); // Закрываем виджет
|
||||||
|
}
|
||||||
|
closeAllChildWidgets(wgt, objName); // Рекурсия для возможных внучатых виджетов
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
InstructorsAndTrainees/widgets/widgettools.h
Normal file
16
InstructorsAndTrainees/widgets/widgettools.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef WIDGETTOOLS_H
|
||||||
|
#define WIDGETTOOLS_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class WidgetTools
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WidgetTools();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void closeAllChildWidgets(QWidget* parent, QString objName);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WIDGETTOOLS_H
|
||||||
Reference in New Issue
Block a user