src/gui/s60framework/qs60mainappui.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 // INCLUDE FILES
    42 // INCLUDE FILES
    43 #include <exception>
    43 #include <exception>
       
    44 #include <qglobal.h>
       
    45 #ifdef Q_WS_S60
    44 #include <avkon.hrh>
    46 #include <avkon.hrh>
    45 #include <eikmenub.h>
    47 #include <eikmenub.h>
    46 #include <eikmenup.h>
    48 #include <eikmenup.h>
       
    49 #include <avkon.rsg>
       
    50 #endif
    47 #include <barsread.h>
    51 #include <barsread.h>
    48 #include <qconfig.h>
    52 #include <qconfig.h>
    49 #if defined(QT_LIBINFIX_UNQUOTED)
    53 #ifdef Q_WS_S60
       
    54 #  if defined(QT_LIBINFIX_UNQUOTED)
    50 // Two level macro needed for proper expansion of libinfix
    55 // Two level macro needed for proper expansion of libinfix
    51 #  define QT_S60MAIN_RSG_2(x) <s60main##x##.rsg>
    56 #    define QT_S60MAIN_RSG_2(x) <s60main##x##.rsg>
    52 #  define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x)
    57 #    define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x)
    53 #  include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED)
    58 #    include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED)
    54 #else
    59 #  else
    55 #  include <s60main.rsg>
    60 #    include <s60main.rsg>
    56 #endif
    61 #  endif
    57 #include <avkon.rsg>
    62 #endif
    58 
    63 
    59 #include "qs60mainappui.h"
    64 #include "qs60mainappui.h"
    60 #include <QtGui/qapplication.h>
    65 #include <QtGui/qapplication.h>
    61 #include <QtGui/qsymbianevent.h>
    66 #include <QtGui/qsymbianevent.h>
    62 #include <QtGui/qmenu.h>
    67 #include <QtGui/qmenu.h>
    63 #include <private/qmenu_p.h>
    68 #include <private/qmenu_p.h>
    64 #include <private/qt_s60_p.h>
    69 #include <private/qt_s60_p.h>
    65 #include <qdebug.h>
    70 #include <qdebug.h>
    66 
    71 
       
    72 //Animated wallpapers in Qt applications are not supported.
       
    73 const TInt KAknDisableAnimationBackground = 0x02000000;
       
    74 
    67 QT_BEGIN_NAMESPACE
    75 QT_BEGIN_NAMESPACE
    68 
    76 
    69 /*!
    77 /*!
    70   \class QS60MainAppUi
    78   \class QS60MainAppUi
    71   \since 4.6
    79   \since 4.6
   110 
   118 
   111     // Initialise app UI with standard value.
   119     // Initialise app UI with standard value.
   112     // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without
   120     // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without
   113     // resource files in most SDKs. S60 3rd FP1 public seems to require resource file
   121     // resource files in most SDKs. S60 3rd FP1 public seems to require resource file
   114     // even these flags are defined
   122     // even these flags are defined
   115     TInt flags = CAknAppUi::EAknEnableSkin
   123     TInt flags = CEikAppUi::ENoScreenFurniture
   116                  | CAknAppUi::ENoScreenFurniture
   124                | CEikAppUi::ENonStandardResourceFile;
   117                  | CAknAppUi::ENonStandardResourceFile;
   125 #ifdef Q_WS_S60
       
   126     flags |= CAknAppUi::EAknEnableSkin;
       
   127     // After 5th Edition S60, native side supports animated wallpapers.
       
   128 	// However, there is no support for that feature on Qt side, so indicate to
       
   129 	// native UI framework that this application will not support background animations.
       
   130     if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0)
       
   131         flags |= KAknDisableAnimationBackground;
       
   132 #endif
   118     BaseConstructL(flags);
   133     BaseConstructL(flags);
   119 }
   134 }
   120 
   135 
   121 /*!
   136 /*!
   122  * \brief Contructs an instance of QS60MainAppUi.
   137  * \brief Contructs an instance of QS60MainAppUi.
   158  * If you override this function, you should call the base class implementation if you do not
   173  * If you override this function, you should call the base class implementation if you do not
   159  * handle the resource change.
   174  * handle the resource change.
   160  */
   175  */
   161 void QS60MainAppUi::HandleResourceChangeL(TInt type)
   176 void QS60MainAppUi::HandleResourceChangeL(TInt type)
   162 {
   177 {
   163     CAknAppUi::HandleResourceChangeL(type);
   178     QS60MainAppUiBase::HandleResourceChangeL(type);
   164 
   179 
   165     if (qApp) {
   180     if (qApp) {
   166         QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type);
   181         QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type);
   167         QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
   182         QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
   168     }
   183     }
   175  * \a destination.
   190  * \a destination.
   176  *
   191  *
   177  * If you override this function, you should call the base class implementation if you do not
   192  * If you override this function, you should call the base class implementation if you do not
   178  * handle the event.
   193  * handle the event.
   179  */
   194  */
   180 void QS60MainAppUi::HandleWsEventL(const TWsEvent& wsEvent, CCoeControl *destination)
   195 void QS60MainAppUi::HandleWsEventL(const TWsEvent &wsEvent, CCoeControl *destination)
   181 {
   196 {
   182     int result = 0;
   197     int result = 0;
   183     if (qApp) {
   198     if (qApp) {
   184         QSymbianEvent event(&wsEvent);
   199         QSymbianEvent event(&wsEvent);
   185         QT_TRYCATCH_LEAVING(
   200         QT_TRYCATCH_LEAVING(
   186             result = qApp->symbianProcessEvent(&event)
   201             result = qApp->symbianProcessEvent(&event)
   187         );
   202         );
   188     }
   203     }
   189 
   204 
   190     if (result <= 0)
   205     if (result <= 0)
   191         CAknAppUi::HandleWsEventL(wsEvent, destination);
   206         QS60MainAppUiBase::HandleWsEventL(wsEvent, destination);
   192 }
   207 }
   193 
   208 
   194 
   209 
   195 /*!
   210 /*!
   196  * \brief Handles changes to the status pane size.
   211  * \brief Handles changes to the status pane size.
   226  *
   241  *
   227  * If you override this function, you should call the base class implementation as well.
   242  * If you override this function, you should call the base class implementation as well.
   228  */
   243  */
   229 void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane)
   244 void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane)
   230 {
   245 {
       
   246 #ifdef Q_WS_S60
   231     if (resourceId == R_QT_WRAPPERAPP_MENU) {
   247     if (resourceId == R_QT_WRAPPERAPP_MENU) {
   232         if (menuPane->NumberOfItemsInPane() <= 1)
   248         if (menuPane->NumberOfItemsInPane() <= 1)
   233             QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane));
   249             QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane));
   234 
   250 
   235     } else if (resourceId != R_AVKON_MENUPANE_FEP_DEFAULT
   251     } else if (resourceId != R_AVKON_MENUPANE_FEP_DEFAULT
   236             && resourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT
   252             && resourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT
   237             && resourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT) {
   253             && resourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT) {
   238         QT_TRYCATCH_LEAVING(qt_symbian_show_submenu(menuPane, resourceId));
   254         QT_TRYCATCH_LEAVING(qt_symbian_show_submenu(menuPane, resourceId));
   239     }
   255     }
       
   256 #else
       
   257     QS60MainAppUiBase::DynInitMenuPaneL(resourceId, menuPane);
       
   258 #endif
   240 }
   259 }
   241 
   260 
   242 /*!
   261 /*!
   243  * \brief Restores a menu window.
   262  * \brief Restores a menu window.
   244  *
   263  *
   245  * The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given
   264  * The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given
   246  * in \a resourceId and \a menuType, respectively.
   265  * in \a resourceId and \a menuType, respectively.
   247  *
   266  *
   248  * If you override this function, you should call the base class implementation as well.
   267  * If you override this function, you should call the base class implementation as well.
   249  */
   268  */
   250 void QS60MainAppUi::RestoreMenuL(CCoeControl* menuWindow, TInt resourceId, TMenuType menuType)
   269 void QS60MainAppUi::RestoreMenuL(CCoeControl *menuWindow, TInt resourceId, TMenuType menuType)
   251 {
   270 {
       
   271 #ifdef Q_WS_S60
   252     if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) {
   272     if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) {
   253         if (menuType == EMenuPane)
   273         if (menuType == EMenuPane)
   254             DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow);
   274             DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow);
   255         else
   275         else
   256             DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow);
   276             DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow);
   257     } else {
   277     } else
   258         CAknAppUi::RestoreMenuL(menuWindow, resourceId, menuType);
   278 #endif
   259     }
   279     {
   260 }
   280         QS60MainAppUiBase::RestoreMenuL(menuWindow, resourceId, menuType);
       
   281     }
       
   282 }
       
   283 
       
   284 void QS60MainAppUi::Exit()
       
   285 {
       
   286     QS60MainAppUiBase::Exit();
       
   287 }
       
   288 
       
   289 void QS60MainAppUi::SetFadedL(TBool aFaded)
       
   290 {
       
   291     QS60MainAppUiBase::SetFadedL(aFaded);
       
   292 }
       
   293 
       
   294 TRect QS60MainAppUi::ApplicationRect() const
       
   295 {
       
   296     return QS60MainAppUiBase::ApplicationRect();
       
   297 }
       
   298 
       
   299 void QS60MainAppUi::HandleScreenDeviceChangedL()
       
   300 {
       
   301     QS60MainAppUiBase::HandleScreenDeviceChangedL();
       
   302 }
       
   303 
       
   304 void QS60MainAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent &aEvent)
       
   305 {
       
   306     QS60MainAppUiBase::HandleApplicationSpecificEventL(aType, aEvent);
       
   307 }
       
   308 
       
   309 TTypeUid::Ptr QS60MainAppUi::MopSupplyObject(TTypeUid aId)
       
   310 {
       
   311     return QS60MainAppUiBase::MopSupplyObject(aId);
       
   312 }
       
   313 
       
   314 void QS60MainAppUi::ProcessCommandL(TInt aCommand)
       
   315 {
       
   316     QS60MainAppUiBase::ProcessCommandL(aCommand);
       
   317 }
       
   318 
       
   319 TErrorHandlerResponse QS60MainAppUi::HandleError (TInt aError, const SExtendedError &aExtErr, TDes &aErrorText, TDes &aContextText)
       
   320 {
       
   321     return QS60MainAppUiBase::HandleError(aError, aExtErr, aErrorText, aContextText);
       
   322 }
       
   323 
       
   324 void QS60MainAppUi::HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId)
       
   325 {
       
   326     QS60MainAppUiBase::HandleViewDeactivation(aViewIdToBeDeactivated, aNewlyActivatedViewId);
       
   327 }
       
   328 
       
   329 void QS60MainAppUi::PrepareToExit()
       
   330 {
       
   331     QS60MainAppUiBase::PrepareToExit();
       
   332 }
       
   333 
       
   334 void QS60MainAppUi::HandleTouchPaneSizeChange()
       
   335 {
       
   336     QS60MainAppUiBase::HandleTouchPaneSizeChange();
       
   337 }
       
   338 
       
   339 void QS60MainAppUi::HandleSystemEventL(const TWsEvent &aEvent)
       
   340 {
       
   341     QS60MainAppUiBase::HandleSystemEventL(aEvent);
       
   342 }
       
   343 
       
   344 void QS60MainAppUi::Reserved_MtsmPosition()
       
   345 {
       
   346     QS60MainAppUiBase::Reserved_MtsmPosition();
       
   347 }
       
   348 
       
   349 void QS60MainAppUi::Reserved_MtsmObject()
       
   350 {
       
   351     QS60MainAppUiBase::Reserved_MtsmObject();
       
   352 }
       
   353 
       
   354 void QS60MainAppUi::HandleForegroundEventL(TBool aForeground)
       
   355 {
       
   356     QS60MainAppUiBase::HandleForegroundEventL(aForeground);
       
   357 }
       
   358 
       
   359 #ifndef Q_WS_S60
       
   360 
       
   361 void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {}
       
   362 void QS60StubAknAppUi::HandleTouchPaneSizeChange() {}
       
   363 void QS60StubAknAppUi::HandleStatusPaneSizeChange() {}
       
   364 void QS60StubAknAppUi::Reserved_MtsmPosition() {}
       
   365 void QS60StubAknAppUi::Reserved_MtsmObject() {}
       
   366 
       
   367 #endif
   261 
   368 
   262 QT_END_NAMESPACE
   369 QT_END_NAMESPACE