author | hgs |
Wed, 20 Oct 2010 15:25:39 +0300 | |
changeset 101 | ba1b7e218624 |
parent 86 | e4f038c420f7 |
permissions | -rw-r--r-- |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <HbInstance> |
69 | 19 |
#include <HbMainWindow> |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <HbView> |
69 | 21 |
#include <HbMenu> |
22 |
#include <HbAction> |
|
55
03646e8da489
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
23 |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
#include "hsgui.h" |
69 | 25 |
#include "hsidlewidget.h" |
26 |
#include "hsscene.h" |
|
27 |
#include "hsconfiguration.h" |
|
28 |
#include "hspropertyanimationwrapper.h" |
|
29 |
namespace { |
|
30 |
const char gApplicationLibraryIconName[] = "qtg_mono_applications_all"; |
|
31 |
} |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
/*! |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
\class HsGui |
62 | 35 |
\ingroup group_hsdomainmodel |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
\brief Represents a view in the framework. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
HsGui includes common UI components for Home screen. |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
*/ |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
|
69 | 40 |
HsGui *HsGui::mInstance(0); |
41 |
||
42 |
struct HsGuiImpl |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
{ |
69 | 44 |
HsIdleWidget *mIdleWidget; |
45 |
HbView *mIdleView; |
|
46 |
HbMainWindow *mWindow; |
|
47 |
HbAction *mNavigationAction; |
|
48 |
HsPropertyAnimationWrapper *mPageChangeAnimation; |
|
49 |
HsPropertyAnimationWrapper *mPageCrawlingAnimation; |
|
50 |
}; |
|
51 |
||
52 |
||
53 |
||
54 |
HsGui::~HsGui() |
|
55 |
{ |
|
56 |
if (mImpl->mNavigationAction) { |
|
57 |
delete mImpl->mNavigationAction; |
|
58 |
} |
|
59 |
||
60 |
if (mImpl->mPageChangeAnimation) { |
|
61 |
mImpl->mPageChangeAnimation->stop(); |
|
62 |
delete mImpl->mPageChangeAnimation; |
|
63 |
} |
|
64 |
if (mImpl->mPageCrawlingAnimation) { |
|
65 |
mImpl->mPageCrawlingAnimation->stop(); |
|
66 |
delete mImpl->mPageCrawlingAnimation; |
|
67 |
} |
|
68 |
delete mImpl; |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
|
69 | 71 |
HsGui *HsGui::setInstance(HsGui *instance) |
72 |
{ |
|
73 |
HsGui *old = mInstance; |
|
74 |
if (mInstance != instance) { |
|
75 |
mInstance = instance; |
|
76 |
} |
|
77 |
return old; |
|
78 |
} |
|
79 |
||
80 |
HsGui *HsGui::instance() |
|
81 |
{ |
|
82 |
if (!mInstance) { |
|
83 |
mInstance = new HsGui(QCoreApplication::instance()); |
|
84 |
} |
|
85 |
return mInstance; |
|
86 |
} |
|
87 |
||
88 |
HsGui *HsGui::takeInstance() |
|
89 |
{ |
|
90 |
HsGui *instance = mInstance; |
|
91 |
mInstance = 0; |
|
92 |
return instance; |
|
93 |
} |
|
94 |
||
95 |
void HsGui::setupIdleUi() |
|
96 |
{ |
|
97 |
if (!mImpl->mIdleWidget) { |
|
98 |
mImpl->mIdleWidget = new HsIdleWidget; |
|
99 |
mImpl->mIdleView = mImpl->mWindow->addView(mImpl->mIdleWidget); |
|
100 |
mImpl->mIdleView->setContentFullScreen(); |
|
101 |
||
102 |
delete mImpl->mNavigationAction; |
|
103 |
mImpl->mNavigationAction = 0; |
|
104 |
mImpl->mNavigationAction = new HbAction; |
|
105 |
mImpl->mNavigationAction->setIcon(HbIcon(gApplicationLibraryIconName)); |
|
106 |
mImpl->mNavigationAction->setObjectName("applib_navigation_action"); |
|
107 |
connect(mImpl->mNavigationAction, SIGNAL(triggered()), SIGNAL(navigateToApplibrary())); |
|
108 |
mImpl->mIdleView->setNavigationAction(mImpl->mNavigationAction); |
|
109 |
} |
|
71 | 110 |
bool animate = !mImpl->mWindow->isObscured(); |
86 | 111 |
mImpl->mWindow->setCurrentView(mImpl->mIdleView, animate, Hb::ViewSwitchCachedFullScreen); |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
|
69 | 114 |
void HsGui::cleanupIdleUi() |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
{ |
69 | 116 |
if (mImpl->mIdleView) { |
117 |
mImpl->mIdleView->setNavigationAction(0); |
|
118 |
delete mImpl->mNavigationAction; |
|
119 |
mImpl->mNavigationAction = 0; |
|
120 |
||
121 |
mImpl->mWindow->removeView(mImpl->mIdleView); |
|
122 |
delete mImpl->mIdleView; |
|
123 |
mImpl->mIdleView = 0; |
|
124 |
||
125 |
delete mImpl->mPageChangeAnimation; |
|
126 |
mImpl->mPageChangeAnimation = 0; |
|
127 |
||
128 |
delete mImpl->mPageCrawlingAnimation; |
|
129 |
mImpl->mPageCrawlingAnimation = 0; |
|
81 | 130 |
// This gets deleted when mImpl->mIdleView is deleted |
131 |
// so just nullify. |
|
132 |
mImpl->mIdleWidget = 0; |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
} |
69 | 134 |
|
135 |
} |
|
136 |
||
137 |
void HsGui::setOrientation(Qt::Orientation orientation) |
|
138 |
{ |
|
139 |
mImpl->mWindow->setOrientation(orientation); |
|
140 |
} |
|
141 |
||
142 |
Qt::Orientation HsGui::orientation() |
|
143 |
{ |
|
144 |
return mImpl->mWindow->orientation(); |
|
145 |
} |
|
146 |
||
147 |
HbView *HsGui::idleView() const |
|
148 |
{ |
|
149 |
return mImpl->mIdleView; |
|
150 |
} |
|
151 |
||
152 |
HsIdleWidget *HsGui::idleWidget() const |
|
153 |
{ |
|
154 |
return mImpl->mIdleWidget; |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
|
69 | 157 |
QRectF HsGui::layoutRect() const |
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
{ |
69 | 159 |
return mImpl->mWindow->layoutRect(); |
160 |
} |
|
161 |
||
162 |
void HsGui::show() |
|
163 |
{ |
|
164 |
mImpl->mWindow->raise(); |
|
165 |
mImpl->mWindow->show(); |
|
51
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
} |
4785f57bf3d4
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
|
69 | 168 |
HsPropertyAnimationWrapper *HsGui::pageChangeAnimation() |
169 |
{ |
|
170 |
if (!mImpl->mPageChangeAnimation) { |
|
171 |
mImpl->mPageChangeAnimation = new HsPropertyAnimationWrapper; |
|
172 |
mImpl->mPageChangeAnimation->setTargetObject(mImpl->mIdleWidget); |
|
173 |
mImpl->mPageChangeAnimation->setPropertyName("sceneX"); |
|
174 |
} |
|
175 |
return mImpl->mPageChangeAnimation; |
|
176 |
} |
|
177 |
HsPropertyAnimationWrapper *HsGui::pageCrawlingAnimation() |
|
178 |
{ |
|
179 |
if (!mImpl->mPageCrawlingAnimation) { |
|
180 |
mImpl->mPageCrawlingAnimation = new HsPropertyAnimationWrapper; |
|
181 |
mImpl->mPageCrawlingAnimation->setTargetObject(mImpl->mIdleWidget); |
|
182 |
mImpl->mPageCrawlingAnimation->setPropertyName("sceneX"); |
|
183 |
} |
|
184 |
return mImpl->mPageCrawlingAnimation; |
|
185 |
} |
|
186 |
||
187 |
HsGui::HsGui(QObject *parent): |
|
188 |
QObject(parent),mImpl(new HsGuiImpl) |
|
189 |
{ |
|
190 |
mImpl->mIdleView = 0; |
|
191 |
mImpl->mIdleWidget = 0; |
|
192 |
mImpl->mNavigationAction = 0; |
|
193 |
mImpl->mPageChangeAnimation = 0; |
|
194 |
mImpl->mPageCrawlingAnimation = 0; |
|
195 |
||
196 |
mImpl->mWindow = hbInstance->allMainWindows().first(); |
|
197 |
connect(mImpl->mWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
198 |
SIGNAL(orientationChanged(Qt::Orientation))); |
|
101 | 199 |
connect(mImpl->mWindow, SIGNAL(aboutToChangeOrientation()), |
200 |
SIGNAL(aboutToChangeOrientation())); |
|
69 | 201 |
} |