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

📄 oggdialogss80.cpp

📁 OggPlay for Symbian 是symbian上的一个媒体播放程序的源码。它支持ogg,wav等等多媒体格式。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
 *  Copyright (c) 2005 OggPlay Team.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

// Platform settings
#include <OggOs.h>

// This file is for Series 80 only
#if defined(SERIES80)

#include "OggDialogsS80.h"
#include "OggPlay.h"
#include <eiklabel.h>
#include <eikchlst.h>
#include <eikchkbx.h>
#include "OggPlay.hrh"
#include <OggPlay.rsg>
#include <eikon.rsg>
#include <gulbordr.h>
#include <ckndgtrg.h>

#include "OggUserHotkeys.h"


CSettingsS80Dialog::CSettingsS80Dialog(TOggplaySettings *aSettings)
{
  iSettings = aSettings;
}


TBool
CSettingsS80Dialog::OkToExitL(int  /*aButtonId */)
{
  _LIT(KBackslash,"\\");	
 
  iScanDirControl->GetText(iSettings->iCustomScanDir);
  iSettings->iCustomScanDir.TrimAll();
  if (iSettings->iCustomScanDir==KNullDesC)
	  iSettings->iCustomScanDir = KFullScanString;

  if (iSettings->iCustomScanDir==KFullScanString) {
	iSettings->iScanmode = TOggplaySettings::EFullScan;    
  } else {  	
  	iSettings->iScanmode = TOggplaySettings::ECustomDir;    
  	if (iSettings->iCustomScanDir.Right(1)[0]!=KBackslash().Right(1)[0]) {
  		iSettings->iCustomScanDir.Append(KBackslash);
  	}
  }
  
  iSettings->iAutoplay = static_cast <TInt> (iAutostartControl->State());

  UpdateSoftkeysFromControls();
  return ETrue;
}

void
CSettingsS80Dialog::ProcessCommandL(TInt aButtonId)
{
	if (aButtonId==ECbaSelectFolder)
	{
		TBuf<255> temp; 
		iScanDirControl->GetText(temp);
		if (CCknTargetFolderDialog::RunSelectFolderDlgLD(temp))
		{
			iScanDirControl->SetTextL(&temp);
		}
	}
}

void
CSettingsS80Dialog::PreLayoutDynInitL()
{
  iScanDirControl = static_cast <CEikComboBox*> (Control(EOggSettingScanDir));
  iAutostartControl = static_cast <CEikCheckBox*> (Control(EOggSettingAutoPlayId));
  iRepeatControl = static_cast <CEikCheckBox*> (Control(EOggSettingRepeatId));
  iRandomControl = static_cast <CEikCheckBox*> (Control(EOggSettingRandomId));
  iCbaControl[0][0] = static_cast <CEikChoiceList*> (Control(EOggSettingCba01));
  iCbaControl[0][1] = static_cast <CEikChoiceList*> (Control(EOggSettingCba02));
  iCbaControl[0][2] = static_cast <CEikChoiceList*> (Control(EOggSettingCba03));
  iCbaControl[0][3] = static_cast <CEikChoiceList*> (Control(EOggSettingCba04));
  iCbaControl[1][0] = static_cast <CEikChoiceList*> (Control(EOggSettingCba11));
  iCbaControl[1][1] = static_cast <CEikChoiceList*> (Control(EOggSettingCba12));
  iCbaControl[1][2] = static_cast <CEikChoiceList*> (Control(EOggSettingCba13));
  iCbaControl[1][3] = static_cast <CEikChoiceList*> (Control(EOggSettingCba14));
  iVolumeBoostControl = static_cast <CEikChoiceList*> (Control(EOggSettingVolumeBoost));

  iAlarmActiveControl = static_cast<CEikCheckBox*> (Control(EOggAlarmActive));
  iAlarmTimeControl = static_cast<CEikTimeEditor*> (Control(EOggAlarmTime));
  iAlarmSnoozeControl = static_cast<CEikChoiceList*> (Control(EOggAlarmSnooze));
  iAlarmVolumeControl = static_cast<CEikChoiceList*> (Control(EOggAlarmVolume));
  iAlarmBoostControl = static_cast<CEikChoiceList*> (Control(EOggAlarmBoost));

  CDesCArray *listboxArray= new (ELeave) CDesCArrayFlat(10);
  listboxArray->AppendL(KFullScanString); 
  iScanDirControl->SetArray(listboxArray);
  iScanDirControl->SetTextL(&(iSettings->iCustomScanDir));
  iAutostartControl->SetState(static_cast <CEikButtonBase::TState>(iSettings->iAutoplay));
  
  iRepeatControl->SetState(static_cast <CEikButtonBase::TState>(iSettings->iRepeat));
  iRandomControl->SetState(static_cast <CEikButtonBase::TState>(iSettings->iRandom));
  iVolumeBoostControl->SetCurrentItem(iSettings->iGainType);

  iAlarmActiveControl->SetState(static_cast <CEikButtonBase::TState>(iSettings->iAlarmActive));
  iAlarmTimeControl->SetTime(iSettings->iAlarmTime);
  iAlarmSnoozeControl->SetCurrentItem(iSettings->iAlarmSnooze);
  iAlarmVolumeControl->SetCurrentItem(iSettings->iAlarmVolume - 1);
  iAlarmBoostControl->SetCurrentItem(iSettings->iAlarmGain);

  UpdateControlsFromSoftkeys();
}

