2022-02-14 14:38:41 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QQmlContext>
|
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
#include "accounts/module.h"
|
2022-02-14 14:38:41 +00:00
|
|
|
#include "module.h"
|
|
|
|
#include "singleton.h"
|
|
|
|
|
2022-02-16 21:51:04 +00:00
|
|
|
namespace Modules::Main::Wallet
|
2022-02-14 14:38:41 +00:00
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Module::Module(std::shared_ptr<Wallets::ServiceInterface> walletsService, QObject* parent)
|
|
|
|
: QObject(parent)
|
2022-02-14 14:38:41 +00:00
|
|
|
{
|
2022-02-16 21:51:04 +00:00
|
|
|
m_controllerPtr = new Controller(walletsService, this);
|
|
|
|
m_viewPtr = new View(this);
|
2022-02-14 14:38:41 +00:00
|
|
|
|
|
|
|
// Sub-Modules
|
2022-02-16 21:51:04 +00:00
|
|
|
m_accountsModulePtr = new Modules::Main::Wallet::Accounts::Module(walletsService, this);
|
2022-02-14 14:38:41 +00:00
|
|
|
|
|
|
|
m_moduleLoaded = false;
|
|
|
|
connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::connect()
|
|
|
|
{
|
2022-02-16 21:51:04 +00:00
|
|
|
QObject::connect(m_viewPtr, SIGNAL(viewLoaded()), this, SLOT(viewDidLoad()));
|
|
|
|
QObject::connect(dynamic_cast<QObject*>(m_accountsModulePtr), SIGNAL(loaded()), this, SLOT(accountsDidLoad()));
|
2022-02-14 14:38:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::load()
|
|
|
|
{
|
2022-02-16 21:51:04 +00:00
|
|
|
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("walletSection", m_viewPtr);
|
2022-02-14 14:38:41 +00:00
|
|
|
m_controllerPtr->init();
|
|
|
|
m_viewPtr->load();
|
|
|
|
m_accountsModulePtr->load();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Module::isLoaded()
|
|
|
|
{
|
|
|
|
return m_moduleLoaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::checkIfModuleDidLoad()
|
|
|
|
{
|
|
|
|
if(!m_accountsModulePtr->isLoaded())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_moduleLoaded = true;
|
|
|
|
emit loaded();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::viewDidLoad()
|
2022-02-21 18:03:38 +00:00
|
|
|
{
|
2022-02-14 14:38:41 +00:00
|
|
|
checkIfModuleDidLoad();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::accountsDidLoad()
|
|
|
|
{
|
|
|
|
checkIfModuleDidLoad();
|
|
|
|
}
|
|
|
|
|
2022-02-16 21:51:04 +00:00
|
|
|
} // namespace Modules::Main::Wallet
|