You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.5 KiB
C

/**********************************************************************
* @file GUIDialogManager.h
* @brief
* @author BaGuijun (baguijun@163.com)
* @date 2024-10-22
*********************************************************************/
#ifndef __GUIDIALOGMANAGER_H__
#define __GUIDIALOGMANAGER_H__
#include "GUIDialogAPI.h"
#include <QList>
#include <QHash>
#include <QMessageBox>
namespace GUI
{
class GUIDialogBase;
class GUIDialogManagerDeletor;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
class GUIDialogAPI GUIDialogManager
{
public:
/**
* @brief Instance
* @return GUIDialogManager*
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-04-22
*/
static GUIDialogManager *getInstance()
{
if (_instance == nullptr)
_instance = new GUIDialogManager;
return _instance;
}
/**
* @brief
* @param dlg
* @param uniqueFlag
* @author YanZhiHui (chanyuantiandao@126.com)
* @data 2024-05-17
*/
void dialogCreated(GUIDialogBase *dlg, QString uniqueFlag = QString());
/**
* @brief
* @param dlg
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
void dialogDestoried(GUIDialogBase *dlg);
/**
* @brief
* @tparam T GUI::GUIDialogBase
* @return QList<T*>
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
template <typename T>
QList<T *> getDialog()
{
QList<T *> ds;
for (auto d : _dialogList)
{
T *dt = dynamic_cast<T *>(d);
if (dt != nullptr)
ds.append(dt);
}
return ds;
}
private:
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
static GUIDialogManager *_instance;
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
GUIDialogManager() {}
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-04-22
*/
~GUIDialogManager() = default;
/**
* @brief
* @return QList<GUIDialogBase*>
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
QList<GUIDialogBase *> getAllDialogs();
private:
/**
* @brief
* @author LiBaojun (libaojunqd@foxmail.com)
* @date 2023-06-09
*/
QList<GUIDialogBase *> _dialogList{};
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-05-17
*/
QHash<QString, GUIDialogBase *> _dialogHash{};
};
} // namespace GUI
#endif