author | hgs |
Fri, 03 Sep 2010 14:07:42 +0300 | |
changeset 66 | 084b5b1f02a7 |
parent 62 | a8c646b56683 |
child 68 | 83cc6bae1de8 |
permissions | -rw-r--r-- |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
49 | 2 |
* Copyright (c) 2009-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 |
*/ |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "nmuiheaders.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <e32base.h> |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
21 |
static const QString NmSendServiceName = "nmail.com.nokia.symbian.IFileShare"; |
56 | 22 |
static const QString NmActivityName = "EmailInboxView"; |
66 | 23 |
static const int NmErrorNoteDelay = 300000; |
56 | 24 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
/*! |
49 | 26 |
\class NmApplication |
27 |
\brief Application class, creates main window and handles view switching. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
57 | 30 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
/*! |
49 | 32 |
Constructor. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
*/ |
66 | 34 |
NmApplication::NmApplication(int &argc, char *argv[], Hb::ApplicationFlags flags) |
35 |
: HbApplication(argc,argv,flags), |
|
49 | 36 |
mMainWindow(NULL), |
37 |
mViewStack(NULL), |
|
38 |
mActiveViewId(NmUiViewNone), |
|
39 |
mUiEngine(NULL), |
|
40 |
mBackAction(NULL), |
|
41 |
mExtensionManager(NULL), |
|
42 |
mMbListModel(NULL), |
|
43 |
mServiceViewId(NmUiViewNone), |
|
44 |
mForegroundService(false), |
|
45 |
mEffects(NULL), |
|
46 |
mAttaManager(NULL), |
|
47 |
mSettingsViewLauncher(NULL), |
|
48 |
mViewReady(false), |
|
49 |
mQueryDialog(NULL), |
|
62 | 50 |
mBackButtonPressed(false), |
66 | 51 |
mApplicationHidden(false), |
52 |
mErrorNoteTimer(NULL) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
{ |
66 | 54 |
// Load the translation file. |
55 |
QTranslator *translator = new QTranslator(this); |
|
56 |
QString lang = QLocale::system().name(); |
|
57 |
QString appName = "mail_"; |
|
58 |
QString path = "Z:/resource/qt/translations/"; |
|
59 |
translator->load(appName + lang, path); |
|
60 |
installTranslator(translator); |
|
61 |
setApplicationName(hbTrId("txt_mail_title_mail")); |
|
62 |
||
63 |
quint64 accountId = 0; |
|
64 |
QString activateId = this->activateId(); |
|
65 |
if (activateReason() == Hb::ActivationReasonActivity && |
|
66 |
activateId.startsWith(NmActivityName) ) { |
|
67 |
QString accountIdString = activateId.mid(NmActivityName.length()); |
|
68 |
accountId = accountIdString.toULongLong(); |
|
69 |
} |
|
70 |
||
43 | 71 |
TRAP_IGNORE(mUiEngine = NmUiEngine::instance()); |
66 | 72 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
// Create network access manager and cache for application use. |
43 | 74 |
mNetManager = new NmViewerViewNetManager(*mUiEngine); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
QNetworkDiskCache *cache = new QNetworkDiskCache(); |
49 | 76 |
cache->setCacheDirectory( |
77 |
QDesktopServices::storageLocation(QDesktopServices::CacheLocation)); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
mNetManager->setCache(cache); |
49 | 79 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
createMainWindow(); |
49 | 81 |
|
82 |
// Attachment manager can be shared between viewer and editor. |
|
83 |
// The application class has the ownership. |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
84 |
mAttaManager = new NmAttachmentManager(*mUiEngine); |
49 | 85 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
mSendServiceInterface = |
49 | 87 |
new NmSendServiceInterface(NmSendServiceName, NULL, *mUiEngine, this); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
88 |
mSendServiceInterface2 = |
49 | 89 |
new NmSendServiceInterface(emailFullServiceNameSend, NULL, *mUiEngine, this); |
43 | 90 |
mUriServiceInterface = |
91 |
new NmUriServiceInterface(NULL, *mUiEngine, this); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
mMailboxServiceInterface = |
49 | 93 |
new NmMailboxServiceInterface(NULL, *mUiEngine, this); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
mViewerServiceInterface = |
49 | 95 |
new NmViewerServiceInterface(NULL, this, *mUiEngine); |
96 |
||
47 | 97 |
if(accountId != 0) { |
98 |
QVariant mailbox; |
|
57 | 99 |
mailbox.setValue(accountId); |
47 | 100 |
mMailboxServiceInterface->displayInboxByMailboxId(mailbox); |
101 |
} |
|
49 | 102 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
103 |
mEffects = new NmUiEffects(*mMainWindow); |
57 | 104 |
|
66 | 105 |
QObject::connect(this, SIGNAL(activate()), this, SLOT(activityActivated())); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
|
57 | 108 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
/*! |
49 | 110 |
Destructor. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
NmApplication::~NmApplication() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
{ |
57 | 114 |
// Remove the event filter early since catching application activated/ |
115 |
// deactivated events now may cause a crash. |
|
116 |
QCoreApplication::instance()->removeEventFilter(this); |
|
117 |
||
47 | 118 |
if (mQueryDialog) { |
43 | 119 |
delete mQueryDialog; |
49 | 120 |
mQueryDialog = NULL; |
43 | 121 |
} |
49 | 122 |
|
123 |
delete mSendServiceInterface; |
|
124 |
delete mSendServiceInterface2; |
|
125 |
delete mUriServiceInterface; |
|
126 |
delete mMailboxServiceInterface; |
|
127 |
delete mViewerServiceInterface; |
|
128 |
||
129 |
resetViewStack(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
delete mViewStack; |
49 | 131 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
NmIcons::freeIcons(); |
57 | 133 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
NmUiEngine::releaseInstance(mUiEngine); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
mUiEngine = NULL; |
49 | 136 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
delete mBackAction; |
49 | 138 |
|
139 |
// Workaround: the main window has to be closed (hidden) before deleting |
|
140 |
// the extension manager in order to prevent the main window's title bar |
|
141 |
// from showing when the application is closed. |
|
142 |
if (mMainWindow) { |
|
143 |
// Workaround: assert failure may happen if an open main window is |
|
144 |
// deleted. |
|
145 |
mMainWindow->close(); |
|
146 |
} |
|
147 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
delete mExtensionManager; |
49 | 149 |
|
47 | 150 |
if (mNetManager) { |
151 |
if (mNetManager->cache()) { |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
mNetManager->cache()->clear(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
} |
57 | 154 |
|
155 |
delete mNetManager; |
|
156 |
mNetManager = NULL; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
} |
49 | 158 |
|
159 |
// Effects need to be deleted before MainWindow. |
|
43 | 160 |
delete mEffects; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
161 |
delete mMainWindow; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
162 |
delete mAttaManager; |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
163 |
delete mSettingsViewLauncher; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
|
57 | 166 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
/*! |
49 | 168 |
Main application window creation. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
void NmApplication::createMainWindow() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
{ |
43 | 172 |
NM_FUNCTION; |
49 | 173 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
bool service = XQServiceUtil::isService(); |
49 | 175 |
|
176 |
// Register custom widget files. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
177 |
HbStyleLoader::registerFilePath(":nmmessagelistviewitem.widgetml"); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
HbStyleLoader::registerFilePath(":nmmessagelistviewitem.css"); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
HbStyleLoader::registerFilePath(":nmviewerheader.widgetml"); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
HbStyleLoader::registerFilePath(":nmviewerheader.css"); |
49 | 181 |
|
182 |
// Create main window. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
183 |
mMainWindow = new HbMainWindow(); |
49 | 184 |
|
185 |
// Connect to lazy loading signal. |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
186 |
QObject::connect(mMainWindow, SIGNAL(viewReady ()), |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
187 |
this, SLOT(viewReady())); |
49 | 188 |
|
189 |
// Create extension manager. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
mExtensionManager = new NmUiExtensionManager(); |
49 | 191 |
|
192 |
// Create view stack. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
193 |
mViewStack = new QStack<NmBaseView*>; |
49 | 194 |
|
195 |
// Create back action and connect it to prepareForPopView(). |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
if (mMainWindow) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
mBackAction = new HbAction(Hb::BackNaviAction,this); |
49 | 198 |
connect(mBackAction, |
199 |
SIGNAL(triggered()), |
|
200 |
this, |
|
201 |
SLOT(prepareForPopView())); |
|
202 |
||
203 |
// Show mainwindow. |
|
204 |
// Services will active it when the view is ready. |
|
40 | 205 |
if (!service) { |
206 |
mMainWindow->show(); |
|
207 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
208 |
} |
49 | 209 |
|
210 |
// Asynchronous operation completion related notifications. |
|
211 |
connect(mUiEngine, |
|
212 |
SIGNAL(operationCompleted(const NmOperationCompletionEvent &)), |
|
213 |
this, |
|
214 |
SLOT(handleOperationCompleted(const NmOperationCompletionEvent &))); |
|
215 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
216 |
mMbListModel = &mUiEngine->mailboxListModel(); |
49 | 217 |
|
62 | 218 |
|
49 | 219 |
// ---------------------------------------------------------------------- |
220 |
||
47 | 221 |
if (mMainWindow) { |
49 | 222 |
// Start to filter main window events to get "end key" event in all |
223 |
// possible situations. Using event()is not enough to catch the event |
|
224 |
// as it is only called if the view widget has the focus. Note: if |
|
225 |
// key capturing (xqkeycapture.h) is required it is probably best to |
|
226 |
// implement an own QMainWindow class and do the capturing there, not |
|
227 |
// in the views. |
|
47 | 228 |
mMainWindow->installEventFilter(this); |
49 | 229 |
// Optimize the custom paint functions. |
230 |
// Currently effects to NmViewerHeader::paint() and |
|
231 |
// NmAttachmentListWidget::paint(). |
|
47 | 232 |
mMainWindow->setOptimizationFlag(QGraphicsView::DontSavePainterState); |
233 |
} |
|
56 | 234 |
|
57 | 235 |
// Install the event filter in order to receive ApplicationActivate/Deactivate |
236 |
// events. |
|
56 | 237 |
QCoreApplication::instance()->installEventFilter(this); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
238 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
239 |
|
57 | 240 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
241 |
/*! |
49 | 242 |
Slot. React to view ready signal and call current view method. |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
243 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
244 |
void NmApplication::viewReady() |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
245 |
{ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
246 |
mViewReady = true; |
57 | 247 |
|
47 | 248 |
if (mViewStack && !mViewStack->isEmpty()) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
249 |
NmBaseView *currentView = mViewStack->top(); |
57 | 250 |
|
47 | 251 |
if (currentView) { |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
252 |
currentView->viewReady(); |
51 | 253 |
emit applicationReady(); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
254 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
255 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
256 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
257 |
|
57 | 258 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
259 |
/*! |
57 | 260 |
Event filter. End key is filtered from the main window and either the view |
261 |
takes case or the app is exited by default. |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
262 |
*/ |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
263 |
bool NmApplication::eventFilter(QObject *obj, QEvent *event) |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
264 |
{ |
47 | 265 |
bool consumed(false); |
57 | 266 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
267 |
if (obj && obj == mMainWindow && event && event->type() == QEvent::KeyPress) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
268 |
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); |
49 | 269 |
if (keyEvent->key() == Qt::Key_No) { |
270 |
// End key, the "red" key. |
|
271 |
// Exit application if no pending operations are on-going. |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
272 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
273 |
} |
57 | 274 |
else if (event && event->type() == QEvent::ApplicationActivate) { |
56 | 275 |
NM_COMMENT("NmApplication::eventFilter ApplicationActivate"); |
62 | 276 |
mApplicationHidden = false; |
57 | 277 |
// Update task switcher name & screenshot, we could have activated into some other mailbox |
278 |
updateActivity(); |
|
56 | 279 |
} |
57 | 280 |
else if (event && event->type() == QEvent::ApplicationDeactivate) { |
56 | 281 |
NM_COMMENT("NmApplication::eventFilter ApplicationDeactivate"); |
57 | 282 |
// Update the screenshot in the taskswitcher to represent current state |
62 | 283 |
if (!mApplicationHidden) { |
284 |
updateActivity(); |
|
285 |
} |
|
56 | 286 |
// hide the sync indicator when app goes to background |
287 |
mUiEngine->enableSyncIndicator(false); |
|
288 |
} |
|
49 | 289 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
290 |
if (!consumed) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
291 |
consumed = QObject::eventFilter(obj, event); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
292 |
} |
49 | 293 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
294 |
return consumed; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
295 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
296 |
|
57 | 297 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
298 |
/*! |
62 | 299 |
Pushes the given view into the view stack. The new view is also activated |
300 |
and shown. If the view stack contains other views, the one on the top is |
|
301 |
hidden. |
|
302 |
||
303 |
\param newView The view to push into the stack. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
304 |
*/ |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
305 |
void NmApplication::pushView(NmBaseView *newView) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
306 |
{ |
47 | 307 |
if (newView && mViewStack) { |
62 | 308 |
NM_COMMENT("NmApplication::pushView(): The given view is valid."); |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
309 |
newView->setNavigationAction(mBackAction); |
49 | 310 |
|
62 | 311 |
// Store the view to be hidden. |
312 |
NmBaseView *viewToHide(NULL); |
|
313 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
314 |
if (!mViewStack->isEmpty()) { |
62 | 315 |
// The stack contains at least one other view. |
316 |
viewToHide = mViewStack->top(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
317 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
318 |
else { |
49 | 319 |
// viewReady should be informed immediately. |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
320 |
if (mViewReady) { |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
321 |
newView->viewReady(); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
322 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
323 |
} |
49 | 324 |
|
62 | 325 |
// Activate the new view. |
326 |
NM_COMMENT("NmApplication::pushView(): Adding the view into the stack."); |
|
327 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
328 |
mMainWindow->addView(newView); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
329 |
mViewStack->push(newView); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
330 |
mMainWindow->setCurrentView(newView); |
62 | 331 |
mActiveViewId = newView->nmailViewId(); |
49 | 332 |
|
62 | 333 |
// Set the orientation of the toolbar. |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
334 |
HbToolBar *tb = newView->toolBar(); |
62 | 335 |
|
47 | 336 |
if (tb) { |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
337 |
tb->setOrientation(Qt::Horizontal); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
338 |
} |
49 | 339 |
|
62 | 340 |
// Hide the old view. |
341 |
NM_COMMENT("NmApplication::pushView(): Removing the previous view."); |
|
342 |
||
343 |
if (viewToHide) { |
|
344 |
mMainWindow->removeView(viewToHide); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
345 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
346 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
348 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
349 |
/*! |
49 | 350 |
Ask from view that is it ok to pop view. This kind of 2-phase popView is |
351 |
needed because view may show query dialog for user response. |
|
40 | 352 |
*/ |
353 |
void NmApplication::prepareForPopView() |
|
354 |
{ |
|
47 | 355 |
if (mViewStack && mViewStack->size() > 0) { |
49 | 356 |
// Get view pointer. |
40 | 357 |
NmBaseView *view = mViewStack->top(); |
47 | 358 |
if (view){ |
359 |
NmUiViewId topViewId = view->nmailViewId(); |
|
360 |
||
49 | 361 |
// We must know in popView, are we coming with back button from |
362 |
// message view to prevent the send animation. |
|
47 | 363 |
if (topViewId == NmUiViewMessageEditor) { |
364 |
mBackButtonPressed = true; |
|
365 |
} |
|
366 |
||
367 |
// View will call/signal popView if exitting is ok. |
|
368 |
view->okToExitView(); |
|
369 |
} |
|
43 | 370 |
} |
49 | 371 |
// If the view stack is now empty quit the app. This happens also when |
372 |
// the app has been started as a service |
|
47 | 373 |
else if (mViewStack && mViewStack->size() == 0) { |
40 | 374 |
exitApplication(); |
375 |
} |
|
376 |
} |
|
377 |
||
57 | 378 |
|
40 | 379 |
/*! |
51 | 380 |
Hide the application |
381 |
*/ |
|
382 |
void NmApplication::hideApplication() |
|
383 |
{ |
|
62 | 384 |
mApplicationHidden = true; |
385 |
||
51 | 386 |
// Hide the application |
387 |
XQServiceUtil::toBackground(true); |
|
388 |
||
389 |
// hide the sync indicator as well |
|
390 |
mUiEngine->enableSyncIndicator(false); |
|
56 | 391 |
|
392 |
// Hide the mail from the task switcher |
|
393 |
TsTaskSettings taskSettings; |
|
394 |
taskSettings.setVisibility(false); |
|
395 |
||
396 |
// Remove also the mailbox item from the task switcher |
|
66 | 397 |
activityManager()->removeActivity(NmActivityName); |
51 | 398 |
} |
399 |
||
57 | 400 |
|
51 | 401 |
/*! |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
402 |
Pop view from view stack. View object is deleted. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
403 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
void NmApplication::popView() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
405 |
{ |
47 | 406 |
if (mViewStack && mViewStack->size() > 0) { |
407 |
NmBaseView *view = mViewStack->top(); |
|
408 |
if (view) { |
|
49 | 409 |
// Get top view id. |
47 | 410 |
NmUiViewId topViewId = view->nmailViewId(); |
49 | 411 |
|
412 |
// Prepare for send animation if returing from editor and message |
|
413 |
// has been sent. |
|
47 | 414 |
if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) { |
49 | 415 |
// If we are coming from message editor with back button. |
47 | 416 |
// do not prepare the send animation. |
417 |
if (!mBackButtonPressed) { |
|
418 |
mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation); |
|
419 |
} |
|
420 |
} |
|
421 |
mBackButtonPressed = false; |
|
51 | 422 |
|
423 |
// Move the application to background if closing the message list view |
|
424 |
if (topViewId == NmUiViewMessageList && mViewStack->size() == 1) { |
|
66 | 425 |
|
426 |
// if the application has been started as embedded service, |
|
427 |
// we must close it. Otherwise we cannot return back to the calling application. |
|
428 |
if (!XQServiceUtil::isEmbedded()) { |
|
429 |
hideApplication(); |
|
430 |
return; |
|
431 |
} |
|
51 | 432 |
} |
433 |
||
47 | 434 |
mViewStack->pop(); |
49 | 435 |
// Call custom exit function. |
47 | 436 |
view->aboutToExitView(); |
437 |
// Remove view from stack. |
|
438 |
mMainWindow->removeView(view); |
|
49 | 439 |
|
440 |
// If we were in editor and sent a message, pop viewer from stack |
|
441 |
// first so we can go straight to mail list. |
|
47 | 442 |
if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor && |
443 |
mUiEngine->isSendingMessage() && |
|
444 |
mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) { |
|
445 |
NmBaseView *tmpView = mViewStack->pop(); |
|
446 |
mMainWindow->removeView(tmpView); |
|
447 |
delete tmpView; |
|
448 |
tmpView = NULL; |
|
449 |
} |
|
49 | 450 |
|
47 | 451 |
if (!mViewStack->isEmpty()) { |
49 | 452 |
// Activate next view in stack. |
47 | 453 |
NmBaseView *showView = mViewStack->top(); |
454 |
mMainWindow->addView(showView); |
|
455 |
mMainWindow->setCurrentView(showView); |
|
49 | 456 |
// Store activated view id. |
47 | 457 |
mActiveViewId=showView->nmailViewId(); |
458 |
// Perform send animation if requested. |
|
459 |
mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation); |
|
460 |
} |
|
49 | 461 |
|
47 | 462 |
delete view; |
463 |
view = NULL; |
|
49 | 464 |
|
465 |
// If view was started as service, move the app now to the |
|
466 |
// background, unless it was started when the app was already in |
|
467 |
// foreground. |
|
47 | 468 |
if (mServiceViewId == topViewId) { |
469 |
mServiceViewId = NmUiViewNone; |
|
49 | 470 |
NM_COMMENT("NmApplication::popView() : returned from service view."); |
471 |
// If started as embedded or while the app was in foreground, |
|
472 |
// do not hide the app. |
|
47 | 473 |
if (!XQServiceUtil::isEmbedded() && |
474 |
!mForegroundService) { |
|
475 |
XQServiceUtil::toBackground(true); |
|
476 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
} |
40 | 478 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
} |
49 | 480 |
|
481 |
// If the view stack is now empty quit the app. This happens also when |
|
482 |
// the app has been started as a service. |
|
47 | 483 |
if (mViewStack && mViewStack->size() == 0) { |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
484 |
exitApplication(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
485 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
486 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
487 |
|
57 | 488 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
489 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
490 |
Reset view stack. Remove and destroy view objects. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
491 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
492 |
void NmApplication::resetViewStack() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
493 |
{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
494 |
if (mViewStack && !mViewStack->isEmpty()) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
495 |
int viewCount = mViewStack->count(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
496 |
// Pop and destroy all views |
47 | 497 |
for (int i=0 ; i < viewCount ; i++) { |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
498 |
NmBaseView *view = mViewStack->pop(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
499 |
mMainWindow->removeView(view); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
500 |
delete view; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
501 |
} |
47 | 502 |
mActiveViewId = NmUiViewNone; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
503 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
504 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
505 |
|
57 | 506 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
507 |
/*! |
49 | 508 |
Function activates view based on viewId parameter. If requested view is |
509 |
already open, it is requested to reload. Otherwise view object is created |
|
510 |
and pushed to view stack. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
511 |
*/ |
47 | 512 |
void NmApplication::enterNmUiView(NmUiStartParam *startParam) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
513 |
{ |
43 | 514 |
NM_FUNCTION; |
49 | 515 |
|
516 |
// Check the validity of start parameter object. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
517 |
if (startParam) { |
56 | 518 |
|
519 |
mCurrentMailboxId = startParam->mailboxId(); |
|
49 | 520 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
521 |
if (startParam->service() && mMainWindow) { |
49 | 522 |
// When the message list is started as a service previous views |
62 | 523 |
// are removed from the stack. Open editors are closed. Also |
49 | 524 |
// if the view is same than the new one, keep it open (reload the |
525 |
// content). |
|
526 |
||
527 |
// Reset the foreground service flag while popping the views. |
|
44 | 528 |
bool previousForegroundService = mForegroundService; |
529 |
mForegroundService = true; |
|
49 | 530 |
|
531 |
// At least one view must remain in the stack. |
|
47 | 532 |
while (mViewStack->count( )> 1) { |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
533 |
NmUiViewId topId = mViewStack->top()->nmailViewId(); |
47 | 534 |
if (topId != NmUiViewMessageEditor && |
535 |
topId != NmUiViewMailboxList && |
|
536 |
topId != startParam->viewId()) { |
|
40 | 537 |
prepareForPopView(); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
538 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
539 |
else { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
540 |
// Editor or mailbox list in the top. Stop the loop. |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
541 |
break; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
542 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
543 |
} |
44 | 544 |
mForegroundService = previousForegroundService; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
545 |
} |
49 | 546 |
|
547 |
// Check whether requested view is already active and if so, ask it |
|
548 |
// to reload contents with new start parameter data. Do not reuse the |
|
549 |
// view if started as service to editor view (ShareUI). |
|
47 | 550 |
if (mActiveViewId == startParam->viewId() && |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
551 |
(!startParam->service() || mActiveViewId!=NmUiViewMessageEditor)) { |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
552 |
mViewStack->top()->reloadViewContents(startParam); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
553 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
554 |
else { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
555 |
switch (startParam->viewId()) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
556 |
case NmUiViewMailboxList: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
557 |
{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
558 |
NmMailboxListView *mbListView = new NmMailboxListView( |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
559 |
*this, startParam, *mUiEngine, |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
560 |
*mMbListModel, new HbDocumentLoader(mMainWindow)); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
561 |
pushView(mbListView); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
562 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
563 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
564 |
case NmUiViewMessageList: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
565 |
{ |
62 | 566 |
// Check the topmost view. If it is an editor, save to draft and close it. |
567 |
if (startParam->service() && !mViewStack->isEmpty() && |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
568 |
mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) { |
62 | 569 |
QMetaObject::invokeMethod(mViewStack->top(), |
570 |
"safeToDraft", Qt::DirectConnection); |
|
571 |
popView(); |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
572 |
} |
62 | 573 |
|
574 |
NmMessageListModel *messageListModel = |
|
575 |
&mUiEngine->messageListModel(startParam->mailboxId(), |
|
576 |
startParam->folderId()); |
|
577 |
NmMessageListView *msgList = |
|
578 |
new NmMessageListView(*this, startParam, *mUiEngine, |
|
579 |
*mMbListModel, messageListModel, |
|
580 |
new HbDocumentLoader(mMainWindow)); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
581 |
pushView(msgList); |
62 | 582 |
|
583 |
// Inform other processes about this event. |
|
584 |
NmUiEventsNotifier::notifyViewStateChanged(NmUiEventsNotifier::NmViewShownEvent, |
|
585 |
NmUiViewMessageList, |
|
586 |
startParam->mailboxId()); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
587 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
588 |
break; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
589 |
case NmUiViewMessageSearchList: |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
590 |
{ |
62 | 591 |
// Check the topmost view. If it is an editor, save to draft and close it. |
592 |
if (startParam->service() && !mViewStack->isEmpty() && |
|
593 |
mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) { |
|
594 |
QMetaObject::invokeMethod(mViewStack->top(), |
|
595 |
"safeToDraft", Qt::DirectConnection); |
|
596 |
popView(); |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
597 |
} |
49 | 598 |
|
40 | 599 |
NmMessageListModel &model = |
600 |
mUiEngine->messageListModelForSearch(startParam->mailboxId()); |
|
49 | 601 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
602 |
NmMessageSearchListView *searchListView = new NmMessageSearchListView( |
40 | 603 |
*this, startParam, *mUiEngine, model, |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
604 |
new HbDocumentLoader(mMainWindow)); |
49 | 605 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
606 |
pushView(searchListView); |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
607 |
} |
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
608 |
break; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
609 |
case NmUiViewMessageViewer: |
43 | 610 |
pushView(new NmViewerView(*this, startParam, *mUiEngine, |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
611 |
mMainWindow, *mAttaManager)); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
612 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
613 |
case NmUiViewMessageEditor: |
62 | 614 |
// Check the topmost view. If it is an editor, save to draft and close it. |
615 |
if (startParam->service() && !mViewStack->isEmpty() && |
|
616 |
mViewStack->top()->nmailViewId()==NmUiViewMessageEditor) { |
|
617 |
QMetaObject::invokeMethod(mViewStack->top(), |
|
618 |
"safeToDraft", Qt::DirectConnection); |
|
619 |
popView(); |
|
620 |
} |
|
43 | 621 |
pushView(new NmEditorView(*this, startParam, *mUiEngine, *mAttaManager)); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
622 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
623 |
default: |
49 | 624 |
// Reset view stack and exit application. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
625 |
delete startParam; |
47 | 626 |
startParam = NULL; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
627 |
resetViewStack(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
628 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
629 |
} |
44 | 630 |
} |
49 | 631 |
|
44 | 632 |
if (startParam && startParam->service()) { |
49 | 633 |
// Store the view id that was launched as service. |
44 | 634 |
mServiceViewId = mActiveViewId; |
635 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
636 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
637 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
638 |
|
57 | 639 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
640 |
/*! |
49 | 641 |
Function can be used from views to exit the application. View stack is |
642 |
cleared. Views can connect exit menu selection to this slot. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
643 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
644 |
void NmApplication::exitApplication() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
645 |
{ |
43 | 646 |
NM_FUNCTION; |
49 | 647 |
|
66 | 648 |
activityManager()->removeActivity(NmActivityName); |
56 | 649 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
650 |
delete mSendServiceInterface; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
651 |
mSendServiceInterface = NULL; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
652 |
delete mSendServiceInterface2; |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
653 |
mSendServiceInterface2 = NULL; |
43 | 654 |
delete mUriServiceInterface; |
655 |
mUriServiceInterface = NULL; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
656 |
delete mMailboxServiceInterface; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
657 |
mMailboxServiceInterface = NULL; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
658 |
delete mViewerServiceInterface; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
659 |
mViewerServiceInterface = NULL; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
660 |
resetViewStack(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
661 |
qApp->quit(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
662 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
663 |
|
57 | 664 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
665 |
/*! |
49 | 666 |
Exit the application in the next event loop. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
667 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
668 |
void NmApplication::delayedExitApplication() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
669 |
{ |
49 | 670 |
// Exit the application in the next event loop. |
47 | 671 |
QMetaObject::invokeMethod(this, "exitApplication", Qt::QueuedConnection); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
672 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
673 |
|
57 | 674 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
675 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
676 |
Getter for main window instance. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
677 |
*/ |
47 | 678 |
HbMainWindow *NmApplication::mainWindow() |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
679 |
{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
680 |
return mMainWindow; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
681 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
682 |
|
57 | 683 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
684 |
/*! |
49 | 685 |
Getter for main UI extension manager. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
686 |
*/ |
47 | 687 |
NmUiExtensionManager &NmApplication::extManager() |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
688 |
{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
689 |
return *mExtensionManager; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
690 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
691 |
|
57 | 692 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
693 |
/*! |
49 | 694 |
Getter for network access manager. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
695 |
*/ |
47 | 696 |
NmViewerViewNetManager &NmApplication::networkAccessManager() |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
697 |
{ |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
698 |
return *mNetManager; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
699 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
700 |
|
57 | 701 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
702 |
/*! |
49 | 703 |
Get the screen size. Function returns curtent screen size. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
704 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
705 |
QSize NmApplication::screenSize() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
706 |
{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
707 |
QSize ret(0,0); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
708 |
if (mMainWindow){ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
709 |
HbDeviceProfile currentP = HbDeviceProfile::current(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
710 |
HbDeviceProfile altP(currentP.alternateProfileName()); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
711 |
QSize curPSize = currentP.logicalSize(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
712 |
QSize altPSize = altP.logicalSize(); |
47 | 713 |
if (mMainWindow->orientation() == Qt::Horizontal) { |
49 | 714 |
// Get wide profile size in landscape. |
47 | 715 |
if (curPSize.width() > altPSize.width()) { |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
716 |
ret = curPSize; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
717 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
718 |
else{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
719 |
ret = altPSize; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
720 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
721 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
722 |
else { |
49 | 723 |
// Get narrow profile size in portrait. |
47 | 724 |
if (curPSize.width() < altPSize.width()) { |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
725 |
ret = curPSize; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
726 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
727 |
else{ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
728 |
ret = altPSize; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
729 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
730 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
731 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
732 |
return ret; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
733 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
734 |
|
57 | 735 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
736 |
/*! |
49 | 737 |
Handles all asynchronous operation's completions at UI level. |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
738 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
739 |
void NmApplication::handleOperationCompleted(const NmOperationCompletionEvent &event) |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
740 |
{ |
47 | 741 |
if (event.mCompletionCode != NmNoError && event.mCompletionCode != NmCancelError) { |
742 |
if (event.mOperationType == Synch && event.mCompletionCode == NmAuthenticationError) { |
|
743 |
mLastOperationMailbox = event.mMailboxId; |
|
744 |
if (mQueryDialog) { |
|
43 | 745 |
delete mQueryDialog; |
47 | 746 |
mQueryDialog = NULL; |
43 | 747 |
} |
748 |
mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_address_or_password_incorrect"), |
|
44 | 749 |
this, SLOT(launchSettings(HbAction*))); |
43 | 750 |
} |
47 | 751 |
if (event.mOperationType == Synch && event.mCompletionCode == NmServerConnectionError) { |
43 | 752 |
mLastOperationMailbox=event.mMailboxId; |
47 | 753 |
if (mQueryDialog) { |
43 | 754 |
delete mQueryDialog; |
47 | 755 |
mQueryDialog = NULL; |
43 | 756 |
} |
757 |
mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_server_settings_incorrect"), |
|
44 | 758 |
this, SLOT(launchSettings(HbAction*))); |
43 | 759 |
} |
49 | 760 |
// Following applies to all operation/event types. |
47 | 761 |
if (event.mCompletionCode == NmConnectionError) { |
66 | 762 |
// Create error note delayer timer when used for the first time |
763 |
if (!mErrorNoteTimer) { |
|
764 |
mErrorNoteTimer = new QTimer(this); |
|
765 |
} |
|
766 |
// Check whether mailbox id has changed, stop |
|
767 |
// timer in that case and note will be displayed even |
|
768 |
// before 5min delay has passed |
|
769 |
if (mLastErrorMailboxId != event.mMailboxId) { |
|
770 |
mErrorNoteTimer->stop(); |
|
771 |
} |
|
772 |
// Store mailbox id |
|
773 |
mLastErrorMailboxId = event.mMailboxId; |
|
774 |
// Show error note if timer is not active, e.g 5 minutes |
|
775 |
// have passed since last "mail connection error". |
|
776 |
if (!mErrorNoteTimer->isActive()) { |
|
777 |
NmUtilities::displayErrorNote(hbTrId("txt_mail_dialog_mail_connection_error")); |
|
778 |
// Start timer with 5 min timeout |
|
779 |
mErrorNoteTimer->start(NmErrorNoteDelay); |
|
780 |
} |
|
43 | 781 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
782 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
783 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
784 |
|
57 | 785 |
|
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
786 |
/*! |
49 | 787 |
Launches settings view of the specified mailbox. |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
788 |
*/ |
43 | 789 |
void NmApplication::launchSettings(HbAction* action) |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
790 |
{ |
49 | 791 |
// Check whether yes button was pressed. |
43 | 792 |
if (mQueryDialog&& action == mQueryDialog->actions().at(0)) { |
49 | 793 |
// Create settingslauncher if doesn't exist. |
43 | 794 |
if(!mSettingsViewLauncher) { |
795 |
mSettingsViewLauncher = new NmSettingsViewLauncher(); |
|
796 |
} |
|
49 | 797 |
// Mailboxname required. |
798 |
NmMailboxMetaData *mailboxMetaData = mUiEngine->mailboxById(mLastOperationMailbox); // No ownership. |
|
47 | 799 |
if( mailboxMetaData ) { |
49 | 800 |
// Launch. |
47 | 801 |
mSettingsViewLauncher->launchSettingsView(mLastOperationMailbox, mailboxMetaData->name()); |
44 | 802 |
} |
803 |
} |
|
43 | 804 |
} |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
805 |
|
57 | 806 |
|
43 | 807 |
/*! |
62 | 808 |
Check the foreground status of the application |
809 |
\return true if the application is in the foreground |
|
810 |
*/ |
|
811 |
bool NmApplication::isForeground() const |
|
812 |
{ |
|
813 |
// At the moment there is no good way to check the foreground state. |
|
814 |
QWindowSurface *surface = mMainWindow->windowSurface(); |
|
815 |
return (surface != 0); |
|
816 |
} |
|
817 |
||
818 |
/*! |
|
43 | 819 |
Stores the visibility state, e.g. when the service was launched. |
49 | 820 |
\return true if the app was visible. |
43 | 821 |
*/ |
822 |
bool NmApplication::updateVisibilityState() |
|
823 |
{ |
|
62 | 824 |
mForegroundService = isForeground(); |
49 | 825 |
NM_COMMENT(QString("NmApplication::updateVisibilityState() : mForegroundService == %1").arg(mForegroundService)); |
43 | 826 |
return mForegroundService; |
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
827 |
} |
56 | 828 |
|
57 | 829 |
|
56 | 830 |
/*! |
57 | 831 |
Update the thumbnail in the task switcher. |
56 | 832 |
*/ |
833 |
void NmApplication::updateActivity() |
|
834 |
{ |
|
835 |
NmMailboxMetaData *meta = mUiEngine->mailboxById(mCurrentMailboxId); |
|
66 | 836 |
|
837 |
// This will ensure that when service is started as a embedded service and a mail |
|
838 |
// process already exists the task activity will show the embedded service inside the |
|
839 |
// calling processes activity and the already running mail process in its own activity. |
|
840 |
if(!XQServiceUtil::isService() || !XQServiceUtil::isEmbedded()) { |
|
841 |
if (meta) { |
|
842 |
TsTaskSettings tasksettings; |
|
843 |
tasksettings.setVisibility(false); |
|
844 |
QVariantHash metadata; |
|
845 |
metadata.insert(ActivityScreenshotKeyword, QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
|
846 |
metadata.insert(ActivityApplicationName, meta->name()); |
|
847 |
metadata.insert(ActivityVisibility, true); |
|
848 |
activityManager()->removeActivity(NmActivityName); |
|
849 |
activityManager()->addActivity(NmActivityName, QVariant(), metadata); |
|
850 |
} |
|
851 |
else { |
|
852 |
activityManager()->removeActivity(NmActivityName); |
|
853 |
TsTaskSettings tasksettings; |
|
854 |
tasksettings.setVisibility(true); |
|
56 | 855 |
} |
856 |
} |
|
857 |
} |
|
57 | 858 |
|
859 |
/*! |
|
860 |
Switch to activated mailbox |
|
861 |
*/ |
|
862 |
void NmApplication::activityActivated() |
|
863 |
{ |
|
66 | 864 |
quint64 accountId(0); |
865 |
QString activateId = this->activateId(); |
|
866 |
if (activateReason() == Hb::ActivationReasonActivity && |
|
867 |
activateId.startsWith(NmActivityName) ) { |
|
868 |
QString accountIdString = activateId.mid(NmActivityName.length()); |
|
869 |
accountId = accountIdString.toULongLong(); |
|
870 |
QVariant mailbox; |
|
871 |
mailbox.setValue(accountId); |
|
872 |
mMailboxServiceInterface->displayInboxByMailboxId(mailbox); |
|
57 | 873 |
} |
874 |
} |
|
875 |