1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-01-31 21:22:58 +08:00
2020-07-18 02:59:38 +08:00

56 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "Common/objectmap.h"
#include "TaoObject.h"
#include <QObject>
class QQmlContext;
class QQuickView;
class TaoFramework {
public:
static TaoFramework* instance();
~TaoFramework();
public:
//初始化
void init();
//反初始化
void uninit();
//ui加载之前做的处理
void beforeUiReady(QQmlContext* ctx);
//ui加载完成时做的处理
void afterUiReady();
public:
//创建TaoObject
template <class TaoObjectType>
void createObject(QObject *parent = nullptr)
{
m_objMap.createObject<TaoObjectType>(parent);
}
//销毁TaoObject
template <class TaoObjectType>
bool destoryObject()
{
return m_objMap.destroyObject<TaoObjectType>();
}
//获取TaoObject
template <class TaoObjectType>
TaoObjectType *getObject() const
{
return m_objMap.getObject<TaoObjectType>();
}
QQuickView *getMainView() const
{
return m_mainView;
}
void setMainView(QQuickView *mainView)
{
m_mainView = mainView;
}
private:
TaoFramework() {}
private:
TaoCommon::CObjectMap<TaoObject> m_objMap;
QQuickView *m_mainView = nullptr;
};