feat: add empty main module

This commit is contained in:
Richard Ramos 2022-01-20 10:48:57 -04:00
parent ec330b2ac8
commit 99ebb07d5c
14 changed files with 265 additions and 14 deletions

View File

@ -17,12 +17,16 @@ add_library(app
modules/startup/login/module.cpp
modules/startup/login/view.cpp
modules/startup/login/selected_account.cpp
modules/main/controller.cpp
modules/main/module.cpp
modules/main/view.cpp
)
target_include_directories(app
PUBLIC
./include/
./boot/
./modules/main
./modules/startup
)

View File

@ -2,6 +2,7 @@
#include "accounts/service.h"
#include "app_service.h"
#include "modules/startup/module.h"
#include "modules/main/module.h"
#include <QDebug>
AppController::AppController()
@ -65,8 +66,7 @@ AppController::AppController()
// # Modules
m_startupModule = new Modules::Startup::Module(this, /*keychainService,*/ m_accountsService);
// result.mainModule = main_module.newModule[AppController](
// result,
m_mainModule = new Modules::Main::Module(this
// statusFoundation.status.events,
// result.keychainService,
// result.accountsService,
@ -93,7 +93,7 @@ AppController::AppController()
// result.nodeConfigurationService,
// result.devicesService,
// result.mailserversService
// )
);
// # Do connections
connect();
@ -102,6 +102,7 @@ AppController::AppController()
AppController::~AppController()
{
delete m_startupModule;
delete m_mainModule;
delete m_accountsService;
}
@ -172,14 +173,14 @@ void AppController::load()
// self.buildAndRegisterUserProfile()
// # load main module
// self.mainModule.load(
// self.statusFoundation.status.events,
// self.settingsService,
// self.contactsService,
// self.chatService,
// self.communityService,
// self.messageService
// )
m_mainModule->load(
// self.statusFoundation.status.events,
// self.settingsService,
// self.contactsService,
// self.chatService,
// self.communityService,
// self.messageService
);
}
void AppController::userLoggedIn()

View File

@ -1,7 +1,8 @@
#pragma once
#include "accounts/service.h"
#include "module_access_interface.h"
#include "../modules/main/module_access_interface.h"
#include "../modules/startup/module_access_interface.h"
#include "app_controller_delegate.h"
#include "app_service.h"
@ -21,7 +22,7 @@ class AppController : public AppControllerDelegate
// Modules
Modules::Startup::ModuleAccessInterface* m_startupModule;
//mainModule: main_module.AccessInterface
Modules::Main::ModuleAccessInterface* m_mainModule;
public:
AppController();

View File

@ -10,6 +10,11 @@ public:
throw std::domain_error("Not implemented");
}
virtual void mainDidLoad()
{
throw std::domain_error("Not implemented");
}
virtual void userLoggedIn()
{
throw std::domain_error("Not implemented");

View File

@ -0,0 +1,18 @@
#include "controller.h"
#include "accounts/service_interface.h"
#include "interfaces/module_controller_delegate_interface.h"
#include <QDebug>
namespace Modules
{
namespace Main
{
Controller::Controller(ModuleControllerDelegateInterface* d, QObject* parent)
: QObject(parent)
, m_delegate(d)
{ }
void Controller::init() { }
} // namespace Main
} // namespace Modules

View File

@ -0,0 +1,24 @@
#pragma once
#include "controller_interface.h"
#include "interfaces/module_controller_delegate_interface.h"
#include "signals.h"
#include <QObject>
namespace Modules
{
namespace Main
{
class Controller : public QObject, ControllerInterface
{
public:
Controller(ModuleControllerDelegateInterface* d, QObject* parent = nullptr);
void init() override;
private:
ModuleControllerDelegateInterface* m_delegate;
};
} // namespace Main
} // namespace Modules

View File

@ -0,0 +1,21 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Main
{
// Abstract class for any input/interaction with this module.
class ControllerInterface
{
public:
virtual void init()
{
throw std::domain_error("Not implemented");
}
};
} // namespace Main
} // namespace Modules

View File

@ -0,0 +1,17 @@
#pragma once
#include "accounts/service_interface.h"
#include "app_controller_delegate.h"
#include "controller.h"
#include <stdexcept>
namespace Modules
{
namespace Main
{
class ModuleControllerDelegateInterface
{
public:
};
}; // namespace Main
}; // namespace Modules

View File

@ -0,0 +1,18 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Main
{
class ModuleViewDelegateInterface
{
public:
virtual void viewDidLoad()
{
throw std::domain_error("Not implemented");
}
};
}; // namespace Main
}; // namespace Modules

View File

@ -0,0 +1,46 @@
#include "module.h"
#include "controller.h"
#include "singleton.h"
#include "view.h"
#include <QDebug>
#include <QObject>
#include <QQmlContext>
#include <QVariant>
namespace Modules
{
namespace Main
{
Module::Module(AppControllerDelegate* d)
{
m_delegate = d;
m_controller = new Controller(this);
m_view = new View(this);
}
Module::~Module()
{
delete m_controller;
delete m_view;
}
void Module::load()
{
Global::Singleton::instance()->engine()->rootContext()->setContextProperty("mainModule", m_view);
m_controller->init();
m_view->load();
}
void Module::checkIfModuleDidLoad()
{
m_delegate->mainDidLoad();
}
void Module::viewDidLoad()
{
Module::checkIfModuleDidLoad();
}
} // namespace Main
} // namespace Modules

View File

@ -0,0 +1,32 @@
#pragma once
#include "app_controller_delegate.h"
#include "controller.h"
#include "interfaces/module_controller_delegate_interface.h"
#include "interfaces/module_view_delegate_interface.h"
#include "login/module_access_interface.h"
#include "module_access_interface.h"
#include "onboarding/module_access_interface.h"
#include "view.h"
#include <QVariant>
namespace Modules
{
namespace Main
{
class Module : public ModuleAccessInterface, ModuleControllerDelegateInterface, ModuleViewDelegateInterface
{
private:
AppControllerDelegate* m_delegate;
View* m_view;
Controller* m_controller;
public:
Module(AppControllerDelegate* d);
~Module();
void load() override;
void checkIfModuleDidLoad();
void viewDidLoad() override;
};
}; // namespace Main
}; // namespace Modules

View File

@ -0,0 +1,18 @@
#pragma once
#include <stdexcept>
namespace Modules
{
namespace Main
{
class ModuleAccessInterface
{
public:
virtual void load()
{
throw std::domain_error("Not implemented");
}
};
}; // namespace Main
}; // namespace Modules

View File

@ -0,0 +1,23 @@
#include "view.h"
#include "interfaces/module_view_delegate_interface.h"
#include <QObject>
namespace Modules
{
namespace Main
{
View::View(ModuleViewDelegateInterface* d, QObject* parent)
: QObject(parent)
{
m_delegate = d;
}
void View::load()
{
// In some point, here, we will setup some exposed main module related things.
m_delegate->viewDidLoad();
}
} // namespace Main
} // namespace Modules

View File

@ -0,0 +1,23 @@
#pragma once
#include "interfaces/module_view_delegate_interface.h"
#include <QObject>
namespace Modules
{
namespace Main
{
class View : public QObject
{
Q_OBJECT
public:
explicit View(ModuleViewDelegateInterface* d, QObject* parent = nullptr);
void load();
private:
ModuleViewDelegateInterface* m_delegate;
};
} // namespace Main
} // namespace Modules