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 <QGraphicsLinearLayout> |
|
20 #include <hbaction.h> |
|
21 #include <hbmenu.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")), SIGNAL(triggered()), this, SLOT(SampleMP3())); |
|
59 connect(optionsMenu->addAction(tr("nokiatune.aac")), SIGNAL(triggered()), this, SLOT(Nokiatuneaac())); |
|
60 //connect(optionsMenu->addAction(tr("Quit"))->action(), SIGNAL(triggered()), qApp, SLOT(quit())); |
|
61 } |
|
62 |
|
63 void t_phoneringingtoneplayer::createContent() |
|
64 { |
|
65 QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
66 |
|
67 HbPushButton *ringingButton = new HbPushButton(tr("EProfileRingingTypeRinging"), this); |
|
68 connect(ringingButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneRingning())); |
|
69 |
|
70 HbPushButton *beeponceButton = new HbPushButton(tr("EProfileRingingTypeBeepOnce"), this); |
|
71 connect(beeponceButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneBeepOnce())); |
|
72 |
|
73 HbPushButton *silenceButton = new HbPushButton(tr("EProfileRingingTypeSilent"), this); |
|
74 connect(silenceButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneSilence())); |
|
75 |
|
76 HbPushButton *ttsButton = new HbPushButton(tr("EProfileRingingTypeRinging+tts"), this); |
|
77 connect(ttsButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneTTS())); |
|
78 |
|
79 HbPushButton *ascendingButton = new HbPushButton(tr("EProfileRingingTypeAscending"), this); |
|
80 connect(ascendingButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneAscending())); |
|
81 |
|
82 HbPushButton *ringingonceButton = new HbPushButton(tr("EProfileRingingTypeRingingOnce"), this); |
|
83 connect(ringingonceButton, SIGNAL(clicked()), this, SLOT(PlayRingingtoneOnce())); |
|
84 |
|
85 HbPushButton *stopButton = new HbPushButton(tr("Stop ringingtone"), this); |
|
86 connect(stopButton, SIGNAL(clicked()), this, SLOT(StopRingingtone())); |
|
87 |
|
88 HbPushButton *quitButton = new HbPushButton(tr("Quit"), this); |
|
89 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
90 |
|
91 HbSlider *volumeslider = new HbSlider(this); |
|
92 //volumeslider->setSliderType(HbSlider::VolumeSlider); |
|
93 volumeslider->setOrientation( Qt::Horizontal); |
|
94 volumeslider->setMinimum(EProfileRingingVolumeLevel1); |
|
95 volumeslider->setMaximum(EProfileRingingVolumeLevel10); |
|
96 volumeslider->setSingleStep(1); |
|
97 volumeslider->setValue(m_volume); |
|
98 connect(volumeslider, SIGNAL(valueChanged(int)), this, SLOT(volumeSliderChanged(int))); |
|
99 |
|
100 mainLayout->addItem(volumeslider); |
|
101 mainLayout->addItem(ringingButton); |
|
102 mainLayout->addItem(beeponceButton); |
|
103 mainLayout->addItem(silenceButton); |
|
104 mainLayout->addItem(ttsButton); |
|
105 mainLayout->addItem(ascendingButton); |
|
106 mainLayout->addItem(ringingonceButton); |
|
107 mainLayout->addItem(stopButton); |
|
108 mainLayout->addItem(quitButton); |
|
109 //mainLayout->addStretch(); |
|
110 |
|
111 setLayout(mainLayout); |
|
112 } |
|
113 |
|
114 void t_phoneringingtoneplayer::PlayRingingtoneRingning() |
|
115 { |
|
116 m_ringingtoneplayer->StopPlaying(); |
|
117 TPhoneCmdParamRingTone ringToneParam; |
|
118 ringToneParam.SetVolume(m_volume); |
|
119 ringToneParam.SetRingingType(EProfileRingingTypeRinging); |
|
120 // Set the profile ring tone |
|
121 ringToneParam.SetRingTone( m_ringingtone); |
|
122 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
123 |
|
124 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
125 } |
|
126 |
|
127 void t_phoneringingtoneplayer::PlayRingingtoneBeepOnce() |
|
128 { |
|
129 m_ringingtoneplayer->StopPlaying(); |
|
130 TPhoneCmdParamRingTone ringToneParam; |
|
131 ringToneParam.SetVolume(m_volume); |
|
132 ringToneParam.SetRingingType(EProfileRingingTypeBeepOnce); |
|
133 // Set the profile ring tone |
|
134 ringToneParam.SetRingTone( m_ringingtone); |
|
135 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
136 |
|
137 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
138 } |
|
139 |
|
140 |
|
141 void t_phoneringingtoneplayer::PlayRingingtoneSilence() |
|
142 { |
|
143 m_ringingtoneplayer->StopPlaying(); |
|
144 TPhoneCmdParamRingTone ringToneParam; |
|
145 ringToneParam.SetVolume(m_volume); |
|
146 ringToneParam.SetRingingType(EProfileRingingTypeSilent); |
|
147 // Set the profile ring tone |
|
148 ringToneParam.SetRingTone( m_ringingtone); |
|
149 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
150 |
|
151 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
152 } |
|
153 |
|
154 void t_phoneringingtoneplayer::PlayRingingtoneTTS() |
|
155 { |
|
156 m_ringingtoneplayer->StopPlaying(); |
|
157 _LIT(KTextToSay, "Mr. Brownstone"); |
|
158 TBuf<30> texttosay (KTextToSay); |
|
159 TPhoneCmdParamRingTone ringToneParam; |
|
160 ringToneParam.SetVolume(m_volume); |
|
161 ringToneParam.SetRingingType(EProfileRingingTypeRinging); |
|
162 ringToneParam.SetTextToSay(texttosay); |
|
163 // Set the profile ring tone |
|
164 ringToneParam.SetRingTone( m_ringingtone); |
|
165 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
166 |
|
167 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
168 } |
|
169 |
|
170 void t_phoneringingtoneplayer::PlayRingingtoneAscending() |
|
171 { |
|
172 m_ringingtoneplayer->StopPlaying(); |
|
173 TPhoneCmdParamRingTone ringToneParam; |
|
174 ringToneParam.SetVolume(m_volume); |
|
175 ringToneParam.SetRingingType(EProfileRingingTypeAscending); |
|
176 // Set the profile ring tone |
|
177 ringToneParam.SetRingTone( m_ringingtone); |
|
178 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
179 |
|
180 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
181 } |
|
182 |
|
183 void t_phoneringingtoneplayer::PlayRingingtoneOnce() |
|
184 { |
|
185 m_ringingtoneplayer->StopPlaying(); |
|
186 |
|
187 TPhoneCmdParamRingTone ringToneParam; |
|
188 ringToneParam.SetVolume(m_volume); |
|
189 ringToneParam.SetRingingType(EProfileRingingTypeRingingOnce); |
|
190 // Set the profile ring tone |
|
191 ringToneParam.SetRingTone(m_ringingtone); |
|
192 ringToneParam.SetType( EPhoneRingToneProfile ); |
|
193 |
|
194 m_ringingtoneplayer->PlayRingToneL( &ringToneParam ); |
|
195 } |
|
196 |
|
197 |
|
198 void t_phoneringingtoneplayer::StopRingingtone() |
|
199 { |
|
200 m_ringingtoneplayer->StopPlaying(); |
|
201 } |
|
202 |
|
203 void t_phoneringingtoneplayer::SampleMP3() |
|
204 { |
|
205 m_ringingtone.Format(KSamplemp3); |
|
206 } |
|
207 void t_phoneringingtoneplayer::Nokiatuneaac() |
|
208 { |
|
209 m_ringingtone.Format(KNokiatune); |
|
210 } |
|
211 void t_phoneringingtoneplayer::volumeSliderChanged(int value) |
|
212 { |
|
213 m_volume = value; |
|
214 } |
|