void 
CSettingsS80Dialog::UpdateSoftkeysFromControls()
{
    // Update softkeys
	for (TInt i=0; i<4; i++)
	{
	    iSettings->iSoftKeysIdle[i] = 
	        COggUserHotkeysS80::MapRssListToCommand(iCbaControl[0][i]->CurrentItem());
        iSettings->iSoftKeysPlay[i] = 
	        COggUserHotkeysS80::MapRssListToCommand(iCbaControl[1][i]->CurrentItem());
	}
}

void 
CSettingsS80Dialog::UpdateControlsFromSoftkeys()
{    
	for (TInt i=0; i<4; i++)
	{	
	   iCbaControl[0][i]->SetCurrentItem( 
	      COggUserHotkeysS80::MapCommandToRssList(iSettings->iSoftKeysIdle[i]) );
	   iCbaControl[1][i]->SetCurrentItem( 
	      COggUserHotkeysS80::MapCommandToRssList(iSettings->iSoftKeysPlay[i]) );
	}
}

void CSettingsS80Dialog::ShowFolderCommand(TBool aShow)
{
	CEikButtonGroupContainer* cba=&(ButtonGroupContainer());
	TBool redrawCba=EFalse; 
	if (aShow)
	{
		if(cba->ControlOrNull(ECbaSelectFolder)==NULL)
			{
			TBuf<30> buf;
			CEikonEnv::Static()->ReadResource( buf, R_SELECT_FOLDER_BUTTON_TEXT );
			cba->SetCommandL(1,ECbaSelectFolder,buf);
			cba->CleanupCommandPushL(1);
			cba->UpdateCommandObserverL(1,*this);
			cba->CleanupCommandPop();
			ButtonGroupContainer().SetDefaultCommand(ECbaSelectFolder);
			redrawCba=ETrue;
			}
	}
	else if(cba->ControlOrNull(ECbaSelectFolder)!=NULL)
		{
		cba->SetCommandL(1,EEikBidBlank,KNullDesC);
		cba->RemoveCommandObserver(1);
		redrawCba=ETrue;
		}

	if(redrawCba) {
		cba->DrawDeferred();}
}

void CSettingsS80Dialog::LineChangedL(TInt aControlId)
{
	if (aControlId==EOggSettingScanDir)
		{
			ShowFolderCommand(ETrue);
		}
	else 
		{
			ShowFolderCommand(EFalse);
		}
}

