|
1 /* |
|
2 * Copyright (c) 2010 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: FM Radio home screen widget |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <HbPushButton> |
|
20 #include <HbLabel> |
|
21 #include <HbDocumentLoader> |
|
22 #include <HbFrameDrawer> |
|
23 #include <HbIcon> |
|
24 #include <HbIconAnimationManager> |
|
25 #include <HbIconAnimationDefinition> |
|
26 #include <HbColorScheme> |
|
27 #include <HbDeviceMessageBox> |
|
28 #include <QGraphicsLinearLayout> |
|
29 #include <QGraphicsItem> |
|
30 #include <QDesktopServices> |
|
31 #include <QSignalMapper> |
|
32 |
|
33 // User includes |
|
34 #include "radiohswidget.h" |
|
35 #include "radiohswidgetprofilereader.h" |
|
36 #include "radiohswidgetradioserviceclient.h" |
|
37 #include "radioservicedef.h" |
|
38 #include "radio_global.h" |
|
39 #include "radiologger.h" |
|
40 |
|
41 // Constants |
|
42 /** Path to docml file */ |
|
43 const QString DOCML(":/ui/resource/fmradiohswidget.docml"); |
|
44 |
|
45 /** DOCML object name for mainLayout */ |
|
46 const QString DOCML_OBJECT_NAME_MAIN_LAYOUT("mainLayout"); |
|
47 /** DOCML object name for contentLayout */ |
|
48 const QString DOCML_OBJECT_NAME_CONTENT_LAYOUT("contentLayout"); |
|
49 /** DOCML object name for tunerBackgroundPushButton */ |
|
50 const QString DOCML_OBJECT_NAME_TUNER_BACKGROUND_BUTTON( |
|
51 "tunerBackgroundPushButton"); |
|
52 /** DOCML object name for tunerStackedLayout */ |
|
53 const QString DOCML_OBJECT_NAME_TUNER_STACKED_LAYOUT("tunerStackedLayout"); |
|
54 /** DOCML object name for tunerInformationStackedLayout */ |
|
55 const QString DOCML_OBJECT_NAME_TUNER_INFORMATION_STACKED_LAYOUT( |
|
56 "tunerInformationStackedLayout"); |
|
57 /** DOCML object name for controlButtons */ |
|
58 const QString DOCML_OBJECT_NAME_CONTROL_BUTTONS_LAYOUT("controlButtons"); |
|
59 /** DOCML object name for powerToggleButton */ |
|
60 const QString DOCML_OBJECT_NAME_POWER_BUTTON("powerButton"); |
|
61 /** DOCML object name for previousPushButton */ |
|
62 const QString DOCML_OBJECT_NAME_PREVIOUS_BUTTON("previousPushButton"); |
|
63 /** DOCML object name for nextPushButton */ |
|
64 const QString DOCML_OBJECT_NAME_NEXT_BUTTON("nextPushButton"); |
|
65 /** DOCML object name for twoRowsLayout */ |
|
66 const QString DOCML_OBJECT_NAME_TWO_ROWS_LAYOUT("twoRowsLayout"); |
|
67 /** DOCML object name for firstRowLabel */ |
|
68 const QString DOCML_OBJECT_NAME_FIRST_ROW_LABEL("firstRowLabel"); |
|
69 /** DOCML object name for secondRowLabel */ |
|
70 const QString DOCML_OBJECT_NAME_SECOND_ROW_LABEL("secondRowLabel"); |
|
71 /** DOCML object name for lonelyRowLabel */ |
|
72 const QString DOCML_OBJECT_NAME_LONELY_ROW_LABEL("lonelyRowLabel"); |
|
73 /** DOCML object name for animationIcon */ |
|
74 const QString DOCML_OBJECT_NAME_ANIMATION_ICON("animationIcon"); |
|
75 |
|
76 /** Unknown favorite station count. */ |
|
77 const int FAVORITE_STATION_COUNT_UNDEFINED(-1); |
|
78 /** One favorite station set. */ |
|
79 const int FAVORITE_STATION_COUNT_ONE(1); |
|
80 /** Favorite station count lower boundary including this number. */ |
|
81 const int FAVORITE_STATION_COUNT_LOWER_BOUNDARY(0); |
|
82 /** Favorite station count upper boundary including this number. */ |
|
83 const int FAVORITE_STATION_COUNT_UPPER_BOUNDARY(100); |
|
84 |
|
85 // Graphics identifiers for different push button states |
|
86 const QString CONTROL_BUTTON_GRAPHICS_NORMAL ("qtg_fr_hsbutton_normal"); |
|
87 const QString CONTROL_BUTTON_GRAPHICS_PRESSED ("qtg_fr_hsbutton_pressed"); |
|
88 const QString CONTROL_BUTTON_GRAPHICS_DISABLED("qtg_fr_hsbutton_disabled"); |
|
89 const QString CONTROL_BUTTON_GRAPHICS_LATCHED ("qtg_fr_hsbutton_latched"); |
|
90 |
|
91 // Push button icon colors for each of the states (normal, pressed, disabled |
|
92 // and latched) |
|
93 const QString CONTROL_BUTTON_ICON_COLOR_NORMAL ("qtc_button_normal"); |
|
94 const QString CONTROL_BUTTON_ICON_COLOR_PRESSED ("qtc_button_pressed"); |
|
95 const QString CONTROL_BUTTON_ICON_COLOR_DISABLED("qtc_button_disabled"); |
|
96 const QString CONTROL_BUTTON_ICON_COLOR_LATCHED ("qtc_button_latched"); |
|
97 |
|
98 // File name suffix lists for push buttons |
|
99 const QStringList POWER_BUTTON_SUFFIX( |
|
100 (QStringList() << "_l" << "_c" << "_cr")); |
|
101 const QStringList PREVIOUS_BUTTON_SUFFIX( |
|
102 (QStringList() << "_cl" << "_c" << "_cr")); |
|
103 const QStringList NEXT_BUTTON_SUFFIX( |
|
104 (QStringList() << "_cl" << "_c" << "_r")); |
|
105 |
|
106 /** Icon for power button off. */ |
|
107 const QString POWER_BUTTON_ICON_OFF("qtg_mono_power"); |
|
108 /** Icon for power button on. */ |
|
109 const QString POWER_BUTTON_ICON_ON ("qtg_mono_power"); |
|
110 |
|
111 // Tuner background button graphics for different states. |
|
112 const QString TUNER_BUTTON_NORMAL_OFF("qtg_fr_tuner"); |
|
113 const QString TUNER_BUTTON_NORMAL_ON("qtg_fr_tuner"); |
|
114 const QString TUNER_BUTTON_NORMAL_PRESSED("qtg_fr_hsitems2_pressed"); |
|
115 |
|
116 /*! |
|
117 \class RadioHsWidget |
|
118 \brief Implementation of FM Radio home screen widget. |
|
119 |
|
120 RadioHsWidget implements needed functions for the FM Radio home screen |
|
121 widget. |
|
122 */ |
|
123 |
|
124 // ======== MEMBER FUNCTIONS ======== |
|
125 |
|
126 /*! |
|
127 Constructs a widget which is a child of \a parent, with widget flags set |
|
128 to \a flags. |
|
129 |
|
130 Constructor should be empty and all the actual construction should be |
|
131 done in onInitialize(). |
|
132 */ |
|
133 RadioHsWidget::RadioHsWidget(QGraphicsItem* parent, Qt::WindowFlags flags) |
|
134 : HbWidget(parent, flags), |
|
135 mInformationAreaBackgroundButton(NULL), |
|
136 mPowerButton(NULL), |
|
137 mPreviousButton(NULL), |
|
138 mNextButton(NULL), |
|
139 mInformationAreaTwoRowsLayout(NULL), |
|
140 mInformationLonelyRowLabel(NULL), |
|
141 mInformationFirstRowLabel(NULL), |
|
142 mInformationSecondRowLabel(NULL), |
|
143 mAnimationIcon(NULL), |
|
144 mFmRadioState(FmRadio::StateUndefined), |
|
145 mFavoriteStationCount(FAVORITE_STATION_COUNT_UNDEFINED), |
|
146 mCurrentStationIsFavorite(false), |
|
147 mProfileMonitor(NULL), |
|
148 mRadioServiceClient(NULL) |
|
149 { |
|
150 LOG_METHOD; |
|
151 } |
|
152 |
|
153 /*! |
|
154 Destructor |
|
155 */ |
|
156 RadioHsWidget::~RadioHsWidget() |
|
157 { |
|
158 LOG_METHOD; |
|
159 } |
|
160 |
|
161 /*! |
|
162 Handles changes in FM Radio information. |
|
163 |
|
164 \param informationType Type of changed information. |
|
165 \param information Actual information. |
|
166 */ |
|
167 void RadioHsWidget::handleRadioInformationChange(const int informationType, |
|
168 const QVariant &information) |
|
169 { |
|
170 LOG_METHOD; |
|
171 switch (informationType) { |
|
172 |
|
173 case RadioServiceNotification::FavoriteCount: |
|
174 LOG("FavoriteCount"); |
|
175 if (information.canConvert(QVariant::Int) && |
|
176 information.toInt() >= FAVORITE_STATION_COUNT_LOWER_BOUNDARY && |
|
177 information.toInt() <= FAVORITE_STATION_COUNT_UPPER_BOUNDARY) { |
|
178 mFavoriteStationCount = information.toInt(); |
|
179 // If there are favorite stations, enable the next/previous |
|
180 // buttons. |
|
181 LOG_FORMAT("mFavoriteStationCount: %d", mFavoriteStationCount); |
|
182 // Enable or disable buttons only if favoriteCount differs |
|
183 // from 1. CurrentIsFavorite case handles situation when there |
|
184 // is only one favorite station. |
|
185 if (mFavoriteStationCount != FAVORITE_STATION_COUNT_ONE) { |
|
186 enableStationButtons(); |
|
187 } |
|
188 } else { |
|
189 mFavoriteStationCount = FAVORITE_STATION_COUNT_UNDEFINED; |
|
190 } |
|
191 break; |
|
192 |
|
193 case RadioServiceNotification::CurrentIsFavorite: |
|
194 LOG("CurrentIsFavorite"); |
|
195 if (information.canConvert(QVariant::Bool)) { |
|
196 mCurrentStationIsFavorite = information.toBool(); |
|
197 LOG_FORMAT("currentIsFavorite: %d", mCurrentStationIsFavorite); |
|
198 // If current station is favorite disable next/prev buttons. |
|
199 // Radio sends this information only when there is only one |
|
200 // favorite station set. |
|
201 enableStationButtons(); |
|
202 } |
|
203 break; |
|
204 |
|
205 case RadioServiceNotification::RadioStatus: |
|
206 LOG("RadioStatus"); |
|
207 if (information.canConvert(QVariant::Int)) { |
|
208 const int status = information.toInt(); |
|
209 switch (status) { |
|
210 case RadioStatus::Playing: |
|
211 LOG("Playing"); |
|
212 break; |
|
213 case RadioStatus::Muted: |
|
214 LOG("Muted"); |
|
215 break; |
|
216 case RadioStatus::Seeking: |
|
217 LEVEL2(LOG("Seeking")); |
|
218 handleRadioStateChange(FmRadio::StateSeeking); |
|
219 break; |
|
220 case RadioStatus::NoAntenna: |
|
221 LEVEL2(LOG("NoAntenna")); |
|
222 handleRadioStateChange(FmRadio::StateAntennaNotConnected); |
|
223 break; |
|
224 case RadioStatus::PoweringOff: |
|
225 LEVEL2(LOG("PoweringOff")); |
|
226 handleRadioStateChange(FmRadio::StateClosing); |
|
227 break; |
|
228 default: |
|
229 LOG("default case at case RadioStatus"); |
|
230 break; |
|
231 } |
|
232 } |
|
233 break; |
|
234 |
|
235 case RadioServiceNotification::Frequency: |
|
236 LOG("Frequency"); |
|
237 // TODO: Should information.toString() be checked for too many characters? What's the limit? |
|
238 if (information.canConvert(QVariant::String)) { |
|
239 LOG_FORMAT("frequency: %s", GETSTRING(information.toString())); |
|
240 // TODO: Remove comment when localisation is working on device. |
|
241 //frequencyString = hbTrId("txt_fmradiohswidget_rad_list_l1_mhz").arg(freqString); |
|
242 bool frequencyCleared = false; |
|
243 // If widget has some frequency information and new frequency |
|
244 // differs from that |
|
245 if (mRadioInformation.contains(Frequency) |
|
246 && mRadioInformation[Frequency].compare(information.toString()) != 0) { |
|
247 // Clear all infromation from widget because station has changed. |
|
248 clearRadioInformation(); |
|
249 frequencyCleared = true; |
|
250 } |
|
251 // If widget do not have any frquency information, update it. |
|
252 bool frequencyUpdated = updateRadioInformation(Frequency, |
|
253 information.toString()); |
|
254 if (frequencyCleared || frequencyUpdated) { |
|
255 // Information changed, update the UI. |
|
256 changeInRadioInformation(); |
|
257 } |
|
258 } |
|
259 break; |
|
260 |
|
261 case RadioServiceNotification::Name: |
|
262 LOG("Name"); |
|
263 handleSimilarRadioInformation(StationName, information); |
|
264 break; |
|
265 |
|
266 case RadioServiceNotification::Genre: |
|
267 LOG("Genre"); |
|
268 handleSimilarRadioInformation(Pty, information); |
|
269 break; |
|
270 |
|
271 case RadioServiceNotification::RadioText: |
|
272 LOG("RadioText"); |
|
273 handleSimilarRadioInformation(RadioText, information); |
|
274 break; |
|
275 |
|
276 case RadioServiceNotification::DynamicPS: |
|
277 LOG("DynamicPS"); |
|
278 handleSimilarRadioInformation(DynamicPsName, information); |
|
279 break; |
|
280 |
|
281 default: |
|
282 LOG("default case at notificationId"); |
|
283 break; |
|
284 } |
|
285 } |
|
286 |
|
287 /*! |
|
288 Handles changes in FM Radio state. |
|
289 |
|
290 \param value New state of the radio application. |
|
291 */ |
|
292 void RadioHsWidget::handleRadioStateChange(const QVariant &value) |
|
293 { |
|
294 LOG_METHOD; |
|
295 int state; |
|
296 if (value.canConvert(QVariant::Int)) { |
|
297 state = value.toInt(); |
|
298 } else { |
|
299 return; |
|
300 } |
|
301 |
|
302 if (state == mFmRadioState) { |
|
303 // State did not change, so return. |
|
304 return; |
|
305 } |
|
306 |
|
307 switch (state) { |
|
308 case FmRadio::StateUndefined: |
|
309 LOG("FmRadio::StateUndefined"); |
|
310 // Something went wrong. Widget should not be in this state after onInitialize(). |
|
311 mFmRadioState = FmRadio::StateUndefined; |
|
312 break; |
|
313 case FmRadio::StateNotRunning: |
|
314 LOG("FmRadio::StateNotRunning"); |
|
315 mFmRadioState = FmRadio::StateNotRunning; |
|
316 mRadioServiceClient->stopMonitoring(); |
|
317 changePowerButtonOn(false); |
|
318 mFavoriteStationCount = FAVORITE_STATION_COUNT_UNDEFINED; |
|
319 mCurrentStationIsFavorite = false; |
|
320 enableStationButtons(); |
|
321 clearRadioInformation(); |
|
322 mInformationFirstRowLabel->setPlainText(""); |
|
323 mInformationSecondRowLabel->setPlainText(""); |
|
324 mInformationLonelyRowLabel->setPlainText(hbTrId("txt_fmradiohswidget_rad_list_fm_radio")); |
|
325 changeInformationAreaLayout(OneRow); |
|
326 break; |
|
327 case FmRadio::StateStarting: |
|
328 LOG("FmRadio::StateStarting"); |
|
329 mFmRadioState = FmRadio::StateStarting; |
|
330 changePowerButtonOn(true); |
|
331 mFavoriteStationCount = FAVORITE_STATION_COUNT_UNDEFINED; |
|
332 mCurrentStationIsFavorite = false; |
|
333 enableStationButtons(); |
|
334 changeInformationAreaLayout(Animation); |
|
335 break; |
|
336 case FmRadio::StateRunning: |
|
337 LOG("FmRadio::StateRunning"); |
|
338 mFmRadioState = FmRadio::StateRunning; |
|
339 // Stop timer if it is running because radio is now running. |
|
340 mRadioServiceClient->startMonitoring( |
|
341 FmRadio::VisibiltyDoNotChange); |
|
342 changePowerButtonOn(true); |
|
343 enableStationButtons(); |
|
344 changeInformationAreaLayout(OneRow); |
|
345 break; |
|
346 case FmRadio::StateSeeking: |
|
347 LOG("FmRadio::StateSeeking"); |
|
348 mFmRadioState = FmRadio::StateSeeking; |
|
349 mFavoriteStationCount = FAVORITE_STATION_COUNT_UNDEFINED; |
|
350 mCurrentStationIsFavorite = false; |
|
351 enableStationButtons(); |
|
352 changeInformationAreaLayout(Animation); |
|
353 break; |
|
354 case FmRadio::StateAntennaNotConnected: |
|
355 LOG("FmRadio::StateAntennaNotConnected"); |
|
356 mFmRadioState = FmRadio::StateAntennaNotConnected; |
|
357 mFavoriteStationCount = FAVORITE_STATION_COUNT_UNDEFINED; |
|
358 mCurrentStationIsFavorite = false; |
|
359 enableStationButtons(); |
|
360 mInformationFirstRowLabel->setPlainText(""); |
|
361 mInformationSecondRowLabel->setPlainText(""); |
|
362 mInformationLonelyRowLabel->setPlainText(hbTrId( |
|
363 "txt_fmradiohswidget_rad_info_connect_wired_headset")); |
|
364 changeInformationAreaLayout(OneRow); |
|
365 break; |
|
366 case FmRadio::StateClosing: |
|
367 LOG("FmRadio::StateClosing"); |
|
368 mFmRadioState = FmRadio::StateClosing; |
|
369 changePowerButtonOn(false); |
|
370 mFavoriteStationCount = FAVORITE_STATION_COUNT_UNDEFINED; |
|
371 mCurrentStationIsFavorite = false; |
|
372 enableStationButtons(); |
|
373 clearRadioInformation(); |
|
374 mInformationFirstRowLabel->setPlainText(""); |
|
375 mInformationSecondRowLabel->setPlainText(""); |
|
376 mInformationLonelyRowLabel->setPlainText(hbTrId( |
|
377 "txt_fmradiohswidget_rad_list_fm_radio")); |
|
378 changeInformationAreaLayout(OneRow); |
|
379 break; |
|
380 default: |
|
381 LOG_FORMAT("default case at state. State: %d", state); |
|
382 break; |
|
383 } |
|
384 } |
|
385 |
|
386 /*! |
|
387 Called when widget is initialized. Constructs objects and connects them. |
|
388 */ |
|
389 void RadioHsWidget::onInitialize() |
|
390 { |
|
391 LOG_METHOD_ENTER; |
|
392 mProfileMonitor = new RadioHsWidgetProfileReader(this); |
|
393 mRadioServiceClient = new RadioHsWidgetRadioServiceClient(this); |
|
394 |
|
395 load(DOCML); |
|
396 |
|
397 // Use signal mapper to indicate button identifiers to button event |
|
398 // slots. |
|
399 QSignalMapper* signalMapperPressed = new QSignalMapper(this); |
|
400 signalMapperPressed->setMapping(mPowerButton, Power); |
|
401 signalMapperPressed->setMapping(mPreviousButton, Previous); |
|
402 signalMapperPressed->setMapping(mNextButton, Next); |
|
403 |
|
404 // Need to use different signal mapper for pressed and released events, |
|
405 // both have same mappings but they are mapped to different slots. |
|
406 QSignalMapper* signalMapperReleased = new QSignalMapper(this); |
|
407 signalMapperReleased->setMapping(mPowerButton, Power); |
|
408 signalMapperReleased->setMapping(mPreviousButton, Previous); |
|
409 signalMapperReleased->setMapping(mNextButton, Next); |
|
410 |
|
411 // Connect button events to signal maps. |
|
412 Radio::connect(mPowerButton, SIGNAL(pressed()), signalMapperPressed, SLOT (map())); |
|
413 Radio::connect(mPowerButton, SIGNAL(released()), signalMapperReleased, SLOT (map())); |
|
414 Radio::connect(mPreviousButton, SIGNAL(pressed()), signalMapperPressed, SLOT (map())); |
|
415 Radio::connect(mPreviousButton, SIGNAL(released()), signalMapperReleased, SLOT (map())); |
|
416 Radio::connect(mNextButton, SIGNAL(pressed()), signalMapperPressed, SLOT (map())); |
|
417 Radio::connect(mNextButton, SIGNAL(released()), signalMapperReleased, SLOT (map())); |
|
418 |
|
419 // Connect mapper signals to self implemented slots. |
|
420 Radio::connect(signalMapperPressed, SIGNAL(mapped(int)), this, SLOT(changeButtonToPressed(int))); |
|
421 Radio::connect(signalMapperReleased, SIGNAL(mapped(int)), this, SLOT(changeButtonToReleased(int))); |
|
422 |
|
423 mProfileMonitor->startMonitoringRadioRunningStatus(); |
|
424 } |
|
425 |
|
426 /*! |
|
427 Called when widget is shown in the home screen |
|
428 */ |
|
429 void RadioHsWidget::onShow() |
|
430 { |
|
431 LOG_METHOD_ENTER; |
|
432 } |
|
433 |
|
434 /*! |
|
435 Called when widget is hidden from the home screen |
|
436 */ |
|
437 void RadioHsWidget::onHide() |
|
438 { |
|
439 LOG_METHOD_ENTER; |
|
440 } |
|
441 |
|
442 /*! |
|
443 Emited from HbPushButton:pressed() signal, changes the button layout to |
|
444 pressed state. |
|
445 |
|
446 \param hsButtonIdentifier Identifies the button which was pressed. |
|
447 */ |
|
448 void RadioHsWidget::changeButtonToPressed(int hsButtonIdentifier) |
|
449 { |
|
450 LEVEL2(LOG_METHOD); |
|
451 buttonEvent(static_cast<ControlButtonIdentifier>(hsButtonIdentifier), Pressed); |
|
452 } |
|
453 |
|
454 /*! |
|
455 Emited from HbPushButton:released() signal, changes the button layout to |
|
456 normal state. |
|
457 |
|
458 \param hsButtonIdentifier Identifies the button which was released. |
|
459 */ |
|
460 void RadioHsWidget::changeButtonToReleased(int hsButtonIdentifier) |
|
461 { |
|
462 LEVEL2(LOG_METHOD); |
|
463 buttonEvent(static_cast<ControlButtonIdentifier>(hsButtonIdentifier), Normal); |
|
464 } |
|
465 |
|
466 /*! |
|
467 Slot for closing FM Radio application from power button. |
|
468 */ |
|
469 void RadioHsWidget::closeRadio() |
|
470 { |
|
471 LOG_SLOT_CALLER; |
|
472 mRadioServiceClient->commandFmRadio(RadioServiceCommand::PowerOff); |
|
473 } |
|
474 |
|
475 /*! |
|
476 Slot for previous button clicked. |
|
477 */ |
|
478 void RadioHsWidget::changeToPreviousStation() |
|
479 { |
|
480 LOG_SLOT_CALLER; |
|
481 clearRadioInformation(); |
|
482 mRadioServiceClient->commandFmRadio(RadioServiceCommand::Previous); |
|
483 } |
|
484 |
|
485 /*! |
|
486 Slot for next button clicked. |
|
487 */ |
|
488 void RadioHsWidget::changeToNextStation() |
|
489 { |
|
490 LOG_SLOT_CALLER; |
|
491 clearRadioInformation(); |
|
492 mRadioServiceClient->commandFmRadio(RadioServiceCommand::Next); |
|
493 |
|
494 } |
|
495 |
|
496 /*! |
|
497 Slot for bringing the radio application to foreground. |
|
498 */ |
|
499 void RadioHsWidget::changeRadioToForeground() |
|
500 { |
|
501 LOG_SLOT_CALLER; |
|
502 // If radio is not running start it to foreground by monitor request. |
|
503 if (mFmRadioState == FmRadio::StateNotRunning) { |
|
504 bool okToStartRadio = radioStartPermission(); |
|
505 if (okToStartRadio) { |
|
506 handleRadioStateChange(FmRadio::StateStarting); |
|
507 mRadioServiceClient->startMonitoring( |
|
508 FmRadio::VisibiltyToForeground); |
|
509 } |
|
510 } |
|
511 else { |
|
512 if (mFmRadioState == FmRadio::StateClosing) { |
|
513 // Radio is closing but user wants to power it up again. |
|
514 mRadioServiceClient->commandFmRadio(RadioServiceCommand::PowerOn); |
|
515 // Stop and start monitoring to get refresh. |
|
516 mRadioServiceClient->stopMonitoring(); |
|
517 mRadioServiceClient->startMonitoring( |
|
518 FmRadio::VisibiltyToBackground); |
|
519 handleRadioStateChange(FmRadio::StateRunning); |
|
520 } |
|
521 // If radio is running, bring it to the foreground. |
|
522 mRadioServiceClient->commandFmRadio(RadioServiceCommand::Foreground); |
|
523 } |
|
524 } |
|
525 |
|
526 /*! |
|
527 Slot for putting the radio application to the background. |
|
528 */ |
|
529 void RadioHsWidget::changeRadioToBackground() |
|
530 { |
|
531 LOG_SLOT_CALLER; |
|
532 // If radio is not running start it to background by monitor request. |
|
533 if (mFmRadioState == FmRadio::StateNotRunning) { |
|
534 bool okToStartRadio = radioStartPermission(); |
|
535 if (okToStartRadio) { |
|
536 handleRadioStateChange(FmRadio::StateStarting); |
|
537 mRadioServiceClient->startMonitoring( |
|
538 FmRadio::VisibiltyToBackground); |
|
539 } |
|
540 } |
|
541 else if (mFmRadioState == FmRadio::StateStarting) { |
|
542 // Do nothing if radio is starting. |
|
543 } |
|
544 else if (mFmRadioState == FmRadio::StateClosing) { |
|
545 // Radio is closing but user wants to power it up again. |
|
546 mRadioServiceClient->commandFmRadio(RadioServiceCommand::PowerOn); |
|
547 // Stop and start monitoring to get refresh. |
|
548 mRadioServiceClient->stopMonitoring(); |
|
549 mRadioServiceClient->startMonitoring( |
|
550 FmRadio::VisibiltyToBackground); |
|
551 handleRadioStateChange(FmRadio::StateRunning); |
|
552 } |
|
553 else { |
|
554 // If radio is running, put it to the background. |
|
555 // This is little bit useless because the radio is in background if |
|
556 // user is able to click the widget. |
|
557 mRadioServiceClient->commandFmRadio(RadioServiceCommand::Background); |
|
558 } |
|
559 } |
|
560 |
|
561 /*! |
|
562 Powering off or on the radio. |
|
563 */ |
|
564 void RadioHsWidget::toggleRadioPower() |
|
565 { |
|
566 LOG_SLOT_CALLER; |
|
567 // If radio is not running start it to background by monitor request. |
|
568 if (mFmRadioState == FmRadio::StateNotRunning || mFmRadioState == FmRadio::StateClosing) { |
|
569 LEVEL2(LOG("Power on")); |
|
570 // Start radio |
|
571 changeRadioToBackground(); |
|
572 } else { |
|
573 LEVEL2(LOG("Power off")); |
|
574 // Close radio |
|
575 closeRadio(); |
|
576 } |
|
577 } |
|
578 |
|
579 /*! |
|
580 Loads docml file. |
|
581 |
|
582 \param docml Docml filename to be loaded. |
|
583 */ |
|
584 void RadioHsWidget::load(const QString &docml) |
|
585 { |
|
586 LOG_METHOD_ENTER; |
|
587 |
|
588 QScopedPointer<HbDocumentLoader> documentLoader(new HbDocumentLoader()); |
|
589 bool loaded = false; |
|
590 documentLoader->load(docml, &loaded); |
|
591 if (loaded) { |
|
592 // Find mainLayout |
|
593 HbWidget *mainLayout = qobject_cast<HbWidget*> ( |
|
594 documentLoader->findWidget(DOCML_OBJECT_NAME_MAIN_LAYOUT)); |
|
595 |
|
596 if (mainLayout) { |
|
597 QGraphicsLinearLayout *widgetLayout = new QGraphicsLinearLayout( |
|
598 Qt::Vertical, this); |
|
599 widgetLayout->addItem(mainLayout); |
|
600 setLayout(widgetLayout); |
|
601 } |
|
602 |
|
603 // Find contentLayout |
|
604 HbWidget *contentLayout = qobject_cast<HbWidget*> ( |
|
605 documentLoader->findWidget(DOCML_OBJECT_NAME_CONTENT_LAYOUT)); |
|
606 if (contentLayout) { |
|
607 |
|
608 // Find stacked layout for tuner area. |
|
609 HbWidget *tunerStackedLayout = qobject_cast<HbWidget*> ( |
|
610 documentLoader->findWidget( |
|
611 DOCML_OBJECT_NAME_TUNER_STACKED_LAYOUT)); |
|
612 if (tunerStackedLayout) { |
|
613 |
|
614 // Find stacked layout for information area. |
|
615 HbWidget *tunerInformationStackedLayout = qobject_cast< |
|
616 HbWidget*> (documentLoader->findWidget( |
|
617 DOCML_OBJECT_NAME_TUNER_INFORMATION_STACKED_LAYOUT)); |
|
618 if (tunerInformationStackedLayout) { |
|
619 } |
|
620 |
|
621 // Find lonely label |
|
622 mInformationLonelyRowLabel = qobject_cast<HbLabel *> ( |
|
623 documentLoader->findWidget( |
|
624 DOCML_OBJECT_NAME_LONELY_ROW_LABEL)); |
|
625 if (mInformationLonelyRowLabel) { |
|
626 // TODO: Set the color in docml when application designer supports it. |
|
627 QColor color = HbColorScheme::color( |
|
628 "qtc_radio_tuner_normal"); |
|
629 mInformationLonelyRowLabel->setTextColor(color); |
|
630 } |
|
631 |
|
632 // Find layout for two rows |
|
633 mInformationAreaTwoRowsLayout = qobject_cast< |
|
634 QGraphicsWidget *> (documentLoader->findObject( |
|
635 DOCML_OBJECT_NAME_TWO_ROWS_LAYOUT)); |
|
636 if (mInformationAreaTwoRowsLayout) { |
|
637 // Find first row |
|
638 mInformationFirstRowLabel = qobject_cast<HbLabel *> ( |
|
639 documentLoader->findWidget( |
|
640 DOCML_OBJECT_NAME_FIRST_ROW_LABEL)); |
|
641 if (mInformationFirstRowLabel) { |
|
642 // TODO: Set the color in docml when application designer supports it. |
|
643 QColor color = HbColorScheme::color( |
|
644 "qtc_radio_tuner_normal"); |
|
645 mInformationFirstRowLabel->setTextColor(color); |
|
646 } |
|
647 |
|
648 // Find second row |
|
649 mInformationSecondRowLabel = qobject_cast<HbLabel *> ( |
|
650 documentLoader->findWidget( |
|
651 DOCML_OBJECT_NAME_SECOND_ROW_LABEL)); |
|
652 if (mInformationSecondRowLabel) { |
|
653 // TODO: Set the color in docml when application designer supports it. |
|
654 QColor color = HbColorScheme::color( |
|
655 "qtc_radio_tuner_normal"); |
|
656 mInformationSecondRowLabel->setTextColor(color); |
|
657 } |
|
658 } |
|
659 |
|
660 mAnimationIcon = qobject_cast<HbLabel *> ( |
|
661 documentLoader->findWidget( |
|
662 DOCML_OBJECT_NAME_ANIMATION_ICON)); |
|
663 if (mAnimationIcon) { |
|
664 // Use animation manager to access anim loading animation. |
|
665 HbIconAnimationManager *animationManager = |
|
666 HbIconAnimationManager::global(); |
|
667 // TODO: Axml extension can be removed after wk24 release. |
|
668 animationManager->addDefinitionFile(QLatin1String( |
|
669 "qtg_anim_loading.axml")); |
|
670 mAnimationIcon->setIcon(HbIcon("qtg_anim_loading")); |
|
671 } |
|
672 } |
|
673 |
|
674 // Find push button for tuner area. |
|
675 mInformationAreaBackgroundButton = qobject_cast<HbPushButton*> ( |
|
676 documentLoader->findWidget( |
|
677 DOCML_OBJECT_NAME_TUNER_BACKGROUND_BUTTON)); |
|
678 if (mInformationAreaBackgroundButton) { |
|
679 // Use the frame background. |
|
680 HbFrameDrawer *tunerBackgroundButtonFrameDrawer = |
|
681 new HbFrameDrawer("qtg_fr_tuner", |
|
682 HbFrameDrawer::ThreePiecesHorizontal); |
|
683 tunerBackgroundButtonFrameDrawer->setFillWholeRect(true); |
|
684 mInformationAreaBackgroundButton->setFrameBackground( |
|
685 tunerBackgroundButtonFrameDrawer); |
|
686 // Connect the button's clicked signal. |
|
687 Radio::connect(mInformationAreaBackgroundButton, |
|
688 SIGNAL(clicked()), this, SLOT(changeRadioToForeground())); |
|
689 } |
|
690 |
|
691 // Find layout for control buttons. |
|
692 HbWidget *controlButtonsLayout = qobject_cast<HbWidget*> ( |
|
693 documentLoader->findWidget( |
|
694 DOCML_OBJECT_NAME_CONTROL_BUTTONS_LAYOUT)); |
|
695 if (controlButtonsLayout) { |
|
696 |
|
697 // Find power button. |
|
698 mPowerButton |
|
699 = qobject_cast<HbPushButton *> ( |
|
700 documentLoader->findWidget( |
|
701 DOCML_OBJECT_NAME_POWER_BUTTON)); |
|
702 if (mPowerButton) { |
|
703 defineButton(*mPowerButton, |
|
704 CONTROL_BUTTON_GRAPHICS_NORMAL, POWER_BUTTON_SUFFIX, |
|
705 POWER_BUTTON_ICON_ON, |
|
706 CONTROL_BUTTON_ICON_COLOR_NORMAL); |
|
707 // Connect the button's clicked signal. |
|
708 Radio::connect(mPowerButton, SIGNAL(clicked()), this, |
|
709 SLOT(toggleRadioPower())); |
|
710 } |
|
711 |
|
712 // Find previous button. |
|
713 mPreviousButton = qobject_cast<HbPushButton *> ( |
|
714 documentLoader->findWidget( |
|
715 DOCML_OBJECT_NAME_PREVIOUS_BUTTON)); |
|
716 if (mPreviousButton) { |
|
717 defineButton(*mPreviousButton, |
|
718 CONTROL_BUTTON_GRAPHICS_DISABLED, |
|
719 PREVIOUS_BUTTON_SUFFIX, NULL, |
|
720 CONTROL_BUTTON_ICON_COLOR_DISABLED); |
|
721 // Connect the button's clicked signal. |
|
722 Radio::connect(mPreviousButton, SIGNAL(clicked()), this, |
|
723 SLOT(changeToPreviousStation())); |
|
724 } |
|
725 |
|
726 // Find next button. |
|
727 mNextButton |
|
728 = qobject_cast<HbPushButton *> ( |
|
729 documentLoader->findWidget( |
|
730 DOCML_OBJECT_NAME_NEXT_BUTTON)); |
|
731 if (mNextButton) { |
|
732 defineButton(*mNextButton, |
|
733 CONTROL_BUTTON_GRAPHICS_DISABLED, NEXT_BUTTON_SUFFIX, |
|
734 NULL, CONTROL_BUTTON_ICON_COLOR_DISABLED); |
|
735 // Connect the button's clicked signal. |
|
736 Radio::connect(mNextButton, SIGNAL(clicked()), this, |
|
737 SLOT(changeToNextStation())); |
|
738 } |
|
739 } |
|
740 } |
|
741 } |
|
742 else { |
|
743 // Docml was not succesfully loaded. UI cannot be displayed. |
|
744 // Emit error to home screen framework, which removes the widget. |
|
745 emit error(); |
|
746 } |
|
747 } |
|
748 |
|
749 /*! |
|
750 Groups handling of similar kind of radio information (textual) to one |
|
751 function. |
|
752 |
|
753 \param informationType Type of changed information. |
|
754 \param information Actual textual information. |
|
755 */ |
|
756 void RadioHsWidget::handleSimilarRadioInformation( |
|
757 const FmRadioInformationType informationType, const QVariant &information) |
|
758 { |
|
759 LOG_METHOD_ENTER; |
|
760 // TODO: Should information.toString() be checked for too many characters? What's the limit? |
|
761 if (information.canConvert(QVariant::String) && updateRadioInformation( |
|
762 informationType, information.toString())) { |
|
763 LOG_FORMAT("informationType: %d, information: %s", informationType, GETSTRING(information.toString())); |
|
764 changeInRadioInformation(); |
|
765 } |
|
766 } |
|
767 |
|
768 /*! |
|
769 Check if the the radio information is changed. If it is changed, it is |
|
770 also updated. |
|
771 |
|
772 \param informationType Type of the information. |
|
773 \param information Information text. |
|
774 |
|
775 \returns Returns \c true, if information is updated. Returns \c false otherwise. |
|
776 */ |
|
777 bool RadioHsWidget::updateRadioInformation(const FmRadioInformationType informationType, |
|
778 const QString &information) |
|
779 { |
|
780 LOG_METHOD_RET("%d"); |
|
781 // If hash contains this type of information. |
|
782 if (mRadioInformation.contains(informationType)) { |
|
783 // If new information is empty. |
|
784 if (information.isEmpty()) { |
|
785 // Remove old information from the hash. |
|
786 LEVEL2(LOG_FORMAT("informationType: %s removed", GETSTRING(informationType))); |
|
787 mRadioInformation.remove(informationType); |
|
788 // Return true to indicate the change. |
|
789 return true; |
|
790 } |
|
791 // If new information differs from the old one. |
|
792 if (mRadioInformation[informationType].compare(information) != 0) { |
|
793 // Update the information. |
|
794 LEVEL2(LOG_FORMAT("informationType: %s = %s", GETSTRING(informationType), GETSTRING(information))); |
|
795 mRadioInformation[informationType] = information; |
|
796 // And return true to indicate the change. |
|
797 return true; |
|
798 } |
|
799 } else { // Hash do not contain this type of information. |
|
800 // If new information is not empty. |
|
801 if (!information.isEmpty()) { |
|
802 // Add it to the hash. |
|
803 LEVEL2(LOG_FORMAT("informationType: %s = %s", GETSTRING(informationType), GETSTRING(information))); |
|
804 mRadioInformation[informationType] = information; |
|
805 // Return true to indicate the change. |
|
806 return true; |
|
807 } |
|
808 } |
|
809 // Return false to indicate that nothing changed. |
|
810 return false; |
|
811 } |
|
812 |
|
813 /*! |
|
814 Formatting radio information texts after a change. |
|
815 */ |
|
816 void RadioHsWidget::changeInRadioInformation() |
|
817 { |
|
818 LOG_METHOD_ENTER; |
|
819 // Clear the rows. |
|
820 mRadioInformationFirstRow.clear(); |
|
821 mRadioInformationSecondRow.clear(); |
|
822 |
|
823 // First row contains station name. |
|
824 if (mRadioInformation.contains(StationName)) { |
|
825 mRadioInformationFirstRow.append(mRadioInformation.value(StationName)); |
|
826 } |
|
827 else if (mRadioInformation.contains(Frequency)) { |
|
828 // Or frequency. |
|
829 mRadioInformationFirstRow.append(mRadioInformation.value(Frequency)); |
|
830 } LEVEL2(LOG_FORMAT("mRadioInformationFirstRow: %s", GETSTRING(mRadioInformationFirstRow))); |
|
831 |
|
832 // Second row of information contains radio text. |
|
833 if (mRadioInformation.contains(RadioText)) { |
|
834 mRadioInformationSecondRow.append(mRadioInformation.value(RadioText)); |
|
835 } |
|
836 else if (mRadioInformation.contains(DynamicPsName)) { |
|
837 // Or Dynamic PS name. |
|
838 mRadioInformationSecondRow.append(mRadioInformation.value(DynamicPsName)); |
|
839 } |
|
840 else if (mRadioInformation.contains(Pty)) { |
|
841 // Or PTY. |
|
842 mRadioInformationSecondRow.append(mRadioInformation.value(Pty)); |
|
843 } |
|
844 LEVEL2(LOG_FORMAT("mRadioInformationSecondRow: %s", GETSTRING(mRadioInformationSecondRow))); |
|
845 |
|
846 // If second row is empty. |
|
847 if (mRadioInformationSecondRow.isEmpty()) { |
|
848 // Show only the lonely row. |
|
849 mInformationLonelyRowLabel->setPlainText(mRadioInformationFirstRow); |
|
850 changeInformationAreaLayout(OneRow); |
|
851 } |
|
852 else { |
|
853 // Else display both rows. |
|
854 mInformationFirstRowLabel->setPlainText(mRadioInformationFirstRow); |
|
855 mInformationSecondRowLabel->setPlainText(mRadioInformationSecondRow); |
|
856 changeInformationAreaLayout(TwoRows); |
|
857 } |
|
858 } |
|
859 |
|
860 /*! |
|
861 Clears the radio station information. For example, when the station is |
|
862 changed, old information should be cleared. |
|
863 */ |
|
864 void RadioHsWidget::clearRadioInformation() |
|
865 { |
|
866 LOG_METHOD_ENTER; |
|
867 mRadioInformation.clear(); |
|
868 } |
|
869 |
|
870 /*! |
|
871 Changes visible widgets of information area stacked layout. |
|
872 |
|
873 \param layout The layout to switch visible. |
|
874 */ |
|
875 void RadioHsWidget::changeInformationAreaLayout(const InformationAreaLayout layout) |
|
876 { |
|
877 LOG_METHOD_ENTER; |
|
878 mInformationLonelyRowLabel->setVisible(layout == OneRow); |
|
879 mInformationAreaTwoRowsLayout->setVisible(layout == TwoRows); |
|
880 mAnimationIcon->setVisible(layout == Animation); |
|
881 } |
|
882 |
|
883 /*! |
|
884 Changes state of power button. |
|
885 |
|
886 \param isPowerOn \c true the power is on and \c false the power is off. |
|
887 */ |
|
888 void RadioHsWidget::changePowerButtonOn(const bool isPowerOn) |
|
889 { |
|
890 LEVEL2(LOG_METHOD); |
|
891 if (isPowerOn) { |
|
892 LEVEL2(LOG("Power on")); |
|
893 // TODO: Temporarily set the text to clarify the action it performs. |
|
894 // Remove when graphics displays the difference. |
|
895 mPowerButton->setText("Off"); |
|
896 buttonEvent(Power, Latched); |
|
897 } else { |
|
898 LEVEL2(LOG("Power off")); |
|
899 // TODO: Temporarily set the text to clarify the action it performs. |
|
900 // Remove when graphics displays the difference. |
|
901 mPowerButton->setText("On"); |
|
902 buttonEvent(Power, Normal); |
|
903 } |
|
904 } |
|
905 |
|
906 /*! |
|
907 Changes enabled state of station buttons. |
|
908 */ |
|
909 void RadioHsWidget::enableStationButtons() |
|
910 { |
|
911 LEVEL2(LOG_METHOD_ENTER); |
|
912 if ((mFavoriteStationCount > 1) || (mFavoriteStationCount == 1 |
|
913 && !mCurrentStationIsFavorite)) { |
|
914 changeButtonToEnabled(Next); |
|
915 changeButtonToEnabled(Previous); |
|
916 } |
|
917 else if ((mFavoriteStationCount == 1 && mCurrentStationIsFavorite) |
|
918 || (mFavoriteStationCount < 1)) { |
|
919 changeButtonToDisabled(Next); |
|
920 changeButtonToDisabled(Previous); |
|
921 } |
|
922 } |
|
923 |
|
924 /*! |
|
925 Makes homescreen specific push button based on parameters. |
|
926 |
|
927 \param target Target push button to modify. Must not be NULL. |
|
928 \param graphicsId Defines the target button background graphics. |
|
929 \param suffix Defines the suffix for the target button background graphics. |
|
930 \param icon Defines the icon for the target button. |
|
931 \param iconColor Defines the icon color for the target button. |
|
932 */ |
|
933 void RadioHsWidget::defineButton(HbPushButton &target, const QString &graphicsId, |
|
934 const QStringList &suffix, const QString &icon, const QString &iconColor) |
|
935 { |
|
936 LEVEL2(LOG_METHOD); |
|
937 HbFrameDrawer* drawer = NULL; |
|
938 |
|
939 // First check if the drawer is already created for this push button |
|
940 if (!target.frameBackground()) { |
|
941 LEVEL2(LOG("Creating new frame background.")); |
|
942 // Nope, create one now |
|
943 drawer = new HbFrameDrawer(graphicsId, |
|
944 HbFrameDrawer::ThreePiecesHorizontal); |
|
945 target.setFrameBackground(drawer); |
|
946 } |
|
947 else { |
|
948 // Frame drawer already created, only need to update frame graphics |
|
949 drawer = target.frameBackground(); |
|
950 drawer->setFrameGraphicsName(graphicsId); |
|
951 } |
|
952 |
|
953 // Set file name suffix list, so that drawer can load correct 3-piece graphic files |
|
954 drawer->setFileNameSuffixList(suffix); |
|
955 |
|
956 // Set the icon, if it is not NULL |
|
957 if (!icon.isNull()) { |
|
958 target.setIcon(HbIcon(icon)); |
|
959 } |
|
960 |
|
961 // Update also the icon color |
|
962 QColor color = HbColorScheme::color(iconColor); |
|
963 target.icon().setColor(color); |
|
964 |
|
965 // Lastly, check if the buttton is disabled |
|
966 if (iconColor == CONTROL_BUTTON_ICON_COLOR_DISABLED) { |
|
967 target.setEnabled(false); |
|
968 } |
|
969 else { |
|
970 target.setEnabled(true); |
|
971 } |
|
972 } |
|
973 |
|
974 /*! |
|
975 Prepares the information needed for displaying the button correctly |
|
976 reflecting its state. |
|
977 |
|
978 \param buttonId Identifies the button. |
|
979 \param state Tells in what state the button is. |
|
980 */ |
|
981 void RadioHsWidget::buttonEvent(ControlButtonIdentifier buttonId, |
|
982 const ControlButtonState state) |
|
983 { |
|
984 LEVEL2(LOG_METHOD); |
|
985 HbPushButton* target = NULL; |
|
986 QStringList suffix; |
|
987 QString icon; |
|
988 |
|
989 switch (buttonId) { |
|
990 case Power: |
|
991 LEVEL2(LOG("Power")); |
|
992 target = mPowerButton; |
|
993 icon = POWER_BUTTON_ICON_ON; |
|
994 suffix = POWER_BUTTON_SUFFIX; |
|
995 break; |
|
996 case Previous: |
|
997 LEVEL2(LOG("Previous")); |
|
998 target = mPreviousButton; |
|
999 suffix = PREVIOUS_BUTTON_SUFFIX; |
|
1000 break; |
|
1001 case Next: |
|
1002 LEVEL2(LOG("Next")); |
|
1003 target = mNextButton; |
|
1004 suffix = NEXT_BUTTON_SUFFIX; |
|
1005 break; |
|
1006 default: |
|
1007 LOG("default case at buttonId"); |
|
1008 break; |
|
1009 } |
|
1010 |
|
1011 QString buttonBackgroundGraphics; |
|
1012 QString buttonIconColors; |
|
1013 switch (state) { |
|
1014 case Normal: |
|
1015 LEVEL2(LOG("Normal")); |
|
1016 target->setProperty("state", "normal"); |
|
1017 buttonBackgroundGraphics = CONTROL_BUTTON_GRAPHICS_NORMAL; |
|
1018 buttonIconColors = CONTROL_BUTTON_ICON_COLOR_NORMAL; |
|
1019 break; |
|
1020 case Pressed: |
|
1021 LEVEL2(LOG("Pressed")); |
|
1022 target->setProperty("state", "pressed"); |
|
1023 buttonBackgroundGraphics = CONTROL_BUTTON_GRAPHICS_PRESSED; |
|
1024 buttonIconColors = CONTROL_BUTTON_ICON_COLOR_PRESSED; |
|
1025 break; |
|
1026 case Disabled: |
|
1027 LEVEL2(LOG("Disabled")); |
|
1028 target->setProperty("state", "disabled"); |
|
1029 buttonBackgroundGraphics = CONTROL_BUTTON_GRAPHICS_DISABLED; |
|
1030 buttonIconColors = CONTROL_BUTTON_ICON_COLOR_DISABLED; |
|
1031 break; |
|
1032 case Latched: |
|
1033 LEVEL2(LOG("Latched")); |
|
1034 target->setProperty("state", "latched"); |
|
1035 buttonBackgroundGraphics = CONTROL_BUTTON_GRAPHICS_LATCHED; |
|
1036 buttonIconColors = CONTROL_BUTTON_ICON_COLOR_LATCHED; |
|
1037 break; |
|
1038 default: |
|
1039 LOG("default case at button state"); |
|
1040 break; |
|
1041 } |
|
1042 |
|
1043 RadioHsWidget::defineButton(*target, buttonBackgroundGraphics, |
|
1044 suffix, icon, buttonIconColors); |
|
1045 } |
|
1046 |
|
1047 /*! |
|
1048 Disables specified push button. |
|
1049 |
|
1050 \param hsButtonIdentifier Which button is to be disabled. |
|
1051 */ |
|
1052 void RadioHsWidget::changeButtonToDisabled(int hsButtonIdentifier) |
|
1053 { |
|
1054 LEVEL2(LOG_METHOD_ENTER); |
|
1055 buttonEvent(static_cast<ControlButtonIdentifier>(hsButtonIdentifier), Disabled); |
|
1056 } |
|
1057 |
|
1058 /*! |
|
1059 Enabled specified push button. |
|
1060 |
|
1061 \param hsButtonIdentifier Which button is to be enabled. |
|
1062 */ |
|
1063 void RadioHsWidget::changeButtonToEnabled(int hsButtonIdentifier) |
|
1064 { |
|
1065 LEVEL2(LOG_METHOD_ENTER); |
|
1066 changeButtonToReleased(hsButtonIdentifier); |
|
1067 } |
|
1068 |
|
1069 /*! |
|
1070 Checks the profile of the device. If profile is offline, user is asked a |
|
1071 permission to start the radio in offline profile. Dialog is shown on |
|
1072 behalf of the radio asking the permission. |
|
1073 |
|
1074 \returns \c true if radio can be started, \c false if device is in |
|
1075 offline profile and user didn't gave permission to start the radio. |
|
1076 */ |
|
1077 bool RadioHsWidget::radioStartPermission() |
|
1078 { |
|
1079 LOG_METHOD_ENTER; |
|
1080 // This is true by default because we might not be in offline profile and |
|
1081 // starting the radio is allowed in other profiles without asking a |
|
1082 // permission. |
|
1083 bool radioStartPermssion = true; |
|
1084 if (mProfileMonitor->isCurrentProfileOffline()) { |
|
1085 // Device is in offline profile, ask the user for permission to start |
|
1086 HbDeviceMessageBox box(hbTrId( |
|
1087 "txt_fmradiohswidget_rad_info_activate_radio_in_offline_mode_hs"), |
|
1088 HbMessageBox::MessageTypeQuestion); |
|
1089 box.setTimeout(HbPopup::NoTimeout); |
|
1090 box.exec(); |
|
1091 // radioStartPermssion is now true or false, depending what the user |
|
1092 // selected. If user didn't gave permission, then radio is not |
|
1093 // started. |
|
1094 radioStartPermssion = box.isAcceptAction(box.triggeredAction()); |
|
1095 } |
|
1096 return radioStartPermssion; |
|
1097 } |