2022-01-06 19:29:19 +00:00
|
|
|
#include "module.h"
|
|
|
|
#include "accounts/service_interface.h"
|
|
|
|
#include "controller.h"
|
|
|
|
#include "modules/startup/login/module.h"
|
|
|
|
#include "modules/startup/onboarding/module.h"
|
|
|
|
#include "singleton.h"
|
|
|
|
#include "view.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QQmlContext>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
namespace Modules
|
|
|
|
{
|
|
|
|
namespace Startup
|
|
|
|
{
|
2022-01-20 15:50:10 +00:00
|
|
|
Module::Module(AppControllerDelegate* delegate,
|
2022-02-21 18:03:38 +00:00
|
|
|
/*keychainService,*/
|
|
|
|
Accounts::ServiceInterface* accountsService)
|
|
|
|
: m_delegate(delegate)
|
2022-01-06 19:29:19 +00:00
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_controller = new Controller(this, accountsService);
|
|
|
|
m_view = new View(this);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
// Submodules
|
|
|
|
m_onboardingModule = new Modules::Startup::Onboarding::Module(this, accountsService);
|
|
|
|
m_loginModule = new Modules::Startup::Login::Module(this, /*keychainService, */ accountsService);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Module::~Module()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
delete m_controller;
|
|
|
|
delete m_view;
|
|
|
|
delete m_onboardingModule;
|
|
|
|
delete m_loginModule;
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::load()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("startupModule", m_view);
|
|
|
|
m_controller->init();
|
|
|
|
m_view->load();
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
AppState initialAppState(AppState::OnboardingState);
|
|
|
|
if(!m_controller->shouldStartWithOnboardingScreen())
|
|
|
|
{
|
|
|
|
initialAppState = AppState::LoginState;
|
|
|
|
}
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->setAppState(initialAppState);
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
m_onboardingModule->load();
|
|
|
|
m_loginModule->load();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::checkIfModuleDidLoad()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
if(!m_onboardingModule->isLoaded())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
if(!m_loginModule->isLoaded())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-01-06 19:29:19 +00:00
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
m_delegate->startupDidLoad();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::viewDidLoad()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Module::checkIfModuleDidLoad();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::onboardingDidLoad()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Module::checkIfModuleDidLoad();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::loginDidLoad()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
Module::checkIfModuleDidLoad();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::userLoggedIn()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_delegate->userLoggedIn();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::moveToAppState()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->setAppState(AppState::MainAppState);
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Module::emitLogOut()
|
|
|
|
{
|
2022-02-21 18:03:38 +00:00
|
|
|
m_view->emitLogOut();
|
2022-01-06 19:29:19 +00:00
|
|
|
}
|
|
|
|
} // namespace Startup
|
2022-02-21 18:03:38 +00:00
|
|
|
} // namespace Modules
|