mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
WidgetTools::closeAllChildWidgets
This commit is contained in:
@@ -27,8 +27,6 @@ add_library(InstructorsAndTrainees SHARED
|
||||
specialmessagebox/specialmessagebox.cpp
|
||||
specialmessagebox/specialmessagebox.h
|
||||
specialmessagebox/specialmessagebox.ui
|
||||
specialmessagebox/notifycontroller.cpp
|
||||
specialmessagebox/notifycontroller.h
|
||||
|
||||
authorization/dialogauthorization.cpp
|
||||
authorization/dialogauthorization.h
|
||||
@@ -141,6 +139,8 @@ add_library(InstructorsAndTrainees SHARED
|
||||
widgets/waitanimationwidget.cpp
|
||||
widgets/waitanimationwidget.h
|
||||
widgets/waitanimationwidget.ui
|
||||
widgets/widgettools.cpp
|
||||
widgets/widgettools.h
|
||||
|
||||
InstructorsAndTrainees.qrc
|
||||
)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "connectortoserver.h"
|
||||
#include <QThread>
|
||||
|
||||
ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
|
||||
ConnectorToServer::ConnectorToServer(QObject *parent) :
|
||||
QObject(parent),
|
||||
parentWidget(parentWidget),
|
||||
connectionThread(nullptr),
|
||||
client(nullptr),
|
||||
dataParser(nullptr),
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "computer.h"
|
||||
#include "classroom.h"
|
||||
#include "Datas.h"
|
||||
#include "notifycontroller.h"
|
||||
#include "streamingversiondata.h"
|
||||
|
||||
class ConnectorToServer : public QObject
|
||||
@@ -22,7 +21,7 @@ class ConnectorToServer : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectorToServer(QWidget* parentWidget, QObject *parent = nullptr);
|
||||
explicit ConnectorToServer(QObject *parent = nullptr);
|
||||
~ConnectorToServer();
|
||||
|
||||
public:
|
||||
@@ -167,7 +166,6 @@ private:
|
||||
void createObjects();
|
||||
|
||||
private:
|
||||
QWidget* parentWidget;
|
||||
QThread *connectionThread;
|
||||
TCPClient *client;
|
||||
DataParser *dataParser;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "dialogsettings.h"
|
||||
#include "specialmessagebox.h"
|
||||
#include "hashtools.h"
|
||||
#include "widgettools.h"
|
||||
|
||||
|
||||
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
|
||||
@@ -50,7 +51,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
|
||||
setLanguageInterfase();
|
||||
|
||||
connectorToServer = new ConnectorToServer(this);
|
||||
connectorToServer = new ConnectorToServer();
|
||||
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
|
||||
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
|
||||
connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked);
|
||||
@@ -406,7 +407,10 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
||||
if(!flSettingsServerIsChanged)
|
||||
{
|
||||
if(!flTryConnectToServer)
|
||||
{
|
||||
WidgetTools::closeAllChildWidgets(this, "SpecMsgBox");
|
||||
SpecMsgBox::WarningClose(this, tr("The server is not available!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
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);
|
||||
|
||||
this->setObjectName("SpecMsgBox");
|
||||
|
||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
if(type == TypeSpecMsgBox::warningYesNo)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "ui_ammtaskswidget.h"
|
||||
#include "checkertask.h"
|
||||
#include "specialmessagebox.h"
|
||||
#include "widgettools.h"
|
||||
|
||||
AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -155,7 +156,7 @@ void AMMtasksWidget::closeChildDlg()
|
||||
if(dlgCheckerTask)
|
||||
dlgCheckerTask->close();
|
||||
if(dlgListSubProc)
|
||||
dlgListSubProc->close();
|
||||
dlgListSubProc->close();
|
||||
}
|
||||
|
||||
void AMMtasksWidget::changeEvent(QEvent *event)
|
||||
|
||||
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