62
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 "hswallpaperselectionstate.h"
|
|
19 |
#include "hsspinnerdialog.h"
|
|
20 |
#include "hsscene.h"
|
|
21 |
#include "hspage.h"
|
|
22 |
#include "hswallpaper.h"
|
|
23 |
#include "hsconfiguration.h"
|
|
24 |
|
|
25 |
#ifdef Q_OS_SYMBIAN
|
90
|
26 |
#include "hsimagehandlingclient.h"
|
62
|
27 |
#else
|
|
28 |
#include "xqaiwgetimageclient.h"
|
|
29 |
#endif
|
|
30 |
|
|
31 |
// Helper macros for connecting state entry and exit actions.
|
|
32 |
#define ENTRY_ACTION(state, action) \
|
|
33 |
connect(state, SIGNAL(entered()), SLOT(action()));
|
|
34 |
#define EXIT_ACTION(state, action) \
|
|
35 |
connect(state, SIGNAL(exited()), SLOT(action()));
|
|
36 |
|
|
37 |
/*!
|
|
38 |
\class HsWallpaperSelectionState
|
|
39 |
\ingroup group_hshomescreenstateplugin
|
|
40 |
\brief
|
|
41 |
*/
|
|
42 |
|
|
43 |
/*!
|
|
44 |
|
|
45 |
*/
|
|
46 |
HsWallpaperSelectionState::HsWallpaperSelectionState(QState *parent)
|
|
47 |
: QState(parent),
|
90
|
48 |
mImageHandler(0),
|
62
|
49 |
mWallpaper(0),
|
|
50 |
mWaitDialog(0)
|
|
51 |
{
|
|
52 |
setupStates();
|
|
53 |
}
|
|
54 |
|
|
55 |
/*!
|
|
56 |
|
|
57 |
*/
|
|
58 |
HsWallpaperSelectionState::~HsWallpaperSelectionState()
|
|
59 |
{
|
|
60 |
|
|
61 |
}
|
|
62 |
|
|
63 |
/*!
|
|
64 |
|
|
65 |
*/
|
|
66 |
void HsWallpaperSelectionState::setupStates()
|
|
67 |
{
|
|
68 |
// States
|
|
69 |
|
|
70 |
QState *state_processing = new QState(this);
|
|
71 |
QState *state_selectingImage = new QState(state_processing);
|
90
|
72 |
QState *state_editingImage = new QState(state_processing);
|
62
|
73 |
QState *state_assigningImage = new QState(state_processing);
|
|
74 |
QState *state_errorMessage = new QState(this);
|
|
75 |
|
|
76 |
setInitialState(state_processing);
|
|
77 |
state_processing->setInitialState(state_selectingImage);
|
|
78 |
|
|
79 |
// Transitions
|
90
|
80 |
#if defined (Q_OS_SYMBIAN) && !defined (__WINSCW__)
|
|
81 |
state_selectingImage->addTransition(
|
|
82 |
this, SIGNAL(event_assignImage()), state_editingImage);
|
|
83 |
#else
|
62
|
84 |
state_selectingImage->addTransition(
|
|
85 |
this, SIGNAL(event_assignImage()), state_assigningImage);
|
90
|
86 |
#endif // Q_OS_SYMBIAN
|
62
|
87 |
|
|
88 |
state_processing->addTransition(
|
|
89 |
this, SIGNAL(event_error()), state_errorMessage);
|
|
90 |
|
|
91 |
// Actions
|
|
92 |
|
|
93 |
ENTRY_ACTION(state_selectingImage, action_selectingImage_start)
|
90
|
94 |
EXIT_ACTION(state_selectingImage, action_imageHandler_cleanup)
|
|
95 |
|
|
96 |
ENTRY_ACTION(state_editingImage, action_editingImage_start)
|
|
97 |
EXIT_ACTION(state_editingImage, action_imageHandler_cleanup)
|
62
|
98 |
|
|
99 |
ENTRY_ACTION(state_assigningImage, action_assigningImage_showWaitDialog)
|
|
100 |
ENTRY_ACTION(state_assigningImage, action_assigningImage_start)
|
|
101 |
EXIT_ACTION(state_assigningImage, action_assigningImage_cleanup)
|
|
102 |
EXIT_ACTION(state_assigningImage, action_assigningImage_hideWaitDialog)
|
|
103 |
|
|
104 |
ENTRY_ACTION(state_errorMessage, action_errorMessage_show)
|
|
105 |
}
|
|
106 |
|
|
107 |
/*!
|
|
108 |
|
|
109 |
*/
|
|
110 |
void HsWallpaperSelectionState::action_selectingImage_start()
|
|
111 |
{
|
|
112 |
#ifdef Q_OS_SYMBIAN
|
90
|
113 |
mImageHandler = new HsImageHandlingClient;
|
62
|
114 |
#else
|
90
|
115 |
mImageHandler = new XQAIWGetImageClient;
|
62
|
116 |
#endif
|
|
117 |
|
90
|
118 |
connect(mImageHandler, SIGNAL(fetchCompleted(const QString&)),
|
62
|
119 |
this, SLOT(onFetchCompleted(const QString&)));
|
90
|
120 |
connect(mImageHandler, SIGNAL(fetchFailed(int, const QString&)),
|
62
|
121 |
this, SLOT(onFetchFailed(int, const QString&)));
|
|
122 |
|
90
|
123 |
mImageHandler->fetch();
|
62
|
124 |
}
|
|
125 |
|
|
126 |
/*!
|
|
127 |
|
|
128 |
*/
|
90
|
129 |
void HsWallpaperSelectionState::action_imageHandler_cleanup()
|
62
|
130 |
{
|
90
|
131 |
mImageHandler->disconnect(this);
|
|
132 |
mImageHandler->deleteLater();
|
|
133 |
mImageHandler = 0;
|
62
|
134 |
}
|
|
135 |
|
|
136 |
/*!
|
|
137 |
|
|
138 |
*/
|
|
139 |
void HsWallpaperSelectionState::action_assigningImage_showWaitDialog()
|
|
140 |
{
|
|
141 |
mWaitDialog = new HsSpinnerDialog;
|
|
142 |
mWaitDialog->start();
|
|
143 |
}
|
|
144 |
|
|
145 |
/*!
|
|
146 |
|
|
147 |
*/
|
|
148 |
void HsWallpaperSelectionState::action_assigningImage_start()
|
|
149 |
{
|
|
150 |
HsScene *scene = HsScene::instance();
|
|
151 |
|
|
152 |
if (HSCONFIGURATION_GET(sceneType) == HsConfiguration::SceneWallpaper) {
|
|
153 |
mWallpaper = scene->wallpaper();
|
|
154 |
} else {
|
|
155 |
mWallpaper = scene->activePage()->wallpaper();
|
|
156 |
}
|
|
157 |
|
|
158 |
connect(mWallpaper, SIGNAL(imageSet()), SLOT(onImageSet()));
|
|
159 |
connect(mWallpaper, SIGNAL(imageSetFailed()), SLOT(onImageSetFailed()));
|
|
160 |
|
|
161 |
mWallpaper->setImage(mImagePath);
|
|
162 |
}
|
|
163 |
|
|
164 |
/*!
|
|
165 |
|
|
166 |
*/
|
|
167 |
void HsWallpaperSelectionState::action_assigningImage_cleanup()
|
|
168 |
{
|
|
169 |
mWallpaper->disconnect(this);
|
|
170 |
mWallpaper = 0;
|
|
171 |
}
|
|
172 |
|
|
173 |
/*!
|
|
174 |
|
|
175 |
*/
|
|
176 |
void HsWallpaperSelectionState::action_assigningImage_hideWaitDialog()
|
|
177 |
{
|
|
178 |
mWaitDialog->stop();
|
|
179 |
mWaitDialog = 0;
|
|
180 |
}
|
|
181 |
|
|
182 |
/*!
|
|
183 |
|
|
184 |
*/
|
|
185 |
void HsWallpaperSelectionState::action_errorMessage_show()
|
|
186 |
{
|
|
187 |
// TODO: Waiting for UX decision.
|
|
188 |
emit event_waitInput();
|
|
189 |
}
|
|
190 |
|
90
|
191 |
#ifdef COVERAGE_MEASUREMENT
|
|
192 |
#pragma CTC SKIP
|
|
193 |
#endif //COVERAGE_MEASUREMENT
|
|
194 |
/*!
|
|
195 |
|
|
196 |
*/
|
|
197 |
void HsWallpaperSelectionState::action_editingImage_start()
|
|
198 |
{
|
|
199 |
#ifdef Q_OS_SYMBIAN
|
|
200 |
mImageHandler = new HsImageHandlingClient;
|
|
201 |
|
|
202 |
connect(mImageHandler, SIGNAL(editorCompleted()),
|
|
203 |
this, SLOT(onEditorCompleted()));
|
|
204 |
connect(mImageHandler, SIGNAL(editorFailed(int, const QString&)),
|
|
205 |
this, SLOT(onFetchFailed(int, const QString&)));
|
|
206 |
|
|
207 |
mImageHandler->edit(mImagePath);
|
|
208 |
#endif //Q_OS_SYMBIAN
|
|
209 |
}
|
|
210 |
#ifdef COVERAGE_MEASUREMENT
|
|
211 |
#pragma CTC ENDSKIP
|
|
212 |
#endif //COVERAGE_MEASUREMENT
|
|
213 |
|
62
|
214 |
/*!
|
|
215 |
|
|
216 |
*/
|
|
217 |
void HsWallpaperSelectionState::onFetchCompleted(const QString &imagePath)
|
|
218 |
{
|
|
219 |
mImagePath = imagePath;
|
|
220 |
emit event_assignImage();
|
|
221 |
}
|
|
222 |
|
|
223 |
/*!
|
|
224 |
|
|
225 |
*/
|
|
226 |
void HsWallpaperSelectionState::onFetchFailed(int errorCode, const QString &errorMessage)
|
|
227 |
{
|
|
228 |
Q_UNUSED(errorCode)
|
|
229 |
Q_UNUSED(errorMessage)
|
|
230 |
emit event_error();
|
|
231 |
}
|
|
232 |
|
|
233 |
/*!
|
|
234 |
|
|
235 |
*/
|
|
236 |
void HsWallpaperSelectionState::onImageSet()
|
|
237 |
{
|
|
238 |
emit event_waitInput();
|
|
239 |
}
|
|
240 |
|
|
241 |
/*!
|
|
242 |
|
|
243 |
*/
|
|
244 |
void HsWallpaperSelectionState::onImageSetFailed()
|
|
245 |
{
|
|
246 |
emit event_error();
|
|
247 |
}
|
90
|
248 |
|
|
249 |
#ifdef COVERAGE_MEASUREMENT
|
|
250 |
#pragma CTC SKIP
|
|
251 |
#endif //COVERAGE_MEASUREMENT
|
|
252 |
/*!
|
|
253 |
|
|
254 |
*/
|
|
255 |
void HsWallpaperSelectionState::onEditorCompleted()
|
|
256 |
{
|
|
257 |
emit event_waitInput();
|
|
258 |
}
|
|
259 |
#ifdef COVERAGE_MEASUREMENT
|
|
260 |
#pragma CTC ENDSKIP
|
|
261 |
#endif //COVERAGE_MEASUREMENT
|