1 /* |
1 /* |
2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "nmuiheaders.h" |
18 #include "nmuiheaders.h" |
19 #include <email_services_api.h> |
19 #include <email_services_api.h> |
20 #include <e32base.h> |
20 #include <e32base.h> |
21 |
21 |
22 static const QString NmSendServiceName = "nmail.com.nokia.symbian.IFileShare"; |
22 static const QString NmSendServiceName = "nmail.com.nokia.symbian.IFileShare"; |
23 |
23 |
24 /*! |
24 /*! |
25 \class NmApplication |
25 \class NmApplication |
26 \brief Application class, creates main window and handles view switching |
26 \brief Application class, creates main window and handles view switching. |
27 */ |
27 */ |
28 |
28 |
29 /*! |
29 /*! |
30 Constructor |
30 Constructor. |
31 */ |
31 */ |
32 NmApplication::NmApplication(QObject *parent, quint32 accountId) |
32 NmApplication::NmApplication(QObject *parent, quint32 accountId) |
33 :QObject(parent), |
33 : QObject(parent), |
34 mMainWindow(NULL), |
34 mMainWindow(NULL), |
35 mViewStack(NULL), |
35 mViewStack(NULL), |
36 mActiveViewId(NmUiViewNone), |
36 mActiveViewId(NmUiViewNone), |
37 mUiEngine(NULL), |
37 mUiEngine(NULL), |
38 mBackAction(NULL), |
38 mBackAction(NULL), |
39 mExtensionManager(NULL), |
39 mExtensionManager(NULL), |
40 mMbListModel(NULL), |
40 mMbListModel(NULL), |
41 mServiceViewId(NmUiViewNone), |
41 mServiceViewId(NmUiViewNone), |
42 mForegroundService(false), |
42 mForegroundService(false), |
43 mEffects(NULL), |
43 mEffects(NULL), |
44 mAttaManager(NULL), |
44 mAttaManager(NULL), |
45 mSettingsViewLauncher(NULL), |
45 mSettingsViewLauncher(NULL), |
46 mViewReady(false), |
46 mViewReady(false), |
47 mQueryDialog(NULL), |
47 mQueryDialog(NULL), |
48 mBackButtonPressed(false) |
48 mBackButtonPressed(false) |
49 { |
49 { |
50 NM_FUNCTION; |
|
51 |
|
52 TRAP_IGNORE(mUiEngine = NmUiEngine::instance()); |
50 TRAP_IGNORE(mUiEngine = NmUiEngine::instance()); |
53 |
51 |
54 // Create network access manager and cache for application use. |
52 // Create network access manager and cache for application use. |
55 mNetManager = new NmViewerViewNetManager(*mUiEngine); |
53 mNetManager = new NmViewerViewNetManager(*mUiEngine); |
56 QNetworkDiskCache *cache = new QNetworkDiskCache(); |
54 QNetworkDiskCache *cache = new QNetworkDiskCache(); |
57 cache->setCacheDirectory(QDesktopServices::storageLocation(QDesktopServices::CacheLocation)); |
55 cache->setCacheDirectory( |
|
56 QDesktopServices::storageLocation(QDesktopServices::CacheLocation)); |
58 mNetManager->setCache(cache); |
57 mNetManager->setCache(cache); |
59 |
58 |
60 createMainWindow(); |
59 createMainWindow(); |
61 |
60 |
62 // attachment manager can be shared between viewer and editor, ownership in application class |
61 // Attachment manager can be shared between viewer and editor. |
|
62 // The application class has the ownership. |
63 mAttaManager = new NmAttachmentManager(*mUiEngine); |
63 mAttaManager = new NmAttachmentManager(*mUiEngine); |
64 |
64 |
65 mSendServiceInterface = |
65 mSendServiceInterface = |
66 new NmSendServiceInterface(NmSendServiceName, NULL, *mUiEngine, this); |
66 new NmSendServiceInterface(NmSendServiceName, NULL, *mUiEngine, this); |
67 mSendServiceInterface2 = |
67 mSendServiceInterface2 = |
68 new NmSendServiceInterface(emailFullServiceNameSend, NULL, *mUiEngine, this); |
68 new NmSendServiceInterface(emailFullServiceNameSend, NULL, *mUiEngine, this); |
69 mUriServiceInterface = |
69 mUriServiceInterface = |
70 new NmUriServiceInterface(NULL, *mUiEngine, this); |
70 new NmUriServiceInterface(NULL, *mUiEngine, this); |
71 mMailboxServiceInterface = |
71 mMailboxServiceInterface = |
72 new NmMailboxServiceInterface(NULL, *mUiEngine, this); |
72 new NmMailboxServiceInterface(NULL, *mUiEngine, this); |
73 mViewerServiceInterface = |
73 mViewerServiceInterface = |
74 new NmViewerServiceInterface(NULL, this, *mUiEngine); |
74 new NmViewerServiceInterface(NULL, this, *mUiEngine); |
75 |
75 |
76 if(accountId != 0) { |
76 if(accountId != 0) { |
77 QVariant mailbox; |
77 QVariant mailbox; |
78 mailbox.setValue(mUiEngine->getPluginIdByMailboxId(accountId).id()); |
78 mailbox.setValue(mUiEngine->getPluginIdByMailboxId(accountId).id()); |
79 mMailboxServiceInterface->displayInboxByMailboxId(mailbox); |
79 mMailboxServiceInterface->displayInboxByMailboxId(mailbox); |
80 } |
80 } |
81 |
81 |
82 mEffects = new NmUiEffects(*mMainWindow); |
82 mEffects = new NmUiEffects(*mMainWindow); |
83 } |
83 } |
84 |
84 |
85 /*! |
85 /*! |
86 Destructor |
86 Destructor. |
87 */ |
87 */ |
88 NmApplication::~NmApplication() |
88 NmApplication::~NmApplication() |
89 { |
89 { |
90 NM_FUNCTION; |
|
91 |
|
92 if (mQueryDialog) { |
90 if (mQueryDialog) { |
93 delete mQueryDialog; |
91 delete mQueryDialog; |
94 mQueryDialog=NULL; |
92 mQueryDialog = NULL; |
95 } |
93 } |
96 |
94 |
97 delete mSendServiceInterface; |
95 delete mSendServiceInterface; |
98 delete mSendServiceInterface2; |
96 delete mSendServiceInterface2; |
99 delete mUriServiceInterface; |
97 delete mUriServiceInterface; |
100 delete mMailboxServiceInterface; |
98 delete mMailboxServiceInterface; |
101 delete mViewerServiceInterface; |
99 delete mViewerServiceInterface; |
102 |
100 |
103 resetViewStack(); |
101 resetViewStack(); |
104 delete mViewStack; |
102 delete mViewStack; |
|
103 |
105 NmIcons::freeIcons(); |
104 NmIcons::freeIcons(); |
106 NmUiEngine::releaseInstance(mUiEngine); |
105 NmUiEngine::releaseInstance(mUiEngine); |
107 mUiEngine = NULL; |
106 mUiEngine = NULL; |
|
107 |
108 delete mBackAction; |
108 delete mBackAction; |
|
109 |
|
110 // Workaround: the main window has to be closed (hidden) before deleting |
|
111 // the extension manager in order to prevent the main window's title bar |
|
112 // from showing when the application is closed. |
|
113 if (mMainWindow) { |
|
114 // Workaround: assert failure may happen if an open main window is |
|
115 // deleted. |
|
116 mMainWindow->close(); |
|
117 } |
|
118 |
109 delete mExtensionManager; |
119 delete mExtensionManager; |
|
120 |
110 if (mNetManager) { |
121 if (mNetManager) { |
111 if (mNetManager->cache()) { |
122 if (mNetManager->cache()) { |
112 mNetManager->cache()->clear(); |
123 mNetManager->cache()->clear(); |
113 } |
124 } |
114 delete mNetManager; |
125 delete mNetManager; |
115 mNetManager = NULL; |
126 mNetManager = NULL; |
116 } |
127 } |
117 // Effects needs to be deleted before MainWindow. |
128 |
|
129 // Effects need to be deleted before MainWindow. |
118 delete mEffects; |
130 delete mEffects; |
119 if (mMainWindow) { |
|
120 // workaround: assert failure may happen otherwise |
|
121 mMainWindow->close(); |
|
122 } |
|
123 delete mMainWindow; |
131 delete mMainWindow; |
124 delete mAttaManager; |
132 delete mAttaManager; |
125 delete mSettingsViewLauncher; |
133 delete mSettingsViewLauncher; |
126 } |
134 } |
127 |
135 |
128 /*! |
136 /*! |
129 Main application window creation |
137 Main application window creation. |
130 */ |
138 */ |
131 void NmApplication::createMainWindow() |
139 void NmApplication::createMainWindow() |
132 { |
140 { |
133 NM_FUNCTION; |
141 NM_FUNCTION; |
134 |
142 |
135 bool service = XQServiceUtil::isService(); |
143 bool service = XQServiceUtil::isService(); |
136 |
144 |
137 // Register custom widget files |
145 // Register custom widget files. |
138 HbStyleLoader::registerFilePath(":nmmessagelistviewitem.widgetml"); |
146 HbStyleLoader::registerFilePath(":nmmessagelistviewitem.widgetml"); |
139 HbStyleLoader::registerFilePath(":nmmessagelistviewitem.css"); |
147 HbStyleLoader::registerFilePath(":nmmessagelistviewitem.css"); |
140 HbStyleLoader::registerFilePath(":nmviewerheader.widgetml"); |
148 HbStyleLoader::registerFilePath(":nmviewerheader.widgetml"); |
141 HbStyleLoader::registerFilePath(":nmviewerheader.css"); |
149 HbStyleLoader::registerFilePath(":nmviewerheader.css"); |
142 |
150 |
143 // Create main window |
151 // Create main window. |
144 mMainWindow = new HbMainWindow(); |
152 mMainWindow = new HbMainWindow(); |
145 |
153 |
146 // Connect to lazy loading signal |
154 // Connect to lazy loading signal. |
147 QObject::connect(mMainWindow, SIGNAL(viewReady ()), |
155 QObject::connect(mMainWindow, SIGNAL(viewReady ()), |
148 this, SLOT(viewReady())); |
156 this, SLOT(viewReady())); |
149 |
157 |
150 // Create extension manager |
158 // Create extension manager. |
151 mExtensionManager = new NmUiExtensionManager(); |
159 mExtensionManager = new NmUiExtensionManager(); |
152 |
160 |
153 // Create view stack |
161 // Create view stack. |
154 mViewStack = new QStack<NmBaseView*>; |
162 mViewStack = new QStack<NmBaseView*>; |
155 |
163 |
156 // Create back action and connect it to prepareForPopView() |
164 // Create back action and connect it to prepareForPopView(). |
157 if (mMainWindow) { |
165 if (mMainWindow) { |
158 mBackAction = new HbAction(Hb::BackNaviAction,this); |
166 mBackAction = new HbAction(Hb::BackNaviAction,this); |
159 connect(mBackAction, SIGNAL(triggered()), this, SLOT(prepareForPopView())); |
167 connect(mBackAction, |
160 |
168 SIGNAL(triggered()), |
161 // Show mainwindow |
169 this, |
162 // Services will active it when the view is ready |
170 SLOT(prepareForPopView())); |
|
171 |
|
172 // Show mainwindow. |
|
173 // Services will active it when the view is ready. |
163 if (!service) { |
174 if (!service) { |
164 mMainWindow->show(); |
175 mMainWindow->show(); |
165 } |
176 } |
166 } |
177 } |
167 |
178 |
168 // async operation completion related notifications |
179 // Asynchronous operation completion related notifications. |
169 connect( |
180 connect(mUiEngine, |
170 mUiEngine, SIGNAL(operationCompleted(const NmOperationCompletionEvent &)), |
181 SIGNAL(operationCompleted(const NmOperationCompletionEvent &)), |
171 this, SLOT(handleOperationCompleted(const NmOperationCompletionEvent &))); |
182 this, |
172 |
183 SLOT(handleOperationCompleted(const NmOperationCompletionEvent &))); |
|
184 |
173 mMbListModel = &mUiEngine->mailboxListModel(); |
185 mMbListModel = &mUiEngine->mailboxListModel(); |
174 |
186 |
175 // Start application to mailbox view |
187 // ---------------------------------------------------------------------- |
176 // If started as service, there is no need to create views |
188 // TODO: Remove or comment out the following code block when the mail |
|
189 // wizard starts to work with Mfe. |
|
190 // ---------------------------------------------------------------------- |
|
191 // Start application to mailbox view. If started as service, there is no |
|
192 // need to create views. |
177 if (!service) { |
193 if (!service) { |
178 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMailboxList); |
194 NmUiStartParam *startParam = new NmUiStartParam(NmUiViewMailboxList); |
179 enterNmUiView(startParam); |
195 enterNmUiView(startParam); |
180 } |
196 } |
181 |
197 // ---------------------------------------------------------------------- |
|
198 |
182 if (mMainWindow) { |
199 if (mMainWindow) { |
183 // Start to filter main window events to get "end key" event in all possible situations. Using |
200 // Start to filter main window events to get "end key" event in all |
184 // event() is not enough to catch the event as it is only called if the view widget has the |
201 // possible situations. Using event()is not enough to catch the event |
185 // focus. Note: if key capturing (xqkeycapture.h) is required it is probably best to implement |
202 // as it is only called if the view widget has the focus. Note: if |
186 // an own QMainWindow class and do the capturing there, not in the views. |
203 // key capturing (xqkeycapture.h) is required it is probably best to |
|
204 // implement an own QMainWindow class and do the capturing there, not |
|
205 // in the views. |
187 mMainWindow->installEventFilter(this); |
206 mMainWindow->installEventFilter(this); |
188 |
207 // Optimize the custom paint functions. |
189 // Optimize the custom paint functions. |
208 // Currently effects to NmViewerHeader::paint() and |
190 // Currently effects to NmViewerHeader::paint & NmAttachmentListWidget::paint |
209 // NmAttachmentListWidget::paint(). |
191 mMainWindow->setOptimizationFlag(QGraphicsView::DontSavePainterState); |
210 mMainWindow->setOptimizationFlag(QGraphicsView::DontSavePainterState); |
192 } |
211 } |
193 } |
212 } |
194 |
213 |
195 /*! |
214 /*! |
196 Slot. React to view ready signal and call |
215 Slot. React to view ready signal and call current view method. |
197 current view method. |
|
198 */ |
216 */ |
199 void NmApplication::viewReady() |
217 void NmApplication::viewReady() |
200 { |
218 { |
201 NM_FUNCTION; |
|
202 |
|
203 mViewReady = true; |
219 mViewReady = true; |
204 if (mViewStack && !mViewStack->isEmpty()) { |
220 if (mViewStack && !mViewStack->isEmpty()) { |
205 NmBaseView *currentView = mViewStack->top(); |
221 NmBaseView *currentView = mViewStack->top(); |
206 if (currentView) { |
222 if (currentView) { |
207 currentView->viewReady(); |
223 currentView->viewReady(); |
208 } |
224 } |
209 } |
225 } |
210 } |
226 } |
211 |
227 |
212 /*! |
228 /*! |
213 Event filter. End key is filtered from the main window and either the view takes case of the |
229 Event filter. End key is filtered from the main window and either the |
214 or the app is exited by default. |
230 view takes case of the or the app is exited by default. |
215 */ |
231 */ |
216 bool NmApplication::eventFilter(QObject *obj, QEvent *event) |
232 bool NmApplication::eventFilter(QObject *obj, QEvent *event) |
217 { |
233 { |
218 NM_FUNCTION; |
|
219 |
|
220 bool consumed(false); |
234 bool consumed(false); |
221 |
235 |
222 if (obj && obj == mMainWindow && event && event->type() == QEvent::KeyPress) { |
236 if (obj && obj == mMainWindow && event && event->type() == QEvent::KeyPress) { |
223 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); |
237 QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); |
224 |
238 if (keyEvent->key() == Qt::Key_No) { |
225 if (keyEvent->key() == Qt::Key_No) { // end key, the "red" key |
239 // End key, the "red" key. |
226 |
240 // Exit application if no pending operations are on-going. |
227 // exit application if no pending operations are on-going |
241 } |
228 } |
242 } |
229 } |
243 |
230 |
|
231 if (!consumed) { |
244 if (!consumed) { |
232 consumed = QObject::eventFilter(obj, event); |
245 consumed = QObject::eventFilter(obj, event); |
233 } |
246 } |
234 |
247 |
235 return consumed; |
248 return consumed; |
236 } |
249 } |
237 |
250 |
238 /*! |
251 /*! |
239 Push view to view stack |
252 Push view to view stack. |
240 */ |
253 */ |
241 void NmApplication::pushView(NmBaseView *newView) |
254 void NmApplication::pushView(NmBaseView *newView) |
242 { |
255 { |
243 NM_FUNCTION; |
|
244 |
|
245 if (newView && mViewStack) { |
256 if (newView && mViewStack) { |
246 NM_COMMENT("nmailui: view exists"); |
257 NM_COMMENT("NmApplication::pushView() : view exists."); |
247 newView->setNavigationAction(mBackAction); |
258 newView->setNavigationAction(mBackAction); |
248 |
259 |
249 // Store view to be hidden |
260 // Store view to be hidden. |
250 NmBaseView *hideView(NULL); |
261 NmBaseView *hideView(NULL); |
251 if (!mViewStack->isEmpty()) { |
262 if (!mViewStack->isEmpty()) { |
252 hideView = mViewStack->top(); |
263 hideView = mViewStack->top(); |
253 } |
264 } |
254 else { |
265 else { |
255 // viewReady should be informed immediatelly |
266 // viewReady should be informed immediately. |
256 if (mViewReady) { |
267 if (mViewReady) { |
257 newView->viewReady(); |
268 newView->viewReady(); |
258 } |
269 } |
259 } |
270 } |
260 |
271 |
261 // activate new view |
272 // Activate new view. |
262 NM_COMMENT("nmailui: addView"); |
273 NM_COMMENT("NmApplication::pushView() : add view."); |
263 mMainWindow->addView(newView); |
274 mMainWindow->addView(newView); |
264 mViewStack->push(newView); |
275 mViewStack->push(newView); |
265 mMainWindow->setCurrentView(newView); |
276 mMainWindow->setCurrentView(newView); |
266 mActiveViewId=newView->nmailViewId(); |
277 mActiveViewId=newView->nmailViewId(); |
267 |
278 |
268 // Set toolbars orientation |
279 // Set toolbars orientation. |
269 HbToolBar *tb = newView->toolBar(); |
280 HbToolBar *tb = newView->toolBar(); |
270 if (tb) { |
281 if (tb) { |
271 tb->setOrientation(Qt::Horizontal); |
282 tb->setOrientation(Qt::Horizontal); |
272 } |
283 } |
273 |
284 |
274 // hide old view |
285 // Hide old view. |
275 NM_COMMENT("nmailui: removeView"); |
286 NM_COMMENT("NmApplication::pushView() : remove view."); |
276 if (hideView) { |
287 if (hideView) { |
277 mMainWindow->removeView(hideView); |
288 mMainWindow->removeView(hideView); |
278 } |
289 } |
279 |
290 } |
280 NM_COMMENT("nmailui: pushView done"); |
291 } |
281 } |
292 |
282 } |
293 /*! |
283 |
294 Ask from view that is it ok to pop view. This kind of 2-phase popView is |
284 /*! |
295 needed because view may show query dialog for user response. |
285 Ask from view that is it ok to pop view. This kind of 2-phase popView is needed |
|
286 because view may show query dialog for user response. |
|
287 */ |
296 */ |
288 void NmApplication::prepareForPopView() |
297 void NmApplication::prepareForPopView() |
289 { |
298 { |
290 if (mViewStack && mViewStack->size() > 0) { |
299 if (mViewStack && mViewStack->size() > 0) { |
291 // Get view pointer |
300 // Get view pointer. |
292 NmBaseView *view = mViewStack->top(); |
301 NmBaseView *view = mViewStack->top(); |
293 if (view){ |
302 if (view){ |
294 NmUiViewId topViewId = view->nmailViewId(); |
303 NmUiViewId topViewId = view->nmailViewId(); |
295 |
304 |
296 // We must know in popView, are we coming with back button from message view |
305 // We must know in popView, are we coming with back button from |
297 // to prevent the send animation. |
306 // message view to prevent the send animation. |
298 if (topViewId == NmUiViewMessageEditor) { |
307 if (topViewId == NmUiViewMessageEditor) { |
299 mBackButtonPressed = true; |
308 mBackButtonPressed = true; |
300 } |
309 } |
301 |
310 |
302 // View will call/signal popView if exitting is ok. |
311 // View will call/signal popView if exitting is ok. |
303 view->okToExitView(); |
312 view->okToExitView(); |
304 } |
313 } |
305 } |
314 } |
306 // If the view stack is now empty quit the app |
315 // If the view stack is now empty quit the app. This happens also when |
307 // This happens also when the app has been started as a service |
316 // the app has been started as a service |
308 else if (mViewStack && mViewStack->size() == 0) { |
317 else if (mViewStack && mViewStack->size() == 0) { |
309 exitApplication(); |
318 exitApplication(); |
310 } |
319 } |
311 } |
320 } |
312 |
321 |
313 /*! |
322 /*! |
314 Pop view from view stack. View object is deleted. |
323 Pop view from view stack. View object is deleted. |
315 */ |
324 */ |
316 void NmApplication::popView() |
325 void NmApplication::popView() |
317 { |
326 { |
318 NM_FUNCTION; |
|
319 if (mViewStack && mViewStack->size() > 0) { |
327 if (mViewStack && mViewStack->size() > 0) { |
320 NmBaseView *view = mViewStack->top(); |
328 NmBaseView *view = mViewStack->top(); |
321 if (view) { |
329 if (view) { |
322 // Get top view id |
330 // Get top view id. |
323 NmUiViewId topViewId = view->nmailViewId(); |
331 NmUiViewId topViewId = view->nmailViewId(); |
324 |
332 |
325 // Prepare for send animation if returing from editor and message has been sent. |
333 // Prepare for send animation if returing from editor and message |
|
334 // has been sent. |
326 if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) { |
335 if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) { |
327 // If we are coming from message editor with back button |
336 // If we are coming from message editor with back button. |
328 // do not prepare the send animation. |
337 // do not prepare the send animation. |
329 if (!mBackButtonPressed) { |
338 if (!mBackButtonPressed) { |
330 mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation); |
339 mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation); |
331 } |
340 } |
332 } |
341 } |
333 mBackButtonPressed = false; |
342 mBackButtonPressed = false; |
334 mViewStack->pop(); |
343 mViewStack->pop(); |
335 // Call custom exit function |
344 // Call custom exit function. |
336 view->aboutToExitView(); |
345 view->aboutToExitView(); |
337 // Remove view from stack. |
346 // Remove view from stack. |
338 mMainWindow->removeView(view); |
347 mMainWindow->removeView(view); |
339 |
348 |
340 // if we were in editor and sent a message, pop viewer from stack first |
349 // If we were in editor and sent a message, pop viewer from stack |
341 // so we can go straight to mail list |
350 // first so we can go straight to mail list. |
342 if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor && |
351 if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor && |
343 mUiEngine->isSendingMessage() && |
352 mUiEngine->isSendingMessage() && |
344 mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) { |
353 mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) { |
345 NmBaseView *tmpView = mViewStack->pop(); |
354 NmBaseView *tmpView = mViewStack->pop(); |
346 mMainWindow->removeView(tmpView); |
355 mMainWindow->removeView(tmpView); |
347 delete tmpView; |
356 delete tmpView; |
348 tmpView = NULL; |
357 tmpView = NULL; |
349 } |
358 } |
350 |
359 |
351 if (!mViewStack->isEmpty()) { |
360 if (!mViewStack->isEmpty()) { |
352 // Activate next view in stack |
361 // Activate next view in stack. |
353 NmBaseView *showView = mViewStack->top(); |
362 NmBaseView *showView = mViewStack->top(); |
354 mMainWindow->addView(showView); |
363 mMainWindow->addView(showView); |
355 mMainWindow->setCurrentView(showView); |
364 mMainWindow->setCurrentView(showView); |
356 // Store activated view id |
365 // Store activated view id. |
357 mActiveViewId=showView->nmailViewId(); |
366 mActiveViewId=showView->nmailViewId(); |
358 // Perform send animation if requested. |
367 // Perform send animation if requested. |
359 mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation); |
368 mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation); |
360 } |
369 } |
361 |
370 |
362 delete view; |
371 delete view; |
363 view = NULL; |
372 view = NULL; |
364 |
373 |
365 // If view was started as service, move the app now |
374 // If view was started as service, move the app now to the |
366 // to the background, unless it was started when the app |
375 // background, unless it was started when the app was already in |
367 // was already in foreground.. |
376 // foreground. |
368 if (mServiceViewId == topViewId) { |
377 if (mServiceViewId == topViewId) { |
369 mServiceViewId = NmUiViewNone; |
378 mServiceViewId = NmUiViewNone; |
370 NM_COMMENT("Returned from service view"); |
379 NM_COMMENT("NmApplication::popView() : returned from service view."); |
371 |
380 // If started as embedded or while the app was in foreground, |
372 // if started as embedded or while the app was in foreground, |
381 // do not hide the app. |
373 // do not hide the app |
|
374 if (!XQServiceUtil::isEmbedded() && |
382 if (!XQServiceUtil::isEmbedded() && |
375 !mForegroundService) { |
383 !mForegroundService) { |
376 XQServiceUtil::toBackground(true); |
384 XQServiceUtil::toBackground(true); |
377 } |
385 } |
378 } |
386 } |
379 } |
387 } |
380 } |
388 } |
381 |
389 |
382 // If the view stack is now empty quit the app |
390 // If the view stack is now empty quit the app. This happens also when |
383 // This happens also when the app has been started as a service |
391 // the app has been started as a service. |
384 if (mViewStack && mViewStack->size() == 0) { |
392 if (mViewStack && mViewStack->size() == 0) { |
385 exitApplication(); |
393 exitApplication(); |
386 } |
394 } |
387 } |
395 } |
388 |
396 |
389 /*! |
397 /*! |
390 Reset view stack. Remove and destroy view objects. |
398 Reset view stack. Remove and destroy view objects. |
391 */ |
399 */ |
392 void NmApplication::resetViewStack() |
400 void NmApplication::resetViewStack() |
393 { |
401 { |
394 NM_FUNCTION; |
|
395 |
|
396 if (mViewStack && !mViewStack->isEmpty()) { |
402 if (mViewStack && !mViewStack->isEmpty()) { |
397 int viewCount = mViewStack->count(); |
403 int viewCount = mViewStack->count(); |
398 // Pop and destroy all views |
404 // Pop and destroy all views |
399 for (int i=0 ; i < viewCount ; i++) { |
405 for (int i=0 ; i < viewCount ; i++) { |
400 NmBaseView *view = mViewStack->pop(); |
406 NmBaseView *view = mViewStack->pop(); |