status-desktop/src-cpp/app/modules/main/module.cpp

65 lines
1.3 KiB
C++
Raw Normal View History

2022-01-20 14:48:57 +00:00
#include <QDebug>
#include <QQmlContext>
#include "../shared/section_item.h"
#include "module.h"
#include "modules/main/wallet/module.h"
#include "singleton.h"
2022-01-20 14:48:57 +00:00
namespace Modules::Main
2022-01-20 14:48:57 +00:00
{
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletService, QObject* parent)
: QObject(parent)
2022-01-20 14:48:57 +00:00
{
m_controllerPtr = new Controller(this);
m_viewPtr = new View(this);
// Submodules
m_walletModulePtr = new Modules::Main::Wallet::Module(walletService, this);
m_moduleLoaded = false;
connect();
2022-01-20 14:48:57 +00:00
}
void Module::connect()
2022-01-20 14:48:57 +00:00
{
QObject::connect(m_viewPtr, &View::viewLoaded, this, &Module::viewDidLoad);
// FIXME: use PointerToMember approach
QObject::connect(dynamic_cast<QObject*>(m_walletModulePtr), SIGNAL(loaded()), this, SLOT(walletDidLoad()));
2022-01-20 14:48:57 +00:00
}
void Module::load()
{
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("mainModule", m_viewPtr);
m_controllerPtr->init();
m_viewPtr->load();
m_walletModulePtr->load();
2022-01-20 14:48:57 +00:00
}
void Module::checkIfModuleDidLoad()
{
if(!m_walletModulePtr->isLoaded())
{
return;
}
m_moduleLoaded = true;
emit loaded();
2022-01-20 14:48:57 +00:00
}
void Module::viewDidLoad()
{
Module::checkIfModuleDidLoad();
}
void Module::walletDidLoad()
{
Module::checkIfModuleDidLoad();
}
bool Module::isLoaded()
{
return m_moduleLoaded;
2022-01-20 14:48:57 +00:00
}
} // namespace Modules::Main