1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
16 */ |
16 */ |
17 #include <QGraphicsWidget> |
17 #include <QGraphicsWidget> |
18 #include <hblabel.h> |
18 #include <hblabel.h> |
19 #include <hbpushbutton.h> |
19 #include <hbpushbutton.h> |
20 |
20 |
|
21 #ifdef Q_OS_SYMBIAN |
|
22 #include <ProfileEngineSDKCRKeys.h> |
|
23 #endif |
|
24 |
21 #include "cxuiselftimer.h" |
25 #include "cxuiselftimer.h" |
22 #include "cxutils.h" |
26 #include "cxutils.h" |
23 #include "cxuienums.h" |
27 #include "cxuienums.h" |
24 #include "cxuidocumentloader.h" |
28 #include "cxuidocumentloader.h" |
25 #include "cxesettings.h" |
29 #include "cxesettings.h" |
51 mWidgetContainer(NULL), |
55 mWidgetContainer(NULL), |
52 mTimerLabel(NULL), |
56 mTimerLabel(NULL), |
53 mCancelButton(NULL), |
57 mCancelButton(NULL), |
54 mStartButton(NULL), |
58 mStartButton(NULL), |
55 mSettings(settings), |
59 mSettings(settings), |
56 mSound(SELFTIMER_SOUND) |
60 mSound(SELFTIMER_SOUND), |
|
61 mUseSound(true) |
57 { |
62 { |
58 CX_DEBUG_ENTER_FUNCTION(); |
63 CX_DEBUG_ENTER_FUNCTION(); |
59 |
64 |
60 connect(&mTimer, SIGNAL(timeout()), this, SLOT(timeout())); |
65 connect(&mTimer, SIGNAL(timeout()), this, SLOT(timeout())); |
61 mTimer.setSingleShot(false); |
66 mTimer.setSingleShot(false); |
|
67 |
|
68 // connect to capture sound signal in order to monitor |
|
69 // warning tone changes |
|
70 connect(&mSettings, |
|
71 SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
|
72 this, SLOT(enableSound(long int, unsigned long int, QVariant))); |
|
73 |
|
74 // get initial warning tone value from profile |
|
75 QVariant value(0); |
|
76 |
|
77 #ifdef Q_OS_SYMBIAN |
|
78 // get current profile setting for using camerasound |
|
79 // camera sound follows warning tone setting |
|
80 unsigned long int key = KProEngActiveWarningTones; |
|
81 long int uid = KCRUidProfileEngine.iUid; |
|
82 mSettings.get(uid, key, Cxe::Repository, value); |
|
83 #endif |
|
84 |
|
85 // possible values are: |
|
86 // 0 -> warning tones off |
|
87 // 1 -> warning tones on |
|
88 mUseSound = (value.toInt() == 1); |
|
89 CX_DEBUG(("Warning tones enabled [%d]", value.toInt())); |
62 |
90 |
63 CX_DEBUG_EXIT_FUNCTION(); |
91 CX_DEBUG_EXIT_FUNCTION(); |
64 } |
92 } |
65 |
93 |
66 CxuiSelfTimer::~CxuiSelfTimer() |
94 CxuiSelfTimer::~CxuiSelfTimer() |
203 */ |
231 */ |
204 void CxuiSelfTimer::playSound() |
232 void CxuiSelfTimer::playSound() |
205 { |
233 { |
206 CX_DEBUG_ENTER_FUNCTION(); |
234 CX_DEBUG_ENTER_FUNCTION(); |
207 |
235 |
208 int timeLeft = mDelay - mCounter; |
236 // play sounds only if warning tones are enabled |
209 |
237 if (mUseSound) { |
210 if (timeLeft <= 3) { |
238 CX_DEBUG(("play")); |
211 // play as fast as we can |
239 |
212 if (mSound.isFinished()) { |
240 int timeLeft = mDelay - mCounter; |
213 mSound.setLoops(-1); |
241 |
214 mSound.play(); |
242 if (timeLeft <= 3) { |
215 } |
243 // play as fast as we can |
216 } else if (timeLeft <= 10) { |
244 if (mSound.isFinished()) { |
217 // play every second |
245 mSound.setLoops(-1); |
218 mSound.setLoops(1); |
246 mSound.play(); |
219 mSound.play(); |
247 } |
220 } else { |
248 } else if (timeLeft <= 10) { |
221 // play once every two seconds |
249 // play every second |
222 if (mCounter%2) { |
|
223 mSound.setLoops(1); |
250 mSound.setLoops(1); |
224 mSound.play(); |
251 mSound.play(); |
|
252 } else { |
|
253 // play once every two seconds |
|
254 if (mCounter%2) { |
|
255 mSound.setLoops(1); |
|
256 mSound.play(); |
|
257 } |
225 } |
258 } |
226 } |
259 } |
227 |
260 |
228 CX_DEBUG_EXIT_FUNCTION(); |
261 CX_DEBUG_EXIT_FUNCTION(); |
229 } |
262 } |
354 { |
387 { |
355 if (mWidgetContainer){ |
388 if (mWidgetContainer){ |
356 mWidgetContainer->hide(); |
389 mWidgetContainer->hide(); |
357 } |
390 } |
358 |
391 |
359 |
392 } |
360 |
393 |
361 } |
394 /*! |
|
395 * Enables or disables the selftimer sound. |
|
396 * \param uid UID of the changed setting |
|
397 * \param key Key of the changed setting |
|
398 * \param value New setting value |
|
399 */ |
|
400 void CxuiSelfTimer::enableSound(long int uid, unsigned long int key, QVariant value) |
|
401 { |
|
402 #ifdef Q_OS_SYMBIAN |
|
403 // selftimer is only interested in warning tones |
|
404 if (uid == KCRUidProfileEngine.iUid && key == KProEngActiveWarningTones) { |
|
405 CX_DEBUG_IN_FUNCTION(); |
|
406 // possible values are: |
|
407 // 0 -> warning tones off |
|
408 // 1 -> warning tones on |
|
409 mUseSound = (value.toInt() == 1); |
|
410 } |
|
411 #else |
|
412 Q_UNUSED(uid); |
|
413 Q_UNUSED(key); |
|
414 Q_UNUSED(value); |
|
415 #endif |
|
416 } |
|
417 |