90
|
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 "hsidlewidget.h"
|
|
26 |
#include "hsscene.h"
|
|
27 |
#include "hspropertyanimationwrapper.h"
|
|
28 |
|
|
29 |
namespace {
|
|
30 |
const char gApplicationLibraryIconName[] = "qtg_mono_applications_all";
|
|
31 |
}
|
|
32 |
|
|
33 |
/*!
|
|
34 |
\class HsGui
|
|
35 |
\ingroup group_hsdomainmodel
|
|
36 |
\brief Represents a view in the framework.
|
|
37 |
HsGui includes common UI components for Home screen.
|
|
38 |
*/
|
|
39 |
|
|
40 |
HsGui *HsGui::mInstance(0);
|
|
41 |
|
|
42 |
struct HsGuiImpl
|
|
43 |
{
|
|
44 |
HsIdleWidget *mIdleWidget;
|
|
45 |
HbView *mIdleView;
|
|
46 |
HbMainWindow *mWindow;
|
|
47 |
HbAction *mNavigationAction;
|
|
48 |
HsPropertyAnimationWrapper *mPageChangeAnimation;
|
|
49 |
HsPropertyAnimationWrapper *mPageCrawlingAnimation;
|
|
50 |
};
|
|
51 |
|
|
52 |
HsGui::~HsGui()
|
|
53 |
{
|
|
54 |
if (mImpl->mNavigationAction) {
|
|
55 |
delete mImpl->mNavigationAction;
|
|
56 |
}
|
|
57 |
|
|
58 |
if (mImpl->mPageChangeAnimation) {
|
|
59 |
mImpl->mPageChangeAnimation->stop();
|
|
60 |
delete mImpl->mPageChangeAnimation;
|
|
61 |
}
|
|
62 |
if (mImpl->mPageCrawlingAnimation) {
|
|
63 |
mImpl->mPageCrawlingAnimation->stop();
|
|
64 |
delete mImpl->mPageCrawlingAnimation;
|
|
65 |
}
|
|
66 |
delete mImpl;
|
|
67 |
}
|
|
68 |
|
|
69 |
HsGui *HsGui::setInstance(HsGui *instance)
|
|
70 |
{
|
|
71 |
HsGui *old = mInstance;
|
|
72 |
if (mInstance != instance) {
|
|
73 |
mInstance = instance;
|
|
74 |
}
|
|
75 |
return old;
|
|
76 |
}
|
|
77 |
|
|
78 |
HsGui *HsGui::instance()
|
|
79 |
{
|
|
80 |
if (!mInstance) {
|
|
81 |
mInstance = new HsGui(QCoreApplication::instance());
|
|
82 |
}
|
|
83 |
return mInstance;
|
|
84 |
}
|
|
85 |
|
|
86 |
void HsGui::setupIdleUi()
|
|
87 |
{
|
|
88 |
if (!mImpl->mIdleWidget) {
|
|
89 |
mImpl->mIdleWidget = new HsIdleWidget;
|
|
90 |
mImpl->mIdleView = mImpl->mWindow->addView(mImpl->mIdleWidget);
|
|
91 |
mImpl->mIdleView->setContentFullScreen();
|
|
92 |
|
|
93 |
delete mImpl->mNavigationAction;
|
|
94 |
mImpl->mNavigationAction = 0;
|
|
95 |
mImpl->mNavigationAction = new HbAction;
|
|
96 |
mImpl->mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName));
|
|
97 |
mImpl->mNavigationAction->setObjectName("applib_navigation_action");
|
|
98 |
connect(mImpl->mNavigationAction, SIGNAL(triggered()), SIGNAL(navigateToApplibrary()));
|
|
99 |
mImpl->mIdleView->setNavigationAction(mImpl->mNavigationAction);
|
|
100 |
}
|
|
101 |
mImpl->mWindow->setCurrentView(mImpl->mIdleView);
|
|
102 |
}
|
|
103 |
|
|
104 |
void HsGui::cleanupIdleUi()
|
|
105 |
{
|
|
106 |
if (mImpl->mIdleView) {
|
|
107 |
mImpl->mIdleView->setNavigationAction(0);
|
|
108 |
delete mImpl->mNavigationAction;
|
|
109 |
mImpl->mNavigationAction = 0;
|
|
110 |
|
|
111 |
mImpl->mWindow->removeView(mImpl->mIdleView);
|
|
112 |
delete mImpl->mIdleView;
|
|
113 |
mImpl->mIdleView = 0;
|
|
114 |
|
|
115 |
delete mImpl->mPageChangeAnimation;
|
|
116 |
mImpl->mPageChangeAnimation = 0;
|
|
117 |
|
|
118 |
delete mImpl->mPageCrawlingAnimation;
|
|
119 |
mImpl->mPageCrawlingAnimation = 0;
|
|
120 |
}
|
|
121 |
|
|
122 |
}
|
|
123 |
|
|
124 |
void HsGui::setOrientation(Qt::Orientation orientation)
|
|
125 |
{
|
|
126 |
mImpl->mWindow->setOrientation(orientation);
|
|
127 |
}
|
|
128 |
|
|
129 |
Qt::Orientation HsGui::orientation()
|
|
130 |
{
|
|
131 |
return mImpl->mWindow->orientation();
|
|
132 |
}
|
|
133 |
|
|
134 |
HbView *HsGui::idleView() const
|
|
135 |
{
|
|
136 |
return mImpl->mIdleView;
|
|
137 |
}
|
|
138 |
|
|
139 |
HsIdleWidget *HsGui::idleWidget() const
|
|
140 |
{
|
|
141 |
return mImpl->mIdleWidget;
|
|
142 |
}
|
|
143 |
|
|
144 |
QRectF HsGui::layoutRect() const
|
|
145 |
{
|
|
146 |
return mImpl->mWindow->layoutRect();
|
|
147 |
}
|
|
148 |
|
|
149 |
void HsGui::show()
|
|
150 |
{
|
|
151 |
mImpl->mWindow->raise();
|
|
152 |
mImpl->mWindow->show();
|
|
153 |
}
|
|
154 |
|
|
155 |
HsPropertyAnimationWrapper *HsGui::pageChangeAnimation()
|
|
156 |
{
|
|
157 |
if (!mImpl->mPageChangeAnimation) {
|
|
158 |
mImpl->mPageChangeAnimation = new HsPropertyAnimationWrapper;
|
|
159 |
mImpl->mPageChangeAnimation->setTargetObject(mImpl->mIdleWidget);
|
|
160 |
mImpl->mPageChangeAnimation->setPropertyName("sceneX");
|
|
161 |
}
|
|
162 |
return mImpl->mPageChangeAnimation;
|
|
163 |
}
|
|
164 |
HsPropertyAnimationWrapper *HsGui::pageCrawlingAnimation()
|
|
165 |
{
|
|
166 |
if (!mImpl->mPageCrawlingAnimation) {
|
|
167 |
mImpl->mPageCrawlingAnimation = new HsPropertyAnimationWrapper;
|
|
168 |
mImpl->mPageCrawlingAnimation->setTargetObject(mImpl->mIdleWidget);
|
|
169 |
mImpl->mPageCrawlingAnimation->setPropertyName("sceneX");
|
|
170 |
}
|
|
171 |
return mImpl->mPageCrawlingAnimation;
|
|
172 |
}
|
|
173 |
|
|
174 |
HsGui::HsGui(QObject *parent):
|
|
175 |
QObject(parent),mImpl(new HsGuiImpl)
|
|
176 |
{
|
|
177 |
mImpl->mIdleView = 0;
|
|
178 |
mImpl->mIdleWidget = 0;
|
|
179 |
mImpl->mNavigationAction = 0;
|
|
180 |
mImpl->mPageChangeAnimation = 0;
|
|
181 |
mImpl->mPageCrawlingAnimation = 0;
|
|
182 |
|
|
183 |
mImpl->mWindow = hbInstance->allMainWindows().first();
|
|
184 |
connect(mImpl->mWindow, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
185 |
SIGNAL(orientationChanged(Qt::Orientation)));
|
|
186 |
}
|