/*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright \n * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n * IN PART OR IN WHOLE, \n * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n * * \file applicationcontroller.cpp * \date 2019/09/30 * \author Behrouz NematiPour * */ #include "applicationcontroller.h" // Qt // Project #include "guiglobals.h" #include "guicontroller.h" #include "messagehandler.h" // Singleton SINGLETON_INIT(ApplicationController) /*! * \brief ApplicationController Constructor * \param parent */ ApplicationController::ApplicationController(QObject *parent) : QObject(parent) { _fileHandler = new Storage::FileHandler (this); _applicationPost = new ApplicationPost(this); } /*! * \brief ApplicationController initializer */ bool ApplicationController::init() { if (!_fileHandler ->init()) return false; if (!_applicationPost->init()) return false; connection(); return true; } /*! * \brief GUI Controller connections definition */ void ApplicationController::connection() { // From GUI connect(_GuiController , SIGNAL(didActionRequest(GuiActionType)), this , SLOT( onActionRequest(GuiActionType))); // From GUI connect(_GuiController , SIGNAL(didActionPerform(GuiActionType,GuiActionInfo)), this , SLOT( onActionPerform(GuiActionType, GuiActionInfo))); // From HD/DG connect(_MessageHandler, SIGNAL(didActionCommand(GuiActionType)), this , SLOT( onActionCommand(GuiActionType))); // From HD/DG connect(_MessageHandler, SIGNAL(didActionConfirm(GuiActionType,GuiActionInfo)), this , SLOT( onActionConfirm(GuiActionType, GuiActionInfo))); } /*! * \brief Process the requested action * \details Processes the requested action * \param vAction - User requested Action */ void ApplicationController::onActionRequest(GuiActionType vAction) { // qDebug() << "ApplicationController.actionRequested : " << vAction; // Process the requested action by GUI // Process ... emit didActionRequest(vAction); } /*! * \brief Process the performed action * \details An action which has been commanded by HD has been performed by GUI.\n * GUI notifies that the action has been performed * \param vAction * \param vInfo */ void ApplicationController::onActionPerform(GuiActionType vAction, GuiActionInfo vInfo) { // qDebug() << "ApplicationController.actionPerformed : " << vAction << vInfo; // Process the performed action by GUI // Process ... emit didActionPerform(vAction, vInfo); } /*! * \brief Action commanded by HD * \details An action has been commanded by HD, * GUI requires to be notified to perform the action. * \param vAction */ void ApplicationController::onActionCommand(GuiActionType vAction) { // qDebug() << "ApplicationController.actionCommanded : " << vAction; // Process the command and notify GUI Controller // Process ... emit didActionCommand(vAction); } /*! * \brief An action has been confirmed * \details GUI requested an action. * In response HD confirmed the action. * \param vAction * \param vInfo */ void ApplicationController::onActionConfirm(GuiActionType vAction, GuiActionInfo vInfo) { // qDebug() << "ApplicationController.actionConfirmed : " << vAction; // Process the command and notify GUI Controller // Process ... emit didActionConfirm(vAction, vInfo); }