⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogs.cpp

📁 手机文件浏览程序的另外一个版本! SMan is a system utility that manages your UIQ device. It provides functionality wh
💻 CPP
字号:
#include "dialogs.h"
#include <sman.rsg>

/*************************************************************
*
* Hotkey dialog
*
**************************************************************/

CHotkeyDialog::CHotkeyDialog(TInt *iHotkey)
{
	localiHotkey = iHotkey;
}

TBool CHotkeyDialog::OkToExitL(TInt aButtonId)
{
	if (aButtonId == EEikBidOk)
	{
		// Save the config changes
		CEikChoiceList *myHotkey = STATIC_CAST(CEikChoiceList*, Control(cHotkeyControl));
		*localiHotkey = myHotkey->CurrentItem();

		return ETrue;
	}
	return EFalse;
} 

void CHotkeyDialog::PreLayoutDynInitL()
{
	hotkeyChoiceList = STATIC_CAST(CEikChoiceList*, Control(cHotkeyControl));
	hotkeyChoiceList->SetArrayL(R_HOTKEY_ARRAY);	
	hotkeyChoiceList->SetCurrentItem(*localiHotkey);
}

/*************************************************************
*
* Shortcut dialog
*
**************************************************************/

CShortcutDialog::CShortcutDialog(CArrayFixFlat<TUid> *shortCut)
{
	tempUid = shortCut;
	// For each app we get from the app server, store its caption and uid
	appListArray = new (ELeave) CDesCArrayFlat(3);
	appListUid = new (ELeave) CArrayFixFlat<TUid>(3);
}

CShortcutDialog::~CShortcutDialog(void)
{
	delete appListArray;
	delete appListUid;
}

TBool CShortcutDialog::OkToExitL(TInt aButtonId)
{
	if (aButtonId == EEikBidOk)
	{
		for (int i = 0; i < tempUid->Count(); i++)
		{
			CEikChoiceList *myShortCut = STATIC_CAST(CEikChoiceList*, Control(cShortcut1 + i));
			tempUid->At(i) = appListUid->At(myShortCut->CurrentItem());
		}
		return ETrue;
	}
	return EFalse;
} 

void CShortcutDialog::PreLayoutDynInitL()
{
	int dump;
	TKeyArrayFix keyArray = TKeyArrayFix(0, ECmpTUint);
	
	populateAppArray();
	for (int i = 0; i < tempUid->Count(); i++)
	{
		CEikChoiceList *myShortCut = STATIC_CAST(CEikChoiceList*, Control(cShortcut1 + i));
		myShortCut->SetArrayL(appListArray);
		myShortCut->SetArrayExternalOwnership(ETrue);
		if (appListUid->Find(tempUid->At(i), keyArray, dump) == 0)
		{
			myShortCut->SetCurrentItem(dump);
		}
		else
		{
			myShortCut->SetCurrentItem(0);
			tempUid->At(i) = KNullUid;
		}
	}
}

void CShortcutDialog::populateAppArray(void)
{
	// Scan the list of applications registered with the app server
	// For each shortcut uid, set focus to that item

	RApaLsSession mySession;
	TApaAppInfo theAppInfo;
	TApaAppCapabilityBuf aCapabilityBuf;
	TBuf<10> appUid;
	TBuf<1> bSeparator;
	TApaAppCaption aCaption;
	TUid aUid;
	TPtrC currentCaption, temp, temp1;
	TLex lxUid;
	
	mySession.Connect();
	mySession.GetAllApps();
	bSeparator.Append(255);

	// Query the app server
	while (mySession.GetNextApp(theAppInfo) == KErrNone)
	{
		if (mySession.GetAppCapability(aCapabilityBuf, theAppInfo.iUid) == KErrNone)
		{
			// Only scan applications that are not hidden
			if (aCapabilityBuf().iAppIsHidden == EFalse)
			{
				// For each app we get from the app server, store its caption and uid
				aCaption.Copy(theAppInfo.iCaption);
				aCaption.Append(bSeparator);
				appUid.Format(_L("%u"), theAppInfo.iUid);
				aCaption.Append(appUid);
				appListArray->AppendL(aCaption);
			}
		}
	}
	mySession.Close();
	appListArray->Sort();

	// The first item is for unassigning a shortcut
	aCaption.Format(_L("<unassigned>%c%u"), 255, KNullUid);
	appListArray->InsertL(0, aCaption);

	// After sorting, separate the UIDs out. I'm doing this because I couldn't find a
	// nicer way of linking the UID to the Caption while sorting.
	// The assumption is there is no app with a 0xff char in its caption...pretty safe i
	// think!!
	for (int i = 0; i < appListArray->Count(); i++)
	{		
		// Get app caption & uid
		currentCaption.Set(appListArray->MdcaPoint(i));
		TextUtils::ColumnText(temp, 0, &currentCaption, TChar(255));
		TextUtils::ColumnText(temp1, 1, &currentCaption, TChar(255));
		aCaption.Copy(temp);
		lxUid.Assign(temp1);
		lxUid.Val(aUid.iUid);
		appListUid->AppendL(aUid);
		appListArray->Delete(i);
		appListArray->InsertL(i, aCaption);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -