/*! * * 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 guicontroller.cpp * \date 2019/09/30 * \author Behrouz NematiPour * */ #include "guicontroller.h" // Qt #include // Project #include "applicationcontroller.h" // namespace using namespace Gui; // Singleton SINGLETON_INIT(GuiController) /*! * \brief GuiController Constructor * \param parent */ GuiController::GuiController(QObject *parent) : QObject(parent) {} /*! * \brief GuiController connections definition */ void GuiController::connection() { // From HD/DG connect(_ApplicationController, SIGNAL(didActionCommand(GuiActionType)), this , SLOT( onActionCommand(GuiActionType))); // From HD/DG connect(_ApplicationController, SIGNAL(didActionConfirm(GuiActionType, GuiActionInfo)), this , SLOT( onActionConfirm(GuiActionType, GuiActionInfo))); } /*! * \brief GuiController initializer */ void GuiController::init() { connection(); } /*! * \brief GuiController::onActionRequest * This method Confirmed that if the action is accepted or not,\n * Regarding the current state and the action.\n * These actions are only user actions and there is only one user interaction,\n * So no need to capture from which screen this action comes since we have the current state.\n * Sometimes GuiController requires to investigate with the ApplicationController to get approval from HD device.\n * \param vAction - User requested Action */ void GuiController::doActionRequest(GuiActionType vAction) { // Process the GuiView Request. // If can be processed in GuiController take action and notify GuiView //qDebug() << "GuiController.actionRequested : " << vAction; GuiActionInfo mInfo = GuiActionInfo::Accepted; Q_UNUSED(mInfo) switch (vAction) { // TODO : Test Code case GuiActionType::PowerOff: emit didActionConfirm(vAction, mInfo); break; default: // If it requires to be Confirmed by HD/DG send the request to ApplicationController emit didActionRequest(vAction); break; } } /*! * \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 GuiController::doActionPerform(GuiActionType vAction, GuiActionInfo vInfo) { // qDebug() << "GuiController.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 GuiController::onActionCommand(GuiActionType vAction) { // qDebug() << "GuiController.actionCommanded : " << vAction; // Process the command and notify GuiView // 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 GuiController::onActionConfirm(GuiActionType vAction, GuiActionInfo vInfo) { // qDebug() << "GuiController.actionConfirmed : " << vAction; // Process the command and notify GuiView // Process ... emit didActionConfirm(vAction, vInfo); }