status-desktop/src-cpp/app/modules/startup/onboarding/module.cpp

103 lines
2.2 KiB
C++
Raw Normal View History

2022-01-06 19:29:19 +00:00
#include "module.h"
2022-01-20 15:50:10 +00:00
#include "../interfaces/module_onboarding_delegate_interface.h"
2022-01-06 19:29:19 +00:00
#include "accounts/generated_account.h"
#include "accounts/service_interface.h"
#include "controller.h"
#include "singleton.h"
#include "view.h"
2022-01-20 15:50:10 +00:00
#include <QDebug>
2022-01-06 19:29:19 +00:00
#include <QObject>
#include <QQmlContext>
#include <QVariant>
#include <iostream>
namespace Modules
{
namespace Startup
{
namespace Onboarding
{
2022-01-20 15:50:10 +00:00
Module::Module(Modules::Startup::ModuleOnboardingDelegateInterface* delegate,
Accounts::ServiceInterface* accountsService)
: m_delegate(delegate)
2022-01-06 19:29:19 +00:00
{
m_controller = new Controller(this, accountsService);
m_view = new View(this);
m_moduleLoaded = false;
2022-01-06 19:29:19 +00:00
}
Module::~Module()
{
delete m_controller;
delete m_view;
2022-01-06 19:29:19 +00:00
}
void Module::load()
{
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("onboardingModule", m_view);
m_controller->init();
m_view->load();
2022-01-06 19:29:19 +00:00
QVector<Accounts::GeneratedAccountDto> gAcc = m_controller->getGeneratedAccounts();
QVector<Item> accounts;
foreach(const Accounts::GeneratedAccountDto& acc, gAcc)
{
accounts << Item(acc.id, acc.alias, acc.identicon, acc.address, acc.keyUid);
}
2022-01-06 19:29:19 +00:00
m_view->setAccountList(accounts);
2022-01-06 19:29:19 +00:00
}
bool Module::isLoaded()
{
return m_moduleLoaded;
2022-01-06 19:29:19 +00:00
}
void Module::viewDidLoad()
{
m_moduleLoaded = true;
m_delegate->onboardingDidLoad();
2022-01-06 19:29:19 +00:00
}
void Module::setSelectedAccountByIndex(int index)
{
m_controller->setSelectedAccountByIndex(index);
2022-01-06 19:29:19 +00:00
}
void Module::storeSelectedAccountAndLogin(QString password)
{
m_controller->storeSelectedAccountAndLogin(password);
2022-01-06 19:29:19 +00:00
}
void Module::setupAccountError()
{
m_view->setupAccountError();
2022-01-06 19:29:19 +00:00
}
Accounts::GeneratedAccountDto Module::getImportedAccount()
{
return m_controller->getImportedAccount();
2022-01-06 19:29:19 +00:00
}
QString Module::validateMnemonic(QString mnemonic)
{
return m_controller->validateMnemonic(mnemonic);
2022-01-06 19:29:19 +00:00
}
void Module::importMnemonic(QString mnemonic)
{
m_controller->importMnemonic(mnemonic);
2022-01-06 19:29:19 +00:00
}
void Module::importAccountError()
{
m_view->importAccountError();
2022-01-06 19:29:19 +00:00
}
void Module::importAccountSuccess()
{
m_view->importAccountSuccess();
2022-01-06 19:29:19 +00:00
}
} // namespace Onboarding
} // namespace Startup
} // namespace Modules