screengrabber/src/SGAppUi.cpp
changeset 0 d6fe6244b863
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "SGAppUi.h"
       
    21 #include "SGMainView.h"
       
    22 #include "SGSettingListView.h"
       
    23 #include <screengrabber.rsg>
       
    24 #include "SG.hrh"
       
    25 #include "SGModel.h"
       
    26 #include "SGDocument.h"
       
    27 
       
    28 #include <avkon.hrh>
       
    29 #include <AknQueryDialog.h>
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 //
       
    33 // ----------------------------------------------------------
       
    34 // CScreenGrabberAppUi::ConstructL()
       
    35 // ?implementation_description
       
    36 // ----------------------------------------------------------
       
    37 //
       
    38 void CScreenGrabberAppUi::ConstructL()
       
    39     {
       
    40     // disable window server priority control for this application
       
    41     iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
       
    42 
       
    43     BaseConstructL(EAknEnableSkin);
       
    44 
       
    45     iModel = static_cast<CScreenGrabberDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model();
       
    46 
       
    47     CScreenGrabberMainView* view1 = new (ELeave) CScreenGrabberMainView;
       
    48 
       
    49     CleanupStack::PushL( view1 );
       
    50     view1->ConstructL();
       
    51     AddViewL( view1 );      // transfer ownership to CAknViewAppUi
       
    52     CleanupStack::Pop();    // view1
       
    53 
       
    54     CScreenGrabberSettingListView* view2 = new (ELeave) CScreenGrabberSettingListView;
       
    55 
       
    56     CleanupStack::PushL( view2 );
       
    57     view2->ConstructL();
       
    58     AddViewL( view2 );      // transfer ownership to CAknViewAppUi
       
    59     CleanupStack::Pop();    // view2
       
    60 
       
    61     SetDefaultViewL(*view1);
       
    62 
       
    63     // notify the model that everything has been constructed
       
    64     iModel->ActivateModelL();
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------
       
    68 // CScreenGrabberAppUi::~CScreenGrabberAppUi()
       
    69 // Destructor
       
    70 // Frees reserved resources
       
    71 // ----------------------------------------------------
       
    72 //
       
    73 CScreenGrabberAppUi::~CScreenGrabberAppUi()
       
    74     {
       
    75     // notify the model that app ui will be deconstructed
       
    76     if (iModel)
       
    77         TRAP_IGNORE(iModel->DeActivateModelL());
       
    78     }
       
    79 
       
    80 // ------------------------------------------------------------------------------
       
    81 // CScreenGrabberAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
    82 //  This function is called by the EIKON framework just before it displays
       
    83 //  a menu pane. Its default implementation is empty, and by overriding it,
       
    84 //  the application can set the state of menu items dynamically according
       
    85 //  to the state of application data.
       
    86 // ------------------------------------------------------------------------------
       
    87 //
       
    88 void CScreenGrabberAppUi::DynInitMenuPaneL(
       
    89     TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
       
    90     {
       
    91     }
       
    92 
       
    93 // ----------------------------------------------------
       
    94 // CScreenGrabberAppUi::HandleKeyEventL(
       
    95 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
    96 // ?implementation_description
       
    97 // ----------------------------------------------------
       
    98 //
       
    99 TKeyResponse CScreenGrabberAppUi::HandleKeyEventL(
       
   100     const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   101     {
       
   102     return EKeyWasNotConsumed;
       
   103     }
       
   104 
       
   105 // ----------------------------------------------------
       
   106 // CScreenGrabberAppUi::HandleCommandL(TInt aCommand)
       
   107 // ?implementation_description
       
   108 // ----------------------------------------------------
       
   109 //
       
   110 void CScreenGrabberAppUi::HandleCommandL(TInt aCommand)
       
   111     {
       
   112     switch ( aCommand )
       
   113         {
       
   114         // a normal way to close an application
       
   115         case EAknCmdExit:
       
   116         case EEikCmdExit: 
       
   117 			{
       
   118             CAknQueryDialog* exitQuery = CAknQueryDialog::NewL();
       
   119             exitQuery->SetPromptL(_L("Stop taking screen shots and exit?"));
       
   120             if (exitQuery->ExecuteLD(R_MY_GENERAL_CONFIRMATION_QUERY))
       
   121                 {
       
   122                 // pressed yes, exit
       
   123 		        Exit();
       
   124                 }
       
   125             else
       
   126                 {
       
   127                 // pressed no, do nothing
       
   128                 }
       
   129 			}
       
   130             break;
       
   131 
       
   132         default:
       
   133             break;      
       
   134         }
       
   135     }
       
   136 
       
   137 // ----------------------------------------------------
       
   138 // CScreenGrabberAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
       
   139 // ?implementation_description
       
   140 // ----------------------------------------------------
       
   141 //
       
   142 void CScreenGrabberAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
       
   143     {
       
   144     if (iModel->HandleCaptureCommandsL(aEvent))
       
   145       	CAknAppUi::HandleWsEventL(aEvent, aDestination);  //continue the event loop if needed
       
   146     }
       
   147 
       
   148 // End of File