author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 7 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
child 11 | 25a739ee40f4 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Symbian application wrapper of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
// INCLUDE FILES |
|
43 |
#include <exception> |
|
44 |
#include <avkon.hrh> |
|
45 |
#include <eikmenub.h> |
|
46 |
#include <eikmenup.h> |
|
47 |
#include <barsread.h> |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
48 |
#include <qconfig.h> |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
49 |
#if defined(QT_LIBINFIX_UNQUOTED) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
50 |
// Two level macro needed for proper expansion of libinfix |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
51 |
# define QT_S60MAIN_RSG_2(x) <s60main##x##.rsg> |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
52 |
# define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
53 |
# include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
54 |
#else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
55 |
# include <s60main.rsg> |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
56 |
#endif |
0 | 57 |
#include <avkon.rsg> |
58 |
||
59 |
#include "qs60mainappui.h" |
|
60 |
#include <QtGui/qapplication.h> |
|
61 |
#include <QtGui/qsymbianevent.h> |
|
62 |
#include <QtGui/qmenu.h> |
|
63 |
#include <private/qmenu_p.h> |
|
64 |
#include <private/qt_s60_p.h> |
|
65 |
#include <qdebug.h> |
|
66 |
||
67 |
QT_BEGIN_NAMESPACE |
|
68 |
||
69 |
/*! |
|
70 |
\class QS60MainAppUi |
|
71 |
\since 4.6 |
|
72 |
\brief The QS60MainAppUi class is a helper class for S60 migration. |
|
73 |
||
74 |
\warning This class is provided only to get access to S60 specific |
|
75 |
functionality in the application framework classes. It is not |
|
76 |
portable. We strongly recommend against using it in new applications. |
|
77 |
||
78 |
The QS60MainAppUi provides a helper class for use in migrating from |
|
79 |
existing S60 based applications to Qt based applications. It is used |
|
80 |
in the exact same way as the \c CAknAppUi class from Symbian, but |
|
81 |
internally provides extensions used by Qt. |
|
82 |
||
83 |
When modifying old S60 applications that rely on implementing |
|
84 |
functions in \c CAknAppUi, the class should be modified to inherit |
|
85 |
from this class instead of \c CAknAppUi. Then the application can |
|
86 |
choose to override only certain functions. |
|
87 |
||
88 |
For more information on \c CAknAppUi, please see the S60 |
|
89 |
documentation. |
|
90 |
||
91 |
Unlike other Qt classes, QS60MainAppUi behaves like an S60 class, |
|
92 |
and can throw Symbian leaves. |
|
93 |
||
94 |
\sa QS60MainDocument, QS60MainApplication |
|
95 |
*/ |
|
96 |
||
97 |
/*! |
|
98 |
* \brief Second phase Symbian constructor. |
|
99 |
* |
|
100 |
* Constructs all the elements of the class that can cause a leave to happen. |
|
101 |
* |
|
102 |
* If you override this function, you should call the base class implementation as well. |
|
103 |
*/ |
|
104 |
void QS60MainAppUi::ConstructL() |
|
105 |
{ |
|
106 |
// Cone's heap and handle checks on app destruction are not suitable for Qt apps, as many |
|
107 |
// objects can still exist in static data at that point. Instead we will print relevant information |
|
108 |
// so that comparative checks may be made for memory leaks, using ~SPrintExitInfo in corelib. |
|
109 |
iEikonEnv->DisableExitChecks(ETrue); |
|
110 |
||
111 |
// Initialise app UI with standard value. |
|
112 |
// ENoAppResourceFile and ENonStandardResourceFile makes UI to work without |
|
113 |
// resource files in most SDKs. S60 3rd FP1 public seems to require resource file |
|
114 |
// even these flags are defined |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
115 |
TInt flags = CAknAppUi::EAknEnableSkin; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
116 |
if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)) { |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
117 |
flags |= CAknAppUi::ENoScreenFurniture | CAknAppUi::ENonStandardResourceFile; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
118 |
} |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
119 |
BaseConstructL(flags); |
0 | 120 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
121 |
if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)) { |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
122 |
CEikButtonGroupContainer* nativeContainer = Cba(); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
123 |
nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
124 |
} |
0 | 125 |
} |
126 |
||
127 |
/*! |
|
128 |
* \brief Contructs an instance of QS60MainAppUi. |
|
129 |
*/ |
|
130 |
QS60MainAppUi::QS60MainAppUi() |
|
131 |
{ |
|
132 |
// No implementation required |
|
133 |
} |
|
134 |
||
135 |
/*! |
|
136 |
* \brief Destroys the QS60MainAppUi. |
|
137 |
*/ |
|
138 |
QS60MainAppUi::~QS60MainAppUi() |
|
139 |
{ |
|
140 |
} |
|
141 |
||
142 |
/*! |
|
143 |
* \brief Handles commands produced by the S60 framework. |
|
144 |
* |
|
145 |
* \a command holds the ID of the command to handle, and is S60 specific. |
|
146 |
* |
|
147 |
* If you override this function, you should call the base class implementation if you do not |
|
148 |
* handle the command. |
|
149 |
*/ |
|
150 |
void QS60MainAppUi::HandleCommandL(TInt command) |
|
151 |
{ |
|
152 |
if (qApp) { |
|
153 |
QSymbianEvent event(QSymbianEvent::CommandEvent, command); |
|
154 |
QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event)); |
|
155 |
} |
|
156 |
} |
|
157 |
||
158 |
/*! |
|
159 |
* \brief Handles a resource change in the S60 framework. |
|
160 |
* |
|
161 |
* Resource changes include layout switches. \a type holds the type of resource change that |
|
162 |
* occurred. |
|
163 |
* |
|
164 |
* If you override this function, you should call the base class implementation if you do not |
|
165 |
* handle the resource change. |
|
166 |
*/ |
|
167 |
void QS60MainAppUi::HandleResourceChangeL(TInt type) |
|
168 |
{ |
|
169 |
CAknAppUi::HandleResourceChangeL(type); |
|
170 |
||
171 |
if (qApp) { |
|
172 |
QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type); |
|
173 |
QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event)); |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
/*! |
|
178 |
* \brief Handles raw window server events. |
|
179 |
* |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
* The event type and information is passed in \a wsEvent, while the receiving control is passed in |
0 | 181 |
* \a destination. |
182 |
* |
|
183 |
* If you override this function, you should call the base class implementation if you do not |
|
184 |
* handle the event. |
|
185 |
*/ |
|
186 |
void QS60MainAppUi::HandleWsEventL(const TWsEvent& wsEvent, CCoeControl *destination) |
|
187 |
{ |
|
188 |
int result = 0; |
|
189 |
if (qApp) { |
|
190 |
QSymbianEvent event(&wsEvent); |
|
191 |
QT_TRYCATCH_LEAVING( |
|
192 |
result = qApp->symbianProcessEvent(&event) |
|
193 |
); |
|
194 |
} |
|
195 |
||
196 |
if (result <= 0) |
|
197 |
CAknAppUi::HandleWsEventL(wsEvent, destination); |
|
198 |
} |
|
199 |
||
200 |
||
201 |
/*! |
|
202 |
* \brief Handles changes to the status pane size. |
|
203 |
* |
|
204 |
* Called by the framework when the application status pane size is changed. |
|
205 |
* |
|
206 |
* If you override this function, you should call the base class implementation if you do not |
|
207 |
* handle the size change. |
|
208 |
*/ |
|
209 |
void QS60MainAppUi::HandleStatusPaneSizeChange() |
|
210 |
{ |
|
211 |
TRAP_IGNORE(HandleResourceChangeL(KInternalStatusPaneChange)); |
|
212 |
HandleStackedControlsResourceChange(KInternalStatusPaneChange); |
|
213 |
} |
|
214 |
||
215 |
/*! |
|
216 |
* \brief Dynamically initializes a menu bar. |
|
217 |
* |
|
218 |
* The resource associated with the menu is given in \a resourceId, and the actual menu bar is |
|
219 |
* passed in \a menuBar. |
|
220 |
* |
|
221 |
* If you override this function, you should call the base class implementation as well. |
|
222 |
*/ |
|
223 |
void QS60MainAppUi::DynInitMenuBarL(TInt /* resourceId */, CEikMenuBar * /* menuBar */) |
|
224 |
{ |
|
225 |
} |
|
226 |
||
227 |
/*! |
|
228 |
* \brief Dynamically initializes a menu pane. |
|
229 |
* |
|
230 |
* The resource associated with the menu is given in \a resourceId, and the actual menu pane is |
|
231 |
* passed in \a menuPane. |
|
232 |
* |
|
233 |
* If you override this function, you should call the base class implementation as well. |
|
234 |
*/ |
|
235 |
void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane) |
|
236 |
{ |
|
237 |
if (resourceId == R_QT_WRAPPERAPP_MENU) { |
|
238 |
if (menuPane->NumberOfItemsInPane() <= 1) |
|
239 |
QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane)); |
|
240 |
||
241 |
} else if (resourceId != R_AVKON_MENUPANE_FEP_DEFAULT |
|
242 |
&& resourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT |
|
243 |
&& resourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT) { |
|
244 |
QT_TRYCATCH_LEAVING(qt_symbian_show_submenu(menuPane, resourceId)); |
|
245 |
} |
|
246 |
} |
|
247 |
||
248 |
/*! |
|
249 |
* \brief Restores a menu window. |
|
250 |
* |
|
251 |
* The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given |
|
252 |
* in \a resourceId and \a menuType, respectively. |
|
253 |
* |
|
254 |
* If you override this function, you should call the base class implementation as well. |
|
255 |
*/ |
|
256 |
void QS60MainAppUi::RestoreMenuL(CCoeControl* menuWindow, TInt resourceId, TMenuType menuType) |
|
257 |
{ |
|
258 |
if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) { |
|
259 |
if (menuType == EMenuPane) |
|
260 |
DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow); |
|
261 |
else |
|
262 |
DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow); |
|
263 |
} else { |
|
264 |
CAknAppUi::RestoreMenuL(menuWindow, resourceId, menuType); |
|
265 |
} |
|
266 |
} |
|
267 |
||
268 |
QT_END_NAMESPACE |