×
Namespaces

Variants
Actions

如何更换当前主题

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台:
Symbian

文章
huwell 在 03 Jul 2007 创建
最后由 hamishwillee 在 08 May 2013 编辑
  • 设备, 软件 版本:

S60 3rd Edition


  • 详细描述:

描述

S60第三版SDK并未提供给第三方程序一个方法来更换主题。 但我们可以在

Extensions plug-in package for S60 3rd Edition SDK 获取到我们需要的API.


解决方案

如何更换主题:

1、连接Skin Server

    #include <AknSSrvClient.h> // link against aknskinsrv.lib
 
RAknsSrvSession skinsSession;
 
User::LeaveIfError( skinsSession.Connect( this ) );
 
CleanupClosePushL( skinsSession );


2、获取当前skin的package ID

 #include <centralrepository.h> // link against centralrepository.lib
 
#include <AknSkinsInternalCRKeys.h>
 
void CMyThemeManager::StoreCurrentSkinIdL()
{
 
TAknsPkgIDBuf pidBuf;
 
CRepository* repository = CRepository::NewL(KCRUidPersonalisation );
 
TInt retVal = repository->Get( KPslnActiveSkinUid, pidBuf );
 
delete repository;
 
repository = NULL;
 
iOriginalSkinPid.SetFromDesL( pidBuf ); // iOriginalSkinPid is of type TAknsPkgID
 
}


3、获得已安装skin packages列表

CArrayPtr<CAknsSrvSkinInformationPkg>* skinInfoArray = 
 
skinsSession.EnumerateSkinPackagesL();
 
CleanupStack::PushL( skinInfoArray );


4、查询已安装的主题,确认第一个有效新主题

TInt retValue( KErrNone );
 
if ( skinInfoArray->Count() > 0 )
 
{
 
for ( TInt i = 0; i < skinInfoArray->Count(); i++ )
 
{
 
TAknsPkgID pkgId = skinInfoArray->At( i )->PID();
 
if ( pkgId != iOriginalSkinPid )
 
{
 
// Activates a complete skin package
 
retValue = skinsSession.SetAllDefinitionSets( pkgId );
 
if ( retValue == KErrNone )
 
{
 
SetNewSkinIdL( pkgId );
 
}
 
break;
 
}
 
}
 
}


5、在Central Repository中存储新主题id

    void CMyThemeManager::SetNewSkinIdL( TAknsPkgID aPkgId )
 
{
 
TAknsPkgIDBuf pidBuf;
 
aPkgId.CopyToDes( pidBuf );
 
CRepository* repository = CRepository::NewL( KCRUidPersonalisation );
 
TInt retVal = repository->Set( KPslnActiveSkinUid, pidBuf );
 
// KPslnActiveSkinLocation value needs to be updated
 
// if the new skin resides on memory card and the
 
// previous one resided in phone memory (and vice versa)
 
delete repository;
 
repository = NULL;
 
}
This page was last modified on 8 May 2013, at 03:00.
40 page views in the last 30 days.
×