void CSettingsS80Dialog::HandleControlStateChangeL(TInt aControlId)
{
	COggPlayAppUi * appUi = static_cast <COggPlayAppUi*> (CEikonEnv::Static()->AppUi());
	if (aControlId == EOggSettingRepeatId)
		{
		appUi->SetRepeat(iRepeatControl->State());
		}
	else if (aControlId == EOggSettingRandomId)
		{
		appUi->SetRandomL(iRandomControl->State());
		}
	if (aControlId == EOggSettingVolumeBoost)
		{
		appUi->SetVolumeGainL((TGainType) iVolumeBoostControl->CurrentItem());
		}
	else if (aControlId == EOggAlarmActive)
		{
		appUi->SetAlarm(static_cast <TBool> (iAlarmActiveControl->State()));
		}
	else if (aControlId == EOggAlarmTime)
		{
		appUi->iSettings.iAlarmTime = iAlarmTimeControl->Time();
		appUi->SetAlarmTime();
		}
	else if (aControlId == EOggAlarmSnooze)
		{
		appUi->iSettings.iAlarmSnooze = iAlarmSnoozeControl->CurrentItem();
		appUi->SetAlarmTime();
		}
	else if (aControlId == EOggAlarmVolume)
		{
		appUi->iSettings.iAlarmVolume = iAlarmVolumeControl->CurrentItem() + 1;
		}
	else if (aControlId == EOggAlarmBoost)
		{
		appUi->iSettings.iAlarmGain = iAlarmBoostControl->CurrentItem();
		}
}

void CSettingsS80Dialog::PageChangedL(TInt aPageId)
{
	if(aPageId!=0)
		{
			ShowFolderCommand(EFalse);
		}
}

///////////////////////////////////////////////

CCodecsS80Dialog::CCodecsS80Dialog()
{
}

TBool
CCodecsS80Dialog::OkToExitL(TInt /*aButtonId*/)
{
  for (TInt i=0; i<iNbOfLines; i++)
  {
  	  DeleteLine(555+i);
  }
 
  return(ETrue);
}

void
CCodecsS80Dialog::PreLayoutDynInitL()
  {
    // Build the menu on the fly, according to the list plugins.
  	COggPlayAppUi * appUi = static_cast <COggPlayAppUi*> (CEikonEnv::Static()->AppUi());
    CDesCArrayFlat * extensions = appUi->iOggPlayback->GetPluginListL().SupportedExtensions();
 	CleanupStack::PushL(extensions);
 	
    TInt foo;
    iNbOfLines = extensions->Count();
    for (TInt i=0; i<iNbOfLines; i++)
    {
       CCodecsLabel * ctrl = static_cast<CCodecsLabel *> 
         (CreateLineByTypeL( (*extensions)[i],0, 555+i, EOggCodecPresentationControl,&foo ));
       ctrl->ConstructL( (*extensions)[i] );
    }
    CleanupStack::PopAndDestroy(extensions);
    
    // Change the CBA     
    TBuf<50> tmp;
	iEikonEnv->ReadResource(tmp, R_OGG_CBA_SELECT);
	CEikButtonGroupContainer& cba = ButtonGroupContainer();
    cba.SetCommandL(0,EUserSelectCBA,tmp); 
    cba.UpdateCommandObserverL(0,*this); // We will receive the commands for that button
    cba.DrawNow();
  }

CCodecsS80Dialog::~CCodecsS80Dialog()
{
}

SEikControlInfo CCodecsS80Dialog::CreateCustomControlL(TInt aControlType)
{
    if (aControlType == EOggCodecPresentationControl) 
    { 
        iContainer = new (ELeave) CCodecsLabel();
    } 
    SEikControlInfo info = {iContainer,0,0};
    return info;
}

void CCodecsS80Dialog::ProcessCommandL(TInt aCommandId)
{
	if (aCommandId == EUserSelectCBA)
	{
		// Tell the control that it has been selected.

⌨️ 快捷键说明

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