|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Part of the MVS Application for TechView |
|
15 // |
|
16 |
|
17 |
|
18 #include "MVSAudioSettingDialog.h" |
|
19 #include "MVSApp.hrh" |
|
20 |
|
21 |
|
22 void CMVSAudioSettingDialog::SetupDialogLD(TInt aNoRepeats, |
|
23 TTimeIntervalMicroSeconds aTrailingSilence,TInt aAudioPriority, |
|
24 TMdaPriorityPreference aPriorityPreference, TInt& aMaxFileBuf, |
|
25 CMVSAppUi* aAppUi) |
|
26 { |
|
27 CMVSAudioSettingDialog* dialog = new (ELeave) CMVSAudioSettingDialog(aNoRepeats, |
|
28 aTrailingSilence,aAudioPriority, aPriorityPreference, aMaxFileBuf, aAppUi); |
|
29 dialog->ExecuteLD(R_NEW_MVS_DIALOG_AUDIOSETTING); |
|
30 } |
|
31 |
|
32 void CMVSAudioSettingDialog::PreLayoutDynInitL() |
|
33 { |
|
34 CEikNumberEditor* repeatControl = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetRepeats)); |
|
35 CEikNumberEditor* myTrSilenceControl = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetTrailingSilence)); |
|
36 iMaxFileSizeCtrl = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetMaxFileSizeNum)); |
|
37 |
|
38 if(iMaxFileBuf>0) |
|
39 { |
|
40 iMaxFileSizeCtrl->SetNumber(iMaxFileBuf); |
|
41 } |
|
42 else |
|
43 { |
|
44 iMaxFileSizeCtrl->SetNumber(0); |
|
45 } |
|
46 //Now seed the controls with appropriate values |
|
47 if(repeatControl) |
|
48 { |
|
49 repeatControl->SetNumber(iNoRepeats); |
|
50 } |
|
51 if(myTrSilenceControl) |
|
52 { |
|
53 myTrSilenceControl->SetNumber(I64INT(iTrailingSilence.Int64()/1000000)); |
|
54 } |
|
55 // Get a downcasted pointer to the controls |
|
56 CEikChoiceList* audioPriority = static_cast<CEikChoiceList*>(Control(EMVSCmdSetAudioPriority)); |
|
57 |
|
58 CEikChoiceList* audioPriorityPref = static_cast<CEikChoiceList*>(Control(EMVSCmdSetAudioPriorityPreference)); |
|
59 |
|
60 |
|
61 if(audioPriority) |
|
62 { |
|
63 //Set the current item based on the argument passed to the object |
|
64 switch (iAudioPriority) |
|
65 { |
|
66 case(EMdaPriorityMin): |
|
67 audioPriority->SetCurrentItem(0); |
|
68 break; |
|
69 |
|
70 case(EMdaPriorityMax): |
|
71 audioPriority->SetCurrentItem(2); |
|
72 break; |
|
73 |
|
74 case(EMdaPriorityNormal): |
|
75 default: |
|
76 audioPriority->SetCurrentItem(1); |
|
77 break; |
|
78 } |
|
79 } |
|
80 if(audioPriorityPref) |
|
81 { |
|
82 //Set the priority preference based on the argument passed to the object |
|
83 switch (iPriorityPreference) |
|
84 { |
|
85 case(EMdaPriorityPreferenceTime): |
|
86 audioPriorityPref->SetCurrentItem(1); |
|
87 break; |
|
88 |
|
89 case(EMdaPriorityPreferenceQuality): |
|
90 audioPriorityPref->SetCurrentItem(2); |
|
91 break; |
|
92 |
|
93 case(EMdaPriorityPreferenceTimeAndQuality): |
|
94 audioPriorityPref->SetCurrentItem(3); |
|
95 break; |
|
96 |
|
97 case(EMdaPriorityPreferenceNone): |
|
98 default: |
|
99 audioPriorityPref->SetCurrentItem(0); |
|
100 } |
|
101 } |
|
102 } |
|
103 |
|
104 |
|
105 CMVSAudioSettingDialog::CMVSAudioSettingDialog(TInt aNoRepeats, |
|
106 TTimeIntervalMicroSeconds aTrailingSilence,TInt aAudioPriority, |
|
107 TMdaPriorityPreference aPriorityPreference, TInt& aMaxFileBuf, |
|
108 CMVSAppUi* aAppUi) |
|
109 : iAppUi(aAppUi),iAudioPriority(aAudioPriority), iPriorityPreference (aPriorityPreference), |
|
110 iNoRepeats(aNoRepeats),iTrailingSilence(aTrailingSilence), iMaxFileBuf(aMaxFileBuf) |
|
111 { |
|
112 |
|
113 } |
|
114 |
|
115 TKeyResponse CMVSAudioSettingDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
116 { |
|
117 if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown) |
|
118 { |
|
119 OkToExitL(EMVSButtonUpdate); |
|
120 } |
|
121 else if(aKeyEvent.iCode == EKeyEscape && aType == EEventKeyDown) |
|
122 { |
|
123 OkToExitL(EMVSButtonCancel); |
|
124 } |
|
125 return CEikDialog::OfferKeyEventL(aKeyEvent,aType); |
|
126 } |
|
127 |
|
128 TBool CMVSAudioSettingDialog::OkToExitL(TInt aButtonId) |
|
129 { |
|
130 // Get a pointer to the progress bar control. |
|
131 // Downcast the returned CCoeControl* pointer to the correct type. |
|
132 CEikChoiceList* audioPriority = static_cast<CEikChoiceList*>(Control(EMVSCmdSetAudioPriority)); |
|
133 |
|
134 CEikChoiceList* audioPriorityPref = static_cast<CEikChoiceList*>(Control(EMVSCmdSetAudioPriorityPreference)); |
|
135 |
|
136 iMaxFileBuf = iMaxFileSizeCtrl->Number(); |
|
137 iAppUi->SetMaxFileSize(iMaxFileBuf); |
|
138 //Identify current Audio Priority item, and set that |
|
139 if(audioPriority) |
|
140 { |
|
141 switch (audioPriority->CurrentItem()) |
|
142 { |
|
143 case 0: |
|
144 iAudioPriority = EMdaPriorityMin; |
|
145 break; |
|
146 |
|
147 case 1: |
|
148 iAudioPriority = EMdaPriorityNormal; |
|
149 break; |
|
150 |
|
151 case 2: |
|
152 iAudioPriority = EMdaPriorityMax; |
|
153 break; |
|
154 |
|
155 default: |
|
156 iAudioPriority = EMdaPriorityNormal; |
|
157 break; |
|
158 } |
|
159 } |
|
160 |
|
161 //Now do the same for the Priority Preference. |
|
162 if(audioPriorityPref) |
|
163 { |
|
164 switch (audioPriorityPref->CurrentItem()) |
|
165 { |
|
166 case 1: |
|
167 iPriorityPreference = EMdaPriorityPreferenceTime; |
|
168 break; |
|
169 |
|
170 case 2: |
|
171 iPriorityPreference = EMdaPriorityPreferenceQuality; |
|
172 break; |
|
173 |
|
174 case 3: |
|
175 iPriorityPreference = EMdaPriorityPreferenceTimeAndQuality; |
|
176 break; |
|
177 |
|
178 case 0: |
|
179 default: |
|
180 iPriorityPreference = EMdaPriorityPreferenceNone; |
|
181 break; |
|
182 } |
|
183 } |
|
184 iNoRepeats = static_cast<CEikNumberEditor*> |
|
185 (Control(EMVSCmdSetRepeats))->Number(); |
|
186 |
|
187 //Update the trailing silence from the control. |
|
188 TInt64 silence64 = (static_cast<CEikNumberEditor*> |
|
189 (Control(EMVSCmdSetTrailingSilence))->Number()); |
|
190 TInt silence = I64INT(silence64*1000000); |
|
191 TTimeIntervalMicroSeconds theSilence(silence); |
|
192 |
|
193 switch(aButtonId) |
|
194 { |
|
195 case(EMVSButtonUpdate): |
|
196 iAppUi->SetPriorityL(iAudioPriority, iPriorityPreference); |
|
197 iAppUi->SetRepeats(iNoRepeats, theSilence); |
|
198 return ETrue; |
|
199 |
|
200 case(EMVSButtonCancel): |
|
201 return ETrue; |
|
202 default: |
|
203 break; |
|
204 } |
|
205 return ETrue; |
|
206 } |