homescreenapp/hsapplication/tsrc/t_hsapplication/t_hsapplicationexe/src/hsgui_mock.cpp
changeset 90 3ac3aaebaee5
equal deleted inserted replaced
86:e4f038c420f7 90:3ac3aaebaee5
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <HbInstance>
       
    19 #include <HbMainWindow>
       
    20 #include <HbView>
       
    21 #include <HbMenu>
       
    22 #include <HbAction>
       
    23 
       
    24 #include "hsgui.h"
       
    25 #include "hsscene.h"
       
    26 #include "hsconfiguration.h"
       
    27 
       
    28 namespace {
       
    29       const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
       
    30 }
       
    31 
       
    32 /*!
       
    33     \class HsGui
       
    34     \ingroup group_hsdomainmodel
       
    35     \brief Represents a view in the framework.
       
    36     HsGui includes common UI components for Home screen.
       
    37 */
       
    38 
       
    39 HsGui *HsGui::mInstance(0);
       
    40 
       
    41 struct HsGuiImpl
       
    42 {
       
    43     HbView *mIdleView;
       
    44     HbMainWindow *mWindow;
       
    45     HbAction *mNavigationAction;
       
    46 };
       
    47 
       
    48 
       
    49 
       
    50 HsGui::~HsGui()
       
    51 {
       
    52     if (mImpl->mNavigationAction) {
       
    53         delete mImpl->mNavigationAction;
       
    54     }
       
    55 
       
    56     delete mImpl;
       
    57 }
       
    58 
       
    59 HsGui *HsGui::setInstance(HsGui *instance)
       
    60 {
       
    61     HsGui *old = mInstance;
       
    62     if (mInstance != instance) {
       
    63         mInstance = instance;
       
    64     }
       
    65     return old;
       
    66 }
       
    67 
       
    68 HsGui *HsGui::instance()
       
    69 {
       
    70     if (!mInstance) {
       
    71         mInstance = new HsGui(QCoreApplication::instance());
       
    72     }
       
    73     return mInstance;
       
    74 }
       
    75 
       
    76 HsGui *HsGui::takeInstance()
       
    77 {
       
    78     HsGui *instance = mInstance;
       
    79     mInstance = 0;
       
    80     return instance;
       
    81 }
       
    82 
       
    83 void HsGui::setupIdleUi()
       
    84 {
       
    85     
       
    86 }
       
    87 
       
    88 void HsGui::cleanupIdleUi()
       
    89 {
       
    90     if (mImpl->mIdleView) {
       
    91         mImpl->mIdleView->setNavigationAction(0);
       
    92         delete mImpl->mNavigationAction;
       
    93         mImpl->mNavigationAction = 0;
       
    94         
       
    95         mImpl->mWindow->removeView(mImpl->mIdleView);
       
    96         delete mImpl->mIdleView;
       
    97         mImpl->mIdleView = 0;
       
    98 
       
    99         // This gets deleted when mImpl->mIdleView is deleted
       
   100         // so just nullify.
       
   101     }
       
   102     
       
   103 }
       
   104 
       
   105 void HsGui::setOrientation(Qt::Orientation orientation)
       
   106 {
       
   107     mImpl->mWindow->setOrientation(orientation);
       
   108 }
       
   109 
       
   110 Qt::Orientation HsGui::orientation()
       
   111 {
       
   112     return mImpl->mWindow->orientation();
       
   113 }
       
   114 
       
   115 HbView *HsGui::idleView() const
       
   116 {
       
   117     return mImpl->mIdleView;
       
   118 }
       
   119 
       
   120 QRectF HsGui::layoutRect() const
       
   121 {
       
   122     return mImpl->mWindow->layoutRect();
       
   123 }
       
   124 
       
   125 void HsGui::show()
       
   126 {
       
   127     mImpl->mWindow->raise();
       
   128     mImpl->mWindow->show();
       
   129 }
       
   130 
       
   131 HsGui::HsGui(QObject *parent):
       
   132     QObject(parent),mImpl(new HsGuiImpl)
       
   133 {
       
   134     mImpl->mIdleView = 0;
       
   135     mImpl->mNavigationAction = 0;
       
   136 
       
   137     mImpl->mWindow = hbInstance->allMainWindows().first();
       
   138     connect(mImpl->mWindow, SIGNAL(orientationChanged(Qt::Orientation)),
       
   139         SIGNAL(orientationChanged(Qt::Orientation)));
       
   140 }