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

Last change on this file since 787 was 769, checked in by Dmitry A. Kuminov, 15 years ago

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

  • Property svn:eol-style set to native
File size: 9.2 KB
RevLine 
[556]1/****************************************************************************
2**
[651]3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
[556]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 <avkon.hrh>
45#include <eikmenub.h>
46#include <eikmenup.h>
47#include <barsread.h>
[769]48#include <qconfig.h>
49#if defined(QT_LIBINFIX_UNQUOTED)
50// Two level macro needed for proper expansion of libinfix
51# define QT_S60MAIN_RSG_2(x) <s60main##x##.rsg>
52# define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x)
53# include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED)
54#else
55# include <s60main.rsg>
56#endif
[556]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
[769]67//Animated wallpapers in Qt applications are not supported.
68const TInt KAknDisableAnimationBackground = 0x02000000;
69
[556]70QT_BEGIN_NAMESPACE
71
72/*!
73 \class QS60MainAppUi
74 \since 4.6
75 \brief The QS60MainAppUi class is a helper class for S60 migration.
76
77 \warning This class is provided only to get access to S60 specific
78 functionality in the application framework classes. It is not
79 portable. We strongly recommend against using it in new applications.
80
81 The QS60MainAppUi provides a helper class for use in migrating from
82 existing S60 based applications to Qt based applications. It is used
83 in the exact same way as the \c CAknAppUi class from Symbian, but
84 internally provides extensions used by Qt.
85
86 When modifying old S60 applications that rely on implementing
87 functions in \c CAknAppUi, the class should be modified to inherit
88 from this class instead of \c CAknAppUi. Then the application can
89 choose to override only certain functions.
90
91 For more information on \c CAknAppUi, please see the S60
92 documentation.
93
94 Unlike other Qt classes, QS60MainAppUi behaves like an S60 class,
95 and can throw Symbian leaves.
96
97 \sa QS60MainDocument, QS60MainApplication
98 */
99
100/*!
101 * \brief Second phase Symbian constructor.
102 *
103 * Constructs all the elements of the class that can cause a leave to happen.
104 *
105 * If you override this function, you should call the base class implementation as well.
106 */
107void QS60MainAppUi::ConstructL()
108{
109 // Cone's heap and handle checks on app destruction are not suitable for Qt apps, as many
110 // objects can still exist in static data at that point. Instead we will print relevant information
111 // so that comparative checks may be made for memory leaks, using ~SPrintExitInfo in corelib.
112 iEikonEnv->DisableExitChecks(ETrue);
113
114 // Initialise app UI with standard value.
115 // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without
116 // resource files in most SDKs. S60 3rd FP1 public seems to require resource file
117 // even these flags are defined
[769]118 TInt flags = CAknAppUi::EAknEnableSkin
119 | CAknAppUi::ENoScreenFurniture
120 | CAknAppUi::ENonStandardResourceFile;
121 // After 5th Edition S60, native side supports animated wallpapers.
122 // However, there is no support for that feature on Qt side, so indicate to
123 // native UI framework that this application will not support background animations.
124 if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0)
125 flags |= KAknDisableAnimationBackground;
[556]126 BaseConstructL(flags);
127}
128
129/*!
130 * \brief Contructs an instance of QS60MainAppUi.
131 */
132QS60MainAppUi::QS60MainAppUi()
133{
134 // No implementation required
135}
136
137/*!
138 * \brief Destroys the QS60MainAppUi.
139 */
140QS60MainAppUi::~QS60MainAppUi()
141{
142}
143
144/*!
145 * \brief Handles commands produced by the S60 framework.
146 *
147 * \a command holds the ID of the command to handle, and is S60 specific.
148 *
149 * If you override this function, you should call the base class implementation if you do not
150 * handle the command.
151 */
152void QS60MainAppUi::HandleCommandL(TInt command)
153{
154 if (qApp) {
155 QSymbianEvent event(QSymbianEvent::CommandEvent, command);
156 QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
157 }
158}
159
160/*!
161 * \brief Handles a resource change in the S60 framework.
162 *
163 * Resource changes include layout switches. \a type holds the type of resource change that
164 * occurred.
165 *
166 * If you override this function, you should call the base class implementation if you do not
167 * handle the resource change.
168 */
169void QS60MainAppUi::HandleResourceChangeL(TInt type)
170{
171 CAknAppUi::HandleResourceChangeL(type);
172
173 if (qApp) {
174 QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type);
175 QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
176 }
177}
178
179/*!
180 * \brief Handles raw window server events.
181 *
182 * The event type and information is passed in \a wsEvent, while the receiving control is passed in
183 * \a destination.
184 *
185 * If you override this function, you should call the base class implementation if you do not
186 * handle the event.
187 */
188void QS60MainAppUi::HandleWsEventL(const TWsEvent& wsEvent, CCoeControl *destination)
189{
190 int result = 0;
191 if (qApp) {
192 QSymbianEvent event(&wsEvent);
193 QT_TRYCATCH_LEAVING(
194 result = qApp->symbianProcessEvent(&event)
195 );
196 }
197
198 if (result <= 0)
199 CAknAppUi::HandleWsEventL(wsEvent, destination);
200}
201
202
203/*!
204 * \brief Handles changes to the status pane size.
205 *
206 * Called by the framework when the application status pane size is changed.
207 *
208 * If you override this function, you should call the base class implementation if you do not
209 * handle the size change.
210 */
211void QS60MainAppUi::HandleStatusPaneSizeChange()
212{
213 TRAP_IGNORE(HandleResourceChangeL(KInternalStatusPaneChange));
214 HandleStackedControlsResourceChange(KInternalStatusPaneChange);
215}
216
217/*!
218 * \brief Dynamically initializes a menu bar.
219 *
220 * The resource associated with the menu is given in \a resourceId, and the actual menu bar is
221 * passed in \a menuBar.
222 *
223 * If you override this function, you should call the base class implementation as well.
224 */
225void QS60MainAppUi::DynInitMenuBarL(TInt /* resourceId */, CEikMenuBar * /* menuBar */)
226{
227}
228
229/*!
230 * \brief Dynamically initializes a menu pane.
231 *
232 * The resource associated with the menu is given in \a resourceId, and the actual menu pane is
233 * passed in \a menuPane.
234 *
235 * If you override this function, you should call the base class implementation as well.
236 */
237void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane)
238{
239 if (resourceId == R_QT_WRAPPERAPP_MENU) {
240 if (menuPane->NumberOfItemsInPane() <= 1)
241 QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane));
242
243 } else if (resourceId != R_AVKON_MENUPANE_FEP_DEFAULT
244 && resourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT
245 && resourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT) {
246 QT_TRYCATCH_LEAVING(qt_symbian_show_submenu(menuPane, resourceId));
247 }
248}
249
250/*!
251 * \brief Restores a menu window.
252 *
253 * The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given
254 * in \a resourceId and \a menuType, respectively.
255 *
256 * If you override this function, you should call the base class implementation as well.
257 */
258void QS60MainAppUi::RestoreMenuL(CCoeControl* menuWindow, TInt resourceId, TMenuType menuType)
259{
260 if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) {
261 if (menuType == EMenuPane)
262 DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow);
263 else
264 DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow);
265 } else {
266 CAknAppUi::RestoreMenuL(menuWindow, resourceId, menuType);
267 }
268}
269
270QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.