source: trunk/src/gui/s60framework/qs60mainappui.cpp

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 11.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the Symbian application wrapper of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42// INCLUDE FILES
43#include <exception>
44#include <qglobal.h>
45#ifdef Q_WS_S60
46#include <avkon.hrh>
47#include <eikmenub.h>
48#include <eikmenup.h>
49#include <avkon.rsg>
50#endif
51#include <barsread.h>
52#include <qconfig.h>
53
54#include "qs60mainappui.h"
55#include <QtGui/qapplication.h>
56#include <QtGui/qsymbianevent.h>
57#include <QtGui/qmenu.h>
58#include <private/qmenu_p.h>
59#include <private/qt_s60_p.h>
60#include <qdebug.h>
61
62//Animated wallpapers in Qt applications are not supported.
63const TInt KAknDisableAnimationBackground = 0x02000000;
64
65QT_BEGIN_NAMESPACE
66
67/*!
68 \class QS60MainAppUi
69 \since 4.6
70 \brief The QS60MainAppUi class is a helper class for S60 migration.
71
72 \warning This class is provided only to get access to S60 specific
73 functionality in the application framework classes. It is not
74 portable. We strongly recommend against using it in new applications.
75
76 The QS60MainAppUi provides a helper class for use in migrating from
77 existing S60 based applications to Qt based applications. It is used
78 in the exact same way as the \c CAknAppUi class from Symbian, but
79 internally provides extensions used by Qt.
80
81 When modifying old S60 applications that rely on implementing
82 functions in \c CAknAppUi, the class should be modified to inherit
83 from this class instead of \c CAknAppUi. Then the application can
84 choose to override only certain functions.
85
86 For more information on \c CAknAppUi, please see the S60
87 documentation.
88
89 Unlike other Qt classes, QS60MainAppUi behaves like an S60 class,
90 and can throw Symbian leaves.
91
92 \sa QS60MainDocument, QS60MainApplication
93 */
94
95/*!
96 * \brief Second phase Symbian constructor.
97 *
98 * Constructs all the elements of the class that can cause a leave to happen.
99 *
100 * If you override this function, you should call the base class implementation as well.
101 */
102void QS60MainAppUi::ConstructL()
103{
104 // Cone's heap and handle checks on app destruction are not suitable for Qt apps, as many
105 // objects can still exist in static data at that point. Instead we will print relevant information
106 // so that comparative checks may be made for memory leaks, using ~SPrintExitInfo in corelib.
107 iEikonEnv->DisableExitChecks(ETrue);
108
109 // Initialise app UI with standard value.
110 // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without
111 // resource files in most SDKs. S60 3rd FP1 public seems to require resource file
112 // even these flags are defined
113 TInt flags = CEikAppUi::ENoScreenFurniture
114 | CEikAppUi::ENonStandardResourceFile;
115#ifdef Q_WS_S60
116 flags |= CAknAppUi::EAknEnableSkin;
117 // After 5th Edition S60, native side supports animated wallpapers.
118 // However, there is no support for that feature on Qt side, so indicate to
119 // native UI framework that this application will not support background animations.
120 if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0)
121 flags |= KAknDisableAnimationBackground;
122#endif
123 BaseConstructL(flags);
124}
125
126/*!
127 * \brief Contructs an instance of QS60MainAppUi.
128 */
129QS60MainAppUi::QS60MainAppUi()
130{
131 // No implementation required
132}
133
134/*!
135 * \brief Destroys the QS60MainAppUi.
136 */
137QS60MainAppUi::~QS60MainAppUi()
138{
139}
140
141/*!
142 * \brief Handles commands produced by the S60 framework.
143 *
144 * \a command holds the ID of the command to handle, and is S60 specific.
145 *
146 * If you override this function, you should call the base class implementation if you do not
147 * handle the command.
148 */
149void QS60MainAppUi::HandleCommandL(TInt command)
150{
151 if (qApp) {
152 QSymbianEvent event(QSymbianEvent::CommandEvent, command);
153 QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
154 }
155}
156
157/*!
158 * \brief Handles a resource change in the S60 framework.
159 *
160 * Resource changes include layout switches. \a type holds the type of resource change that
161 * occurred.
162 *
163 * If you override this function, you should call the base class implementation if you do not
164 * handle the resource change.
165 */
166void QS60MainAppUi::HandleResourceChangeL(TInt type)
167{
168 QS60MainAppUiBase::HandleResourceChangeL(type);
169
170 if (qApp) {
171 QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type);
172 QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
173 }
174}
175
176/*!
177 * \brief Handles raw window server events.
178 *
179 * The event type and information is passed in \a wsEvent, while the receiving control is passed in
180 * \a destination.
181 *
182 * If you override this function, you should call the base class implementation if you do not
183 * handle the event.
184 */
185void QS60MainAppUi::HandleWsEventL(const TWsEvent &wsEvent, CCoeControl *destination)
186{
187 int result = 0;
188 if (qApp) {
189 QSymbianEvent event(&wsEvent);
190 QT_TRYCATCH_LEAVING(
191 result = qApp->symbianProcessEvent(&event)
192 );
193 }
194
195 if (result <= 0)
196 QS60MainAppUiBase::HandleWsEventL(wsEvent, destination);
197}
198
199
200/*!
201 * \brief Handles changes to the status pane size.
202 *
203 * Called by the framework when the application status pane size is changed.
204 *
205 * If you override this function, you should call the base class implementation if you do not
206 * handle the size change.
207 */
208void QS60MainAppUi::HandleStatusPaneSizeChange()
209{
210 TRAP_IGNORE(HandleResourceChangeL(KInternalStatusPaneChange));
211 HandleStackedControlsResourceChange(KInternalStatusPaneChange);
212}
213
214/*!
215 * \brief Dynamically initializes a menu bar.
216 *
217 * The resource associated with the menu is given in \a resourceId, and the actual menu bar is
218 * passed in \a menuBar.
219 *
220 * If you override this function, you should call the base class implementation as well.
221 */
222void QS60MainAppUi::DynInitMenuBarL(TInt /* resourceId */, CEikMenuBar * /* menuBar */)
223{
224}
225
226/*!
227 * \brief Dynamically initializes a menu pane.
228 *
229 * The resource associated with the menu is given in \a resourceId, and the actual menu pane is
230 * passed in \a menuPane.
231 *
232 * If you override this function, you should call the base class implementation as well.
233 */
234void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane)
235{
236#ifdef Q_WS_S60
237 if (resourceId == R_AVKON_MENUPANE_EMPTY) {
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#else
247 QS60MainAppUiBase::DynInitMenuPaneL(resourceId, menuPane);
248#endif
249}
250
251/*!
252 * \brief Restores a menu window.
253 *
254 * The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given
255 * in \a resourceId and \a menuType, respectively.
256 *
257 * If you override this function, you should call the base class implementation as well.
258 */
259void QS60MainAppUi::RestoreMenuL(CCoeControl *menuWindow, TInt resourceId, TMenuType menuType)
260{
261#ifdef Q_WS_S60
262 if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) {
263 if (menuType == EMenuPane)
264 DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow);
265 else
266 DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow);
267 } else if(resourceId == R_AVKON_MENUPANE_EMPTY) {
268 CEikMenuBarTitle *title = new(ELeave) CEikMenuBarTitle;
269 CleanupStack::PushL(title);
270
271 title->iData.iMenuPaneResourceId = R_AVKON_MENUPANE_EMPTY;
272 title->iTitleFlags = 0;
273
274 S60->menuBar()->TitleArray()->AddTitleL(title);
275 CleanupStack::Pop( title );
276 }
277 else
278#endif
279 {
280 QS60MainAppUiBase::RestoreMenuL(menuWindow, resourceId, menuType);
281 }
282}
283
284/*!
285 \internal
286*/
287void QS60MainAppUi::Exit()
288{
289 QS60MainAppUiBase::Exit();
290}
291
292/*!
293 \internal
294*/
295void QS60MainAppUi::SetFadedL(TBool aFaded)
296{
297 QS60MainAppUiBase::SetFadedL(aFaded);
298}
299
300/*!
301 \internal
302*/
303TRect QS60MainAppUi::ApplicationRect() const
304{
305 return QS60MainAppUiBase::ApplicationRect();
306}
307
308/*!
309 \internal
310*/
311void QS60MainAppUi::HandleScreenDeviceChangedL()
312{
313 QS60MainAppUiBase::HandleScreenDeviceChangedL();
314}
315
316/*!
317 \internal
318*/
319void QS60MainAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent &aEvent)
320{
321 QS60MainAppUiBase::HandleApplicationSpecificEventL(aType, aEvent);
322}
323
324/*!
325 \internal
326*/
327TTypeUid::Ptr QS60MainAppUi::MopSupplyObject(TTypeUid aId)
328{
329 return QS60MainAppUiBase::MopSupplyObject(aId);
330}
331
332/*!
333 \internal
334*/
335void QS60MainAppUi::ProcessCommandL(TInt aCommand)
336{
337 QS60MainAppUiBase::ProcessCommandL(aCommand);
338}
339
340/*!
341 \internal
342*/
343TErrorHandlerResponse QS60MainAppUi::HandleError (TInt aError, const SExtendedError &aExtErr, TDes &aErrorText, TDes &aContextText)
344{
345 return QS60MainAppUiBase::HandleError(aError, aExtErr, aErrorText, aContextText);
346}
347
348/*!
349 \internal
350*/
351void QS60MainAppUi::HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId)
352{
353 QS60MainAppUiBase::HandleViewDeactivation(aViewIdToBeDeactivated, aNewlyActivatedViewId);
354}
355
356/*!
357 \internal
358*/
359void QS60MainAppUi::PrepareToExit()
360{
361 QS60MainAppUiBase::PrepareToExit();
362}
363
364/*!
365 \internal
366*/
367void QS60MainAppUi::HandleTouchPaneSizeChange()
368{
369 QS60MainAppUiBase::HandleTouchPaneSizeChange();
370}
371
372/*!
373 \internal
374*/
375void QS60MainAppUi::HandleSystemEventL(const TWsEvent &aEvent)
376{
377 QS60MainAppUiBase::HandleSystemEventL(aEvent);
378}
379
380/*!
381 \internal
382*/
383void QS60MainAppUi::Reserved_MtsmPosition()
384{
385 QS60MainAppUiBase::Reserved_MtsmPosition();
386}
387
388/*!
389 \internal
390*/
391void QS60MainAppUi::Reserved_MtsmObject()
392{
393 QS60MainAppUiBase::Reserved_MtsmObject();
394}
395
396/*!
397 \internal
398*/
399void QS60MainAppUi::HandleForegroundEventL(TBool aForeground)
400{
401 QS60MainAppUiBase::HandleForegroundEventL(aForeground);
402}
403
404#ifndef Q_WS_S60
405
406void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {}
407void QS60StubAknAppUi::HandleTouchPaneSizeChange() {}
408void QS60StubAknAppUi::HandleStatusPaneSizeChange() {}
409void QS60StubAknAppUi::Reserved_MtsmPosition() {}
410void QS60StubAknAppUi::Reserved_MtsmObject() {}
411
412#endif
413
414QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.