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