1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtGui/QApplication.h> |
|
19 #include <hbaction.h> |
|
20 #include <hbmenu.h> |
|
21 #include <hbmenuitem.h> |
|
22 #include <hbpushbutton.h> |
|
23 #include <hbslider.h> |
|
24 #include <profile.hrh> |
|
25 #include "t_phoneringingtoneplayer.h" |
|
26 #include "cphoneringingtonecontroller.h" |
|
27 #include "TPhoneCmdParamRingTone.h" |
|
28 |
|
29 |
|
30 _LIT(KNokiatune, "Z:\\Data\\Sounds\\Digital\\Nokia tune.aac"); |
|
31 _LIT(KSamplemp3, "c:\\Data\\Sounds\\Digital\\sample.mp3"); |
|
32 |
|
33 t_phoneringingtoneplayer::t_phoneringingtoneplayer(QGraphicsItem *parent) |
|
34 : HbView(parent), m_volume(10) |
|
35 { |
|
36 setTitle(tr("t_ringingtoneplayer")); |
|
37 createMenu(); |
|
38 createContent(); |
|
39 |
|
40 m_ringingtone.Format(KNokiatune); |
|
41 m_ringingtoneplayer = CPhoneRingingToneController::NewL(); |
|
42 } |
|
43 |
|
44 t_phoneringingtoneplayer::~t_phoneringingtoneplayer() |
|
45 { |
|
46 delete m_ringingtoneplayer; |
|
47 } |
|
48 void t_phoneringingtoneplayer::createMenu() |
|
49 { |
|
50 HbMenu *optionsMenu = menu(); |
|
51 /*connect(optionsMenu->addAction(tr("EProfileRingingTypeRinging"))->action(), SIGNAL(triggered()), this, SLOT(PlayRingingtoneRingning())); |
|
52 connect(optionsMenu->addAction(tr("EProfileRingingTypeBeepOnce"))->action(), SIGNAL(triggered()), this, SLOT(PlayRingingtoneBeepOnce())); |
|
53 connect(optionsMenu->addAction(tr("EProfileRingingTypeSilent"))->action(), SIGNAL(triggered()), this, SLOT(PlayRingingtoneSilence())); |
|
54 connect(optionsMenu->addAction(tr("EProfileRingingTypeRinging+tts"))->action(), SIGNAL(triggered()), this, SLOT(PlayRingingtoneTTS())); |
|
55 connect(optionsMenu->addAction(tr("EProfileRingingTypeAscending"))->action(), SIGNAL(triggered()), this, SLOT(PlayRingingtoneAscending())); |
|
56 connect(optionsMenu->addAction(tr("EProfileRingingTypeRingingOnce"))->action(), SIGNAL(triggered()), this, SLOT(PlayRingingtoneOnce())); |
|
57 connect(optionsMenu->addAction(tr("Stop ringingtone"))->action(), SIGNAL(triggered()), this, SLOT(StopRingingtone())); */ |
|
58 connect(optionsMenu->addAction(tr("sample.mp3"))->action(), SIGNAL(triggered()), this, SLOT(SampleMP3())); |
|
59 connect(optionsMenu->addAction(tr("nokiatune.aac"))->action(), SIGNAL(triggered()), this, SLOT(Nokiatuneaac())); |
|
60 //connect(optionsMenu->addAction(tr("Quit"))->action(), SIGNAL(triggered()), qApp, SLOT(quit())); |
|
61 |
|
62 |
|
63 } |
|
64 |
|
65 void t_phoneringingtoneplayer::createContent() |
|
66 { |
|
67 QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
68 |
|
69 HbPushButton *ringingButton = new HbPushButton(tr("EProfileRingingTypeRinging"), this); |
|
70 connect(ringingButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneRingning())); |
|
71 |
|
72 HbPushButton *beeponceButton = new HbPushButton(tr("EProfileRingingTypeBeepOnce"), this); |
|
73 connect(beeponceButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneBeepOnce())); |
|
74 |
|
75 HbPushButton *silenceButton = new HbPushButton(tr("EProfileRingingTypeSilent"), this); |
|
76 connect(silenceButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneSilence())); |
|
77 |
|
78 HbPushButton *ttsButton = new HbPushButton(tr("EProfileRingingTypeRinging+tts"), this); |
|
79 connect(ttsButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneTTS())); |
|
80 |
|
81 HbPushButton *ascendingButton = new HbPushButton(tr("EProfileRingingTypeAscending"), this); |
|
82 connect(ascendingButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneAscending())); |
|
83 |
|
84 HbPushButton *ringingonceButton = new HbPushButton(tr("EProfileRingingTypeRingingOnce"), this); |
|
85 connect(ringingonceButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneOnce())); |
|
86 |
|
87 HbPushButton *stopButton = new HbPushButton(tr("Stop ringingtone"), this); |
|
88 connect(stopButton, SIGNAL(clicked()), this, SLOT(StopRingingtone())); |
|
89 |
|
90 HbPushButton *quitButton = new HbPushButton(tr("Quit"), this); |
|
91 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
92 |
|
93 HbSlider *volumeslider = new HbSlider(this); |
|
94 //volumeslider->setSliderType(HbSlider::VolumeSlider); |
|
95 volumeslider->setOrientation( Qt::Horizontal); |
|
96 volumeslider->setMinimum(EProfileRingingVolumeLevel1); |
|
97 volumeslider->setMaximum(EProfileRingingVolumeLevel10); |
|
98 volumeslider->setSingleStep(1); |
|
99 volumeslider->setValue(m_volume); |
|
100 connect(volumeslider, SIGNAL(valueChanged(int)), this, SLOT(volumeSliderChanged(int))); |
|
101 |
|
102 mainLayout->addItem(volumeslider); |
|
103 mainLayout->addItem(ringingButton); |
|
104 mainLayout->addItem(beeponceButton); |
|
105 mainLayout->addItem(silenceButton); |
|
106 mainLayout->addItem(ttsButton); |
|
107 mainLayout->addItem(ascendingButton); |
|
108 mainLayout->addItem(ringingonceButton); |
|
109 mainLayout->addItem(stopButton); |
|
110 mainLayout->addItem(quitButton); |
|
111 //mainLayout->addStretch(); |
|
112 |
|
113 setLayout(mainLayout); |
|
114 } |
|
115 |
|
116 void t_phoneringingtoneplayer::PlayRingingtoneRingning() |
|
117 { |
|
118 m_ringingtoneplayer->StopPlaying(); |
|
119 TPhoneCmdParamRingTone ringToneParam; |
|
120 ringToneParam.SetVolume(m_volume); |
|
121 ringToneParam.SetRingingType(EProfileRingingTypeRinging); |
|
122 // Set the profile ring tone |
|
123 ringToneParam.SetRingTone( m_ringingtone); |
|
124 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
125 |
|
126 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
127 } |
|
128 |
|
129 void t_phoneringingtoneplayer::PlayRingingtoneBeepOnce() |
|
130 { |
|
131 m_ringingtoneplayer->StopPlaying(); |
|
132 TPhoneCmdParamRingTone ringToneParam; |
|
133 ringToneParam.SetVolume(m_volume); |
|
134 ringToneParam.SetRingingType(EProfileRingingTypeBeepOnce); |
|
135 // Set the profile ring tone |
|
136 ringToneParam.SetRingTone( m_ringingtone); |
|
137 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
138 |
|
139 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
140 } |
|
141 |
|
142 |
|
143 void t_phoneringingtoneplayer::PlayRingingtoneSilence() |
|
144 { |
|
145 m_ringingtoneplayer->StopPlaying(); |
|
146 TPhoneCmdParamRingTone ringToneParam; |
|
147 ringToneParam.SetVolume(m_volume); |
|
148 ringToneParam.SetRingingType(EProfileRingingTypeSilent); |
|
149 // Set the profile ring tone |
|
150 ringToneParam.SetRingTone( m_ringingtone); |
|
151 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
152 |
|
153 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
154 } |
|
155 |
|
156 void t_phoneringingtoneplayer::PlayRingingtoneTTS() |
|
157 { |
|
158 m_ringingtoneplayer->StopPlaying(); |
|
159 _LIT(KTextToSay, "Mr. Brownstone"); |
|
160 TBuf<30> texttosay (KTextToSay); |
|
161 TPhoneCmdParamRingTone ringToneParam; |
|
162 ringToneParam.SetVolume(m_volume); |
|
163 ringToneParam.SetRingingType(EProfileRingingTypeRinging); |
|
164 ringToneParam.SetTextToSay(texttosay); |
|
165 // Set the profile ring tone |
|
166 ringToneParam.SetRingTone( m_ringingtone); |
|
167 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
168 |
|
169 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
170 } |
|
171 |
|
172 void t_phoneringingtoneplayer::PlayRingingtoneAscending() |
|
173 { |
|
174 m_ringingtoneplayer->StopPlaying(); |
|
175 TPhoneCmdParamRingTone ringToneParam; |
|
176 ringToneParam.SetVolume(m_volume); |
|
177 ringToneParam.SetRingingType(EProfileRingingTypeAscending); |
|
178 // Set the profile ring tone |
|
179 ringToneParam.SetRingTone( m_ringingtone); |
|
180 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
181 |
|
182 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
183 } |
|
184 |
|
185 void t_phoneringingtoneplayer::PlayRingingtoneOnce() |
|
186 { |
|
187 m_ringingtoneplayer->StopPlaying(); |
|
188 |
|
189 TPhoneCmdParamRingTone ringToneParam; |
|
190 ringToneParam.SetVolume(m_volume); |
|
191 ringToneParam.SetRingingType(EProfileRingingTypeRingingOnce); |
|
192 // Set the profile ring tone |
|
193 ringToneParam.SetRingTone(m_ringingtone); |
|
194 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
195 |
|
196 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
197 } |
|
198 |
|
199 |
|
200 void t_phoneringingtoneplayer::StopRingingtone() |
|
201 { |
|
202 m_ringingtoneplayer->StopPlaying(); |
|
203 } |
|
204 |
|
205 void t_phoneringingtoneplayer::SampleMP3() |
|
206 { |
|
207 m_ringingtone.Format(KSamplemp3); |
|
208 } |
|
209 void t_phoneringingtoneplayer::Nokiatuneaac() |
|
210 { |
|
211 m_ringingtone.Format(KNokiatune); |
|
212 } |
|
213 void t_phoneringingtoneplayer::volumeSliderChanged(int value) |
|
214 { |
|
215 m_volume = value; |
|
216 } |
|