/*! * * Copyright (c) 2019-2019 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::initConnections() { // From HD/DG connect(_ApplicationController, SIGNAL(didActionReceive (GuiActionType, const QVariantList &)), this , SLOT( onActionReceive (GuiActionType, const QVariantList &))); } /*! * \brief GuiController initializer */ void GuiController::init() { initConnections(); } /*! * \brief An Action has been requested * \details 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::doActionTransmit(GuiActionType vAction, const QVariantList &vData) { if (! handleTransmit(vAction, vData)) { emit didActionTransmit(vAction, vData); } } bool GuiController::handleTransmit(GuiActionType, const QVariantList &) { // This is an example implementation of how to handle // which does not require HD approval in GuiController /* // Process the GuiView Request. // It can be processed in GuiController take action and notify GuiView switch (vAction) { case GuiActionType::PowerOff: // GUI Controller decides (loop back) if (vData == GuiActionData::NoData){ // PowerOff noData is a request emit didActionReceive (vAction, GuiActionData::Accepted); return true; } break; //case Another_Command_Which_Doesn't_Require_HD_Approval: //return true; //break; default: break; } */ return false; } /*! * \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::onActionReceive (GuiActionType vAction, const QVariantList &vData) { // Process the command and notify GuiView // Process ... emit didActionReceive (vAction, vData); }