Files
status-app/src-cpp/app/modules/main/module.cpp
T

65 lines
1.3 KiB
C++
Raw Normal View History

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