📄 exelauncherappui.cpp
字号:
/*
* ============================================================================
* Name : CExeLauncherAppUi from ExeLauncherAppui.cpp
* Part of : ExeLauncher
* Created : 01.09.2005 by Artem Marchenko
* Version : 1.0
* Copyright: Artem Marchenko 2005
* ============================================================================
*/
// INCLUDE FILES
#include "ExeLauncherAppui.h"
#include "ExeLauncherContainer.h"
#include <ExeLauncher.rsg>
#include "ExeLauncher.hrh"
#include <avkon.hrh>
#include <EIKDLL.H>
#include <f32file.h>
#include <aknglobalnote.h>
#include <stringloader.h>
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CExeLauncherAppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CExeLauncherAppUi::ConstructL()
{
BaseConstructL();
iAppContainer = new (ELeave) CExeLauncherContainer;
iAppContainer->SetMopParent( this );
iAppContainer->ConstructL( ClientRect() );
AddToStackL( iAppContainer );
}
// ----------------------------------------------------
// CExeLauncherAppUi::~CExeLauncherAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CExeLauncherAppUi::~CExeLauncherAppUi()
{
if (iAppContainer)
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
}
}
// ------------------------------------------------------------------------------
// CExeLauncherAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CExeLauncherAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CExeLauncherAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CExeLauncherAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------
// CExeLauncherAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CExeLauncherAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
// Menu item "Exit"
case EEikCmdExit:
// RSK "Exit"
case EAknSoftkeyExit:
{
Exit();
break;
}
case EExeLauncherCmdAppRun:
{
// Get file name from the current item
CAknSettingItemArray* items = iAppContainer->FileList()->SettingItemArray();
TInt currentIndex = iAppContainer->FileList()->ListBox()->CurrentItemIndex();
CAknSettingItem* item = items->At( currentIndex );
const TDesC& fileName = item->SettingTextL();
RFile file;
// Check for file existance
TInt err = file.Open( iEikonEnv->FsSession(), fileName, EFileShareAny );
if ( (err == KErrNotFound) || ( err == KErrPathNotFound ) ) // file does not exist - create it
{
// Load a string from the resource file.
HBufC* errorString = StringLoader::LoadLC( R_EXEL_ERROR_NOT_FOUND );
// Create Error Note object via CAknGlobalNote API
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL( EAknGlobalErrorNote, *errorString );
// Clean-up
CleanupStack::PopAndDestroy( globalNote );
CleanupStack::PopAndDestroy( errorString );
}
else
{
// File exists. Close used RFile resource and try to run it
file.Close();
// No additional error handling in a tutorial-like application
// In commerical project, we would also check if there are arguments
// in the item content and handle them appropriately
EikDll::StartExeL( fileName );
}
break;
}
case EExeLauncherCmdAppEdit:
{
CSettingItemList* list = iAppContainer->FileList();
const TInt current = list->ListBox()->CurrentItemIndex();
list->EditItemL(current, ETrue);
break;
}
default:
break;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -